summaryrefslogtreecommitdiffstats
path: root/Source/QtDialog
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-06-12 14:11:42 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-06-12 14:11:54 (GMT)
commit068551cfb24c9cd3606ef698cfcc2403c44469fc (patch)
tree20e88eddaaca7dc6bfb62be5339432d2237f4afc /Source/QtDialog
parentd55ab3526c57d2dbe9d9950516d7a01b9e49216c (diff)
parent4037beb7477590569ef5290f34103a7015450fe0 (diff)
downloadCMake-068551cfb24c9cd3606ef698cfcc2403c44469fc.zip
CMake-068551cfb24c9cd3606ef698cfcc2403c44469fc.tar.gz
CMake-068551cfb24c9cd3606ef698cfcc2403c44469fc.tar.bz2
Merge topic 'cmake-gui-qt5-only'
4037beb747 QtDialog: remove Qt4 definition ce9dbceb42 QtDialog: remove Qt4-only code 8ea50749da QtDialog: use Qt5's imported targets 4ccc9921be QtDialog: use qt5 functions for special Qt sources e4d6015460 QtDialog: remove Qt4 support Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4836
Diffstat (limited to 'Source/QtDialog')
-rw-r--r--Source/QtDialog/CMakeLists.txt179
-rw-r--r--Source/QtDialog/CMakeSetup.cxx8
-rw-r--r--Source/QtDialog/QCMake.cxx4
-rw-r--r--Source/QtDialog/QCMakeCacheView.cxx33
-rw-r--r--Source/QtDialog/QCMakeCacheView.h1
5 files changed, 80 insertions, 145 deletions
diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt
index 98dd0e2..e6d6b17 100644
--- a/Source/QtDialog/CMakeLists.txt
+++ b/Source/QtDialog/CMakeLists.txt
@@ -3,111 +3,79 @@
project(QtDialog)
CMake_OPTIONAL_COMPONENT(cmake-gui)
-find_package(Qt5Widgets QUIET)
-if (Qt5Widgets_FOUND)
- include_directories(${Qt5Widgets_INCLUDE_DIRS})
- add_definitions(${Qt5Widgets_DEFINITONS})
- macro(qt4_wrap_ui)
- qt5_wrap_ui(${ARGN})
- endmacro()
- macro(qt4_wrap_cpp)
- qt5_wrap_cpp(${ARGN})
- endmacro()
- macro(qt4_add_resources)
- qt5_add_resources(${ARGN})
- endmacro()
+find_package(Qt5Widgets REQUIRED)
- set(CMake_QT_LIBRARIES ${Qt5Widgets_LIBRARIES})
- set(QT_QTMAIN_LIBRARY ${Qt5Core_QTMAIN_LIBRARIES})
+set(CMake_QT_EXTRA_LIBRARIES)
- # Try to find the package WinExtras for the task bar progress
- if(WIN32)
- find_package(Qt5WinExtras QUIET)
- if (Qt5WinExtras_FOUND)
- include_directories(${Qt5WinExtras_INCLUDE_DIRS})
- add_definitions(-DQT_WINEXTRAS)
- list(APPEND CMake_QT_LIBRARIES ${Qt5WinExtras_LIBRARIES})
- endif()
+# Try to find the package WinExtras for the task bar progress
+if(WIN32)
+ find_package(Qt5WinExtras QUIET)
+ if (Qt5WinExtras_FOUND)
+ add_definitions(-DQT_WINEXTRAS)
+ list(APPEND CMake_QT_EXTRA_LIBRARIES Qt5::WinExtras)
endif()
+endif()
- # Remove this when the minimum version of Qt is 4.6.
- add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0)
-
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
- if(CMake_QT_STATIC_QXcbIntegrationPlugin_LIBRARIES)
- list(APPEND CMake_QT_LIBRARIES ${CMake_QT_STATIC_QXcbIntegrationPlugin_LIBRARIES})
- set_property(SOURCE CMakeSetup.cxx
- PROPERTY COMPILE_DEFINITIONS USE_QXcbIntegrationPlugin)
- endif()
+if(CMake_QT_STATIC_QXcbIntegrationPlugin_LIBRARIES)
+ list(APPEND CMake_QT_EXTRA_LIBRARIES ${CMake_QT_STATIC_QXcbIntegrationPlugin_LIBRARIES})
+ set_property(SOURCE CMakeSetup.cxx
+ PROPERTY COMPILE_DEFINITIONS USE_QXcbIntegrationPlugin)
+endif()
- if(CMake_QT_STATIC_QWindowsIntegrationPlugin_LIBRARIES)
- list(APPEND CMake_QT_LIBRARIES ${CMake_QT_STATIC_QWindowsIntegrationPlugin_LIBRARIES})
- set_property(SOURCE CMakeSetup.cxx
- PROPERTY COMPILE_DEFINITIONS USE_QWindowsIntegrationPlugin)
- endif()
+if(CMake_QT_STATIC_QWindowsIntegrationPlugin_LIBRARIES)
+ list(APPEND CMake_QT_EXTRA_LIBRARIES ${CMake_QT_STATIC_QWindowsIntegrationPlugin_LIBRARIES})
+ set_property(SOURCE CMakeSetup.cxx
+ PROPERTY COMPILE_DEFINITIONS USE_QWindowsIntegrationPlugin)
+endif()
- # We need to install platform plugin and add qt.conf for Qt5 on Mac and Windows.
- # FIXME: This should be part of Qt5 CMake scripts, but unfortunately
- # Qt5 support is missing there.
- if(CMake_INSTALL_DEPENDENCIES AND (APPLE OR WIN32))
- macro(install_qt5_plugin _qt_plugin_name _qt_plugins_var)
- get_target_property(_qt_plugin_path "${_qt_plugin_name}" LOCATION)
- if(EXISTS "${_qt_plugin_path}")
- get_filename_component(_qt_plugin_file "${_qt_plugin_path}" NAME)
- get_filename_component(_qt_plugin_type "${_qt_plugin_path}" PATH)
- get_filename_component(_qt_plugin_type "${_qt_plugin_type}" NAME)
- if(APPLE)
- set(_qt_plugin_dir "PlugIns")
- elseif(WIN32)
- set(_qt_plugin_dir "plugins")
- endif()
- set(_qt_plugin_dest "${_qt_plugin_dir}/${_qt_plugin_type}")
- install(FILES "${_qt_plugin_path}"
- DESTINATION "${_qt_plugin_dest}"
- ${COMPONENT})
- set(${_qt_plugins_var}
- "${${_qt_plugins_var}};\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${_qt_plugin_dest}/${_qt_plugin_file}")
- else()
- message(FATAL_ERROR "QT plugin ${_qt_plugin_name} not found")
+# We need to install platform plugin and add qt.conf for Qt5 on Mac and Windows.
+# FIXME: This should be part of Qt5 CMake scripts, but unfortunately
+# Qt5 support is missing there.
+if(CMake_INSTALL_DEPENDENCIES AND (APPLE OR WIN32))
+ macro(install_qt5_plugin _qt_plugin_name _qt_plugins_var)
+ get_target_property(_qt_plugin_path "${_qt_plugin_name}" LOCATION)
+ if(EXISTS "${_qt_plugin_path}")
+ get_filename_component(_qt_plugin_file "${_qt_plugin_path}" NAME)
+ get_filename_component(_qt_plugin_type "${_qt_plugin_path}" PATH)
+ get_filename_component(_qt_plugin_type "${_qt_plugin_type}" NAME)
+ if(APPLE)
+ set(_qt_plugin_dir "PlugIns")
+ elseif(WIN32)
+ set(_qt_plugin_dir "plugins")
endif()
- endmacro()
- if(APPLE)
- install_qt5_plugin("Qt5::QCocoaIntegrationPlugin" QT_PLUGINS)
- file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
- "[Paths]\nPlugins = ${_qt_plugin_dir}\n")
- install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
- DESTINATION "${CMAKE_INSTALL_PREFIX}/Resources"
+ set(_qt_plugin_dest "${_qt_plugin_dir}/${_qt_plugin_type}")
+ install(FILES "${_qt_plugin_path}"
+ DESTINATION "${_qt_plugin_dest}"
${COMPONENT})
- elseif(WIN32 AND NOT CMake_QT_STATIC_QWindowsIntegrationPlugin_LIBRARIES)
- install_qt5_plugin("Qt5::QWindowsIntegrationPlugin" QT_PLUGINS)
- file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
- "[Paths]\nPlugins = ../${_qt_plugin_dir}\n")
- install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
- DESTINATION bin
- ${COMPONENT})
- endif()
- endif()
-
- if(TARGET Qt5::Core)
- get_property(_Qt5_Core_LOCATION TARGET Qt5::Core PROPERTY LOCATION)
- get_filename_component(Qt_BIN_DIR "${_Qt5_Core_LOCATION}" PATH)
- if(APPLE)
- get_filename_component(Qt_BIN_DIR "${Qt_BIN_DIR}" PATH)
+ set(${_qt_plugins_var}
+ "${${_qt_plugins_var}};\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${_qt_plugin_dest}/${_qt_plugin_file}")
+ else()
+ message(FATAL_ERROR "QT plugin ${_qt_plugin_name} not found")
endif()
+ endmacro()
+ if(APPLE)
+ install_qt5_plugin("Qt5::QCocoaIntegrationPlugin" QT_PLUGINS)
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
+ "[Paths]\nPlugins = ${_qt_plugin_dir}\n")
+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
+ DESTINATION "${CMAKE_INSTALL_PREFIX}/Resources"
+ ${COMPONENT})
+ elseif(WIN32 AND NOT CMake_QT_STATIC_QWindowsIntegrationPlugin_LIBRARIES)
+ install_qt5_plugin("Qt5::QWindowsIntegrationPlugin" QT_PLUGINS)
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
+ "[Paths]\nPlugins = ../${_qt_plugin_dir}\n")
+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
+ DESTINATION bin
+ ${COMPONENT})
endif()
-else()
- set(QT_MIN_VERSION "4.4.0")
- find_package(Qt4 REQUIRED)
- if(NOT QT4_FOUND)
- message(SEND_ERROR "Failed to find Qt 4.4 or greater.")
- return()
- endif()
-
- include(${QT_USE_FILE})
-
- set(CMake_QT_LIBRARIES ${QT_LIBRARIES})
+endif()
+get_property(_Qt5_Core_LOCATION TARGET Qt5::Core PROPERTY LOCATION)
+get_filename_component(Qt_BIN_DIR "${_Qt5_Core_LOCATION}" PATH)
+if(APPLE)
+ get_filename_component(Qt_BIN_DIR "${Qt_BIN_DIR}" PATH)
endif()
set(SRCS
@@ -116,6 +84,7 @@ set(SRCS
CMakeSetup.cxx
CMakeSetupDialog.cxx
CMakeSetupDialog.h
+ Compilers.h
FirstConfigure.cxx
FirstConfigure.h
QCMake.cxx
@@ -129,7 +98,7 @@ set(SRCS
WarningMessagesDialog.cxx
WarningMessagesDialog.h
)
-QT4_WRAP_UI(UI_SRCS
+qt5_wrap_ui(UI_SRCS
CMakeSetupDialog.ui
Compilers.ui
CrossCompiler.ui
@@ -137,7 +106,7 @@ QT4_WRAP_UI(UI_SRCS
RegexExplorer.ui
WarningMessagesDialog.ui
)
-QT4_WRAP_CPP(MOC_SRCS
+qt5_wrap_cpp(MOC_SRCS
AddCacheEntry.h
Compilers.h
CMakeSetupDialog.h
@@ -148,14 +117,24 @@ QT4_WRAP_CPP(MOC_SRCS
RegexExplorer.h
WarningMessagesDialog.h
)
-QT4_ADD_RESOURCES(RC_SRCS CMakeSetup.qrc)
+qt5_add_resources(RC_SRCS CMakeSetup.qrc)
+
+if (FALSE) # CMake's bootstrap binary does not support automoc
+ set(CMAKE_AUTOMOC 1)
+ set(CMAKE_AUTORCC 1)
+ set(CMAKE_AUTOUIC 1)
+else ()
+ list(APPEND SRCS
+ ${UI_SRCS}
+ ${MOC_SRCS}
+ ${RC_SRCS})
+endif ()
-set(SRCS ${SRCS} ${UI_SRCS} ${MOC_SRCS} ${RC_SRCS})
if(WIN32)
- set(SRCS ${SRCS} CMakeSetup.rc)
+ list(APPEND SRCS CMakeSetup.rc)
endif()
if(APPLE)
- set(SRCS ${SRCS} CMakeSetup.icns)
+ list(APPEND SRCS CMakeSetup.icns)
set(MACOSX_BUNDLE_ICON_FILE CMakeSetup.icns)
set_source_files_properties(CMakeSetup.icns PROPERTIES
MACOSX_PACKAGE_LOCATION Resources)
@@ -172,7 +151,7 @@ endif()
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(cmake-gui WIN32 MACOSX_BUNDLE ${SRCS} ${MANIFEST_FILE})
-target_link_libraries(cmake-gui CMakeLib ${QT_QTMAIN_LIBRARY} ${CMake_QT_LIBRARIES})
+target_link_libraries(cmake-gui CMakeLib Qt5::Core Qt5::Widgets ${CMake_QT_EXTRA_LIBRARIES})
if(WIN32)
target_sources(cmake-gui PRIVATE $<TARGET_OBJECTS:CMakeVersion>)
diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx
index 9d928b2..7ef5a72 100644
--- a/Source/QtDialog/CMakeSetup.cxx
+++ b/Source/QtDialog/CMakeSetup.cxx
@@ -115,14 +115,6 @@ int main(int argc, char** argv)
QTextCodec* utf8_codec = QTextCodec::codecForName("UTF-8");
QTextCodec::setCodecForLocale(utf8_codec);
-#if QT_VERSION < 0x050000
- // clean out standard Qt paths for plugins, which we don't use anyway
- // when creating Mac bundles, it potentially causes problems
- foreach (QString p, QApplication::libraryPaths()) {
- QApplication::removeLibraryPath(p);
- }
-#endif
-
// tell the cmake library where cmake is
QDir cmExecDir(QApplication::applicationDirPath());
#if defined(Q_OS_MAC)
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index 776af81..a631404 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -340,11 +340,7 @@ void QCMake::interrupt()
bool QCMake::interruptCallback()
{
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- return this->InterruptFlag;
-#else
return this->InterruptFlag.load();
-#endif
}
void QCMake::progressCallback(const std::string& msg, float percent)
diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx
index 541d3e9..928494b 100644
--- a/Source/QtDialog/QCMakeCacheView.cxx
+++ b/Source/QtDialog/QCMakeCacheView.cxx
@@ -155,11 +155,7 @@ QModelIndex QCMakeCacheView::moveCursor(CursorAction act,
void QCMakeCacheView::setShowAdvanced(bool s)
{
-#if QT_VERSION >= 040300
- // new 4.3 API that needs to be called. what about an older Qt?
this->SearchFilter->invalidate();
-#endif
-
this->AdvancedFilter->setShowAdvanced(s);
}
@@ -209,9 +205,7 @@ void QCMakeCacheModel::clear()
void QCMakeCacheModel::setProperties(const QCMakePropertyList& props)
{
-#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
this->beginResetModel();
-#endif
QSet<QCMakeProperty> newProps;
QSet<QCMakeProperty> newProps2;
@@ -334,11 +328,7 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props)
}
this->blockSignals(b);
-#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
this->endResetModel();
-#else
- this->reset();
-#endif
}
QCMakeCacheModel::ViewType QCMakeCacheModel::viewType() const
@@ -348,9 +338,7 @@ QCMakeCacheModel::ViewType QCMakeCacheModel::viewType() const
void QCMakeCacheModel::setViewType(QCMakeCacheModel::ViewType t)
{
-#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
this->beginResetModel();
-#endif
this->View = t;
@@ -367,11 +355,7 @@ void QCMakeCacheModel::setViewType(QCMakeCacheModel::ViewType t)
this->setProperties(oldProps);
this->setProperties(props);
this->blockSignals(b);
-#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
this->endResetModel();
-#else
- this->reset();
-#endif
}
void QCMakeCacheModel::setPropertyData(const QModelIndex& idx1,
@@ -497,8 +481,7 @@ QCMakePropertyList QCMakeCacheModel::properties() const
// go to the next in the tree
while (!idxs.isEmpty() &&
(
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) && \
- QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
+#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
(idxs.last().row() + 1) >= rowCount(idxs.last().parent()) ||
#endif
!idxs.last().sibling(idxs.last().row() + 1, 0).isValid())) {
@@ -658,20 +641,6 @@ bool QCMakeCacheModelDelegate::editorEvent(QEvent* e,
return success;
}
-// Issue 205903 fixed in Qt 4.5.0.
-// Can remove this function and FileDialogFlag when minimum Qt version is 4.5
-bool QCMakeCacheModelDelegate::eventFilter(QObject* object, QEvent* evt)
-{
- // workaround for what looks like a bug in Qt on macOS
- // where it doesn't create a QWidget wrapper for the native file dialog
- // so the Qt library ends up assuming the focus was lost to something else
-
- if (evt->type() == QEvent::FocusOut && this->FileDialogFlag) {
- return false;
- }
- return QItemDelegate::eventFilter(object, evt);
-}
-
void QCMakeCacheModelDelegate::setModelData(QWidget* editor,
QAbstractItemModel* model,
const QModelIndex& index) const
diff --git a/Source/QtDialog/QCMakeCacheView.h b/Source/QtDialog/QCMakeCacheView.h
index bea1965..a252708 100644
--- a/Source/QtDialog/QCMakeCacheView.h
+++ b/Source/QtDialog/QCMakeCacheView.h
@@ -144,7 +144,6 @@ public:
bool editorEvent(QEvent* event, QAbstractItemModel* model,
const QStyleOptionViewItem& option,
const QModelIndex& index);
- bool eventFilter(QObject* object, QEvent* event);
void setModelData(QWidget* editor, QAbstractItemModel* model,
const QModelIndex& index) const;
QSize sizeHint(const QStyleOptionViewItem& option,