From 1971a93da96a2cfcd2e923dbed6cdbb84f9703d2 Mon Sep 17 00:00:00 2001 From: Scharel Date: Tue, 11 Dec 2018 17:44:00 +0100 Subject: [PATCH] Worked on Syntax Page --- qml/pages/EditPage.qml | 2 +- qml/pages/SyntaxPage.qml | 125 +++++++++++++++++++++++++++++++++------ 2 files changed, 109 insertions(+), 18 deletions(-) diff --git a/qml/pages/EditPage.qml b/qml/pages/EditPage.qml index 756da73..fcaa1be 100644 --- a/qml/pages/EditPage.qml +++ b/qml/pages/EditPage.qml @@ -60,7 +60,7 @@ Dialog { width: parent.width focus: true text: note.content - font.family: appSettings.useMonoFont ? "DejaVu Sans Mono" : Theme.fontFamily // "Courier" + font.family: appSettings.useMonoFont ? "DejaVu Sans Mono" : Theme.fontFamily property int preTextLength: 0 property var listPrefixes: [/^( *)- /gm, /^( *)\* /gm, /^( *)\+ /gm, /^( *)- \[ \] /gm, /^( *)- \[[xX]\] /gm, /^( *)> /gm, /^( *)\d+. /gm] onTextChanged: { diff --git a/qml/pages/SyntaxPage.qml b/qml/pages/SyntaxPage.qml index 9291837..5096f8a 100644 --- a/qml/pages/SyntaxPage.qml +++ b/qml/pages/SyntaxPage.qml @@ -4,6 +4,52 @@ import Sailfish.Silica 1.0 Page { id: page + Component { + id: syntaxDrawer + + Drawer { + id: drawer + width: page.width + height: rawTextLabel.height > convertedTextLabel.height ? rawTextLabel.height : convertedTextLabel.height + backgroundSize: height + foreground: BackgroundItem { + width: parent.width + height: parent.height + onClicked: drawer.show() + Label { + id: rawTextLabel + x: Theme.horizontalPageMargin + width: parent.width - 2*x + wrapMode: Text.Wrap + font.family: appSettings.useMonoFont ? "DejaVu Sans Mono" : Theme.fontFamily + text: rawText + } + } + background: BackgroundItem { + width: parent.width + height: parent.height + onClicked: drawer.hide() + LinkedLabel { + id: convertedTextLabel + x: Theme.horizontalPageMargin + width: parent.width - 2*x + textFormat: Text.RichText + linkColor: Theme.primaryColor + defaultLinkActions: false + onLinkActivated: drawer.hide() + text: "\n" + convertedText + } + } + } + } + SilicaFlickable { id: flickable anchors.fill: parent @@ -20,23 +66,68 @@ Page { SectionHeader { text: qsTr("Header") } - Drawer { - id: headerDrawer - width: parent.width - background: LinkedLabel { - x: Theme.horizontalPageMargin - width: parent.width - 2*x - textFormat: Text.RichText - linkColor: Theme.primaryColor - text: "Formatted Text" - } - BackgroundItem { - anchors.fill: parent - onClicked: headerDrawer.open = !headerDrawer.open - Label { - text: "Raw Text" - } - } + Loader { + sourceComponent: syntaxDrawer + property string rawText: " +# Header 1 +## Header 2 +### Header 3 +#### Header 4 +##### Header 5 +###### Header 6"; + property string convertedText: " +

Header 1

+

Header 2

+

Header 3

+

Header 4

+
Header 5
+
Header 6
" + } + + SectionHeader { + text: qsTr("Links") + } + Loader { + sourceComponent: syntaxDrawer + property string rawText: " +https://jolla.com +info@jolla.com +[Homepage - Jolla](https://jolla.com) +[Link to Jolla][1] +[jolla][] + +[1]: https://jolla.com +[jolla]: https://jolla.com" + property string convertedText: " +https://jolla.com
+info@jolla.com
+Homepage - Jolla
+Homepage - Jolla
+Homepage - Jolla" + } + + SectionHeader { + text: qsTr("Tables") + } + Loader { + sourceComponent: syntaxDrawer + property string rawText: " +|Header 1 |Header 2 |Header 3 | +|:-----------|:----------:|-----------:| +|Content 1.1 |Content 2.1 |Content 3.1 | +|Content 1.2 |Content 2.2 |Content 3.2 | +|Content 1.3 |Content 2.3 |Content 3.3 |" + property string convertedText: " + + + + + + + + + +
Header 1Header 2Header 3
Content 1.1Content 2.1Content 3.1
Content 1.2Content 2.2Content 3.2
Content 1.3Content 2.3Content 3.3
" } }