diff --git a/org.kde.nota.desktop b/org.kde.nota.desktop index c8326b6..463fa9a 100755 --- a/org.kde.nota.desktop +++ b/org.kde.nota.desktop @@ -1,60 +1,60 @@ [Desktop Entry] Name=Nota Name[ca]=Nota Name[ca@valencia]=Nota Name[cs]=Nota Name[es]=Nota Name[et]=Nota Name[it]=Nota Name[ko]=Nota Name[lt]=Nota Name[nl]=Nota Name[pt]=Nota Name[pt_BR]=Nota Name[sk]=Nota Name[sv]=Nota Name[uk]=Нота Name[x-test]=xxNotaxx Name[zh_TW]=Nota Comment=Simple Text Editor Comment[ca]=Editor de text senzill Comment[ca@valencia]=Editor de text senzill Comment[cs]=Jednoduchý editor textu Comment[es]=Editor simple de texto Comment[et]=Lihtne tekstiredaktor Comment[it]=Semplice editor di testo Comment[ko]=간단한 텍스트 편집기 Comment[lt]=Paprastas tekstų redaktorius Comment[nl]=Eenvoudige tekstverwerker Comment[pt]=Editor de Texto Simples Comment[pt_BR]=Editor de texto simples Comment[sk]=Jednoduchý textový editor Comment[sv]=Enkel texteditor Comment[uk]=Простий текстовий редактор Comment[x-test]=xxSimple Text Editorxx Comment[zh_TW]=簡易文字編輯器 TryExec=nota Exec=nota %U Terminal=false Type=Application Categories=Qt;KDE;Utility;TextEditor; GenericName=Simple Text Editor GenericName[ca]=Editor de text senzill GenericName[ca@valencia]=Editor de text senzill GenericName[cs]=Jednoduchý editor textu GenericName[es]=Editor simple de texto GenericName[et]=Lihtne tekstiredaktor GenericName[it]=Semplice editor di testo GenericName[ko]=간단한 텍스트 편집기 GenericName[lt]=Paprastas tekstų redaktorius GenericName[nl]=Eenvoudige tekstverwerker GenericName[pt]=Editor de Texto Simples GenericName[pt_BR]=Editor de texto simples GenericName[sk]=Jednoduchý textový editor GenericName[sv]=Enkel texteditor GenericName[uk]=Простий текстовий редактор GenericName[x-test]=xxSimple Text Editorxx GenericName[zh_TW]=簡易文字編輯器 StartupNotify=true -Icon=accessories-text-editor +Icon=maui-nota MimeType=text/plain; diff --git a/src/Editor.qml b/src/Editor.qml index 8e7794b..cfc6ab4 100644 --- a/src/Editor.qml +++ b/src/Editor.qml @@ -1,235 +1,242 @@ import QtQuick 2.13 import QtQuick.Controls 2.13 import QtQuick.Layouts 1.3 import org.kde.mauikit 1.0 as Maui import org.kde.mauikit 1.1 as MauiLab import org.kde.kirigami 2.7 as Kirigami import org.maui.nota 1.0 as Nota SplitView { id: control property alias document: _editor.document property alias editor: _editor property alias body: _editor.body property alias footBar: _editor.footBar property alias headBar: _editor.headBar property alias fileUrl : _editor.fileUrl property alias title : _editor.title property alias footer : _editor.footer property alias header : _editor.header property alias terminal : terminalLoader.item height: _editorListView.height width: _editorListView.width spacing: 0 orientation: Qt.Vertical handle: Rectangle { implicitWidth: 6 implicitHeight: 6 color: SplitHandle.pressed ? Kirigami.Theme.highlightColor : (SplitHandle.hovered ? Qt.lighter(Kirigami.Theme.backgroundColor, 1.1) : Kirigami.Theme.backgroundColor) Rectangle { anchors.centerIn: parent width: 48 height: parent.height color: _splitSeparator.color } Kirigami.Separator { id: _splitSeparator anchors.bottom: parent.bottom anchors.right: parent.right anchors.left: parent.left } Kirigami.Separator { anchors.top: parent.top anchors.right: parent.right anchors.left: parent.left } } Maui.Editor { id: _editor SplitView.fillHeight: true SplitView.fillWidth: true showLineNumbers: root.showLineNumbers - body.font.family: root.fontFamily - body.font.pointSize: root.fontSize - document.backgroundColor: document.enableSyntaxHighlighting ? root.backgroundColor : Kirigami.Theme.backgroundColor + body.color: root.textColor + body.font.family: root.font.family + body.font.pointSize: root.font.pointSize + document.backgroundColor: root.backgroundColor showSyntaxHighlightingLanguages: root.showSyntaxHighlightingLanguages document.theme: root.theme document.enableSyntaxHighlighting: root.enableSyntaxHighlighting onFileUrlChanged: syncTerminal(control.fileUrl) // floatingHeader: root.focusMode autoHideHeader: root.focusMode footBar.visible: false footBar.leftContent: [ Maui.TextField { id: _findField placeholderText: qsTr("Find") onAccepted: { console.log("FIND THE QUERY", text) document.find(text) } }, Maui.TextField { placeholderText: qsTr("Replace") }, Button { text: qsTr("Replace") } ] headBar.middleContent: Button { // visible: root.focusMode icon.name: "quickview" text: qsTr("Focus") checked: root.focusMode onClicked: root.focusMode = !root.focusMode } altHeader: Kirigami.Settings.isMobile headBar.rightContent:[ Maui.ToolActions { autoExclusive: false checkable: false expanded: true Action { text: qsTr("Save") icon.name: "document-save" onTriggered: saveFile(document.fileUrl, _tabBar.currentIndex) } Action { icon.name: "document-save-as" text: qsTr("Save as...") onTriggered: saveFile("", _tabBar.currentIndex) } }, ToolButton { icon.name: "tool_pen" onClicked: _doodleDialog.open() checked: _doodleDialog.visible }] Keys.enabled: true Keys.onPressed: { if((event.key === Qt.Key_S) && (event.modifiers & Qt.ControlModifier)) { saveFile(document.fileUrl, _tabBar.currentIndex) } - if(event.key === Qt.F4) + if(event.key === Qt.Key_F4) { - toggleTerminal() + root.terminalVisible = !root.terminalVisible + Maui.FM.saveSettings("TERMINAL", terminalVisible, "EXTENSIONS") } if((event.key === Qt.Key_T) && (event.modifiers & Qt.ControlModifier)) { syncTerminal(control.fileUrl) control.terminal.forceActiveFocus() } if((event.key === Qt.Key_O) && (event.modifiers & Qt.ControlModifier)) { openFile() } if((event.key === Qt.Key_N) && (event.modifiers & Qt.ControlModifier)) { openTab("") } + if((event.key === Qt.Key_L) && (event.modifiers & Qt.ControlModifier)) + { + root.showLineNumbers = !root.showLineNumbers + } + if((event.key === Qt.Key_F) && (event.modifiers & Qt.ControlModifier)) { footBar.visible = !footBar.visible if(footBar.visible) { _findField.forceActiveFocus() }else { _editor.forceActiveFocus() } } } } Loader { id: terminalLoader active: Nota.Nota.supportsEmbededTerminal() visible: active && terminalVisible && terminal SplitView.fillWidth: true SplitView.preferredHeight: 200 SplitView.maximumHeight: parent.height * 0.5 SplitView.minimumHeight : 100 source: "Terminal.qml" onLoaded: syncTerminal(control.fileUrl) Behavior on SplitView.preferredHeight { NumberAnimation { duration: Kirigami.Units.longDuration easing.type: Easing.InQuad } } } function saveFile(path, index) { if (path && Maui.FM.fileExists(path)) { document.saveAs(path); } else { _dialogLoader.sourceComponent = _fileDialogComponent dialog.mode = dialog.modes.SAVE; // fileDialog.settings.singleSelection = true dialog.show(function (paths) { document.saveAs(paths[0]); _editorList.update(index, paths[0]); }); } } function syncTerminal(path) { if(control.terminal && control.terminal.visible && Maui.FM.fileExists(path)) control.terminal.session.sendText("cd '" + String(Maui.FM.fileDir(path)).replace("file://", "") + "'\n") } } diff --git a/src/main.qml b/src/main.qml index 9233c8e..c7a4c09 100644 --- a/src/main.qml +++ b/src/main.qml @@ -1,674 +1,677 @@ import QtQuick 2.13 import QtQuick.Controls 2.13 import QtQuick.Layouts 1.3 import org.kde.kirigami 2.7 as Kirigami import org.kde.mauikit 1.0 as Maui import org.kde.mauikit 1.1 as MauiLab import org.maui.nota 1.0 as Nota import QtQuick.Window 2.0 import QtQml.Models 2.3 import "views" import "views/widgets" as Widgets Maui.ApplicationWindow { id: root title: currentTab ? currentTab.title : "" Maui.App.iconName: "qrc:/img/nota.svg" Maui.App.description: qsTr("Nota allows you to edit text files.") Maui.App.handleAccounts: false background.opacity: translucency ? 0.5 : 1 readonly property var views : ({editor: 0, documents: 1, recent: 2}) property alias currentTab : _editorListView.currentItem property alias dialog : _dialogLoader.item property bool selectionMode : false property bool translucency : Maui.Handy.isLinux - property bool terminalVisible : Maui.FM.loadSettings("TERMINAL", "EXTENSIONS", false) == "true" + property bool terminalVisible : Maui.FM.loadSettings("TERMINAL", "EXTENSIONS", false) //Global editor props property bool focusMode : false - property bool enableSidebar : !focusMode - property bool showLineNumbers : true - property bool enableSyntaxHighlighting : true + property bool enableSidebar : Maui.FM.loadSettings("ENABLE_SIDEBAR", "EXTENSIONS", !focusMode) == "true" + + property bool showLineNumbers : Maui.FM.loadSettings("SHOW_LINE_NUMBERS", "EDITOR", true) == "true" + property bool enableSyntaxHighlighting : Maui.FM.loadSettings("ENABLE_SYNTAX_HIGHLIGHTING", "EDITOR", true) == "true" property bool showSyntaxHighlightingLanguages: false - property string theme - property color backgroundColor - property string fontFamily : "Noto Sans Mono" - property int fontSize : 10 + property string theme : Maui.FM.loadSettings("THEME", "EDITOR", "Default") + property color backgroundColor : Maui.FM.loadSettings("BACKGROUND_COLOR", "EDITOR", root.Kirigami.Theme.backgroundColor) + property color textColor : Maui.FM.loadSettings("TEXT_COLOR", "EDITOR", root.Kirigami.Theme.textColor) + + property font font : Maui.FM.loadSettings("FONT", "EDITOR", defaultFont) + + readonly property font defaultFont: + { + family: "Noto Sans Mono" + pointSize: Maui.Style.fontSizes.default + } onCurrentTabChanged: syncSidebar(currentTab.fileUrl) MauiLab.Doodle { id: _doodleDialog sourceItem: root.currentTab ? root.currentTab.body : null } mainMenu: [ MenuItem { text: qsTr("Settings") icon.name: "settings-configure" onTriggered: { _dialogLoader.sourceComponent = _settingsDialogComponent dialog.open() } - }, - - MenuSeparator {visible: Nota.Nota.supportsEmbededTerminal()}, - - MenuItem - { - visible: Nota.Nota.supportsEmbededTerminal() - text: qsTr("Show Terminal") - icon.name: "utilities-terminal" - onTriggered: toggleTerminal() - checked : terminalVisible - checkable: true - }] + } + ] ObjectModel { id: _documentModel } onClosing: { _dialogLoader.sourceComponent = _unsavedDialogComponent if(!dialog.discard) { for(var i = 0; i<_editorListView.count; i++) { const doc = _documentModel.get(i) if(doc.document.modified) { close.accepted = false dialog.open() return } } } close.accepted = true } Loader { id: _dialogLoader } Component { id: _unsavedDialogComponent Maui.Dialog { property bool discard : false title: qsTr("Un saved files") message: qsTr("You have un saved files. You can go back and save them or choose to dicard all changes and exit.") page.padding: Maui.Style.space.big acceptButton.text: qsTr("Go back") rejectButton.text: qsTr("Discard") onRejected: { discard = true root.close() } onAccepted: close() } } Component { id: _settingsDialogComponent Widgets.SettingsDialog {} } Component { id: _fileDialogComponent Maui.FileDialog { settings.onlyDirs: false settings.filterType: Maui.FMList.TEXT settings.sortBy: Maui.FMList.MODIFIED mode: modes.OPEN } } headBar.visible: root.currentTab && _swipeView.currentIndex === views.editor && Kirigami.Settings.isMobile ? root.currentTab.height > Kirigami.Units.gridUnit*30 : !focusMode headBar.leftContent: ToolButton { visible: root.enableSidebar icon.name: "view-split-left-right" checked: _drawer.visible onClicked: _drawer.visible ? _drawer.close() : _drawer.open() } headBar.rightContent: [ ToolButton { icon.name: "document-open" onClicked: openFile() }, ToolButton { visible: Maui.Handy.isTouch icon.name: "item-select" onClicked: { selectionMode = !selectionMode if(_swipeView.currentIndex === views.editor) { _swipeView.currentIndex = views.documents } } checked: selectionMode } ] sideBar: Maui.AbstractSideBar { id : _drawer Kirigami.Theme.inherit: false Kirigami.Theme.colorSet: Kirigami.Theme.Window width: visible ? Math.min(Kirigami.Units.gridUnit * 14, root.width) : 0 collapsed: !isWide collapsible: true dragMargin: Maui.Style.space.big overlay.visible: collapsed && position > 0 && visible visible: (_swipeView.currentIndex === views.editor) && enableSidebar enabled: root.enableSidebar + onVisibleChanged: + { + if(currentTab) + syncSidebar(currentTab.fileUrl) + } + Connections { target: _drawer.overlay onClicked: _drawer.close() } background: Rectangle { color: Kirigami.Theme.backgroundColor opacity: translucency ? 0.5 : 1 } Maui.Page { anchors.fill: parent Kirigami.Theme.inherit: false Kirigami.Theme.colorSet: Kirigami.Theme.Window background: Rectangle { color: Kirigami.Theme.backgroundColor opacity: translucency ? 0.7 : 1 } headBar.visible: true headBar.middleContent: ComboBox { Layout.fillWidth: true z : _drawer.z + 9999 model: Maui.BaseModel { list: Maui.PlacesList { groups: [ Maui.FMList.PLACES_PATH, Maui.FMList.DRIVES_PATH, Maui.FMList.TAGS_PATH] } } textRole: "label" onActivated: { currentIndex = index browserView.openFolder(model.list.get(index).path) } } Maui.FileBrowser { id: browserView anchors.fill: parent currentPath: Maui.FM.homePath() settings.viewType : Maui.FMList.LIST_VIEW settings.filterType: Maui.FMList.TEXT headBar.rightLayout.visible: false headBar.rightLayout.width: 0 selectionMode: root.selectionMode selectionBar: _selectionbar Kirigami.Theme.backgroundColor: "transparent" onItemClicked: { var item = currentFMList.get(index) if(Maui.Handy.singleClick) { if(item.isdir == "true") { openFolder(item.path) }else { root.openTab(item.path) } } } onItemDoubleClicked: { var item = currentFMList.get(index) if(!Maui.Handy.singleClick) { if(item.isdir == "true") { openFolder(item.path) }else { root.openTab(item.path) } } } } } } Maui.BaseModel { id: _editorModel list: Nota.Editor { id: _editorList } } Maui.Page { anchors.fill: parent spacing: 0 flickable: _swipeView.currentItem.item ? _swipeView.currentItem.item.flickable : null MauiLab.AppViews { id: _swipeView anchors.fill: parent Maui.Page { id: editorView MauiLab.AppView.iconName: "document-edit" MauiLab.AppView.title: qsTr("Editor") header: Maui.TabBar { id: _tabBar visible: _editorListView.count > 1 width: parent.width position: TabBar.Header currentIndex : _editorListView.currentIndex onNewTabClicked: root.openTab("") Repeater { id: _repeater model: _editorModel Maui.TabButton { id: _tabButton readonly property int index_ : index implicitHeight: _tabBar.implicitHeight implicitWidth: Math.max(parent.width / _repeater.count, 120) checked: index === _tabBar.currentIndex text: model.label onClicked: _editorListView.currentIndex = index onCloseClicked: { if( _documentModel.get(model.index).document.modified) { _saveDialog.fileIndex = model.index _saveDialog.open() } else closeTab(model.index) } Maui.Dialog { id: _saveDialog property int fileIndex page.padding: Maui.Style.space.huge title: qsTr("Save file") message: qsTr(String("This file has been modified, you can save your changes now or discard them.\n")) + _editorModel.get(_tabButton.index).path acceptButton.text: qsTr("Save") rejectButton.text: qsTr("Discard") onAccepted: { _documentModel.get(fileIndex).saveFile(_editorModel.get(fileIndex).path, fileIndex) closeTab(fileIndex) _saveDialog.close() } onRejected: { _saveDialog.close() closeTab(fileIndex) } } } } } Maui.Holder { id: _holder visible: !_editorListView.count emoji: "qrc:/img/document-edit.svg" emojiSize: Maui.Style.iconSizes.huge isMask: true onActionTriggered: openTab("") title: qsTr("Create a new document") body: qsTr("You can create a new document by clicking the New File button, or here.
Alternative you can open existing files from the left places sidebar or by clicking the Open button") } Maui.FloatingButton { id: _overlayButton z: 999 anchors.right: parent.right anchors.bottom: parent.bottom anchors.margins: Maui.Style.toolBarHeightAlt anchors.bottomMargin: Maui.Style.toolBarHeight + (root.currentTab ? root.currentTab.footBar.height : 0) height: Maui.Style.toolBarHeight width: height icon.name: "document-new" icon.color: Kirigami.Theme.highlightedTextColor onClicked: openTab("") Maui.Badge { anchors { horizontalCenter: parent.right verticalCenter: parent.top } onClicked: _newDocumentMenu.open() Maui.PlusSign { color: parent.Kirigami.Theme.textColor height: 10 width: height anchors.centerIn: parent } } Maui.Dialog { id: _newDocumentMenu maxHeight: 300 maxWidth: 400 defaultButtons: false footBar.middleContent: Button { text: qsTr("New template") } ColumnLayout { Layout.fillWidth: true Layout.fillHeight: true Layout.margins: Maui.Style.space.big spacing: Maui.Style.space.big Maui.ItemDelegate { Layout.fillWidth: true Layout.fillHeight: true Maui.ListItemTemplate { anchors.fill:parent iconSizeHint: Math.min(height, Maui.Style.iconSizes.big) iconSource: "text-x-generic" label1.text: qsTr("Text file") label2.text: qsTr("Simple text file with syntax highlighting") } onClicked: { openTab("") _editorListView.currentItem.body.textFormat = TextEdit.PlainText _newDocumentMenu.close() } } Maui.ItemDelegate { Layout.fillWidth: true Layout.fillHeight: true Maui.ListItemTemplate { anchors.fill:parent iconSizeHint: Math.min(height, Maui.Style.iconSizes.big) iconSource: "text-enriched" label1.text: qsTr("Rich text file") label2.text: qsTr("With support for basic text format editing") } onClicked: { openTab("") _editorListView.currentItem.body.textFormat = TextEdit.RichText _newDocumentMenu.close() } } Maui.ItemDelegate { Layout.fillWidth: true Layout.fillHeight: true Maui.ListItemTemplate { anchors.fill:parent iconSizeHint: Math.min(height, Maui.Style.iconSizes.big) iconSource: "text-html" label1.text: qsTr("HTML text file") label2.text: qsTr("Text file with HTML markup support") } } } } } ListView { id: _editorListView anchors.fill: parent orientation: ListView.Horizontal model: _documentModel snapMode: ListView.SnapOneItem spacing: 0 interactive: Maui.Handy.isTouch && count > 1 highlightFollowsCurrentItem: true highlightMoveDuration: 0 highlightResizeDuration : 0 onMovementEnded: currentIndex = indexAt(contentX, contentY) cacheBuffer: count clip: true } } MauiLab.AppViewLoader { MauiLab.AppView.iconName: "view-pim-journal" MauiLab.AppView.title: qsTr("Documents") visible: !focusMode DocumentsView { id: _documentsView } } MauiLab.AppViewLoader { MauiLab.AppView.iconName: "view-media-recent" MauiLab.AppView.title: qsTr("Recent") visible: !focusMode RecentView { id:_recentView } } } footer: MauiLab.SelectionBar { id: _selectionbar padding: Maui.Style.space.big anchors.horizontalCenter: parent.horizontalCenter width: Math.min(parent.width-(Maui.Style.space.medium*2), implicitWidth) maxListHeight: root.height - (Maui.Style.contentMargins*2) onItemClicked : console.log(index) onExitClicked: clear() Action { text: qsTr("Open") icon.name: "document-open" onTriggered: { const paths = _selectionbar.uris for(var i in paths) openTab(paths[i]) _selectionbar.clear() } } Action { text: qsTr("Share") icon.name: "document-share" } Action { text: qsTr("Export") icon.name: "document-export" } } } DropArea { id: _dropArea anchors.fill: parent onDropped: { if(drop.urls) { var urls = drop.urls.join(",") Nota.Nota.requestFiles(urls.split(",")) } } } Connections { target: Nota.Nota onOpenFiles: { for(var i in urls) openTab(urls[i]) } } function openTab(path) { _swipeView.currentIndex = views.editor const index = _editorList.urlIndex(path) if(index >= 0) _editorListView.currentIndex = index; if(!_editorList.append(path)) return ; var component = Qt.createComponent("Editor.qml"); if (component.status === Component.Ready) { _documentModel.append(component.createObject(_documentModel)); _editorListView.currentIndex = _documentModel.count - 1 _documentModel.get(_documentModel.count - 1).fileUrl = path syncSidebar(path) } } function closeTab(index) { console.log("CLOSING FILE", index, _editorList.count, _documentModel.count) _editorList.remove(index) _documentModel.remove(index) console.log("CLOSING FILE", index, _editorList.count, _documentModel.count) } function syncSidebar(path) { if(path && Maui.FM.fileExists(path) && root.enableSidebar) { browserView.openFolder(Maui.FM.fileDir(path)) } } function toggleTerminal() { terminalVisible = !terminalVisible Maui.FM.saveSettings("TERMINAL", terminalVisible, "EXTENSIONS") } function openFile() { _dialogLoader.sourceComponent = _fileDialogComponent dialog.mode = dialog.modes.OPEN dialog.settings.onlyDirs = false dialog.show(function (paths) { for(var i in paths) { openTab(paths[i]) } }); } } diff --git a/src/views/DocumentsView.qml b/src/views/DocumentsView.qml index 39bc108..ef0f2fa 100644 --- a/src/views/DocumentsView.qml +++ b/src/views/DocumentsView.qml @@ -1,23 +1,23 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import org.kde.kirigami 2.6 as Kirigami import org.kde.mauikit 1.0 as Maui import org.maui.nota 1.0 as Nota import "widgets" DocsBrowser { id: control property alias list : _documentsList - + headBar.visible: true model: Maui.BaseModel { id: _documentsModel list: Nota.Documents { id: _documentsList } } } diff --git a/src/views/widgets/SettingsDialog.qml b/src/views/widgets/SettingsDialog.qml index 11ef90e..ceb23a4 100644 --- a/src/views/widgets/SettingsDialog.qml +++ b/src/views/widgets/SettingsDialog.qml @@ -1,224 +1,254 @@ import QtQuick 2.13 import QtQuick.Controls 2.13 import QtQuick.Layouts 1.3 import org.kde.kirigami 2.7 as Kirigami import org.kde.mauikit 1.0 as Maui import org.kde.mauikit 1.1 as MauiLab +import org.maui.nota 1.0 as Nota MauiLab.SettingsDialog { MauiLab.SettingsSection { title: qsTr("General") description: qsTr("Configure the app UI and plugins.") Switch { Layout.fillWidth: true checkable: true checked: root.enableSidebar Kirigami.FormData.label: qsTr("Enable Places Sidebar") onToggled: { root.enableSidebar = !root.enableSidebar - Maui.FM.saveSettings("ENABLE_SIDEBAR", enableSidebar, "GENERAL") + Maui.FM.saveSettings("ENABLE_SIDEBAR", enableSidebar, "EXTENSIONS") } } Switch { - enabled: terminalLoader.item + enabled: Nota.Nota.supportsEmbededTerminal() Layout.fillWidth: true checkable: true checked: root.terminalVisible Kirigami.FormData.label: qsTr("Enable Embedded Terminal") - onToggled: toogleTerminal() + onToggled: + { + root.terminalVisible = !root.terminalVisible + Maui.FM.saveSettings("TERMINAL", terminalVisible, "EXTENSIONS") + } } } MauiLab.SettingsSection { title: qsTr("Editor") description: qsTr("Configure the look and feel of the editor. The settings are applied globally") Switch { Layout.fillWidth: true checkable: true checked: root.showLineNumbers Kirigami.FormData.label: qsTr("Show line numbers") onToggled: { root.showLineNumbers = !root.showLineNumbers Maui.FM.saveSettings("SHOW_LINE_NUMBERS", showLineNumbers, "EDITOR") } } Switch { Layout.fillWidth: true checkable: true checked: root.showSyntaxHighlightingLanguages Kirigami.FormData.label: qsTr("Show Syntax Highlighting Languages") onToggled: { root.showSyntaxHighlightingLanguages = !root.showSyntaxHighlightingLanguages - Maui.FM.saveSettings("SHOW_LINE_NUMBERS", showLineNumbers, "EDITOR") + Maui.FM.saveSettings("SHOW_SYNTAXHIGHLIGHTING_BOX", showSyntaxHighlightingLanguages, "EDITOR") } } Switch { Layout.fillWidth: true Kirigami.FormData.label: qsTr("Enable Syntax Highlighting") checkable: true checked: root.enableSyntaxHighlighting onToggled: { root.enableSyntaxHighlighting = !root.enableSyntaxHighlighting Maui.FM.saveSettings("ENABLE_SYNTAX_HIGHLIGHTING", enableSyntaxHighlighting, "EDITOR") } } } MauiLab.SettingsSection { title: qsTr("Fonts") description: qsTr("Configure the global editor font family and size") ComboBox { Layout.fillWidth: true Kirigami.FormData.label: qsTr("Family") model: Qt.fontFamilies() - onActivated: root.fontFamily = currentText + Component.onCompleted: currentIndex = find(root.font.family, Qt.MatchExactly) + onActivated: + { + root.font.family = currentText + Maui.FM.saveSettings("FONT", root.font, "EDITOR") + } } SpinBox { Layout.fillWidth: true Kirigami.FormData.label: qsTr("Size") from: 0; to : 500 - value: currentTab ? currentTab.body.font.pointSize : Maui.Style.fontSizes.default - onValueChanged: root.fontSize = value + value: root.font.pointSize + onValueChanged: + { + root.font.pointSize = value + Maui.FM.saveSettings("FONT", root.font, "EDITOR") + } } } MauiLab.SettingsSection { title: qsTr("Style") description: qsTr("Configure the style of the syntax highliting. This configuration in not applied for rich text formats.") visible: root.enableSyntaxHighlighting ComboBox { Layout.fillWidth: true Kirigami.FormData.label: qsTr("Theme") model: _dummyDocumentHandler.getThemes() - onActivated: root.theme = currentText + Component.onCompleted: currentIndex = find(root.theme, Qt.MatchExactly) + + onActivated: + { + root.theme = currentText + Maui.FM.saveSettings("THEME", root.theme, "EDITOR") + } Maui.DocumentHandler { id: _dummyDocumentHandler } } Row { Layout.fillWidth: true Kirigami.FormData.label: qsTr("Color") spacing: Maui.Style.space.medium Rectangle { height: 22 width: 22 radius: Maui.Style.radiusV color: "#333" border.color: Qt.darker(color) MouseArea { anchors.fill: parent - onClicked: root.backgroundColor = parent.color + onClicked: switchBackgroundColor(parent.color, "#fafafa") } } Rectangle { height: 22 width: 22 radius: Maui.Style.radiusV color: "#fafafa" border.color: Qt.darker(color) MouseArea { anchors.fill: parent - onClicked: root.backgroundColor = parent.color + onClicked: switchBackgroundColor(parent.color, "#333") } } Rectangle { height: 22 width: 22 radius: Maui.Style.radiusV color: "#fff3e6" border.color: Qt.darker(color) MouseArea { anchors.fill: parent - onClicked: root.backgroundColor = parent.color + onClicked: switchBackgroundColor(parent.color, Qt.darker(parent.color, 2)) + } } Rectangle { height: 22 width: 22 radius: Maui.Style.radiusV color: "#4c425b" border.color: Qt.darker(color) MouseArea { anchors.fill: parent - onClicked: root.backgroundColor = parent.color + onClicked: switchBackgroundColor(parent.color, Qt.lighter(parent.color, 2,5)) } } } } MauiLab.SettingsSection { title: qsTr("Interface") description: qsTr("Configure the app UI.") Switch { Kirigami.FormData.label: qsTr("Focus Mode") checkable: true checked: root.focusMode onToggled: { root.focusMode = !root.focusMode } } Switch { Kirigami.FormData.label: qsTr("Translucent Sidebar") checkable: true enabled: root.enableSidebar && Maui.Handy.isLinux checked: root.translucency onToggled: root.translucency = !root.translucency } Switch { Kirigami.FormData.label: qsTr("Dark Mode") checkable: true enabled: false } } + + function switchBackgroundColor(backgroundColor, textColor) + { + root.backgroundColor = backgroundColor + root.textColor = textColor + + Maui.FM.saveSettings("BACKGROUND_COLOR", root.backgroundColor, "EDITOR") + Maui.FM.saveSettings("TEXT_COLOR", root.textColor, "EDITOR") + } }