From: Flavio Tordini Date: Tue, 30 Jun 2009 19:40:50 +0000 (+0200) Subject: Enable watch button only when there is a keyword X-Git-Tag: 0.4~18 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0683d57a1d07423eba1511a19621e0272468dd40;p=minitube Enable watch button only when there is a keyword --- diff --git a/src/SearchView.cpp b/src/SearchView.cpp index 96e26b3..c1f2cbe 100644 --- a/src/SearchView.cpp +++ b/src/SearchView.cpp @@ -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 diff --git a/src/SearchView.h b/src/SearchView.h index 519c666..e033c15 100644 --- a/src/SearchView.h +++ b/src/SearchView.h @@ -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;