Fixed #39 and workaround for #40. Some other changes

This commit is contained in:
Scharel 2018-12-23 01:59:01 +01:00
parent 41f530c0f6
commit 40aa889e07
13 changed files with 210 additions and 98 deletions

View file

@ -16,7 +16,11 @@ CONFIG += sailfishapp
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
SOURCES += src/harbour-nextcloudnotes.cpp
HEADERS += \
src/sslconfiguration.h
SOURCES += src/harbour-nextcloudnotes.cpp \
src/sslconfiguration.cpp
DISTFILES += qml/harbour-nextcloudnotes.qml \
qml/cover/CoverPage.qml \
@ -52,5 +56,3 @@ CONFIG += sailfishapp_i18n
# modify the localized app name in the the .desktop file.
TRANSLATIONS += translations/harbour-nextcloudnotes-de.ts \
translations/harbour-nextcloudnotes-sv.ts
HEADERS +=

View file

@ -47,7 +47,10 @@ Item {
onUsernameChanged: account.setValue("username", username)
onPasswordChanged: account.setValue("password", password)
onUpdateChanged: account.setValue("update", update)
onUnsecureConnectionChanged: account.setValue("unsecureConnection", unsecureConnection)
onUnsecureConnectionChanged: {
account.setValue("unsecureConnection", unsecureConnection)
ssl.checkCert = !unsecureConnection
}
onUnencryptedConnectionChanged: account.setValue("unencryptedConnection", unencryptedConnection)
ConfigurationGroup {

View file

@ -1,6 +1,7 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
import Nemo.Configuration 1.0
import SslConfiguration 1.0
import "pages"
import "components"
@ -66,6 +67,11 @@ ApplicationWindow
}
}
SslConfiguration {
id: ssl
checkCert: true
}
Timer {
id: autoSyncTimer
interval: appSettings.autoSyncInterval * 1000

View file

@ -16,7 +16,7 @@ Dialog {
serverField.text = value("server", "https://", String)
usernameField.text = value("username", "", String)
passwordField.text = value("password", "", String)
//unsecureConnectionTextSwitch.checked = value("unencryptedConnection", false, Boolean)
unsecureConnectionTextSwitch.checked = value("unencryptedConnection", false, Boolean)
unencryptedConnectionTextSwitch.checked = value("allowUnencryptedConnection", false, Boolean)
}
}
@ -27,7 +27,7 @@ Dialog {
account.setValue("server", serverField.text)
account.setValue("username", usernameField.text)
account.setValue("password", passwordField.text)
//account.setValue("unsecureConnection", unsecureConnectionTextSwitch.checked)
account.setValue("unsecureConnection", unsecureConnectionTextSwitch.checked)
account.setValue("allowUnencryptedConnection", unencryptedConnectionTextSwitch.checked)
account.sync()
api.uuid = accountId
@ -121,11 +121,12 @@ Dialog {
color: Theme.secondaryColor
text: qsTr("<strong>CAUTION: Your password will be saved without any encryption on the device!</strong><br>Please consider creating a dedicated app password! Open your Nextcloud in a browser and go to <i>Settings</i> → <i>Security</i>.")
}
/*TextSwitch {
TextSwitch {
id: unsecureConnectionTextSwitch
text: qsTr("Do not check certificates")
description: qsTr("Enable this option to allow selfsigned certificates")
}*/
checked: account.value("allowUnencryptedConnection", false, Boolean)
}
TextSwitch {
id: unencryptedConnectionTextSwitch
automaticCheck: false

View file

@ -1,5 +1,5 @@
import "../js/showdown-1.9.0/dist/showdown.js" as ShowDown
import QtQuick 2.0
import QtQuick 2.4
import Sailfish.Silica 1.0
Dialog {
@ -12,15 +12,17 @@ Dialog {
property var converter: new showdown.Converter(
{ simplifiedAutoLink: true,
excludeTrailingPunctuationFromURLs: true,
parseImgDimensions: true,
strikethrough: true,
tables: true,
tasklists: false, // this is handled by the function parseContent() because LinkedLabel HTML support is to basic
parseImgDimensions: true,
smoothLivePreview: true,
simpleLineBreaks: true,
emoji: true } )
acceptDestination: Qt.resolvedUrl("EditPage.qml")
acceptDestinationProperties: { note: note }
onAccepted: {
acceptDestinationInstance.note = note
acceptDestinationInstance.reloadContent()
@ -70,7 +72,8 @@ Dialog {
occurence++
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 + "'>")
convertedText = convertedText.replace(/<table>/gmi, "<table border='1' cellpadding='" + Theme.paddingMedium + "'>")
convertedText = convertedText.replace(/<hr \/>/gmi, "---")
contentLabel.text = "<style>\n" +
"ul,ol,table,img { margin: " + Theme.paddingLarge + "px 0px; }\n" +
"a:link { color: " + Theme.primaryColor + "; }\n" +
@ -79,7 +82,7 @@ Dialog {
"del { text-decoration: line-through; }\n" +
"table { border-color: " + Theme.secondaryColor + "; }\n" +
"</style>\n" + convertedText
//console.log(contentLabel.text)
if (debug) console.log(contentLabel.text)
}
SilicaFlickable {
@ -104,7 +107,7 @@ Dialog {
MenuItem {
text: enabled ? qsTr("Reload") : qsTr("Updating...")
enabled: !api.busy
onClicked: api.getNoteFromApi(note.id)
onClicked: api.getNoteFromApi(noteID)
}
MenuLabel {
visible: appSettings.currentAccount.length >= 0
@ -120,13 +123,14 @@ Dialog {
title: note.title
acceptText: qsTr("Edit")
cancelText: qsTr("Notes")
}
BusyIndicator {
parent: dialogHeader.extraContent
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
size: BusyIndicatorSize.Medium
running: api.busy
}
}
Column {
width: parent.width

View file

@ -54,7 +54,8 @@ Page {
SearchField {
id: searchField
width: parent.width
placeholderText: api.name
enabled: appSettings.accountIDs.count > 0
placeholderText: api.name.length > 0 ? api.name : qsTr("Nextcloud Notes")
EnterKey.iconSource: "image://theme/icon-m-enter-close"
EnterKey.onClicked: focus = false
onTextChanged: noteListModel.searchText = text
@ -63,6 +64,7 @@ Page {
id: description
x: Theme.horizontalPageMargin
width: parent.width - 2*x
visible: appSettings.accountIDs.count > 0
anchors.bottom: parent.bottom
anchors.bottomMargin: Theme.paddingMedium
color: Theme.secondaryHighlightColor

View file

@ -14,6 +14,8 @@
* Mon Dec 17 2018 Scharel Clemens <harbour-nextcloudnotes@scharel.name> 0.2-8
- Some changes in the backgend
- Fixed #39
- Workaround for #40
* Wed Dec 12 2018 Scharel Clemens <harbour-nextcloudnotes@scharel.name> 0.2-7
- Implementing #18: Page with Markdown syntax

View file

@ -1,5 +1,7 @@
#include <QtQuick>
#include <sailfishapp.h>
#include <QObject>
#include "sslconfiguration.h"
int main(int argc, char *argv[])
{
@ -11,6 +13,7 @@ int main(int argc, char *argv[])
app->setOrganizationName("harbour-nextcloudnotes");
qDebug() << app->applicationDisplayName() << app->applicationVersion();
qmlRegisterType<SslConfiguration>("SslConfiguration", 1, 0, "SslConfiguration");
QQuickView* view = SailfishApp::createView();

22
src/sslconfiguration.cpp Normal file
View file

@ -0,0 +1,22 @@
#include "sslconfiguration.h"
#include <QDebug>
SslConfiguration::SslConfiguration(QObject *parent) : QObject(parent), _checkCert(true) {
checkCertConfig = noCheckConfig = QSslConfiguration::defaultConfiguration();
noCheckConfig.setPeerVerifyMode(QSslSocket::VerifyNone);
QSslConfiguration::setDefaultConfiguration(checkCertConfig);
}
bool SslConfiguration::checkCert() {
return _checkCert;
}
void SslConfiguration::setCheckCert(bool check) {
if (_checkCert != check) {
qDebug() << "Changing SSL Cert check to" << check;
_checkCert = check;
emit checkCertChanged(_checkCert);
QSslConfiguration::setDefaultConfiguration(_checkCert ? checkCertConfig : noCheckConfig);
}
}

28
src/sslconfiguration.h Normal file
View file

@ -0,0 +1,28 @@
#ifndef SSLCONFIGURATION_H
#define SSLCONFIGURATION_H
#include <QObject>
#include <QSslConfiguration>
#include <QSslSocket>
class SslConfiguration : public QObject
{
Q_OBJECT
Q_PROPERTY(bool checkCert READ checkCert WRITE setCheckCert NOTIFY checkCertChanged)
public:
explicit SslConfiguration(QObject *parent = nullptr);
public slots:
bool checkCert();
void setCheckCert(bool check);
signals:
void checkCertChanged(bool check);
private:
bool _checkCert;
QSslConfiguration checkCertConfig;
QSslConfiguration noCheckConfig;
};
#endif // SSLCONFIGURATION_H

View file

@ -147,6 +147,14 @@
<source></source>
<translation></translation>
</message>
<message>
<source>Do not check certificates</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable this option to allow selfsigned certificates</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MITLicense</name>
@ -286,6 +294,10 @@
<source>Open the settings to configure your Nextcloud accounts</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Nextcloud Notes</source>
<translation type="unfinished">Nextcloud Notizen</translation>
</message>
</context>
<context>
<name>SettingsPage</name>

View file

@ -147,6 +147,14 @@
<source>Allow unencrypted connections</source>
<translation>Tillåt okrypterade anslutningar</translation>
</message>
<message>
<source>Do not check certificates</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable this option to allow selfsigned certificates</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MITLicense</name>
@ -286,6 +294,10 @@
<source>Open the settings to configure your Nextcloud accounts</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Nextcloud Notes</source>
<translation type="unfinished">Nextcloud Notes</translation>
</message>
</context>
<context>
<name>SettingsPage</name>

View file

@ -170,7 +170,17 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/LoginDialog.qml" line="132"/>
<location filename="../qml/pages/LoginDialog.qml" line="126"/>
<source>Do not check certificates</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/LoginDialog.qml" line="127"/>
<source>Enable this option to allow selfsigned certificates</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/LoginDialog.qml" line="133"/>
<source>Allow unencrypted connections</source>
<translation type="unfinished"></translation>
</message>
@ -191,17 +201,17 @@
<context>
<name>NoteDelegateModel</name>
<message>
<location filename="../qml/components/NoteDelegateModel.qml" line="192"/>
<location filename="../qml/components/NoteDelegateModel.qml" line="201"/>
<source>Modified</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/components/NoteDelegateModel.qml" line="195"/>
<location filename="../qml/components/NoteDelegateModel.qml" line="204"/>
<source>Delete</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/components/NoteDelegateModel.qml" line="197"/>
<location filename="../qml/components/NoteDelegateModel.qml" line="206"/>
<source>Deleting note</source>
<translation type="unfinished"></translation>
</message>
@ -209,52 +219,52 @@
<context>
<name>NotePage</name>
<message>
<location filename="../qml/pages/NotePage.qml" line="101"/>
<location filename="../qml/pages/NotePage.qml" line="104"/>
<source>Delete</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotePage.qml" line="105"/>
<location filename="../qml/pages/NotePage.qml" line="108"/>
<source>Reload</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotePage.qml" line="105"/>
<location filename="../qml/pages/NotePage.qml" line="108"/>
<source>Updating...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotePage.qml" line="111"/>
<location filename="../qml/pages/NotePage.qml" line="114"/>
<source>Last update</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotePage.qml" line="114"/>
<location filename="../qml/pages/NotePage.qml" line="117"/>
<source>never</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotePage.qml" line="121"/>
<location filename="../qml/pages/NotePage.qml" line="124"/>
<source>Edit</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotePage.qml" line="122"/>
<location filename="../qml/pages/NotePage.qml" line="125"/>
<source>Notes</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotePage.qml" line="241"/>
<location filename="../qml/pages/NotePage.qml" line="245"/>
<source>No category</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotePage.qml" line="242"/>
<location filename="../qml/pages/NotePage.qml" line="246"/>
<source>Category</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotePage.qml" line="257"/>
<location filename="../qml/pages/NotePage.qml" line="261"/>
<source>Modified</source>
<translation type="unfinished"></translation>
</message>
@ -262,17 +272,17 @@
<context>
<name>NotesApi</name>
<message>
<location filename="../qml/components/NotesApi.qml" line="145"/>
<location filename="../qml/components/NotesApi.qml" line="148"/>
<source>Unable to connect</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/components/NotesApi.qml" line="281"/>
<location filename="../qml/components/NotesApi.qml" line="284"/>
<source>Today</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/components/NotesApi.qml" line="283"/>
<location filename="../qml/components/NotesApi.qml" line="286"/>
<source>Yesterday</source>
<translation type="unfinished"></translation>
</message>
@ -310,42 +320,47 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="106"/>
<location filename="../qml/pages/NotesPage.qml" line="58"/>
<source>Nextcloud Notes</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="108"/>
<source>No account yet</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="107"/>
<location filename="../qml/pages/NotesPage.qml" line="109"/>
<source>Got to the settings to add an account</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="113"/>
<location filename="../qml/pages/NotesPage.qml" line="115"/>
<source>No notes yet</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="114"/>
<location filename="../qml/pages/NotesPage.qml" line="116"/>
<source>Pull down to add a note</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="120"/>
<location filename="../qml/pages/NotesPage.qml" line="122"/>
<source>No result</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="121"/>
<location filename="../qml/pages/NotesPage.qml" line="123"/>
<source>Try another query</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="127"/>
<location filename="../qml/pages/NotesPage.qml" line="129"/>
<source>An error occurred</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="138"/>
<location filename="../qml/pages/NotesPage.qml" line="140"/>
<source>Open the settings to configure your Nextcloud accounts</source>
<translation type="unfinished"></translation>
</message>