]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Select the whole text in the filterbar and searchbox if the widget has lost the focus...
authorPeter Penz <peter.penz19@gmail.com>
Sun, 19 Dec 2010 12:03:46 +0000 (12:03 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sun, 19 Dec 2010 12:03:46 +0000 (12:03 +0000)
CCBUG: 256160

svn path=/trunk/KDE/kdebase/apps/; revision=1207719

src/dolphinviewcontainer.cpp
src/filterbar/filterbar.cpp
src/filterbar/filterbar.h
src/search/dolphinsearchbox.cpp
src/search/dolphinsearchbox.h

index 830dc5e74084f7f6c7d31fcb46e5b36e46fa32ce..508c0360df93b259bd108b0d65adff3625191e68 100644 (file)
@@ -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();
     }
index c5dd99d78470432f1607e7e76a0434fd5f216835..8e4dfcc9bc38c455dd5447e210b0b712e2fe1a67 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>                  *
+ *   Copyright (C) 2006-2010 by Peter Penz <peter.penz19@gmail.com>        *
  *   Copyright (C) 2006 by Gregor Kališnik <gregor@podnapisi.net>          *
  *                                                                         *
  *   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();
index bf1bce684f7ae5dafe297eb2bd2ed78f3ab27a3a..cc26ebe674a7a7be69ce8cce284822359372d6f8 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>                  *
+ *   Copyright (C) 2006-2010 by Peter Penz <peter.penz19@gmail.com>        *
  *   Copyright (C) 2006 by Gregor Kališnik <gregor@podnapisi.net>          *
  *                                                                         *
  *   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 <gregor@podnapisi.net>
- * @author Peter Penz <peter.penz@gmx.at>
  */
 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();
index 71c2275018d3f551524af801fe07c17d795cc20b..bcee7e9af894bcd5b5bc5b714a0e0de7bbb54b81 100644 (file)
@@ -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)),
index cbe1645027e36549b1371ad4a5bd4e7073142079..5fc707e917c8ff3cf180e0c2da6d53d3ceb9a6e1 100644 (file)
@@ -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);