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();
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 ¤t, const QModelIndex &previous) {
Q_UNUSED(previous)
NetworkId networkId = current.data(NetworkModel::NetworkIdRole).value<NetworkId>();
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;
#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"
//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));
#include "chatviewsettings.h"
#include "qtui.h"
#include "qtuisettings.h"
+#include "qtuistyle.h"
#include "util.h"
#include <QDir>
+#include <QFontDialog>
+#include <QSignalMapper>
#include <QStyleFactory>
AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent)
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() {
_locales << locale;
ui.languageComboBox->addItem(QLocale::languageToString(locale.language()));
}
-
}
void AppearanceSettingsPage::defaults() {
ui.styleComboBox->setCurrentIndex(0);
+ loadFonts(Settings::Default);
+ _fontsChanged = true;
widgetHasChanged();
}
BufferSettings bufferSettings;
SettingsPage::load(ui.showUserStateIcons, bufferSettings.showUserStateIcons());
+ loadFonts(Settings::Custom);
+
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;
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);
}
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() {
+ 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())
return false;
}
-
-
-
-
#include <QHash>
#include <QList>
#include <QLocale>
+#include <QTextCharFormat>
+#include "settings.h"
#include "settingspage.h"
#include "ui_appearancesettingspage.h"
+class QSignalMapper;
+
class AppearanceSettingsPage : public SettingsPage {
Q_OBJECT
void save();
void load();
void defaults();
-
+
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;
+ void clearFontFromFormat(QTextCharFormat &fmt);
+
+ Ui::AppearanceSettingsPage ui;
+ QHash<QString, QVariant> settings;
+ QList<QLocale> _locales;
+ QSignalMapper *mapper;
+ bool _fontsChanged;
};
#endif
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
<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>
- <width>396</width>
- <height>324</height>
+ <width>521</width>
+ <height>447</height>
</rect>
</property>
- <property name="windowTitle" >
+ <property name="windowTitle">
<string>Form</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout_2" >
+ <layout class="QVBoxLayout" name="verticalLayout">
<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>
- <layout class="QVBoxLayout" >
+ <layout class="QVBoxLayout">
<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>
- <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>
- <layout class="QVBoxLayout" name="verticalLayout" >
+ <layout class="QHBoxLayout" name="horizontalLayout">
<item>
- <widget class="QComboBox" name="languageComboBox" >
+ <widget class="QComboBox" name="languageComboBox">
+ <property name="toolTip">
+ <string>Set the application language. Requires restart!</string>
+ </property>
<item>
- <property name="text" >
- <string><System Default></string>
+ <property name="text">
+ <string><System Default></string>
</property>
</item>
<item>
- <property name="text" >
- <string><Original></string>
+ <property name="text">
+ <string><Original></string>
</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>
</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>
- <layout class="QVBoxLayout" name="verticalLayout_3" >
+ <layout class="QVBoxLayout" name="verticalLayout_3">
<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 name="checked" >
+ <property name="checked">
<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 name="checked" >
+ <property name="checked">
<bool>true</bool>
</property>
</widget>
</widget>
</item>
<item>
- <spacer name="verticalSpacer" >
- <property name="orientation" >
+ <spacer name="verticalSpacer">
+ <property name="orientation">
<enum>Qt::Vertical</enum>
</property>
- <property name="sizeHint" stdset="0" >
+ <property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
# 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)
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::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 on_configChanged();
+ void setCustomFont(const QVariant &font);
+
private:
QPointer<BufferViewConfig> _config;
#include "nickview.h"
+#include <QApplication>
#include <QHeaderView>
#include <QScrollBar>
#include <QDebug>
// 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() {
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 showContextMenu(const QPoint & pos);
void startQuery(const QModelIndex & modelIndex);
+private slots:
+ void setCustomFont(const QVariant &);
+
signals:
void selectionUpdated();