diff options
| author | George Florea Bănuș <[email protected]> | 2024-05-08 08:11:56 +0000 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2024-05-08 08:11:56 +0000 |
| commit | 65d7ef184acf97e7881050df88ddace97bde4b93 (patch) | |
| tree | 867a15204eca1e88420e7e707389936ac0bed3c7 /src/dolphinmainwindow.cpp | |
| parent | d42fec2315f4b32f7dbc74a00155f7e6abff7738 (diff) | |
view: Add setting to trigger user set action with double click
Default action is select-all.
Diffstat (limited to 'src/dolphinmainwindow.cpp')
| -rw-r--r-- | src/dolphinmainwindow.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 05fbb41b2..10dc9375d 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -40,6 +40,7 @@ #include <KColorSchemeManager> #include <KConfig> #include <KConfigGui> +#include <KDialogJobUiDelegate> #include <KDualAction> #include <KFileItemListProperties> #include <KIO/CommandLauncherJob> @@ -81,6 +82,7 @@ #include <QTimer> #include <QToolButton> #include <QtConcurrentRun> +#include <dolphindebug.h> #include <algorithm> @@ -2586,6 +2588,7 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer *container) connect(view, &DolphinView::goForwardRequested, this, &DolphinMainWindow::goForward); connect(view, &DolphinView::urlActivated, this, &DolphinMainWindow::handleUrl); connect(view, &DolphinView::goUpRequested, this, &DolphinMainWindow::goUp); + connect(view, &DolphinView::doubleClickViewBackground, this, &DolphinMainWindow::slotDoubleClickViewBackground); connect(container->urlNavigatorInternalWithHistory(), &KUrlNavigator::urlChanged, this, &DolphinMainWindow::changeUrl); connect(container->urlNavigatorInternalWithHistory(), &KUrlNavigator::historyChanged, this, &DolphinMainWindow::updateHistory); @@ -2902,4 +2905,38 @@ bool DolphinMainWindow::isItemVisibleInAnyView(const QString &urlOfItem) return m_tabWidget->isItemVisibleInAnyView(QUrl::fromUserInput(urlOfItem)); } +void DolphinMainWindow::slotDoubleClickViewBackground(Qt::MouseButton button) +{ + Q_UNUSED(button) // might be of use later + + GeneralSettings *settings = GeneralSettings::self(); + QString clickAction = settings->doubleClickViewAction(); + + DolphinView *view = activeViewContainer()->view(); + if (view == nullptr || clickAction == "none") { + return; + } + + if (clickAction == customCommand) { + // run custom command set by the user + QString path = view->url().toLocalFile(); + QString clickCustomAction = settings->doubleClickViewCustomAction(); + clickCustomAction.replace("{path}", path.prepend('"').append('"')); + + m_job = new KIO::CommandLauncherJob(clickCustomAction); + m_job->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this)); + m_job->start(); + + } else { + // get the action set by the user and trigger it + const KActionCollection *actions = actionCollection(); + QAction *action = actions->action(clickAction); + if (action == nullptr) { + qCWarning(DolphinDebug) << QStringLiteral("Double-click view: action `%1` was not found").arg(clickAction); + return; + } + action->trigger(); + } +} + #include "moc_dolphinmainwindow.cpp" |
