diff --git a/cmake/modules/ECMQt4To5Porting.cmake b/cmake/modules/ECMQt4To5Porting.cmake new file mode 100644 index 0000000..4204fa5 --- /dev/null +++ b/cmake/modules/ECMQt4To5Porting.cmake @@ -0,0 +1,235 @@ +#============================================================================= +# Copyright 2005-2011 Kitware, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of Kitware, Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#============================================================================= + +# The automoc_qt4 macro is superceded by CMAKE_AUTOMOC from CMake 2.8.6 +# A Qt 5 version is not provided by CMake or Qt. + +include(MacroAddFileDependencies) + +MACRO (QT4_GET_MOC_FLAGS _moc_flags) + SET(${_moc_flags}) + GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES) + + FOREACH(_current ${_inc_DIRS}) + IF("${_current}" MATCHES "\\.framework/?$") + STRING(REGEX REPLACE "/[^/]+\\.framework" "" framework_path "${_current}") + SET(${_moc_flags} ${${_moc_flags}} "-F${framework_path}") + ELSE("${_current}" MATCHES "\\.framework/?$") + SET(${_moc_flags} ${${_moc_flags}} "-I${_current}") + ENDIF("${_current}" MATCHES "\\.framework/?$") + ENDFOREACH(_current ${_inc_DIRS}) + + GET_DIRECTORY_PROPERTY(_defines COMPILE_DEFINITIONS) + FOREACH(_current ${_defines}) + SET(${_moc_flags} ${${_moc_flags}} "-D${_current}") + ENDFOREACH(_current ${_defines}) + + IF(Q_WS_WIN) + SET(${_moc_flags} ${${_moc_flags}} -DWIN32) + ENDIF(Q_WS_WIN) + +ENDMACRO(QT4_GET_MOC_FLAGS) + +# helper macro to set up a moc rule +MACRO (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options) + # For Windows, create a parameters file to work around command line length limit + IF (WIN32) + # Pass the parameters in a file. Set the working directory to + # be that containing the parameters file and reference it by + # just the file name. This is necessary because the moc tool on + # MinGW builds does not seem to handle spaces in the path to the + # file given with the @ syntax. + GET_FILENAME_COMPONENT(_moc_outfile_name "${outfile}" NAME) + GET_FILENAME_COMPONENT(_moc_outfile_dir "${outfile}" PATH) + IF(_moc_outfile_dir) + SET(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir}) + ENDIF(_moc_outfile_dir) + SET (_moc_parameters_file ${outfile}_parameters) + SET (_moc_parameters ${moc_flags} ${moc_options} -o "${outfile}" "${infile}") + STRING (REPLACE ";" "\n" _moc_parameters "${_moc_parameters}") + FILE (WRITE ${_moc_parameters_file} "${_moc_parameters}") + ADD_CUSTOM_COMMAND(OUTPUT ${outfile} + COMMAND ${QT_MOC_EXECUTABLE} @${_moc_outfile_name}_parameters + DEPENDS ${infile} + ${_moc_working_dir} + VERBATIM) + ELSE (WIN32) + ADD_CUSTOM_COMMAND(OUTPUT ${outfile} + COMMAND ${QT_MOC_EXECUTABLE} + ARGS ${moc_flags} ${moc_options} -o ${outfile} ${infile} + DEPENDS ${infile} VERBATIM) + ENDIF (WIN32) +ENDMACRO (QT4_CREATE_MOC_COMMAND) + + +MACRO(QT4_AUTOMOC) + QT4_GET_MOC_FLAGS(_moc_INCS) + + SET(_matching_FILES ) + FOREACH (_current_FILE ${ARGN}) + + GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE) + # if "SKIP_AUTOMOC" is set to true, we will not handle this file here. + # This is required to make uic work correctly: + # we need to add generated .cpp files to the sources (to compile them), + # but we cannot let automoc handle them, as the .cpp files don't exist yet when + # cmake is run for the very first time on them -> however the .cpp files might + # exist at a later run. at that time we need to skip them, so that we don't add two + # different rules for the same moc file + GET_SOURCE_FILE_PROPERTY(_skip ${_abs_FILE} SKIP_AUTOMOC) + + IF ( NOT _skip AND EXISTS ${_abs_FILE} ) + + FILE(READ ${_abs_FILE} _contents) + + GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH) + + STRING(REGEX MATCHALL "# *include +[^ ]+\\.moc[\">]" _match "${_contents}") + IF(_match) + FOREACH (_current_MOC_INC ${_match}) + STRING(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}") + + GET_FILENAME_COMPONENT(_basename ${_current_MOC} NAME_WE) + IF(EXISTS ${_abs_PATH}/${_basename}.hpp) + SET(_header ${_abs_PATH}/${_basename}.hpp) + ELSE(EXISTS ${_abs_PATH}/${_basename}.hpp) + SET(_header ${_abs_PATH}/${_basename}.h) + ENDIF(EXISTS ${_abs_PATH}/${_basename}.hpp) + SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC}) + QT4_CREATE_MOC_COMMAND(${_header} ${_moc} "${_moc_INCS}" "") + MACRO_ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc}) + ENDFOREACH (_current_MOC_INC) + ENDIF(_match) + ENDIF ( NOT _skip AND EXISTS ${_abs_FILE} ) + ENDFOREACH (_current_FILE) +ENDMACRO(QT4_AUTOMOC) + + +# Portability helpers. + +set(QT_QTGUI_LIBRARIES + ${Qt5Gui_LIBRARIES} + ${Qt5Widgets_LIBRARIES} + ${Qt5PrintSupport_LIBRARIES} + ${Qt5Svg_LIBRARIES} +) + +set(QT_INCLUDES + ${Qt5Gui_INCLUDE_DIRS} + ${Qt5Widgets_INCLUDE_DIRS} + ${Qt5PrintSupport_INCLUDE_DIRS} + ${Qt5Svg_INCLUDE_DIRS} +) +set(QT_QTGUI_LIBRARY ${QT_QTGUI_LIBRARIES}) + +set(_qt_modules + Core + Declarative + Widgets + Script + ScriptTools + DBus + Network + Test + Designer + Concurrent + Xml + UiTools + Qml + Quick + WebKit + WebKitWidgets + Sql + OpenGL +) + +foreach(_module ${_qt_modules}) + string(TOUPPER ${_module} _module_upper) + set(QT_QT${_module_upper}_LIBRARIES ${Qt5${_module}_LIBRARIES}) + set(QT_QT${_module_upper}_LIBRARY ${QT_QT${_module_upper}_LIBRARIES}) + list(APPEND QT_INCLUDES ${Qt5${_module}_INCLUDE_DIRS}) + set(QT_QT${_module_upper}_FOUND ${Qt5${_module}_FOUND}) +endforeach() + +list(APPEND QT_QTCORE_LIBRARIES ${Qt5Concurrent_LIBRARIES}) +list(APPEND QT_QTCORE_LIBRARY ${Qt5Concurrent_LIBRARIES}) + +list(APPEND QT_QTWEBKIT_LIBRARIES ${Qt5WebKitWidgets_LIBRARIES}) +list(APPEND QT_QTWEBKIT_LIBRARY ${Qt5WebKitWidgets_LIBRARIES}) + +get_target_property(QT_QMAKE_EXECUTABLE Qt5::qmake LOCATION) +get_target_property(QT_RCC_EXECUTABLE Qt5::rcc LOCATION) +if (TARGET Qt5::uic) + get_target_property(QT_UIC_EXECUTABLE Qt5::uic LOCATION) +endif() + +if (TARGET Qt5::qdbuscpp2xml) + get_target_property(QT_QDBUSCPP2XML_EXECUTABLE Qt5::qdbuscpp2xml LOCATION) +endif() + +if (TARGET Qt5::qdbusxml2cpp) + get_target_property(QT_QDBUSXML2CPP_EXECUTABLE Qt5::qdbusxml2cpp LOCATION) +endif() + +add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0) + +macro(qt4_wrap_ui) + qt5_wrap_ui(${ARGN}) +endmacro() + +macro(qt4_wrap_cpp) + qt5_wrap_cpp(${ARGN}) +endmacro() + +macro(qt4_generate_moc) + qt5_generate_moc(${ARGN}) +endmacro() + +macro(qt4_add_dbus_adaptor) + qt5_add_dbus_adaptor(${ARGN}) +endmacro() + +macro(qt4_add_dbus_interfaces) + qt5_add_dbus_interfaces(${ARGN}) +endmacro() + +macro(qt4_add_dbus_interface) + qt5_add_dbus_interface(${ARGN}) +endmacro() + +macro(qt4_generate_dbus_interface) + qt5_generate_dbus_interface(${ARGN}) +endmacro() + +macro(qt4_add_resources) + qt5_add_resources(${ARGN}) +endmacro() diff --git a/cmake/modules/FindQt5Transitional.cmake b/cmake/modules/FindQt5Transitional.cmake new file mode 100644 index 0000000..1b22076 --- /dev/null +++ b/cmake/modules/FindQt5Transitional.cmake @@ -0,0 +1,78 @@ + +find_package(Qt5Core QUIET) + +if (Qt5Core_FOUND) + set(_allComponents + Core + Gui + DBus + Designer + Declarative + Script + ScriptTools + Network + Test + Xml + Svg + Sql + Widgets + PrintSupport + Concurrent + UiTools + WebKit + WebKitWidgets + OpenGL + X11Extras + Qml + Quick + ) + if (NOT Qt5Transitional_FIND_COMPONENTS) + foreach(_component ${_allComponents}) + find_package(Qt5${_component}) + + list(APPEND QT_LIBRARIES ${Qt5${_component}_LIBRARIES}) + endforeach() + else() + set(_components ${Qt5Transitional_FIND_COMPONENTS}) + foreach(_component ${Qt5Transitional_FIND_COMPONENTS}) + find_package(Qt5${_component} REQUIRED) + if ("${_component}" STREQUAL "WebKit") + find_package(Qt5WebKitWidgets REQUIRED) + list(APPEND QT_LIBRARIES ${Qt5WebKitWidgets_LIBRARIES} ) + endif() + if ("${_component}" STREQUAL "Gui") + find_package(Qt5Widgets REQUIRED) + find_package(Qt5PrintSupport REQUIRED) + find_package(Qt5Svg REQUIRED) + list(APPEND QT_LIBRARIES ${Qt5Widgets_LIBRARIES} + ${Qt5PrintSupport_LIBRARIES} + ${Qt5Svg_LIBRARIES} ) + endif() + if ("${_component}" STREQUAL "Core") + find_package(Qt5Concurrent REQUIRED) + list(APPEND QT_LIBRARIES ${Qt5Concurrent_LIBRARIES} ) + endif() + endforeach() + endif() + + set(Qt5Transitional_FOUND TRUE) + set(QT5_BUILD TRUE) + + get_filename_component(_modules_dir "${CMAKE_CURRENT_LIST_DIR}/../modules" ABSOLUTE) + include("${_modules_dir}/ECMQt4To5Porting.cmake") # TODO: Port away from this. + +else() + foreach(_component ${Qt5Transitional_FIND_COMPONENTS}) + if("${_component}" STREQUAL "Widgets") # new in Qt5 + set(_component Gui) + elseif("${_component}" STREQUAL "Concurrent") # new in Qt5 + set(_component Core) + endif() + list(APPEND _components Qt${_component}) + endforeach() + find_package(Qt4 ${QT_MIN_VERSION} REQUIRED ${_components}) + + if(QT4_FOUND) + set(Qt5Transitional_FOUND TRUE) + endif() +endif() diff --git a/cmake/modules/NoKDE.cmake b/cmake/modules/NoKDE.cmake index da7fe1d..3db366c 100644 --- a/cmake/modules/NoKDE.cmake +++ b/cmake/modules/NoKDE.cmake @@ -1,13 +1,6 @@ -find_package( Qt4 REQUIRED ) +find_package(Qt5Transitional) +include_directories( ${QT_INCLUDES} ) -include_directories( ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTNETWORK_INCLUDE_DIR}) - -if (WITH_FREEDESKTOP_FRONTEND) - include_directories(${QT_QTDBUS_INCLUDE_DIR}) -endif (WITH_FREEDESKTOP_FRONTEND) - -include( ${QT_USE_FILE} ) if (CMAKE_COMPILER_IS_GNUCXX) set (KDE4_ENABLE_EXCEPTIONS -fexceptions) diff --git a/src/core/plugins/plugincontainer.cpp b/src/core/plugins/plugincontainer.cpp index 771836c..9b1d2bc 100644 --- a/src/core/plugins/plugincontainer.cpp +++ b/src/core/plugins/plugincontainer.cpp @@ -23,7 +23,6 @@ #include "snorebackend.h" #include "snorefrontend.h" -#include #include #include diff --git a/src/core/plugins/plugincontainer.h b/src/core/plugins/plugincontainer.h index 72b1b8b..8e4d209 100644 --- a/src/core/plugins/plugincontainer.h +++ b/src/core/plugins/plugincontainer.h @@ -62,4 +62,5 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(Snore::PluginContainer::PluginTypes) + #endif//PLUGINCONTAINER_H diff --git a/src/core/plugins/plugins.h b/src/core/plugins/plugins.h index 1bdd276..e83329a 100644 --- a/src/core/plugins/plugins.h +++ b/src/core/plugins/plugins.h @@ -24,6 +24,8 @@ #include #include #include +#include +#include namespace Snore{ class Application; @@ -61,6 +63,19 @@ private: Q_DECLARE_INTERFACE ( Snore::SnorePlugin, "org.Snore.SnorePlugin/1.0" ) +//compatability defines to reduce the number of ifdefs to make fiat compile with qt4 and qt5 +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) +# if defined(Q_EXPORT_PLUGIN) +# undef Q_EXPORT_PLUGIN +# endif +# if defined(Q_EXPORT_PLUGIN2) +# undef Q_EXPORT_PLUGIN2 +# endif +# define Q_EXPORT_PLUGIN(a) +# define Q_EXPORT_PLUGIN2(a, b) +#else +# define Q_PLUGIN_METADATA(a) +#endif diff --git a/src/core/plugins/snorebackend.cpp b/src/core/plugins/snorebackend.cpp index 22be3ec..72ba200 100644 --- a/src/core/plugins/snorebackend.cpp +++ b/src/core/plugins/snorebackend.cpp @@ -23,7 +23,6 @@ #include "../notification/notification.h" #include -#include #include #include diff --git a/src/core/plugins/snorebackend.h b/src/core/plugins/snorebackend.h index ff0f19d..2b37929 100644 --- a/src/core/plugins/snorebackend.h +++ b/src/core/plugins/snorebackend.h @@ -26,7 +26,6 @@ #include #include -#include namespace Snore{ diff --git a/src/core/plugins/snorefrontend.cpp b/src/core/plugins/snorefrontend.cpp index a7aed17..98c4bba 100644 --- a/src/core/plugins/snorefrontend.cpp +++ b/src/core/plugins/snorefrontend.cpp @@ -21,7 +21,6 @@ #include "../snore.h" #include -#include #include #include diff --git a/src/core/snore.cpp b/src/core/snore.cpp index 1f6455b..6781228 100644 --- a/src/core/snore.cpp +++ b/src/core/snore.cpp @@ -28,7 +28,6 @@ #include -#include #include #include #include @@ -76,10 +75,11 @@ QHash SnoreCore::pluginCache(){ QSettings &cache = cacheFile(); QString version = cache.value("version").toString(); QString path = cache.value("pluginPath").toString(); - int size = cache.beginReadArray("plugins"); + int size = cache.beginReadArray("plugins"); if(size == 0 || version != Version::revision() || path != pluginDir().path()){ qDebug() << version << "!=" << Version::revision(); qDebug() << path << "!=" << pluginDir().path(); + cache.endArray(); updatePluginCache(); }else{ for(int i=0;i +#include #ifdef HAVE_KDE #include "core/version.h" diff --git a/src/plugins/backends/growl/growl.h b/src/plugins/backends/growl/growl.h index 83974be..725c898 100644 --- a/src/plugins/backends/growl/growl.h +++ b/src/plugins/backends/growl/growl.h @@ -27,6 +27,8 @@ class Growl:public Snore::SnoreBackend { Q_OBJECT Q_INTERFACES(Snore::SnoreBackend) + Q_PLUGIN_METADATA(IID "org.Snore.NotificationBackend/1.0") + public: Growl(); ~Growl(); diff --git a/src/plugins/backends/snarl/snarl.cpp b/src/plugins/backends/snarl/snarl.cpp index eb415cc..c6bb728 100644 --- a/src/plugins/backends/snarl/snarl.cpp +++ b/src/plugins/backends/snarl/snarl.cpp @@ -173,7 +173,7 @@ void SnarlBackend::slotRegisterApplication(Application *application){ snarlInterface->Register(appName.toUtf8().constData(), application->name().toUtf8().constData(), application->icon().localUrl().toUtf8().constData(), - 0,m_eventLoop->winId(),SNORENOTIFIER_MESSAGE_ID); + 0,(HWND)m_eventLoop->winId(),SNORENOTIFIER_MESSAGE_ID); foreach(Alert *alert,application->alerts()){ qDebug()<<"registering snarl alert"<name(); diff --git a/src/plugins/backends/snarl/snarl.h b/src/plugins/backends/snarl/snarl.h index d3f690e..0ab8d37 100644 --- a/src/plugins/backends/snarl/snarl.h +++ b/src/plugins/backends/snarl/snarl.h @@ -28,6 +28,7 @@ class SnarlBackend:public Snore::SnoreBackend { Q_OBJECT Q_INTERFACES(Snore::SnoreBackend) + Q_PLUGIN_METADATA(IID "org.Snore.NotificationBackend/1.0") public: SnarlBackend(); ~SnarlBackend(); diff --git a/src/plugins/backends/snoretoast/snoretoast.cpp b/src/plugins/backends/snoretoast/snoretoast.cpp index e13f8d3..d22f914 100644 --- a/src/plugins/backends/snoretoast/snoretoast.cpp +++ b/src/plugins/backends/snoretoast/snoretoast.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include diff --git a/src/plugins/backends/snoretoast/snoretoast.h b/src/plugins/backends/snoretoast/snoretoast.h index 2351a1d..ba69309 100644 --- a/src/plugins/backends/snoretoast/snoretoast.h +++ b/src/plugins/backends/snoretoast/snoretoast.h @@ -2,11 +2,13 @@ #define TOASTER_H #include "core/plugins/snorebackend.h" +#include class SnoreToast : public Snore::SnoreBackend { Q_OBJECT Q_INTERFACES(Snore::SnoreBackend) + Q_PLUGIN_METADATA(IID "org.Snore.NotificationBackend/1.0") public: SnoreToast(); ~SnoreToast(); diff --git a/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.h b/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.h index 6d0d7cb..814a421 100644 --- a/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.h +++ b/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.h @@ -25,6 +25,7 @@ class FreedesktopFrontend:public Snore::SnoreFrontend{ Q_OBJECT Q_INTERFACES(Snore::SnoreFrontend) + Q_PLUGIN_METADATA(IID "org.Snore.NotificationFrontend/1.0") public: FreedesktopFrontend(); ~FreedesktopFrontend(); diff --git a/src/plugins/frontends/snarlnetwork/snarlnetwork.h b/src/plugins/frontends/snarlnetwork/snarlnetwork.h index 3c079d0..2ad6bcd 100644 --- a/src/plugins/frontends/snarlnetwork/snarlnetwork.h +++ b/src/plugins/frontends/snarlnetwork/snarlnetwork.h @@ -41,6 +41,7 @@ struct SnarlNotification{ class SnarlNetworkFrontend:public Snore::SnoreFrontend{ Q_OBJECT Q_INTERFACES(Snore::SnoreFrontend) + Q_PLUGIN_METADATA(IID "org.Snore.NotificationFrontend/1.0") friend class Parser; public: static const int port=9887;