comparison widgets/SearchWidget.cpp @ 70:46af1af183ac

Highlight the button of the current theme in the search tab
author lbajardsilogic
date Wed, 13 Jun 2007 13:15:45 +0000
parents a5175615d153
children d99441818cd9
comparison
equal deleted inserted replaced
69:72123059fa93 70:46af1af183ac
117 117
118 m_buttonLayout->addStretch(1); 118 m_buttonLayout->addStretch(1);
119 119
120 QString themeName = getActiveTheme(); 120 QString themeName = getActiveTheme();
121 m_searchButton->setObjectName(themeName); 121 m_searchButton->setObjectName(themeName);
122 highlightThemeButton(themeName);
122 123
123 } 124 }
124 125
125 void SearchWidget::addTheme(const QString &name, const QString &label) 126 void SearchWidget::addTheme(const QString &name, const QString &label)
126 { 127 {
246 { 247 {
247 QString name = sender()->objectName(); 248 QString name = sender()->objectName();
248 249
249 m_searchButton->setObjectName(name); 250 m_searchButton->setObjectName(name);
250 251
252 highlightThemeButton(name);
253
251 std::map<QString, int>::iterator iter = m_themes.find(name); 254 std::map<QString, int>::iterator iter = m_themes.find(name);
252 255
253 if (iter != m_themes.end()) 256 if (iter != m_themes.end())
257 {
254 m_themesLayout->setCurrentIndex(iter->second); 258 m_themesLayout->setCurrentIndex(iter->second);
259 }
260 }
261
262 void SearchWidget::highlightThemeButton(QString &name)
263 {
264 QLayoutItem *child;
265
266 for (int i = 0; i<m_buttonLayout->count(); i++ )
267 {
268 child = m_buttonLayout->itemAt(i);
269 QPushButton* button = (QPushButton*) child->widget();
270 if (button)
271 {
272 if (name == button->objectName())
273 {
274 QPalette palette;
275 palette.setColor(QPalette::Button,palette.color(QPalette::Highlight));
276 button->setPalette(palette);
277 }
278 else
279 {
280 QPalette palette;
281 button->setPalette(palette);
282 }
283 }
284 }
255 } 285 }
256 286
257 QString SearchWidget::getActiveTheme() 287 QString SearchWidget::getActiveTheme()
258 { 288 {
259 int index = m_themesLayout->currentIndex(); 289 int index = m_themesLayout->currentIndex();