]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Folders Panel: Activate folders on single-click
authorPeter Penz <peter.penz19@gmail.com>
Thu, 5 Jan 2012 19:41:59 +0000 (20:41 +0100)
committerPeter Penz <peter.penz19@gmail.com>
Thu, 5 Jan 2012 19:44:46 +0000 (20:44 +0100)
Even if double-click is used as default setting, the folders panel should
open folders with a single-click.

BUG: 289971
FIXED-IN: 4.8.0

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

index 026c245f53c1658cd779894725d9ba4f17dd0f92..220748be70770b27e75517847c2410c14f1f54e5 100644 (file)
@@ -41,6 +41,7 @@
 
 KItemListController::KItemListController(QObject* parent) :
     QObject(parent),
+    m_singleClickActivation(KGlobalSettings::singleClick()),
     m_selectionTogglePressed(false),
     m_selectionBehavior(NoSelection),
     m_model(0),
@@ -142,6 +143,16 @@ int KItemListController::autoActivationDelay() const
     return m_autoActivationTimer->interval();
 }
 
+void KItemListController::setSingleClickActivation(bool singleClick)
+{
+    m_singleClickActivation = singleClick;
+}
+
+bool KItemListController::singleClickActivation() const
+{
+    return m_singleClickActivation;
+}
+
 bool KItemListController::showEvent(QShowEvent* event)
 {
     Q_UNUSED(event);
@@ -577,7 +588,7 @@ bool KItemListController::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, con
             } else if (shiftOrControlPressed) {
                 // The mouse click should only update the selection, not trigger the item
                 emitItemActivated = false;
-            } else if (!KGlobalSettings::singleClick()) {
+            } else if (!m_singleClickActivation) {
                 emitItemActivated = false;
             }
             if (emitItemActivated) {
@@ -598,7 +609,7 @@ bool KItemListController::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event,
     const QPointF pos = transform.map(event->pos());
     const int index = m_view->itemAt(pos);
 
-    bool emitItemActivated = !KGlobalSettings::singleClick() &&
+    bool emitItemActivated = !m_singleClickActivation &&
                              (event->button() & Qt::LeftButton) &&
                              index >= 0 && index < m_model->count();
     if (emitItemActivated) {
index b8de195eb62eded031c4eb5f51d21572732eb3fe..b7efbde74cc6ef3f67e8fd8ad6c52963120d7f5f 100644 (file)
@@ -104,6 +104,15 @@ public:
     void setAutoActivationDelay(int delay);
     int autoActivationDelay() const;
 
+    /**
+     * If set to true, the signals itemActivated() and itemsActivated() are emitted
+     * after a single-click of the left mouse button. If set to false, a double-click
+     * is required. Per default the setting from KGlobalSettings::singleClick() is
+     * used.
+     */
+    void setSingleClickActivation(bool singleClick);
+    bool singleClickActivation() const;
+
     virtual bool showEvent(QShowEvent* event);
     virtual bool hideEvent(QHideEvent* event);
     virtual bool keyPressEvent(QKeyEvent* event);
@@ -249,6 +258,7 @@ private:
     qreal keyboardAnchorPos(int index) const;
 
 private:
+    bool m_singleClickActivation;
     bool m_selectionTogglePressed;
     SelectionBehavior m_selectionBehavior;
     KItemModelBase* m_model;
index bb2198d487ea0ee4d2697cfdfda19955527ffd9b..86a1c0ccd6ed15c5a78b46158329195426cf48a1 100644 (file)
@@ -174,6 +174,7 @@ void FoldersPanel::showEvent(QShowEvent* event)
         m_controller->setModel(model);
         m_controller->setSelectionBehavior(KItemListController::SingleSelection);
         m_controller->setAutoActivationDelay(750);
+        m_controller->setSingleClickActivation(true);
 
         connect(m_controller, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int)));
         connect(m_controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int)));