Warning, /plasma-mobile/qmlkonsole/src/contents/ui/SettingsComponent.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2019-2020 Jonah BrĂ¼chert <jbb@kaidan.im>
0002 // SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
0003 //
0004 // SPDX-License-Identifier: GPL-2.0-or-later
0005
0006 import QtQuick 2.15
0007 import QtQuick.Controls 2.15 as Controls
0008 import QtQuick.Layouts 1.15
0009
0010 import org.kde.kirigami 2.19 as Kirigami
0011 import QMLTermWidget 1.0
0012
0013 import org.kde.qmlkonsole 1.0
0014 import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm
0015
0016 ColumnLayout {
0017 id: root
0018 property QMLTermWidget terminal
0019 property var dialog: null // dialog component if this is within a dialog
0020
0021 spacing: 0
0022
0023 // HACK: dialog switching requires some time between closing and opening
0024 Timer {
0025 id: dialogTimer
0026 interval: 1
0027 property var dialog
0028 onTriggered: {
0029 root.dialog.close();
0030 dialog.open();
0031 }
0032 }
0033
0034 MobileForm.FormCard {
0035 Layout.alignment: Qt.AlignTop
0036 Layout.fillWidth: true
0037
0038 contentItem: ColumnLayout {
0039 spacing: 0
0040
0041 MobileForm.FormCardHeader {
0042 title: i18n("General")
0043 }
0044
0045 MobileForm.FormButtonDelegate {
0046 id: aboutDelegate
0047 text: i18n("About")
0048 onClicked: {
0049 if (root.dialog) {
0050 root.dialog.close();
0051 }
0052 applicationWindow().pageStack.push("qrc:/AboutPage.qml")
0053 }
0054 }
0055 }
0056 }
0057
0058 MobileForm.FormCard {
0059 Layout.alignment: Qt.AlignTop
0060 Layout.topMargin: Kirigami.Units.largeSpacing
0061 Layout.fillWidth: true
0062
0063 contentItem: ColumnLayout {
0064 spacing: 0
0065
0066 MobileForm.FormCardHeader {
0067 title: i18n("Appearance")
0068 }
0069
0070 MobileForm.FormComboBoxDelegate {
0071 id: colorSchemeDropdown
0072 text: i18n("Color scheme")
0073 displayMode: MobileForm.FormComboBoxDelegate.Dialog
0074 Component.onCompleted: currentIndex = indexOfValue(TerminalSettings.colorScheme)
0075 model: terminal.availableColorSchemes
0076
0077 onClicked: {
0078 if (root.dialog && displayMode === MobileForm.FormComboBoxDelegate.Dialog) {
0079 dialogTimer.dialog = colorSchemeDropdown.dialog;
0080 dialogTimer.restart();
0081 }
0082 }
0083
0084 Connections {
0085 target: colorSchemeDropdown.dialog
0086 function onClosed() {
0087 if (root.dialog) {
0088 root.dialog.open();
0089 }
0090 }
0091 }
0092
0093 onCurrentValueChanged: {
0094 TerminalSettings.colorScheme = currentValue;
0095 TerminalSettings.save();
0096 }
0097 }
0098
0099 MobileForm.FormDelegateSeparator { above: colorSchemeDropdown; below: fontFamilyDelegate }
0100
0101 MobileForm.AbstractFormDelegate {
0102 id: fontFamilyDelegate
0103 Layout.fillWidth: true
0104 text: i18n("Font Family")
0105
0106 onClicked: {
0107 if (fontFamilyPickerLoader.active) {
0108 fontFamilyPickerLoader.item.open();
0109 } else {
0110 fontFamilyPickerLoader.active = true;
0111 fontFamilyPickerLoader.requestOpen = true;
0112 }
0113 }
0114
0115 contentItem: RowLayout {
0116 Controls.Label {
0117 Layout.fillWidth: true
0118 text: i18n("Font Family")
0119 elide: Text.ElideRight
0120 }
0121
0122 Controls.Label {
0123 Layout.alignment: Qt.AlignRight
0124 Layout.rightMargin: Kirigami.Units.smallSpacing
0125 color: Kirigami.Theme.disabledTextColor
0126 text: TerminalSettings.fontFamily
0127 font.family: TerminalSettings.fontFamily
0128 }
0129
0130 MobileForm.FormArrow {
0131 Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
0132 direction: MobileForm.FormArrow.Down
0133 }
0134 }
0135
0136 Loader {
0137 id: fontFamilyPickerLoader
0138 active: false
0139 asynchronous: true
0140
0141 property bool requestOpen: false
0142 onLoaded: {
0143 if (requestOpen) {
0144 item.open();
0145 requestOpen = false;
0146 }
0147 }
0148
0149 sourceComponent: Kirigami.Dialog {
0150 id: fontFamilyPicker
0151 title: i18nc("@title:window", "Pick font")
0152
0153 onClosed: {
0154 if (root.dialog) {
0155 root.dialog.open();
0156 }
0157 }
0158
0159 onOpened: {
0160 if (root.dialog) {
0161 root.dialog.close();
0162 }
0163 }
0164
0165 ListView {
0166 implicitWidth: Kirigami.Units.gridUnit * 18
0167 implicitHeight: Kirigami.Units.gridUnit * 24
0168
0169 reuseItems: true
0170 model: FontListSearchModel
0171 currentIndex: -1
0172 clip: true
0173
0174 header: Controls.Control {
0175 topPadding: Kirigami.Units.smallSpacing
0176 bottomPadding: Kirigami.Units.smallSpacing
0177 rightPadding: Kirigami.Units.smallSpacing
0178 leftPadding: Kirigami.Units.smallSpacing
0179 width: fontFamilyPicker.width
0180
0181 contentItem: Kirigami.SearchField {
0182 id: searchField
0183 onTextChanged: {
0184 FontListSearchModel.setFilterFixedString(text)
0185 searchField.forceActiveFocus()
0186 }
0187 }
0188 }
0189
0190 delegate: Kirigami.BasicListItem {
0191 text: model.name
0192 onClicked: {
0193 TerminalSettings.fontFamily = model.name;
0194 TerminalSettings.save();
0195 fontFamilyPicker.close();
0196 }
0197 }
0198 }
0199 }
0200 }
0201 }
0202
0203 MobileForm.FormDelegateSeparator { above: fontFamilyDelegate }
0204
0205 MobileForm.AbstractFormDelegate {
0206 id: fontSizeDelegate
0207 Layout.fillWidth: true
0208 background: Item {}
0209
0210 contentItem: RowLayout {
0211 width: fontSizeDelegate.width
0212 Controls.Label {
0213 Layout.fillWidth: true
0214 text: i18n("Font Size")
0215 }
0216
0217 Controls.SpinBox {
0218 value: TerminalSettings.fontSize
0219 onValueChanged: {
0220 TerminalSettings.fontSize = value;
0221 TerminalSettings.save();
0222 }
0223 from: 5
0224 to: 100
0225 }
0226 }
0227 }
0228
0229 MobileForm.FormDelegateSeparator {}
0230
0231 MobileForm.AbstractFormDelegate {
0232 id: opacityDelegate
0233 Layout.fillWidth: true
0234
0235 background: Item {}
0236
0237 contentItem: ColumnLayout {
0238 Controls.Label {
0239 text: i18n("Window Transparency")
0240 }
0241
0242 RowLayout {
0243 spacing: Kirigami.Units.gridUnit
0244 Kirigami.Icon {
0245 implicitWidth: Kirigami.Units.iconSizes.smallMedium
0246 implicitHeight: Kirigami.Units.iconSizes.smallMedium
0247 source: "brightness-low"
0248 }
0249
0250 Controls.Slider {
0251 Layout.fillWidth: true
0252 from: 0
0253 to: 100
0254 value: (1 - TerminalSettings.windowOpacity) * 100
0255 stepSize: 5
0256 snapMode: Controls.Slider.SnapAlways
0257
0258 onMoved: {
0259 TerminalSettings.windowOpacity = 1 - (value / 100);
0260 TerminalSettings.save();
0261 }
0262 }
0263
0264 Kirigami.Icon {
0265 implicitWidth: Kirigami.Units.iconSizes.smallMedium
0266 implicitHeight: Kirigami.Units.iconSizes.smallMedium
0267 source: "brightness-high"
0268 }
0269 }
0270 }
0271 }
0272
0273 MobileForm.FormDelegateSeparator { below: blurDelegate }
0274
0275 MobileForm.FormSwitchDelegate {
0276 id: blurDelegate
0277 text: i18n("Blur Background")
0278 checked: TerminalSettings.blurWindow
0279
0280 onCheckedChanged: {
0281 TerminalSettings.blurWindow = checked;
0282 TerminalSettings.save();
0283 Util.setBlur(applicationWindow().pageStack, TerminalSettings.blurWindow);
0284 }
0285 }
0286 }
0287 }
0288
0289 Item { Layout.fillHeight: true }
0290 }