diff --git a/CMakeLists.txt b/CMakeLists.txt index d281365..e53f35b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,8 +8,8 @@ set(META_APP_AUTHOR "Martchus") set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}") set(META_APP_DESCRIPTION "Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models") set(META_VERSION_MAJOR 5) -set(META_VERSION_MINOR 6) -set(META_VERSION_PATCH 1) +set(META_VERSION_MINOR 7) +set(META_VERSION_PATCH 0) set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}) # add project files @@ -138,13 +138,13 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" "${CMAKE_MODUL # configure platform specific capslock detection if(WIN32) # WinAPI provides functions required for capslock detection - list(APPEND META_PRIVATE_COMPILE_DEFINITIONS QT_UTILITIES_PLATFORM_SPECIFIC_CAPSLOCK_DETECTION) + list(APPEND META_PRIVATE_COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_PLATFORM_SPECIFIC_CAPSLOCK_DETECTION) else() # X11 can provide functions required for capslock detection under non-Windows environments find_package(X11) if(X11_FOUND) list(APPEND LIBRARIES ${X11_LIBRARIES}) - list(APPEND META_PRIVATE_COMPILE_DEFINITIONS QT_UTILITIES_PLATFORM_SPECIFIC_CAPSLOCK_DETECTION) + list(APPEND META_PRIVATE_COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_PLATFORM_SPECIFIC_CAPSLOCK_DETECTION) endif() endif() @@ -172,13 +172,15 @@ else() endif() # find c++utilities -find_package(c++utilities 4.6.0 REQUIRED) +find_package(c++utilities 4.7.0 REQUIRED) use_cpp_utilities() # include modules to apply configuration include(BasicConfig) include(QtGuiConfig) +# apply Qt utilities specific configuration set(META_PUBLIC_QT_MODULES Core ${ADDITIONAL_QT_MODULES}) +# include further modules to apply configuration include(QtConfig) include(WindowsResources) include(LibraryTarget) diff --git a/cmake/modules/QtGuiConfig.cmake b/cmake/modules/QtGuiConfig.cmake index 7308a8f..4cb1f7b 100644 --- a/cmake/modules/QtGuiConfig.cmake +++ b/cmake/modules/QtGuiConfig.cmake @@ -12,7 +12,8 @@ endif() # enable Qt Widgets GUI if(WIDGETS_GUI) - list(APPEND META_PRIVATE_COMPILE_DEFINITIONS GUI_QTWIDGETS MODEL_UNDO_SUPPORT) + list(APPEND META_PRIVATE_COMPILE_DEFINITIONS GUI_QTWIDGETS) + list(APPEND META_PUBLIC_COMPILE_DEFINITIONS ${META_PROJECT_VARNAME_UPPER}_GUI_QTWIDGETS) list(APPEND WIDGETS_FILES ${WIDGETS_HEADER_FILES} ${WIDGETS_SRC_FILES} ${WIDGETS_RES_FILES} ${WIDGETS_UI_FILES}) list(APPEND ADDITIONAL_HEADER_FILES ${WIDGETS_HEADER_FILES}) if(WIDGETS_FILES) @@ -28,6 +29,7 @@ endif() # enable Qt Quick GUI if(QUICK_GUI) list(APPEND META_PRIVATE_COMPILE_DEFINITIONS GUI_QTQUICK) + list(APPEND META_PUBLIC_COMPILE_DEFINITIONS ${META_PROJECT_VARNAME_UPPER}_GUI_QTQUICK) list(APPEND QML_FILES ${QML_HEADER_FILES} ${QML_SRC_FILES} ${QML_RES_FILES}) list(APPEND ADDITIONAL_HEADER_FILES ${QML_HEADER_FILES}) if(QML_FILES) diff --git a/enterpassworddialog/enterpassworddialog.cpp b/enterpassworddialog/enterpassworddialog.cpp index 1688523..f20c88c 100644 --- a/enterpassworddialog/enterpassworddialog.cpp +++ b/enterpassworddialog/enterpassworddialog.cpp @@ -301,11 +301,11 @@ void EnterPasswordDialog::confirm() * \brief Returns an indication whether the capslock key is pressed using platform specific functions. * * \remarks - Returns always false for unsupported platforms. - * - This method always returns false when not built with - * QT_UTILITIES_PLATFORM_SPECIFIC_CAPSLOCK_DETECTION defined. - * - This static function will be used internally to detect whether the capslock key is pressed - * when initializing the dialog if available. + * - This method always returns false when the detection is not supported. It is supported under X11 + * and Windows. * - The function requires the application to be linked against X11 on Linux/Unix. + * - This static function will be used internally to detect whether the capslock key is pressed + * when initializing the dialog. */ bool EnterPasswordDialog::isCapslockPressed() { @@ -325,6 +325,7 @@ bool EnterPasswordDialog::isCapslockPressed() # else return false; # endif +#else return false; #endif } diff --git a/misc/dialogutils.cpp b/misc/dialogutils.cpp index 0d621d6..9c3023a 100644 --- a/misc/dialogutils.cpp +++ b/misc/dialogutils.cpp @@ -1,13 +1,13 @@ #include "./dialogutils.h" -#ifdef GUI_NONE +#if !defined(QT_UTILITIES_GUI_QTWIDGETS) && !defined(QT_UTILITIES_GUI_QTQUICK) # include #else # include # include # include # include -# ifdef GUI_QTWIDGETS +# ifdef QT_UTILITIES_GUI_QTWIDGETS # include # include # include @@ -46,7 +46,7 @@ QString generateWindowTitle(DocumentStatus documentStatus, const QString &docume } } -#ifndef GUI_NONE +#if defined(QT_UTILITIES_GUI_QTWIDGETS) || defined(QT_UTILITIES_GUI_QTQUICK) # ifdef Q_OS_WIN32 @@ -87,7 +87,7 @@ const QString &dialogStyle() return style; } -# ifdef GUI_QTWIDGETS +# ifdef QT_UTILITIES_GUI_QTWIDGETS /*! * \brief Moves the specified \a widget in the middle of the (available) screen area. If there are multiple diff --git a/misc/dialogutils.h b/misc/dialogutils.h index 4cb75bf..9c25cd7 100644 --- a/misc/dialogutils.h +++ b/misc/dialogutils.h @@ -22,13 +22,13 @@ enum class DocumentStatus { QString QT_UTILITIES_EXPORT generateWindowTitle(DocumentStatus documentStatus, const QString &documentPath); -#ifndef GUI_NONE +#if defined(QT_UTILITIES_GUI_QTWIDGETS) || defined (QT_UTILITIES_GUI_QTQUICK) # ifdef Q_OS_WIN32 QColor QT_UTILITIES_EXPORT windowFrameColor(); QColor QT_UTILITIES_EXPORT instructionTextColor(); # endif const QString QT_UTILITIES_EXPORT &dialogStyle(); -# ifdef GUI_QTWIDGETS +# ifdef QT_UTILITIES_GUI_QTWIDGETS void QT_UTILITIES_EXPORT centerWidget(QWidget *widget); void QT_UTILITIES_EXPORT cornerWidget(QWidget *widget); void QT_UTILITIES_EXPORT makeHeading(QWidget *widget); diff --git a/resources/importplugin.h b/resources/importplugin.h index 3c2d4a3..85d0215 100644 --- a/resources/importplugin.h +++ b/resources/importplugin.h @@ -4,7 +4,7 @@ #include "resources/config.h" #ifdef QT_STATIC -# if defined(GUI_QTWIDGETS) || defined(GUI_QTQUICK) +# if defined(QT_UTILITIES_GUI_QTWIDGETS) || defined(QT_UTILITIES_GUI_QTQUICK) # include # ifdef Q_OS_WIN32 Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin) diff --git a/resources/qtconfigarguments.cpp b/resources/qtconfigarguments.cpp index 052820f..a94bd36 100644 --- a/resources/qtconfigarguments.cpp +++ b/resources/qtconfigarguments.cpp @@ -6,7 +6,7 @@ #include #include #include -#ifdef GUI_QTWIDGETS +#ifdef QT_UTILITIES_GUI_QTWIDGETS # include # include #else @@ -65,9 +65,9 @@ QtConfigArguments::QtConfigArguments() : m_qtQuickGuiArg.setSubArguments({&m_lngArg, &m_qmlDebuggerArg, &m_iconThemeArg, &m_fontArg, &m_libraryPathsArg, &m_platformThemeArg}); m_qtWidgetsGuiArg.setDenotesOperation(true); m_qtQuickGuiArg.setDenotesOperation(true); -#if defined GUI_QTWIDGETS +#if defined QT_UTILITIES_GUI_QTWIDGETS m_qtWidgetsGuiArg.setImplicit(true); -#elif defined GUI_QTQUICK +#elif defined QT_UTILITIES_GUI_QTQUICK m_qtQuickGuiArg.setImplicit(true); #endif } @@ -83,14 +83,14 @@ void QtConfigArguments::applySettings(bool preventApplyingDefaultFont) const QLocale::setDefault(QLocale(QString::fromLocal8Bit(m_lngArg.values().front()))); } if(m_styleArg.isPresent()) { -#ifdef GUI_QTWIDGETS +#ifdef QT_UTILITIES_GUI_QTWIDGETS if(QStyle *style = QStyleFactory::create(QString::fromLocal8Bit(m_styleArg.values().front()))) { QApplication::setStyle(style); } else { cerr << "Warning: Can not find the specified style." << endl; } #else -# ifdef GUI_QTQUICK +# ifdef QT_UTILITIES_GUI_QTQUICK cerr << "Warning: Can not set a style for the Qt Quick GUI." << endl; # endif #endif diff --git a/resources/resources.cpp b/resources/resources.cpp index 250f5f6..24fd393 100644 --- a/resources/resources.cpp +++ b/resources/resources.cpp @@ -10,12 +10,12 @@ #include #include #include -#if defined(GUI_QTWIDGETS) +#if defined(QT_UTILITIES_GUI_QTWIDGETS) # include # include # include # include -#elif defined(GUI_QTQUICK) +#elif defined(QT_UTILITIES_GUI_QTQUICK) # include # include # include @@ -214,7 +214,7 @@ void loadApplicationTranslationFile(const std::initializer_list &applic */ namespace ApplicationInstances { -#if defined(GUI_QTWIDGETS) +#if defined(QT_UTILITIES_GUI_QTWIDGETS) /*! * \brief Returns whether a QApplication has been instantiated yet. */ @@ -224,7 +224,7 @@ bool hasWidgetsApp() } #endif -#if defined(GUI_QTWIDGETS) || defined(GUI_QTQUICK) +#if defined(QT_UTILITIES_GUI_QTWIDGETS) || defined(QT_UTILITIES_GUI_QTQUICK) /*! * \brief Returns whether a QGuiApplication has been instantiated yet. */ diff --git a/resources/resources.h b/resources/resources.h index f0d0bce..5129d93 100644 --- a/resources/resources.h +++ b/resources/resources.h @@ -49,10 +49,10 @@ QT_UTILITIES_EXPORT void loadApplicationTranslationFile(const std::initializer_l namespace ApplicationInstances { -#if defined(GUI_QTWIDGETS) +#if defined(QT_UTILITIES_GUI_QTWIDGETS) QT_UTILITIES_EXPORT bool hasWidgetsApp(); #endif -#if defined(GUI_QTWIDGETS) || defined(GUI_QTQUICK) +#if defined(QT_UTILITIES_GUI_QTWIDGETS) || defined(QT_UTILITIES_GUI_QTQUICK) QT_UTILITIES_EXPORT bool hasGuiApp(); #endif QT_UTILITIES_EXPORT bool hasCoreApp(); diff --git a/settingsdialog/optioncategorymodel.cpp b/settingsdialog/optioncategorymodel.cpp index 3d98828..f8314b6 100644 --- a/settingsdialog/optioncategorymodel.cpp +++ b/settingsdialog/optioncategorymodel.cpp @@ -1,7 +1,7 @@ #include "./optioncategorymodel.h" #include "./optioncategory.h" -#ifdef GUI_QTWIDGETS +#ifdef QT_UTILITIES_GUI_QTWIDGETS # include # include #endif @@ -72,7 +72,7 @@ QVariant OptionCategoryModel::data(const QModelIndex &index, int role) const const QIcon &icon = m_categories.at(index.row())->icon(); if(!icon.isNull()) { return icon.pixmap( -#ifdef GUI_QTWIDGETS +#ifdef QT_UTILITIES_GUI_QTWIDGETS QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize) #else QSize(32, 32)