Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make font size configurable #1872

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 54 additions & 0 deletions src/mumble/LookConfig.cpp
Expand Up @@ -67,6 +67,8 @@ LookConfig::LookConfig(Settings &st) : ConfigWidget(st) {
qcbLanguage->addItem(displayName, QVariant(cc));
}

updateFontInfo();

qcbExpand->addItem(tr("None"), Settings::NoChannels);
qcbExpand->addItem(tr("Only with users"), Settings::ChannelsWithUsers);
qcbExpand->addItem(tr("All"), Settings::AllChannels);
Expand Down Expand Up @@ -103,6 +105,20 @@ LookConfig::LookConfig(Settings &st) : ConfigWidget(st) {
}
}

void LookConfig::updateFontInfo(QLabel *label, const QFont &font) {
label->setText(QString::fromLatin1("%1, %2pt").arg(font.family()).arg(font.pointSize()));
}

void LookConfig::updateFontInfo() {
updateFontInfo(s);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's s? I think there should be a comment here explaining what this call is supposed to do

}

void LookConfig::updateFontInfo(const Settings &r) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think r is a bad choice for a variable representing a setting. I'd also prefer a more verbose name. Something like settings I think would be ideal.

updateFontInfo(qlFontLogCurrent, r.qfFontLog);
updateFontInfo(qlFontInputCurrent, r.qfFontInput);
updateFontInfo(qlFontTreeCurrent, r.qfFontTree);
}

QString LookConfig::title() const {
return tr("User Interface");
}
Expand Down Expand Up @@ -169,6 +185,8 @@ void LookConfig::load(const Settings &r) {
}
}

updateFontInfo(r);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this doing? It appears somewhat lonely in the code, so I think there should be a comment


loadComboBox(qcbAlwaysOnTop, r.aotbAlwaysOnTop);

loadComboBox(qcbExpand, r.ceExpand);
Expand Down Expand Up @@ -297,3 +315,39 @@ void LookConfig::on_qcbAbbreviateChannelNames_stateChanged(int state) {
qleChannelSeparator->setEnabled(abbreviateNames);
qleAbbreviationReplacement->setEnabled(abbreviateNames);
}

void LookConfig::changeFont(QFont & font) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a style-thing: There's an additional blank after the &

bool ok;
QFont new_font = QFontDialog::getFont(&ok, font);
if (ok) {
font = new_font;
updateFontInfo();
}
}

void LookConfig::on_qpbFontLog_clicked() {
changeFont(s.qfFontLog);
}

void LookConfig::on_qpbFontInput_clicked() {
changeFont(s.qfFontInput);
}

void LookConfig::on_qpbFontTree_clicked() {
changeFont(s.qfFontTree);
}

void LookConfig::on_qpbFontAll_clicked() {
QFont initial;
if (s.qfFontLog == s.qfFontInput && s.qfFontInput == s.qfFontTree) {
initial = s.qfFontLog;
}
bool ok;
QFont new_font = QFontDialog::getFont(&ok, initial);
if (ok) {
s.qfFontLog = new_font;
s.qfFontInput = new_font;
s.qfFontTree = new_font;
updateFontInfo();
}
}
11 changes: 11 additions & 0 deletions src/mumble/LookConfig.h
Expand Up @@ -33,6 +33,17 @@ public slots:
void themeDirectoryChanged();
void on_qcbAbbreviateChannelNames_stateChanged(int state);

protected:
void updateFontInfo(QLabel *l, const QFont &f);
void updateFontInfo();
void updateFontInfo(const Settings &r);
void changeFont(QFont & font);
protected slots:
void on_qpbFontLog_clicked();
void on_qpbFontInput_clicked();
void on_qpbFontTree_clicked();
void on_qpbFontAll_clicked();

private:
/// Reload themes combobox and select given configuredStyle in it
void reloadThemes(const boost::optional< ThemeInfo::StyleInfo > configuredStyle);
Expand Down
137 changes: 128 additions & 9 deletions src/mumble/LookConfig.ui
Expand Up @@ -485,13 +485,6 @@
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="qcbShowTransmitModeComboBox">
<property name="text">
<string>Show transmit mode dropdown in toolbar</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="qcbHighContrast">
<property name="toolTip">
Expand All @@ -502,7 +495,7 @@
</property>
</widget>
</item>
<item row="6" column="0">
<item row="5" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand Down Expand Up @@ -662,7 +655,7 @@
</layout>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand All @@ -688,6 +681,19 @@
</property>
</widget>
</item>
<item row="6" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="MUComboBox" name="qcbExpand">
<property name="toolTip">
Expand Down Expand Up @@ -795,6 +801,119 @@
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QGroupBox" name="qgbToolbar">
<property name="title">
<string>Toolbar</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="qcbShowTransmitModeComboBox">
<property name="text">
<string>Show transmit mode dropdown in toolbar</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="qgbFonts">
<property name="title">
<string>Fonts</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="1" column="2">
<widget class="QPushButton" name="qpbFontInput">
<property name="text">
<string>Change</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="qlFontTreeCurrent">
<property name="text">
<string notr="true">Family, 0pt</string>
</property>
<property name="buddy">
<cstring>qpbFontTree</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Input Field</string>
</property>
<property name="buddy">
<cstring>qpbFontInput</cstring>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="qpbFontTree">
<property name="text">
<string>Change</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="qlFontInputCurrent">
<property name="text">
<string notr="true">Family, 0pt</string>
</property>
<property name="buddy">
<cstring>qpbFontInput</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Channel Tree</string>
</property>
<property name="buddy">
<cstring>qpbFontTree</cstring>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="qlFontLog">
<property name="text">
<string>Log Messages</string>
</property>
<property name="buddy">
<cstring>qpbFontLog</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="qlFontLogCurrent">
<property name="text">
<string notr="true">Family, 0pt</string>
</property>
<property name="buddy">
<cstring>qpbFontLog</cstring>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="qpbFontLog">
<property name="text">
<string>Change</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="qpbFontAll">
<property name="text">
<string>Change All</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
Expand Down
4 changes: 4 additions & 0 deletions src/mumble/MainWindow.cpp
Expand Up @@ -1043,6 +1043,10 @@ void MainWindow::setOnTop(bool top) {
void MainWindow::setupView(bool toggle_minimize) {
bool showit = !g.s.bMinimalView;

qteLog->setFont(g.s.qfFontLog);
qteChat->setFont(g.s.qfFontInput);
qtvUsers->setFont(g.s.qfFontTree);

switch (g.s.wlWindowLayout) {
case Settings::LayoutClassic:
removeDockWidget(qdwLog);
Expand Down
6 changes: 6 additions & 0 deletions src/mumble/Settings.cpp
Expand Up @@ -837,6 +837,9 @@ void Settings::load(QSettings *settings_ptr) {
SAVELOAD(qsLanguage, "ui/language");
SAVELOAD(themeName, "ui/theme");
SAVELOAD(themeStyleName, "ui/themestyle");
SAVELOAD(qfFontLog, "ui/fontlog");
SAVELOAD(qfFontInput, "ui/fontinput");
SAVELOAD(qfFontTree, "ui/fonttree");
LOADENUM(ceExpand, "ui/expand");
LOADENUM(ceChannelDrag, "ui/drag");
LOADENUM(ceUserDrag, "ui/userdrag");
Expand Down Expand Up @@ -1209,6 +1212,9 @@ void Settings::save() {
SAVELOAD(qsLanguage, "ui/language");
SAVELOAD(themeName, "ui/theme");
SAVELOAD(themeStyleName, "ui/themestyle");
SAVELOAD(qfFontLog, "ui/fontlog");
SAVELOAD(qfFontInput, "ui/fontinput");
SAVELOAD(qfFontTree, "ui/fonttree");
SAVELOAD(ceExpand, "ui/expand");
SAVELOAD(ceChannelDrag, "ui/drag");
SAVELOAD(ceUserDrag, "ui/userdrag");
Expand Down
4 changes: 4 additions & 0 deletions src/mumble/Settings.h
Expand Up @@ -315,6 +315,10 @@ struct Settings {
/// Name of the style to use from theme. @see Themes
QString themeStyleName;

QFont qfFontLog;
QFont qfFontInput;
QFont qfFontTree;
Comment on lines +318 to +320
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation: A small Doxygen comment stating what these fonts are intended to be used for would improve readability


QByteArray qbaMainWindowGeometry, qbaMainWindowState, qbaMinimalViewGeometry, qbaMinimalViewState, qbaSplitterState,
qbaHeaderState;
QByteArray qbaConfigGeometry;
Expand Down
4 changes: 2 additions & 2 deletions src/mumble/UserModel.cpp
Expand Up @@ -465,7 +465,7 @@ QVariant UserModel::data(const QModelIndex &idx, int role) const {
break;
case Qt::FontRole:
if ((idx.column() == 0) && (p->uiSession == g.uiSession)) {
QFont f = g.mw->font();
QFont f = g.s.qfFontTree;
f.setBold(!f.bold());
f.setItalic(item->isListener);
return f;
Expand Down Expand Up @@ -560,7 +560,7 @@ QVariant UserModel::data(const QModelIndex &idx, int role) const {
Channel *home = ClientUser::get(g.uiSession)->cChannel;

if ((c == home) || qsLinked.contains(c)) {
QFont f = g.mw->font();
QFont f = g.s.qfFontTree;
if (qsLinked.count() > 1)
f.setItalic(!f.italic());
if (c == home)
Expand Down