1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-27 08:21:03 +02:00

Setup for CLI app

This commit is contained in:
Laurent Cozic 2017-01-27 20:26:46 +00:00
parent 99666740e8
commit 2fbbdbdb34
6 changed files with 77 additions and 3 deletions

View File

@ -44,7 +44,8 @@ SOURCES += \
paths.cpp \
window.cpp \
filters.cpp \
models/abstractlistmodel.cpp
models/abstractlistmodel.cpp \
cliapplication.cpp
RESOURCES += qml.qrc \
database.qrc
@ -81,7 +82,8 @@ HEADERS += \
constants.h \
window.h \
filters.h \
models/abstractlistmodel.h
models/abstractlistmodel.h \
cliapplication.h
defined(JOP_FRONT_END_GUI, var) {
SOURCES += application.cpp

View File

@ -0,0 +1,41 @@
#include <stab.h>
#include "cliapplication.h"
#include "constants.h"
#include "database.h"
#include "paths.h"
#include "uuid.h"
#include "settings.h"
namespace jop {
CliApplication::CliApplication(int &argc, char **argv) : QCoreApplication(argc, argv) {
// 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
// somewhere else.
QCoreApplication::setOrganizationName(jop::ORG_NAME);
QCoreApplication::setOrganizationDomain(jop::ORG_DOMAIN);
QCoreApplication::setApplicationName(jop::APP_NAME);
qInfo() << "Config dir:" << paths::configDir();
qInfo() << "Database file:" << paths::databaseFile();
qInfo() << "SSL:" << QSslSocket::sslLibraryBuildVersionString() << QSslSocket::sslLibraryVersionNumber();
jop::db().initialize(paths::databaseFile());
Settings::initialize();
Settings settings;
if (!settings.contains("clientId")) {
// Client ID should be unique per instance of a program
settings.setValue("clientId", uuid::createUuid());
}
}
int CliApplication::exec() {
qDebug() << "exec";
return 0;
}
}

View File

@ -0,0 +1,19 @@
#ifndef CLIAPPLICATION_H
#define CLIAPPLICATION_H
#include <stable.h>
namespace jop {
class CliApplication : public QCoreApplication {
public:
CliApplication(int &argc, char **argv);
int exec();
};
}
#endif // CLIAPPLICATION_H

View File

@ -9,6 +9,12 @@ const QString ORG_NAME = "Cozic";
const QString ORG_DOMAIN = "cozic.net";
const QString APP_NAME = "Joplin";
#if defined(JOP_FRONT_END_CLI)
const QString FRONT_END = "cli";
#elif defined(JOP_FRONT_END_GUI)
const QString FRONT_END = "gui";
#endif
}
#endif // CONSTANTS_H

View File

@ -1,6 +1,11 @@
#include <stable.h>
#if defined(JOP_FRONT_END_CLI)
#include "cliapplication.h"
#elif defined(JOP_FRONT_END_GUI)
#include "application.h"
#endif
#include "models/folder.h"
#include "database.h"
#include "models/foldermodel.h"
@ -26,7 +31,7 @@ int main(int argc, char *argv[]) {
#endif
#ifdef JOP_FRONT_END_CLI
QCoreApplication app(argc, argv);
CliApplication app(argc, argv);
#endif
return app.exec();

View File

@ -6,6 +6,7 @@
#include <memory>
#include <QAbstractListModel>
#include <QCoreApplication>
#include <QGuiApplication>
#include <QDebug>
#include <QFileInfo>