Skip to content

Commit

Permalink
rehaul settings dialog
Browse files Browse the repository at this point in the history
Signed-off-by: swurl <[email protected]>
  • Loading branch information
crueter committed Dec 24, 2024
1 parent 8e79492 commit b0810ab
Show file tree
Hide file tree
Showing 35 changed files with 765 additions and 1,270 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ jobs:

- os: ubuntu-20.04
qt_host: linux
qt_version: '6.8.0'
qt_version: '6.8.1'
qt_modules: 'qtmultimedia qtcharts qtwaylandcompositor'
qt_arch: 'linux_gcc_64'

- os: windows-2022
qt_host: windows
qt_version: '6.8.0'
qt_version: '6.8.1'
qt_modules: 'qtmultimedia qtcharts'
qt_arch: 'win64_msvc2022_64'

- os: macos-latest
qt_host: mac
qt_version: '6.7.2'
qt_version: '6.8.1'
qt_modules: 'qtmultimedia qtcharts'
qt_arch: 'clang_64'

Expand Down
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,14 @@ set(QML_ELEMENTS
dialogs/TopicView
dialogs/TabNameDialog
dialogs/TabSizeDialog
dialogs/WidgetConfig
dialogs/ServerDialog

dialogs/ServerTab
dialogs/MiscTab
dialogs/AppearanceTab
dialogs/SettingsDialog
dialogs/SettingsTabButton
dialogs/AppearanceComboBox

dialogs/AccentEditor
)

Expand Down
87 changes: 14 additions & 73 deletions Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,81 +10,18 @@ ApplicationWindow {
visible: true
title: titleManager.title

menuBar: MenuBar {
contentWidth: parent.width

Menu {
contentWidth: 210
title: qsTr("&Settings")
Action {
text: qsTr("&Server Settings...")
onTriggered: screen.serverSettings()
shortcut: "Ctrl+E"
}
MenuItem {
text: "&Load Most Recent File?"
checkable: true
checked: settings.loadRecent
onCheckedChanged: settings.loadRecent = checked
}

Menu {
title: qsTr("&Theme")
Repeater {
model: ["Light", "Dark", "Midnight"]

MenuItem {
text: "&" + modelData
checkable: true
checked: settings.theme === modelData.toLowerCase()
onCheckedChanged: {
if (checked)
Constants.setTheme(modelData.toLowerCase())
}
}
}
}

Menu {
title: qsTr("&Accent")
AccentEditor {
id: accentEditor

Repeater {
model: accents

MenuItem {
function toTitleCase(str) {
return str.replace(
/\w\S*/g,
text => text.charAt(0).toUpperCase() + text.substring(1).toLowerCase()
);
}
anchors.centerIn: Overlay.overlay
}

text: "&" + toTitleCase(model.name)
checkable: true
checked: settings.accent === model.name
onCheckedChanged: {
if (checked)
Constants.setAccent(model.name)
}
}
}
}
menuBar: MenuBar {
contentWidth: parent.width

Menu {
title: qsTr("&Custom Accents")
MenuItem {
text: "&Edit Accents..."
onTriggered: screen.editAccents()
}
MenuItem {
text: "Export Accents..."
onTriggered: screen.exportAccentsAction()
}
MenuItem {
text: "Import Accents..."
onTriggered: screen.importAccentsAction()
}
}
MenuBarItem {
text: qsTr("&Settings")
onTriggered: screen.settingsDialog()
}

Menu {
Expand Down Expand Up @@ -112,7 +49,11 @@ ApplicationWindow {

delegate: MenuItem {
text: qsTr("&" + index + ". " + modelData)
onTriggered: tlm.load(modelData)
onTriggered: {
if (modelData === "" || modelData === null) return;
tlm.clear()
tlm.load(modelData)
}
}
}
}
Expand Down
67 changes: 67 additions & 0 deletions dialogs/AppearanceComboBox.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Shapes 2.15

import QFRCDashboard

ComboBox {
required property string label

/** what property to bind to */
required property string bindedProperty

/** the target to bind the property to */
required property var bindTarget

required property var choices

id: combo
model: choices
font.pixelSize: 15

function toTitleCase(str) {
return str.replace(
/\w\S*/g,
text => text.charAt(0).toUpperCase() + text.substring(1).toLowerCase()
);
}

function open() {
currentIndex = indexOfValue(toTitleCase(bindTarget[bindedProperty]))
}

function accept() {
bindTarget[bindedProperty] = currentText.toLowerCase()
}

delegate: ItemDelegate {
id: delegate

width: combo.width
contentItem: Text {
text: modelData
color: "white"
font.pixelSize: 15
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
}
highlighted: combo.highlightedIndex === index
}

Text {
id: floatingLabel
text: label
color: Constants.palette.text

font.pixelSize: 15

anchors {
left: parent.left
bottom: parent.top

bottomMargin: -2
leftMargin: 10
}
}
}
110 changes: 110 additions & 0 deletions dialogs/AppearanceTab.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import QtCore
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 6.6
import QtQuick.Dialogs

import QFRCDashboard

ColumnLayout {
spacing: 5

function editAccents() {
accentEditor.open()
}

FileDialog {
id: saveAccentDialog
currentFolder: StandardPaths.writableLocation(
StandardPaths.HomeLocation)
fileMode: FileDialog.SaveFile
defaultSuffix: "json"
selectedNameFilter.index: 0
nameFilters: ["JSON files (*.json)", "All files (*)"]

onAccepted: accents.exportJson(selectedFile)
}

function exportAccents() {
saveAccentDialog.open()
}

FileDialog {
id: loadAccentDialog
currentFolder: StandardPaths.writableLocation(
StandardPaths.HomeLocation)
fileMode: FileDialog.OpenFile
defaultSuffix: "json"
selectedNameFilter.index: 0
nameFilters: ["JSON files (*.json)", "All files (*)"]

onAccepted: accents.importJson(loadAccentDialog.selectedFile)
}

function importAccents() {
loadAccentDialog.open()
}

function accept() {
theme.accept()
accent.accept()

Constants.setTheme(settings.theme)
Constants.setAccent(settings.accent)
}

function open() {
theme.open()
accent.open()
}

RowLayout {
Layout.fillWidth: true

AppearanceComboBox {
implicitWidth: 200
id: theme

label: "Theme"

bindedProperty: "theme"
bindTarget: settings

choices: ["Light", "Dark", "Midnight"]
}

AppearanceComboBox {
implicitWidth: 200
id: accent

label: "Accent"

bindedProperty: "accent"
bindTarget: settings

choices: accents.names()
}
}

SectionHeader {
label: "Custom Accents"
}

RowLayout {
uniformCellSizes: true
Layout.fillWidth: true

Button {
text: "&Edit"
onClicked: editAccents()
}
Button {
text: "E&xport"
onClicked: exportAccents()
}
Button {
text: "I&mport"
onClicked: importAccents()
}
}
}
26 changes: 26 additions & 0 deletions dialogs/MiscTab.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 6.6
import QtQuick.Dialogs

import QFRCDashboard

ColumnLayout {
spacing: 5

function accept() {
load.accept()
}

function open() {
load.open()
}

LabeledCheckbox {
id: load
label: "Load Recent Files?"

bindTarget: settings
bindedProperty: "loadRecent"
}
}
Loading

0 comments on commit b0810ab

Please sign in to comment.