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