1/***************************************************************************
2 * Copyright (C) 2005-2014 by the Quassel Project *
3 * devel@quassel-irc.org *
4 * *
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. *
9 * *
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. *
14 * *
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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
20
21#include <QSignalMapper>
22
23#include "itemviewsettingspage.h"
24#include "colorbutton.h"
25#include "qtui.h"
26#include "qtuistyle.h"
27
28ItemViewSettingsPage::ItemViewSettingsPage(QWidget *parent)
29 : SettingsPage(tr("Interface"), tr("Chat & Nick Lists"), parent),
30 _mapper(new QSignalMapper(this))
31{
32 ui.setupUi(this);
33
34 _networkItem = new QTreeWidgetItem(ui.bufferViewPreview, QStringList(tr("Network")));
35 _networkItem->setFlags(Qt::NoItemFlags);
36
37 _inactiveBufferItem = new QTreeWidgetItem(_networkItem, QStringList(tr("Inactive")));
38 _defaultBufferItem = new QTreeWidgetItem(_networkItem, QStringList(tr("Normal")));
39 _unreadBufferItem = new QTreeWidgetItem(_networkItem, QStringList(tr("Unread messages")));
40 _highlightedBufferItem = new QTreeWidgetItem(_networkItem, QStringList(tr("Highlight")));
41 _activeBufferItem = new QTreeWidgetItem(_networkItem, QStringList(tr("Other activity")));
42
43 ui.bufferViewPreview->expandAll();
44
45 foreach(ColorButton *button, findChildren<ColorButton *>()) {
46 connect(button, SIGNAL(colorChanged(QColor)), _mapper, SLOT(map()));
47 _mapper->setMapping(button, button);
48 }
49 connect(_mapper, SIGNAL(mapped(QWidget *)), SLOT(updateBufferViewPreview(QWidget *)));
50
51 initAutoWidgets();
52}
53
54
55void ItemViewSettingsPage::save()
56{
57 SettingsPage::save();
58 QtUi::style()->generateSettingsQss();
59 QtUi::style()->reload();
60}
61
62
63void ItemViewSettingsPage::updateBufferViewPreview(QWidget *widget)
64{
65 ColorButton *button = qobject_cast<ColorButton *>(widget);
66 if (!button)
67 return;
68
69 QString objName = button->objectName();
70 if (objName == "defaultBufferColor") {
71 _networkItem->setForeground(0, button->color());
72 _defaultBufferItem->setForeground(0, button->color());
73 }
74 else if (objName == "inactiveBufferColor")
75 _inactiveBufferItem->setForeground(0, button->color());
76 else if (objName == "activeBufferColor")
77 _activeBufferItem->setForeground(0, button->color());
78 else if (objName == "unreadBufferColor")
79 _unreadBufferItem->setForeground(0, button->color());
80 else if (objName == "highlightedBufferColor")
81 _highlightedBufferItem->setForeground(0, button->color());
82}
83