diff --git a/src/controls/Editor.qml b/src/controls/Editor.qml index b1d1e99..eccc502 100644 --- a/src/controls/Editor.qml +++ b/src/controls/Editor.qml @@ -1,216 +1,214 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import org.kde.mauikit 1.0 as Maui import DocumentHandler 1.0 import "private" Maui.Page { id: control property bool showLineCount : 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 - headBarExit: false 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 }, ToolButton { icon.name: "format-text-bold" focusPolicy: Qt.TabFocus icon.color: checked ? highlightColor : textColor checkable: false checked: document.bold onClicked: document.bold = !document.bold }, ToolButton { icon.name: "format-text-italic" icon.color: checked ? highlightColor : textColor focusPolicy: Qt.TabFocus checkable: false checked: document.italic onClicked: document.italic = !document.italic }, ToolButton { icon.name: "format-text-underline" icon.color: checked ? highlightColor : textColor focusPolicy: Qt.TabFocus checkable: true checked: document.underline onClicked: document.underline = !document.underline }, ToolButton { icon.name: "format-text-uppercase" icon.color: checked ? highlightColor : textColor focusPolicy: Qt.TabFocus checkable: true checked: document.uppercase onClicked: document.uppercase = !document.uppercase } ] DocumentHandler { id: document document: body.textDocument cursorPosition: body.cursorPosition selectionStart: body.selectionStart selectionEnd: body.selectionEnd // textColor: TODO // onLoaded: { // body.text = text // } onError: { body.text = message body.visible = true } onLoaded: { body.text = text } } ScrollView { id: _scrollView anchors.fill: parent TextArea { id: body width: parent.width height: parent.height placeholderText: qsTr("Body") selectByKeyboard :!isMobile selectByMouse : !isMobile textFormat : TextEdit.AutoText color: control.colorScheme.textColor font.pointSize: fontSizes.large wrapMode: TextEdit.WrapAnywhere activeFocusOnPress: true activeFocusOnTab: true persistentSelection: true // background: Rectangle // { // color: "transparent" // } // onPressAndHold: isMobile ? documentMenu.popup() : undefined onPressed: { if(!isMobile && event.button === Qt.RightButton) documentMenu.popup() } Row { visible: showLineCount anchors { right: parent.right bottom: parent.bottom } width: implicitWidth height: implicitHeight Label { text: body.length + " / " + body.lineCount color: textColor opacity: 0.5 font.pointSize: 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 } } } } } diff --git a/src/controls/PieButton.qml b/src/controls/PieButton.qml index a6bc532..02bf711 100644 --- a/src/controls/PieButton.qml +++ b/src/controls/PieButton.qml @@ -1,100 +1,100 @@ /* * 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.6 import QtQuick.Controls 2.2 import org.kde.mauikit 1.0 as Maui -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.7 as Kirigami import "private" ToolButton { id: control /* Controlc color scheming */ ColorScheme {id: colorScheme} property alias colorScheme : colorScheme /***************************/ property int alignment : Qt.AlignLeft property int barHeight : 0 property int maxWidth : ApplicationWindow.overlay.width *( isMobile ? 1 : 0.5) property alias content : content.middleContent onClicked: popup.visible ? close(): open() layer.enabled: true clip: true z: 1 Popup { id: popup height: barHeight implicitWidth: content.middleLayout.implicitWidth + space.big + space.small width: implicitWidth > maxWidth ? maxWidth : (content.middleLayout.implicitWidth > ApplicationWindow.overlay.width ? ApplicationWindow.overlay.width : implicitWidth) padding: 0 margins: 0 x: alignment === Qt.AlignLeft ? (control.x - width) - space.big : (control.x + control.width) + space.big y: parent.height / 2 - height / 2 background: Rectangle { radius: radiusV color: colorScheme.backgroundColor border.color: colorScheme.borderColor } onFocusChanged: !activeFocus || !focus ? close() : undefined enter: Transition { // grow_fade_in NumberAnimation { property: "scale"; from: 0.9; to: 1.0; easing.type: Easing.OutQuint; duration: 220 } NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; easing.type: Easing.OutCubic; duration: 150 } } exit: Transition { // shrink_fade_out NumberAnimation { property: "scale"; from: 1.0; to: 0.9; easing.type: Easing.OutQuint; duration: 220 } NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; easing.type: Easing.OutCubic; duration: 150 } } Maui.ToolBar { id: content anchors.fill: parent implicitHeight: parent.height spacing: space.enormous - colorScheme.backgroundColor: "transparent" + Kirigami.Theme.backgroundColor: "transparent" drawBorder: false } } function open() { popup.open() } function close() { popup.close() } }