Warning, /office/klevernotes/src/contents/ui/pages/SettingsPage.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 // SPDX-FileCopyrightText: 2023 Louis Schul <schul9louis@gmail.com>
0003 
0004 import QtQuick 2.15
0005 import QtQuick.Layouts 1.3
0006 
0007 import org.kde.kirigami 2.19 as Kirigami
0008 import org.kde.kirigamiaddons.formcard 1.0 as FormCard
0009 
0010 import org.kde.Klever 1.0
0011 
0012 import "qrc:/contents/ui/settings"
0013 import "qrc:/contents/ui/dialogs"
0014 import "qrc:/contents/ui/dialogs/colorDialog"
0015 
0016 FormCard.FormCardPage {
0017     id: settingsPage
0018 
0019     title: i18nc("@title:window", "Settings")
0020 
0021     data: [
0022         StorageDialog {
0023             id: storageDialog
0024 
0025             subtitle: i18n("Please choose a location for your future KleverNotes storage or select an existing one.\n")
0026             firstSetup: false
0027 
0028             onClosed: {
0029                 storageField.text = Config.storagePath
0030             }
0031         },
0032         NamingDialog {
0033             id: namingDialog
0034 
0035             useCase: ""
0036             parentPath: ""
0037             newItem: false
0038         },
0039         ColorDialog {
0040             id: colorPicker
0041 
0042             property var caller
0043 
0044             onCallerChanged: if (caller) {
0045                 selectedColor = caller.color
0046             }
0047             onApplied: {
0048                 if (selectedColor != caller.color) updateColor(caller, selectedColor)
0049                 colorPicker.close()
0050             }
0051             onClosed: {
0052                 caller = undefined
0053             }
0054         },
0055         FontPickerDialog{
0056             id: fontDialog
0057 
0058             onApplied: {
0059                 caller.newFont = Qt.font({"family": checkedFamily, "pointSize": checkedSize})
0060                 fontDialog.close()
0061             }
0062         }
0063     ]
0064 
0065     header: TabBar {
0066         id: tabBar
0067 
0068         Layout.fillWidth: true
0069     }
0070 
0071     Loader {
0072         id: generalLoader
0073 
0074         Layout.fillWidth: true
0075         Layout.fillHeight: true
0076         
0077         sourceComponent: GeneralTab {}
0078 
0079         active: tabBar.currentTab === "general" 
0080         visible: active
0081     }
0082 
0083     Loader {
0084         id: appearanceLoader
0085 
0086         Layout.fillWidth: true
0087         Layout.fillHeight: true
0088  
0089         sourceComponent: AppearanceTab {}
0090 
0091         active: tabBar.currentTab === "appearance" 
0092         visible: active
0093     }
0094 
0095     Loader {
0096         id: pluginsLoader
0097 
0098         Layout.fillWidth: true
0099         Layout.fillHeight: true
0100  
0101         sourceComponent: PluginsTab {}
0102 
0103         active: tabBar.currentTab === "plugins" 
0104         visible: active
0105     }
0106 
0107     onBackRequested: {
0108         applicationWindow().currentPageName = "Main"
0109     }
0110 
0111     function updateName(shownName,callingAction){
0112         namingDialog.shownName = shownName
0113         namingDialog.callingAction = callingAction
0114         namingDialog.open()
0115         namingDialog.nameField.selectAll()
0116         namingDialog.nameField.forceActiveFocus()
0117     }
0118 
0119     function updateColor(button, selectedColor) {
0120         switch(button.name) {
0121             case "background":
0122                 Config.viewBodyColor = selectedColor
0123                 break;
0124             case "text":
0125                 Config.viewTextColor = selectedColor
0126                 break;
0127             case "title":
0128                 Config.viewTitleColor = selectedColor
0129                 break;
0130             case "link":
0131                 Config.viewLinkColor = selectedColor
0132                 break;
0133             case "visitedLink":
0134                 Config.viewVisitedLinkColor = selectedColor
0135                 break;
0136             case "code":
0137                 Config.viewCodeColor = selectedColor
0138                 break;
0139             case "highlight":
0140                 Config.viewHighlightColor = selectedColor
0141                 break;
0142         }
0143     }
0144 }