mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 10:22:52 +00:00
ark: mark URL as modified in the part upon adding or deleting
required the following commit from kdelibs to actually save: 319ebf4d2089a167b2a9e1f746eb52cd54dec150 Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
763d88a96d
commit
bc2a235c3b
3 changed files with 59 additions and 32 deletions
|
@ -251,9 +251,10 @@ void MainWindow::newArchive()
|
|||
|
||||
kDebug() << "Supported mimetypes are" << mimeTypes.join( QLatin1String( " " ));
|
||||
|
||||
const KUrl saveFileUrl =
|
||||
KFileDialog::getSaveUrl(KUrl("kfiledialog:///ArkNewDir"),
|
||||
mimeTypes.join(QLatin1String(" ")));
|
||||
const KUrl saveFileUrl = KFileDialog::getSaveUrl(
|
||||
KUrl("kfiledialog:///ArkNewDir"),
|
||||
mimeTypes.join(QLatin1String(" "))
|
||||
);
|
||||
|
||||
m_openArgs.metaData()[QLatin1String( "createNewArchive" )] = QLatin1String( "true" );
|
||||
|
||||
|
|
|
@ -390,29 +390,37 @@ KAboutData* Part::createAboutData()
|
|||
|
||||
bool Part::openFile()
|
||||
{
|
||||
const QString localFile(localFilePath());
|
||||
const QString localFile = localFilePath();
|
||||
const QFileInfo localFileInfo(localFile);
|
||||
const bool creatingNewArchive =
|
||||
arguments().metaData()[QLatin1String("createNewArchive")] == QLatin1String("true");
|
||||
|
||||
if (localFileInfo.isDir()) {
|
||||
KMessageBox::error(NULL, i18nc("@info",
|
||||
"<tt>%1</tt> is a directory.",
|
||||
localFile));
|
||||
KMessageBox::error(
|
||||
NULL,
|
||||
i18nc("@info", "<tt>%1</tt> is a directory.", localFile)
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (creatingNewArchive) {
|
||||
if (localFileInfo.exists()) {
|
||||
int overwrite = KMessageBox::questionYesNo(NULL, i18nc("@info", "The archive <tt>%1</tt> already exists. Would you like to open it instead?", localFile), i18nc("@title:window", "File Exists"), KGuiItem(i18n("Open File")), KStandardGuiItem::cancel());
|
||||
|
||||
int overwrite = KMessageBox::questionYesNo(
|
||||
NULL,
|
||||
i18nc("@info", "The archive <tt>%1</tt> already exists. Would you like to open it instead?", localFile),
|
||||
i18nc("@title:window", "File Exists"), KGuiItem(i18n("Open File")), KStandardGuiItem::cancel()
|
||||
);
|
||||
if (overwrite == KMessageBox::No) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!localFileInfo.exists()) {
|
||||
KMessageBox::sorry(NULL, i18nc("@info", "The archive <tt>%1</tt> was not found.", localFile), i18nc("@title:window", "Error Opening Archive"));
|
||||
KMessageBox::sorry(
|
||||
NULL,
|
||||
i18nc("@info", "The archive <tt>%1</tt> was not found.", localFile),
|
||||
i18nc("@title:window", "Error Opening Archive")
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -440,7 +448,7 @@ bool Part::openFile()
|
|||
QStringList mimeComments(mimeTypes.values());
|
||||
mimeComments.sort();
|
||||
|
||||
bool ok;
|
||||
bool ok = false;
|
||||
QString item;
|
||||
|
||||
if (creatingNewArchive) {
|
||||
|
@ -465,7 +473,11 @@ bool Part::openFile()
|
|||
}
|
||||
|
||||
if (!archive) {
|
||||
KMessageBox::sorry(NULL, i18nc("@info", "Ark was not able to open the archive <tt>%1</tt>. No plugin capable of handling the file was found.", localFile), i18nc("@title:window", "Error Opening Archive"));
|
||||
KMessageBox::sorry(
|
||||
NULL,
|
||||
i18nc("@info", "Ark was not able to open the archive <tt>%1</tt>. No plugin capable of handling the file was found.", localFile),
|
||||
i18nc("@title:window", "Error Opening Archive")
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -499,7 +511,11 @@ void Part::slotLoadingFinished(KJob *job)
|
|||
{
|
||||
if (job->error() != KJob::NoError) {
|
||||
if (arguments().metaData()[QLatin1String( "createNewArchive" )] != QLatin1String( "true" )) {
|
||||
KMessageBox::sorry(NULL, i18nc("@info", "Loading the archive <tt>%1</tt> failed with the following error: <i>%2</i>", localFilePath(), job->errorText()), i18nc("@title:window", "Error Opening Archive"));
|
||||
KMessageBox::sorry(
|
||||
NULL,
|
||||
i18nc("@info", "Loading the archive <tt>%1</tt> failed with the following error: <i>%2</i>", localFilePath(), job->errorText()),
|
||||
i18nc("@title:window", "Error Opening Archive")
|
||||
);
|
||||
|
||||
// The file failed to open, so reset the open archive, info panel and caption.
|
||||
m_model->setArchive(NULL);
|
||||
|
@ -585,8 +601,7 @@ void Part::slotPreviewExtracted(KJob *job)
|
|||
// if there's an error or an overwrite dialog,
|
||||
// the preview dialog will be launched anyway
|
||||
if (!job->error()) {
|
||||
const ArchiveEntry& entry =
|
||||
m_model->entryForIndex(m_view->selectionModel()->currentIndex());
|
||||
const ArchiveEntry& entry = m_model->entryForIndex(m_view->selectionModel()->currentIndex());
|
||||
|
||||
ExtractJob *extractJob = qobject_cast<ExtractJob*>(job);
|
||||
Q_ASSERT(extractJob);
|
||||
|
@ -799,8 +814,7 @@ void Part::slotAddFiles(const QStringList& filesToAdd, const QString& path)
|
|||
return;
|
||||
}
|
||||
|
||||
connect(job, SIGNAL(result(KJob*)),
|
||||
this, SLOT(slotAddFilesDone(KJob*)));
|
||||
connect(job, SIGNAL(result(KJob*)), this, SLOT(slotAddFilesDone(KJob*)));
|
||||
registerJob(job);
|
||||
job->start();
|
||||
}
|
||||
|
@ -842,6 +856,8 @@ void Part::slotAddFilesDone(KJob* job)
|
|||
{
|
||||
if (job->error() != KJob::NoError) {
|
||||
KMessageBox::error(widget(), job->errorString());
|
||||
} else {
|
||||
setModified();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -849,6 +865,8 @@ void Part::slotDeleteFilesDone(KJob* job)
|
|||
{
|
||||
if (job->error() != KJob::NoError) {
|
||||
KMessageBox::error(widget(), job->errorString());
|
||||
} else {
|
||||
setModified();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -869,8 +887,7 @@ void Part::slotDeleteFiles()
|
|||
}
|
||||
|
||||
DeleteJob *job = m_model->deleteFiles(selectedFilesWithChildren());
|
||||
connect(job, SIGNAL(result(KJob*)),
|
||||
this, SLOT(slotDeleteFilesDone(KJob*)));
|
||||
connect(job, SIGNAL(result(KJob*)), this, SLOT(slotDeleteFilesDone(KJob*)));
|
||||
registerJob(job);
|
||||
job->start();
|
||||
}
|
||||
|
@ -899,15 +916,20 @@ void Part::saveSplitterSizes()
|
|||
|
||||
void Part::slotSaveAs()
|
||||
{
|
||||
KUrl saveUrl = KFileDialog::getSaveUrl(KUrl(QLatin1String( "kfiledialog:///ArkSaveAs/" ) + url().fileName()), QString(), widget());
|
||||
KUrl saveUrl = KFileDialog::getSaveUrl(
|
||||
KUrl(QLatin1String( "kfiledialog:///ArkSaveAs/" ) + url().fileName()),
|
||||
QString(),
|
||||
widget()
|
||||
);
|
||||
|
||||
if ((saveUrl.isValid()) && (!saveUrl.isEmpty())) {
|
||||
if (KIO::NetAccess::exists(saveUrl, KIO::NetAccess::DestinationSide, widget())) {
|
||||
int overwrite = KMessageBox::warningContinueCancel(widget(),
|
||||
i18nc("@info", "An archive named <tt>%1</tt> already exists. Are you sure you want to overwrite it?", saveUrl.fileName()),
|
||||
QString(),
|
||||
KStandardGuiItem::overwrite());
|
||||
|
||||
int overwrite = KMessageBox::warningContinueCancel(
|
||||
widget(),
|
||||
i18nc("@info", "An archive named <tt>%1</tt> already exists. Are you sure you want to overwrite it?", saveUrl.fileName()),
|
||||
QString(),
|
||||
KStandardGuiItem::overwrite()
|
||||
);
|
||||
if (overwrite != KMessageBox::Continue) {
|
||||
return;
|
||||
}
|
||||
|
@ -917,9 +939,10 @@ void Part::slotSaveAs()
|
|||
|
||||
if (!QFile::exists(localFilePath())) {
|
||||
if (url().isLocalFile()) {
|
||||
KMessageBox::error(widget(),
|
||||
i18nc("@info", "The archive <tt>%1</tt> cannot be copied to the specified location. The archive does not exist anymore.", localFilePath()));
|
||||
|
||||
KMessageBox::error(
|
||||
widget(),
|
||||
i18nc("@info", "The archive <tt>%1</tt> cannot be copied to the specified location. The archive does not exist anymore.", localFilePath())
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
srcUrl = url();
|
||||
|
@ -929,8 +952,10 @@ void Part::slotSaveAs()
|
|||
KIO::Job *copyJob = KIO::file_copy(srcUrl, saveUrl, -1, KIO::Overwrite);
|
||||
|
||||
if (!KIO::NetAccess::synchronousRun(copyJob, widget())) {
|
||||
KMessageBox::error(widget(),
|
||||
i18nc("@info", "The archive could not be saved as <tt>%1</tt>. Try saving it to another location.", saveUrl.pathOrUrl()));
|
||||
KMessageBox::error(
|
||||
widget(),
|
||||
i18nc("@info", "The archive could not be saved as <tt>%1</tt>. Try saving it to another location.", saveUrl.pathOrUrl())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,10 +55,11 @@ public:
|
|||
|
||||
Part(QWidget *parentWidget, QObject *parent, const QVariantList &);
|
||||
~Part();
|
||||
|
||||
static KAboutData* createAboutData();
|
||||
|
||||
virtual bool openFile();
|
||||
virtual bool saveFile();
|
||||
bool openFile() final;
|
||||
bool saveFile() final;
|
||||
|
||||
bool isBusy() const;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue