Move font settings to general appearance settingspage
authorManuel Nickschas <sputnick@quassel-irc.org>
Mon, 16 Feb 2009 09:42:17 +0000 (10:42 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Mon, 16 Feb 2009 09:42:17 +0000 (10:42 +0100)
This retires our old fonts settingspage for now, since most of what was on
there didn't work anyway. You can now choose fonts for the ChatView, the input line
and (this is brandnew!1!!) the buffer views and nick list.

Also added tooltips for that settingspage and changed the wording a bit.

src/qtui/inputwidget.cpp
src/qtui/inputwidget.h
src/qtui/mainwin.cpp
src/qtui/settingspages/appearancesettingspage.cpp
src/qtui/settingspages/appearancesettingspage.h
src/qtui/settingspages/appearancesettingspage.ui
src/qtui/settingspages/settingspages.inc
src/uisupport/bufferview.cpp
src/uisupport/bufferview.h
src/uisupport/nickview.cpp
src/uisupport/nickview.h

index cd48764..299ebce 100644 (file)
@@ -44,11 +44,12 @@ InputWidget::InputWidget(QWidget *parent)
   ui.ownNick->installEventFilter(new MouseWheelFilter(this));
   ui.inputEdit->installEventFilter(new JumpKeyHandler(this));
 
   ui.ownNick->installEventFilter(new MouseWheelFilter(this));
   ui.inputEdit->installEventFilter(new JumpKeyHandler(this));
 
-  QtUiSettings s;
-  bool useInputLineFont = s.value("UseInputLineFont", QVariant(false)).toBool();
-  if(useInputLineFont) {
-    ui.inputEdit->setFont(s.value("InputLineFont").value<QFont>());
-  }
+  QtUiStyleSettings s("Fonts");
+  s.notify("InputLine", this, SLOT(setFont(QVariant)));
+  QFont font = s.value("InputLine", QFont()).value<QFont>();
+  if(font.family().isEmpty())
+    font = QApplication::font();
+  setFont(font);
 
   ActionCollection *coll = QtUi::actionCollection();
 
 
   ActionCollection *coll = QtUi::actionCollection();
 
@@ -61,6 +62,13 @@ InputWidget::InputWidget(QWidget *parent)
 InputWidget::~InputWidget() {
 }
 
 InputWidget::~InputWidget() {
 }
 
+void InputWidget::setCustomFont(const QVariant &v) {
+  QFont font = v.value<QFont>();
+  if(font.family().isEmpty())
+    font = QApplication::font();
+  ui.inputEdit->setFont(font);
+}
+
 void InputWidget::currentChanged(const QModelIndex &current, const QModelIndex &previous) {
   Q_UNUSED(previous)
   NetworkId networkId = current.data(NetworkModel::NetworkIdRole).value<NetworkId>();
 void InputWidget::currentChanged(const QModelIndex &current, const QModelIndex &previous) {
   Q_UNUSED(previous)
   NetworkId networkId = current.data(NetworkModel::NetworkIdRole).value<NetworkId>();
index 89fe393..297830b 100644 (file)
@@ -48,6 +48,7 @@ protected slots:
   virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
 
 private slots:
   virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
 
 private slots:
+  void setCustomFont(const QVariant &font);
   void sendText(QString text);
   void changeNick(const QString &newNick) const;
 
   void sendText(QString text);
   void changeNick(const QString &newNick) const;
 
index 53324dd..2b758d5 100644 (file)
@@ -89,7 +89,6 @@
 #include "settingspages/bufferviewsettingspage.h"
 #include "settingspages/chatmonitorsettingspage.h"
 #include "settingspages/colorsettingspage.h"
 #include "settingspages/bufferviewsettingspage.h"
 #include "settingspages/chatmonitorsettingspage.h"
 #include "settingspages/colorsettingspage.h"
-#include "settingspages/fontssettingspage.h"
 #include "settingspages/generalsettingspage.h"
 #include "settingspages/highlightsettingspage.h"
 #include "settingspages/identitiessettingspage.h"
 #include "settingspages/generalsettingspage.h"
 #include "settingspages/highlightsettingspage.h"
 #include "settingspages/identitiessettingspage.h"
@@ -724,7 +723,6 @@ void MainWin::showSettingsDlg() {
   //Category: Appearance
   dlg->registerSettingsPage(new AppearanceSettingsPage(dlg)); //General
   dlg->registerSettingsPage(new ColorSettingsPage(dlg));
   //Category: Appearance
   dlg->registerSettingsPage(new AppearanceSettingsPage(dlg)); //General
   dlg->registerSettingsPage(new ColorSettingsPage(dlg));
-  dlg->registerSettingsPage(new FontsSettingsPage(dlg));
   dlg->registerSettingsPage(new HighlightSettingsPage(dlg));
   dlg->registerSettingsPage(new NotificationsSettingsPage(dlg));
   dlg->registerSettingsPage(new BacklogSettingsPage(dlg));
   dlg->registerSettingsPage(new HighlightSettingsPage(dlg));
   dlg->registerSettingsPage(new NotificationsSettingsPage(dlg));
   dlg->registerSettingsPage(new BacklogSettingsPage(dlg));
index 91e32a0..c6a8b45 100644 (file)
 #include "chatviewsettings.h"
 #include "qtui.h"
 #include "qtuisettings.h"
 #include "chatviewsettings.h"
 #include "qtui.h"
 #include "qtuisettings.h"
+#include "qtuistyle.h"
 #include "util.h"
 
 #include <QDir>
 #include "util.h"
 
 #include <QDir>
+#include <QFontDialog>
+#include <QSignalMapper>
 #include <QStyleFactory>
 
 AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent)
 #include <QStyleFactory>
 
 AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent)
@@ -47,6 +50,17 @@ AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent)
   foreach(QCheckBox *checkBox, findChildren<QCheckBox *>()) {
     connect(checkBox, SIGNAL(clicked()), this, SLOT(widgetHasChanged()));
   }
   foreach(QCheckBox *checkBox, findChildren<QCheckBox *>()) {
     connect(checkBox, SIGNAL(clicked()), this, SLOT(widgetHasChanged()));
   }
+
+  mapper = new QSignalMapper(this);
+  connect(mapper, SIGNAL(mapped(QWidget *)), this, SLOT(chooseFont(QWidget *)));
+
+  connect(ui.chooseChatView, SIGNAL(clicked()), mapper, SLOT(map()));
+  connect(ui.chooseBufferView, SIGNAL(clicked()), mapper, SLOT(map()));
+  connect(ui.chooseInputLine, SIGNAL(clicked()), mapper, SLOT(map()));
+
+  mapper->setMapping(ui.chooseChatView, ui.demoChatView);
+  mapper->setMapping(ui.chooseBufferView, ui.demoBufferView);
+  mapper->setMapping(ui.chooseInputLine, ui.demoInputLine);
 }
 
 void AppearanceSettingsPage::initStyleComboBox() {
 }
 
 void AppearanceSettingsPage::initStyleComboBox() {
@@ -67,12 +81,13 @@ void AppearanceSettingsPage::initLanguageComboBox() {
     _locales << locale;
     ui.languageComboBox->addItem(QLocale::languageToString(locale.language()));
   }
     _locales << locale;
     ui.languageComboBox->addItem(QLocale::languageToString(locale.language()));
   }
-
 }
 
 void AppearanceSettingsPage::defaults() {
   ui.styleComboBox->setCurrentIndex(0);
 
 }
 
 void AppearanceSettingsPage::defaults() {
   ui.styleComboBox->setCurrentIndex(0);
 
+  loadFonts(Settings::Default);
+  _fontsChanged = true;
   widgetHasChanged();
 }
 
   widgetHasChanged();
 }
 
@@ -104,9 +119,30 @@ void AppearanceSettingsPage::load() {
   BufferSettings bufferSettings;
   SettingsPage::load(ui.showUserStateIcons, bufferSettings.showUserStateIcons());
 
   BufferSettings bufferSettings;
   SettingsPage::load(ui.showUserStateIcons, bufferSettings.showUserStateIcons());
 
+  loadFonts(Settings::Custom);
+
   setChangedState(false);
 }
 
   setChangedState(false);
 }
 
+void AppearanceSettingsPage::loadFonts(Settings::Mode mode) {
+  QtUiStyleSettings s("Fonts");
+
+  QFont inputLineFont;
+  if(mode == Settings::Custom)
+    inputLineFont = s.value("InputLine", QFont()).value<QFont>();
+  setFont(ui.demoInputLine, inputLineFont);
+
+  QFont bufferViewFont;
+  if(mode == Settings::Custom)
+    bufferViewFont = s.value("BufferView", QFont()).value<QFont>();
+  setFont(ui.demoBufferView, bufferViewFont);
+
+  QTextCharFormat chatFormat = QtUi::style()->format(UiStyle::None, mode);
+  setFont(ui.demoChatView, chatFormat.font());
+
+  _fontsChanged = false;
+}
+
 void AppearanceSettingsPage::save() {
   QtUiSettings uiSettings;
 
 void AppearanceSettingsPage::save() {
   QtUiSettings uiSettings;
 
@@ -128,6 +164,24 @@ void AppearanceSettingsPage::save() {
   BufferSettings bufferSettings;
   bufferSettings.enableUserStateIcons(ui.showUserStateIcons->isChecked());
 
   BufferSettings bufferSettings;
   bufferSettings.enableUserStateIcons(ui.showUserStateIcons->isChecked());
 
+  // Fonts
+  QtUiStyleSettings fontSettings("Fonts");
+  if(ui.demoInputLine->font() != QApplication::font())
+    fontSettings.setValue("InputLine", ui.demoInputLine->font());
+  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;
+
   load();
   setChangedState(false);
 }
   load();
   setChangedState(false);
 }
@@ -145,11 +199,33 @@ QLocale AppearanceSettingsPage::selectedLocale() const {
   return locale;
 }
 
   return locale;
 }
 
+void AppearanceSettingsPage::setFont(QLabel *label, const QFont &font_) {
+  QFont font = font_;
+  if(font.family().isEmpty())
+    font = QApplication::font();
+  label->setFont(font);
+  label->setText(QString("%1 %2").arg(font.family()).arg(font.pointSize()));
+  widgetHasChanged();
+}
+
+void AppearanceSettingsPage::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);
+    _fontsChanged = true;
+  }
+}
+
 void AppearanceSettingsPage::widgetHasChanged() {
   setChangedState(testHasChanged());
 }
 
 bool AppearanceSettingsPage::testHasChanged() {
 void AppearanceSettingsPage::widgetHasChanged() {
   setChangedState(testHasChanged());
 }
 
 bool AppearanceSettingsPage::testHasChanged() {
+  if(_fontsChanged) return true; // comparisons are nasty for now
+
   if(settings["Style"].toString() != ui.styleComboBox->currentText()) return true;
   if(selectedLocale() != QLocale()) return true; // QLocale() returns the default locale (manipulated via loadTranslation())
 
   if(settings["Style"].toString() != ui.styleComboBox->currentText()) return true;
   if(selectedLocale() != QLocale()) return true; // QLocale() returns the default locale (manipulated via loadTranslation())
 
@@ -158,7 +234,3 @@ bool AppearanceSettingsPage::testHasChanged() {
 
   return false;
 }
 
   return false;
 }
-
-
-
-
index 9cbfc19..c3e51a9 100644 (file)
 #include <QHash>
 #include <QList>
 #include <QLocale>
 #include <QHash>
 #include <QList>
 #include <QLocale>
+#include <QTextCharFormat>
 
 
+#include "settings.h"
 #include "settingspage.h"
 #include "ui_appearancesettingspage.h"
 
 #include "settingspage.h"
 #include "ui_appearancesettingspage.h"
 
+class QSignalMapper;
+
 class AppearanceSettingsPage : public SettingsPage {
   Q_OBJECT
 
 class AppearanceSettingsPage : public SettingsPage {
   Q_OBJECT
 
@@ -40,19 +44,26 @@ public slots:
   void save();
   void load();
   void defaults();
   void save();
   void load();
   void defaults();
-                
+
 private slots:
   void widgetHasChanged();
 private slots:
   void widgetHasChanged();
-  
-private:
-  Ui::AppearanceSettingsPage ui;
-  QHash<QString, QVariant> settings;
-  QList<QLocale> _locales;
 
 
+  void loadFonts(Settings::Mode mode);
+  void setFont(QLabel *label, const QFont &font);
+  void chooseFont(QWidget *label);
+
+private:
   bool testHasChanged();
   void initStyleComboBox();
   void initLanguageComboBox();
   QLocale selectedLocale() const;
   bool testHasChanged();
   void initStyleComboBox();
   void initLanguageComboBox();
   QLocale selectedLocale() const;
+  void clearFontFromFormat(QTextCharFormat &fmt);
+
+  Ui::AppearanceSettingsPage ui;
+  QHash<QString, QVariant> settings;
+  QList<QLocale> _locales;
+  QSignalMapper *mapper;
+  bool _fontsChanged;
 };
 
 #endif
 };
 
 #endif
index bc1e26b..a988b83 100644 (file)
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
  <class>AppearanceSettingsPage</class>
  <class>AppearanceSettingsPage</class>
- <widget class="QWidget" name="AppearanceSettingsPage" >
-  <property name="geometry" >
+ <widget class="QWidget" name="AppearanceSettingsPage">
+  <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>396</width>
-    <height>324</height>
+    <width>521</width>
+    <height>447</height>
    </rect>
   </property>
    </rect>
   </property>
-  <property name="windowTitle" >
+  <property name="windowTitle">
    <string>Form</string>
   </property>
    <string>Form</string>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout_2" >
+  <layout class="QVBoxLayout" name="verticalLayout">
    <item>
    <item>
-    <widget class="QGroupBox" name="groupBox" >
-     <property name="title" >
-      <string>Client style:</string>
+    <widget class="QGroupBox" name="groupBox">
+     <property name="title">
+      <string>Client Style</string>
      </property>
      </property>
-     <layout class="QVBoxLayout" >
+     <layout class="QVBoxLayout">
       <item>
       <item>
-       <widget class="QComboBox" name="styleComboBox" />
+       <widget class="QComboBox" name="styleComboBox">
+        <property name="toolTip">
+         <string>Set application style</string>
+        </property>
+       </widget>
       </item>
      </layout>
     </widget>
    </item>
    <item>
       </item>
      </layout>
     </widget>
    </item>
    <item>
-    <widget class="QGroupBox" name="groupBox_2" >
-     <property name="title" >
-      <string>Language:</string>
+    <widget class="QGroupBox" name="groupBox_2">
+     <property name="title">
+      <string>Language</string>
      </property>
      </property>
-     <layout class="QVBoxLayout" name="verticalLayout" >
+     <layout class="QHBoxLayout" name="horizontalLayout">
       <item>
       <item>
-       <widget class="QComboBox" name="languageComboBox" >
+       <widget class="QComboBox" name="languageComboBox">
+        <property name="toolTip">
+         <string>Set the application language. Requires restart!</string>
+        </property>
         <item>
         <item>
-         <property name="text" >
-          <string>&lt;System Default></string>
+         <property name="text">
+          <string>&lt;System Default&gt;</string>
          </property>
         </item>
         <item>
          </property>
         </item>
         <item>
-         <property name="text" >
-          <string>&lt;Original></string>
+         <property name="text">
+          <string>&lt;Original&gt;</string>
          </property>
         </item>
        </widget>
       </item>
          </property>
         </item>
        </widget>
       </item>
-      <item>
-       <widget class="QLabel" name="label" >
-        <property name="text" >
-         <string>Note: needs client restart for full effect!</string>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="groupBox_4">
+     <property name="title">
+      <string>Fonts</string>
+     </property>
+     <layout class="QGridLayout" name="gridLayout">
+      <item row="0" column="0">
+       <widget class="QLabel" name="label_2">
+        <property name="toolTip">
+         <string>Set font for the main chat window and the chat monitor</string>
+        </property>
+        <property name="text">
+         <string>Chat window:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1">
+       <widget class="QLabel" name="demoChatView">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="toolTip">
+         <string>Set font for the main chat window and the chat monitor</string>
+        </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="chooseChatView">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string>Choose...</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="0">
+       <widget class="QLabel" name="label_4">
+        <property name="toolTip">
+         <string>Set font for channel and nick lists</string>
+        </property>
+        <property name="text">
+         <string>Channel list:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="1">
+       <widget class="QLabel" name="demoBufferView">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="toolTip">
+         <string>Set font for channel and nick lists</string>
+        </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="chooseBufferView">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string>Choose...</string>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="0">
+       <widget class="QLabel" name="label_3">
+        <property name="toolTip">
+         <string>Set font for the input line</string>
+        </property>
+        <property name="text">
+         <string>Input line:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="1">
+       <widget class="QLabel" name="demoInputLine">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="toolTip">
+         <string>Set font for the input line</string>
+        </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="chooseInputLine">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string>Choose...</string>
         </property>
        </widget>
       </item>
         </property>
        </widget>
       </item>
     </widget>
    </item>
    <item>
     </widget>
    </item>
    <item>
-    <widget class="QGroupBox" name="groupBox_3" >
-     <property name="title" >
-      <string>Misc:</string>
+    <widget class="QGroupBox" name="groupBox_3">
+     <property name="title">
+      <string>Misc</string>
      </property>
      </property>
-     <layout class="QVBoxLayout" name="verticalLayout_3" >
+     <layout class="QVBoxLayout" name="verticalLayout_3">
       <item>
       <item>
-       <widget class="QCheckBox" name="showWebPreview" >
-        <property name="text" >
-         <string>Show Web Previews</string>
+       <widget class="QCheckBox" name="showWebPreview">
+        <property name="toolTip">
+         <string>Show a website preview window when hovering the mouse over a web address</string>
+        </property>
+        <property name="text">
+         <string>Show previews of webpages on URL hover</string>
         </property>
         </property>
-        <property name="checked" >
+        <property name="checked">
          <bool>true</bool>
         </property>
        </widget>
       </item>
       <item>
          <bool>true</bool>
         </property>
        </widget>
       </item>
       <item>
-       <widget class="QCheckBox" name="showUserStateIcons" >
-        <property name="text" >
-         <string>Use Icons to represent away state of Users</string>
+       <widget class="QCheckBox" name="showUserStateIcons">
+        <property name="toolTip">
+         <string>Show status icons in channel and nick lists</string>
+        </property>
+        <property name="text">
+         <string>Use icons in channel and nick lists</string>
         </property>
         </property>
-        <property name="checked" >
+        <property name="checked">
          <bool>true</bool>
         </property>
        </widget>
          <bool>true</bool>
         </property>
        </widget>
     </widget>
    </item>
    <item>
     </widget>
    </item>
    <item>
-    <spacer name="verticalSpacer" >
-     <property name="orientation" >
+    <spacer name="verticalSpacer">
+     <property name="orientation">
       <enum>Qt::Vertical</enum>
      </property>
       <enum>Qt::Vertical</enum>
      </property>
-     <property name="sizeHint" stdset="0" >
+     <property name="sizeHint" stdset="0">
       <size>
        <width>20</width>
        <height>40</height>
       <size>
        <width>20</width>
        <height>40</height>
index f33ac22..d4ccb4d 100644 (file)
@@ -1,7 +1,7 @@
 # Putting $FOO in SETTINGSPAGES automatically includes
 # $FOOsettingspage.cpp, $FOOsettingspage.h and $FOOsettingspage.ui
 
 # Putting $FOO in SETTINGSPAGES automatically includes
 # $FOOsettingspage.cpp, $FOOsettingspage.h and $FOOsettingspage.ui
 
-set(SETTINGSPAGES aliases appearance backlog bufferview color chatmonitor fonts general highlight identities networks)
+set(SETTINGSPAGES aliases appearance backlog bufferview color chatmonitor general highlight identities networks)
 
 # Specify additional files (e.g. for subdialogs) here!
 set(SP_SOURCES aliasesmodel.cpp identityeditwidget.cpp notificationssettingspage.cpp)
 
 # Specify additional files (e.g. for subdialogs) here!
 set(SP_SOURCES aliasesmodel.cpp identityeditwidget.cpp notificationssettingspage.cpp)
index ccea4e8..d6c1106 100644 (file)
@@ -60,6 +60,10 @@ BufferView::BufferView(QWidget *parent)
   BufferViewDelegate *tristateDelegate = new BufferViewDelegate(this);
   setItemDelegate(tristateDelegate);
   delete oldDelegate;
   BufferViewDelegate *tristateDelegate = new BufferViewDelegate(this);
   setItemDelegate(tristateDelegate);
   delete oldDelegate;
+
+  UiStyleSettings s("QtUiStyle/Fonts"); // li'l dirty here, but fonts are stored in QtUiStyle :/
+  s.notify("BufferView", this, SLOT(setCustomFont(QVariant)));
+  setCustomFont(s.value("BufferView", QFont()));
 }
 
 void BufferView::init() {
 }
 
 void BufferView::init() {
@@ -188,6 +192,13 @@ void BufferView::setRootIndexForNetworkId(const NetworkId &networkId) {
   }
 }
 
   }
 }
 
+void BufferView::setCustomFont(const QVariant &v) {
+  QFont font = v.value<QFont>();
+  if(font.family().isEmpty())
+    font = QApplication::font();
+  setFont(font);
+}
+
 void BufferView::joinChannel(const QModelIndex &index) {
   BufferInfo::Type bufferType = (BufferInfo::Type)index.data(NetworkModel::BufferTypeRole).value<int>();
 
 void BufferView::joinChannel(const QModelIndex &index) {
   BufferInfo::Type bufferType = (BufferInfo::Type)index.data(NetworkModel::BufferTypeRole).value<int>();
 
index 419f33b..f72b7a6 100644 (file)
@@ -81,6 +81,8 @@ private slots:
 
   void on_configChanged();
 
 
   void on_configChanged();
 
+  void setCustomFont(const QVariant &font);
+
 private:
   QPointer<BufferViewConfig> _config;
 
 private:
   QPointer<BufferViewConfig> _config;
 
index e27640e..bbb36a7 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "nickview.h"
 
 
 #include "nickview.h"
 
+#include <QApplication>
 #include <QHeaderView>
 #include <QScrollBar>
 #include <QDebug>
 #include <QHeaderView>
 #include <QScrollBar>
 #include <QDebug>
@@ -66,6 +67,10 @@ NickView::NickView(QWidget *parent)
   // afaik this is better on Mac and Windows
   connect(this, SIGNAL(activated(QModelIndex)), SLOT(startQuery(QModelIndex)));
 #endif
   // afaik this is better on Mac and Windows
   connect(this, SIGNAL(activated(QModelIndex)), SLOT(startQuery(QModelIndex)));
 #endif
+
+  UiStyleSettings s("QtUiStyle/Fonts"); // li'l dirty here, but fonts are stored in QtUiStyle :/
+  s.notify("BufferView", this, SLOT(setCustomFont(QVariant))); // yes, we share the BufferView settings
+  setCustomFont(s.value("BufferView", QFont()));
 }
 
 void NickView::init() {
 }
 
 void NickView::init() {
@@ -87,6 +92,13 @@ void NickView::setModel(QAbstractItemModel *model_) {
   init();
 }
 
   init();
 }
 
+void NickView::setCustomFont(const QVariant &v) {
+  QFont font = v.value<QFont>();
+  if(font.family().isEmpty())
+    font = QApplication::font();
+  setFont(font);
+}
+
 void NickView::rowsInserted(const QModelIndex &parent, int start, int end) {
   QTreeView::rowsInserted(parent, start, end);
   if(model()->data(parent, NetworkModel::ItemTypeRole) == NetworkModel::UserCategoryItemType && !isExpanded(parent)) {
 void NickView::rowsInserted(const QModelIndex &parent, int start, int end) {
   QTreeView::rowsInserted(parent, start, end);
   if(model()->data(parent, NetworkModel::ItemTypeRole) == NetworkModel::UserCategoryItemType && !isExpanded(parent)) {
index 0a567e5..5fd4eed 100644 (file)
@@ -45,6 +45,9 @@ public slots:
   void showContextMenu(const QPoint & pos);
   void startQuery(const QModelIndex & modelIndex);
 
   void showContextMenu(const QPoint & pos);
   void startQuery(const QModelIndex & modelIndex);
 
+private slots:
+  void setCustomFont(const QVariant &);
+
 signals:
   void selectionUpdated();
 
 signals:
   void selectionUpdated();