Changed #34: Do not underline lines with tick boxes. Began implementing #18: Page with Markdown syntax

This commit is contained in:
Scharel 2018-12-11 13:34:17 +01:00
parent 413d3e3486
commit a01fe96830
7 changed files with 116 additions and 61 deletions

View file

@ -1,53 +1,54 @@
# NOTICE:
#
# Application name defined in TARGET has a corresponding QML filename.
# If name defined in TARGET is changed, the following needs to be done
# to match new name:
# - corresponding QML filename must be changed
# - desktop icon filename must be changed
# - desktop filename must be changed
# - icon definition filename in desktop file must be changed
# - translation filenames have to be changed
# The name of your application
TARGET = harbour-nextcloudnotes
CONFIG += sailfishapp
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
SOURCES += src/harbour-nextcloudnotes.cpp
DISTFILES += qml/harbour-nextcloudnotes.qml \
qml/cover/CoverPage.qml \
rpm/harbour-nextcloudnotes.changes.run.in \
rpm/harbour-nextcloudnotes.changes \
rpm/harbour-nextcloudnotes.spec \
rpm/harbour-nextcloudnotes.yaml \
translations/*.ts \
harbour-nextcloudnotes.desktop \
qml/pages/NotePage.qml \
qml/pages/NotesPage.qml \
qml/pages/LoginDialog.qml \
qml/pages/EditPage.qml \
qml/pages/SettingsPage.qml \
qml/pages/AboutPage.qml \
qml/pages/UnencryptedDialog.qml \
qml/pages/NotesApi.qml \
qml/pages/MITLicense.qml \
qml/pages/GPLLicense.qml
SAILFISHAPP_ICONS = 86x86 108x108 128x128 172x172
# to disable building translations every time, comment out the
# following CONFIG line
CONFIG += sailfishapp_i18n
# German translation is enabled as an example. If you aren't
# planning to localize your app, remember to comment out the
# following TRANSLATIONS line. And also do not forget to
# modify the localized app name in the the .desktop file.
TRANSLATIONS += translations/harbour-nextcloudnotes-de.ts \
translations/harbour-nextcloudnotes-sv.ts
HEADERS +=
# NOTICE:
#
# Application name defined in TARGET has a corresponding QML filename.
# If name defined in TARGET is changed, the following needs to be done
# to match new name:
# - corresponding QML filename must be changed
# - desktop icon filename must be changed
# - desktop filename must be changed
# - icon definition filename in desktop file must be changed
# - translation filenames have to be changed
# The name of your application
TARGET = harbour-nextcloudnotes
CONFIG += sailfishapp
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
SOURCES += src/harbour-nextcloudnotes.cpp
DISTFILES += qml/harbour-nextcloudnotes.qml \
qml/cover/CoverPage.qml \
rpm/harbour-nextcloudnotes.changes.run.in \
rpm/harbour-nextcloudnotes.changes \
rpm/harbour-nextcloudnotes.spec \
rpm/harbour-nextcloudnotes.yaml \
translations/*.ts \
harbour-nextcloudnotes.desktop \
qml/pages/NotePage.qml \
qml/pages/NotesPage.qml \
qml/pages/LoginDialog.qml \
qml/pages/EditPage.qml \
qml/pages/SettingsPage.qml \
qml/pages/AboutPage.qml \
qml/pages/UnencryptedDialog.qml \
qml/pages/NotesApi.qml \
qml/pages/MITLicense.qml \
qml/pages/GPLLicense.qml \
qml/pages/SyntaxPage.qml
SAILFISHAPP_ICONS = 86x86 108x108 128x128 172x172
# to disable building translations every time, comment out the
# following CONFIG line
CONFIG += sailfishapp_i18n
# German translation is enabled as an example. If you aren't
# planning to localize your app, remember to comment out the
# following TRANSLATIONS line. And also do not forget to
# modify the localized app name in the the .desktop file.
TRANSLATIONS += translations/harbour-nextcloudnotes-de.ts \
translations/harbour-nextcloudnotes-sv.ts
HEADERS +=

View file

@ -33,7 +33,7 @@ Dialog {
}
MenuItem {
text: qsTr("Markdown syntax")
onClicked: Qt.openUrlExternally("https://github.com/showdownjs/showdown/wiki/Showdown's-Markdown-syntax")
onClicked: pageStack.push(Qt.resolvedUrl("SyntaxPage.qml")) //Qt.openUrlExternally("https://github.com/showdownjs/showdown/wiki/Showdown's-Markdown-syntax")
}
}

View file

@ -47,20 +47,23 @@ Dialog {
convertedText = convertedText.replace(/^<li>(<p>)?\[ \] (.*)(<.*)$/gmi,
function(match, p1, p2, p3, offset) {
occurence++
return '<li class="tasklist"><a href="tasklist:checkbox_' + occurence + '">' + (p1 ? p1 : "") + '☐ ' + p2 + '</a>' + p3
return '<li class="tasklist"><a class="checkbox" href="tasklist:checkbox_' + occurence + '">' + (p1 ? p1 : "") + '☐ ' + p2 + '</a>' + p3
} )
occurence = -1
convertedText = convertedText.replace(/^<li>(<p>)?\[[xX]\] (.*)(<.*)$/gmi,
function(match, p1, p2, p3, offset) {
occurence++
return '<li class="tasklist"><a href="tasklist:uncheckbox_' + occurence + '">' + (p1 ? p1 : "") + '☑ ' + p2 + '</a>' + p3
return '<li class="tasklist"><a class="checkbox" href="tasklist:uncheckbox_' + occurence + '">' + (p1 ? p1 : "") + '☑ ' + p2 + '</a>' + p3
} )
convertedText = convertedText.replace("<table>", "<table border='1' cellpadding='" + Theme.paddingMedium + "'>")
contentLabel.text = "<style>ul,ol,table,img { margin-bottom: " + Theme.paddingLarge + "px; margin-top: " + Theme.paddingLarge + "px; }\n" +
contentLabel.text = "<style>\n" +
"ul,ol,table,img { margin: " + Theme.paddingLarge + "px 0px; }\n" +
"a:link { color: " + Theme.primaryColor + "; }\n" +
"li.tasklist { font-size:large; margin-bottom: " + Theme.paddingMedium + "px; margin-top: " + Theme.paddingMedium + "px; }\n" +
"a.checkbox { text-decoration: none; padding: " + Theme.paddingSmall + "px; display: inline-block; }\n" +
"li.tasklist { font-size:large; margin: " + Theme.paddingMedium + "px 0px; }\n" +
"del { text-decoration: line-through; }\n" +
"table { border-color: " + Theme.secondaryColor + "; }</style>" + convertedText
"table { border-color: " + Theme.secondaryColor + "; }\n" +
"</style>\n" + convertedText
//console.log(contentLabel.text)
}

47
qml/pages/SyntaxPage.qml Normal file
View file

@ -0,0 +1,47 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
Page {
id: page
SilicaFlickable {
id: flickable
anchors.fill: parent
contentHeight: column.height
Column {
id: column
width: parent.width
PageHeader {
title: qsTr("Markdown Syntax")
}
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"
}
}
}
}
VerticalScrollDecorator {}
}
allowedOrientations: defaultAllowedOrientations
}

View file

@ -12,6 +12,10 @@
# * date Author's Name <author's email> version-release
# - Summary of changes
* Mon Dec 11 2018 Scharel Clemens <harbour-nextcloudnotes@scharel.name> 0.2-6
- Changed #34: "Do not underline lines with tick boxes"
- Began implementing #18: Page with Markdown syntax
* Mon Dec 11 2018 Scharel Clemens <harbour-nextcloudnotes@scharel.name> 0.2-5
- Fixed an issue that prevented to edit accounts

View file

@ -14,7 +14,7 @@ Name: harbour-nextcloudnotes
%{?qtc_builddir:%define _builddir %qtc_builddir}
Summary: Nextcloud Notes
Version: 0.2
Release: 5
Release: 6
Group: Applications/Editors
License: MIT
URL: https://github.com/scharel/harbour-nextcloudnotes

View file

@ -1,7 +1,7 @@
Name: harbour-nextcloudnotes
Summary: Nextcloud Notes
Version: 0.2
Release: 5
Release: 6
# The contents of the Group field should be one of the groups listed here:
# https://github.com/mer-tools/spectacle/blob/master/data/GROUPS
Group: Applications/Editors