You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-16 00:14:34 +02:00
Added sync button
This commit is contained in:
@ -56,7 +56,8 @@ HEADERS += \
|
|||||||
models/basemodel.h \
|
models/basemodel.h \
|
||||||
enum.h \
|
enum.h \
|
||||||
models/setting.h \
|
models/setting.h \
|
||||||
paths.h
|
paths.h \
|
||||||
|
constants.h
|
||||||
|
|
||||||
DISTFILES += \
|
DISTFILES += \
|
||||||
AndroidManifest.xml
|
AndroidManifest.xml
|
||||||
|
@ -9,13 +9,14 @@
|
|||||||
#include "uuid.h"
|
#include "uuid.h"
|
||||||
#include "dispatcher.h"
|
#include "dispatcher.h"
|
||||||
#include "paths.h"
|
#include "paths.h"
|
||||||
|
#include "constants.h"
|
||||||
|
|
||||||
using namespace jop;
|
using namespace jop;
|
||||||
|
|
||||||
Application::Application(int &argc, char **argv) :
|
Application::Application(int &argc, char **argv) :
|
||||||
QGuiApplication(argc, argv),
|
QGuiApplication(argc, argv),
|
||||||
db_(jop::db()),
|
db_(jop::db()),
|
||||||
api_("http://joplin.local"),
|
api_(jop::API_BASE_URL),
|
||||||
//api_("https://joplin.cozic.net"),
|
//api_("https://joplin.cozic.net"),
|
||||||
synchronizer_(api_.baseUrl(), db_),
|
synchronizer_(api_.baseUrl(), db_),
|
||||||
folderModel_(db_)
|
folderModel_(db_)
|
||||||
@ -25,9 +26,9 @@ Application::Application(int &argc, char **argv) :
|
|||||||
// This is linked to where the QSettings will be saved. In other words,
|
// This is linked to where the QSettings will be saved. In other words,
|
||||||
// if these values are changed, the settings will be reset and saved
|
// if these values are changed, the settings will be reset and saved
|
||||||
// somewhere else.
|
// somewhere else.
|
||||||
QCoreApplication::setOrganizationName("Cozic");
|
QCoreApplication::setOrganizationName(jop::ORG_NAME);
|
||||||
QCoreApplication::setOrganizationDomain("cozic.net");
|
QCoreApplication::setOrganizationDomain(jop::ORG_DOMAIN);
|
||||||
QCoreApplication::setApplicationName("Joplin");
|
QCoreApplication::setApplicationName(jop::APP_NAME);
|
||||||
|
|
||||||
qDebug() << "Config dir:" << paths::configDir();
|
qDebug() << "Config dir:" << paths::configDir();
|
||||||
qDebug() << "Database file:" << paths::databaseFile();
|
qDebug() << "Database file:" << paths::databaseFile();
|
||||||
@ -51,6 +52,7 @@ Application::Application(int &argc, char **argv) :
|
|||||||
connect(rootObject, SIGNAL(currentFolderChanged()), this, SLOT(view_currentFolderChanged()));
|
connect(rootObject, SIGNAL(currentFolderChanged()), this, SLOT(view_currentFolderChanged()));
|
||||||
connect(rootObject, SIGNAL(currentNoteChanged()), this, SLOT(view_currentNoteChanged()));
|
connect(rootObject, SIGNAL(currentNoteChanged()), this, SLOT(view_currentNoteChanged()));
|
||||||
connect(rootObject, SIGNAL(addFolderButtonClicked()), this, SLOT(view_addFolderButtonClicked()));
|
connect(rootObject, SIGNAL(addFolderButtonClicked()), this, SLOT(view_addFolderButtonClicked()));
|
||||||
|
connect(rootObject, SIGNAL(syncButtonClicked()), this, SLOT(view_syncButtonClicked()));
|
||||||
|
|
||||||
connect(&dispatcher(), SIGNAL(folderCreated(QString)), this, SLOT(dispatcher_folderCreated(QString)));
|
connect(&dispatcher(), SIGNAL(folderCreated(QString)), this, SLOT(dispatcher_folderCreated(QString)));
|
||||||
connect(&dispatcher(), SIGNAL(folderUpdated(QString)), this, SLOT(dispatcher_folderUpdated(QString)));
|
connect(&dispatcher(), SIGNAL(folderUpdated(QString)), this, SLOT(dispatcher_folderUpdated(QString)));
|
||||||
@ -58,7 +60,7 @@ Application::Application(int &argc, char **argv) :
|
|||||||
|
|
||||||
view_.show();
|
view_.show();
|
||||||
|
|
||||||
synchronizerTimer_.setInterval(1000 * 10);
|
synchronizerTimer_.setInterval(1000 * 120);
|
||||||
synchronizerTimer_.start();
|
synchronizerTimer_.start();
|
||||||
|
|
||||||
connect(&synchronizerTimer_, SIGNAL(timeout()), this, SLOT(synchronizerTimer_timeout()));
|
connect(&synchronizerTimer_, SIGNAL(timeout()), this, SLOT(synchronizerTimer_timeout()));
|
||||||
@ -168,3 +170,7 @@ void Application::view_addFolderButtonClicked() {
|
|||||||
|
|
||||||
//qDebug() << "Added" << q.lastInsertId().toString();
|
//qDebug() << "Added" << q.lastInsertId().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::view_syncButtonClicked() {
|
||||||
|
synchronizer_.start();
|
||||||
|
}
|
||||||
|
@ -43,6 +43,8 @@ public slots:
|
|||||||
void view_currentNoteChanged();
|
void view_currentNoteChanged();
|
||||||
void view_addNoteButtonClicked();
|
void view_addNoteButtonClicked();
|
||||||
void view_addFolderButtonClicked();
|
void view_addFolderButtonClicked();
|
||||||
|
void view_syncButtonClicked();
|
||||||
|
|
||||||
void api_requestDone(const QJsonObject& response, const QString& tag);
|
void api_requestDone(const QJsonObject& response, const QString& tag);
|
||||||
|
|
||||||
void dispatcher_folderCreated(const QString& folderId);
|
void dispatcher_folderCreated(const QString& folderId);
|
||||||
|
15
QtClient/JoplinQtClient/constants.h
Executable file
15
QtClient/JoplinQtClient/constants.h
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#ifndef CONSTANTS_H
|
||||||
|
#define CONSTANTS_H
|
||||||
|
|
||||||
|
#include <stable.h>
|
||||||
|
|
||||||
|
namespace jop {
|
||||||
|
|
||||||
|
const QString ORG_NAME = "Cozic";
|
||||||
|
const QString ORG_DOMAIN = "cozic.net";
|
||||||
|
const QString APP_NAME = "Joplin";
|
||||||
|
const QString API_BASE_URL = "https://joplin.cozic.net";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // CONSTANTS_H
|
@ -11,6 +11,7 @@ Item {
|
|||||||
signal currentNoteChanged()
|
signal currentNoteChanged()
|
||||||
signal addNoteButtonClicked()
|
signal addNoteButtonClicked()
|
||||||
signal addFolderButtonClicked()
|
signal addFolderButtonClicked()
|
||||||
|
signal syncButtonClicked()
|
||||||
property alias currentFolderIndex: folderList.currentIndex
|
property alias currentFolderIndex: folderList.currentIndex
|
||||||
property alias currentNoteIndex: noteList.currentIndex
|
property alias currentNoteIndex: noteList.currentIndex
|
||||||
|
|
||||||
@ -91,4 +92,12 @@ Item {
|
|||||||
onAddNoteButtonClicked: root.addNoteButtonClicked()
|
onAddNoteButtonClicked: root.addNoteButtonClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
id: syncButton
|
||||||
|
text: "Sync"
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: parent.top
|
||||||
|
onClicked: root.syncButtonClicked()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ Synchronizer::Synchronizer(const QString &apiUrl, Database &database) : api_(api
|
|||||||
qDebug() << api_.baseUrl();
|
qDebug() << api_.baseUrl();
|
||||||
state_ = Idle;
|
state_ = Idle;
|
||||||
uploadsRemaining_ = 0;
|
uploadsRemaining_ = 0;
|
||||||
//downloadsRemaining_ = 0;
|
|
||||||
connect(&api_, SIGNAL(requestDone(QJsonObject,QString)), this, SLOT(api_requestDone(QJsonObject,QString)));
|
connect(&api_, SIGNAL(requestDone(QJsonObject,QString)), this, SLOT(api_requestDone(QJsonObject,QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,13 +52,6 @@ void Synchronizer::checkNextState() {
|
|||||||
case DownloadingChanges:
|
case DownloadingChanges:
|
||||||
|
|
||||||
switchState(Idle);
|
switchState(Idle);
|
||||||
|
|
||||||
// if (downloadsRemaining_ < 0) qCritical() << "Mismatch on download operations done" << downloadsRemaining_;
|
|
||||||
|
|
||||||
// if (downloadsRemaining_ <= 0) {
|
|
||||||
// downloadsRemaining_ = 0;
|
|
||||||
// switchState(Idle);
|
|
||||||
// }
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Idle:
|
case Idle:
|
||||||
|
@ -27,7 +27,6 @@ private:
|
|||||||
Database& db_;
|
Database& db_;
|
||||||
SynchronizationState state_;
|
SynchronizationState state_;
|
||||||
int uploadsRemaining_;
|
int uploadsRemaining_;
|
||||||
int downloadsRemaining_;
|
|
||||||
void checkNextState();
|
void checkNextState();
|
||||||
void switchState(SynchronizationState state);
|
void switchState(SynchronizationState state);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user