]> git.sur5r.net Git - minitube/commitdiff
Enable watch button only when there is a keyword
authorFlavio Tordini <flavio.tordini@gmail.com>
Tue, 30 Jun 2009 19:40:50 +0000 (21:40 +0200)
committerFlavio Tordini <flavio.tordini@gmail.com>
Tue, 30 Jun 2009 19:40:50 +0000 (21:40 +0200)
src/SearchView.cpp
src/SearchView.h

index 96e26b37bc16fe2464b22ac7ff864f206c15b3f7..c1f2cbe68287e06ea079b01eb8da58425fd9f045 100644 (file)
@@ -47,12 +47,14 @@ SearchView::SearchView(QWidget *parent) : QWidget(parent) {
     queryEdit->setFocus(Qt::OtherFocusReason);
     // connect(queryEdit, SIGNAL(returnPressed()), this, SLOT(watch()));
     connect(queryEdit, SIGNAL(search(const QString&)), this, SLOT(watch(const QString&)));
+    connect(queryEdit, SIGNAL(textChanged(const QString &)), this, SLOT(textChanged(const QString &)));
     searchLayout->addWidget(queryEdit);
 
     searchLayout->addSpacing(10);
 
-    QPushButton *watchButton = new QPushButton(tr("Watch"), this);
+    watchButton = new QPushButton(tr("Watch"), this);
     watchButton->setDefault(true);
+    watchButton->setEnabled(false);
     connect(watchButton, SIGNAL(clicked()), this, SLOT(watch()));
     searchLayout->addWidget(watchButton);
 
@@ -135,6 +137,10 @@ void SearchView::watch() {
     watch(query);
 }
 
+void SearchView::textChanged(const QString &text) {
+    watchButton->setEnabled(!text.trimmed().isEmpty());
+}
+
 void SearchView::watch(QString query) {
 
     // check for empty query
index 519c666ccab5ba63d8ec453924ac8844adeefa9a..e033c15590d0f209af10fe59934ff549e442968f 100644 (file)
@@ -40,6 +40,7 @@ signals:
 
 private slots:
     void watch();
+    void textChanged(const QString &text);
 
 private:
     void updateRecentKeywords();
@@ -49,6 +50,7 @@ private:
     QLabel *recentKeywordsLabel;
     QVBoxLayout *recentKeywordsLayout;
     QLabel *message;
+    QPushButton *watchButton;
 
     UpdateChecker *updateChecker;