]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/search/dolphinsearchbox.cpp
Do not select items when navigating back/forward with the mouse
[dolphin.git] / src / search / dolphinsearchbox.cpp
index 8b660712a1abff9545499a6164892d62e734f41e..cf1f0c8e5243fb56ba9794f67f396b396e99bf19 100644 (file)
@@ -58,6 +58,7 @@ DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
     QWidget(parent),
     m_startedSearching(false),
     m_readOnly(false),
+    m_active(true),
     m_topLayout(0),
     m_searchLabel(0),
     m_searchInput(0),
@@ -159,7 +160,7 @@ void DolphinSearchBox::selectAll()
 
 void DolphinSearchBox::setReadOnly(bool readOnly, const KUrl& query)
 {
-    if (m_readOnly != readOnly) {
+    if (m_readOnly != readOnly || m_readOnlyQuery != query) {
         m_readOnly = readOnly;
         m_readOnlyQuery = query;
         applyReadOnlyState();
@@ -171,6 +172,22 @@ bool DolphinSearchBox::isReadOnly() const
     return m_readOnly;
 }
 
+void DolphinSearchBox::setActive(bool active)
+{
+    if (active != m_active) {
+        m_active = active;
+
+        if (active) {
+            emit activated();
+        }
+    }
+}
+
+bool DolphinSearchBox::isActive() const
+{
+    return m_active;
+}
+
 bool DolphinSearchBox::event(QEvent* event)
 {
     if (event->type() == QEvent::Polish) {
@@ -199,6 +216,21 @@ void DolphinSearchBox::keyReleaseEvent(QKeyEvent* event)
     }
 }
 
+bool DolphinSearchBox::eventFilter(QObject* obj, QEvent* event)
+{
+    switch (event->type()) {
+    case QEvent::FocusIn:
+        setActive(true);
+        setFocus();
+        break;
+
+    default:
+        break;
+    }
+
+    return QObject::eventFilter(obj, event);
+}
+
 void DolphinSearchBox::emitSearchRequest()
 {
     m_startSearchTimer->stop();
@@ -253,6 +285,7 @@ void DolphinSearchBox::slotFacetChanged()
 
 void DolphinSearchBox::initButton(QToolButton* button)
 {
+    button->installEventFilter(this);
     button->setAutoExclusive(true);
     button->setAutoRaise(true);
     button->setCheckable(true);
@@ -298,6 +331,7 @@ void DolphinSearchBox::init()
 
     // Create search box
     m_searchInput = new KLineEdit(this);
+    m_searchInput->installEventFilter(this);
     m_searchInput->setClearButtonShown(true);
     m_searchInput->setFont(KGlobalSettings::generalFont());
     setFocusProxy(m_searchInput);
@@ -348,6 +382,7 @@ void DolphinSearchBox::init()
     connect(m_facetsToggleButton, SIGNAL(clicked()), this, SLOT(slotFacetsButtonToggled()));
 
     m_facetsWidget = new DolphinFacetsWidget(this);
+    m_facetsWidget->installEventFilter(this);
     m_facetsWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
     connect(m_facetsWidget, SIGNAL(facetChanged()), this, SLOT(slotFacetChanged()));
 
@@ -473,7 +508,7 @@ void DolphinSearchBox::updateFacetsToggleButton()
     const bool facetsIsVisible = SearchSettings::showFacetsWidget();
     m_facetsToggleButton->setChecked(facetsIsVisible ? true : false);
     m_facetsToggleButton->setIcon(KIcon(facetsIsVisible ? "arrow-up-double" : "arrow-down-double"));
-    m_facetsToggleButton->setText(facetsIsVisible ? i18nc("action:button", "Less Options") : i18nc("action:button", "More Options"));
+    m_facetsToggleButton->setText(facetsIsVisible ? i18nc("action:button", "Fewer Options") : i18nc("action:button", "More Options"));
 }
 
 #include "dolphinsearchbox.moc"