]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Filter bar: add a button that prevents clearing if the URL changes
authorStuart Citrin <ctrn3e8@gmail.com>
Wed, 22 May 2013 16:48:00 +0000 (18:48 +0200)
committerFrank Reininghaus <frank78ac@googlemail.com>
Wed, 22 May 2013 16:48:00 +0000 (18:48 +0200)
FEATURE: 256651
FIXED-IN: 4.11.0
REVIEW: 107392

src/dolphinviewcontainer.cpp
src/filterbar/filterbar.cpp
src/filterbar/filterbar.h

index 0e413bc61e1ca77d7c1a0b09e257f25e70438007..44d4ee36fcd4faf58e69e4743abedfdbb76202da 100644 (file)
@@ -162,7 +162,7 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
     connect(m_filterBar, SIGNAL(focusViewRequest()),
             this, SLOT(requestFocus()));
     connect(m_view, SIGNAL(urlChanged(KUrl)),
-            m_filterBar, SLOT(clear()));
+            m_filterBar, SLOT(slotUrlChanged()));
 
     m_topLayout->addWidget(m_urlNavigator);
     m_topLayout->addWidget(m_searchBox);
@@ -536,8 +536,7 @@ void DolphinViewContainer::showItemInfo(const KFileItem& item)
 
 void DolphinViewContainer::closeFilterBar()
 {
-    m_filterBar->hide();
-    m_filterBar->clear();
+    m_filterBar->closeFilterBar();
     m_view->setFocus();
     emit showFilterBarChanged(false);
 }
index 7a8951743bc4a5d8c8274dd410de9cc1d1e0e9ef..3fa9cc14706d9119759b3cce5f20f6d6212b93fa 100644 (file)
@@ -1,6 +1,7 @@
 /***************************************************************************
  *   Copyright (C) 2006-2010 by Peter Penz <peter.penz19@gmail.com>        *
  *   Copyright (C) 2006 by Gregor Kališnik <gregor@podnapisi.net>          *
+ *   Copyright (C) 2012 by Stuart Citrin <ctrn3e8@gmail.com>               *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -39,6 +40,13 @@ FilterBar::FilterBar(QWidget* parent) :
     closeButton->setToolTip(i18nc("@info:tooltip", "Hide Filter Bar"));
     connect(closeButton, SIGNAL(clicked()), this, SIGNAL(closeRequest()));
 
+    // Create button to lock text when changing folders
+    m_lockButton = new QToolButton(this);
+    m_lockButton->setCheckable(true);
+    m_lockButton->setIcon(KIcon("system-lock-screen.png"));
+    m_lockButton->setToolTip(i18nc("@info:tooltip", "Keep Filter When Changing Folders"));
+    connect(m_lockButton, SIGNAL(toggled(bool)), this, SLOT(slotToggleLockButton(bool)));
+
     // Create label
     QLabel* filterLabel = new QLabel(i18nc("@label:textbox", "Filter:"), this);
 
@@ -56,6 +64,7 @@ FilterBar::FilterBar(QWidget* parent) :
     hLayout->addWidget(closeButton);
     hLayout->addWidget(filterLabel);
     hLayout->addWidget(m_filterInput);
+    hLayout->addWidget(m_lockButton);
 
     filterLabel->setBuddy(m_filterInput);
 }
@@ -64,6 +73,15 @@ FilterBar::~FilterBar()
 {
 }
 
+void FilterBar::closeFilterBar()
+{
+    hide();
+    clear();
+    if (m_lockButton) {
+        m_lockButton->setChecked(false);
+    }
+}
+
 void FilterBar::selectAll()
 {
     m_filterInput->selectAll();
@@ -74,6 +92,20 @@ void FilterBar::clear()
     m_filterInput->clear();
 }
 
+void FilterBar::slotUrlChanged()
+{
+    if (!m_lockButton || !(m_lockButton->isChecked())) {
+        clear();
+    }
+}
+
+void FilterBar::slotToggleLockButton(bool checked)
+{
+    if (!checked) {
+        clear();
+    }
+}
+
 void FilterBar::showEvent(QShowEvent* event)
 {
     if (!event->spontaneous()) {
index 539d1e23f08b2ddc04f83e0a6a9a948eb92798bb..5d5463a28e960e9e88baf440340e381e81c3944b 100644 (file)
@@ -1,6 +1,7 @@
 /***************************************************************************
  *   Copyright (C) 2006-2010 by Peter Penz <peter.penz19@gmail.com>        *
  *   Copyright (C) 2006 by Gregor Kališnik <gregor@podnapisi.net>          *
+ *   Copyright (C) 2012 by Stuart Citrin <ctrn3e8@gmail.com>               *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -24,6 +25,7 @@
 #include <QWidget>
 
 class KLineEdit;
+class QToolButton;
 
 /**
  * @brief Provides an input field for filtering the currently shown items.
@@ -38,6 +40,9 @@ public:
     explicit FilterBar(QWidget* parent = 0);
     virtual ~FilterBar();
 
+    /** Called by view container to hide this **/
+    void closeFilterBar();
+
     /**
      * Selects the whole text of the filter bar.
      */
@@ -46,6 +51,10 @@ public:
 public slots:
     /** Clears the input field. */
     void clear();
+    /** Clears the input field if the "lock button" is disabled. */
+    void slotUrlChanged();
+    /** The input field is cleared also if the "lock button" is released. */
+    void slotToggleLockButton(bool checked);
 
 signals:
     /**
@@ -70,6 +79,7 @@ protected:
 
 private:
     KLineEdit* m_filterInput;
+    QToolButton* m_lockButton;
 };
 
 #endif