┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dolphinviewcontainer.cpp5
-rw-r--r--src/filterbar/filterbar.cpp32
-rw-r--r--src/filterbar/filterbar.h10
3 files changed, 44 insertions, 3 deletions
diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp
index 0e413bc61..44d4ee36f 100644
--- a/src/dolphinviewcontainer.cpp
+++ b/src/dolphinviewcontainer.cpp
@@ -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);
}
diff --git a/src/filterbar/filterbar.cpp b/src/filterbar/filterbar.cpp
index 7a8951743..3fa9cc147 100644
--- a/src/filterbar/filterbar.cpp
+++ b/src/filterbar/filterbar.cpp
@@ -1,6 +1,7 @@
/***************************************************************************
* Copyright (C) 2006-2010 by Peter Penz <[email protected]> *
* Copyright (C) 2006 by Gregor Kališnik <[email protected]> *
+ * Copyright (C) 2012 by Stuart Citrin <[email protected]> *
* *
* 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()) {
diff --git a/src/filterbar/filterbar.h b/src/filterbar/filterbar.h
index 539d1e23f..5d5463a28 100644
--- a/src/filterbar/filterbar.h
+++ b/src/filterbar/filterbar.h
@@ -1,6 +1,7 @@
/***************************************************************************
* Copyright (C) 2006-2010 by Peter Penz <[email protected]> *
* Copyright (C) 2006 by Gregor Kališnik <[email protected]> *
+ * Copyright (C) 2012 by Stuart Citrin <[email protected]> *
* *
* 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