Commit 0c36a286 authored by KLOCZKO Thibaud's avatar KLOCZKO Thibaud

Need to be terminated.

parent 8472f685
...@@ -72,21 +72,11 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS "ON") ...@@ -72,21 +72,11 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
if(MSVC)
add_definitions("/wd4068")
endif(MSVC)
## ################################################################### ## ###################################################################
## Test setup ## Test setup
## ################################################################### ## ###################################################################
include(CTest) include(CTest)
enable_testing() enable_testing()
## ################################################################### ## ###################################################################
...@@ -99,28 +89,17 @@ include(GenerateExportHeader) ...@@ -99,28 +89,17 @@ include(GenerateExportHeader)
## Dependencies - external ## Dependencies - external
## ################################################################# ## #################################################################
find_package(Qt5 REQUIRED COMPONENTS Core Gui WebSockets Widgets Xml Test) find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets Xml Test)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(dtkCore REQUIRED) find_package(dtkCore REQUIRED)
find_package(dtkFonts REQUIRED) find_package(dtkFonts REQUIRED)
find_package(dtkLog REQUIRED) find_package(dtkLog REQUIRED)
find_package(dtkThemes REQUIRED) find_package(dtkThemes REQUIRED)
include_directories(${dtkCore_INCLUDE_DIRS})
include_directories(${dtkFonts_INCLUDE_DIRS})
include_directories(${dtkLog_INCLUDE_DIRS})
include_directories(${dtkThemes_INCLUDE_DIRS})
## #################################################################
## Dependencies - internal
## #################################################################
include_directories(${CMAKE_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${CMAKE_SOURCE_DIR}/src/dtkWidgets)
include_directories(${CMAKE_SOURCE_DIR}/tst)
include_directories(${CMAKE_SOURCE_DIR}/tst/dtkWidgets)
## ################################################################### ## ###################################################################
## Input ## Input
## ################################################################### ## ###################################################################
...@@ -130,26 +109,43 @@ add_subdirectory(tst) ...@@ -130,26 +109,43 @@ add_subdirectory(tst)
add_subdirectory(exp) add_subdirectory(exp)
## ################################################################### ## ###################################################################
## Exporting ## Export configuration
## ################################################################### ## ###################################################################
export(PACKAGE ${PROJECT_NAME}) include(CMakePackageConfigHelpers)
set(${PROJECT_NAME}_CMAKE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" CACHE
STRING "install path for ${PROJECT_NAME}Config.cmake")
set(${PROJECT_NAME}_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src)
configure_package_config_file(cmake/${PROJECT_NAME}Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION "${${PROJECT_NAME}_CMAKE_INSTALL_DIR}"
PATH_VARS ${PROJECT_NAME}_INCLUDE_DIRS)
set(${PROJECT_NAME}_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include)
configure_package_config_file(cmake/${PROJECT_NAME}Config.cmake.in
${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION "${${PROJECT_NAME}_CMAKE_INSTALL_DIR}"
PATH_VARS ${PROJECT_NAME}_INCLUDE_DIRS)
configure_file(${CMAKE_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}Config.cmake" @ONLY) VERSION ${${PROJECT_NAME}_VERSION}
COMPATIBILITY AnyNewerVersion)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.install.cmake.in ## ###################################################################
"${CMAKE_BINARY_DIR}/install/${PROJECT_NAME}Config.cmake" @ONLY) ## Exporting
## ###################################################################
configure_file(${CMAKE_SOURCE_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake.in install(FILES ${CMAKE_CURRENT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" @ONLY) ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${${PROJECT_NAME}_CMAKE_INSTALL_DIR})
install(FILES install(EXPORT layer-targets
"${CMAKE_BINARY_DIR}/install/${PROJECT_NAME}Config.cmake" FILE ${PROJECT_NAME}Targets.cmake
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" DESTINATION ${${PROJECT_NAME}_CMAKE_INSTALL_DIR})
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
install(EXPORT ${PROJECT_NAME}Depends DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) export(PACKAGE ${PROJECT_NAME})
## ################################################################### ## ###################################################################
## Beautifying ## Beautifying
...@@ -159,6 +155,8 @@ mark_as_advanced(${PROJECT_NAME}_VERSION_MAJOR) ...@@ -159,6 +155,8 @@ mark_as_advanced(${PROJECT_NAME}_VERSION_MAJOR)
mark_as_advanced(${PROJECT_NAME}_VERSION_MINOR) mark_as_advanced(${PROJECT_NAME}_VERSION_MINOR)
mark_as_advanced(${PROJECT_NAME}_VERSION_BUILD) mark_as_advanced(${PROJECT_NAME}_VERSION_BUILD)
mark_as_advanced(${PROJECT_NAME}_CMAKE_INSTALL_DIR)
mark_as_advanced(Qt5_DIR) mark_as_advanced(Qt5_DIR)
mark_as_advanced(Qt5Core_DIR) mark_as_advanced(Qt5Core_DIR)
mark_as_advanced(Qt5Gui_DIR) mark_as_advanced(Qt5Gui_DIR)
...@@ -166,24 +164,16 @@ mark_as_advanced(Qt5OpenGL_DIR) ...@@ -166,24 +164,16 @@ mark_as_advanced(Qt5OpenGL_DIR)
mark_as_advanced(Qt5Test_DIR) mark_as_advanced(Qt5Test_DIR)
mark_as_advanced(Qt5Widgets_DIR) mark_as_advanced(Qt5Widgets_DIR)
mark_as_advanced(dtkCore_DIR)
mark_as_advanced(dtkFonts_DIR)
mark_as_advanced(dtkLog_DIR)
mark_as_advanced(dtkThemes_DIR)
mark_as_advanced(CMAKE_AR) mark_as_advanced(CMAKE_AR)
mark_as_advanced(CMAKE_BUILD_TYPE) mark_as_advanced(CMAKE_BUILD_TYPE)
mark_as_advanced(CMAKE_INSTALL_PREFIX)
mark_as_advanced(CMAKE_OSX_ARCHITECTURES) mark_as_advanced(CMAKE_OSX_ARCHITECTURES)
mark_as_advanced(CMAKE_OSX_DEPLOYMENT_TARGET) mark_as_advanced(CMAKE_OSX_DEPLOYMENT_TARGET)
mark_as_advanced(CMAKE_OSX_SYSROOT) mark_as_advanced(CMAKE_OSX_SYSROOT)
## ###################################################################
## Packaging
## ###################################################################
include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_VERSION_MAJOR "${${PROJECT_NAME}_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${${PROJECT_NAME}_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${${PROJECT_NAME}_VERSION_PATCH}")
include(CPack)
###################################################################### ######################################################################
### CMakeLists.txt ends here ### CMakeLists.txt ends here
...@@ -12,12 +12,7 @@ ...@@ -12,12 +12,7 @@
## ##
### Code: ### Code:
set(dtkWidgets_INCLUDE_DIRS include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
"@CMAKE_CURRENT_SOURCE_DIR@/src"
"@CMAKE_CURRENT_SOURCE_DIR@/src/dtkWidgets"
"@CMAKE_CURRENT_BINARY_DIR@")
include("@CMAKE_BINARY_DIR@/dtkWidgetsDepends.cmake")
###################################################################### ######################################################################
### dtkWidgetsConfig.cmake.in ends here ### dtkWidgetsConfig.cmake.in ends here
## Version: $Id$
##
######################################################################
##
### Commentary:
##
######################################################################
##
### Change Log:
##
######################################################################
##
### Code:
set(dtkWidgets_INCLUDE_DIRS
"@CMAKE_INSTALL_PREFIX@/include"
"@CMAKE_INSTALL_PREFIX@/include/dtkWidgets")
include("@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/cmake/dtkWidgets/dtkWidgetsDepends.cmake")
######################################################################
### dtkWidgetsConfig.install.cmake.in ends here
## Version: $Id$
##
######################################################################
##
### Commentary:
##
######################################################################
##
### Change Log:
##
######################################################################
##
### Code:
set(PACKAGE_VERSION "@dtkWidgets_VERSION@")
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()
######################################################################
### dtkWidgetsConfigVersion.cmake.in ends here
...@@ -12,21 +12,16 @@ ...@@ -12,21 +12,16 @@
## ##
### Code: ### Code:
add_subdirectory(dtkWidgets) set(layer_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
## #################################################################
## Target definition
## #################################################################
set(DTKWIDGETS_TARGETS)
set(DTKWIDGETS_TARGETS ${DTKWIDGETS_TARGETS} dtkWidgets) add_subdirectory(dtkWidgets)
## ################################################################# ## #################################################################
## Target export ## Target export
## ################################################################# ## #################################################################
export(TARGETS ${DTKWIDGETS_TARGETS} FILE "${CMAKE_BINARY_DIR}/dtkWidgetsDepends.cmake") export(EXPORT layer-targets
FILE "${CMAKE_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")
###################################################################### ######################################################################
### CMakeLists.txt ends here ### CMakeLists.txt ends here
...@@ -160,6 +160,24 @@ set(${PROJECT_NAME}_SOURCES ...@@ -160,6 +160,24 @@ set(${PROJECT_NAME}_SOURCES
dtkWidgetsWorkspaceBar.cpp dtkWidgetsWorkspaceBar.cpp
dtkWidgetsWorkspaceStackBar.cpp) dtkWidgetsWorkspaceStackBar.cpp)
## ###################################################################
## Config file
## ###################################################################
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.h.in"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.h")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.h.in"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config")
set(${PROJECT_NAME}_HEADERS
${${PROJECT_NAME}_HEADERS}
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.h")
set(layer_BINARY_DIR "${PROJECT_BINARY_DIR}/..")
## ################################################################# ## #################################################################
## Build rules ## Build rules
## ################################################################# ## #################################################################
...@@ -169,7 +187,6 @@ add_library(${PROJECT_NAME} SHARED ...@@ -169,7 +187,6 @@ add_library(${PROJECT_NAME} SHARED
${${PROJECT_NAME}_HEADERS}) ${${PROJECT_NAME}_HEADERS})
target_link_libraries(${PROJECT_NAME} Qt5::Core) target_link_libraries(${PROJECT_NAME} Qt5::Core)
target_link_libraries(${PROJECT_NAME} Qt5::WebSockets)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets) target_link_libraries(${PROJECT_NAME} Qt5::Widgets)
target_link_libraries(${PROJECT_NAME} Qt5::Xml) target_link_libraries(${PROJECT_NAME} Qt5::Xml)
...@@ -179,6 +196,15 @@ target_link_libraries(${PROJECT_NAME} dtkCore) ...@@ -179,6 +196,15 @@ target_link_libraries(${PROJECT_NAME} dtkCore)
target_link_libraries(${PROJECT_NAME} dtkFonts) target_link_libraries(${PROJECT_NAME} dtkFonts)
target_link_libraries(${PROJECT_NAME} dtkLog) target_link_libraries(${PROJECT_NAME} dtkLog)
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${layer_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
$<BUILD_INTERFACE:${layer_BINARY_DIR}>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
$<INSTALL_INTERFACE:include>)
## ################################################################# ## #################################################################
## Target properties ## Target properties
## ################################################################# ## #################################################################
...@@ -201,40 +227,21 @@ set(${PROJECT_NAME}_HEADERS ...@@ -201,40 +227,21 @@ set(${PROJECT_NAME}_HEADERS
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}Export" "${CMAKE_BINARY_DIR}/${PROJECT_NAME}Export"
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}Export.h") "${CMAKE_BINARY_DIR}/${PROJECT_NAME}Export.h")
## ###################################################################
## Config file
## ###################################################################
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.h.in"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.h")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.h.in"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config")
set(${PROJECT_NAME}_HEADERS
${${PROJECT_NAME}_HEADERS}
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.h")
## ################################################################### ## ###################################################################
## Install rules - files ## Install rules - files
## ################################################################### ## ###################################################################
install(FILES ${${PROJECT_NAME}_HEADERS} install(FILES ${${PROJECT_NAME}_HEADERS}
DESTINATION include/${PROJECT_NAME} DESTINATION include/${PROJECT_NAME})
COMPONENT widgets)
## ################################################################### ## ###################################################################
## Install rules - targets ## Install rules - targets
## ################################################################### ## ###################################################################
install(TARGETS ${PROJECT_NAME} install(TARGETS ${PROJECT_NAME} EXPORT layer-targets
EXPORT ${PROJECT_NAME}Depends
RUNTIME DESTINATION bin
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT widgets) ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
###################################################################### ######################################################################
### CMakeLists.txt ends here ### CMakeLists.txt ends here
...@@ -18,23 +18,132 @@ ...@@ -18,23 +18,132 @@
#include "dtkWidgetsMainWindow.h" #include "dtkWidgetsMainWindow.h"
#include <dtkFonts> #include <dtkFonts>
#include <dtkLog>
#include <dtkThemes>
dtkApplication::dtkApplication(int& argc, char **argv): QApplication(argc, argv) #include <QtCore>
#include <QtWidgets>
// /////////////////////////////////////////////////////////////////////////////
// dtkApplicationPrivate implementation
// /////////////////////////////////////////////////////////////////////////////
dtkWidgetsMainWindow *dtkApplicationPrivate::window = nullptr;
dtkApplicationPrivate::dtkApplicationPrivate(void) : settings(nullptr), parser(new QCommandLineParser), app(nullptr)
{
this->parser->setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
}
dtkApplicationPrivate::~dtkApplicationPrivate(void)
{
if (this->settings) {
delete this->settings;
this->settings = nullptr;
}
delete this->parser;
this->parser = nullptr;
}
void dtkApplicationPrivate::setApplication(QCoreApplication *q)
{
this->app = q;
}
void dtkApplicationPrivate::initialize(void)
{
QString verbosity = "info";
qputenv("QT_PLUGIN_PATH", "1");
qputenv("LC_ALL", "C");
QLocale::setDefault(QLocale::c());
#if defined (Q_OS_UNIX) && !defined(Q_OS_MAC)
setlocale(LC_NUMERIC, "C");
#endif
this->parser->addHelpOption();
this->parser->addVersionOption();
QCommandLineOption settingsOption("settings", "main settings file", "filename");
this->parser->addOption(settingsOption);
QCommandLineOption verboseOption("verbose", QCoreApplication::translate("main", "verbose plugin initialization"));
this->parser->addOption(verboseOption);
QCommandLineOption nonguiOption(QStringList() << "nw" << "no-window", QCoreApplication::translate("main", "non GUI application (no window)"));
this->parser->addOption(nonguiOption);
QCommandLineOption loglevelOption("loglevel", "log level used by dtkLog (default is info), available: trace|debug|info|warn|error|fatal", "level", verbosity);
this->parser->addOption(loglevelOption);
QCommandLineOption logfileOption("logfile", qPrintable(QString("log file used by dtkLog; default is: ").append(dtkLogPath(app))), "filename | console", dtkLogPath(app));
this->parser->addOption(logfileOption);
QCommandLineOption logfileMaxSizeOption("logfilemax", "log file max size (in MB); default is: 3072 (3GB)", "size");
this->parser->addOption(logfileMaxSizeOption);
QCommandLineOption themeOption("theme", "theme", "themename");
this->parser->addOption(themeOption);
this->parser->process(*(this->app));
if (this->parser->isSet(settingsOption))
this->settings = new QSettings(this->parser->value(settingsOption), QSettings::IniFormat);
else
this->settings = new QSettings(this->app->organizationName(), this->app->applicationName());
if (settings->contains("log_level")) {
dtkLogger::instance().setLevel(settings->value("log_level").toString());
} else {
if (this->parser->isSet(loglevelOption))
verbosity = this->parser->value(loglevelOption);
dtkLogger::instance().setLevel(verbosity);
}
qlonglong max_size = 1024L * 1024L * 1024L;
if (this->parser->isSet(logfileMaxSizeOption))
max_size = this->parser->value(logfileMaxSizeOption).toLongLong() * 1024 * 1024;
if (this->parser->isSet(logfileOption)) {
if (this->parser->value(logfileOption) == "console")
dtkLogger::instance().attachConsole();
else
dtkLogger::instance().attachFile(this->parser->value(logfileOption), max_size);
} else {
dtkLogger::instance().attachFile(dtkLogPath(this->app), max_size);
}
}
// ///////////////////////////////////////////////////////////////////
// dtkApplication implementation
// ///////////////////////////////////////////////////////////////////
dtkApplication::dtkApplication(int& argc, char **argv): QApplication(argc, argv), d(new dtkApplicationPrivate)
{ {
dtkFontSourceSansPro::instance()->initFontSourceSansPro(); dtkFontSourceSansPro::instance()->initFontSourceSansPro();
d = new dtkApplicationPrivate;
d->setApplication(this); d->setApplication(this);
this->setFont(dtkFontSourceSansPro::instance()->font(13)); this->setFont(dtkFontSourceSansPro::instance()->font(13));
} }
dtkApplication::~dtkApplication(void) dtkApplication::~dtkApplication(void)
{ {
delete d; delete d;
d = NULL; d = nullptr;
} }
void dtkApplication::initialize(void) void dtkApplication::initialize(void)
......
...@@ -14,14 +14,13 @@ ...@@ -14,14 +14,13 @@
#pragma once #pragma once
#include <QtCore> #include <dtkWidgetsExport>
#include <QtWidgets>
#include <dtkLog> #include <QtWidgets/QApplication>
#include <dtkWidgetsExport.h>
class dtkWidgetsMainWindow; class dtkWidgetsMainWindow;
class QCommandLineParser;
class QSettings;
class DTKWIDGETS_EXPORT dtkApplication : public QApplication class DTKWIDGETS_EXPORT dtkApplication : public QApplication
{ {
...@@ -29,8 +28,8 @@ public: ...@@ -29,8 +28,8 @@ public:
typedef void (*setup_t)(dtkApplication *); typedef void (*setup_t)(dtkApplication *);
public: public:
dtkApplication(int& argc, char **argv); dtkApplication(int& argc, char **argv);
virtual ~dtkApplication(void); ~dtkApplication(void);
public: public:
virtual void initialize(void); virtual void initialize(void);
......
...@@ -14,22 +14,18 @@ ...@@ -14,22 +14,18 @@
#pragma once #pragma once
#include <QtCore> #include <dtkWidgetsExport>
#include <QtWidgets>
#include <dtkWidgetsExport.h>
// /////////////////////////////////////////////////////////////////////////////
//
// /////////////////////////////////////////////////////////////////////////////
class dtkWidgetsMainWindow; class dtkWidgetsMainWindow;
class QCoreApplication;