From: Flavio Tordini Date: Mon, 4 Jan 2010 00:51:27 +0000 (+0100) Subject: Clear recent keywords based on a patch by Sebastian Frysztak X-Git-Tag: 0.9~16 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d2961371f60954af46e5b34256f45e3aca6720bb;p=minitube Clear recent keywords based on a patch by Sebastian Frysztak --- diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 9d05596..50de29b 100755 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -149,7 +149,14 @@ void MainWindow::createActions() { moveDownAct->setEnabled(false); actions->insert("moveDown", moveDownAct); connect(moveDownAct, SIGNAL(triggered()), mediaView, SLOT(moveDownSelected())); - + + clearAct = new QAction(tr("&Clear recent keywords"), this); + clearAct->setMenuRole(QAction::ApplicationSpecificRole); + clearAct->setShortcuts(QList() << QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Delete) << QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Backspace)); + clearAct->setEnabled(true); + actions->insert("clearRecentKeywords", clearAct); + connect(clearAct, SIGNAL(triggered()), searchView, SLOT(clearRecentKeywords())); + quitAct = new QAction(tr("&Quit"), this); quitAct->setMenuRole(QAction::QuitRole); quitAct->setShortcuts(QList() << QKeySequence(tr("Ctrl+Q")) << QKeySequence(Qt::CTRL + Qt::Key_W)); @@ -244,13 +251,13 @@ void MainWindow::createMenus() { QMap *menus = The::globalMenus(); - /* fileMenu = menuBar()->addMenu(tr("&Application")); // menus->insert("file", fileMenu); // fileMenu->addAction(settingsAct); + fileMenu->addAction(clearAct); fileMenu->addSeparator(); fileMenu->addAction(quitAct); - */ + playlistMenu = menuBar()->addMenu(tr("&Playlist")); menus->insert("playlist", playlistMenu); @@ -502,7 +509,7 @@ void MainWindow::stateChanged(Phonon::State newState, Phonon::State /* oldState switch (newState) { - case Phonon::ErrorState: + case Phonon::ErrorState: if (mediaObject->errorType() == Phonon::FatalError) { statusBar()->showMessage(tr("Fatal error: %1").arg(mediaObject->errorString())); } else { diff --git a/src/MainWindow.h b/src/MainWindow.h index 7d3f23d..e8d2ed5 100755 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -126,6 +126,7 @@ private: QAction *moveDownAct; QAction *moveUpAct; QAction *fetchMoreAct; + QAction *clearAct; // menus QMenu *fileMenu; diff --git a/src/SearchView.cpp b/src/SearchView.cpp index a8a8ab4..e819e8d 100644 --- a/src/SearchView.cpp +++ b/src/SearchView.cpp @@ -1,6 +1,10 @@ #include "SearchView.h" #include "Constants.h" +namespace The { + QMap* globalActions(); +} + static const QString recentKeywordsKey = "recentKeywords"; static const int PADDING = 30; @@ -134,6 +138,8 @@ void SearchView::updateRecentKeywords() { QSettings settings; QStringList keywords = settings.value(recentKeywordsKey).toStringList(); recentKeywordsLabel->setVisible(!keywords.isEmpty()); + The::globalActions()->value("clearRecentKeywords")->setEnabled(!keywords.isEmpty()); + foreach (QString keyword, keywords) { QLabel *itemLabel = new QLabel("" @@ -149,6 +155,12 @@ void SearchView::updateRecentKeywords() { } +void SearchView::clearRecentKeywords() { + QSettings settings; + settings.remove(recentKeywordsKey); + updateRecentKeywords(); +} + void SearchView::watch() { QString query = queryEdit->text().simplified(); watch(query); diff --git a/src/SearchView.h b/src/SearchView.h index 4690a44..fe4e939 100644 --- a/src/SearchView.h +++ b/src/SearchView.h @@ -42,6 +42,7 @@ signals: private slots: void watch(); void textChanged(const QString &text); + void clearRecentKeywords(); private: void updateRecentKeywords();