Cover support for DarkOnLight themes, new icon, began to implement new API version

This commit is contained in:
Scharel Clemens 2020-05-25 08:05:16 +02:00
parent 3ff56872c0
commit 1c77cd57fc
13 changed files with 106 additions and 60 deletions

View file

@ -27,6 +27,8 @@ SOURCES += src/harbour-nextcloudnotes.cpp \
DISTFILES += qml/harbour-nextcloudnotes.qml \
qml/cover/CoverPage.qml \
qml/img/nextcloud-logo-dark.png \
qml/img/nextcloud-logo-light.png \
qml/pages/LoginPage.qml \
rpm/harbour-nextcloudnotes.changes.run.in \
rpm/harbour-nextcloudnotes.changes \

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View file

@ -4,7 +4,7 @@ import Sailfish.Silica 1.0
CoverBackground {
CoverPlaceholder {
icon.source: "../img/nextcloud-logo-transparent.png"
icon.source: Theme.colorScheme === Theme.DarkOnLight ? "../img/nextcloud-logo-dark.png" : "../img/nextcloud-logo-light.png"
icon.width: parent.width
icon.fillMode: Image.PreserveAspectFit
text: qsTr("Notes")

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

View file

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -26,10 +26,8 @@ int main(int argc, char *argv[])
notesProxyModel->setFilterRole(NotesModel::ContentRole);
notesProxyModel->setSourceModel(notesModel);
//NotesStore* notesStore = new NotesStore;
NotesApi* notesApi = new NotesApi;
notesModel->setNotesApi(notesApi);
//notesModel->setNotesStore(notesStore);
QQuickView* view = SailfishApp::createView();
#ifdef QT_DEBUG
@ -39,7 +37,6 @@ int main(int argc, char *argv[])
#endif
view->rootContext()->setContextProperty("notesModel", notesModel);
view->rootContext()->setContextProperty("notesProxyModel", notesProxyModel);
//view->rootContext()->setContextProperty("notesStore", notesStore);
view->rootContext()->setContextProperty("notesApi", notesApi);
view->setSource(SailfishApp::pathTo("qml/harbour-nextcloudnotes.qml"));
@ -48,7 +45,6 @@ int main(int argc, char *argv[])
int retval = app->exec();
notesApi->deleteLater();
//notesStore->deleteLater();
notesProxyModel->deleteLater();
notesModel->deleteLater();
return retval;

View file

@ -12,6 +12,7 @@ NotesApi::NotesApi(const QString statusEndpoint, const QString loginEndpoint, co
// TODO verify connections (also in destructor)
m_loginPollTimer.setInterval(POLL_INTERVALL);
connect(&m_loginPollTimer, SIGNAL(timeout()), this, SLOT(pollLoginUrl()));
setCababilitiesStatus(CapabilitiesStatus::CapabilitiesUnknown);
setNcStatusStatus(NextcloudStatus::NextcloudUnknown);
setLoginStatus(LoginStatus::LoginUnknown);
m_ncStatusStatus = NextcloudStatus::NextcloudUnknown;
@ -29,6 +30,7 @@ NotesApi::NotesApi(const QString statusEndpoint, const QString loginEndpoint, co
m_request.setHeader(QNetworkRequest::UserAgentHeader, QGuiApplication::applicationDisplayName() + " " + QGuiApplication::applicationVersion() + " - " + QSysInfo::machineHostName());
m_request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/x-www-form-urlencoded").toUtf8());
m_request.setRawHeader("OCS-APIREQUEST", "true");
m_request.setRawHeader("Accept", "application/json");
m_authenticatedRequest = m_request;
m_authenticatedRequest.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/json").toUtf8());
}
@ -374,6 +376,8 @@ void NotesApi::replyFinished(QNetworkReply *reply) {
emit noteError(CommunicationError);
QByteArray data = reply->readAll();
//qDebug() << data;
qDebug() << reply->rawHeader("X-Notes-API-Versions");
QJsonDocument json = QJsonDocument::fromJson(data);
if (m_getAllNotesReplies.contains(reply)) {
@ -488,21 +492,25 @@ QUrl NotesApi::apiEndpointUrl(const QString endpoint) const {
}
void NotesApi::updateNcStatus(const QJsonObject &status) {
if (m_status_installed != status.value("installed").toBool()) {
m_status_installed = status.value("installed").toBool();
bool tmpStatus = status.value("installed").toBool();
if (m_status_installed != tmpStatus) {
m_status_installed = tmpStatus;
emit statusInstalledChanged(m_status_installed);
}
if (m_status_maintenance != status.value("maintenance").toBool()) {
m_status_maintenance = status.value("maintenance").toBool();
bool tmpMaintenance = status.value("maintenance").toBool();
if (m_status_maintenance != tmpMaintenance) {
m_status_maintenance = tmpMaintenance;
emit statusMaintenanceChanged(m_status_maintenance);
}
if (m_status_needsDbUpgrade != status.value("needsDbUpgrade").toBool()) {
m_status_needsDbUpgrade = status.value("needsDbUpgrade").toBool();
bool tmpNeedsDbUpgrade = status.value("needsDbUpgrade").toBool();
if (m_status_needsDbUpgrade != tmpNeedsDbUpgrade) {
m_status_needsDbUpgrade = tmpNeedsDbUpgrade;
emit statusNeedsDbUpgradeChanged(m_status_needsDbUpgrade);
}
if (m_status_version != status.value("version").toString()) {
m_status_version = status.value("version").toString();
emit statusVersionChanged(m_status_version);
QVersionNumber tmpVersion = QVersionNumber::fromString(status.value("version").toString());
if (m_status_version != tmpVersion) {
m_status_version = tmpVersion;
emit statusVersionChanged(m_status_version.toString());
}
if (m_status_versionstring != status.value("versionstring").toString()) {
m_status_versionstring = status.value("versionstring").toString();
@ -526,6 +534,15 @@ void NotesApi::updateNcStatus(const QJsonObject &status) {
setNcStatusStatus(NextcloudStatus::NextcloudSuccess);
}
void NotesApi::setCababilitiesStatus(CapabilitiesStatus status, bool *changed) {
if (status != m_capabilitiesStatus) {
if (changed)
*changed = true;
m_capabilitiesStatus = status;
emit capabilitiesStatusChanged(m_capabilitiesStatus);
}
}
void NotesApi::setNcStatusStatus(NextcloudStatus status, bool *changed) {
if (status != m_ncStatusStatus) {
if (changed)

View file

@ -3,6 +3,7 @@
#include <QObject>
#include <QJsonObject>
#include <QVersionNumber>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
@ -15,12 +16,15 @@
#define NOTES_ENDPOINT "/index.php/apps/notes/api/v0.2/notes"
#define OCS_ENDPOINT "/ocs/v1.php/cloud"
#define EXCLUDE_QUERY "exclude="
#define PURGE_QUERY "purgeBefore="
#define ETAG_HEADER "If-None-Match"
#define POLL_INTERVALL 5000
class NotesApi : public QObject
{
Q_OBJECT
// Generic API properties
Q_PROPERTY(bool verifySsl READ verifySsl WRITE setVerifySsl NOTIFY verifySslChanged)
Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
Q_PROPERTY(QString server READ server WRITE setServer NOTIFY serverChanged)
@ -31,11 +35,20 @@ class NotesApi : public QObject
Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged)
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
// Status information
Q_PROPERTY(bool urlValid READ urlValid NOTIFY urlValidChanged)
Q_PROPERTY(bool networkAccessible READ networkAccessible NOTIFY networkAccessibleChanged)
Q_PROPERTY(QDateTime lastSync READ lastSync NOTIFY lastSyncChanged)
Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
// Nextcloud capabilities
Q_PROPERTY(CapabilitiesStatus capabilitiesStatus READ capabilitiesStatus NOTIFY capabilitiesStatusChanged)
//Q_PROPERTY(bool notesAppInstalled READ notesAppInstalled NOTIFY notesAppInstalledChanged)
//Q_PROPERTY(QStringList notesAppApiVersions READ notesAppApiVersions NOTIFY notesAppApiVersionsChanged)
//Q_PROPERTY(QString notesAppApiMaxVersion READ notesAppApiMaxVersion NOTIFY notesAppApiMaxVersionChanged)
//Q_PROPERTY(QString notesAppApiMinVersion READ notesAppApiMinVersion NOTIFY notesAppApiMinVersionChanged)
// Nextcloud status (status.php)
Q_PROPERTY(NextcloudStatus ncStatusStatus READ ncStatusStatus NOTIFY ncStatusStatusChanged)
Q_PROPERTY(bool statusInstalled READ statusInstalled NOTIFY statusInstalledChanged)
Q_PROPERTY(bool statusMaintenance READ statusMaintenance NOTIFY statusMaintenanceChanged)
@ -46,6 +59,7 @@ class NotesApi : public QObject
Q_PROPERTY(QString statusProductName READ statusProductName NOTIFY statusProductNameChanged)
Q_PROPERTY(bool statusExtendedSupport READ statusExtendedSupport NOTIFY statusExtendedSupportChanged)
// Login status
Q_PROPERTY(LoginStatus loginStatus READ loginStatus NOTIFY loginStatusChanged)
Q_PROPERTY(QUrl loginUrl READ loginUrl NOTIFY loginUrlChanged)
@ -57,6 +71,34 @@ public:
QObject *parent = nullptr);
virtual ~NotesApi();
enum CapabilitiesStatus {
CapabilitiesUnknown, // Initial unknown state
CapabilitiesBusy, // Gettin information
CapabilitiesSuccess, // Capabilities successfully read
CapabilitiesStatusFailed // Faild to retreive capabilities
};
Q_ENUM(CapabilitiesStatus)
enum NextcloudStatus {
NextcloudUnknown, // Initial unknown state
NextcloudBusy, // Getting information from the nextcloud server
NextcloudSuccess, // Got information about the nextcloud server
NextcloudFailed // Error getting information from the nextcloud server, see error()
};
Q_ENUM(NextcloudStatus)
enum LoginStatus {
LoginUnknown, // Inital unknown state
LoginLegacyReady, // Ready for legacy login
LoginFlowV2Initiating, // Initiating login flow v2
LoginFlowV2Polling, // Ready for login flow v2
LoginFlowV2Success, // Finished login flow v2
LoginFlowV2Failed, // An error in login flow v2
LoginSuccess, // Login has been verified successfull
LoginFailed // Login has failed, see error()
};
Q_ENUM(LoginStatus)
bool verifySsl() const { return m_authenticatedRequest.sslConfiguration().peerVerifyMode() == QSslSocket::VerifyPeer; }
void setVerifySsl(bool verify);
@ -92,30 +134,13 @@ public:
bool busy() const;
enum NextcloudStatus {
NextcloudUnknown, // Nothing known about the nextcloud server
NextcloudBusy, // Getting information from the nextcloud server
NextcloudSuccess, // Got information about the nextcloud server
NextcloudFailed // Error getting information from the nextcloud server, see error()
};
Q_ENUM(NextcloudStatus)
enum LoginStatus {
LoginUnknown, // Inital unknown state
LoginLegacyReady, // Ready for legacy login
LoginFlowV2Initiating, // Initiating login flow v2
LoginFlowV2Polling, // Ready for login flow v2
LoginFlowV2Success, // Finished login flow v2
LoginFlowV2Failed, // An error in login flow v2
LoginSuccess, // Login has been verified successfull
LoginFailed // Login has failed, see error()
};
Q_ENUM(LoginStatus)
CapabilitiesStatus capabilitiesStatus() const { return m_capabilitiesStatus; }
NextcloudStatus ncStatusStatus() const { return m_ncStatusStatus; }
bool statusInstalled() const { return m_status_installed; }
bool statusMaintenance() const { return m_status_maintenance; }
bool statusNeedsDbUpgrade() const { return m_status_needsDbUpgrade; }
QString statusVersion() const { return m_status_version; }
QString statusVersion() const { return m_status_version.toString(); }
QString statusVersionString() const { return m_status_versionstring; }
QString statusEdition() const { return m_status_edition; }
QString statusProductName() const { return m_status_productname; }
@ -169,6 +194,8 @@ signals:
void lastSyncChanged(QDateTime lastSync);
void busyChanged(bool busy);
void capabilitiesStatusChanged(CapabilitiesStatus status);
void ncStatusStatusChanged(NextcloudStatus status);
void statusInstalledChanged(bool installed);
void statusMaintenanceChanged(bool maintenance);
@ -204,6 +231,9 @@ private:
QNetworkRequest m_ocsRequest;
QUrl apiEndpointUrl(const QString endpoint) const;
CapabilitiesStatus m_capabilitiesStatus;
void setCababilitiesStatus(CapabilitiesStatus status, bool *changed = NULL);
// Nextcloud status.php
const QString m_statusEndpoint;
QVector<QNetworkReply*> m_statusReplies;
@ -213,7 +243,8 @@ private:
bool m_status_installed;
bool m_status_maintenance;
bool m_status_needsDbUpgrade;
QString m_status_version;
QVersionNumber m_status_version;
//QString m_status_version;
QString m_status_versionstring;
QString m_status_edition;
QString m_status_productname;
@ -238,6 +269,7 @@ private:
// Nextcloud Notes API - https://github.com/nextcloud/notes/wiki/Notes-0.2
const QString m_notesEndpoint;
QVersionNumber m_notesApiVersion;
QVector<QNetworkReply*> m_getAllNotesReplies;
QVector<QNetworkReply*> m_getNoteReplies;
QVector<QNetworkReply*> m_createNoteReplies;

View file

@ -103,7 +103,6 @@ signals:
private:
const static QHash<int, QByteArray> m_roleNames;
//QMap<int, QFile> m_files;
QDir m_fileDir;
const static QString m_fileSuffix;

View file

@ -316,32 +316,32 @@
<context>
<name>NotesApi</name>
<message>
<location filename="../src/notesapi.cpp" line="325"/>
<location filename="../src/notesapi.cpp" line="327"/>
<source>No error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/notesapi.cpp" line="328"/>
<location filename="../src/notesapi.cpp" line="330"/>
<source>No network connection available</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/notesapi.cpp" line="331"/>
<location filename="../src/notesapi.cpp" line="333"/>
<source>Failed to communicate with the Nextcloud server</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/notesapi.cpp" line="334"/>
<location filename="../src/notesapi.cpp" line="336"/>
<source>An error occured while establishing an encrypted connection</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/notesapi.cpp" line="337"/>
<location filename="../src/notesapi.cpp" line="339"/>
<source>Could not authenticate to the Nextcloud instance</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/notesapi.cpp" line="340"/>
<location filename="../src/notesapi.cpp" line="342"/>
<source>Unknown error</source>
<translation type="unfinished"></translation>
</message>
@ -349,97 +349,97 @@
<context>
<name>NotesPage</name>
<message>
<location filename="../qml/pages/NotesPage.qml" line="32"/>
<location filename="../qml/pages/NotesPage.qml" line="30"/>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="36"/>
<location filename="../qml/pages/NotesPage.qml" line="34"/>
<source>Add note</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="41"/>
<location filename="../qml/pages/NotesPage.qml" line="39"/>
<source>Reload</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="41"/>
<location filename="../qml/pages/NotesPage.qml" line="39"/>
<source>Updating...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="47"/>
<location filename="../qml/pages/NotesPage.qml" line="45"/>
<source>Last update</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="50"/>
<location filename="../qml/pages/NotesPage.qml" line="48"/>
<source>never</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="60"/>
<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="191"/>
<location filename="../qml/pages/NotesPage.qml" line="187"/>
<source>Modified</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="194"/>
<location filename="../qml/pages/NotesPage.qml" line="190"/>
<source>Delete</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="196"/>
<location filename="../qml/pages/NotesPage.qml" line="192"/>
<source>Deleting note</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="226"/>
<location filename="../qml/pages/NotesPage.qml" line="222"/>
<source>Loading notes...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="232"/>
<location filename="../qml/pages/NotesPage.qml" line="228"/>
<source>No account yet</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="233"/>
<location filename="../qml/pages/NotesPage.qml" line="229"/>
<source>Got to the settings to add an account</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="239"/>
<location filename="../qml/pages/NotesPage.qml" line="235"/>
<source>No notes yet</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="240"/>
<location filename="../qml/pages/NotesPage.qml" line="236"/>
<source>Pull down to add a note</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="246"/>
<location filename="../qml/pages/NotesPage.qml" line="242"/>
<source>No result</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="247"/>
<location filename="../qml/pages/NotesPage.qml" line="243"/>
<source>Try another query</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="253"/>
<location filename="../qml/pages/NotesPage.qml" line="249"/>
<source>An error occurred</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/NotesPage.qml" line="264"/>
<location filename="../qml/pages/NotesPage.qml" line="260"/>
<source>Open the settings to configure your Nextcloud accounts</source>
<translation type="unfinished"></translation>
</message>