diff options
| -rwxr-xr-x | appiumtests/dolphintest.py | 32 | ||||
| -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 |
7 files changed, 66 insertions, 0 deletions
diff --git a/appiumtests/dolphintest.py b/appiumtests/dolphintest.py index f0df3941e..2f1d3c6bf 100755 --- a/appiumtests/dolphintest.py +++ b/appiumtests/dolphintest.py @@ -95,6 +95,38 @@ class DolphinTests(unittest.TestCase): self.assertEqual(len(elements), 2) self.assertEqual(elements[0].text, "test1.txt") self.assertEqual(elements[1].text, "test2.txt") + + def test_3_autovalidate_url(self): + dolphinBackground = self.driver.find_element( + by=AppiumBy.ACCESSIBILITY_ID, + value="DolphinViewContainer.DolphinView.KItemListContainer" + ) + + editButton = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value="KUrlNavigatorToggleButton") + editButton.click() + + # clear contents + clearButton = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value="DolphinUrlNavigator.KUrlComboBox.KLineEdit.QLineEditIconButton") + clearButton.click() + + locationBar = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value="DolphinUrlNavigator.KUrlComboBox.KLineEdit") + locationBar.send_keys("{}/testDir".format(os.environ["HOME"])) + + # Move to the bottom right at 50px of the border to ensure not clicking on items + rect = dolphinBackground.rect + x = rect['width'] - 50 + y = rect['height'] - 50 + + actions = ActionChains(self.driver) + actions.move_to_element_with_offset(dolphinBackground, x, y).click().perform() + + # Check if the button visible on edit mode has been hidden + self.assertFalse(clearButton.is_displayed()) + + elements = self.driver.find_elements(by=AppiumBy.XPATH, value="//table_cell") + self.assertEqual(len(elements), 2) + self.assertEqual(elements[0].text, "test1.txt") + self.assertEqual(elements[1].text, "test2.txt") """ 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. */ |
