From: Flavio Tordini Date: Tue, 4 Aug 2015 15:48:52 +0000 (+0200) Subject: Avoid recreating recent item labels when there's no change X-Git-Tag: 2.5~44 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=57b77805cb1ff818af997b1bc3ee84827a33f04a;p=minitube Avoid recreating recent item labels when there's no change --- diff --git a/src/searchview.cpp b/src/searchview.cpp index 60cc7a4..f72751b 100644 --- a/src/searchview.cpp +++ b/src/searchview.cpp @@ -214,6 +214,11 @@ void SearchView::disappear() { } void SearchView::updateRecentKeywords() { + // load + QSettings settings; + QStringList keywords = settings.value(recentKeywordsKey).toStringList(); + if (keywords == recentKeywords) return; + recentKeywords = keywords; // cleanup QLayoutItem *item; @@ -222,9 +227,6 @@ void SearchView::updateRecentKeywords() { delete item; } - // load - QSettings settings; - QStringList keywords = settings.value(recentKeywordsKey).toStringList(); recentKeywordsLabel->setVisible(!keywords.isEmpty()); The::globalActions()->value("clearRecentKeywords")->setEnabled(!keywords.isEmpty()); @@ -262,6 +264,11 @@ void SearchView::updateRecentKeywords() { } void SearchView::updateRecentChannels() { + // load + QSettings settings; + QStringList keywords = settings.value(recentChannelsKey).toStringList(); + if (keywords == recentChannels) return; + recentChannels = keywords; // cleanup QLayoutItem *item; @@ -270,9 +277,6 @@ void SearchView::updateRecentChannels() { delete item; } - // load - QSettings settings; - QStringList keywords = settings.value(recentChannelsKey).toStringList(); recentChannelsLabel->setVisible(!keywords.isEmpty()); // TODO The::globalActions()->value("clearRecentKeywords")->setEnabled(!keywords.isEmpty()); diff --git a/src/searchview.h b/src/searchview.h index 3e81879..e8751a6 100644 --- a/src/searchview.h +++ b/src/searchview.h @@ -74,6 +74,8 @@ private: QLabel *message; QPushButton *watchButton; + QStringList recentKeywords; + QStringList recentChannels; }; #endif // __SEARCHVIEW_H__