diff --git a/src/app/app.cpp b/src/app/app.cpp index 97109412..21f4586e 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -68,8 +69,21 @@ void Application::initAppInfo() void Application::initAppFonts() { - QFontDatabase::addApplicationFont("://fonts/OpenSans-Regular.ttc"); - QFont defaultFont("OpenSans", 11); + QSettings settings; + QString appFont = settings.value("app/appFont", "Open Sans").toString(); + int appFontSize = settings.value("app/appFontSize", 11).toInt(); + + if (appFont == "Open Sans") { + int result = QFontDatabase::addApplicationFont("://fonts/OpenSans.ttc"); + +#ifdef Q_OS_LINUX + if (result == -1) { + appFont = "Ubuntu"; + } +#endif + } + qDebug() << "App font:" << appFont << appFontSize; + QFont defaultFont(appFont, appFontSize); QApplication::setFont(defaultFont); } diff --git a/src/qml/GlobalSettings.qml b/src/qml/GlobalSettings.qml index ed03ebed..259e545c 100644 --- a/src/qml/GlobalSettings.qml +++ b/src/qml/GlobalSettings.qml @@ -10,16 +10,6 @@ Dialog { id: root title: "Settings" - Settings { - id: globalSettings - category: "app" - - property alias reopenNamespacesOnReload: nsReload.value - property alias enableKeySortingInTree: keySorting.value - property alias liveUpdateKeysLimit: liveKeyLimit.value - property alias liveUpdateInterval: liveUpdateInterval.value - } - contentItem: Item { implicitWidth: 800 implicitHeight: 600 @@ -29,7 +19,36 @@ Dialog { anchors.margins: 20 Text { - text: "Connections Tree Settings" + text: "Appearance" + font.pixelSize: 20 + } + + ComboboxOption { + id: appFont + + Layout.fillWidth: true + Layout.preferredHeight: 40 + + value: "Open Sans" + model: Qt.fontFamilies() + label: "Font" + description: "" + } + + ComboboxOption { + id: appFontSize + + Layout.fillWidth: true + Layout.preferredHeight: 40 + + model: ["8", "9", "10", "11", "12"] + value: "10" + label: "Font Size" + description: "in pixels" + } + + Text { + text: "Connections Tree" font.pixelSize: 20 } @@ -96,4 +115,16 @@ Dialog { } } } + + Settings { + id: globalSettings + category: "app" + + property alias reopenNamespacesOnReload: nsReload.value + property alias enableKeySortingInTree: keySorting.value + property alias liveUpdateKeysLimit: liveKeyLimit.value + property alias liveUpdateInterval: liveUpdateInterval.value + property alias appFont: appFont.value + property alias appFontSize: appFontSize.value + } } diff --git a/src/qml/qml.qrc b/src/qml/qml.qrc index 85f8035e..ae1f8282 100644 --- a/src/qml/qml.qrc +++ b/src/qml/qml.qrc @@ -30,7 +30,7 @@ value-editor/editors/editor.js 3rdparty/php-unserialize-js/phpUnserialize.js console/QConsole.qml - console/BaseConsole.qml + console/BaseConsole.qml console/Consoles.qml connections-tree/BetterTreeView.qml AppToolBar.qml @@ -41,5 +41,6 @@ settings/IntOption.qml bulk-operations/BulkOperationsDialog.qml value-editor/editors/formatters/json-tools.js + settings/ComboboxOption.qml diff --git a/src/qml/settings/ComboboxOption.qml b/src/qml/settings/ComboboxOption.qml new file mode 100644 index 00000000..8e16d136 --- /dev/null +++ b/src/qml/settings/ComboboxOption.qml @@ -0,0 +1,54 @@ +import QtQuick 2.3 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 1.2 + +Item { + id: root + property string label + property string description + property string value + property alias model: val.model + + onValueChanged: { + if (val.currentText != root.value) { + val.currentIndex = val.find(root.value) + } + } + + RowLayout { + anchors.fill: parent + + ColumnLayout { + Layout.fillWidth: true + spacing: 1 + + Label { + Layout.fillWidth: true + text: root.label + } + + Text { + color: "#cccccc" + text: root.description + } + } + + ComboBox { + id: val + + Layout.minimumWidth: 80 + + onActivated: { + if (index >= 0) + root.value = textAt(index) + } + + onCountChanged: { + if (model) { + currentIndex = val.find(root.value) + } + } + } + } +} +