]> cloud.milkyroute.net Git - dolphin.git/commitdiff
DolphinView: get rid of writeStateChanged signal in setActive()
authorAmol Godbole <amolagodbole@gmail.com>
Wed, 11 Oct 2023 03:39:03 +0000 (22:39 -0500)
committerFelix Ernst <felixernst@kde.org>
Thu, 12 Oct 2023 09:43:37 +0000 (09:43 +0000)
The signal writeStateChanged() was not working because it is not connected
to slotWriteStateChanged() slots when the active view changes. Replace the
signal with direct calls to the slots.

Also, do not delay openRequest signal in DolphinSearchBox::slotSearchTextChanged.
It's no longer required.

BUG: 440366

src/dolphinmainwindow.cpp
src/search/dolphinsearchbox.cpp
src/views/dolphinview.cpp
src/views/dolphinview.h
src/views/dolphinviewactionhandler.cpp

index 744ad8f0aa980d6ea00ef5a09421efdff0194aa5..ca0038586951c2ea5a9a111401d6ce8106157278 100644 (file)
@@ -2387,6 +2387,7 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer *container)
 {
     connect(container, &DolphinViewContainer::showFilterBarChanged, this, &DolphinMainWindow::updateFilterBarAction);
     connect(container, &DolphinViewContainer::writeStateChanged, this, &DolphinMainWindow::slotWriteStateChanged);
+    slotWriteStateChanged(container->view()->isFolderWritable());
     connect(container, &DolphinViewContainer::searchModeEnabledChanged, this, &DolphinMainWindow::updateSearchAction);
     connect(container, &DolphinViewContainer::captionChanged, this, &DolphinMainWindow::updateWindowTitle);
     connect(container, &DolphinViewContainer::tabRequested, this, &DolphinMainWindow::openNewTab);
index a09f252937e7853451a4fac160646636d4fd217c..a3cec6fe7e1ea4ea55e51d34a11943cab2d2a38e 100644 (file)
@@ -265,9 +265,7 @@ void DolphinSearchBox::slotSearchTextChanged(const QString &text)
     if (text.isEmpty()) {
         // Restore URL when search box is cleared by closing and reopening the box.
         emitCloseRequest();
-        QTimer::singleShot(0, this, [this] {
-            Q_EMIT openRequest();
-        });
+        Q_EMIT openRequest();
     } else {
         m_startSearchTimer->start();
     }
index d8eab142d54f4f37860337893e0089f6bb741bca..ace763b153167949f3b61733701c09a7528441d6 100644 (file)
@@ -270,7 +270,6 @@ void DolphinView::setActive(bool active)
     if (active) {
         m_container->setFocus();
         Q_EMIT activated();
-        Q_EMIT writeStateChanged(m_isFolderWritable);
     }
 }
 
@@ -2246,6 +2245,11 @@ void DolphinView::updateWritableState()
     }
 }
 
+bool DolphinView::isFolderWritable() const
+{
+    return m_isFolderWritable;
+}
+
 QUrl DolphinView::viewPropertiesUrl() const
 {
     if (m_viewPropertiesContext.isEmpty()) {
index 05b9e009c058eb4b33ceaea44c29962c97bc941b..0b0c83487680725a6aaadd20919994f23542b911 100644 (file)
@@ -344,6 +344,11 @@ public:
     /** Activates the view if the item list container gets focus. */
     bool eventFilter(QObject *watched, QEvent *event) override;
 
+    /**
+     * Returns whether the folder represented by the current URL is writable.
+     */
+    bool isFolderWritable() const;
+
 public Q_SLOTS:
 
     void reload();
@@ -880,7 +885,7 @@ private:
     /**
      * Updates m_isFolderWritable dependent on whether the folder represented by
      * the current URL is writable. If the state has changed, the signal
-     * writeableStateChanged() will be emitted.
+     * writeStateChanged() will be emitted.
      */
     void updateWritableState();
 
index 7117e9e1b811d930efd5ade9b49318de5a2520bf..f73c613e0a57dc774fd62665ce4755788ffa9205 100644 (file)
@@ -60,6 +60,7 @@ void DolphinViewActionHandler::setCurrentView(DolphinView *view)
     connect(view, &DolphinView::sortRoleChanged, this, &DolphinViewActionHandler::slotSortRoleChanged);
     connect(view, &DolphinView::zoomLevelChanged, this, &DolphinViewActionHandler::slotZoomLevelChanged);
     connect(view, &DolphinView::writeStateChanged, this, &DolphinViewActionHandler::slotWriteStateChanged);
+    slotWriteStateChanged(view->isFolderWritable());
     connect(view, &DolphinView::selectionModeChangeRequested, this, [this](bool enabled) {
         Q_EMIT selectionModeChangeTriggered(enabled);
     });