diff --git a/src/controls/AboutDialog.qml b/src/controls/AboutDialog.qml index ad02969..d393826 100644 --- a/src/controls/AboutDialog.qml +++ b/src/controls/AboutDialog.qml @@ -1,197 +1,197 @@ /* * Copyright 2018 Camilo Higuita * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import QtQuick 2.0 -import QtQuick.Controls 2.2 +import QtQuick 2.10 +import QtQuick.Controls 2.10 import QtQuick.Layouts 1.3 import QtGraphicalEffects 1.12 import org.kde.kirigami 2.7 as Kirigami import org.kde.mauikit 1.0 as Maui Maui.Dialog { id: control defaultButtons: false widthHint: 0.9 heightHint: 0.8 maxWidth: Maui.Style.unit * 400 maxHeight: Maui.Style.unit * 250 page.padding: Maui.Style.space.small footBar.middleContent: ToolButton { icon.name: "link" onClicked: Qt.openUrlExternally(Maui.App.webPage) } footBar.rightContent: ToolButton { icon.name: "love" onClicked: Qt.openUrlExternally(Maui.App.donationPage) } footBar.leftContent: ToolButton { icon.name: "documentinfo" onClicked: Qt.openUrlExternally(Maui.App.reportPage) } RowLayout { id: layout anchors.centerIn: parent width: parent.width height: parent.height * 0.7 spacing: Maui.Style.space.big // Behavior on width // { // NumberAnimation // { // duration: Kirigami.Units.longDuration // easing.type: Easing.InOutQuad // } // } Item { visible: parent.width > control.maxWidth * 0.7 Layout.fillHeight: true Layout.margins: Maui.Style.space.small Layout.alignment: Qt.AlignVCenter Layout.preferredWidth: visible ? Maui.Style.iconSizes.huge : 0 Image { id: _imgIcon anchors.centerIn: parent source: Maui.App.iconName width: Math.max(Maui.Style.iconSizes.huge, parent.width) height: width sourceSize.width: width sourceSize.height: height asynchronous: true fillMode: Image.PreserveAspectFit } DropShadow { anchors.fill: _imgIcon horizontalOffset: 0 verticalOffset: 0 radius: 8.0 samples: 17 color: "#80000000" source: _imgIcon } } Kirigami.ScrollablePage { id: _descriptionItem Layout.fillWidth: true Layout.fillHeight: true Layout.alignment: Qt.AlignLeft | Qt.AlignTop Kirigami.Theme.backgroundColor: "transparent" padding: 0 leftPadding: padding rightPadding: padding topPadding: padding bottomPadding: padding ColumnLayout { id: _columnInfo spacing: Maui.Style.space.medium Label { Layout.fillWidth: true Layout.alignment: Qt.AlignLeft color: Kirigami.Theme.textColor text: Maui.App.displayName font.weight: Font.Bold font.bold: true font.pointSize: Maui.Style.fontSizes.huge elide: Text.ElideRight wrapMode: Text.NoWrap } Label { Layout.fillWidth: true Layout.alignment: Qt.AlignLeft color: Qt.lighter(Kirigami.Theme.textColor, 1.2) text: Maui.App.version font.weight: Font.Light font.pointSize: Maui.Style.fontSizes.default elide: Text.ElideRight wrapMode: Text.WrapAtWordBoundaryOrAnywhere } Label { id: body Layout.fillWidth: true text: Maui.App.description color: Kirigami.Theme.textColor font.pointSize: Maui.Style.fontSizes.default elide: Text.ElideRight wrapMode: Text.WrapAtWordBoundaryOrAnywhere } Label { color: Kirigami.Theme.textColor Layout.fillWidth: true text: qsTr("By ") + Maui.App.org font.pointSize: Maui.Style.fontSizes.default elide: Text.ElideRight wrapMode: Text.WrapAtWordBoundaryOrAnywhere } Kirigami.Separator { Layout.fillWidth: true Layout.margins: Maui.Style.space.tiny opacity: 0.4 } Label { color: Kirigami.Theme.textColor Layout.fillWidth: true text: qsTr("Powered by") + " MauiKit " + Maui.App.mauikitVersion + " and Kirigami." font.pointSize: Maui.Style.fontSizes.default elide: Text.ElideRight wrapMode: Text.WrapAtWordBoundaryOrAnywhere } } } } } diff --git a/src/controls/Editor.qml b/src/controls/Editor.qml index 28f68a7..19a4ea6 100644 --- a/src/controls/Editor.qml +++ b/src/controls/Editor.qml @@ -1,286 +1,277 @@ -import QtQuick 2.9 -import QtQuick.Controls 2.5 +import QtQuick 2.10 +import QtQuick.Controls 2.10 import QtQuick.Layouts 1.3 import org.kde.mauikit 1.0 as Maui import org.kde.kirigami 2.7 as Kirigami import org.maui.kquicksyntaxhighlighter 0.1 import "private" Maui.Page { id: control property bool showLineCount : true - property bool stickyHeadBar : true property bool showSyntaxHighlighting: true property alias body : body property alias document : document property alias scrollView: _scrollView property alias text: body.text property alias uppercase: document.uppercase property alias underline: document.underline property alias italic: document.italic property alias bold: document.bold property alias canRedo: body.canRedo - property alias headBar: _editorToolBar Maui.DocumentHandler { id: document document: body.textDocument cursorPosition: body.cursorPosition selectionStart: body.selectionStart selectionEnd: body.selectionEnd // textColor: TODO onError: { body.text = message body.visible = true } onLoaded: { body.text = text var formatName = document.syntaxHighlighterUtil.getLanguageNameFromFileName(document.fileName) languagesListComboBox.currentIndex = languagesListComboBox.find(formatName) } } Row { z: _scrollView.z +1 visible: showLineCount anchors { right: parent.right bottom: parent.bottom margins: Maui.Style.space.big } width: implicitWidth height: implicitHeight Label { text: body.length + " / " + body.lineCount color: Kirigami.Theme.textColor opacity: 0.5 font.pointSize: Maui.Style.fontSizes.medium } } Menu { id: documentMenu z: 999 MenuItem { text: qsTr("Copy") onTriggered: body.copy() enabled: body.selectedText.length } MenuItem { text: qsTr("Cut") onTriggered: body.cut() enabled: !body.readOnly && body.selectedText.length } MenuItem { text: qsTr("Paste") onTriggered: body.paste() enabled: !body.readOnly } MenuItem { text: qsTr("Select all") onTriggered: body.selectAll() } MenuItem { text: qsTr("Web search") onTriggered: Maui.FM.openUrl("https://www.google.com/search?q="+body.selectedText) enabled: body.selectedText.length } } + headBar.visible: !body.readOnly + + headBar.leftContent: [ + + ToolButton + { + icon.name: "edit-undo" + enabled: body.canUndo + onClicked: body.undo() + opacity: enabled ? 1 : 0.5 + + }, + + ToolButton + { + icon.name: "edit-redo" + enabled: body.canRedo + onClicked: body.redo() + opacity: enabled ? 1 : 0.5 + }, + + Row + { + id: _editingActions + visible: document.isRich && !body.readOnly + + ToolButton + { + icon.name: "format-text-bold" + focusPolicy: Qt.TabFocus + icon.color: checked ? Kirigami.Theme.highlightColor : Kirigami.Theme.textColor + checkable: false + checked: document.bold + onClicked: document.bold = !document.bold + } + + ToolButton + { + icon.name: "format-text-italic" + icon.color: checked ? Kirigami.Theme.highlightColor : Kirigami.Theme.textColor + focusPolicy: Qt.TabFocus + checkable: false + checked: document.italic + onClicked: document.italic = !document.italic + } + + ToolButton + { + icon.name: "format-text-underline" + icon.color: checked ? Kirigami.Theme.highlightColor : Kirigami.Theme.textColor + focusPolicy: Qt.TabFocus + checkable: true + checked: document.underline + onClicked: document.underline = !document.underline + } + + ToolButton + { + icon.name: "format-text-uppercase" + icon.color: checked ? Kirigami.Theme.highlightColor : Kirigami.Theme.textColor + focusPolicy: Qt.TabFocus + checkable: true + checked: document.uppercase + onClicked: document.uppercase = !document.uppercase + } + } + ] + + + + // footBar.visible: !body.readOnly footBar.rightContent: [ ToolButton { icon.name: "zoom-in" onClicked: zoomIn() }, ToolButton { icon.name: "zoom-out" onClicked: zoomOut() }, ComboBox { visible: control.showSyntaxHighlighting id: languagesListComboBox model: document.syntaxHighlighterUtil.getLanguageNameList() onCurrentIndexChanged: syntaxHighlighter.formatName = languagesListComboBox.model[currentIndex] } ] - ScrollView + Kirigami.ScrollablePage { id: _scrollView anchors.fill: parent + contentWidth: width + contentHeight: body.implicitHeight + + leftPadding: 0 + rightPadding: 0 + topPadding: 0 + bottomPadding: 0 + TextArea { id: body - width: parent.width - topPadding: _editorToolBar.visible ? _editorToolBar.height : 0 - topInset: stickyHeadBar ? 0 : topPadding font.family: languagesListComboBox.currentIndex > 0 ? "Monospace" : undefined placeholderText: qsTr("Body") Kirigami.Theme.backgroundColor: control.Kirigami.Theme.backgroundColor selectByKeyboard :!Kirigami.Settings.isMobile selectByMouse : !Kirigami.Settings.isMobile textFormat: TextEdit.AutoText palette.text: Kirigami.Theme.textColor color: control.Kirigami.Theme.textColor font.pointSize: Maui.Style.fontSizes.large wrapMode: TextEdit.WrapAnywhere activeFocusOnPress: true activeFocusOnTab: true persistentSelection: true -// background: Rectangle -// { -// color: Kirigami.Theme.backgroundColor -// implicitWidth: 200 -// implicitHeight: 22 -// } - - // onPressAndHold: isMobile ? documentMenu.popup() : undefined - Maui.ToolBar + background: Rectangle { - id: _editorToolBar - visible: !body.readOnly - parent: stickyHeadBar ? body : control - anchors - { - left: parent.left - right: parent.right - top: parent.top - } - - leftContent: [ - - ToolButton - { - icon.name: "edit-undo" - enabled: body.canUndo - onClicked: body.undo() - opacity: enabled ? 1 : 0.5 - - }, - - ToolButton - { - icon.name: "edit-redo" - enabled: body.canRedo - onClicked: body.redo() - opacity: enabled ? 1 : 0.5 - }, - - Row - { - id: _editingActions - visible: document.isRich && !body.readOnly - - ToolButton - { - icon.name: "format-text-bold" - focusPolicy: Qt.TabFocus - icon.color: checked ? Kirigami.Theme.highlightColor : Kirigami.Theme.textColor - checkable: false - checked: document.bold - onClicked: document.bold = !document.bold - } - - ToolButton - { - icon.name: "format-text-italic" - icon.color: checked ? Kirigami.Theme.highlightColor : Kirigami.Theme.textColor - focusPolicy: Qt.TabFocus - checkable: false - checked: document.italic - onClicked: document.italic = !document.italic - } - - ToolButton - { - icon.name: "format-text-underline" - icon.color: checked ? Kirigami.Theme.highlightColor : Kirigami.Theme.textColor - focusPolicy: Qt.TabFocus - checkable: true - checked: document.underline - onClicked: document.underline = !document.underline - } - - ToolButton - { - icon.name: "format-text-uppercase" - icon.color: checked ? Kirigami.Theme.highlightColor : Kirigami.Theme.textColor - focusPolicy: Qt.TabFocus - checkable: true - checked: document.uppercase - onClicked: document.uppercase = !document.uppercase - } - } - ] - - background: Rectangle - { - color: "transparent" - } + color: Kirigami.Theme.backgroundColor + implicitWidth: body.implicitWidth + implicitHeight: body.implicitHeight } + // onPressAndHold: isMobile ? documentMenu.popup() : undefined + onPressed: { if(!Kirigami.Settings.isMobile && event.button === Qt.RightButton) documentMenu.popup() } KQuickSyntaxHighlighter { id: syntaxHighlighter textEdit: body } } - ScrollBar.vertical.height: _scrollView.height - body.topPadding - ScrollBar.vertical.y: body.topPadding +// ScrollBar.vertical.height: _scrollView.height - body.topPadding +// ScrollBar.vertical.y: body.topPadding } function zoomIn() { body.font.pointSize = body.font.pointSize + 2 } function zoomOut() { body.font.pointSize = body.font.pointSize - 2 } }