Skip to content

Commit

Permalink
Fix Qt5 build for custom widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids authored and m-kuhn committed Jan 6, 2015
1 parent 664efe9 commit d8acc55
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 23 deletions.
6 changes: 0 additions & 6 deletions CMakeLists.txt
Expand Up @@ -240,9 +240,7 @@ IF (ENABLE_QT5)
FIND_PACKAGE(Qt5Script REQUIRED)
FIND_PACKAGE(Qt5Sql REQUIRED)
SET(QT5_BUILD TRUE)

INCLUDE("cmake/modules/ECMQt4To5Porting.cmake")

MESSAGE(STATUS "Found Qt version: ${Qt5Core_VERSION_STRING}")
ELSE()
FIND_PACKAGE(Qt4 ${QT_MIN_VERSION} REQUIRED)
Expand All @@ -251,10 +249,6 @@ ELSE()
SET(QT_USE_QTSVG 1)
SET(QT_USE_QTSQL 1)
SET(QT_USE_QTWEBKIT 1)
IF (WITH_CUSTOM_WIDGETS)
SET(QT_USE_QTDESIGNER 1)
ENDIF (WITH_CUSTOM_WIDGETS)

IF (NOT QT_QTXML_FOUND OR NOT QT_QTNETWORK_FOUND OR NOT QT_QTSVG_FOUND OR NOT QT_QTSQL_FOUND OR NOT QT_QTWEBKIT_FOUND OR (WITH_CUSTOM_WIDGETS AND NOT QT_QTDESIGNER_FOUND))
MESSAGE(SEND_ERROR "Some Qt4 modules haven't been found!")
ENDIF (NOT QT_QTXML_FOUND OR NOT QT_QTNETWORK_FOUND OR NOT QT_QTSVG_FOUND OR NOT QT_QTSQL_FOUND OR NOT QT_QTWEBKIT_FOUND OR (WITH_CUSTOM_WIDGETS AND NOT QT_QTDESIGNER_FOUND))
Expand Down
3 changes: 3 additions & 0 deletions cmake/modules/ECMQt4To5Porting.cmake
Expand Up @@ -243,3 +243,6 @@ macro(qt4_add_resources)
qt5_add_resources(${ARGN})
endmacro()

# get the Qt plugins directory
GET_TARGET_PROPERTY(QMAKE_EXECUTABLE Qt5::qmake LOCATION)
EXEC_PROGRAM(${QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_PLUGINS" RETURN_VALUE return_code OUTPUT_VARIABLE QT_PLUGINS_DIR )
11 changes: 9 additions & 2 deletions src/customwidgets/CMakeLists.txt
Expand Up @@ -2,6 +2,12 @@ ADD_DEFINITIONS(-DQT_PLUGIN)
ADD_DEFINITIONS(-DQT_NO_DEBUG)
ADD_DEFINITIONS(-DQT_SHARED)

IF (QT5_BUILD)
FIND_PACKAGE(Qt5Designer REQUIRED)
ENDIF (QT5_BUILD)

SET(QT_USE_QTDESIGNER ON)

IF (WIN32)
IF (MSVC)
ADD_DEFINITIONS("-DCUSTOMWIDGETS_EXPORT=${DLLEXPORT}")
Expand Down Expand Up @@ -51,8 +57,6 @@ SET (QGIS_CUSTOMWIDGETS_MOC_HDRS
qgsspinboxplugin.h
)

QT4_WRAP_CPP(QGIS_CUSTOMWIDGETS_MOC_SRCS ${QGIS_CUSTOMWIDGETS_MOC_HDRS})

IF(MSVC)
SET_SOURCE_FILES_PROPERTIES(${QGIS_CUSTOMWIDGETS_MOC_SRCS} PROPERTIES COMPILE_FLAGS "/wd4996" )
ELSE(MSVC)
Expand Down Expand Up @@ -92,8 +96,11 @@ INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}/../gui/editorwidgets/
${CMAKE_CURRENT_BINARY_DIR}/../ui/
${GEOS_INCLUDE_DIR}
${Qt5Designer_INCLUDE_DIRS}
)

QT4_WRAP_CPP(QGIS_CUSTOMWIDGETS_MOC_SRCS ${QGIS_CUSTOMWIDGETS_MOC_HDRS})

#############################################################
# qgis_customwidgets library

Expand Down
34 changes: 19 additions & 15 deletions src/customwidgets/qgiscustomwidgets.cpp
Expand Up @@ -25,6 +25,7 @@
#include "qgsdoublespinboxplugin.h"
#include "qgsfieldcomboboxplugin.h"
#include "qgsfieldexpressionwidgetplugin.h"
#include "qgsfilterlineeditplugin.h"
#include "qgsmaplayercomboboxplugin.h"
#include "qgsprojectionselectionwidgetplugin.h"
#include "qgsrelationeditorwidgetplugin.h"
Expand All @@ -36,25 +37,28 @@
QgisCustomWidgets::QgisCustomWidgets( QObject *parent )
: QObject( parent )
{
mWidgets.append( new QgsCollapsibleGroupBoxPlugin );
mWidgets.append( new QgsColorButtonPlugin );
mWidgets.append( new QgsColorButtonV2Plugin );
mWidgets.append( new QgsDataDefinedButtonPlugin );
mWidgets.append( new QgsDateTimeEditPlugin );
mWidgets.append( new QgsDoubleSpinBoxPlugin );
mWidgets.append( new QgsFieldComboBoxPlugin );
mWidgets.append( new QgsFieldExpressionWidgetPlugin );
mWidgets.append( new QgsMapLayerComboBoxPlugin );
mWidgets.append( new QgsProjectionSelectionWidgetPlugin );
mWidgets.append( new QgsRelationEditorWidgetPlugin );
mWidgets.append( new QgsRelationReferenceWidgetPlugin );
mWidgets.append( new QgsScaleRangeWidgetPlugin );
mWidgets.append( new QgsSpinBoxPlugin );
mWidgets.append( new QgsCollapsibleGroupBoxPlugin(this) );
mWidgets.append( new QgsColorButtonPlugin(this) );
mWidgets.append( new QgsColorButtonV2Plugin(this) );
mWidgets.append( new QgsDataDefinedButtonPlugin(this) );
mWidgets.append( new QgsDateTimeEditPlugin(this) );
mWidgets.append( new QgsDoubleSpinBoxPlugin(this) );
mWidgets.append( new QgsFieldComboBoxPlugin(this) );
mWidgets.append( new QgsFieldExpressionWidgetPlugin(this) );
mWidgets.append( new QgsFilterLineEditPlugin(this) );
mWidgets.append( new QgsMapLayerComboBoxPlugin(this) );
mWidgets.append( new QgsProjectionSelectionWidgetPlugin(this) );
mWidgets.append( new QgsRelationEditorWidgetPlugin(this) );
mWidgets.append( new QgsRelationReferenceWidgetPlugin(this) );
mWidgets.append( new QgsScaleRangeWidgetPlugin(this) );
mWidgets.append( new QgsSpinBoxPlugin(this) );
}

QList<QDesignerCustomWidgetInterface*> QgisCustomWidgets::customWidgets() const
{
return mWidgets;
}

Q_EXPORT_PLUGIN2( customwidgetsplugin, QgisCustomWidgets )
#if QT_VERSION < 0x050000
Q_EXPORT_PLUGIN2( customwidgetsplugin, QgisCustomWidgets )
#endif
5 changes: 5 additions & 0 deletions src/customwidgets/qgiscustomwidgets.h
Expand Up @@ -16,12 +16,17 @@
#ifndef QGISCUSTOMWIDGETS_H
#define QGISCUSTOMWIDGETS_H


#include <QDesignerCustomWidgetCollectionInterface>
#include <qplugin.h>


class QgisCustomWidgets : public QObject, public QDesignerCustomWidgetCollectionInterface
{
Q_OBJECT
#if QT_VERSION >= 0x050000
Q_PLUGIN_METADATA(IID "org.qgis.CustomWidgets")
#endif
Q_INTERFACES( QDesignerCustomWidgetCollectionInterface )

public:
Expand Down
5 changes: 5 additions & 0 deletions src/providers/wms/CMakeLists.txt
@@ -1,3 +1,8 @@
IF (QT5_BUILD)
FIND_PACKAGE(Qt5XmlPatterns REQUIRED)
ENDIF()


SET (WMS_SRCS
qgswmscapabilities.cpp
qgswmsprovider.cpp
Expand Down

0 comments on commit d8acc55

Please sign in to comment.