chore: import files to project

This commit is contained in:
qsaker 2023-09-19 18:42:14 +08:00
parent ebbef4e269
commit 7da3365f39
3 changed files with 123 additions and 0 deletions

View File

@ -272,3 +272,4 @@ add_compile_definitions(SAK_COMMIT_DATE="${LAST_COMMIT_DATE}")
add_subdirectory(src)
add_subdirectory(deploy)
add_subdirectory(resources/translations)
add_subdirectory(src/guiapp)

24
src/guiapp/CMakeLists.txt Normal file
View File

@ -0,0 +1,24 @@
file(
GLOB
EASY_DEBUG_SOURCES
"src/common/common/*.h"
"src/common/common/*.cc"
"src/toolbox/toolbox/*.h"
"src/toolbox/toolbox/*.cc"
"src/tools/tools/*.hh"
"src/tools/tools/*.cc"
"src/guiapp/*.h"
"src/guiapp/*.cc")
set(EASY_DEBUG_APP_SOURCES ${EASY_DEBUG_SOURCES})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/EasyDebug")
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(EasyDebug MANUAL_FINALIZATION ${EASY_DEBUG_APP_SOURCES})
else()
if(ANDROID)
add_library(EasyDebug SHARED ${EASY_DEBUG_APP_SOURCES})
else()
add_executable(EasyDebug ${EASY_DEBUG_APP_SOURCES})
endif(ANDROID)
endif()

98
src/guiapp/main.cc Normal file
View File

@ -0,0 +1,98 @@
/******************************************************************************
* Copyright 2018-2023 Qsaker(qsaker@foxmail.com). All rights reserved.
*
* The file is encoded using "utf8 with bom", it is a part
* of QtSwissArmyKnife project.
*
* QtSwissArmyKnife is licensed according to the terms in
* the file LICENCE in the root of the source code directory.
*****************************************************************************/
#include <QFile>
#include <QLoggingCategory>
#include <QStyleFactory>
#include "SAKApplication.h"
#include "SAKInterface.h"
#include "SAKLog.h"
#include "SAKSettings.h"
#ifdef SAK_IMPORT_MODULE_QML
#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
#include "SAKGuiApplication.h"
#endif
#endif
int main(int argc, char* argv[]) {
#ifndef QT_DEBUG
qInstallMessageHandler(SAKLog::messageOutput);
#endif
// Initialize some information about application.
QCoreApplication::setOrganizationName(QString("Qsaker"));
QCoreApplication::setOrganizationDomain(QString("IT"));
#ifdef SAK_RELEASE_FOR_APP_STORE
QCoreApplication::setApplicationName(QString("QtSwissArmyKnife"));
#else
QCoreApplication::setApplicationName(QString("QtSwissArmyKnife(Community)"));
#endif
#ifdef SAK_VERSION
QCoreApplication::setApplicationVersion(SAK_VERSION);
#else
QCoreApplication::setApplicationVersion("0.0.0");
#endif
QLoggingCategory lc{"SAK.Main"};
// Remove settings file and database
if (SAKSettings::instance()->clearSettings()) {
SAKSettings::instance()->setClearSettings(false);
if (QFile::remove(SAKSettings::instance()->fileName())) {
qCInfo(lc) << "Remove settings file successfully.";
} else {
qCWarning(lc) << "Remove settings file failed!";
}
}
qCInfo(lc) << "Supported style:" << QStyleFactory::keys();
// High dpi settings.
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
int policy = SAKSettings::instance()->hdpiPolicy();
if (SAKInterface::isQtHighDpiScalePolicy(policy)) {
auto cookedPolicy = Qt::HighDpiScaleFactorRoundingPolicy(policy);
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(cookedPolicy);
}
#endif
#ifdef SAK_IMPORT_MODULE_QML
int uiType = SAKSettings::instance()->uiType();
#else
int ui_type = SAKSettings::UiTypeWidget;
#endif
// Startup application.
if (ui_type == SAKSettings::UiTypeWidget) {
QString style = SAKSettings::instance()->appStyle();
if (!style.isEmpty() && QStyleFactory::keys().contains(style)) {
qCInfo(lc) << "App style:" << style;
QApplication::setStyle(QStyleFactory::create(style));
}
SAKApplication app(argc, argv);
SAKLog::instance()->start();
return app.exec();
}
#ifdef SAK_IMPORT_MODULE_QML
#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
SAKGuiApplication app(argc, argv);
SAKLog::instance()->start();
return app.exec();
#else
SAKSettings::instance()->setUiType(SAKSettings::UiTypeWidget);
qCInfo(lc) << "To using qml ui, please using qt 6.4.0 or later!";
return 0;
#endif
#endif
return 0;
}