From: Manuel Nickschas Date: Thu, 6 Aug 2009 17:00:30 +0000 (+0200) Subject: Add new ItemView settingspage X-Git-Tag: 0.5-rc1~81 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=983164018267de71e92c025ff81e4f10b8ddc5b0;ds=sidebyside Add new ItemView settingspage This can be used to define custom colors and fonts for the chat list and nick list. As with the ChatView, only basic things are settable here; more complex stuff requires a custom stylesheet. --- diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 8b76d0ed..ea94561d 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -103,6 +103,7 @@ #include "settingspages/generalsettingspage.h" #include "settingspages/highlightsettingspage.h" #include "settingspages/identitiessettingspage.h" +#include "settingspages/itemviewsettingspage.h" #include "settingspages/networkssettingspage.h" #include "settingspages/notificationssettingspage.h" @@ -810,6 +811,7 @@ void MainWin::showSettingsDlg() { //Category: Appearance dlg->registerSettingsPage(new AppearanceSettingsPage(dlg)); dlg->registerSettingsPage(new ChatViewSettingsPage(dlg)); + dlg->registerSettingsPage(new ItemViewSettingsPage(dlg)); dlg->registerSettingsPage(new HighlightSettingsPage(dlg)); dlg->registerSettingsPage(new NotificationsSettingsPage(dlg)); dlg->registerSettingsPage(new BacklogSettingsPage(dlg)); diff --git a/src/qtui/settingspages/appearancesettingspage.cpp b/src/qtui/settingspages/appearancesettingspage.cpp index 5206430b..8ab7ce39 100644 --- a/src/qtui/settingspages/appearancesettingspage.cpp +++ b/src/qtui/settingspages/appearancesettingspage.cpp @@ -27,6 +27,7 @@ #include "qtuistyle.h" #include "util.h" +#include #include #include #include @@ -57,10 +58,8 @@ AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent) mapper = new QSignalMapper(this); connect(mapper, SIGNAL(mapped(QWidget *)), this, SLOT(chooseFont(QWidget *))); - connect(ui.chooseBufferView, SIGNAL(clicked()), mapper, SLOT(map())); connect(ui.chooseInputLine, SIGNAL(clicked()), mapper, SLOT(map())); - mapper->setMapping(ui.chooseBufferView, ui.demoBufferView); mapper->setMapping(ui.chooseInputLine, ui.demoInputLine); connect(ui.chooseStyleSheet, SIGNAL(clicked()), SLOT(chooseStyleSheet())); @@ -92,8 +91,6 @@ void AppearanceSettingsPage::defaults() { loadFonts(Settings::Default); _fontsChanged = true; - ui.showUserStateIcons->setChecked(true); - SettingsPage::defaults(); widgetHasChanged(); } @@ -122,9 +119,6 @@ void AppearanceSettingsPage::load() { ui.languageComboBox->setProperty("storedValue", ui.languageComboBox->currentIndex()); Quassel::loadTranslation(selectedLocale()); - BufferSettings bufferSettings; - SettingsPage::load(ui.showUserStateIcons, bufferSettings.showUserStateIcons()); - loadFonts(Settings::Custom); SettingsPage::load(); @@ -139,14 +133,6 @@ void AppearanceSettingsPage::loadFonts(Settings::Mode mode) { inputLineFont = s.value("InputLine", QFont()).value(); setFont(ui.demoInputLine, inputLineFont); - QFont bufferViewFont; - if(mode == Settings::Custom) - bufferViewFont = s.value("BufferView", QFont()).value(); - setFont(ui.demoBufferView, bufferViewFont); - - //QTextCharFormat chatFormat = QtUi::style()->cachedFormat(UiStyle::None, 0); // FIXME - //setFont(ui.demoChatView, chatFormat.font()); - _fontsChanged = false; } @@ -165,9 +151,6 @@ void AppearanceSettingsPage::save() { uiSettings.setValue("Locale", selectedLocale()); } - BufferSettings bufferSettings; - bufferSettings.enableUserStateIcons(ui.showUserStateIcons->isChecked()); - // Fonts QtUiStyleSettings fontSettings("Fonts"); if(ui.demoInputLine->font() != QApplication::font()) @@ -175,15 +158,6 @@ void AppearanceSettingsPage::save() { else fontSettings.setValue("InputLine", ""); - if(ui.demoBufferView->font() != QApplication::font()) - fontSettings.setValue("BufferView", ui.demoBufferView->font()); - else - fontSettings.setValue("BufferView", ""); - - //QTextCharFormat chatFormat = QtUi::style()->format(UiStyle::None); - //chatFormat.setFont(ui.demoChatView->font()); - //QtUi::style()->setFormat(UiStyle::None, chatFormat, Settings::Custom); - _fontsChanged = false; bool needsStyleReload = @@ -246,7 +220,5 @@ bool AppearanceSettingsPage::testHasChanged() { if(selectedLocale() != QLocale()) return true; // QLocale() returns the default locale (manipulated via loadTranslation()) - if(SettingsPage::hasChanged(ui.showUserStateIcons)) return true; - return false; } diff --git a/src/qtui/settingspages/appearancesettingspage.ui b/src/qtui/settingspages/appearancesettingspage.ui index 291881a8..9c484191 100644 --- a/src/qtui/settingspages/appearancesettingspage.ui +++ b/src/qtui/settingspages/appearancesettingspage.ui @@ -124,54 +124,6 @@ - - - Set font for channel and nick lists - - - Channel list: - - - - - - - - 0 - 0 - - - - Set font for channel and nick lists - - - QFrame::StyledPanel - - - QFrame::Sunken - - - Font - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Choose... - - - - Set font for the input line @@ -181,7 +133,7 @@ - + @@ -206,7 +158,7 @@ - + @@ -222,28 +174,6 @@ - - - - Misc - - - - - - Show status icons in channel and nick lists - - - Use icons in channel and nick lists - - - true - - - - - - diff --git a/src/qtui/settingspages/generalsettingspage.cpp b/src/qtui/settingspages/generalsettingspage.cpp index 9f34b595..9888235d 100644 --- a/src/qtui/settingspages/generalsettingspage.cpp +++ b/src/qtui/settingspages/generalsettingspage.cpp @@ -50,8 +50,6 @@ GeneralSettingsPage::GeneralSettingsPage(QWidget *parent) connect(ui.errorMsgsInStatusBuffer, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); connect(ui.errorMsgsInCurrentBuffer, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); - connect(ui.displayTopicInTooltip, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); - connect(ui.mouseWheelChangesBuffers, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); connect(ui.completionSuffix, SIGNAL(textEdited(const QString&)), this, SLOT(widgetHasChanged())); } @@ -76,9 +74,6 @@ void GeneralSettingsPage::defaults() { ui.errorMsgsInStatusBuffer->setChecked(false); ui.errorMsgsInCurrentBuffer->setChecked(false); - ui.displayTopicInTooltip->setChecked(false); - ui.mouseWheelChangesBuffers->setChecked(false); - ui.completionSuffix->setText(": "); widgetHasChanged(); @@ -95,9 +90,6 @@ void GeneralSettingsPage::load() { settings["MinimizeOnClose"] = qtuiSettings.value("MinimizeOnClose", QVariant(false)); ui.minimizeOnClose->setChecked(settings["MinimizeOnClose"].toBool()); - settings["MouseWheelChangesBuffers"] = uiSettings.value("MouseWheelChangesBuffers", QVariant(false)); - ui.mouseWheelChangesBuffers->setChecked(settings["MouseWheelChangesBuffers"].toBool()); - // bufferSettings: BufferSettings bufferSettings; int redirectTarget = bufferSettings.userNoticesTarget(); @@ -115,10 +107,6 @@ void GeneralSettingsPage::load() { SettingsPage::load(ui.errorMsgsInStatusBuffer, redirectTarget & BufferSettings::StatusBuffer); SettingsPage::load(ui.errorMsgsInCurrentBuffer, redirectTarget & BufferSettings::CurrentBuffer); - - settings["DisplayTopicInTooltip"] = bufferSettings.value("DisplayTopicInTooltip", QVariant(false)); - ui.displayTopicInTooltip->setChecked(settings["DisplayTopicInTooltip"].toBool()); - // completion settings TabCompletionSettings completionSettings; settings["CompletionSuffix"] = completionSettings.completionSuffix(); @@ -136,9 +124,6 @@ void GeneralSettingsPage::save() { #endif qtuiSettings.setValue("MinimizeOnClose", ui.minimizeOnClose->isChecked()); - UiSettings uiSettings; - uiSettings.setValue("MouseWheelChangesBuffers", ui.mouseWheelChangesBuffers->isChecked()); - BufferSettings bufferSettings; int redirectTarget = 0; if(ui.userNoticesInDefaultBuffer->isChecked()) @@ -167,8 +152,6 @@ void GeneralSettingsPage::save() { redirectTarget |= BufferSettings::CurrentBuffer; bufferSettings.setErrorMsgsTarget(redirectTarget); - bufferSettings.setValue("DisplayTopicInTooltip", ui.displayTopicInTooltip->isChecked()); - TabCompletionSettings completionSettings; completionSettings.setCompletionSuffix(ui.completionSuffix->text()); @@ -202,9 +185,6 @@ bool GeneralSettingsPage::testHasChanged() { if(SettingsPage::hasChanged(ui.errorMsgsInDefaultBuffer)) return true; if(SettingsPage::hasChanged(ui.errorMsgsInCurrentBuffer)) return true; - if(settings["DisplayTopicInTooltip"].toBool() != ui.displayTopicInTooltip->isChecked()) return true; - if(settings["MouseWheelChangesBuffers"].toBool() != ui.mouseWheelChangesBuffers->isChecked()) return true; - if(settings["CompletionSuffix"].toString() != ui.completionSuffix->text()) return true; return false; diff --git a/src/qtui/settingspages/generalsettingspage.ui b/src/qtui/settingspages/generalsettingspage.ui index 8bf82747..41931dcb 100644 --- a/src/qtui/settingspages/generalsettingspage.ui +++ b/src/qtui/settingspages/generalsettingspage.ui @@ -187,32 +187,6 @@ - - - - Buffer View - - - - - - Display topic in tooltip - - - - - - - Mouse wheel changes displayed buffers - - - false - - - - - - diff --git a/src/qtui/settingspages/itemviewsettingspage.cpp b/src/qtui/settingspages/itemviewsettingspage.cpp new file mode 100644 index 00000000..1b37c534 --- /dev/null +++ b/src/qtui/settingspages/itemviewsettingspage.cpp @@ -0,0 +1,76 @@ +/*************************************************************************** + * Copyright (C) 2005-09 by the Quassel Project * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) version 3. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include + +#include "itemviewsettingspage.h" +#include "colorbutton.h" +#include "qtui.h" +#include "qtuistyle.h" + +ItemViewSettingsPage::ItemViewSettingsPage(QWidget *parent) + : SettingsPage(tr("Appearance"), tr("Chat & Nick Lists"), parent), + _mapper(new QSignalMapper(this)) +{ + ui.setupUi(this); + + _networkItem = new QTreeWidgetItem(ui.bufferViewPreview, QStringList(tr("Network"))); + _networkItem->setFlags(Qt::NoItemFlags); + + _inactiveBufferItem = new QTreeWidgetItem(_networkItem, QStringList(tr("Inactive"))); + _defaultBufferItem = new QTreeWidgetItem(_networkItem, QStringList(tr("Normal"))); + _unreadBufferItem = new QTreeWidgetItem(_networkItem, QStringList(tr("Unread messages"))); + _highlightedBufferItem = new QTreeWidgetItem(_networkItem, QStringList(tr("Highlight"))); + _activeBufferItem = new QTreeWidgetItem(_networkItem, QStringList(tr("Other activity"))); + + ui.bufferViewPreview->expandAll(); + + foreach(ColorButton *button, findChildren()) { + connect(button, SIGNAL(colorChanged(QColor)), _mapper, SLOT(map())); + _mapper->setMapping(button, button); + } + connect(_mapper, SIGNAL(mapped(QWidget *)), SLOT(updateBufferViewPreview(QWidget *))); + + initAutoWidgets(); +} + +void ItemViewSettingsPage::save() { + SettingsPage::save(); + QtUi::style()->generateSettingsQss(); + QtUi::style()->reload(); +} + +void ItemViewSettingsPage::updateBufferViewPreview(QWidget *widget) { + ColorButton *button = qobject_cast(widget); + if(!button) + return; + + QString objName = button->objectName(); + if(objName == "defaultBufferColor") { + _networkItem->setForeground(0, button->color()); + _defaultBufferItem->setForeground(0, button->color()); + } else if(objName == "inactiveBufferColor") + _inactiveBufferItem->setForeground(0, button->color()); + else if(objName == "activeBufferColor") + _activeBufferItem->setForeground(0, button->color()); + else if(objName == "unreadBufferColor") + _unreadBufferItem->setForeground(0, button->color()); + else if(objName == "highlightedBufferColor") + _highlightedBufferItem->setForeground(0, button->color()); +} diff --git a/src/qtui/settingspages/itemviewsettingspage.h b/src/qtui/settingspages/itemviewsettingspage.h new file mode 100644 index 00000000..4b184c40 --- /dev/null +++ b/src/qtui/settingspages/itemviewsettingspage.h @@ -0,0 +1,54 @@ +/*************************************************************************** + * Copyright (C) 2005-09 by the Quassel Project * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) version 3. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef ITEMVIEWSETTINGSPAGE_H_ +#define ITEMVIEWSETTINGSPAGE_H_ + +#include "settingspage.h" +#include "ui_itemviewsettingspage.h" + +class ColorButton; +class QSignalMapper; +class QTreeWidgetItem; + +class ItemViewSettingsPage : public SettingsPage { + Q_OBJECT + +public: + ItemViewSettingsPage(QWidget *parent = 0); + + inline bool hasDefaults() const { return true; } + +public slots: + void save(); + +private slots: + void updateBufferViewPreview(QWidget *button); + +private: + Ui::ItemViewSettingsPage ui; + QSignalMapper *_mapper; + QTreeWidgetItem *_networkItem, *_defaultBufferItem, *_inactiveBufferItem, + *_activeBufferItem, *_unreadBufferItem, *_highlightedBufferItem; + + inline QString settingsKey() const { return QString("ItemViews"); } +}; + +#endif diff --git a/src/qtui/settingspages/itemviewsettingspage.ui b/src/qtui/settingspages/itemviewsettingspage.ui new file mode 100644 index 00000000..1f742047 --- /dev/null +++ b/src/qtui/settingspages/itemviewsettingspage.ui @@ -0,0 +1,438 @@ + + + ItemViewSettingsPage + + + + 0 + 0 + 374 + 508 + + + + Form + + + + + + + + Custom font: + + + /UiStyle/Fonts/UseCustomItemViewFont + + + false + + + + + + + false + + + /UiStyle/Fonts/ItemView + + + + + + + + + + + + Show icons + + + true + + + /UiStyle/ShowItemViewIcons + + + true + + + + + + + Chat List + + + + + + Display topic in tooltip + + + DisplayTopicInTooltip + + + false + + + + + + + Mouse wheel changes selected chat + + + false + + + MouseWheelChangesBuffer + + + false + + + + + + + Use Custom Colors + + + true + + + /UiStyle/Colors/UseBufferViewColors + + + false + + + + + + + + Standard: + + + + + + + ... + + + /UiStyle/Colors/DefaultBuffer + + + + 0 + 0 + 0 + + + + + + + + Inactive: + + + + + + + ... + + + /UiStyle/Colors/InactiveBuffer + + + + 160 + 160 + 164 + + + + + + + + Unread messages: + + + + + + + ... + + + /UiStyle/Colors/UnreadBuffer + + + + 0 + 0 + 128 + + + + + + + + Highlight: + + + + + + + ... + + + /UiStyle/Colors/HighlightedBuffer + + + + 255 + 128 + 0 + + + + + + + + Other activity: + + + + + + + ... + + + /UiStyle/Colors/ActiveBuffer + + + + 0 + 128 + 0 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + QAbstractItemView::NoEditTriggers + + + false + + + false + + + false + + + + 1 + + + + + + + + + + + + + + Custom Nick List Colors + + + true + + + /UiStyle/Colors/UseNickViewColors + + + false + + + + + + Online: + + + + + + + ... + + + /UiStyle/Colors/OnlineNick + + + + 0 + 0 + 0 + + + + + + + + Qt::Horizontal + + + + 88 + 20 + + + + + + + + Away: + + + + + + + ... + + + /UiStyle/Colors/AwayNick + + + + 160 + 160 + 164 + + + + + + + + Qt::Horizontal + + + + 87 + 20 + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + FontSelector + QWidget +
fontselector.h
+ 1 +
+ + ColorButton + QToolButton +
colorbutton.h
+
+
+ + useCustomItemViewFont + showItemViewIcons + displayTopicInTooltip + mouseWheelChangesBuffers + useBufferViewColors + defaultBufferColor + inactiveBufferColor + unreadBufferColor + highlightedBufferColor + activeBufferColor + useNickViewColors + onlineNickColor + awayNickColor + bufferViewPreview + + + + + useCustomItemViewFont + toggled(bool) + widget + setEnabled(bool) + + + 114 + 16 + + + 235 + 17 + + + + +
diff --git a/src/qtui/settingspages/settingspages.inc b/src/qtui/settingspages/settingspages.inc index b993cdc3..3e0fb19c 100644 --- a/src/qtui/settingspages/settingspages.inc +++ b/src/qtui/settingspages/settingspages.inc @@ -1,7 +1,7 @@ # Putting $FOO in SETTINGSPAGES automatically includes # $FOOsettingspage.cpp, $FOOsettingspage.h and $FOOsettingspage.ui -set(SETTINGSPAGES aliases appearance backlog bufferview chatview connection chatmonitor general highlight identities networks) +set(SETTINGSPAGES aliases appearance backlog bufferview chatview connection chatmonitor general highlight identities itemview networks) # Specify additional files (e.g. for subdialogs) here! set(SP_SOURCES aliasesmodel.cpp identityeditwidget.cpp notificationssettingspage.cpp)