]> git.sur5r.net Git - minitube/commitdiff
Fixed toolbar search suggestions working just once
authorFlavio Tordini <flavio.tordini@gmail.com>
Sun, 3 Jan 2010 22:52:29 +0000 (23:52 +0100)
committerFlavio Tordini <flavio.tordini@gmail.com>
Sun, 3 Jan 2010 22:52:29 +0000 (23:52 +0100)
src/SearchView.cpp
src/googlesuggest.cpp
src/searchlineedit.cpp
src/searchlineedit.h

index f7d857d3a05a8df1cfdc1d36bece2e692054671f..a8a8ab4db386970a0ebcae4bf38079f9fa079290 100644 (file)
@@ -166,8 +166,6 @@ void SearchView::watch(QString query) {
         return;
     }
 
-    queryEdit->preventSuggest();
-
     // go!
     emit search(query);
 }
index 141bf2351ad89ef519b7b3ccd0afdb694066fce8..0002ed08e547ae904ee373d6cb1ccc943e77e279 100644 (file)
@@ -90,7 +90,7 @@ bool GSuggestCompletion::eventFilter(QObject *obj, QEvent *ev) {
             break;
 
         default:
-            qDebug() << keyEvent->text();
+            // qDebug() << keyEvent->text();
             editor->setFocus();
             editor->event(ev);
             popup->hide();
@@ -144,12 +144,14 @@ void GSuggestCompletion::doneCompletion() {
 }
 
 void GSuggestCompletion::preventSuggest() {
+    // qDebug() << "preventSuggest";
     timer->stop();
     enabled = false;
     popup->hide();
 }
 
 void GSuggestCompletion::enableSuggest() {
+    // qDebug() << "enableSuggest";
     enabled = true;
 }
 
index bb1cebb159dc31ee1615453e849d82a67265538e..2e5dc6da2570d04182b29f249039cd53aac809d4 100644 (file)
@@ -50,7 +50,7 @@
 #include "googlesuggest.h"
 
 ClearButton::ClearButton(QWidget *parent)
-        : QAbstractButton(parent)
+    : QAbstractButton(parent)
 {
     setCursor(Qt::ArrowCursor);
     setToolTip(tr("Clear"));
@@ -68,7 +68,7 @@ void ClearButton::paintEvent(QPaintEvent *event)
     QColor color = palette().color(QPalette::Mid);
     painter.setBrush(isDown()
                      ? palette().color(QPalette::Dark)
-                     : palette().color(QPalette::Mid));
+                         : palette().color(QPalette::Mid));
     painter.setPen(painter.brush().color());
     int size = width();
     int offset = size / 3.5;
@@ -101,8 +101,8 @@ protected:
 };
 
 SearchButton::SearchButton(QWidget *parent)
-        : QAbstractButton(parent),
-        m_menu(0)
+    : QAbstractButton(parent),
+    m_menu(0)
 {
     setObjectName(QLatin1String("SearchButton"));
     setCursor(Qt::ArrowCursor);
@@ -247,8 +247,10 @@ QMenu *SearchLineEdit::menu() const
 
 void SearchLineEdit::returnPressed()
 {
-    completion->preventSuggest();
-    emit search(lineEdit()->text());
+    if (!lineEdit()->text().isEmpty()) {
+        completion->preventSuggest();
+        emit search(lineEdit()->text());
+    }
 }
 
 void SearchLineEdit::enableSuggest() {
@@ -258,3 +260,7 @@ void SearchLineEdit::enableSuggest() {
 void SearchLineEdit::preventSuggest() {
     completion->preventSuggest();
 }
+
+void SearchLineEdit::focusInEvent(QFocusEvent * /* event */) {
+    enableSuggest();
+}
index 0f20a087e4fbd8d4f81852352c96232486ffa886..a1d71c44f64193aea715b7f4d0085dabaaf5bcf7 100644 (file)
@@ -97,6 +97,7 @@ public:
 protected:
     void resizeEvent(QResizeEvent *event);
     void paintEvent(QPaintEvent *event);
+    void focusInEvent(QFocusEvent *event);
 
 private slots:
     void returnPressed();