Merge branch 'master' of github.com:QuasarApp/QuasarAppLib

This commit is contained in:
Andrei Yankovich 2020-04-25 14:48:49 +03:00
commit 7b413c0539
5 changed files with 40 additions and 9 deletions

2
CMake

@ -1 +1 @@
Subproject commit 0607c96b6268279b89fc209a7d2ca8c1a4447678 Subproject commit f8aab94740ca94298591cc3f0f1ea5c236d84451

View File

@ -5,10 +5,23 @@
# of this license document, but changing it is not allowed. # of this license document, but changing it is not allowed.
# #
if(DEFINED QUASARAPP_LIBRARY)
return()
else()
set(QUASARAPP_LIBRARY 1)
add_definitions(-DQUASARAPP_LIBRARY)
endif()
project(QuasarApp LANGUAGES CXX)
if(TARGET ${PROJECT_NAME})
message("The ${PROJECT_NAME} arledy included in main Project")
return()
endif()
cmake_minimum_required(VERSION 3.1) cmake_minimum_required(VERSION 3.1)
include(CMake/crossplatform/crossplatform.cmake) include(CMake/crossplatform/crossplatform.cmake)
project(QuasarApp LANGUAGES CXX)
include(CMake/ProjectOut.cmake) include(CMake/ProjectOut.cmake)
include(CMake/ccache.cmake) include(CMake/ccache.cmake)

View File

@ -20,11 +20,15 @@
#include <limits.h> #include <limits.h>
#endif #endif
#define APP_PATH "appPath"
#define APP_NAME "appName"
using namespace QuasarAppUtils; using namespace QuasarAppUtils;
static QVariantMap params = QVariantMap(); static QVariantMap params = QVariantMap();
static int _argc = 0; static int _argc = 0;
bool Params::isEndable(const QString& key) { bool Params::isEndable(const QString& key) {
return params.contains(key); return params.contains(key);
} }
@ -87,6 +91,14 @@ void Params::showHelp() {
Help::print(getparamsHelp()); Help::print(getparamsHelp());
} }
QVariantMap Params::getUserParamsMap() {
auto result = params;
result.remove(APP_PATH);
result.remove(APP_NAME);
return result;
}
int Params::size() { int Params::size() {
return params.size(); return params.size();
} }
@ -129,7 +141,7 @@ std::string Params::lvlToString(VerboseLvl vLvl) {
bool Params::writeLoginFile(const QString &log, VerboseLvl vLvl) { bool Params::writeLoginFile(const QString &log, VerboseLvl vLvl) {
if (isEndable("fileLog")) { if (isEndable("fileLog")) {
QString path = getStrArg("appPath") + "/" + getStrArg("appName") + ".log"; QString path = getStrArg(APP_PATH) + "/" + getStrArg(APP_NAME) + ".log";
auto file = getStrArg("fileLog"); auto file = getStrArg("fileLog");
if (file.size()) { if (file.size()) {
QString path = file; QString path = file;
@ -174,8 +186,8 @@ bool Params::parseParams(const QStringList &paramsArray) {
memset(buffer, 0, sizeof buffer); memset(buffer, 0, sizeof buffer);
GetModuleFileNameA(nullptr, buffer, MAX_PATH); GetModuleFileNameA(nullptr, buffer, MAX_PATH);
params ["appPath"] = QFileInfo(buffer).absolutePath(); params [APP_PATH] = QFileInfo(buffer).absolutePath();
params ["appName"] = QFileInfo(buffer).fileName(); params [APP_NAME] = QFileInfo(buffer).fileName();
#else #else
char path[2048]; char path[2048];
@ -186,12 +198,12 @@ bool Params::parseParams(const QStringList &paramsArray) {
QuasarAppUtils::Error); QuasarAppUtils::Error);
return false; return false;
} }
params ["appPath"] = QFileInfo(path).absolutePath(); params [APP_PATH] = QFileInfo(path).absolutePath();
params ["appName"] = QFileInfo(path).fileName(); params [APP_NAME] = QFileInfo(path).fileName();
#endif #endif
if (!getStrArg("appPath").size()) { if (!getStrArg(APP_PATH).size()) {
return false; return false;
} }

View File

@ -142,6 +142,12 @@ public:
* @brief showHelp - show base help section of QuasarAppLib * @brief showHelp - show base help section of QuasarAppLib
*/ */
static void showHelp(); static void showHelp();
/**
* @brief getUserParamsMap
* @return QVariantMap with user params
*/
static QVariantMap getUserParamsMap();
}; };
} }

View File

@ -3,7 +3,7 @@
#include <QtCore/qglobal.h> #include <QtCore/qglobal.h>
#if defined(QUASARAAPP_LIBRARY) #if defined(QUASARAPP_LIBRARY)
# define QUASARAPPSHARED_EXPORT Q_DECL_EXPORT # define QUASARAPPSHARED_EXPORT Q_DECL_EXPORT
#else #else
# define QUASARAPPSHARED_EXPORT Q_DECL_IMPORT # define QUASARAPPSHARED_EXPORT Q_DECL_IMPORT