Say hello to the first settings page in our shiny new, almost working SettingsDlg...
authorManuel Nickschas <sputnick@quassel-irc.org>
Wed, 26 Dec 2007 19:52:34 +0000 (19:52 +0000)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 26 Dec 2007 19:52:34 +0000 (19:52 +0000)
Now you can set the ChatWidget's fonts. To make this work, I made UiStyle (and
automagically its derived classes) remember custom set formats. Also, default formats
can be restored. This allows to change, save and restore all the style's formats
at run-time...
For now, in the settings dialog you can only edit the ChatWidget's base fonts, but later on
we will certainly allow more tweaking of the current style.

24 files changed:
Quassel.kdevelop.filelist
src/common/settings.cpp
src/common/settings.h
src/core/server.cpp
src/qtopia/qtopiauistyle.cpp
src/qtui/mainwin.cpp
src/qtui/qtui.pri
src/qtui/qtuistyle.cpp
src/qtui/settingsdlg.cpp
src/qtui/settingsdlg.h
src/qtui/settingspages/fontssettingspage.cpp [new file with mode: 0644]
src/qtui/settingspages/fontssettingspage.h [new file with mode: 0644]
src/qtui/settingspages/fontssettingspage.ui [new file with mode: 0644]
src/qtui/settingspages/settingspages.pri [new file with mode: 0644]
src/qtui/ui/settingsdlg.ui
src/uisupport/settingspage.cpp
src/uisupport/settingspage.h
src/uisupport/uisettings.cpp
src/uisupport/uisettings.h
src/uisupport/uistyle.cpp
src/uisupport/uistyle.h
src/uisupport/uistylesettings.cpp [new file with mode: 0644]
src/uisupport/uistylesettings.h [new file with mode: 0644]
src/uisupport/uisupport.pri

index f6c3b0b..07f5651 100644 (file)
@@ -161,8 +161,12 @@ src/qtui/serverlist.cpp
 src/qtui/serverlist.h
 src/qtui/settingsdlg.cpp
 src/qtui/settingsdlg.h
+src/qtui/settingspages
 src/qtui/settingspages.cpp
 src/qtui/settingspages.h
+src/qtui/settingspages/settingspages.pri
+src/qtui/settingspages/sp_uistyle.cpp
+src/qtui/settingspages/sp_uistyle.h
 src/qtui/topicwidget.cpp
 src/qtui/topicwidget.h
 src/qtui/ui
@@ -179,6 +183,7 @@ src/qtui/ui/identitieseditdlg.ui
 src/qtui/ui/mainwin.ui
 src/qtui/ui/networkeditdlg.ui
 src/qtui/ui/nickeditdlg.ui
+src/qtui/ui/nicklistwidget.ui
 src/qtui/ui/servereditdlg.ui
 src/qtui/ui/serverlistdlg.ui
 src/qtui/ui/settingsdlg.ui
@@ -205,4 +210,6 @@ src/uisupport/uisettings.cpp
 src/uisupport/uisettings.h
 src/uisupport/uistyle.cpp
 src/uisupport/uistyle.h
+src/uisupport/uistylesettings.cpp
+src/uisupport/uistylesettings.h
 src/uisupport/uisupport.pri
index 3d43e0a..0563ff7 100644 (file)
@@ -65,15 +65,21 @@ QStringList Settings::allLocalKeys() {
   return res;
 }
 
-QStringList Settings::localChildKeys() {
-  beginGroup(group);
+QStringList Settings::localChildKeys(const QString &rootkey) {
+  QString g;
+  if(rootkey.isEmpty()) g = group;
+  else g = QString("%1/%2").arg(group, rootkey);
+  beginGroup(g);
   QStringList res = childKeys();
   endGroup();
   return res;
 }
 
-QStringList Settings::localChildGroups() {
-  beginGroup(group);
+QStringList Settings::localChildGroups(const QString &rootkey) {
+  QString g;
+  if(rootkey.isEmpty()) g = group;
+  else g = QString("%1/%2").arg(group, rootkey);
+  beginGroup(g);
   QStringList res = childGroups();
   endGroup();
   return res;
index fcf9cd5..7142e72 100644 (file)
@@ -30,16 +30,19 @@ class Settings : private QSettings {
   public:
     virtual ~Settings();
 
-    static void setGuiValue(QString, QVariant) {};
-    static QVariant guiValue(QString, QVariant = QVariant()) { return QVariant(); }
+    //static void setGuiValue(QString, QVariant) {};
+    //static QVariant guiValue(QString, QVariant = QVariant()) { return QVariant(); }
+
+    enum Mode { Default, Custom };
+
   protected:
     Settings(QString group = "General");
 
     void setGroup(QString group);
 
     virtual QStringList allLocalKeys();
-    virtual QStringList localChildKeys();
-    virtual QStringList localChildGroups();
+    virtual QStringList localChildKeys(const QString &rootkey = QString());
+    virtual QStringList localChildGroups(const QString &rootkey = QString());
     //virtual QStringList allSessionKeys() = 0;
     virtual QStringList sessionKeys() = 0;
 
index b222b0d..f29e345 100644 (file)
@@ -219,9 +219,11 @@ CoreSession *Server::coreSession() const {
 
 /* Exception classes for message handling */
 Server::ParseError::ParseError(QString cmd, QString prefix, QStringList params) {
+  Q_UNUSED(prefix);
   _msg = QString("Command Parse Error: ") + cmd + params.join(" ");
 }
 
 Server::UnknownCmdError::UnknownCmdError(QString cmd, QString prefix, QStringList params) {
-  _msg = QString("Unknown Command: ") + cmd;
+  Q_UNUSED(prefix);
+  _msg = QString("Unknown Command: ") + cmd + params.join(" ");
 }
index 88dd921..5876eae 100644 (file)
  ***************************************************************************/
 
 #include "qtopiauistyle.h"
+#include "settings.h"
 
-QtopiaUiStyle::QtopiaUiStyle() : UiStyle() {
+QtopiaUiStyle::QtopiaUiStyle() : UiStyle("QtopiaUiStyle") {
 
   QTextCharFormat def;
   def.setForeground(QBrush("#000000"));
   def.setFont(QFont("Verdana",5));
-  setFormat(None, def);
+  setFormat(None, def, Settings::Default);
 
   // We need to just set our internal formats; everything else is done by the base class...
 
@@ -33,81 +34,81 @@ QtopiaUiStyle::QtopiaUiStyle() : UiStyle() {
 
   QTextCharFormat plainMsg;
   plainMsg.setForeground(QBrush("#000000"));
-  setFormat(PlainMsg, plainMsg);
+  setFormat(PlainMsg, plainMsg, Settings::Default);
 
   QTextCharFormat notice;
   notice.setForeground(QBrush("#000080"));
-  setFormat(NoticeMsg, notice);
+  setFormat(NoticeMsg, notice, Settings::Default);
 
   QTextCharFormat server;
   server.setForeground(QBrush("#000080"));
-  setFormat(ServerMsg, server);
+  setFormat(ServerMsg, server, Settings::Default);
 
   QTextCharFormat error;
   error.setForeground(QBrush("#ff0000"));
-  setFormat(ErrorMsg, error);
+  setFormat(ErrorMsg, error, Settings::Default);
 
   QTextCharFormat join;
   join.setForeground(QBrush("#008000"));
-  setFormat(JoinMsg, join);
+  setFormat(JoinMsg, join, Settings::Default);
 
   QTextCharFormat part;
   part.setForeground(QBrush("#ff0000"));
-  setFormat(PartMsg, part);
+  setFormat(PartMsg, part, Settings::Default);
 
   QTextCharFormat quit;
   quit.setForeground(QBrush("#ff0000"));
-  setFormat(QuitMsg, quit);
+  setFormat(QuitMsg, quit, Settings::Default);
 
   QTextCharFormat kick;
   kick.setForeground(QBrush("#ff0000"));
-  setFormat(KickMsg, kick);
+  setFormat(KickMsg, kick, Settings::Default);
 
   QTextCharFormat nren;
   nren.setForeground(QBrush("#6a5acd"));
-  setFormat(RenameMsg, nren);
+  setFormat(RenameMsg, nren, Settings::Default);
 
   QTextCharFormat mode;
   mode.setForeground(QBrush("#4682b4"));
-  setFormat(ModeMsg, mode);
+  setFormat(ModeMsg, mode, Settings::Default);
 
   QTextCharFormat action;
   action.setFontItalic(true);
   action.setForeground(QBrush("#8b008b"));
-  setFormat(ActionMsg, action);
+  setFormat(ActionMsg, action, Settings::Default);
 
   // Internal message element formats
   QTextCharFormat ts;
   ts.setForeground(QBrush("#808080"));
-  setFormat(Timestamp, ts);
+  setFormat(Timestamp, ts, Settings::Default);
 
   QTextCharFormat sender;
   sender.setAnchor(true);
   sender.setForeground(QBrush("#000080"));
-  setFormat(Sender, sender);
+  setFormat(Sender, sender, Settings::Default);
 
   QTextCharFormat nick;
   nick.setAnchor(true);
   nick.setFontWeight(QFont::Bold);
-  setFormat(Nick, nick);
+  setFormat(Nick, nick, Settings::Default);
 
   QTextCharFormat hostmask;
   hostmask.setFontItalic(true);
-  setFormat(Hostmask, hostmask);
+  setFormat(Hostmask, hostmask, Settings::Default);
 
   QTextCharFormat channel;
   channel.setAnchor(true);
   channel.setFontWeight(QFont::Bold);
-  setFormat(ChannelName, channel);
+  setFormat(ChannelName, channel, Settings::Default);
 
   QTextCharFormat flags;
   flags.setFontWeight(QFont::Bold);
-  setFormat(ModeFlags, flags);
+  setFormat(ModeFlags, flags, Settings::Default);
 
   QTextCharFormat url;
   url.setFontUnderline(true);
   url.setAnchor(true);
-  setFormat(Url, url);
+  setFormat(Url, url, Settings::Default);
 
 }
 
index 10b2b98..0d4453d 100644 (file)
@@ -27,7 +27,6 @@
 #include "nicklistwidget.h"
 #include "serverlist.h"
 #include "settingsdlg.h"
-//#include "settingspage.h"
 #include "signalproxy.h"
 
 #include "topicwidget.h"
@@ -35,6 +34,8 @@
 #include "selectionmodelsynchronizer.h"
 #include "mappedselectionmodel.h"
 
+#include "settingspages/fontssettingspage.h"
+
 MainWin::MainWin(QtUi *_gui, QWidget *parent) : QMainWindow(parent), gui(_gui) {
   ui.setupUi(this);
   setWindowTitle("Quassel IRC");
@@ -68,6 +69,7 @@ void MainWin::init() {
 
   setupMenus();
   setupViews();
+  setupSettingsDlg();
 
   // create nick dock
   nickDock = new QDockWidget("Nicks", this);
@@ -125,6 +127,7 @@ void MainWin::init() {
 
   ui.menuViews->addAction(dock->toggleViewAction());
 
+  //showSettingsDlg();
 }
 
 MainWin::~MainWin() {
@@ -186,6 +189,11 @@ void MainWin::addBufferView(const QString &viewname, QAbstractItemModel *model,
   netViews.append(dock);
 }
 
+void MainWin::setupSettingsDlg() {
+  settingsDlg->registerSettingsPage(new FontsSettingsPage(settingsDlg));
+
+}
+
 void MainWin::connectedToCore() {
   foreach(BufferInfo id, Client::allBufferInfos()) {
     emit requestBacklog(id, 1000, -1);
index cd283c5..c5aaab9 100644 (file)
@@ -17,3 +17,11 @@ FORMNAMES = identitiesdlg.ui identitieseditdlg.ui networkeditdlg.ui mainwin.ui n
 for(ui, FORMNAMES) {
   FRMS += ui/$${ui}
 }
+
+# Include settingspages
+include(settingspages/settingspages.pri)
+for(page, SETTINGSPAGES) {
+  SRCS += settingspages/$${page}settingspage.cpp
+  HDRS += settingspages/$${page}settingspage.h
+  FRMS += settingspages/$${page}settingspage.ui
+}
index 18a7407..c96078e 100644 (file)
 
 #include "qtuistyle.h"
 
-QtUiStyle::QtUiStyle() : UiStyle() {
+QtUiStyle::QtUiStyle() : UiStyle("QtUiStyle") {
   // We need to just set our internal formats; everything else is done by the base class...
 
   // Internal message formats
   QTextCharFormat plainMsg;
   plainMsg.setForeground(QBrush("black"));
-  setFormat(PlainMsg, plainMsg);
+  setFormat(PlainMsg, plainMsg, Settings::Default);
 
   QTextCharFormat notice;
   notice.setForeground(QBrush("navy"));
-  setFormat(NoticeMsg, notice);
+  setFormat(NoticeMsg, notice, Settings::Default);
 
   QTextCharFormat server;
   server.setForeground(QBrush("navy"));
-  setFormat(ServerMsg, server);
+  setFormat(ServerMsg, server, Settings::Default);
 
   QTextCharFormat error;
   error.setForeground(QBrush("red"));
-  setFormat(ErrorMsg, error);
+  setFormat(ErrorMsg, error, Settings::Default);
 
   QTextCharFormat join;
   join.setForeground(QBrush("green"));
-  setFormat(JoinMsg, join);
+  setFormat(JoinMsg, join, Settings::Default);
 
   QTextCharFormat part;
   part.setForeground(QBrush("indianred"));
-  setFormat(PartMsg, part);
+  setFormat(PartMsg, part, Settings::Default);
 
   QTextCharFormat quit;
   quit.setForeground(QBrush("indianred"));
-  setFormat(QuitMsg, quit);
+  setFormat(QuitMsg, quit, Settings::Default);
 
   QTextCharFormat kick;
   kick.setForeground(QBrush("indianred"));
-  setFormat(KickMsg, kick);
+  setFormat(KickMsg, kick, Settings::Default);
 
   QTextCharFormat nren;
   nren.setForeground(QBrush("magenta"));
-  setFormat(RenameMsg, nren);
+  setFormat(RenameMsg, nren, Settings::Default);
 
   QTextCharFormat mode;
   mode.setForeground(QBrush("steelblue"));
-  setFormat(ModeMsg, mode);
+  setFormat(ModeMsg, mode, Settings::Default);
 
   QTextCharFormat action;
   action.setFontItalic(true);
   action.setForeground(QBrush("darkmagenta"));
-  setFormat(ActionMsg, action);
+  setFormat(ActionMsg, action, Settings::Default);
 
   // Internal message element formats
   QTextCharFormat ts;
   ts.setForeground(QBrush("grey"));
-  setFormat(Timestamp, ts);
+  setFormat(Timestamp, ts, Settings::Default);
 
   QTextCharFormat sender;
   sender.setAnchor(true);
   sender.setForeground(QBrush("navy"));
-  setFormat(Sender, sender);
+  setFormat(Sender, sender, Settings::Default);
 
   QTextCharFormat nick;
   nick.setAnchor(true);
   nick.setFontWeight(QFont::Bold);
-  setFormat(Nick, nick);
+  setFormat(Nick, nick, Settings::Default);
 
   QTextCharFormat hostmask;
   hostmask.setFontItalic(true);
-  setFormat(Hostmask, hostmask);
+  setFormat(Hostmask, hostmask, Settings::Default);
 
   QTextCharFormat channel;
   channel.setAnchor(true);
   channel.setFontWeight(QFont::Bold);
-  setFormat(ChannelName, channel);
+  setFormat(ChannelName, channel, Settings::Default);
 
   QTextCharFormat flags;
   flags.setFontWeight(QFont::Bold);
-  setFormat(ModeFlags, flags);
+  setFormat(ModeFlags, flags, Settings::Default);
 
   QTextCharFormat url;
   url.setFontUnderline(true);
   url.setAnchor(true);
-  setFormat(Url, url);
+  setFormat(Url, url, Settings::Default);
 
 
 }
index 422f64d..3945cd1 100644 (file)
@@ -23,8 +23,8 @@
 SettingsDlg::SettingsDlg(QWidget *parent) : QDialog(parent) {
   ui.setupUi(this);
 
-  ui.settingsFrame->setWidgetResizable(true);
-  ui.settingsFrame->setWidget(ui.settingsStack);
+  //ui.settingsFrame->setWidgetResizable(true);
+  //ui.settingsFrame->setWidget(ui.settingsStack);
   ui.settingsTree->setRootIsDecorated(false);
 
   connect(ui.settingsTree, SIGNAL(itemSelectionChanged()), this, SLOT(itemSelected()));
@@ -33,7 +33,7 @@ SettingsDlg::SettingsDlg(QWidget *parent) : QDialog(parent) {
 
 
 void SettingsDlg::registerSettingsPage(SettingsPage *sp) {
-  sp->setParent(this);
+  sp->setParent(ui.settingsStack);
   ui.settingsStack->addWidget(sp);
 
   QTreeWidgetItem *cat;
@@ -43,8 +43,11 @@ void SettingsDlg::registerSettingsPage(SettingsPage *sp) {
     cat->setExpanded(true);
     cat->setFlags(Qt::ItemIsEnabled);
   } else cat = cats[0];
-  QTreeWidgetItem *p = new QTreeWidgetItem(cat, QStringList(sp->title()));
+  new QTreeWidgetItem(cat, QStringList(sp->title()));
   pages[QString("%1$%2").arg(sp->category(), sp->title())] = sp;
+  updateGeometry();
+  // TESTING
+  //selectPage(sp->category(), sp->title());
 }
 
 void SettingsDlg::selectPage(const QString &cat, const QString &title) {
@@ -63,28 +66,45 @@ void SettingsDlg::itemSelected() {
     QString cat = parent->text(0);
     QString title = items[0]->text(0);
     selectPage(cat, title);
+    ui.pageTitle->setText(title);
   }
 }
 
 void SettingsDlg::buttonClicked(QAbstractButton *button) {
-  switch(ui.buttonBox->buttonRole(button)) {
-    case QDialogButtonBox::AcceptRole:
+  switch(ui.buttonBox->standardButton(button)) {
+    case QDialogButtonBox::Ok:
       applyChanges();
       accept();
       break;
-    case QDialogButtonBox::ApplyRole:
+    case QDialogButtonBox::Apply:
       applyChanges();
       break;
-    case QDialogButtonBox::RejectRole:
+    case QDialogButtonBox::Cancel:
       reject();
       break;
+    case QDialogButtonBox::Reset:
+      reload();
+      break;
+    case QDialogButtonBox::RestoreDefaults:
+      loadDefaults();
+      break;
     default:
       break;
   }
 }
 
 void SettingsDlg::applyChanges() {
-  //SettingsInterface *sp = qobject_cast<SettingsInterface *>(ui.settingsStack->currentWidget());
-  //if(sp) sp->applyChanges();
+  foreach(SettingsPage *page, pages.values()) {
+    page->save();
+  }
 }
 
+void SettingsDlg::reload() {
+  SettingsPage *page = qobject_cast<SettingsPage *>(ui.settingsStack->currentWidget());
+  if(page) page->load();
+}
+
+void SettingsDlg::loadDefaults() {
+  SettingsPage *page = qobject_cast<SettingsPage *>(ui.settingsStack->currentWidget());
+  if(page) page->defaults();
+}
index c4640bd..d7dc6d8 100644 (file)
@@ -40,6 +40,8 @@ class SettingsDlg : public QDialog {
     void itemSelected();
     void buttonClicked(QAbstractButton *);
     void applyChanges();
+    void reload();
+    void loadDefaults();
 
   private:
     Ui::SettingsDlg ui;
diff --git a/src/qtui/settingspages/fontssettingspage.cpp b/src/qtui/settingspages/fontssettingspage.cpp
new file mode 100644 (file)
index 0000000..3a9843e
--- /dev/null
@@ -0,0 +1,122 @@
+/***************************************************************************
+ *   Copyright (C) 2005-08 by the Quassel IRC Team                         *
+ *   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) any later version.                                   *
+ *                                                                         *
+ *   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 "fontssettingspage.h"
+
+#include "qtui.h"
+
+#include <QFontDialog>
+
+FontsSettingsPage::FontsSettingsPage(QWidget *parent)
+  : SettingsPage(tr("Appearance"), tr("Fonts"), parent) {
+
+  ui.setupUi(this);
+  mapper = new QSignalMapper(this);
+  connect(ui.chooseGeneral, SIGNAL(clicked()), mapper, SLOT(map()));
+  connect(ui.chooseTopic, SIGNAL(clicked()), mapper, SLOT(map()));
+  connect(ui.chooseNickList, SIGNAL(clicked()), mapper, SLOT(map()));
+  connect(ui.chooseBufferView, SIGNAL(clicked()), mapper, SLOT(map()));
+  connect(ui.chooseChatMessages, SIGNAL(clicked()), mapper, SLOT(map()));
+  connect(ui.chooseNicks, SIGNAL(clicked()), mapper, SLOT(map()));
+  connect(ui.chooseTimestamp, SIGNAL(clicked()), mapper, SLOT(map()));
+
+  mapper->setMapping(ui.chooseGeneral, ui.demoGeneral);
+  mapper->setMapping(ui.chooseTopic, ui.demoTopic);
+  mapper->setMapping(ui.chooseNickList, ui.demoNickList);
+  mapper->setMapping(ui.chooseBufferView, ui.demoBufferView);
+  mapper->setMapping(ui.chooseChatMessages, ui.demoChatMessages);
+  mapper->setMapping(ui.chooseNicks, ui.demoNicks);
+  mapper->setMapping(ui.chooseTimestamp, ui.demoTimestamp);
+
+  connect(mapper, SIGNAL(mapped(QWidget *)), this, SLOT(chooseFont(QWidget *)));
+
+  load();
+
+}
+
+bool FontsSettingsPage::hasChanged() const {
+
+  return false;
+}
+
+void FontsSettingsPage::defaults() {
+  load(Settings::Default);
+
+}
+
+void FontsSettingsPage::load() {
+  load(Settings::Custom);
+  changeState(false);
+}
+
+void FontsSettingsPage::load(Settings::Mode mode) {
+  QTextCharFormat chatFormat = QtUi::style()->format(UiStyle::None, mode);
+  setFont(ui.demoChatMessages, chatFormat.font());
+  QTextCharFormat nicksFormat = QtUi::style()->format(UiStyle::Sender, mode);
+  if(nicksFormat.hasProperty(QTextFormat::FontFamily)) {
+    setFont(ui.demoNicks, nicksFormat.font());
+    ui.checkNicks->setChecked(true);
+  } else {
+    setFont(ui.demoNicks, chatFormat.font());
+    ui.checkNicks->setChecked(false);
+  }
+  QTextCharFormat timestampFormat = QtUi::style()->format(UiStyle::Timestamp, mode);
+  if(timestampFormat.hasProperty(QTextFormat::FontFamily)) {
+    setFont(ui.demoTimestamp, timestampFormat.font());
+    ui.checkTimestamp->setChecked(true);
+  } else {
+    setFont(ui.demoTimestamp, chatFormat.font());
+    ui.checkTimestamp->setChecked(false);
+  }
+
+}
+
+void FontsSettingsPage::save() {
+  QTextCharFormat chatFormat = QtUi::style()->format(UiStyle::None);
+  chatFormat.setFont(ui.demoChatMessages->font());
+  QtUi::style()->setFormat(UiStyle::None, chatFormat, Settings::Custom);
+  if(ui.checkNicks->checkState() == Qt::Checked) {
+    QTextCharFormat nicksFormat = QtUi::style()->format(UiStyle::Sender);
+    nicksFormat.setFont(ui.demoNicks->font());
+    QtUi::style()->setFormat(UiStyle::Sender, nicksFormat, Settings::Custom);
+  }
+  if(ui.checkTimestamp->checkState() == Qt::Checked) {
+    QTextCharFormat timestampFormat = QtUi::style()->format(UiStyle::Timestamp);
+    timestampFormat.setFont(ui.demoTimestamp->font());
+    QtUi::style()->setFormat(UiStyle::Timestamp, timestampFormat, Settings::Custom);
+  }
+  changeState(false);
+}
+
+void FontsSettingsPage::setFont(QLabel *label, const QFont &font) {
+  QFontInfo fontInfo(font);
+  label->setFont(font);
+  label->setText(QString("%1 %2").arg(fontInfo.family()).arg(fontInfo.pointSize()));
+}
+
+void FontsSettingsPage::chooseFont(QWidget *widget) {
+  QLabel *label = qobject_cast<QLabel *>(widget);
+  Q_ASSERT(label);
+  bool ok;
+  QFont font = QFontDialog::getFont(&ok, label->font());
+  if(ok) {
+    setFont(label, font);
+  }
+}
diff --git a/src/qtui/settingspages/fontssettingspage.h b/src/qtui/settingspages/fontssettingspage.h
new file mode 100644 (file)
index 0000000..7928cb8
--- /dev/null
@@ -0,0 +1,56 @@
+/***************************************************************************
+ *   Copyright (C) 2005-08 by the Quassel IRC Team                         *
+ *   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) any later version.                                   *
+ *                                                                         *
+ *   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 _FONTSSETTINGSPAGE_H_
+#define _FONTSSETTINGSPAGE_H_
+
+#include "settings.h"
+#include "settingspage.h"
+
+#include "ui_fontssettingspage.h"
+
+class QSignalMapper;
+
+class FontsSettingsPage : public SettingsPage {
+  Q_OBJECT
+
+  public:
+    FontsSettingsPage(QWidget *parent = 0);
+
+    bool hasChanged() const;
+
+  public slots:
+    void save();
+    void load();
+    void defaults();
+
+  private slots:
+    void load(Settings::Mode mode);
+    void setFont(QLabel *label, const QFont &font);
+    void chooseFont(QWidget *label);
+
+  private:
+    Ui::FontsSettingsPage ui;
+
+    QSignalMapper *mapper;
+
+};
+
+#endif
diff --git a/src/qtui/settingspages/fontssettingspage.ui b/src/qtui/settingspages/fontssettingspage.ui
new file mode 100644 (file)
index 0000000..d6abdec
--- /dev/null
@@ -0,0 +1,550 @@
+<ui version="4.0" >
+ <class>FontsSettingsPage</class>
+ <widget class="QWidget" name="FontsSettingsPage" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>524</width>
+    <height>400</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" >
+   <item>
+    <widget class="QGroupBox" name="groupBox" >
+     <property name="enabled" >
+      <bool>false</bool>
+     </property>
+     <property name="title" >
+      <string>Custom Application Fonts</string>
+     </property>
+     <property name="checkable" >
+      <bool>true</bool>
+     </property>
+     <property name="checked" >
+      <bool>false</bool>
+     </property>
+     <layout class="QVBoxLayout" >
+      <item>
+       <layout class="QGridLayout" >
+        <item row="0" column="0" >
+         <widget class="QLabel" name="label" >
+          <property name="text" >
+           <string>General:</string>
+          </property>
+         </widget>
+        </item>
+        <item row="0" column="1" >
+         <widget class="QLabel" name="demoGeneral" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Preferred" hsizetype="Expanding" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="frameShape" >
+           <enum>QFrame::StyledPanel</enum>
+          </property>
+          <property name="frameShadow" >
+           <enum>QFrame::Sunken</enum>
+          </property>
+          <property name="text" >
+           <string>Font</string>
+          </property>
+          <property name="alignment" >
+           <set>Qt::AlignCenter</set>
+          </property>
+         </widget>
+        </item>
+        <item row="0" column="2" >
+         <widget class="QPushButton" name="chooseGeneral" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text" >
+           <string>Choose...</string>
+          </property>
+         </widget>
+        </item>
+        <item row="1" column="0" >
+         <widget class="QCheckBox" name="checkTopic" >
+          <property name="text" >
+           <string>Topic:</string>
+          </property>
+         </widget>
+        </item>
+        <item row="1" column="1" >
+         <widget class="QLabel" name="demoTopic" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Preferred" hsizetype="Expanding" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="frameShape" >
+           <enum>QFrame::StyledPanel</enum>
+          </property>
+          <property name="frameShadow" >
+           <enum>QFrame::Sunken</enum>
+          </property>
+          <property name="text" >
+           <string>Font</string>
+          </property>
+          <property name="alignment" >
+           <set>Qt::AlignCenter</set>
+          </property>
+         </widget>
+        </item>
+        <item row="1" column="2" >
+         <widget class="QPushButton" name="chooseTopic" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text" >
+           <string>Choose...</string>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="0" >
+         <widget class="QCheckBox" name="checkBufferView" >
+          <property name="text" >
+           <string>Buffer Views:</string>
+          </property>
+          <property name="checked" >
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="1" >
+         <widget class="QLabel" name="demoBufferView" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Preferred" hsizetype="Expanding" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="frameShape" >
+           <enum>QFrame::StyledPanel</enum>
+          </property>
+          <property name="frameShadow" >
+           <enum>QFrame::Sunken</enum>
+          </property>
+          <property name="text" >
+           <string>Font</string>
+          </property>
+          <property name="alignment" >
+           <set>Qt::AlignCenter</set>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="2" >
+         <widget class="QPushButton" name="chooseBufferView" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text" >
+           <string>Choose...</string>
+          </property>
+         </widget>
+        </item>
+        <item row="3" column="0" >
+         <widget class="QCheckBox" name="checkNickList" >
+          <property name="text" >
+           <string>Nick List:</string>
+          </property>
+          <property name="checked" >
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item row="3" column="1" >
+         <widget class="QLabel" name="demoNickList" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Preferred" hsizetype="Expanding" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="frameShape" >
+           <enum>QFrame::StyledPanel</enum>
+          </property>
+          <property name="frameShadow" >
+           <enum>QFrame::Sunken</enum>
+          </property>
+          <property name="text" >
+           <string>Font</string>
+          </property>
+          <property name="alignment" >
+           <set>Qt::AlignCenter</set>
+          </property>
+         </widget>
+        </item>
+        <item row="3" column="2" >
+         <widget class="QPushButton" name="chooseNickList" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text" >
+           <string>Choose...</string>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="groupBox_2" >
+     <property name="title" >
+      <string>Chat Widget</string>
+     </property>
+     <layout class="QVBoxLayout" >
+      <item>
+       <layout class="QGridLayout" >
+        <item row="0" column="0" >
+         <widget class="QLabel" name="label_2" >
+          <property name="text" >
+           <string>General:</string>
+          </property>
+         </widget>
+        </item>
+        <item row="0" column="1" >
+         <widget class="QLabel" name="demoChatMessages" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Preferred" hsizetype="Expanding" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="frameShape" >
+           <enum>QFrame::StyledPanel</enum>
+          </property>
+          <property name="frameShadow" >
+           <enum>QFrame::Sunken</enum>
+          </property>
+          <property name="text" >
+           <string>Font</string>
+          </property>
+          <property name="alignment" >
+           <set>Qt::AlignCenter</set>
+          </property>
+         </widget>
+        </item>
+        <item row="0" column="2" >
+         <widget class="QPushButton" name="chooseChatMessages" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text" >
+           <string>Choose...</string>
+          </property>
+         </widget>
+        </item>
+        <item row="1" column="1" >
+         <widget class="QLabel" name="demoNicks" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Preferred" hsizetype="Expanding" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="frameShape" >
+           <enum>QFrame::StyledPanel</enum>
+          </property>
+          <property name="frameShadow" >
+           <enum>QFrame::Sunken</enum>
+          </property>
+          <property name="text" >
+           <string>Font</string>
+          </property>
+          <property name="alignment" >
+           <set>Qt::AlignCenter</set>
+          </property>
+         </widget>
+        </item>
+        <item row="1" column="2" >
+         <widget class="QPushButton" name="chooseNicks" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text" >
+           <string>Choose...</string>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="1" >
+         <widget class="QLabel" name="demoTimestamp" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Preferred" hsizetype="Expanding" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="frameShape" >
+           <enum>QFrame::StyledPanel</enum>
+          </property>
+          <property name="frameShadow" >
+           <enum>QFrame::Sunken</enum>
+          </property>
+          <property name="text" >
+           <string>Font</string>
+          </property>
+          <property name="alignment" >
+           <set>Qt::AlignCenter</set>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="2" >
+         <widget class="QPushButton" name="chooseTimestamp" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text" >
+           <string>Choose...</string>
+          </property>
+         </widget>
+        </item>
+        <item row="1" column="0" >
+         <widget class="QCheckBox" name="checkNicks" >
+          <property name="text" >
+           <string>Nicks:</string>
+          </property>
+          <property name="checked" >
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="0" >
+         <widget class="QCheckBox" name="checkTimestamp" >
+          <property name="text" >
+           <string>Timestamp:</string>
+          </property>
+          <property name="checked" >
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QLabel" name="label_3" >
+     <property name="font" >
+      <font>
+       <italic>true</italic>
+      </font>
+     </property>
+     <property name="text" >
+      <string>Some of these settings require a restart of the Quassel Client in order to take effect. We intend to fix this.</string>
+     </property>
+     <property name="wordWrap" >
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <spacer>
+     <property name="orientation" >
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" >
+      <size>
+       <width>20</width>
+       <height>41</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>checkTimestamp</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>demoTimestamp</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>46</x>
+     <y>292</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>183</x>
+     <y>290</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>checkTimestamp</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>chooseTimestamp</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>96</x>
+     <y>288</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>452</x>
+     <y>293</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>checkBufferView</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>demoBufferView</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>32</x>
+     <y>116</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>215</x>
+     <y>117</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>checkBufferView</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>chooseBufferView</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>86</x>
+     <y>113</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>451</x>
+     <y>118</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>checkNickList</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>demoNickList</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>69</x>
+     <y>147</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>199</x>
+     <y>151</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>checkNickList</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>chooseNickList</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>78</x>
+     <y>145</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>455</x>
+     <y>151</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>checkTopic</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>demoTopic</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>34</x>
+     <y>81</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>190</x>
+     <y>87</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>checkTopic</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>chooseTopic</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>101</x>
+     <y>81</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>451</x>
+     <y>82</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>checkNicks</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>demoNicks</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>40</x>
+     <y>255</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>211</x>
+     <y>257</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>checkNicks</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>chooseNicks</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>89</x>
+     <y>257</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>447</x>
+     <y>258</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
diff --git a/src/qtui/settingspages/settingspages.pri b/src/qtui/settingspages/settingspages.pri
new file mode 100644 (file)
index 0000000..8ee87a2
--- /dev/null
@@ -0,0 +1 @@
+SETTINGSPAGES = fonts
index 8d87a7c..ed00115 100644 (file)
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>784</width>
-    <height>558</height>
+    <width>742</width>
+    <height>502</height>
    </rect>
   </property>
   <property name="windowTitle" >
         <verstretch>0</verstretch>
        </sizepolicy>
       </property>
+      <property name="maximumSize" >
+       <size>
+        <width>200</width>
+        <height>16777215</height>
+       </size>
+      </property>
       <column>
        <property name="text" >
         <string>Settings</string>
        </property>
       </column>
      </widget>
-     <widget class="QScrollArea" name="settingsFrame" >
-      <property name="sizePolicy" >
-       <sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" >
-        <horstretch>0</horstretch>
-        <verstretch>0</verstretch>
-       </sizepolicy>
-      </property>
-      <property name="frameShape" >
-       <enum>QFrame::NoFrame</enum>
-      </property>
-      <property name="frameShadow" >
-       <enum>QFrame::Plain</enum>
-      </property>
+     <widget class="QWidget" name="" >
       <layout class="QVBoxLayout" >
        <item>
-        <widget class="QStackedWidget" name="settingsStack" >
-         <property name="sizePolicy" >
-          <sizepolicy vsizetype="Preferred" hsizetype="Expanding" >
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
+        <widget class="QLabel" name="pageTitle" >
+         <property name="font" >
+          <font>
+           <weight>75</weight>
+           <bold>true</bold>
+          </font>
+         </property>
+         <property name="text" >
+          <string>Settings</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="Line" name="line" >
+         <property name="orientation" >
+          <enum>Qt::Horizontal</enum>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QScrollArea" name="settingsFrame" >
+         <property name="frameShape" >
+          <enum>QFrame::StyledPanel</enum>
+         </property>
+         <property name="frameShadow" >
+          <enum>QFrame::Raised</enum>
          </property>
-         <widget class="QWidget" name="page" />
+         <layout class="QHBoxLayout" >
+          <item>
+           <widget class="QStackedWidget" name="settingsStack" >
+            <widget class="QWidget" name="page_3" />
+            <widget class="QWidget" name="page_4" />
+           </widget>
+          </item>
+         </layout>
         </widget>
        </item>
       </layout>
@@ -66,7 +87,7 @@
       <enum>Qt::Horizontal</enum>
      </property>
      <property name="standardButtons" >
-      <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok|QDialogButtonBox::Reset</set>
+      <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok|QDialogButtonBox::Reset|QDialogButtonBox::RestoreDefaults</set>
      </property>
     </widget>
    </item>
index 0417751..7469454 100644 (file)
@@ -23,6 +23,7 @@
 SettingsPage::SettingsPage(const QString &category, const QString &title, QWidget *parent) : QWidget(parent),
      _category(category), _title(title) {
 
+  _changed = false;
 }
 
 QString SettingsPage::category() const {
@@ -34,9 +35,10 @@ QString SettingsPage::title() const {
 }
 
 void SettingsPage::changed() {
+  _changed = true;
   emit changed(true);
 }
 
 void SettingsPage::changeState(bool hasChanged) {
-  emit changed(hasChanged);
+  if(hasChanged != _changed) emit changed(hasChanged);
 }
index 91171df..b85fa50 100644 (file)
@@ -53,6 +53,7 @@ class SettingsPage : public QWidget {
 
   private:
     QString _category, _title;
+    bool _changed;
 };
 
 #endif
index 2851644..ad04720 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "uisettings.h"
 
-UiSettings::UiSettings() : ClientSettings("UI") {
+UiSettings::UiSettings(const QString &group) : ClientSettings(group) {
 
 
 }
index 282190d..1476f90 100644 (file)
@@ -26,7 +26,7 @@
 class UiSettings : public ClientSettings {
 
   public:
-    UiSettings();
+    UiSettings(const QString &group = "UI");
 
     void setValue(const QString &key, const QVariant &data);
     QVariant value(const QString &key, const QVariant &def = QVariant());
index 5d02db3..1740185 100644 (file)
  ***************************************************************************/
 
 #include "uistyle.h"
+#include "uistylesettings.h"
 
-UiStyle::UiStyle() {
+UiStyle::UiStyle(const QString &settingsKey) : _settingsKey(settingsKey) {
   // Default format
   QTextCharFormat def;
   def.setForeground(QBrush("#000000"));
-  def.setFont(QFont("Verdana",9));
-
-  _formats = QVector<QTextCharFormat>(NumFormatTypes, def);
+  def.setFont(QFont("Mono",12));
+  _defaultFormats = QVector<QTextCharFormat>(NumFormatTypes, def);
+  _customFormats = QVector<QTextCharFormat>(NumFormatTypes, QTextFormat().toCharFormat());
+
+  // Load saved custom formats
+  UiStyleSettings s(_settingsKey);
+  foreach(FormatType type, s.availableFormats()) {
+    _customFormats[type] = s.customFormat(type);
+  }
 
   // Initialize color codes according to mIRC "standard"
   QStringList colors;
@@ -68,19 +75,19 @@ UiStyle::UiStyle() {
     _formatCodes[QString("%Dcf%1").arg(idx)] = (FormatType)(FgCol00 + i);
     _formatCodes[QString("%Dcb%1").arg(idx)] = (FormatType)(BgCol00 + i);
     QTextCharFormat fgf, bgf;
-    fgf.setForeground(QBrush(QColor(colors[i]))); _formats[FgCol00 + i] = fgf;
-    bgf.setBackground(QBrush(QColor(colors[i]))); _formats[BgCol00 + i] = bgf;
+    fgf.setForeground(QBrush(QColor(colors[i]))); setFormat((FormatType)(FgCol00 + i), fgf, Settings::Default);
+    bgf.setBackground(QBrush(QColor(colors[i]))); setFormat((FormatType)(BgCol00 + i), bgf, Settings::Default);
   }
 
   // Set a few more standard formats
   QTextCharFormat bold; bold.setFontWeight(QFont::Bold);
-  setFormat(Bold, bold);
+  setFormat(Bold, bold, Settings::Default);
 
   QTextCharFormat italic; italic.setFontItalic(true);
-  setFormat(Italic, italic);
+  setFormat(Italic, italic, Settings::Default);
 
   QTextCharFormat underline; underline.setFontUnderline(true);
-  setFormat(Underline, underline);
+  setFormat(Underline, underline, Settings::Default);
 
   // All other formats should be defined in derived classes.
 }
@@ -89,12 +96,24 @@ UiStyle::~ UiStyle() {
   
 }
 
-void UiStyle::setFormat(FormatType ftype, QTextCharFormat fmt) {
-  _formats[ftype] = fmt;
+void UiStyle::setFormat(FormatType ftype, QTextCharFormat fmt, Settings::Mode mode) {
+  if(mode == Settings::Default) {
+    _defaultFormats[ftype] = fmt;
+  } else {
+    UiStyleSettings s(_settingsKey);
+    if(fmt != _defaultFormats[ftype]) {
+      _customFormats[ftype] = fmt;
+      s.setCustomFormat(ftype, fmt);
+    } else {
+      _customFormats[ftype] = QTextFormat().toCharFormat();
+      s.removeCustomFormat(ftype);
+    }
+  }
 }
 
-QTextCharFormat UiStyle::format(FormatType ftype) const {
-  return _formats[ftype];
+QTextCharFormat UiStyle::format(FormatType ftype, Settings::Mode mode) const {
+  if(mode == Settings::Custom && _customFormats[ftype].isValid()) return _customFormats[ftype];
+  else return _defaultFormats[ftype];
 }
 
 UiStyle::FormatType UiStyle::formatType(const QString & code) const {
index 3da2925..a80af5e 100644 (file)
 #include <QUrl>
 
 #include "message.h"
+#include "settings.h"
 
 class UiStyle {
 
   public:
-    UiStyle();
+    UiStyle(const QString &settingsKey);
     virtual ~UiStyle();
 
     /** This enumerates the possible formats a text element may have. */
@@ -59,8 +60,8 @@ class UiStyle {
 
     StyledText styleString(QString);
 
-    void setFormat(FormatType, QTextCharFormat);
-    QTextCharFormat format(FormatType) const;
+    void setFormat(FormatType, QTextCharFormat, Settings::Mode mode/* = Settings::Custom*/);
+    QTextCharFormat format(FormatType, Settings::Mode mode = Settings::Custom) const;
 
     FormatType formatType(const QString &code) const;
     QString formatCode(FormatType) const;
@@ -71,9 +72,12 @@ class UiStyle {
   private:
     QTextCharFormat mergedFormat(QList<FormatType>);
 
-    QVector<QTextCharFormat> _formats;
+    QVector<QTextCharFormat> _defaultFormats;
+    QVector<QTextCharFormat> _customFormats;
     QHash<QString, FormatType> _formatCodes;
 
+    QString _settingsKey;
+
 };
 
 #endif
diff --git a/src/uisupport/uistylesettings.cpp b/src/uisupport/uistylesettings.cpp
new file mode 100644 (file)
index 0000000..73d21cf
--- /dev/null
@@ -0,0 +1,47 @@
+/***************************************************************************
+ *   Copyright (C) 2005-08 by the Quassel IRC Team                         *
+ *   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) any later version.                                   *
+ *                                                                         *
+ *   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 "uistylesettings.h"
+
+UiStyleSettings::UiStyleSettings(const QString &group) : ClientSettings(group) {
+
+}
+
+void UiStyleSettings::setCustomFormat(UiStyle::FormatType ftype, QTextCharFormat format) {
+  setLocalValue(QString("Format/%1").arg(ftype), format);
+}
+
+QTextCharFormat UiStyleSettings::customFormat(UiStyle::FormatType ftype) {
+  return localValue(QString("Format/%1").arg(ftype), QTextFormat()).value<QTextFormat>().toCharFormat();
+}
+
+void UiStyleSettings::removeCustomFormat(UiStyle::FormatType ftype) {
+  removeLocalKey(QString("Format/%1").arg(ftype));
+}
+
+QList<UiStyle::FormatType> UiStyleSettings::availableFormats() {
+  QList<UiStyle::FormatType> formats;
+  QStringList list = localChildKeys("Format");
+  foreach(QString type, list) {
+    formats << (UiStyle::FormatType)type.toInt();
+  }
+  return formats;
+}
+
diff --git a/src/uisupport/uistylesettings.h b/src/uisupport/uistylesettings.h
new file mode 100644 (file)
index 0000000..c09e3c7
--- /dev/null
@@ -0,0 +1,42 @@
+/***************************************************************************
+ *   Copyright (C) 2005-08 by the Quassel IRC Team                         *
+ *   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) any later version.                                   *
+ *                                                                         *
+ *   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 _UISTYLESETTINGS_H_
+#define _UISTYLESETTINGS_H_
+
+#include "clientsettings.h"
+#include "uistyle.h"
+
+class UiStyleSettings : public ClientSettings {
+
+  public:
+    UiStyleSettings(const QString &group = "UiStyle");
+
+    void setCustomFormat(UiStyle::FormatType, QTextCharFormat);
+    QTextCharFormat customFormat(UiStyle::FormatType);
+
+    void removeCustomFormat(UiStyle::FormatType);
+    QList<UiStyle::FormatType> availableFormats();
+
+  private:
+
+};
+
+#endif
index a67affb..f7f0e89 100644 (file)
@@ -1,8 +1,8 @@
 DEPMOD = common client
 QT_MOD = core gui network
 
-SRCS += bufferview.cpp bufferviewfilter.cpp inputline.cpp nickview.cpp settingspage.cpp tabcompleter.cpp uisettings.cpp uistyle.cpp
-HDRS += bufferview.h bufferviewfilter.h inputline.h nickview.h settingspage.h tabcompleter.h uisettings.h uistyle.h
+SRCS += bufferview.cpp bufferviewfilter.cpp inputline.cpp nickview.cpp settingspage.cpp tabcompleter.cpp uisettings.cpp uistyle.cpp uistylesettings.cpp
+HDRS += bufferview.h bufferviewfilter.h inputline.h nickview.h settingspage.h tabcompleter.h uisettings.h uistyle.h uistylesettings.h
 
 FORMNAMES =