Warning, /plasma/aura-browser/app/qml/SettingsTab.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2022 Aditya Mehra <aix.m@outlook.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 import QtQuick 2.12
0008 import QtQuick.Window 2.12
0009 import QtWebEngine 1.7
0010 import QtQuick.Layouts 1.12
0011 import QtQuick.Controls 2.12 as Controls
0012 import QtQml.Models 2.12
0013 import QtQuick.LocalStorage 2.12
0014 import QtQuick.VirtualKeyboard 2.4
0015 import Aura 1.0 as Aura
0016 import Qt5Compat.GraphicalEffects
0017 import org.kde.kirigami as Kirigami
0018 
0019 Controls.Popup {
0020     id: settingsPopupArea
0021     width: parent.width / 2
0022     height: settingContents.implicitHeight + headerAreaSettingsPage.implicitHeight + Kirigami.Units.gridUnit * 5 //parent.height / 2
0023     x: (parent.width - width) / 2
0024     y: (parent.height - height) / 2
0025     padding: Kirigami.Units.largeSpacing
0026     dim: true
0027 
0028     Controls.Overlay.modeless: Rectangle {
0029         color: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.77)
0030     }
0031 
0032     background: Rectangle {
0033         Kirigami.Theme.colorSet: Kirigami.Theme.View
0034         color: Kirigami.Theme.backgroundColor
0035         border.color: "black"
0036     }
0037 
0038     onOpened: {
0039         virtualMouseMoveSpeedSlider.forceActiveFocus()
0040     }
0041 
0042     function playKeySounds(event){
0043         switch (event.key) {
0044             case Qt.Key_Down:
0045             case Qt.Key_Right:
0046             case Qt.Key_Left:
0047             case Qt.Key_Up:
0048             case Qt.Key_Tab:
0049             case Qt.Key_Backtab:
0050                 Aura.NavigationSoundEffects.playMovingSound();
0051                 break;
0052             default:
0053                 break;
0054         }
0055     }
0056 
0057     Connections {
0058         target: Aura.GlobalSettings
0059         function onVirtualMouseSpeedChanged() {
0060             Cursor.setStep(virtualMouseSpeed);
0061         }
0062     }
0063 
0064     Item {
0065         anchors.fill: parent
0066 
0067         RowLayout {
0068             id: headerAreaSettingsPage
0069             anchors.top: parent.top
0070             anchors.left: parent.left
0071             anchors.right: parent.right
0072 
0073             Kirigami.Heading {
0074                 id: settingsTabHeading
0075                 level: 1
0076                 text: "Settings"
0077                 color: Kirigami.Theme.textColor
0078                 width: parent.width
0079                 horizontalAlignment: Qt.AlignLeft
0080                 Layout.alignment: Qt.AlignLeft
0081             }
0082 
0083             Controls.Label {
0084                 id: backbtnlabelHeading
0085                 text: i18n("Press 'esc' or the [←] Back button to close")
0086                 color: Kirigami.Theme.textColor
0087                 Layout.alignment: Qt.AlignRight
0088             }
0089         }
0090 
0091         Kirigami.Separator {
0092             id: headerSeparator
0093             anchors.top: headerAreaSettingsPage.bottom
0094             width: parent.width
0095             height: 1
0096         }
0097 
0098         ColumnLayout {
0099             id: settingContents
0100             anchors.centerIn: parent
0101 
0102             Kirigami.Heading {
0103                 id: virtualMouseSpeedSettingLabel
0104                 level: 2
0105                 text: i18n("Virtual Cursor Speed Control")
0106                 Layout.alignment: Qt.AlignLeft | Qt.AlignTop
0107                 color: virtualMouseMoveSpeedSlider.activeFocus ? Kirigami.Theme.linkColor : Kirigami.Theme.textColor
0108             }
0109 
0110             Kirigami.Separator {
0111                 Layout.fillWidth: true
0112                 Layout.preferredHeight: 1
0113             }
0114 
0115             Controls.Slider {
0116                 id: virtualMouseMoveSpeedSlider
0117                 Layout.fillWidth:  true
0118                 snapMode: Controls.Slider.SnapAlways
0119                 stepSize: 5
0120                 from: 5
0121                 to: 100
0122                 value: Aura.GlobalSettings.virtualMouseSpeed
0123                 Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
0124                 Layout.alignment: Qt.AlignTop
0125                 KeyNavigation.down: virtualScrollMoveSpeedSlider
0126 
0127                 background: Rectangle {
0128                     x: virtualMouseMoveSpeedSlider.leftPadding
0129                     y: virtualMouseMoveSpeedSlider.topPadding + virtualMouseMoveSpeedSlider.availableHeight / 2 - height / 2
0130                     implicitWidth: width
0131                     width: virtualMouseMoveSpeedSlider.availableWidth
0132                     height: Kirigami.Units.smallSpacing
0133                     radius: 2
0134                     color: virtualMouseMoveSpeedSlider.activeFocus ? Kirigami.Theme.disabledTextColor : Kirigami.Theme.textColor
0135 
0136                     Rectangle {
0137                         width: virtualMouseMoveSpeedSlider.visualPosition * parent.width
0138                         height: parent.height
0139                         color: Kirigami.Theme.linkColor
0140                         radius: 2
0141                     }
0142                 }
0143 
0144                 onValueChanged: {
0145                     Aura.GlobalSettings.setVirtualMouseSpeed(value);
0146                 }
0147 
0148                 Keys.onPressed: (event)=> {
0149                     playKeySounds(event)
0150                 }
0151             }
0152 
0153             Kirigami.Heading {
0154                 id: currentVirtualMouseSpeedLabel
0155                 level: 3
0156                 text: i18n("Current Speed: %1", virtualMouseMoveSpeedSlider.value)
0157                 Layout.alignment: Qt.AlignLeft | Qt.AlignTop
0158                 color: Kirigami.Theme.textColor
0159             }
0160 
0161             Item {
0162                 Layout.preferredHeight: Kirigami.Units.gridUnit
0163                 Layout.fillWidth: true
0164             }
0165 
0166             Kirigami.Separator {
0167                 Layout.fillWidth: true
0168                 Layout.preferredHeight: 1
0169             }
0170 
0171             Kirigami.Heading {
0172                 id: virtualScrollSpeedSettingLabel
0173                 level: 2
0174                 text: i18n("Virtual Scroll Speed Control")
0175                 Layout.alignment: Qt.AlignLeft | Qt.AlignTop
0176                 color: virtualScrollMoveSpeedSlider.activeFocus ? Kirigami.Theme.linkColor : Kirigami.Theme.textColor
0177             }
0178 
0179             Kirigami.Separator {
0180                 Layout.fillWidth: true
0181                 Layout.preferredHeight: 1
0182             }
0183 
0184             Controls.Slider {
0185                 id: virtualScrollMoveSpeedSlider
0186                 Layout.fillWidth:  true
0187                 snapMode: Controls.Slider.SnapAlways
0188                 stepSize: 5
0189                 from: 5
0190                 to: 100
0191                 value: Aura.GlobalSettings.virtualScrollSpeed
0192                 Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
0193                 Layout.alignment: Qt.AlignTop
0194                 KeyNavigation.up: virtualMouseMoveSpeedSlider
0195                 KeyNavigation.down: virtualCursorSizeSlider
0196 
0197                 background: Rectangle {
0198                     x: virtualScrollMoveSpeedSlider.leftPadding
0199                     y: virtualScrollMoveSpeedSlider.topPadding + virtualScrollMoveSpeedSlider.availableHeight / 2 - height / 2
0200                     implicitWidth: width
0201                     width: virtualScrollMoveSpeedSlider.availableWidth
0202                     height: Kirigami.Units.smallSpacing
0203                     radius: 2
0204                     color: virtualScrollMoveSpeedSlider.activeFocus ? Kirigami.Theme.disabledTextColor : Kirigami.Theme.textColor
0205 
0206                     Rectangle {
0207                         width: virtualScrollMoveSpeedSlider.visualPosition * parent.width
0208                         height: parent.height
0209                         color: Kirigami.Theme.linkColor
0210                         radius: 2
0211                     }
0212                 }
0213 
0214                 onValueChanged: {
0215                     Aura.GlobalSettings.setVirtualScrollSpeed(value);
0216                 }
0217 
0218                 Keys.onPressed: (event)=> {
0219                     playKeySounds(event)
0220                 }
0221             }
0222 
0223             Kirigami.Heading {
0224                 id: currentVirtualScrollSpeedLabel
0225                 level: 3
0226                 text: i18n("Current Speed: %1", virtualScrollMoveSpeedSlider.value)
0227                 Layout.alignment: Qt.AlignLeft | Qt.AlignTop
0228                 color: Kirigami.Theme.textColor
0229             }
0230 
0231             Item {
0232                 Layout.preferredHeight: Kirigami.Units.gridUnit
0233                 Layout.fillWidth: true
0234             }
0235 
0236             Kirigami.Separator {
0237                 Layout.fillWidth: true
0238                 Layout.preferredHeight: 1
0239             }
0240 
0241             Kirigami.Heading {
0242                 id: virtualCursorSizeSettingLabel
0243                 level: 2
0244                 text: i18n("Virtual Cursor Size Control")
0245                 Layout.alignment: Qt.AlignLeft | Qt.AlignTop
0246                 color: virtualCursorSizeSlider.activeFocus ? Kirigami.Theme.linkColor : Kirigami.Theme.textColor
0247             }
0248 
0249             Kirigami.Separator {
0250                 Layout.fillWidth: true
0251                 Layout.preferredHeight: 1
0252             }
0253 
0254             Controls.Slider {
0255                 id: virtualCursorSizeSlider
0256                 Layout.fillWidth:  true
0257                 snapMode: Controls.Slider.SnapAlways
0258                 stepSize: 0.1
0259                 from: 0.8
0260                 to: 1
0261                 value: Aura.GlobalSettings.virtualMouseSize
0262                 Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
0263                 Layout.alignment: Qt.AlignTop
0264                 KeyNavigation.up: virtualScrollMoveSpeedSlider
0265                 KeyNavigation.down: defSearchBtn1
0266 
0267                 background: Rectangle {
0268                     x: virtualCursorSizeSlider.leftPadding
0269                     y: virtualCursorSizeSlider.topPadding + virtualCursorSizeSlider.availableHeight / 2 - height / 2
0270                     implicitWidth: width
0271                     width: virtualCursorSizeSlider.availableWidth
0272                     height: Kirigami.Units.smallSpacing
0273                     radius: 2
0274                     color: virtualCursorSizeSlider.activeFocus ? Kirigami.Theme.disabledTextColor : Kirigami.Theme.textColor
0275 
0276                     Rectangle {
0277                         width: virtualCursorSizeSlider.visualPosition * parent.width
0278                         height: parent.height
0279                         color: Kirigami.Theme.linkColor
0280                         radius: 2
0281                     }
0282                 }
0283 
0284                 onValueChanged: {
0285                     Aura.GlobalSettings.setVirtualMouseSize(value);
0286                 }
0287 
0288                 Keys.onPressed: (event)=> {
0289                     playKeySounds(event)
0290                 }
0291             }
0292 
0293             Kirigami.Heading {
0294                 id: currentVirtualCursorSizeLabel
0295                 level: 3
0296                 text: i18n("Current Size: ") + Aura.GlobalSettings.virtualMouseSize == 1 ? i18n("Large") : (Aura.GlobalSettings.virtualMouseSize == 0.9 ? i18n("Medium") : (Aura.GlobalSettings.virtualMouseSize == 0.8 ? i18n("Small"): i18n("Large"))) 
0297                 Layout.alignment: Qt.AlignLeft | Qt.AlignTop
0298                 color: Kirigami.Theme.textColor
0299             }
0300 
0301             Item {
0302                 Layout.preferredHeight: Kirigami.Units.gridUnit
0303                 Layout.fillWidth: true
0304             }
0305 
0306             Kirigami.Separator {
0307                 Layout.fillWidth: true
0308                 Layout.preferredHeight: 1
0309             }
0310 
0311             Kirigami.Heading {
0312                 id: defSearchSettingLabel
0313                 level: 2
0314                 text: i18n("Search Engine")
0315                 Layout.alignment: Qt.AlignLeft | Qt.AlignTop
0316                 color: defSearchBtn1.activeFocus || defSearchBtn2.activeFocus ? Kirigami.Theme.linkColor : Kirigami.Theme.textColor
0317             }
0318 
0319             Kirigami.Separator {
0320                 Layout.fillWidth: true
0321                 Layout.preferredHeight: 1
0322             }
0323 
0324             RowLayout {
0325                 Layout.fillWidth: true
0326                 Layout.preferredHeight: Kirigami.Units.gridUnit * 2
0327 
0328                 Controls.Button {
0329                     id: defSearchBtn1
0330                     Layout.fillWidth: true
0331                     Layout.preferredHeight: Kirigami.Units.gridUnit * 2
0332                     Layout.alignment: Qt.AlignLeft
0333                     text: i18n("Google")
0334                     KeyNavigation.up: virtualCursorSizeSlider
0335                     KeyNavigation.down: soundEffectsButton
0336                     KeyNavigation.right: defSearchBtn2
0337                     palette.buttonText: Kirigami.Theme.textColor
0338 
0339                     background: Rectangle {
0340                         color: defSearchBtn1.activeFocus ? Kirigami.Theme.highlightColor : Kirigami.Theme.disabledTextColor
0341                         border.color: Aura.GlobalSettings.defaultSearchEngine == "Google" ? Kirigami.Theme.highlightColor : Kirigami.Theme.disabledTextColor
0342                         border.width: Aura.GlobalSettings.defaultSearchEngine == "Google" ? 4 : 1
0343                         radius: 2
0344                     }
0345 
0346                     Keys.onReturnPressed: (event)=> {
0347                         Aura.GlobalSettings.setDefaultSearchEngine("Google")
0348                     }
0349 
0350                     onClicked: (mouse)=> {
0351                         Aura.GlobalSettings.setDefaultSearchEngine("Google")
0352                     }
0353                 }
0354 
0355                 Controls.Button {
0356                     id: defSearchBtn2
0357                     Layout.fillWidth: true
0358                     Layout.preferredHeight: Kirigami.Units.gridUnit * 2
0359                     Layout.alignment: Qt.AlignLeft
0360                     text: i18n("Duck Duck Go")
0361                     KeyNavigation.up: virtualCursorSizeSlider
0362                     KeyNavigation.down: soundEffectsButton
0363                     KeyNavigation.left: defSearchBtn1
0364                     palette.buttonText: Kirigami.Theme.textColor
0365 
0366                     background: Rectangle {
0367                         color: defSearchBtn2.activeFocus ? Kirigami.Theme.highlightColor : Kirigami.Theme.disabledTextColor
0368                         border.color: Aura.GlobalSettings.defaultSearchEngine == "DDG" ? Kirigami.Theme.highlightColor : Kirigami.Theme.disabledTextColor
0369                         border.width: Aura.GlobalSettings.defaultSearchEngine == "DDG" ? 4 : 1
0370                         radius: 2
0371                     }
0372 
0373                     Keys.onReturnPressed: (event)=> {
0374                         Aura.GlobalSettings.setDefaultSearchEngine("DDG")
0375                     }
0376 
0377                     onClicked: (mouse)=> {
0378                         Aura.GlobalSettings.setDefaultSearchEngine("DDG")
0379                     }
0380                 }
0381             }
0382 
0383             Kirigami.Separator {
0384                 Layout.fillWidth: true
0385                 Layout.preferredHeight: 1
0386             }
0387 
0388             Kirigami.Heading {
0389                 id: miscSettingLabel
0390                 level: 2
0391                 text: i18n("General")
0392                 Layout.alignment: Qt.AlignLeft | Qt.AlignTop
0393                 color: soundEffectsButton.activeFocus || clearCacheButton.activeFocus ? Kirigami.Theme.linkColor : Kirigami.Theme.textColor
0394             }
0395 
0396             Kirigami.Separator {
0397                 Layout.fillWidth: true
0398                 Layout.preferredHeight: 1
0399             }
0400 
0401             Controls.Button {
0402                 id: soundEffectsButton
0403                 Layout.fillWidth: true
0404                 Layout.preferredHeight: Kirigami.Units.gridUnit * 2
0405                 Layout.alignment: Qt.AlignLeft
0406                 text: i18n("Disable Button Sounds")
0407                 KeyNavigation.up: defSearchBtn1
0408                 KeyNavigation.down: clearCacheButton
0409                 palette.buttonText: Kirigami.Theme.textColor
0410 
0411                 background: Rectangle {
0412                     color: soundEffectsButton.activeFocus ? Kirigami.Theme.highlightColor : Kirigami.Theme.disabledTextColor
0413                     border.color: Kirigami.Theme.disabledTextColor
0414                     radius: 2
0415                 }
0416 
0417                 onClicked: (mouse)=> {
0418                     Aura.NavigationSoundEffects.playClickedSound();
0419                     if(Aura.GlobalSettings.soundEffects){
0420                         Aura.GlobalSettings.setSoundEffects(false);
0421                         text = i18n("Enable Button Sounds")
0422                     } else {
0423                         Aura.GlobalSettings.setSoundEffects(true);
0424                         text = i18n("Disable Button Sounds")
0425                     }
0426                 }
0427 
0428                 Keys.onReturnPressed: (event)=> {
0429                     Aura.NavigationSoundEffects.playClickedSound();
0430                     if(Aura.GlobalSettings.soundEffects){
0431                         Aura.GlobalSettings.setSoundEffects(false);
0432                         text = i18n("Enable Button Sounds")
0433                     } else {
0434                         Aura.GlobalSettings.setSoundEffects(true);
0435                         text = i18n("Disable Button Sounds")
0436                     }
0437                 }
0438 
0439                 Keys.onPressed: (event)=> {
0440                     playKeySounds(event)
0441                 }
0442             }
0443 
0444             Controls.Button {
0445                 id: clearCacheButton
0446                 Layout.fillWidth: true
0447                 Layout.preferredHeight: Kirigami.Units.gridUnit * 2
0448                 Layout.alignment: Qt.AlignLeft
0449                 text: i18n("Clear Cache")
0450                 KeyNavigation.up: soundEffectsButton
0451                 palette.buttonText: Kirigami.Theme.textColor
0452 
0453                 background: Rectangle {
0454                     color: clearCacheButton.activeFocus ? Kirigami.Theme.highlightColor : Kirigami.Theme.disabledTextColor
0455                     border.color: Kirigami.Theme.disabledTextColor
0456                     radius: 2
0457                 }
0458 
0459                 onClicked: (mouse)=> {
0460                     Aura.NavigationSoundEffects.playClickedSound();
0461                     Aura.GlobalSettings.clearDefaultProfileCache();
0462                 }
0463 
0464                 Keys.onReturnPressed: (event)=> {
0465                     Aura.NavigationSoundEffects.playClickedSound();
0466                     Aura.GlobalSettings.clearDefaultProfileCache();
0467                 }
0468 
0469                 Keys.onPressed: (event)=> {
0470                     playKeySounds(event)
0471                 }
0472             }
0473         }
0474     }
0475 }