diff --git a/app/qml/Dialogs/About.qml b/app/qml/Dialogs/About.qml
index 81bad8fd..f93162b9 100644
--- a/app/qml/Dialogs/About.qml
+++ b/app/qml/Dialogs/About.qml
@@ -94,7 +94,7 @@ Window {
text: root.title
visible: root.titlebarHeight > 0
color: Cpp_ThemeManager.colors["text"]
- font: Cpp_Misc_CommonFonts.customUiFont(13, true)
+ font: Cpp_Misc_CommonFonts.customUiFont(14, true)
anchors {
topMargin: 6
@@ -199,7 +199,7 @@ Window {
Label {
opacity: 0.8
- font.pixelSize: 12
+ font.pointSize: 12
Layout.fillWidth: true
Layout.maximumWidth: 320
wrapMode: Label.WrapAtWordBoundaryOrAnywhere
diff --git a/app/qml/Dialogs/Acknowledgements.qml b/app/qml/Dialogs/Acknowledgements.qml
index 09694c6b..ca641b9e 100644
--- a/app/qml/Dialogs/Acknowledgements.qml
+++ b/app/qml/Dialogs/Acknowledgements.qml
@@ -89,7 +89,7 @@ Window {
text: root.title
visible: root.titlebarHeight > 0
color: Cpp_ThemeManager.colors["text"]
- font: Cpp_Misc_CommonFonts.customUiFont(13, true)
+ font: Cpp_Misc_CommonFonts.customUiFont(14, true)
anchors {
topMargin: 6
diff --git a/app/qml/Dialogs/CsvPlayer.qml b/app/qml/Dialogs/CsvPlayer.qml
index 107b1d63..d8f3a4fa 100644
--- a/app/qml/Dialogs/CsvPlayer.qml
+++ b/app/qml/Dialogs/CsvPlayer.qml
@@ -93,7 +93,7 @@ Window {
text: root.title
visible: root.titlebarHeight > 0
color: Cpp_ThemeManager.colors["text"]
- font: Cpp_Misc_CommonFonts.customUiFont(13, true)
+ font: Cpp_Misc_CommonFonts.customUiFont(14, true)
anchors {
topMargin: 6
diff --git a/app/qml/Dialogs/Donate.qml b/app/qml/Dialogs/Donate.qml
index 0325e722..68f019d3 100644
--- a/app/qml/Dialogs/Donate.qml
+++ b/app/qml/Dialogs/Donate.qml
@@ -91,7 +91,7 @@ Window {
text: root.title
visible: root.titlebarHeight > 0
color: Cpp_ThemeManager.colors["text"]
- font: Cpp_Misc_CommonFonts.customUiFont(13, true)
+ font: Cpp_Misc_CommonFonts.customUiFont(14, true)
anchors {
topMargin: 6
@@ -193,14 +193,14 @@ Window {
Label {
id: title
Layout.fillWidth: true
- Layout.minimumHeight: font.pixelSize
+ Layout.minimumHeight: font.pointSize
font: Cpp_Misc_CommonFonts.customUiFont(16, true)
text: qsTr("Support the development of %1!").arg(Cpp_AppName)
}
Label {
Layout.fillWidth: true
- Layout.minimumHeight: font.pixelSize * 3
+ Layout.minimumHeight: font.pointSize * 3
Layout.maximumWidth: title.implicitWidth
wrapMode: Label.WrapAtWordBoundaryOrAnywhere
text: qsTr("Serial Studio is free & open-source software supported by volunteers. " +
@@ -209,9 +209,9 @@ Window {
Label {
opacity: 0.8
- font.pixelSize: 12
+ font.pointSize: 12
Layout.fillWidth: true
- Layout.minimumHeight: font.pixelSize * 2
+ Layout.minimumHeight: font.pointSize * 2
Layout.maximumWidth: title.implicitWidth
wrapMode: Label.WrapAtWordBoundaryOrAnywhere
text: qsTr("You can also support this project by sharing it, reporting bugs and proposing new features!")
diff --git a/app/qml/Dialogs/ExternalConsole.qml b/app/qml/Dialogs/ExternalConsole.qml
index b32f54a9..47747b2e 100644
--- a/app/qml/Dialogs/ExternalConsole.qml
+++ b/app/qml/Dialogs/ExternalConsole.qml
@@ -83,7 +83,7 @@ Window {
text: root.title
visible: root.titlebarHeight > 0
color: Cpp_ThemeManager.colors["text"]
- font: Cpp_Misc_CommonFonts.customUiFont(13, true)
+ font: Cpp_Misc_CommonFonts.customUiFont(14, true)
anchors {
topMargin: 6
diff --git a/app/qml/Dialogs/MQTTConfiguration.qml b/app/qml/Dialogs/MQTTConfiguration.qml
index b94d4244..390ede50 100644
--- a/app/qml/Dialogs/MQTTConfiguration.qml
+++ b/app/qml/Dialogs/MQTTConfiguration.qml
@@ -95,7 +95,7 @@ Window {
text: root.title
visible: root.titlebarHeight > 0
color: Cpp_ThemeManager.colors["text"]
- font: Cpp_Misc_CommonFonts.customUiFont(13, true)
+ font: Cpp_Misc_CommonFonts.customUiFont(14, true)
anchors {
topMargin: 6
diff --git a/app/qml/MainWindow/Dashboard/WidgetDelegate.qml b/app/qml/MainWindow/Dashboard/WidgetDelegate.qml
index 40a4661f..2721ebf6 100644
--- a/app/qml/MainWindow/Dashboard/WidgetDelegate.qml
+++ b/app/qml/MainWindow/Dashboard/WidgetDelegate.qml
@@ -171,7 +171,7 @@ Widgets.Pane {
text: window.title
visible: window.titlebarHeight > 0
color: Cpp_ThemeManager.colors["text"]
- font: Cpp_Misc_CommonFonts.customUiFont(13, true)
+ font: Cpp_Misc_CommonFonts.customUiFont(14, true)
anchors {
topMargin: 6
diff --git a/app/qml/MainWindow/Panes/Console.qml b/app/qml/MainWindow/Panes/Console.qml
index 20b9abea..e349769f 100644
--- a/app/qml/MainWindow/Panes/Console.qml
+++ b/app/qml/MainWindow/Panes/Console.qml
@@ -32,6 +32,9 @@ Widgets.Pane {
title: qsTr("Console")
icon: "qrc:/rcc/icons/panes/console.svg"
+ Layout.minimumWidth: terminal.implicitWidth
+ Layout.minimumHeight: terminal.implicitHeight
+
//
// Custom properties
//
diff --git a/app/qml/MainWindow/Panes/Setup.qml b/app/qml/MainWindow/Panes/Setup.qml
index d5ed85cf..5ffb83d7 100644
--- a/app/qml/MainWindow/Panes/Setup.qml
+++ b/app/qml/MainWindow/Panes/Setup.qml
@@ -33,6 +33,7 @@ Widgets.Pane {
id: root
title: qsTr("Setup")
icon: "qrc:/rcc/icons/panes/setup.svg"
+ implicitHeight: column.implicitHeight + 32
//
// Custom properties
diff --git a/app/qml/MainWindow/Panes/Toolbar.qml b/app/qml/MainWindow/Panes/Toolbar.qml
index 9e5f6627..0c4cec78 100644
--- a/app/qml/MainWindow/Panes/Toolbar.qml
+++ b/app/qml/MainWindow/Panes/Toolbar.qml
@@ -28,8 +28,9 @@ import QtQuick.Controls
import SerialStudio
import "../../Widgets" as Widgets
-ToolBar {
+Rectangle {
id: root
+ implicitWidth: (layout.implicitWidth + 32)
//
// Custom signals
@@ -72,7 +73,7 @@ ToolBar {
text: mainWindow.title
visible: root.titlebarHeight > 0
color: Cpp_ThemeManager.colors["titlebar_text"]
- font: Cpp_Misc_CommonFonts.customUiFont(13, true)
+ font: Cpp_Misc_CommonFonts.customUiFont(14, true)
anchors {
topMargin: 6
@@ -84,36 +85,40 @@ ToolBar {
//
// Toolbar background
//
- background: Rectangle {
- gradient: Gradient {
- GradientStop {
- position: 0
- color: Cpp_ThemeManager.colors["toolbar_top"]
- }
-
- GradientStop {
- position: 1
- color: Cpp_ThemeManager.colors["toolbar_bottom"]
- }
+ gradient: Gradient {
+ GradientStop {
+ position: 0
+ color: Cpp_ThemeManager.colors["toolbar_top"]
}
- Rectangle {
- height: 1
- color: Cpp_ThemeManager.colors["toolbar_border"]
-
- anchors {
- left: parent.left
- right: parent.right
- bottom: parent.bottom
- }
+ GradientStop {
+ position: 1
+ color: Cpp_ThemeManager.colors["toolbar_bottom"]
}
+ }
- DragHandler {
- target: null
- onActiveChanged: {
- if (active)
- mainWindow.startSystemMove()
- }
+ //
+ // Toolbar border
+ //
+ Rectangle {
+ height: 1
+ color: Cpp_ThemeManager.colors["toolbar_border"]
+
+ anchors {
+ left: parent.left
+ right: parent.right
+ bottom: parent.bottom
+ }
+ }
+
+ //
+ // Drag main window with the toolbar
+ //
+ DragHandler {
+ target: null
+ onActiveChanged: {
+ if (active)
+ mainWindow.startSystemMove()
}
}
@@ -121,6 +126,7 @@ ToolBar {
// Toolbar controls
//
RowLayout {
+ id: layout
spacing: 8
anchors {
@@ -157,7 +163,7 @@ ToolBar {
// Separator
//
Rectangle {
- width: 1
+ implicitWidth: 1
Layout.fillHeight: true
Layout.maximumHeight: 64
Layout.alignment: Qt.AlignVCenter
@@ -192,7 +198,7 @@ ToolBar {
// Separator
//
Rectangle {
- width: 1
+ implicitWidth: 1
Layout.fillHeight: true
Layout.maximumHeight: 64
Layout.alignment: Qt.AlignVCenter
@@ -227,7 +233,7 @@ ToolBar {
// Separator
//
Rectangle {
- width: 1
+ implicitWidth: 1
Layout.fillHeight: true
Layout.maximumHeight: 64
Layout.alignment: Qt.AlignVCenter
@@ -252,7 +258,7 @@ ToolBar {
// Separator
//
Rectangle {
- width: 1
+ implicitWidth: 1
Layout.fillHeight: true
Layout.maximumHeight: 64
Layout.alignment: Qt.AlignVCenter
@@ -293,6 +299,7 @@ ToolBar {
// Horizontal spacer
//
Item {
+ implicitWidth: 1
Layout.fillWidth: true
}
@@ -302,6 +309,7 @@ ToolBar {
Widgets.BigButton {
checked: Cpp_IO_Manager.connected
Layout.alignment: Qt.AlignVCenter
+ implicitWidth: metrics.width + 32
font: Cpp_Misc_CommonFonts.boldUiFont
Layout.minimumWidth: metrics.width + 32
Layout.maximumWidth: metrics.width + 32
@@ -325,5 +333,12 @@ ToolBar {
text: " " + qsTr("Disconnect") + " "
}
}
+
+ //
+ // Horizontal spacer
+ //
+ Item {
+ implicitWidth: 1
+ }
}
}
diff --git a/app/qml/MainWindow/Root.qml b/app/qml/MainWindow/Root.qml
index c0e88134..810bfb0c 100644
--- a/app/qml/MainWindow/Root.qml
+++ b/app/qml/MainWindow/Root.qml
@@ -32,9 +32,9 @@ import "../Widgets" as Widgets
Widgets.SmartWindow {
id: root
- minimumWidth: 1100
- minimumHeight: 660
category: "MainWindow"
+ minimumWidth: layout.implicitWidth
+ minimumHeight: layout.implicitHeight
title: qsTr("%1 - %2").arg(documentTitle).arg(Cpp_AppName)
//
@@ -276,6 +276,8 @@ Widgets.SmartWindow {
initialItem: terminal
Layout.fillWidth: true
Layout.fillHeight: true
+ Layout.minimumHeight: Math.max(dashboard.implicitHeight, terminal.implicitHeight, setup.implicitHeight)
+ Layout.minimumWidth: Math.max(dashboard.implicitWidth, terminal.implicitWidth) + (setup.visible ? 0 : setup.displayedWidth + 1)
data: [
Panes.Console {
diff --git a/app/qml/ProjectEditor/Root.qml b/app/qml/ProjectEditor/Root.qml
index e779363d..a106958e 100644
--- a/app/qml/ProjectEditor/Root.qml
+++ b/app/qml/ProjectEditor/Root.qml
@@ -38,9 +38,9 @@ Widgets.SmartWindow {
//
// Window options
//
- minimumWidth: 970
- minimumHeight: 640
category: "ProjectEditor"
+ minimumWidth: layout.implicitWidth + 32
+ minimumHeight: layout.implicitHeight + 32
title: qsTr("%1 - Project Editor").arg(Cpp_JSON_ProjectModel.title + (Cpp_JSON_ProjectModel.modified ? " (" + qsTr("modified") + ")" : ""))
//
@@ -133,6 +133,7 @@ Widgets.SmartWindow {
Layout.topMargin: -1
Layout.fillWidth: true
Layout.fillHeight: true
+ Layout.minimumHeight: 520
//
// Project structure
diff --git a/app/qml/ProjectEditor/Sections/Toolbar.qml b/app/qml/ProjectEditor/Sections/Toolbar.qml
index 6d18142a..9f242aec 100644
--- a/app/qml/ProjectEditor/Sections/Toolbar.qml
+++ b/app/qml/ProjectEditor/Sections/Toolbar.qml
@@ -29,9 +29,9 @@ import SerialStudio
import "../../Widgets" as Widgets
-
-ToolBar {
+Rectangle {
id: root
+ implicitWidth: layout.implicitWidth + 32
//
// Calculate offset based on platform
@@ -57,7 +57,7 @@ ToolBar {
text: projectEditor.title
visible: root.titlebarHeight > 0
color: Cpp_ThemeManager.colors["titlebar_text"]
- font: Cpp_Misc_CommonFonts.customUiFont(13, true)
+ font: Cpp_Misc_CommonFonts.customUiFont(14, true)
anchors {
topMargin: 6
@@ -69,36 +69,40 @@ ToolBar {
//
// Toolbar background
//
- background: Rectangle {
- gradient: Gradient {
- GradientStop {
- position: 0
- color: Cpp_ThemeManager.colors["toolbar_top"]
- }
-
- GradientStop {
- position: 1
- color: Cpp_ThemeManager.colors["toolbar_bottom"]
- }
+ gradient: Gradient {
+ GradientStop {
+ position: 0
+ color: Cpp_ThemeManager.colors["toolbar_top"]
}
- Rectangle {
- height: 1
- color: Cpp_ThemeManager.colors["toolbar_border"]
-
- anchors {
- left: parent.left
- right: parent.right
- bottom: parent.bottom
- }
+ GradientStop {
+ position: 1
+ color: Cpp_ThemeManager.colors["toolbar_bottom"]
}
+ }
- DragHandler {
- target: null
- onActiveChanged: {
- if (active)
- projectEditor.startSystemMove()
- }
+ //
+ // Toolbar bottom border
+ //
+ Rectangle {
+ height: 1
+ color: Cpp_ThemeManager.colors["toolbar_border"]
+
+ anchors {
+ left: parent.left
+ right: parent.right
+ bottom: parent.bottom
+ }
+ }
+
+ //
+ // Move window with toolbar
+ //
+ DragHandler {
+ target: null
+ onActiveChanged: {
+ if (active)
+ projectEditor.startSystemMove()
}
}
@@ -106,6 +110,7 @@ ToolBar {
// Toolbar controls
//
RowLayout {
+ id: layout
spacing: 8
anchors {
diff --git a/app/qml/Widgets/BigButton.qml b/app/qml/Widgets/BigButton.qml
index bddc1225..9b87504a 100644
--- a/app/qml/Widgets/BigButton.qml
+++ b/app/qml/Widgets/BigButton.qml
@@ -33,11 +33,21 @@ ToolButton {
icon.height: 32
icon.color: "transparent"
display: AbstractButton.TextUnderIcon
-
- Layout.minimumWidth: Math.max(implicitWidth, icon.width / 32 * 72)
- Layout.maximumWidth: Math.max(implicitWidth, icon.width / 32 * 72)
palette.buttonText: Cpp_ThemeManager.colors["toolbar_text"]
+ Layout.minimumWidth: implicitWidth
+ Layout.maximumWidth: implicitWidth
+ implicitWidth: Math.max(Math.ceil(metrics.width + 32), icon.width / 32 * 72)
+
+ opacity: enabled ? 1 : 0.5
+ Behavior on opacity {NumberAnimation{}}
+
+ TextMetrics {
+ id: metrics
+ text: root.text
+ font: Cpp_Misc_CommonFonts.uiFont
+ }
+
background: Item {
Rectangle {
radius: 3
@@ -55,7 +65,4 @@ ToolButton {
visible: root.checked && !root.toolbarButton
}
}
-
- opacity: enabled ? 1 : 0.5
- Behavior on opacity {NumberAnimation{}}
}
diff --git a/app/qml/Widgets/Dashboard/Terminal.qml b/app/qml/Widgets/Dashboard/Terminal.qml
index 2dc0d763..82134808 100644
--- a/app/qml/Widgets/Dashboard/Terminal.qml
+++ b/app/qml/Widgets/Dashboard/Terminal.qml
@@ -29,6 +29,8 @@ import SerialStudio
Item {
id: root
+ implicitWidth: layout.implicitWidth + 32
+ implicitHeight: layout.implicitHeight + 32
property alias vt100emulation: terminal.vt100emulation
//
@@ -169,6 +171,7 @@ Item {
// Controls
//
ColumnLayout {
+ id: layout
spacing: 4
anchors.fill: parent
anchors.topMargin: -6
@@ -181,6 +184,8 @@ Item {
vt100emulation: true
Layout.fillWidth: true
Layout.fillHeight: true
+ Layout.minimumWidth: terminal.charWidth * 80
+ Layout.minimumHeight: terminal.charHeight * 24
Rectangle {
border.width: 1
diff --git a/app/rcc/fonts/NotoSans-Bold.ttf b/app/rcc/fonts/NotoSans-Bold.ttf
deleted file mode 100644
index c4c4b1ee..00000000
Binary files a/app/rcc/fonts/NotoSans-Bold.ttf and /dev/null differ
diff --git a/app/rcc/fonts/NotoSans-Regular.ttf b/app/rcc/fonts/NotoSans-Regular.ttf
deleted file mode 100644
index 9b4f9dbb..00000000
Binary files a/app/rcc/fonts/NotoSans-Regular.ttf and /dev/null differ
diff --git a/app/rcc/fonts/NotoSansMono-Regular.ttf b/app/rcc/fonts/NotoSansMono-Regular.ttf
deleted file mode 100644
index c2bbb5a3..00000000
Binary files a/app/rcc/fonts/NotoSansMono-Regular.ttf and /dev/null differ
diff --git a/app/rcc/fonts/NotoSansSC-Bold.ttf b/app/rcc/fonts/NotoSansSC-Bold.ttf
deleted file mode 100644
index 53f4437e..00000000
Binary files a/app/rcc/fonts/NotoSansSC-Bold.ttf and /dev/null differ
diff --git a/app/rcc/fonts/NotoSansSC-Regular.ttf b/app/rcc/fonts/NotoSansSC-Regular.ttf
deleted file mode 100644
index 7056f5e9..00000000
Binary files a/app/rcc/fonts/NotoSansSC-Regular.ttf and /dev/null differ
diff --git a/app/rcc/fonts/SourceCodePro-Regular.ttf b/app/rcc/fonts/SourceCodePro-Regular.ttf
new file mode 100644
index 00000000..b1fa336c
Binary files /dev/null and b/app/rcc/fonts/SourceCodePro-Regular.ttf differ
diff --git a/app/rcc/rcc.qrc b/app/rcc/rcc.qrc
index 0b93a3a8..3036a21a 100644
--- a/app/rcc/rcc.qrc
+++ b/app/rcc/rcc.qrc
@@ -108,11 +108,7 @@
actions/Xbox Y.svg
actions/Zoom In.svg
actions/Zoom Out.svg
- fonts/NotoSans-Bold.ttf
- fonts/NotoSans-Regular.ttf
- fonts/NotoSansMono-Regular.ttf
- fonts/NotoSansSC-Bold.ttf
- fonts/NotoSansSC-Regular.ttf
+ fonts/SourceCodePro-Regular.ttf
icons/buttons/apply.svg
icons/buttons/center.svg
icons/buttons/clear.svg
diff --git a/app/src/IO/Console.cpp b/app/src/IO/Console.cpp
index 2e882745..38ba6835 100644
--- a/app/src/IO/Console.cpp
+++ b/app/src/IO/Console.cpp
@@ -391,7 +391,6 @@ void IO::Console::print()
// Set font
auto font = Misc::CommonFonts::instance().monoFont();
- font.setPixelSize(10);
font.setPointSize(10);
document.setDefaultFont(font);
diff --git a/app/src/IO/Drivers/Serial.cpp b/app/src/IO/Drivers/Serial.cpp
index 167dca89..9782431c 100644
--- a/app/src/IO/Drivers/Serial.cpp
+++ b/app/src/IO/Drivers/Serial.cpp
@@ -775,7 +775,7 @@ void IO::Drivers::Serial::readSettings()
for (int i = 0; i < list.count(); ++i)
m_baudRateList.append(list.at(i));
- // Sort baud rate list
+ // Sort baud rate list
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
for (auto i = 0; i < m_baudRateList.count() - 1; ++i)
{
diff --git a/app/src/Misc/CommonFonts.cpp b/app/src/Misc/CommonFonts.cpp
index 77fbb6e7..dd9929c6 100644
--- a/app/src/Misc/CommonFonts.cpp
+++ b/app/src/Misc/CommonFonts.cpp
@@ -24,7 +24,6 @@
#include
#include
-#include "Misc/Translator.h"
#include "Misc/CommonFonts.h"
/**
@@ -42,21 +41,22 @@ Misc::CommonFonts::CommonFonts()
(addFont(fonts), ...);
};
- // Add common fonts to application database
- // clang-format off
- addFonts(
- QStringLiteral(":/rcc/fonts/NotoSans-Bold.ttf"),
- QStringLiteral(":/rcc/fonts/NotoSansSC-Bold.ttf"),
- QStringLiteral(":/rcc/fonts/NotoSans-Regular.ttf"),
- QStringLiteral(":/rcc/fonts/NotoSansSC-Regular.ttf"),
- QStringLiteral(":/rcc/fonts/NotoSansMono-Regular.ttf")
- );
- // clang-format on
+ // Register the monospace fonts only
+ addFonts(QStringLiteral(":/rcc/fonts/SourceCodePro-Regular.ttf"));
- // Load appropiate fonts for current language
- onLanguageChanged();
- connect(&Misc::Translator::instance(), &Misc::Translator::languageChanged,
- this, &Misc::CommonFonts::onLanguageChanged);
+ // Set the UI font to the system default
+ m_uiFont = QApplication::font();
+ m_boldUiFont = m_uiFont;
+ m_boldUiFont.setBold(true);
+
+ // Set the monospace font from the embedded font
+ m_monoName = QStringLiteral("Source Code Pro");
+ m_monoFont = QFontDatabase::font(m_monoName, QStringLiteral("Regular"),
+ m_uiFont.pointSize());
+ m_monoFont.setStyleHint(QFont::Monospace);
+
+ // Update application fonts
+ QApplication::setFont(m_uiFont);
}
/**
@@ -98,74 +98,25 @@ const QFont &Misc::CommonFonts::boldUiFont() const
/**
* @brief Creates a custom UI font with specified pixel size and boldness.
- * @param pixelSize The pixel size of the font.
+ * @param pointSize The pixel size of the font.
* @param bold True if the font should be bold, otherwise false.
* @return The custom UI font.
*/
-QFont Misc::CommonFonts::customUiFont(const int pixelSize, const bool bold)
+QFont Misc::CommonFonts::customUiFont(const int pointSize, const bool bold)
{
- auto weight = bold ? QStringLiteral("Bold") : QStringLiteral("Regular");
- QFont font = QFontDatabase::font(m_uiName, weight, 12);
- font.setPixelSize(qMax(1, pixelSize));
+ QFont font = bold ? m_boldUiFont : m_uiFont;
+ font.setPointSize(qMax(1, pointSize));
return font;
}
/**
* @brief Creates a custom monospace font with specified pixel size.
- * @param pixelSize The pixel size of the font.
+ * @param pointSize The pixel size of the font.
* @return The custom monospace font.
*/
-QFont Misc::CommonFonts::customMonoFont(const int pixelSize)
+QFont Misc::CommonFonts::customMonoFont(const int pointSize)
{
QFont font = QFontDatabase::font(m_monoName, QStringLiteral("Regular"), 12);
- font.setPixelSize(qMax(1, pixelSize));
+ font.setPointSize(qMax(1, pointSize));
return font;
}
-
-/**
- * @brief Updates the UI and monospace fonts when the language is changed.
- *
- * This function sets the appropriate UI and monospace font names based on the
- * current language selected in the translator. It then loads the fonts with
- * specified attributes such as style and size from the QFontDatabase.
- */
-void Misc::CommonFonts::onLanguageChanged()
-{
- // Obtain fonts to use for current language
- switch (Misc::Translator::instance().language())
- {
- case Misc::Translator::English:
- case Misc::Translator::Spanish:
- case Misc::Translator::German:
- case Misc::Translator::Russian:
- case Misc::Translator::French:
- m_uiName = QStringLiteral("Noto Sans");
- m_monoName = QStringLiteral("Noto Sans Mono");
- break;
- case Misc::Translator::Chinese:
- m_uiName = QStringLiteral("Noto Sans SC");
- m_monoName = QStringLiteral("Noto Sans Mono");
- break;
- }
-
- // Load fonts
- m_uiFont = QFontDatabase::font(m_uiName, QStringLiteral("Regular"), 12);
- m_boldUiFont = QFontDatabase::font(m_uiName, QStringLiteral("Bold"), 12);
- m_monoFont = QFontDatabase::font(m_monoName, QStringLiteral("Regular"), 12);
-
- // Set font size
- m_uiFont.setPixelSize(12);
- m_monoFont.setPixelSize(12);
- m_boldUiFont.setPixelSize(12);
-
- // Set font properties
- m_uiFont.setStyleHint(QFont::SansSerif);
- m_monoFont.setStyleHint(QFont::Monospace);
- m_boldUiFont.setStyleHint(QFont::SansSerif);
-
- // Update application fonts
- QApplication::setFont(m_uiFont);
-
- // Update fonts
- Q_EMIT fontsChanged();
-}
diff --git a/app/src/Misc/CommonFonts.h b/app/src/Misc/CommonFonts.h
index f16d5372..6ba40f2d 100644
--- a/app/src/Misc/CommonFonts.h
+++ b/app/src/Misc/CommonFonts.h
@@ -64,11 +64,8 @@ public:
[[nodiscard]] const QFont &monoFont() const;
[[nodiscard]] const QFont &boldUiFont() const;
- Q_INVOKABLE QFont customUiFont(int pixelSize = 12, bool bold = false);
- Q_INVOKABLE QFont customMonoFont(int pixelSize = 12);
-
-private slots:
- void onLanguageChanged();
+ Q_INVOKABLE QFont customUiFont(int pointSize = 12, bool bold = false);
+ Q_INVOKABLE QFont customMonoFont(int pointSize = 12);
private:
QFont m_uiFont;
diff --git a/app/src/UI/Widgets/Terminal.cpp b/app/src/UI/Widgets/Terminal.cpp
index 75c70c5e..f8a868fe 100644
--- a/app/src/UI/Widgets/Terminal.cpp
+++ b/app/src/UI/Widgets/Terminal.cpp
@@ -322,6 +322,24 @@ void Widgets::Terminal::paint(QPainter *painter)
}
}
+/**
+ * @brief Returns the width of a single terminal character.
+ * @return
+ */
+int Widgets::Terminal::charWidth() const
+{
+ return m_cWidth;
+}
+
+/**
+ * @brief Returns the height of a single terminal character.
+ * @return
+ */
+int Widgets::Terminal::charHeight() const
+{
+ return m_cHeight;
+}
+
/**
* @brief Gets the current font used by the terminal.
*
@@ -637,10 +655,6 @@ void Widgets::Terminal::setFont(const QFont &font)
m_cHeight = metrics.height();
m_cWidth = metrics.averageCharWidth();
- // Special case for Chinese
- if (Misc::Translator::instance().language() == Misc::Translator::Chinese)
- m_cWidth = font.pixelSize();
-
// Update terminal border
m_borderX = qMax(m_cWidth, m_cHeight) / 2;
m_borderY = qMax(m_cWidth, m_cHeight) / 2;
diff --git a/app/src/UI/Widgets/Terminal.h b/app/src/UI/Widgets/Terminal.h
index bde6e97d..21fbd150 100644
--- a/app/src/UI/Widgets/Terminal.h
+++ b/app/src/UI/Widgets/Terminal.h
@@ -49,6 +49,12 @@ class Terminal : public QQuickPaintedItem
READ font
WRITE setFont
NOTIFY fontChanged)
+ Q_PROPERTY(int charWidth
+ READ charWidth
+ NOTIFY fontChanged)
+ Q_PROPERTY(int charHeight
+ READ charHeight
+ NOTIFY fontChanged)
Q_PROPERTY(bool autoscroll
READ autoscroll
WRITE setAutoscroll
@@ -100,6 +106,9 @@ public:
};
Q_ENUM(State);
+ [[nodiscard]] int charWidth() const;
+ [[nodiscard]] int charHeight() const;
+
[[nodiscard]] QFont font() const;
[[nodiscard]] QPalette palette() const;