ollie/kde/gui/SettingsDialog.qml

220 lines
6.2 KiB
QML

// SettingsDialog.qml — Theme and font settings dialog
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
Dialog {
id: root
title: "Settings"
width: 420
modal: false
x: (parent ? (parent.width - width) / 2 : 0)
y: (parent ? (parent.height - height) / 2 : 0)
// Keep the non-modal dialog visually separate from the application behind it.
background: Item {
// A dark offset layer reads as a shadow instead of a bright outline.
Rectangle {
x: 4
y: 6
width: parent.width
height: parent.height
color: Qt.rgba(0, 0, 0, 0.28)
radius: 4
}
Rectangle {
anchors.fill: parent
color: theme.windowColor
border.color: theme.dialogOutlineColor
border.width: 3
radius: 4
Rectangle {
anchors.fill: parent
anchors.margins: 3
color: "transparent"
border.color: theme.lightColor
border.width: 1
radius: 3
}
}
}
header: Rectangle {
implicitHeight: 36
color: theme.buttonColor
Text { anchors.centerIn: parent; text: root.title; color: theme.buttonTextColor }
MouseArea {
anchors.fill: parent
cursorShape: Qt.SizeAllCursor
property point pressPosition
onPressed: pressPosition = Qt.point(mouse.x, mouse.y)
onPositionChanged: if (pressed) {
root.x += mouse.x - pressPosition.x
root.y += mouse.y - pressPosition.y
}
}
}
standardButtons: Dialog.Close
// Never let the dialog participate in keyboard focus navigation.
focus: false
contentItem: ColumnLayout {
spacing: 16
Layout.margins: 16
Label {
text: "Color Scheme"
font.bold: true
}
Label {
text: "Uses KDE Breeze color schemes from /usr/share/color-schemes/"
opacity: 0.6
wrapMode: Text.Wrap
Layout.fillWidth: true
font.pixelSize: Qt.application.font.pixelSize * 0.9
}
ColumnLayout {
spacing: 8
RadioButton {
text: "Use system theme"
checked: theme.mode === "system"
onClicked: theme.mode = "system"
}
RadioButton {
text: "Breeze Light"
checked: theme.mode === "light"
onClicked: theme.mode = "light"
}
RadioButton {
text: "Breeze Dark"
checked: theme.mode === "dark"
onClicked: theme.mode = "dark"
}
}
Label {
text: theme.isDark ? "Current: dark" : "Current: light"
opacity: 0.5
font.pixelSize: Qt.application.font.pixelSize * 0.85
}
CheckBox {
text: "Keep Ollie running in the system tray when closed"
checked: theme.closeToTray
onToggled: theme.closeToTray = checked
Layout.fillWidth: true
}
Rectangle {
Layout.fillWidth: true
height: 1
color: palette.mid
Layout.topMargin: 8
}
Label {
text: "Keyboard Shortcuts"
font.bold: true
}
GridLayout {
columns: 2
columnSpacing: 12
rowSpacing: 8
Layout.fillWidth: true
Label { text: "Approve bypass:" }
TextField {
id: approveKeyField
Layout.fillWidth: true
text: theme.approveBypassKey
placeholderText: "e.g. Ctrl+Y"
onEditingFinished: theme.approveBypassKey = text
}
Label { text: "Deny bypass:" }
TextField {
id: denyKeyField
Layout.fillWidth: true
text: theme.denyBypassKey
placeholderText: "e.g. Ctrl+N"
onEditingFinished: theme.denyBypassKey = text
}
}
Label {
text: "Use Qt key sequence format (e.g. Ctrl+Y, Alt+A, F5)"
opacity: 0.5
font.pixelSize: Qt.application.font.pixelSize * 0.85
wrapMode: Text.Wrap
Layout.fillWidth: true
}
Rectangle {
Layout.fillWidth: true
height: 1
color: palette.mid
Layout.topMargin: 8
}
Label {
text: "Font"
font.bold: true
}
GridLayout {
columns: 2
columnSpacing: 12
rowSpacing: 8
Layout.fillWidth: true
Label { text: "Family:" }
ComboBox {
id: fontFamilyCombo
Layout.fillWidth: true
model: theme.availableFamilies
editable: true
currentIndex: {
let fam = theme.fontFamily || Qt.application.font.family
let idx = model.indexOf(fam)
return idx >= 0 ? idx : 0
}
onActivated: theme.fontFamily = currentText
onAccepted: theme.fontFamily = editText
}
Label { text: "Style:" }
ComboBox {
id: fontStyleCombo
Layout.fillWidth: true
model: theme.availableStyles
currentIndex: {
let st = theme.fontStyle
let idx = model.indexOf(st)
return idx >= 0 ? idx : 0
}
onActivated: theme.fontStyle = currentText
}
Label { text: "Size:" }
SpinBox {
id: fontSizeSpin
from: 6
to: 72
value: theme.fontSize > 0 ? theme.fontSize : Qt.application.font.pointSize
onValueModified: theme.fontSize = value
}
}
Button {
text: "Reset to system font"
onClicked: theme.resetFont()
}
}
}