]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinview.cpp
Fixed build-time deprecation warning about KStandardGuiItem::yes()
[dolphin.git] / src / views / dolphinview.cpp
index 4e5f4c7863a2023555f60b71270ad123db2252bc..1da3ebf858c5b5114e56f467510fe2c739d88264 100644 (file)
 
 #include <kwidgetsaddons_version.h>
 
+#include <kio_version.h>
+#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0)
+#include <KIO/DeleteOrTrashJob>
+#endif
+
 #include <QAbstractItemView>
 #include <QActionGroup>
 #include <QApplication>
@@ -753,6 +758,13 @@ void DolphinView::renameSelectedItems()
 void DolphinView::trashSelectedItems()
 {
     const QList<QUrl> 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)) {
@@ -762,12 +774,19 @@ void DolphinView::trashSelectedItems()
         connect(job, &KIO::Job::result,
                 this, &DolphinView::slotTrashFileFinished);
     }
+#endif
 }
 
 void DolphinView::deleteSelectedItems()
 {
     const QList<QUrl> 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)) {
@@ -776,6 +795,7 @@ void DolphinView::deleteSelectedItems()
         connect(job, &KIO::Job::result,
                 this, &DolphinView::slotDeleteFileFinished);
     }
+#endif
 }
 
 void DolphinView::cutSelectedItemsToClipboard()
@@ -1886,8 +1906,7 @@ 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,