Commit eae23d5d authored by Filip Fila's avatar Filip Fila 🌆
Browse files

[kcms/fonts] Replace warning message with inline message when applying changes

Summary:
This patch gets rid of the popup message spawned when applying changes in the Fonts KCM and instead places the very same information in an inline message.

BUG: 388433

Test Plan: {F7097619}

Reviewers: #plasma, #vdg, ngraham, davidedmundson

Reviewed By: #plasma, #vdg, ngraham, davidedmundson

Subscribers: davidedmundson, broulik, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D22752
parent 0b9eb1e7
......@@ -288,20 +288,13 @@ bool FontAASettings::save(KXftConfig::AntiAliasing::State aaState)
// TODO: With AASystem the changes already made by this module should be reverted somehow.
#if defined(HAVE_FONTCONFIG) && defined (HAVE_X11)
if (mod || (m_state.antiAliasing != m_originalState.antiAliasing) || m_state.dpi != m_originalState.dpi) {
KMessageBox::information(nullptr,
i18n(
"<p>Some changes such as anti-aliasing or DPI will only affect newly started applications.</p>"
), i18n("Font Settings Changed"), "FontSettingsChanged");
m_originalState.antiAliasing = m_state.antiAliasing;
m_originalState.dpi = m_state.dpi;
emit aliasingChangeApplied();
}
#else
#if HAVE_X11
if (m_state.dpi != m_originalState.dpi) {
KMessageBox::information(0,
i18n(
"<p>Some changes such as DPI will only affect newly started applications.</p>"
), i18n("Font Settings Changed"), "FontSettingsChanged");
m_originalState.dpi = m_state.dpi;
}
#endif
......@@ -310,7 +303,7 @@ bool FontAASettings::save(KXftConfig::AntiAliasing::State aaState)
m_originalState.exclude = m_state.exclude;
m_originalState.excludeTo = m_state.excludeTo;
m_originalState.excludeFrom = m_state.excludeFrom;
m_originalState.subPixel = m_state.subPixel;
m_originalState.hinting = m_state.hinting;
......@@ -542,7 +535,7 @@ void KFonts::load()
m_windowTitleFont = m_windowTitleFontOriginal = nearestExistingFont(cg.readEntry("activeFont", m_defaultFont));
engine()->addImageProvider("preview", new PreviewImageProvider(generalFont()));
emit generalFontChanged();
emit fixedWidthFontChanged();
emit smallFontChanged();
......
......@@ -113,6 +113,7 @@ Q_SIGNALS:
void excludeToChanged();
void excludeFromChanged();
void antiAliasingChanged();
void aliasingChangeApplied();
void aliasingChanged();
void dpiChanged();
void subPixelCurrentIndexChanged();
......
......@@ -21,7 +21,7 @@ import QtQuick 2.1
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.0 as QtControls
import QtQuick.Dialogs 1.2 as QtDialogs
import org.kde.kirigami 2.3 as Kirigami
import org.kde.kirigami 2.4 as Kirigami
import org.kde.kcm 1.1 as KCM
KCM.SimpleKCM {
......@@ -29,214 +29,228 @@ KCM.SimpleKCM {
KCM.ConfigModule.quickHelp: i18n("This module lets you configure the system fonts.")
Kirigami.FormLayout {
id: formLayout
readonly property int maxImplicitWidth: Math.max(adjustAllFontsButton.implicitWidth, excludeField.implicitWidth, subPixelCombo.implicitWidth, hintingCombo.implicitWidth)
ColumnLayout {
QtControls.Button {
id: adjustAllFontsButton
Layout.preferredWidth: formLayout.maxImplicitWidth
icon.name: "font-select-symbolic"
text: i18n("&Adjust All Fonts...")
Kirigami.InlineMessage {
id: antiAliasingMessage
Layout.fillWidth: true
showCloseButton: true
text: i18n("Some changes such as anti-aliasing or DPI will only affect newly started applications.")
onClicked: kcm.adjustAllFonts();
Connections {
target: kcm.fontAASettings
onAliasingChangeApplied: antiAliasingMessage.visible = true
}
}
FontWidget {
id: generalFontWidget
label: i18n("General:")
category: "generalFont"
font: kcm.generalFont
}
FontWidget {
label: i18n("Fixed width:")
category: "fixedWidthFont"
font: kcm.fixedWidthFont
}
FontWidget {
label: i18n("Small:")
category: "smallFont"
font: kcm.smallFont
}
FontWidget {
label: i18n("Toolbar:")
category: "toolbarFont"
font: kcm.toolbarFont
}
FontWidget {
label: i18n("Menu:")
category: "menuFont"
font: kcm.menuFont
}
FontWidget {
label: i18n("Window title:")
category: "windowTitleFont"
font: kcm.windowTitleFont
}
Kirigami.Separator {
Kirigami.FormData.isSection: true
}
Kirigami.FormLayout {
id: formLayout
readonly property int maxImplicitWidth: Math.max(adjustAllFontsButton.implicitWidth, excludeField.implicitWidth, subPixelCombo.implicitWidth, hintingCombo.implicitWidth)
QtControls.CheckBox {
id: antiAliasingCheckBox
checked: kcm.fontAASettings.antiAliasing
onCheckedChanged: kcm.fontAASettings.antiAliasing = checked
Kirigami.FormData.label: i18n("Anti-Aliasing:")
text: i18n("Enable")
Layout.fillWidth: true
}
QtControls.Button {
id: adjustAllFontsButton
Layout.preferredWidth: formLayout.maxImplicitWidth
icon.name: "font-select-symbolic"
text: i18n("&Adjust All Fonts...")
QtControls.CheckBox {
id: excludeCheckBox
checked: kcm.fontAASettings.exclude
onCheckedChanged: kcm.fontAASettings.exclude = checked;
text: i18n("Exclude range from anti-aliasing")
Layout.fillWidth: true
enabled: antiAliasingCheckBox.checked
}
onClicked: kcm.adjustAllFonts();
}
RowLayout {
id: excludeField
Layout.preferredWidth: formLayout.maxImplicitWidth
enabled: antiAliasingCheckBox.checked
QtControls.SpinBox {
id: excludeFromSpinBox
stepSize: 1
onValueChanged: kcm.fontAASettings.excludeFrom = value
textFromValue: function(value, locale) { return i18n("%1 pt", value)}
enabled: excludeCheckBox.checked
FontWidget {
id: generalFontWidget
label: i18n("General:")
category: "generalFont"
font: kcm.generalFont
}
FontWidget {
label: i18n("Fixed width:")
category: "fixedWidthFont"
font: kcm.fixedWidthFont
}
FontWidget {
label: i18n("Small:")
category: "smallFont"
font: kcm.smallFont
}
FontWidget {
label: i18n("Toolbar:")
category: "toolbarFont"
font: kcm.toolbarFont
}
FontWidget {
label: i18n("Menu:")
category: "menuFont"
font: kcm.menuFont
}
FontWidget {
label: i18n("Window title:")
category: "windowTitleFont"
font: kcm.windowTitleFont
}
QtControls.Label {
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
text: i18n("to")
enabled: excludeCheckBox.checked
Kirigami.Separator {
Kirigami.FormData.isSection: true
}
QtControls.SpinBox {
id: excludeToSpinBox
stepSize: 1
onValueChanged: kcm.fontAASettings.excludeTo = value
textFromValue: function(value, locale) { return i18n("%1 pt", value)}
enabled: excludeCheckBox.checked
QtControls.CheckBox {
id: antiAliasingCheckBox
checked: kcm.fontAASettings.antiAliasing
onCheckedChanged: kcm.fontAASettings.antiAliasing = checked
Kirigami.FormData.label: i18n("Anti-Aliasing:")
text: i18n("Enable")
Layout.fillWidth: true
}
Connections {
target: kcm.fontAASettings
onExcludeFromChanged: excludeFromSpinBox.value = kcm.fontAASettings.excludeFrom;
onExcludeToChanged: excludeToSpinBox.value = kcm.fontAASettings.excludeTo;
QtControls.CheckBox {
id: excludeCheckBox
checked: kcm.fontAASettings.exclude
onCheckedChanged: kcm.fontAASettings.exclude = checked;
text: i18n("Exclude range from anti-aliasing")
Layout.fillWidth: true
enabled: antiAliasingCheckBox.checked
}
}
QtControls.ComboBox {
id: subPixelCombo
Layout.preferredWidth: formLayout.maxImplicitWidth
Kirigami.FormData.label: i18nc("Used as a noun, and precedes a combobox full of options", "Sub-pixel rendering:")
currentIndex: kcm.fontAASettings.subPixelCurrentIndex
onCurrentIndexChanged: kcm.fontAASettings.subPixelCurrentIndex = currentIndex;
model: kcm.fontAASettings.subPixelOptionsModel
textRole: "display"
enabled: antiAliasingCheckBox.checked
popup.height: popup.implicitHeight
delegate: QtControls.ItemDelegate {
id: subPixelDelegate
onWidthChanged: {
subPixelCombo.popup.width = Math.max(subPixelCombo.popup.width, width)
RowLayout {
id: excludeField
Layout.preferredWidth: formLayout.maxImplicitWidth
enabled: antiAliasingCheckBox.checked
QtControls.SpinBox {
id: excludeFromSpinBox
stepSize: 1
onValueChanged: kcm.fontAASettings.excludeFrom = value
textFromValue: function(value, locale) { return i18n("%1 pt", value)}
enabled: excludeCheckBox.checked
}
contentItem: ColumnLayout {
id: subPixelLayout
Kirigami.Heading {
id: subPixelComboText
text: model.display
level: 5
QtControls.Label {
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
text: i18n("to")
enabled: excludeCheckBox.checked
}
QtControls.SpinBox {
id: excludeToSpinBox
stepSize: 1
onValueChanged: kcm.fontAASettings.excludeTo = value
textFromValue: function(value, locale) { return i18n("%1 pt", value)}
enabled: excludeCheckBox.checked
}
Connections {
target: kcm.fontAASettings
onExcludeFromChanged: excludeFromSpinBox.value = kcm.fontAASettings.excludeFrom;
onExcludeToChanged: excludeToSpinBox.value = kcm.fontAASettings.excludeTo;
}
}
QtControls.ComboBox {
id: subPixelCombo
Layout.preferredWidth: formLayout.maxImplicitWidth
Kirigami.FormData.label: i18nc("Used as a noun, and precedes a combobox full of options", "Sub-pixel rendering:")
currentIndex: kcm.fontAASettings.subPixelCurrentIndex
onCurrentIndexChanged: kcm.fontAASettings.subPixelCurrentIndex = currentIndex;
model: kcm.fontAASettings.subPixelOptionsModel
textRole: "display"
enabled: antiAliasingCheckBox.checked
popup.height: popup.implicitHeight
delegate: QtControls.ItemDelegate {
id: subPixelDelegate
onWidthChanged: {
subPixelCombo.popup.width = Math.max(subPixelCombo.popup.width, width)
}
Image {
id: subPixelComboImage
source: "image://preview/" + model.index + "_" + kcm.fontAASettings.hintingCurrentIndex + ".png"
// Setting sourceSize here is necessary as a workaround for QTBUG-38127
//
// With this bug, images requested from a QQuickImageProvider have an incorrect scale with devicePixelRatio != 1 when sourceSize is not set.
//
// TODO: Check if QTBUG-38127 is fixed and remove the next two lines.
sourceSize.width: 1
sourceSize.height: 1
contentItem: ColumnLayout {
id: subPixelLayout
Kirigami.Heading {
id: subPixelComboText
text: model.display
level: 5
}
Image {
id: subPixelComboImage
source: "image://preview/" + model.index + "_" + kcm.fontAASettings.hintingCurrentIndex + ".png"
// Setting sourceSize here is necessary as a workaround for QTBUG-38127
//
// With this bug, images requested from a QQuickImageProvider have an incorrect scale with devicePixelRatio != 1 when sourceSize is not set.
//
// TODO: Check if QTBUG-38127 is fixed and remove the next two lines.
sourceSize.width: 1
sourceSize.height: 1
}
}
}
}
}
QtControls.ComboBox {
id: hintingCombo
Layout.preferredWidth: formLayout.maxImplicitWidth
Kirigami.FormData.label: i18nc("Used as a noun, and precedes a combobox full of options", "Hinting:")
currentIndex: kcm.fontAASettings.hintingCurrentIndex
onCurrentTextChanged: kcm.fontAASettings.hintingCurrentIndex = currentIndex;
model: kcm.fontAASettings.hintingOptionsModel
textRole: "display"
enabled: antiAliasingCheckBox.checked
popup.height: popup.implicitHeight
delegate: QtControls.ItemDelegate {
id: hintingDelegate
onWidthChanged: {
hintingCombo.popup.width = Math.max(hintingCombo.popup.width, width)
}
contentItem: ColumnLayout {
id: hintingLayout
Kirigami.Heading {
id: hintingComboText
text: model.display
level: 5
QtControls.ComboBox {
id: hintingCombo
Layout.preferredWidth: formLayout.maxImplicitWidth
Kirigami.FormData.label: i18nc("Used as a noun, and precedes a combobox full of options", "Hinting:")
currentIndex: kcm.fontAASettings.hintingCurrentIndex
onCurrentTextChanged: kcm.fontAASettings.hintingCurrentIndex = currentIndex;
model: kcm.fontAASettings.hintingOptionsModel
textRole: "display"
enabled: antiAliasingCheckBox.checked
popup.height: popup.implicitHeight
delegate: QtControls.ItemDelegate {
id: hintingDelegate
onWidthChanged: {
hintingCombo.popup.width = Math.max(hintingCombo.popup.width, width)
}
Image {
id: hintingComboImage
source: "image://preview/" + kcm.fontAASettings.subPixelCurrentIndex + "_" + model.index + ".png"
// Setting sourceSize here is necessary as a workaround for QTBUG-38127
//
// With this bug, images requested from a QQuickImageProvider have an incorrect scale with devicePixelRatio != 1 when sourceSize is not set.
//
// TODO: Check if QTBUG-38127 is fixed and remove the next two lines.
sourceSize.width: 1
sourceSize.height: 1
contentItem: ColumnLayout {
id: hintingLayout
Kirigami.Heading {
id: hintingComboText
text: model.display
level: 5
}
Image {
id: hintingComboImage
source: "image://preview/" + kcm.fontAASettings.subPixelCurrentIndex + "_" + model.index + ".png"
// Setting sourceSize here is necessary as a workaround for QTBUG-38127
//
// With this bug, images requested from a QQuickImageProvider have an incorrect scale with devicePixelRatio != 1 when sourceSize is not set.
//
// TODO: Check if QTBUG-38127 is fixed and remove the next two lines.
sourceSize.width: 1
sourceSize.height: 1
}
}
}
}
}
RowLayout {
QtControls.CheckBox {
id: dpiCheckBox
checked: kcm.fontAASettings.dpi !== 0
text: i18n("Force font DPI:")
onClicked: kcm.fontAASettings.dpi = (checked ? dpiSpinBox.value : 0)
}
QtControls.SpinBox {
id: dpiSpinBox
stepSize: 24
editable: true
enabled: dpiCheckBox.checked
value: kcm.fontAASettings.dpi !== 0 ? kcm.fontAASettings.dpi : 96
onValueModified: kcm.fontAASettings.dpi = value
to: 1000
from: 1
RowLayout {
QtControls.CheckBox {
id: dpiCheckBox
checked: kcm.fontAASettings.dpi !== 0
text: i18n("Force font DPI:")
onClicked: kcm.fontAASettings.dpi = (checked ? dpiSpinBox.value : 0)
}
QtControls.SpinBox {
id: dpiSpinBox
stepSize: 24
editable: true
enabled: dpiCheckBox.checked
value: kcm.fontAASettings.dpi !== 0 ? kcm.fontAASettings.dpi : 96
onValueModified: kcm.fontAASettings.dpi = value
to: 1000
from: 1
}
}
}
QtDialogs.FontDialog {
id: fontDialog
title: i18n("Select Font")
modality: Qt.WindowModal
property string currentCategory
property bool adjustAllFonts: false
onAccepted: {
if (adjustAllFonts) {
kcm.adjustAllFonts(font);
} else {
kcm[currentCategory] = font;
QtDialogs.FontDialog {
id: fontDialog
title: i18n("Select Font")
modality: Qt.WindowModal
property string currentCategory
property bool adjustAllFonts: false
onAccepted: {
if (adjustAllFonts) {
kcm.adjustAllFonts(font);
} else {
kcm[currentCategory] = font;
}
}
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment