From dee1a69cf00b65073e1bbadb0e80864e86361ceb Mon Sep 17 00:00:00 2001 From: EndrII Date: Sat, 11 Aug 2018 18:09:56 +0300 Subject: [PATCH] lib version 1.0.0 --- .gitignore | 3 ++ QuasarLib.pri | 20 +++++++++++++ QuasarLibDepends.pri | 17 +++++++++++ QuasaraApp.pro | 50 ++++++++++++++++++++++++++++++++ quasaraapp.cpp | 62 ++++++++++++++++++++++++++++++++++++++++ quasaraapp.h | 68 ++++++++++++++++++++++++++++++++++++++++++++ quasaraapp_global.h | 12 ++++++++ res.qrc | 5 ++++ res/languages/en.qm | 0 9 files changed, 237 insertions(+) create mode 100644 QuasarLib.pri create mode 100644 QuasarLibDepends.pri create mode 100644 QuasaraApp.pro create mode 100644 quasaraapp.cpp create mode 100644 quasaraapp.h create mode 100644 quasaraapp_global.h create mode 100644 res.qrc create mode 100755 res/languages/en.qm diff --git a/.gitignore b/.gitignore index 5291a38..903365d 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,6 @@ target_wrapper.* # QtCreator CMake CMakeLists.txt.user* + +build/* +*.user* diff --git a/QuasarLib.pri b/QuasarLib.pri new file mode 100644 index 0000000..bbdd17f --- /dev/null +++ b/QuasarLib.pri @@ -0,0 +1,20 @@ +# +# Copyright (C) 2018 QuasarApp. +# Distributed under the lgplv3 software license, see the accompanying +# Everyone is permitted to copy and distribute verbatim copies +# of this license document, but changing it is not allowed. +# + +!isEmpty(QUASARAPP_LIB):error("QuasarLib.pri already included") +QUASARAPP_LIB = 1 + +#DEPENDS +CONFIG(debug, debug|release): { + OUTPUT_DIR_QUASARAPP = "$$PWD/build/debug/bin" +} else: { + OUTPUT_DIR_QUASARAPP = "$$PWD/build/release/bin" +} + +LIBS += -L"$$OUTPUT_DIR_QUASARAPP/" -lQuasaraApp + +INCLUDEPATH += "$$PWD/" diff --git a/QuasarLibDepends.pri b/QuasarLibDepends.pri new file mode 100644 index 0000000..268fd34 --- /dev/null +++ b/QuasarLibDepends.pri @@ -0,0 +1,17 @@ + + +win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/./release/ -lQuasaraApp +else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/./debug/ -lQuasaraApp +else:unix: LIBS += -L$$OUT_PWD/./ -lQuasaraApp + +INCLUDEPATH += $$PWD/. +DEPENDPATH += $$PWD/. + + +!isEmpty(QUASARAPP_LIB):error("QuasarLib.pri already included") +QUASARAPP_LIB = 1 + +#DEPENDS +include($$PWD/NodusDB_depends.pri) + +INCLUDEPATH += "$$PWD/" diff --git a/QuasaraApp.pro b/QuasaraApp.pro new file mode 100644 index 0000000..4a53b0f --- /dev/null +++ b/QuasaraApp.pro @@ -0,0 +1,50 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2018-07-24T20:32:41 +# +#------------------------------------------------- + +QT -= gui + +TARGET = QuasaraApp +TEMPLATE = lib + +DEFINES += QUASARAAPP_LIBRARY + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + + +CONFIG(debug, debug|release): { + DESTDIR = "$$PWD/build/debug" +} else: { + DESTDIR = "$$PWD/build/release" +} + +SOURCES += \ + quasaraapp.cpp + +HEADERS += \ + quasaraapp.h \ + quasaraapp_global.h + +unix { + target.path = /usr/lib + INSTALLS += target +} + +DISTFILES += \ + QuasarLib.pri + +RESOURCES += \ + res.qrc + + diff --git a/quasaraapp.cpp b/quasaraapp.cpp new file mode 100644 index 0000000..07b3778 --- /dev/null +++ b/quasaraapp.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2018 QuasarApp. + * Distributed under the lgplv3 software license, see the accompanying + * Everyone is permitted to copy and distribute verbatim copies + * of this license document, but changing it is not allowed. +*/ + +#include "quasaraapp.h" +#include +#include +#include +#include + +static QVariantMap params = QVariantMap(); + +bool QuasaraAppUtils::parseParams(int argc, char *argv[]) { + params.clear(); + params ["appPath"] = argv[0]; + + for (int i = 1; i < argc; i++) { + if (argv[i][0] == '-' && i ) { + if (i < (argc - 1) && argv[i + 1][0] != '-') { + params[&(argv[i][1])] = argv[i + 1]; + i++; + } else { + qDebug() << "Missing argument for " + QString(argv[i]) ; + } + } else { + params[argv[i]] = ""; + } + } + + return true; +} + +QString QuasaraAppUtils::getStr(const QString& key) { + return params.value(key, "").toString(); +} + +QVariant QuasaraAppUtils::get(const QString& key) { + return params.value(key, ""); +} + +bool QuasaraAppUtils::isEndable(const QString& key) { + return params.contains(key); +} + +bool initLocale(const QString &locale, QCoreApplication *app, QTranslator *translator){ + + QString defaultLocale = QLocale::system().name(); + defaultLocale.truncate(defaultLocale.lastIndexOf('_')); + + if(!locale.isEmpty() && translator->load(QString(":/languages/%0").arg(locale))){ + return app->installTranslator(translator); + } + + if(!translator->load(QString(":/languages/%0").arg(defaultLocale))){ + return false; + } + + return app->installTranslator(translator); +} diff --git a/quasaraapp.h b/quasaraapp.h new file mode 100644 index 0000000..9f8a59e --- /dev/null +++ b/quasaraapp.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2018 QuasarApp. + * Distributed under the lgplv3 software license, see the accompanying + * Everyone is permitted to copy and distribute verbatim copies + * of this license document, but changing it is not allowed. +*/ + +#ifndef QUASARAAPP_H +#define QUASARAAPP_H + +#include "quasaraapp_global.h" +#include + + +class QGuiApplication; +class QTranslator; + +/** + * @brief The QuasaraAppUtils class + * this lib include base functions for the all applications of QuasarApp group. + * all methods of the Quasar AppUtils is static + */ +class QUASARAAPPSHARED_EXPORT QuasaraAppUtils +{ + +public: + QuasaraAppUtils() = delete; + + /** + * @brief parseParams - parase input data of started application + * @param argc - count of arguments + * @param argv - arrat of arguments + * @return true if all arguments read else false + */ + static bool parseParams(int argc, char *argv[]); + + /** + * @brief getStrArg - get string value of key + * @param key + * @return string value of argument + */ + static QString getStrArg(const QString& key); + + /** + * @brief getArg - get string value of key + * @param key + * @return string value of argument + */ + static QVariant getArg(const QString& key); + + /** + * @brief isEndable - check if enable argument of key + * @param key + * @return true if argument enabled + */ + static bool isEndable(const QString& key); + + /** + * @brief initLocale init translation of applictaion + * @param locale - string value of locale. example (en) + * @param app - app core of qt + * @param translator - translator core of qt + * @return return true if locale funded + */ + static bool initLocale(const QString &locale, QGuiApplication* app, QTranslator *translator); +}; + +#endif // QUASARAAPP_H diff --git a/quasaraapp_global.h b/quasaraapp_global.h new file mode 100644 index 0000000..23eb4c7 --- /dev/null +++ b/quasaraapp_global.h @@ -0,0 +1,12 @@ +#ifndef QUASARAAPP_GLOBAL_H +#define QUASARAAPP_GLOBAL_H + +#include + +#if defined(QUASARAAPP_LIBRARY) +# define QUASARAAPPSHARED_EXPORT Q_DECL_EXPORT +#else +# define QUASARAAPPSHARED_EXPORT Q_DECL_IMPORT +#endif + +#endif // QUASARAAPP_GLOBAL_H diff --git a/res.qrc b/res.qrc new file mode 100644 index 0000000..c9cd32a --- /dev/null +++ b/res.qrc @@ -0,0 +1,5 @@ + + + res/languages/en.qm + + diff --git a/res/languages/en.qm b/res/languages/en.qm new file mode 100755 index 0000000..e69de29