X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/4d81aabd1ee78c2fca61452ef3a866cfad0c88a5..628a2bbb64d08e5aff524b264847699a1f55a611:/src/views/dolphinview.cpp diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 590fe336b..5f331dc27 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -47,6 +47,13 @@ #include #include +#include + +#include +#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0) +#include +#endif + #include #include #include @@ -188,6 +195,7 @@ DolphinView::DolphinView(const QUrl& url, QWidget* parent) : connect(m_model, &KFileItemModel::directoryRedirection, this, &DolphinView::slotDirectoryRedirection); connect(m_model, &KFileItemModel::urlIsFileError, this, &DolphinView::urlIsFileError); connect(m_model, &KFileItemModel::fileItemsChanged, this, &DolphinView::fileItemsChanged); + connect(m_model, &KFileItemModel::currentDirectoryRemoved, this, &DolphinView::currentDirectoryRemoved); connect(this, &DolphinView::itemCountChanged, this, &DolphinView::updatePlaceholderLabel); @@ -751,6 +759,13 @@ void DolphinView::renameSelectedItems() void DolphinView::trashSelectedItems() { const QList list = simplifiedSelectedUrls(); + +#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0) + using Iface = KIO::AskUserActionInterface; + auto *trashJob = new KIO::DeleteOrTrashJob(list, Iface::Trash, Iface::DefaultConfirmation, this); + connect(trashJob, &KJob::result, this, &DolphinView::slotTrashFileFinished); + trashJob->start(); +#else KIO::JobUiDelegate uiDelegate; uiDelegate.setWindow(window()); if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Trash, KIO::JobUiDelegate::DefaultConfirmation)) { @@ -760,12 +775,19 @@ void DolphinView::trashSelectedItems() connect(job, &KIO::Job::result, this, &DolphinView::slotTrashFileFinished); } +#endif } void DolphinView::deleteSelectedItems() { const QList list = simplifiedSelectedUrls(); +#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0) + using Iface = KIO::AskUserActionInterface; + auto *trashJob = new KIO::DeleteOrTrashJob(list, Iface::Delete, Iface::DefaultConfirmation, this); + connect(trashJob, &KJob::result, this, &DolphinView::slotTrashFileFinished); + trashJob->start(); +#else KIO::JobUiDelegate uiDelegate; uiDelegate.setWindow(window()); if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Delete, KIO::JobUiDelegate::DefaultConfirmation)) { @@ -774,6 +796,7 @@ void DolphinView::deleteSelectedItems() connect(job, &KIO::Job::result, this, &DolphinView::slotDeleteFileFinished); } +#endif } void DolphinView::cutSelectedItemsToClipboard() @@ -1017,11 +1040,19 @@ void DolphinView::slotItemsActivated(const KItemSet &indexes) if (indexes.count() > 5) { QString question = i18np("Are you sure you want to open 1 item?", "Are you sure you want to open %1 items?", indexes.count()); +#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0) + const int answer = KMessageBox::warningTwoActions(this, question, {}, +#else const int answer = KMessageBox::warningYesNo(this, question, {}, +#endif KGuiItem(i18ncp("@action:button", "Open %1 Item", "Open %1 Items", indexes.count()), QStringLiteral("document-open")), KStandardGuiItem::cancel()); +#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0) + if (answer != KMessageBox::PrimaryAction) { +#else if (answer != KMessageBox::Yes) { +#endif return; } } @@ -1876,10 +1907,13 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con #ifndef Q_OS_WIN //Confirm hiding file/directory by renaming inline if (!hiddenFilesShown() && newName.startsWith(QLatin1Char('.')) && !oldItem.name().startsWith(QLatin1Char('.'))) { - KGuiItem yesGuiItem(KStandardGuiItem::yes()); - yesGuiItem.setText(i18nc("@action:button", "Rename and Hide")); + KGuiItem yesGuiItem(i18nc("@action:button", "Rename and Hide"), QStringLiteral("view-hidden")); +#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0) + const auto code = KMessageBox::questionTwoActions(this, +#else const auto code = KMessageBox::questionYesNo(this, +#endif oldItem.isFile() ? i18n("Adding a dot to the beginning of this file's name will hide it from view.\n" "Do you still want to rename it?") : i18n("Adding a dot to the beginning of this folder's name will hide it from view.\n" @@ -1890,7 +1924,11 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con QStringLiteral("ConfirmHide") ); +#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0) + if (code == KMessageBox::SecondaryAction) { +#else if (code == KMessageBox::No) { +#endif return; } }