updated application startup
This commit is contained in:
parent
ea6d3c6dfc
commit
8f2bd78b47
|
@ -7,8 +7,7 @@
|
|||
#include <passwordfile/io/field.h>
|
||||
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
|
||||
#include <c++utilities/application/global.h>
|
||||
#include <c++utilities/application/commandlineutils.h>
|
||||
|
||||
#if defined(PLATFORM_UNIX)
|
||||
#include <unistd.h>
|
||||
|
@ -88,7 +87,9 @@ InteractiveCli::InteractiveCli() :
|
|||
m_currentEntry(nullptr),
|
||||
m_modified(false),
|
||||
m_quit(false)
|
||||
{}
|
||||
{
|
||||
CMD_UTILS_START_CONSOLE;
|
||||
}
|
||||
|
||||
void InteractiveCli::run(const string &file)
|
||||
{
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
#ifndef INITIATE_H
|
||||
#define INITIATE_H
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QString;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace QtGui {
|
||||
|
||||
int runWidgetsGui(int argc, char *argv[], const QString &file);
|
||||
|
||||
}
|
||||
|
||||
#endif // INITIATE_H
|
|
@ -0,0 +1,18 @@
|
|||
#ifndef INITIATE_H
|
||||
#define INITIATE_H
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QString)
|
||||
|
||||
namespace ApplicationUtilities {
|
||||
class QtConfigArguments;
|
||||
}
|
||||
|
||||
namespace QtGui {
|
||||
|
||||
int runWidgetsGui(int argc, char *argv[], const ApplicationUtilities::QtConfigArguments &qtConfigArgs, const QString &file);
|
||||
|
||||
}
|
||||
|
||||
#endif // INITIATE_H
|
|
@ -1,25 +1,29 @@
|
|||
#include "initiate.h"
|
||||
#include "initiategui.h"
|
||||
|
||||
# include "gui/mainwindow.h"
|
||||
#include "gui/mainwindow.h"
|
||||
|
||||
#include <qtutilities/resources/qtconfigarguments.h>
|
||||
#include <qtutilities/resources/resources.h>
|
||||
|
||||
#include <QTextCodec>
|
||||
#include <QApplication>
|
||||
#include <QFile>
|
||||
|
||||
using namespace ApplicationUtilities;
|
||||
|
||||
namespace QtGui {
|
||||
|
||||
int runWidgetsGui(int argc, char *argv[], const QString &file)
|
||||
int runWidgetsGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs, const QString &file)
|
||||
{
|
||||
SET_QT_APPLICATION_INFO;
|
||||
// init application
|
||||
QApplication a(argc, argv);
|
||||
// load resources needed by classes of qtutilities
|
||||
QtUtilitiesResources::init();
|
||||
// apply settings specified via command line args
|
||||
qtConfigArgs.applySettings();
|
||||
LOAD_QT_TRANSLATIONS;
|
||||
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
|
||||
// load the other resources
|
||||
QtUtilitiesResources::init();
|
||||
Theme::setup();
|
||||
// init widgets GUI
|
||||
QtGui::MainWindow w;
|
||||
w.show();
|
||||
|
|
17
main.cpp
17
main.cpp
|
@ -1,15 +1,16 @@
|
|||
#include "cli/cli.h"
|
||||
#ifdef GUI_QTWIDGETS
|
||||
# include "gui/initiate.h"
|
||||
# include "gui/initiategui.h"
|
||||
#endif
|
||||
#ifdef GUI_QTQUICK
|
||||
# include "quickgui/initiate.h"
|
||||
# include "quickgui/initiatequick.h"
|
||||
#endif
|
||||
|
||||
#include <passwordfile/util/openssl.h>
|
||||
|
||||
#include <c++utilities/application/argumentparser.h>
|
||||
#include <c++utilities/application/failure.h>
|
||||
#include <c++utilities/application/commandlineutils.h>
|
||||
|
||||
#if defined(GUI_QTWIDGETS) || defined(GUI_QTQUICK)
|
||||
# include <qtutilities/resources/qtconfigarguments.h>
|
||||
|
@ -67,27 +68,31 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
if(qtConfigArgs.qtWidgetsGuiArg().isPresent()) {
|
||||
#ifdef GUI_QTWIDGETS
|
||||
res = QtGui::runWidgetsGui(argc, argv, file);
|
||||
res = QtGui::runWidgetsGui(argc, argv, qtConfigArgs, file);
|
||||
#else
|
||||
CMD_UTILS_START_CONSOLE;
|
||||
cout << "The application has not been built with Qt widgets support." << endl;
|
||||
#endif
|
||||
} else if(qtConfigArgs.qtQuickGuiArg().isPresent()) {
|
||||
#ifdef GUI_QTQUICK
|
||||
res = QtGui::runQuickGui(argc, argv);
|
||||
res = QtGui::runQuickGui(argc, argv, qtConfigArgs);
|
||||
#else
|
||||
CMD_UTILS_START_CONSOLE;
|
||||
cout << "The application has not been built with Qt quick support." << endl;
|
||||
#endif
|
||||
} else {
|
||||
#if defined(GUI_QTQUICK)
|
||||
res = QtGui::runQuickGui(argc, argv);
|
||||
res = QtGui::runQuickGui(argc, argv, qtConfigArgs);
|
||||
#elif defined(GUI_QTWIDGETS)
|
||||
res = QtGui::runWidgetsGui(argc, argv, file);
|
||||
res = QtGui::runWidgetsGui(argc, argv, qtConfigArgs, file);
|
||||
#else
|
||||
CMD_UTILS_START_CONSOLE;
|
||||
cout << "See --help for usage." << endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} catch(Failure &ex) {
|
||||
CMD_UTILS_START_CONSOLE;
|
||||
cout << "Unable to parse arguments. " << ex.what() << "\nSee --help for available commands." << endl;
|
||||
}
|
||||
// clean open ssl
|
||||
|
|
|
@ -56,20 +56,20 @@ HEADERS += model/entrymodel.h \
|
|||
model/fieldmodel.h \
|
||||
model/entryfiltermodel.h \
|
||||
util/testroutines.h \
|
||||
cli/cli.h
|
||||
cli/cli.h \
|
||||
gui/initiategui.h
|
||||
|
||||
guiqtwidgets {
|
||||
HEADERS += gui/mainwindow.h \
|
||||
gui/passwordgeneratordialog.h \
|
||||
gui/undocommands.h \
|
||||
gui/stacksupport.h \
|
||||
gui/initiate.h
|
||||
gui/stacksupport.h
|
||||
}
|
||||
|
||||
guiqtquick {
|
||||
HEADERS += quickgui/applicationinfo.h \
|
||||
quickgui/applicationpaths.h
|
||||
quickgui/initiate.h
|
||||
quickgui/applicationpaths.h \
|
||||
quickgui/initiatequick.h
|
||||
}
|
||||
|
||||
# resources and translations
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
#ifndef QT_QUICK_GUI_INITIATE_H
|
||||
#define QT_QUICK_GUI_INITIATE_H
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QString;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace QtGui {
|
||||
|
||||
int runQuickGui(int argc, char *argv[]);
|
||||
|
||||
}
|
||||
|
||||
#endif // QT_QUICK_GUI_INITIATE_H
|
|
@ -1,11 +1,12 @@
|
|||
#include "initiate.h"
|
||||
#include "initiatequick.h"
|
||||
|
||||
# include "model/entryfiltermodel.h"
|
||||
# include "model/entrymodel.h"
|
||||
# include "model/fieldmodel.h"
|
||||
|
||||
# include "quickgui/applicationinfo.h"
|
||||
#include "quickgui/applicationinfo.h"
|
||||
|
||||
#include <qtutilities/resources/qtconfigarguments.h>
|
||||
#include <qtutilities/resources/resources.h>
|
||||
|
||||
#if defined(GUI_QTWIDGETS)
|
||||
|
@ -19,6 +20,8 @@
|
|||
#include <QQmlApplicationEngine>
|
||||
#include <QDebug>
|
||||
|
||||
using namespace ApplicationUtilities;
|
||||
|
||||
namespace QtGui {
|
||||
|
||||
#if defined(GUI_QTQUICK)
|
||||
|
@ -30,26 +33,21 @@ static QObject *applicationInfo(QQmlEngine *engine, QJSEngine *scriptEngine)
|
|||
}
|
||||
#endif
|
||||
|
||||
int runQuickGui(int argc, char *argv[])
|
||||
int runQuickGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs)
|
||||
{
|
||||
// init application
|
||||
SET_QT_APPLICATION_INFO;
|
||||
#if defined(GUI_QTWIDGETS)
|
||||
QApplication a(argc, argv);
|
||||
#else
|
||||
QGuiApplication a(argc, argv);
|
||||
#endif
|
||||
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
|
||||
QGuiApplication::setOrganizationName(QStringLiteral("Martchus"));
|
||||
QGuiApplication::setOrganizationDomain(QStringLiteral("http://martchus.netai.net/"));
|
||||
QGuiApplication::setApplicationName(QStringLiteral("Password Manager (mobile)"));
|
||||
QGuiApplication::setApplicationVersion(QStringLiteral("2.0.5"));
|
||||
// load translation files
|
||||
TranslationFiles::loadQtTranslationFile();
|
||||
TranslationFiles::loadApplicationTranslationFile(QStringLiteral("passwordmanager"));
|
||||
// load the other resources
|
||||
// load resources needed by classes of qtutilities
|
||||
QtUtilitiesResources::init();
|
||||
Theme::setup();
|
||||
qDebug() << "test 2";
|
||||
// apply settings specified via command line args
|
||||
qtConfigArgs.applySettings();
|
||||
LOAD_QT_TRANSLATIONS;
|
||||
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
|
||||
// init quick GUI
|
||||
qmlRegisterSingletonType<QtGui::ApplicationInfo>("martchus.passwordmanager", 2, 0, "ApplicationInfo", applicationInfo);
|
||||
qmlRegisterType<QtGui::EntryFilterModel>("martchus.passwordmanager", 2, 0, "EntryFilterModel");
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
#ifndef QT_QUICK_GUI_INITIATE_H
|
||||
#define QT_QUICK_GUI_INITIATE_H
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QString)
|
||||
|
||||
namespace ApplicationUtilities {
|
||||
class QtConfigArguments;
|
||||
}
|
||||
|
||||
namespace QtGui {
|
||||
|
||||
int runQuickGui(int argc, char *argv[], const ApplicationUtilities::QtConfigArguments &qtConfigArgs);
|
||||
|
||||
}
|
||||
|
||||
#endif // QT_QUICK_GUI_INITIATE_H
|
Loading…
Reference in New Issue