Make definitions for gui support project specific

This commit is contained in:
Martchus 2017-04-27 22:03:37 +02:00
parent 1d49f41582
commit 61a544d42f
10 changed files with 35 additions and 30 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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
}

View File

@ -1,13 +1,13 @@
#include "./dialogutils.h"
#ifdef GUI_NONE
#if !defined(QT_UTILITIES_GUI_QTWIDGETS) && !defined(QT_UTILITIES_GUI_QTQUICK)
# include <QCoreApplication>
#else
# include <QGuiApplication>
# include <QPalette>
# include <QWidget>
# include <QStyle>
# ifdef GUI_QTWIDGETS
# ifdef QT_UTILITIES_GUI_QTWIDGETS
# include <QApplication>
# include <QDesktopWidget>
# include <QCursor>
@ -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

View File

@ -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);

View File

@ -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 <QtPlugin>
# ifdef Q_OS_WIN32
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)

View File

@ -6,7 +6,7 @@
#include <QLocale>
#include <QFont>
#include <QIcon>
#ifdef GUI_QTWIDGETS
#ifdef QT_UTILITIES_GUI_QTWIDGETS
# include <QApplication>
# include <QStyleFactory>
#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

View File

@ -10,12 +10,12 @@
#include <QDir>
#include <QStringBuilder>
#include <QSettings>
#if defined(GUI_QTWIDGETS)
#if defined(QT_UTILITIES_GUI_QTWIDGETS)
# include <QApplication>
# include <QIcon>
# include <QFont>
# include <QStyleFactory>
#elif defined(GUI_QTQUICK)
#elif defined(QT_UTILITIES_GUI_QTQUICK)
# include <QGuiApplication>
# include <QIcon>
# include <QFont>
@ -214,7 +214,7 @@ void loadApplicationTranslationFile(const std::initializer_list<QString> &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.
*/

View File

@ -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();

View File

@ -1,7 +1,7 @@
#include "./optioncategorymodel.h"
#include "./optioncategory.h"
#ifdef GUI_QTWIDGETS
#ifdef QT_UTILITIES_GUI_QTWIDGETS
# include <QApplication>
# include <QStyle>
#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)