]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Add action to places panel context menu trash entry to open trash settings
authorSaravanan K <saravanank90@yahoo.com>
Thu, 20 May 2021 16:04:41 +0000 (16:04 +0000)
committerNate Graham <nate@kde.org>
Thu, 20 May 2021 16:04:41 +0000 (16:04 +0000)
BUG: 367583
FIXED-IN: 21.08

src/panels/places/placespanel.cpp
src/settings/dolphinsettingsdialog.cpp
src/settings/dolphinsettingsdialog.h

index d49ad39ec49fd59e7960641765930f5fa99b623e..1f5f0260faba5b01e6ccb7e8dd5a5b0a26af40ab 100644 (file)
@@ -23,6 +23,7 @@
 #include "placesview.h"
 #include "trash/dolphintrash.h"
 #include "views/draganddrophelper.h"
+#include "settings/dolphinsettingsdialog.h"
 
 #include <KFilePlaceEditDialog>
 #include <KFilePlacesModel>
@@ -181,6 +182,7 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
     QMenu menu(this);
 
     QAction* emptyTrashAction = nullptr;
+    QAction* configureTrashAction = nullptr;
     QAction* editAction = nullptr;
     QAction* teardownAction = nullptr;
     QAction* ejectAction = nullptr;
@@ -200,7 +202,7 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
     if (item->url().isLocalFile()) {
         propertiesAction = menu.addAction(QIcon::fromTheme(QStringLiteral("document-properties")), i18nc("@action:inmenu", "Properties"));
     }
-    if (!isDevice && !isTrash) {
+    if (!isDevice) {
         menu.addSeparator();
     }
     
@@ -236,6 +238,10 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
         }
     }
 
+    if (isTrash) {
+        configureTrashAction = menu.addAction(QIcon::fromTheme(QStringLiteral("configure")), i18nc("@action:inmenu", "Configure Trash..."));
+    }
+
     if (!isDevice) {
         editAction = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-entry")), i18nc("@item:inmenu", "Edit..."));
     }
@@ -255,6 +261,11 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
     if (action) {
         if (action == emptyTrashAction) {
             Trash::empty(this);
+        } else if (action == configureTrashAction) {
+            DolphinSettingsDialog* settingsDialog = new DolphinSettingsDialog(item->url(), this);
+            settingsDialog->setCurrentPage(settingsDialog->trashSettings);
+            settingsDialog->setAttribute(Qt::WA_DeleteOnClose);
+            settingsDialog->show();
         } else {
             // The index might have changed if devices were added/removed while
             // the context menu was open.
index 0303e59069ec58a89b372f8cec164a18251c573b..281cb7ba582405e9b5f74c945582cff018cd3ee1 100644 (file)
@@ -99,9 +99,9 @@ DolphinSettingsDialog::DolphinSettingsDialog(const QUrl& url, QWidget* parent, K
     trashSettingsPage = createTrashSettingsPage(this);
 #endif
     if (trashSettingsPage) {
-        KPageWidgetItem* trashSettingsFrame = addPage(trashSettingsPage,
+        trashSettings = addPage(trashSettingsPage,
                                                      i18nc("@title:group", "Trash"));
-        trashSettingsFrame->setIcon(QIcon::fromTheme(QStringLiteral("user-trash")));
+        trashSettings->setIcon(QIcon::fromTheme(QStringLiteral("user-trash")));
         connect(trashSettingsPage, &TrashSettingsPage::changed, this, &DolphinSettingsDialog::enableApply);
     }
 
index 65ce95274edf3f8cb8ebac9c77e5453781cfc6a3..f9a5652eaa430d2de6c090c2f0d0e9e501c5fbb2 100644 (file)
@@ -26,6 +26,8 @@ public:
     explicit DolphinSettingsDialog(const QUrl& url, QWidget* parent = nullptr, KActionCollection* actions = {});
     ~DolphinSettingsDialog() override;
 
+    KPageWidgetItem* trashSettings;
+
 Q_SIGNALS:
     void settingsChanged();