diff options
| author | Peter Penz <[email protected]> | 2010-12-19 12:03:46 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2010-12-19 12:03:46 +0000 |
| commit | 342954bb1fdc59fde0a95f2ba97b7e7712cfb47d (patch) | |
| tree | 71edb431764e5f58fa4ce8aec6925ffe70c1fc03 /src | |
| parent | 366db1568224186624cc61ac31b13c7dc28eed40 (diff) | |
Select the whole text in the filterbar and searchbox if the widget has lost the focus and gets focused again by the shortcut (this behavior is consistent to e.g. the behavior in Kate).
CCBUG: 256160
svn path=/trunk/KDE/kdebase/apps/; revision=1207719
Diffstat (limited to 'src')
| -rw-r--r-- | src/dolphinviewcontainer.cpp | 5 | ||||
| -rw-r--r-- | src/filterbar/filterbar.cpp | 7 | ||||
| -rw-r--r-- | src/filterbar/filterbar.h | 9 | ||||
| -rw-r--r-- | src/search/dolphinsearchbox.cpp | 6 | ||||
| -rw-r--r-- | src/search/dolphinsearchbox.h | 5 |
5 files changed, 29 insertions, 3 deletions
diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 830dc5e74..508c0360d 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -239,6 +239,10 @@ bool DolphinViewContainer::isFilterBarVisible() const void DolphinViewContainer::setSearchModeEnabled(bool enabled) { if (enabled == isSearchModeEnabled()) { + if (enabled && !m_searchBox->hasFocus()) { + m_searchBox->setFocus(); + m_searchBox->selectAll(); + } return; } @@ -295,6 +299,7 @@ void DolphinViewContainer::setFilterBarVisible(bool visible) if (visible) { m_filterBar->show(); m_filterBar->setFocus(); + m_filterBar->selectAll(); } else { closeFilterBar(); } diff --git a/src/filterbar/filterbar.cpp b/src/filterbar/filterbar.cpp index c5dd99d78..8e4dfcc9b 100644 --- a/src/filterbar/filterbar.cpp +++ b/src/filterbar/filterbar.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Peter Penz <[email protected]> * + * Copyright (C) 2006-2010 by Peter Penz <[email protected]> * * Copyright (C) 2006 by Gregor Kališnik <[email protected]> * * * * This program is free software; you can redistribute it and/or modify * @@ -64,6 +64,11 @@ FilterBar::~FilterBar() { } +void FilterBar::selectAll() +{ + m_filterInput->selectAll(); +} + void FilterBar::clear() { m_filterInput->clear(); diff --git a/src/filterbar/filterbar.h b/src/filterbar/filterbar.h index bf1bce684..cc26ebe67 100644 --- a/src/filterbar/filterbar.h +++ b/src/filterbar/filterbar.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Peter Penz <[email protected]> * + * Copyright (C) 2006-2010 by Peter Penz <[email protected]> * * Copyright (C) 2006 by Gregor Kališnik <[email protected]> * * * * This program is free software; you can redistribute it and/or modify * @@ -17,6 +17,7 @@ * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ + #ifndef FILTERBAR_H #define FILTERBAR_H @@ -28,7 +29,6 @@ class KLineEdit; * @brief Provides an input field for filtering the currently shown items. * * @author Gregor Kališnik <[email protected]> - * @author Peter Penz <[email protected]> */ class FilterBar : public QWidget { @@ -38,6 +38,11 @@ public: FilterBar(QWidget* parent = 0); virtual ~FilterBar(); + /** + * Selects the whole text of the filter bar. + */ + void selectAll(); + public slots: /** Clears the input field. */ void clear(); diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp index 71c227501..bcee7e9af 100644 --- a/src/search/dolphinsearchbox.cpp +++ b/src/search/dolphinsearchbox.cpp @@ -134,6 +134,11 @@ KUrl DolphinSearchBox::urlForSearching() const return url; } +void DolphinSearchBox::selectAll() +{ + m_searchInput->selectAll(); +} + bool DolphinSearchBox::event(QEvent* event) { if (event->type() == QEvent::Polish) { @@ -243,6 +248,7 @@ void DolphinSearchBox::init() m_searchInput = new KLineEdit(this); m_searchInput->setClearButtonShown(true); m_searchInput->setFont(KGlobalSettings::generalFont()); + setFocusProxy(m_searchInput); connect(m_searchInput, SIGNAL(returnPressed(QString)), this, SLOT(slotReturnPressed(QString))); connect(m_searchInput, SIGNAL(textChanged(QString)), diff --git a/src/search/dolphinsearchbox.h b/src/search/dolphinsearchbox.h index cbe164502..5fc707e91 100644 --- a/src/search/dolphinsearchbox.h +++ b/src/search/dolphinsearchbox.h @@ -64,6 +64,11 @@ public: /** @return URL that will start the searching of files. */ KUrl urlForSearching() const; + /** + * Selects the whole text of the search box. + */ + void selectAll(); + protected: virtual bool event(QEvent* event); virtual void showEvent(QShowEvent* event); |
