mirror of
https://github.com/QuasarApp/QuasarAppLib.git
synced 2025-04-26 01:34:39 +00:00
lib version 1.0.0
This commit is contained in:
parent
230a77c033
commit
dee1a69cf0
3
.gitignore
vendored
3
.gitignore
vendored
@ -41,3 +41,6 @@ target_wrapper.*
|
||||
|
||||
# QtCreator CMake
|
||||
CMakeLists.txt.user*
|
||||
|
||||
build/*
|
||||
*.user*
|
||||
|
20
QuasarLib.pri
Normal file
20
QuasarLib.pri
Normal file
@ -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/"
|
17
QuasarLibDepends.pri
Normal file
17
QuasarLibDepends.pri
Normal file
@ -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/"
|
50
QuasaraApp.pro
Normal file
50
QuasaraApp.pro
Normal file
@ -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
|
||||
|
||||
|
62
quasaraapp.cpp
Normal file
62
quasaraapp.cpp
Normal file
@ -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 <QVariantMap>
|
||||
#include <QDebug>
|
||||
#include <QCoreApplication>
|
||||
#include <QTranslator>
|
||||
|
||||
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);
|
||||
}
|
68
quasaraapp.h
Normal file
68
quasaraapp.h
Normal file
@ -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 <QVariant>
|
||||
|
||||
|
||||
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
|
12
quasaraapp_global.h
Normal file
12
quasaraapp_global.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef QUASARAAPP_GLOBAL_H
|
||||
#define QUASARAAPP_GLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#if defined(QUASARAAPP_LIBRARY)
|
||||
# define QUASARAAPPSHARED_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
# define QUASARAAPPSHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif // QUASARAAPP_GLOBAL_H
|
5
res.qrc
Normal file
5
res.qrc
Normal file
@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/languages">
|
||||
<file alias="en">res/languages/en.qm</file>
|
||||
</qresource>
|
||||
</RCC>
|
0
res/languages/en.qm
Executable file
0
res/languages/en.qm
Executable file
Loading…
x
Reference in New Issue
Block a user