mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
Add action to places panel context menu trash entry to open trash settings
BUG: 367583 FIXED-IN: 21.08
This commit is contained in:
parent
2e536476dd
commit
6b64c7ff56
|
@ -23,6 +23,7 @@
|
||||||
#include "placesview.h"
|
#include "placesview.h"
|
||||||
#include "trash/dolphintrash.h"
|
#include "trash/dolphintrash.h"
|
||||||
#include "views/draganddrophelper.h"
|
#include "views/draganddrophelper.h"
|
||||||
|
#include "settings/dolphinsettingsdialog.h"
|
||||||
|
|
||||||
#include <KFilePlaceEditDialog>
|
#include <KFilePlaceEditDialog>
|
||||||
#include <KFilePlacesModel>
|
#include <KFilePlacesModel>
|
||||||
|
@ -181,6 +182,7 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
|
||||||
QMenu menu(this);
|
QMenu menu(this);
|
||||||
|
|
||||||
QAction* emptyTrashAction = nullptr;
|
QAction* emptyTrashAction = nullptr;
|
||||||
|
QAction* configureTrashAction = nullptr;
|
||||||
QAction* editAction = nullptr;
|
QAction* editAction = nullptr;
|
||||||
QAction* teardownAction = nullptr;
|
QAction* teardownAction = nullptr;
|
||||||
QAction* ejectAction = nullptr;
|
QAction* ejectAction = nullptr;
|
||||||
|
@ -200,7 +202,7 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
|
||||||
if (item->url().isLocalFile()) {
|
if (item->url().isLocalFile()) {
|
||||||
propertiesAction = menu.addAction(QIcon::fromTheme(QStringLiteral("document-properties")), i18nc("@action:inmenu", "Properties"));
|
propertiesAction = menu.addAction(QIcon::fromTheme(QStringLiteral("document-properties")), i18nc("@action:inmenu", "Properties"));
|
||||||
}
|
}
|
||||||
if (!isDevice && !isTrash) {
|
if (!isDevice) {
|
||||||
menu.addSeparator();
|
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) {
|
if (!isDevice) {
|
||||||
editAction = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-entry")), i18nc("@item:inmenu", "Edit..."));
|
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) {
|
||||||
if (action == emptyTrashAction) {
|
if (action == emptyTrashAction) {
|
||||||
Trash::empty(this);
|
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 {
|
} else {
|
||||||
// The index might have changed if devices were added/removed while
|
// The index might have changed if devices were added/removed while
|
||||||
// the context menu was open.
|
// the context menu was open.
|
||||||
|
|
|
@ -99,9 +99,9 @@ DolphinSettingsDialog::DolphinSettingsDialog(const QUrl& url, QWidget* parent, K
|
||||||
trashSettingsPage = createTrashSettingsPage(this);
|
trashSettingsPage = createTrashSettingsPage(this);
|
||||||
#endif
|
#endif
|
||||||
if (trashSettingsPage) {
|
if (trashSettingsPage) {
|
||||||
KPageWidgetItem* trashSettingsFrame = addPage(trashSettingsPage,
|
trashSettings = addPage(trashSettingsPage,
|
||||||
i18nc("@title:group", "Trash"));
|
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);
|
connect(trashSettingsPage, &TrashSettingsPage::changed, this, &DolphinSettingsDialog::enableApply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@ public:
|
||||||
explicit DolphinSettingsDialog(const QUrl& url, QWidget* parent = nullptr, KActionCollection* actions = {});
|
explicit DolphinSettingsDialog(const QUrl& url, QWidget* parent = nullptr, KActionCollection* actions = {});
|
||||||
~DolphinSettingsDialog() override;
|
~DolphinSettingsDialog() override;
|
||||||
|
|
||||||
|
KPageWidgetItem* trashSettings;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void settingsChanged();
|
void settingsChanged();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue