allow building without Qt Widgets specific features
This commit is contained in:
parent
fbfe8491ec
commit
323c3b8824
|
@ -2,17 +2,27 @@ cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
|
|||
|
||||
# add project files
|
||||
set(HEADER_FILES
|
||||
aboutdialog/aboutdialog.h
|
||||
enterpassworddialog/enterpassworddialog.h
|
||||
misc/dialogutils.h
|
||||
misc/desktoputils.h
|
||||
misc/xmlparsermacros.h
|
||||
misc/undefxmlparsermacros.h
|
||||
misc/trylocker.h
|
||||
misc/adoptlocker.h
|
||||
misc/dialogutils.cpp
|
||||
misc/desktoputils.cpp
|
||||
models/checklistmodel.h
|
||||
resources/qtconfigarguments.h
|
||||
resources/resources.h
|
||||
)
|
||||
set(SRC_FILES
|
||||
misc/dialogutils.h
|
||||
misc/desktoputils.h
|
||||
models/checklistmodel.cpp
|
||||
resources/qtconfigarguments.cpp
|
||||
resources/resources.cpp
|
||||
resources/qtutilsicons.qrc
|
||||
)
|
||||
set(WIDGETS_HEADER_FILES
|
||||
aboutdialog/aboutdialog.h
|
||||
enterpassworddialog/enterpassworddialog.h
|
||||
settingsdialog/optioncategory.h
|
||||
settingsdialog/optioncategoryfiltermodel.h
|
||||
settingsdialog/optioncategorymodel.h
|
||||
|
@ -25,17 +35,13 @@ set(HEADER_FILES
|
|||
widgets/clearplaintextedit.h
|
||||
widgets/clearspinbox.h
|
||||
widgets/iconbutton.h
|
||||
widgets/pathselection.h
|
||||
paletteeditor/paletteeditor.h
|
||||
paletteeditor/colorbutton.h
|
||||
)
|
||||
set(SRC_FILES
|
||||
set(WIDGETS_SRC_FILES
|
||||
aboutdialog/aboutdialog.cpp
|
||||
enterpassworddialog/enterpassworddialog.cpp
|
||||
misc/dialogutils.cpp
|
||||
misc/desktoputils.cpp
|
||||
models/checklistmodel.cpp
|
||||
resources/qtconfigarguments.cpp
|
||||
resources/resources.cpp
|
||||
settingsdialog/optioncategory.cpp
|
||||
settingsdialog/optioncategoryfiltermodel.cpp
|
||||
settingsdialog/optioncategorymodel.cpp
|
||||
|
@ -48,9 +54,9 @@ set(SRC_FILES
|
|||
widgets/clearplaintextedit.cpp
|
||||
widgets/clearspinbox.cpp
|
||||
widgets/iconbutton.cpp
|
||||
widgets/pathselection.cpp
|
||||
paletteeditor/paletteeditor.cpp
|
||||
paletteeditor/colorbutton.cpp
|
||||
resources/qtutilsicons.qrc
|
||||
)
|
||||
set(WIDGETS_UI_FILES
|
||||
aboutdialog/aboutdialog.ui
|
||||
|
@ -58,6 +64,7 @@ set(WIDGETS_UI_FILES
|
|||
settingsdialog/settingsdialog.ui
|
||||
settingsdialog/qtappearanceoptionpage.ui
|
||||
settingsdialog/qtlanguageoptionpage.ui
|
||||
settingsdialog/qtenvoptionpage.ui
|
||||
paletteeditor/paletteeditor.ui
|
||||
)
|
||||
|
||||
|
@ -111,18 +118,56 @@ if(MINGW)
|
|||
set(CMAKE_SHARED_LIBRARY_PREFIX "")
|
||||
endif(MINGW)
|
||||
|
||||
# enable Qt Widgets GUI
|
||||
# read cached variables
|
||||
set(WIDGETS_GUI "yes" CACHE STRING "enables/disables Qt Widgets specific features: yes (default) or no")
|
||||
if(${WIDGETS_GUI} STREQUAL "yes")
|
||||
message(STATUS "Building with Qt Widgets specific features.")
|
||||
elseif(${WIDGETS_GUI} STREQUAL "no")
|
||||
message(STATUS "Building WITHOUT Qt Widgets specific features.")
|
||||
else()
|
||||
message(FATAL_ERROR "Specification whether to build Qt Widgets specific features is invalid (must be either yes or no).")
|
||||
endif()
|
||||
set(GUI_QTQUICK "yes" CACHE STRING "enables/disables building Qt Quick specific features: yes (default) or no")
|
||||
if(${GUI_QTQUICK} STREQUAL "yes")
|
||||
message(STATUS "Building with Qt Quick specific features.")
|
||||
elseif(${GUI_QTQUICK} STREQUAL "no")
|
||||
message(STATUS "Building WITHOUT Qt Quick specific features.")
|
||||
else()
|
||||
message(FATAL_ERROR "Specification whether to build Qt Quick specific features is invalid (must be either yes or no).")
|
||||
endif()
|
||||
|
||||
# enable Qt Widgets specific features
|
||||
if(${WIDGETS_GUI} STREQUAL "yes")
|
||||
add_definitions(
|
||||
-DGUI_QTWIDGETS
|
||||
-DMODEL_UNDO_SUPPORT
|
||||
)
|
||||
endif()
|
||||
|
||||
# enable Qt Quick specific features
|
||||
if(${WIDGETS_GUI} STREQUAL "yes")
|
||||
add_definitions(
|
||||
-DGUI_QTQUICK
|
||||
)
|
||||
endif()
|
||||
|
||||
# disable new ABI (can't catch ios_base::failure with new ABI)
|
||||
add_definitions(
|
||||
-DGUI_QTWIDGETS
|
||||
-DMODEL_UNDO_SUPPORT
|
||||
-D_GLIBCXX_USE_CXX11_ABI=0
|
||||
)
|
||||
|
||||
# enable code for debugging
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
add_definitions(-DDEBUG_BUILD)
|
||||
message(STATUS "Debug build enabled.")
|
||||
endif()
|
||||
|
||||
# check required Qt 5 modules
|
||||
find_package(Qt5Core REQUIRED)
|
||||
find_package(Qt5Gui REQUIRED)
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
if(${WIDGETS_GUI} STREQUAL "yes")
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
endif()
|
||||
|
||||
# enable moc, uic and rcc
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
@ -130,8 +175,13 @@ set(CMAKE_AUTOUIC ON)
|
|||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
# stuff which is only required when linking against Qt Widgets
|
||||
if(${WIDGETS_GUI} STREQUAL "yes")
|
||||
set(WIDGETS_STUFF ${GUI_TYPE} ${WIDGETS_HEADER_FILES} ${WIDGETS_SRC_FILES} ${WIDGETS_UI_FILES} ${QM_FILES} ${RES_FILES})
|
||||
endif()
|
||||
|
||||
# executable and linking
|
||||
add_library(${META_PROJECT_NAME} SHARED ${HEADER_FILES} ${SRC_FILES} ${WIDGETS_UI_FILES} ${RES_FILES} ${WINDOWS_ICON_PATH})
|
||||
add_library(${META_PROJECT_NAME} SHARED ${HEADER_FILES} ${SRC_FILES} ${WIDGETS_STUFF} ${RES_FILES} ${WINDOWS_ICON_PATH})
|
||||
if(WIN32)
|
||||
# WinAPI provides functions required for capslock detection
|
||||
add_definitions(-DPLATFORM_SPECIFIC_CAPSLOCK_DETECTION)
|
||||
|
|
|
@ -82,6 +82,8 @@ const QString &dialogStyle()
|
|||
return style;
|
||||
}
|
||||
|
||||
# ifdef GUI_QTWIDGETS
|
||||
|
||||
/*!
|
||||
* \brief Makes \a widget a heading.
|
||||
*/
|
||||
|
@ -102,6 +104,8 @@ void updateStyle(QWidget *widget)
|
|||
widget->update();
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace Dialogs
|
||||
|
|
|
@ -28,8 +28,10 @@ QColor LIB_EXPORT windowFrameColor();
|
|||
QColor LIB_EXPORT instructionTextColor();
|
||||
# endif
|
||||
const QString LIB_EXPORT &dialogStyle();
|
||||
# ifdef GUI_QTWIDGETS
|
||||
void LIB_EXPORT makeHeading(QWidget *widget);
|
||||
void LIB_EXPORT updateStyle(QWidget *widget);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
} // namespace Dialogs
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
#include <QAbstractListModel>
|
||||
#include <QList>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
QT_FORWARD_DECLARE_CLASS(QSettings)
|
||||
|
||||
namespace Models {
|
||||
|
||||
|
|
|
@ -81,11 +81,12 @@ void QtConfigArguments::applySettings() const
|
|||
if(QStyle *style = QStyleFactory::create(QString::fromLocal8Bit(m_styleArg.values().front().data()))) {
|
||||
QApplication::setStyle(style);
|
||||
} else {
|
||||
cout << "Warning: Can not find the specified style." << endl;
|
||||
cerr << "Warning: Can not find the specified style." << endl;
|
||||
}
|
||||
#endif
|
||||
#ifdef GUI_QTQUICK
|
||||
cout << "Warning: Can not set a style for the Qt Quick GUI." << endl;
|
||||
#else
|
||||
# ifdef GUI_QTQUICK
|
||||
cerr << "Warning: Can not set a style for the Qt Quick GUI." << endl;
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
#ifdef Q_OS_WIN32
|
||||
|
@ -137,7 +138,7 @@ void QtConfigArguments::applySettings() const
|
|||
try {
|
||||
font.setPointSize(stringToNumber<int>(m_fontArg.values().back()));
|
||||
} catch(const ConversionException &) {
|
||||
cout << "Warning: The specified font size is no number and will be ignored." << endl;
|
||||
cerr << "Warning: The specified font size is no number and will be ignored." << endl;
|
||||
}
|
||||
QGuiApplication::setFont(font);
|
||||
} else {
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
#ifndef WIDGETS_CLEARABLEWIDGET_H
|
||||
#define WIDGETS_CLEARABLEWIDGET_H
|
||||
#ifndef WIDGETS_BUTTONOVERLAY_H
|
||||
#define WIDGETS_BUTTONOVERLAY_H
|
||||
|
||||
#include <c++utilities/application/global.h>
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QWidget;
|
||||
class QHBoxLayout;
|
||||
class QString;
|
||||
class QPixmap;
|
||||
QT_END_NAMESPACE
|
||||
QT_FORWARD_DECLARE_CLASS(QWidget)
|
||||
QT_FORWARD_DECLARE_CLASS(QHBoxLayout)
|
||||
QT_FORWARD_DECLARE_CLASS(QString)
|
||||
QT_FORWARD_DECLARE_CLASS(QPixmap)
|
||||
|
||||
namespace Widgets {
|
||||
|
||||
|
@ -73,4 +71,4 @@ inline bool ButtonOverlay::isInfoButtonEnabled() const
|
|||
|
||||
}
|
||||
|
||||
#endif // WIDGETS_CLEARABLEWIDGET_H
|
||||
#endif // WIDGETS_BUTTONOVERLAY_H
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef WIDGETS_TAGFIELDLINEEDIT_H
|
||||
#define WIDGETS_TAGFIELDLINEEDIT_H
|
||||
#ifndef WIDGETS_CLEARLINEEDIT_H
|
||||
#define WIDGETS_CLEARLINEEDIT_H
|
||||
|
||||
#include "./buttonoverlay.h"
|
||||
|
||||
|
@ -30,4 +30,4 @@ private Q_SLOTS:
|
|||
|
||||
}
|
||||
|
||||
#endif // WIDGETS_TAGFIELDLINEEDIT_H
|
||||
#endif // WIDGETS_CLEARLINEEDIT_H
|
||||
|
|
Loading…
Reference in New Issue