]> cloud.milkyroute.net Git - dolphin.git/commitdiff
DolphinView: Remove -1 interval, add setAutoActivationEnabled
authorAkseli Lahtinen <akselmo@akselmo.dev>
Fri, 9 May 2025 10:34:30 +0000 (13:34 +0300)
committerAkseli Lahtinen <akselmo@akselmo.dev>
Fri, 9 May 2025 10:34:30 +0000 (13:34 +0300)
In future Qt versions, Qt Timers do not allow negative intervals.
Instead, they will be changed to 1.

Related Qt commit:
https://github.com/qt/qtbase/commit/f1f610bc67bfd5c2ef31270a6945e7bae93b5e4a

Instead of relying on the interval, use a boolean variable
to check if the autoactivation is enabled or not.

src/kitemviews/kitemlistcontroller.cpp
src/kitemviews/kitemlistcontroller.h
src/panels/folders/folderspanel.cpp
src/views/dolphinview.cpp

index 2f1bdc551df3bc071094e415eed870b805d4123a..cd60c3a41b8ab96ad479d3cf74a5d9910df532d2 100644 (file)
@@ -64,7 +64,7 @@ KItemListController::KItemListController(KItemModelBase *model, KItemListView *v
 
     m_autoActivationTimer = new QTimer(this);
     m_autoActivationTimer->setSingleShot(true);
-    m_autoActivationTimer->setInterval(-1);
+    m_autoActivationTimer->setInterval(750);
     connect(m_autoActivationTimer, &QTimer::timeout, this, &KItemListController::slotAutoActivationTimeout);
 
     setModel(model);
@@ -200,14 +200,14 @@ int KItemListController::indexCloseToMousePressedPosition() const
     return -1;
 }
 
-void KItemListController::setAutoActivationDelay(int delay)
+void KItemListController::setAutoActivationEnabled(bool enabled)
 {
-    m_autoActivationTimer->setInterval(delay);
+    m_autoActivationEnabled = enabled;
 }
 
-int KItemListController::autoActivationDelay() const
+bool KItemListController::isAutoActivationEnabled() const
 {
-    return m_autoActivationTimer->interval();
+    return m_autoActivationEnabled;
 }
 
 void KItemListController::setSingleClickActivationEnforced(bool singleClick)
@@ -857,7 +857,7 @@ bool KItemListController::dragMoveEvent(QGraphicsSceneDragDropEvent *event, cons
                 Q_EMIT itemHovered(index);
             }
 
-            if (!m_autoActivationTimer->isActive() && m_autoActivationTimer->interval() >= 0 && m_model->canEnterOnHover(index)) {
+            if (m_autoActivationEnabled && !m_autoActivationTimer->isActive() && m_model->canEnterOnHover(index)) {
                 m_autoActivationTimer->setProperty("index", index);
                 m_autoActivationTimer->start();
                 newHoveredWidget->startActivateSoonAnimation(m_autoActivationTimer->remainingTime());
index fcb971fb7ff81d68b641741636f5b40b07858256..48da07206df1231647b855a9aee48b7b4a23672b 100644 (file)
@@ -88,23 +88,8 @@ public:
 
     int indexCloseToMousePressedPosition() const;
 
-    /**
-     * Sets the delay in milliseconds when dragging an object above an item
-     * until the item gets activated automatically. A value of -1 indicates
-     * that no automatic activation will be done at all (= default value).
-     *
-     * The hovered item must support dropping (see KItemModelBase::supportsDropping()),
-     * otherwise the automatic activation is not available.
-     *
-     * After activating the item the signal itemActivated() will be
-     * emitted. If the view supports the expanding of items
-     * (KItemListView::supportsItemExpanding() returns true) and the item
-     * itself is expandable (see KItemModelBase::isExpandable()) then instead
-     * of activating the item it gets expanded instead (see
-     * KItemModelBase::setExpanded()).
-     */
-    void setAutoActivationDelay(int delay);
-    int autoActivationDelay() const;
+    void setAutoActivationEnabled(bool enabled);
+    bool isAutoActivationEnabled() const;
 
     /**
      * If set to true, the signals itemActivated() and itemsActivated() are emitted
@@ -362,6 +347,7 @@ private:
     std::optional<int> m_pressedIndex;
     QPointF m_pressedMouseGlobalPos;
 
+    bool m_autoActivationEnabled = false;
     QTimer *m_autoActivationTimer;
 
     Qt::GestureType m_swipeGesture;
index 19b57308046fcaf471099ea1f9865456db51152b..e375f2ce51fc84603020becc0e78b2fcff02b213 100644 (file)
@@ -151,7 +151,6 @@ void FoldersPanel::showEvent(QShowEvent *event)
         m_controller->setSelectionBehavior(KItemListController::SingleSelection);
         m_controller->setAutoActivationBehavior(KItemListController::ExpansionOnly);
         m_controller->setMouseDoubleClickAction(KItemListController::ActivateAndExpandItem);
-        m_controller->setAutoActivationDelay(750);
         m_controller->setSingleClickActivationEnforced(true);
 
         connect(m_controller, &KItemListController::itemActivated, this, &FoldersPanel::slotItemActivated);
index 933bfda07fd1ec7c5907ad414c932b7b587ec5e8..bff6e75860e0948b30bb45c521ca5132edb5186b 100644 (file)
@@ -123,8 +123,7 @@ DolphinView::DolphinView(const QUrl &url, QWidget *parent)
     applyModeToView();
 
     KItemListController *controller = new KItemListController(m_model, m_view, this);
-    const int delay = GeneralSettings::autoExpandFolders() ? 750 : -1;
-    controller->setAutoActivationDelay(delay);
+    controller->setAutoActivationEnabled(GeneralSettings::autoExpandFolders());
     connect(controller, &KItemListController::doubleClickViewBackground, this, &DolphinView::doubleClickViewBackground);
 
     // The EnlargeSmallPreviews setting can only be changed after the model
@@ -578,8 +577,7 @@ void DolphinView::readSettings()
     m_view->readSettings();
     applyViewProperties();
 
-    const int delay = GeneralSettings::autoExpandFolders() ? 750 : -1;
-    m_container->controller()->setAutoActivationDelay(delay);
+    m_container->controller()->setAutoActivationEnabled(GeneralSettings::autoExpandFolders());
 
     const int newZoomLevel = m_view->zoomLevel();
     if (newZoomLevel != oldZoomLevel) {