1 /***************************************************************************
2 * Copyright (C) 2005-09 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20 #include <QSignalMapper>
22 #include "itemviewsettingspage.h"
23 #include "colorbutton.h"
25 #include "qtuistyle.h"
27 ItemViewSettingsPage::ItemViewSettingsPage(QWidget *parent)
28 : SettingsPage(tr("Interface"), tr("Chat & Nick Lists"), parent),
29 _mapper(new QSignalMapper(this))
33 _networkItem = new QTreeWidgetItem(ui.bufferViewPreview, QStringList(tr("Network")));
34 _networkItem->setFlags(Qt::NoItemFlags);
36 _inactiveBufferItem = new QTreeWidgetItem(_networkItem, QStringList(tr("Inactive")));
37 _defaultBufferItem = new QTreeWidgetItem(_networkItem, QStringList(tr("Normal")));
38 _unreadBufferItem = new QTreeWidgetItem(_networkItem, QStringList(tr("Unread messages")));
39 _highlightedBufferItem = new QTreeWidgetItem(_networkItem, QStringList(tr("Highlight")));
40 _activeBufferItem = new QTreeWidgetItem(_networkItem, QStringList(tr("Other activity")));
42 ui.bufferViewPreview->expandAll();
44 foreach(ColorButton *button, findChildren<ColorButton *>()) {
45 connect(button, SIGNAL(colorChanged(QColor)), _mapper, SLOT(map()));
46 _mapper->setMapping(button, button);
48 connect(_mapper, SIGNAL(mapped(QWidget *)), SLOT(updateBufferViewPreview(QWidget *)));
53 void ItemViewSettingsPage::save() {
55 QtUi::style()->generateSettingsQss();
56 QtUi::style()->reload();
59 void ItemViewSettingsPage::updateBufferViewPreview(QWidget *widget) {
60 ColorButton *button = qobject_cast<ColorButton *>(widget);
64 QString objName = button->objectName();
65 if(objName == "defaultBufferColor") {
66 _networkItem->setForeground(0, button->color());
67 _defaultBufferItem->setForeground(0, button->color());
68 } else if(objName == "inactiveBufferColor")
69 _inactiveBufferItem->setForeground(0, button->color());
70 else if(objName == "activeBufferColor")
71 _activeBufferItem->setForeground(0, button->color());
72 else if(objName == "unreadBufferColor")
73 _unreadBufferItem->setForeground(0, button->color());
74 else if(objName == "highlightedBufferColor")
75 _highlightedBufferItem->setForeground(0, button->color());