From 0683d57a1d07423eba1511a19621e0272468dd40 Mon Sep 17 00:00:00 2001 From: Flavio Tordini Date: Tue, 30 Jun 2009 21:40:50 +0200 Subject: [PATCH] Enable watch button only when there is a keyword --- src/SearchView.cpp | 8 +++++++- src/SearchView.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) 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; -- 2.39.5