diff options
| author | Florian RICHER <[email protected]> | 2026-05-15 17:29:46 +0200 |
|---|---|---|
| committer | Florian RICHER <[email protected]> | 2026-05-31 10:57:56 +0200 |
| commit | 2a72145eb09276a4576762b74cb976fcd4550e87 (patch) | |
| tree | c7be1a38ab004c12162edff698fceafe3d8e6488 /src | |
| parent | f622de7f00b6585c9a17e3ed208921582babf77e (diff) | |
dolphinview: Unselect navigator when click on background
Diffstat (limited to 'src')
| -rw-r--r-- | src/dolphinmainwindow.cpp | 12 | ||||
| -rw-r--r-- | src/dolphinmainwindow.h | 5 | ||||
| -rw-r--r-- | src/kitemviews/kitemlistcontroller.cpp | 4 | ||||
| -rw-r--r-- | src/kitemviews/kitemlistcontroller.h | 6 | ||||
| -rw-r--r-- | src/views/dolphinview.cpp | 1 | ||||
| -rw-r--r-- | src/views/dolphinview.h | 6 |
6 files changed, 34 insertions, 0 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index ebd811efa..439db8293 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -768,6 +768,17 @@ void DolphinMainWindow::slotSaveSession() } } +void DolphinMainWindow::slotClickViewBackground() +{ + auto navigators = static_cast<DolphinNavigatorsWidgetAction *>(actionCollection()->action(QStringLiteral("url_navigators"))); + KUrlNavigator *navigator = + m_tabWidget->currentTabPage()->primaryViewActive() ? navigators->primaryUrlNavigator() : navigators->secondaryUrlNavigator(); + + if (navigator->isUrlEditable() && !GeneralSettings::editableUrl()) { + navigator->setUrlEditable(false); + } +} + void DolphinMainWindow::setSessionAutoSaveEnabled(bool enable) { if (enable) { @@ -2791,6 +2802,7 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer *container) connect(view, &DolphinView::urlActivated, this, &DolphinMainWindow::handleUrl); connect(view, &DolphinView::goUpRequested, this, &DolphinMainWindow::goUp); connect(view, &DolphinView::doubleClickViewBackground, this, &DolphinMainWindow::slotDoubleClickViewBackground); + connect(view, &DolphinView::clickViewBackground, this, &DolphinMainWindow::slotClickViewBackground); connect(container->urlNavigatorInternalWithHistory(), &KUrlNavigator::urlChanged, this, &DolphinMainWindow::changeUrl); connect(container->urlNavigatorInternalWithHistory(), &KUrlNavigator::historyChanged, this, &DolphinMainWindow::updateHistory); diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index 4b2b0c87b..884b9f7bd 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -685,6 +685,11 @@ private Q_SLOTS: */ void slotSaveSession(); + /** + * Is called when the user clicks the active view's background. + */ + void slotClickViewBackground(); + private: /** * Sets up the various menus and actions and connects them. diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index 3250e570a..b1927fc71 100644 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -604,6 +604,10 @@ bool KItemListController::mousePressEvent(QGraphicsSceneMouseEvent *event, const const Qt::MouseButtons buttons = event->buttons(); + if (!m_pressedIndex.has_value()) { + Q_EMIT clickViewBackground(event->button()); + } + if (!onPress(event->pos(), event->modifiers(), buttons)) { startRubberBand(); return false; diff --git a/src/kitemviews/kitemlistcontroller.h b/src/kitemviews/kitemlistcontroller.h index 6379acbd8..38a4b6038 100644 --- a/src/kitemviews/kitemlistcontroller.h +++ b/src/kitemviews/kitemlistcontroller.h @@ -223,6 +223,12 @@ Q_SIGNALS: void swipeUp(); /** + * Emitted when the view's background is clicked. + * Used to trigger a user configured action. + */ + void clickViewBackground(Qt::MouseButton button); + + /** * Emitted when the view's background is double-clicked. * Used to trigger an user configured action. */ diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 74c5ecd23..97c1e926c 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -129,6 +129,7 @@ DolphinView::DolphinView(const QUrl &url, QWidget *parent) KItemListController *controller = new KItemListController(m_model, m_view, this); controller->setAutoActivationEnabled(GeneralSettings::autoExpandFolders()); + connect(controller, &KItemListController::clickViewBackground, this, &DolphinView::clickViewBackground); connect(controller, &KItemListController::doubleClickViewBackground, this, &DolphinView::doubleClickViewBackground); connect(controller, &KItemListController::typeAheadUsed, this, [this](const QString &typedString, std::optional<int> foundIndex) { if (foundIndex.has_value()) { diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index 9b068f92e..35276f9ac 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -730,6 +730,12 @@ Q_SIGNALS: void currentDirectoryRemoved(); /** + * Emitted when the view's background is clicked. + * Used to trigger a user configured action. + */ + void clickViewBackground(Qt::MouseButton button); + + /** * Emitted when the view's background is double-clicked. * Used to trigger an user configured action. */ |
