Changed on the QML side to adopt the previous changes on the C++ side
This commit is contained in:
parent
84d720c7ca
commit
8211acbe51
10 changed files with 87 additions and 58 deletions
|
@ -39,12 +39,12 @@ Page {
|
|||
}
|
||||
}
|
||||
|
||||
onStatusChanged: {
|
||||
/*onStatusChanged: {
|
||||
if (status === PageStatus.Activating)
|
||||
notesApi.getNcStatus()
|
||||
if (status === PageStatus.Deactivating)
|
||||
notesApi.abortFlowV2Login()
|
||||
}
|
||||
}*/
|
||||
|
||||
Connections {
|
||||
target: notesApi
|
||||
|
@ -85,27 +85,27 @@ Page {
|
|||
}
|
||||
onLoginStatusChanged: {
|
||||
switch(notesApi.loginStatus) {
|
||||
case NotesApi.LoginLegacyReady:
|
||||
case notesApi.LoginLegacyReady:
|
||||
apiProgressBar.label = qsTr("Enter your credentials")
|
||||
break;
|
||||
//case NotesApi.LoginFlowV2Initiating:
|
||||
//case notesApi.LoginFlowV2Initiating:
|
||||
// break;
|
||||
case NotesApi.LoginFlowV2Polling:
|
||||
case notesApi.LoginFlowV2Polling:
|
||||
apiProgressBar.label = qsTr("Follow the instructions in the browser")
|
||||
break;
|
||||
case NotesApi.LoginFlowV2Success:
|
||||
case notesApi.LoginFlowV2Success:
|
||||
notesApi.verifyLogin()
|
||||
break;
|
||||
case NotesApi.LoginFlowV2Failed:
|
||||
case notesApi.LoginFlowV2Failed:
|
||||
apiProgressBar.label = qsTr("Login failed!")
|
||||
break
|
||||
case NotesApi.LoginSuccess:
|
||||
case notesApi.LoginSuccess:
|
||||
apiProgressBar.label = qsTr("Login successfull!")
|
||||
account.username = notesApi.username
|
||||
account.password = notesApi.password
|
||||
appSettings.currentAccount = accountId
|
||||
break;
|
||||
case NotesApi.LoginFailed:
|
||||
case notesApi.LoginFailed:
|
||||
apiProgressBar.label = qsTr("Login failed!")
|
||||
break;
|
||||
default:
|
||||
|
@ -155,8 +155,8 @@ Page {
|
|||
id: apiProgressBar
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: parent.width
|
||||
indeterminate: notesApi.loginStatus === NotesApi.LoginFlowV2Initiating ||
|
||||
notesApi.loginStatus === NotesApi.LoginFlowV2Polling
|
||||
indeterminate: notesApi.loginStatus === notesApi.LoginFlowV2Initiating ||
|
||||
notesApi.loginStatus === notesApi.LoginFlowV2Polling
|
||||
}
|
||||
|
||||
Row {
|
||||
|
@ -171,15 +171,17 @@ Page {
|
|||
onClicked: if (text === "") text = "https://"
|
||||
onTextChanged: {
|
||||
statusBusyIndicatorTimer.restart()
|
||||
if (acceptableInput)
|
||||
if (acceptableInput) {
|
||||
notesApi.server = text
|
||||
notesApi.getNcStatus()
|
||||
}
|
||||
}
|
||||
//EnterKey.enabled: text.length > 0
|
||||
EnterKey.iconSource: legacyLoginPossible ? "image://theme/icon-m-enter-next" : flowLoginV2Possible ? "image://theme/icon-m-enter-accept" : "image://theme/icon-m-enter-close"
|
||||
EnterKey.onClicked: {
|
||||
if (legacyLoginPossible)
|
||||
usernameField.focus = true
|
||||
else if (flowLoginV2Possible && notesApi.loginStatus !== NotesApi.LoginFlowV2Polling)
|
||||
else if (flowLoginV2Possible && notesApi.loginStatus !== notesApi.LoginFlowV2Polling)
|
||||
notesApi.initiateFlowV2Login()
|
||||
focus = false
|
||||
}
|
||||
|
@ -191,7 +193,7 @@ Page {
|
|||
BusyIndicator {
|
||||
anchors.centerIn: parent
|
||||
size: BusyIndicatorSize.Medium
|
||||
running: notesApi.ncStatusStatus === NotesApi.NextcloudBusy || (serverField.focus && statusBusyIndicatorTimer.running && !notesApi.statusInstalled)
|
||||
running: notesApi.ncStatusStatus === notesApi.NextcloudBusy || (serverField.focus && statusBusyIndicatorTimer.running && !notesApi.statusInstalled)
|
||||
Timer {
|
||||
id: statusBusyIndicatorTimer
|
||||
interval: 200
|
||||
|
@ -200,17 +202,28 @@ Page {
|
|||
}
|
||||
}
|
||||
|
||||
TextSwitch {
|
||||
id: forceLegacyButton
|
||||
text: qsTr("Enforce legacy login")
|
||||
onCheckedChanged: {
|
||||
checked != checked
|
||||
if (!checked) {
|
||||
notesApi.getNcStatus()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
id: flowv2LoginColumn
|
||||
width: parent.width
|
||||
spacing: Theme.paddingLarge
|
||||
visible: opacity !== 0.0
|
||||
opacity: flowLoginV2Possible ? 1.0 : 0.0
|
||||
opacity: flowLoginV2Possible && !forceLegacyButton.checked ? 1.0 : 0.0
|
||||
Behavior on opacity { FadeAnimator {} }
|
||||
Button {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: notesApi.loginStatus === NotesApi.LoginFlowV2Polling ? qsTr("Abort") : notesApi.loginStatus === NotesApi.LoginSuccess ? qsTr("Re-Login") : qsTr("Login")
|
||||
onClicked: notesApi.loginStatus === NotesApi.LoginFlowV2Polling ? notesApi.abortFlowV2Login() : notesApi.initiateFlowV2Login()
|
||||
text: notesApi.loginStatus === notesApi.LoginFlowV2Polling ? qsTr("Abort") : notesApi.loginStatus === notesApi.LoginSuccess ? qsTr("Re-Login") : qsTr("Login")
|
||||
onClicked: notesApi.loginStatus === notesApi.LoginFlowV2Polling ? notesApi.abortFlowV2Login() : notesApi.initiateFlowV2Login()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,7 +231,7 @@ Page {
|
|||
id: legacyLoginColumn
|
||||
width: parent.width
|
||||
visible: opacity !== 0.0
|
||||
opacity: legacyLoginPossible ? 1.0 : 0.0
|
||||
opacity: legacyLoginPossible || forceLegacyButton.checked ? 1.0 : 0.0
|
||||
Behavior on opacity { FadeAnimator {} }
|
||||
TextField {
|
||||
id: usernameField
|
||||
|
|
|
@ -5,9 +5,17 @@ import "../js/showdown/dist/showdown.js" as ShowDown
|
|||
Dialog {
|
||||
id: noteDialog
|
||||
|
||||
property int index
|
||||
property var note: notesProxyModel.getNote(notesProxyModel.index(index, 0))
|
||||
|
||||
property int id
|
||||
//property var note: notesProxyModel.getNote(notesProxyModel.index(index, 0))
|
||||
property var note: notesModel.getNoteById(id)
|
||||
Connections {
|
||||
target: notesModel
|
||||
onNoteUpdated: {
|
||||
if (id === noteDialog.id) {
|
||||
noteDialog.note = note
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property var showdown: ShowDown.showdown
|
||||
property var converter: new showdown.Converter(
|
||||
|
|
|
@ -106,7 +106,7 @@ Page {
|
|||
id: remorse
|
||||
}
|
||||
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("../pages/NotePage.qml"), { index: index } )
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("../pages/NotePage.qml"), { id: id } )
|
||||
onPressAndHold: menu.open(note)
|
||||
|
||||
Separator {
|
||||
|
|
|
@ -32,17 +32,6 @@ int main(int argc, char *argv[])
|
|||
notesModel->setNotesApi(notesApi);
|
||||
notesModel->setNotesStore(notesStore);
|
||||
|
||||
//QObject::connect(notesApi, SIGNAL(allNotesReceived(QList<int>)), notesModel, SLOT());
|
||||
//QObject::connect(notesApi, SIGNAL(noteCreated(int,QJsonObject)), notesModel, SLOT(insertNoteFromApi(int,QJsonObject)));
|
||||
//QObject::connect(notesApi, SIGNAL(noteUpdated(int,QJsonObject)), notesModel, SLOT(updateNoteFromApi(int,QJsonObject)));
|
||||
//QObject::connect(notesApi, SIGNAL(noteDeleted(int)), notesModel, SLOT(removeNoteFromApi(int)));
|
||||
|
||||
//QObject::connect(notesApi, SIGNAL(noteUpdated(int,QJsonObject)), notesStore, SLOT(updateNote(int,QJsonObject)));
|
||||
//QObject::connect(notesApi, SIGNAL(noteDeleted(int)), notesStore, SLOT(deleteNote(int)));
|
||||
|
||||
//QObject::connect(notesStore, SIGNAL(noteUpdated(int,QJsonObject)), notesModel, SLOT(updateNoteFromStore(int,QJsonObject)));
|
||||
//QObject::connect(notesStore, SIGNAL(noteDeleted(int)), notesModel, SLOT(removeNoteFromStore(int)));
|
||||
|
||||
QQuickView* view = SailfishApp::createView();
|
||||
#ifdef QT_DEBUG
|
||||
view->rootContext()->setContextProperty("debug", QVariant(true));
|
||||
|
|
|
@ -245,11 +245,11 @@ void NotesApi::setPath(QString path) {
|
|||
|
||||
bool NotesApi::getNcStatus() {
|
||||
QUrl url = apiEndpointUrl(m_statusEndpoint);
|
||||
qDebug() << "POST" << url.toDisplayString();
|
||||
qDebug() << "GET" << url.toDisplayString();
|
||||
if (url.isValid() && !url.scheme().isEmpty() && !url.host().isEmpty()) {
|
||||
setNcStatusStatus(NextcloudStatus::NextcloudBusy);
|
||||
m_request.setUrl(url);
|
||||
m_statusReplies << m_manager.post(m_request, QByteArray());
|
||||
m_statusReplies << m_manager.get(m_request);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -130,6 +130,10 @@ void NotesModel::setAccount(const QString &account) {
|
|||
mp_notesStore->setAccount(account);
|
||||
}
|
||||
|
||||
const QJsonObject NotesModel::getNoteById(const int id) const {
|
||||
return m_notes[id];
|
||||
}
|
||||
|
||||
bool NotesModel::getAllNotes(const QStringList &exclude) {
|
||||
bool success = true;
|
||||
if (mp_notesApi)
|
||||
|
|
|
@ -72,6 +72,8 @@ public:
|
|||
QString account() const;
|
||||
void setAccount(const QString& account);
|
||||
|
||||
const QJsonObject getNoteById(const int id) const;
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE bool getAllNotes(const QStringList& exclude = QStringList());
|
||||
Q_INVOKABLE bool getNote(const int id, const QStringList& exclude = QStringList());
|
||||
|
|
|
@ -190,6 +190,10 @@
|
|||
<source>Re-Login</source>
|
||||
<translation>Neu einloggen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Enforce legacy login</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MITLicense</name>
|
||||
|
|
|
@ -190,6 +190,10 @@
|
|||
<source>Re-Login</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Enforce legacy login</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MITLicense</name>
|
||||
|
|
|
@ -143,17 +143,17 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="226"/>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="239"/>
|
||||
<source>Username</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="237"/>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="250"/>
|
||||
<source>Password</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="212"/>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="225"/>
|
||||
<source>Abort</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -179,52 +179,57 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="212"/>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="207"/>
|
||||
<source>Enforce legacy login</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="225"/>
|
||||
<source>Login</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="212"/>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="225"/>
|
||||
<source>Re-Login</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="246"/>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="259"/>
|
||||
<source>Test Login</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="252"/>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="265"/>
|
||||
<source>Note</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="260"/>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="273"/>
|
||||
<source>The <a href="https://apps.nextcloud.com/apps/notes">Notes</a> app needs to be installed on the Nextcloud server for this app to work.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="264"/>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="277"/>
|
||||
<source>Security</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="271"/>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="284"/>
|
||||
<source><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>.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="275"/>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="288"/>
|
||||
<source>Do not check certificates</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="276"/>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="289"/>
|
||||
<source>Enable this option to allow selfsigned certificates</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="285"/>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="298"/>
|
||||
<source>Allow unencrypted connections</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -258,52 +263,52 @@
|
|||
<context>
|
||||
<name>NotePage</name>
|
||||
<message>
|
||||
<location filename="../qml/pages/NotePage.qml" line="117"/>
|
||||
<location filename="../qml/pages/NotePage.qml" line="125"/>
|
||||
<source>Delete</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/NotePage.qml" line="121"/>
|
||||
<location filename="../qml/pages/NotePage.qml" line="129"/>
|
||||
<source>Reload</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/NotePage.qml" line="121"/>
|
||||
<location filename="../qml/pages/NotePage.qml" line="129"/>
|
||||
<source>Updating...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/NotePage.qml" line="127"/>
|
||||
<location filename="../qml/pages/NotePage.qml" line="135"/>
|
||||
<source>Last update</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/NotePage.qml" line="130"/>
|
||||
<location filename="../qml/pages/NotePage.qml" line="138"/>
|
||||
<source>never</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/NotePage.qml" line="137"/>
|
||||
<location filename="../qml/pages/NotePage.qml" line="145"/>
|
||||
<source>Edit</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/NotePage.qml" line="138"/>
|
||||
<location filename="../qml/pages/NotePage.qml" line="146"/>
|
||||
<source>Notes</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/NotePage.qml" line="258"/>
|
||||
<location filename="../qml/pages/NotePage.qml" line="266"/>
|
||||
<source>No category</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/NotePage.qml" line="259"/>
|
||||
<location filename="../qml/pages/NotePage.qml" line="267"/>
|
||||
<source>Category</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/NotePage.qml" line="274"/>
|
||||
<location filename="../qml/pages/NotePage.qml" line="282"/>
|
||||
<source>Modified</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
Loading…
Reference in a new issue