libdbusmenu-qt6
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
From af9fa001dac49eedc76e15613b67abfd097105f3 Mon Sep 17 00:00:00 2001
|
||||
From: Ilya Fedin <fedin-ilja2010@ya.ru>
|
||||
Date: Sun, 24 Oct 2021 04:25:58 +0400
|
||||
Subject: [PATCH] Fix build with Qt 6
|
||||
|
||||
---
|
||||
src/dbusmenuexporter.cpp | 3 ++-
|
||||
src/dbusmenuimporter.cpp | 1 +
|
||||
src/dbusmenushortcut_p.cpp | 27 +++++++++++++++++++++++++++
|
||||
src/dbusmenushortcut_p.h | 4 ++++
|
||||
4 files changed, 34 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/dbusmenuexporter.cpp b/src/dbusmenuexporter.cpp
|
||||
index f30ce11..9bb5c10 100644
|
||||
--- a/src/dbusmenuexporter.cpp
|
||||
+++ b/src/dbusmenuexporter.cpp
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QTimer>
|
||||
#include <QToolButton>
|
||||
#include <QWidgetAction>
|
||||
+#include <QActionGroup>
|
||||
|
||||
// Local
|
||||
#include "dbusmenu_config.h"
|
||||
@@ -484,7 +485,7 @@ void DBusMenuExporter::activateAction(QAction *action)
|
||||
{
|
||||
int id = d->idForAction(action);
|
||||
DMRETURN_IF_FAIL(id >= 0);
|
||||
- uint timeStamp = QDateTime::currentDateTime().toTime_t();
|
||||
+ uint timeStamp = QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||
d->m_dbusObject->ItemActivationRequested(id, timeStamp);
|
||||
}
|
||||
|
||||
diff --git a/src/dbusmenuimporter.cpp b/src/dbusmenuimporter.cpp
|
||||
index ce6ef18..94abb59 100644
|
||||
--- a/src/dbusmenuimporter.cpp
|
||||
+++ b/src/dbusmenuimporter.cpp
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <QTimer>
|
||||
#include <QToolButton>
|
||||
#include <QWidgetAction>
|
||||
+#include <QActionGroup>
|
||||
|
||||
// Local
|
||||
#include "dbusmenutypes_p.h"
|
||||
diff --git a/src/dbusmenushortcut_p.cpp b/src/dbusmenushortcut_p.cpp
|
||||
index 29d2e58..9f4fc0a 100644
|
||||
--- a/src/dbusmenushortcut_p.cpp
|
||||
+++ b/src/dbusmenushortcut_p.cpp
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
// Qt
|
||||
#include <QtGui/QKeySequence>
|
||||
+#include <QtDBus/QDBusArgument>
|
||||
|
||||
// Local
|
||||
#include "debug_p.h"
|
||||
@@ -83,3 +84,29 @@ QKeySequence DBusMenuShortcut::toKeySequence() const
|
||||
QString string = tmp.join(QLatin1String(", "));
|
||||
return QKeySequence::fromString(string);
|
||||
}
|
||||
+
|
||||
+QDBusArgument &operator<<(QDBusArgument &argument, const DBusMenuShortcut &obj)
|
||||
+{
|
||||
+ int id = qMetaTypeId<QStringList>();
|
||||
+ argument.beginArray(id);
|
||||
+ typename DBusMenuShortcut::ConstIterator it = obj.constBegin();
|
||||
+ typename DBusMenuShortcut::ConstIterator end = obj.constEnd();
|
||||
+ for ( ; it != end; ++it)
|
||||
+ argument << *it;
|
||||
+ argument.endArray();
|
||||
+ return argument;
|
||||
+}
|
||||
+
|
||||
+const QDBusArgument &operator>>(const QDBusArgument &argument, DBusMenuShortcut &obj)
|
||||
+{
|
||||
+ argument.beginArray();
|
||||
+ obj.clear();
|
||||
+ while (!argument.atEnd()) {
|
||||
+ QStringList item;
|
||||
+ argument >> item;
|
||||
+ obj.push_back(item);
|
||||
+ }
|
||||
+ argument.endArray();
|
||||
+
|
||||
+ return argument;
|
||||
+}
|
||||
diff --git a/src/dbusmenushortcut_p.h b/src/dbusmenushortcut_p.h
|
||||
index e26dd8c..d62c272 100644
|
||||
--- a/src/dbusmenushortcut_p.h
|
||||
+++ b/src/dbusmenushortcut_p.h
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
|
||||
class QKeySequence;
|
||||
+class QDBusArgument;
|
||||
|
||||
class DBUSMENU_EXPORT DBusMenuShortcut : public QList<QStringList>
|
||||
{
|
||||
@@ -40,4 +41,7 @@ class DBUSMENU_EXPORT DBusMenuShortcut : public QList<QStringList>
|
||||
|
||||
Q_DECLARE_METATYPE(DBusMenuShortcut)
|
||||
|
||||
+DBUSMENU_EXPORT QDBusArgument &operator<<(QDBusArgument &argument, const DBusMenuShortcut &);
|
||||
+DBUSMENU_EXPORT const QDBusArgument &operator>>(const QDBusArgument &argument, DBusMenuShortcut &);
|
||||
+
|
||||
#endif /* DBUSMENUSHORTCUT_H */
|
||||
@@ -0,0 +1,207 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 72cbc45..15b3ffe 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -25,7 +25,7 @@ set(dbusmenu_qt_lib_PATCH_VERSION 0)
|
||||
set(dbusmenu_qt_lib_VERSION ${dbusmenu_qt_lib_SOVERSION}.${dbusmenu_qt_lib_API_VERSION}.${dbusmenu_qt_lib_PATCH_VERSION})
|
||||
|
||||
# Check if we want to explicitly select the Qt version to be used or autodetect
|
||||
-if (NOT USE_QT4 AND NOT USE_QT5)
|
||||
+if (NOT USE_QT4 AND NOT USE_QT5 AND NOT USE_QT6)
|
||||
# Autodetect, prefering Qt5
|
||||
message(STATUS "Autodetecting Qt version to use")
|
||||
find_package(Qt5Widgets QUIET)
|
||||
@@ -35,7 +35,15 @@ if (NOT USE_QT4 AND NOT USE_QT5)
|
||||
endif()
|
||||
|
||||
# Detect for which Qt version we're building
|
||||
-if (USE_QT5)
|
||||
+if (USE_QT6)
|
||||
+ find_package(Qt6 REQUIRED COMPONENTS Core Widgets DBus)
|
||||
+ include_directories(${Qt5Widgets_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS})
|
||||
+ set(CMAKE_AUTOMOC ON)
|
||||
+ set(CMAKE_AUTOMOC_RELAXED_MODE ON)
|
||||
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
+
|
||||
+ set(QT_SUFFIX "qt6")
|
||||
+elseif (USE_QT5)
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
find_package(Qt5DBus REQUIRED)
|
||||
include_directories(${Qt5Widgets_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS})
|
||||
@@ -69,9 +77,9 @@ if (__DBUSMENU_HAVE_W_OVERLOADED_VIRTUAL)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual")
|
||||
endif (__DBUSMENU_HAVE_W_OVERLOADED_VIRTUAL)
|
||||
|
||||
-check_cxx_compiler_flag(-std=c++11 __DBUSMENU_HAVE_CXX11)
|
||||
+check_cxx_compiler_flag(-std=c++17 __DBUSMENU_HAVE_CXX11)
|
||||
if (__DBUSMENU_HAVE_CXX11)
|
||||
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
|
||||
endif (__DBUSMENU_HAVE_CXX11)
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
||||
index 2c4a4e8..e99d24a 100644
|
||||
--- a/src/CMakeLists.txt
|
||||
+++ b/src/CMakeLists.txt
|
||||
@@ -21,20 +21,23 @@ if (__DBUSMENU_HAVE_W_ALL)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
endif (__DBUSMENU_HAVE_W_ALL)
|
||||
|
||||
-check_cxx_compiler_flag(-std=c++11 __DBUSMENU_HAVE_CXX11)
|
||||
+check_cxx_compiler_flag(-std=c++17 __DBUSMENU_HAVE_CXX11)
|
||||
if (__DBUSMENU_HAVE_CXX11)
|
||||
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
|
||||
endif (__DBUSMENU_HAVE_CXX11)
|
||||
|
||||
# Check whether QIcon::name() exists. It was added in late Qt 4.7 cycle, and is
|
||||
# not present in betas.
|
||||
|
||||
-if (NOT USE_QT5)
|
||||
+if (NOT USE_QT5 AND NOT USE_QT6)
|
||||
set(CMAKE_REQUIRED_INCLUDES "${QT_INCLUDE_DIR}")
|
||||
set(CMAKE_REQUIRED_LIBRARIES "${QT_QTGUI_LIBRARIES};${QT_QTCORE_LIBRARIES}")
|
||||
-else()
|
||||
+elseif(USE_QT5)
|
||||
set(CMAKE_REQUIRED_INCLUDES "${Qt5Gui_INCLUDE_DIRS};${Qt5Core_INCLUDE_DIRS}")
|
||||
set(CMAKE_REQUIRED_LIBRARIES "${Qt5Gui_LIBRARIES};${Qt5Core_LIBRARIES}")
|
||||
+else()
|
||||
+ set(CMAKE_REQUIRED_INCLUDES "${Qt6Gui_INCLUDE_DIRS};${Qt6Core_INCLUDE_DIRS}")
|
||||
+ set(CMAKE_REQUIRED_LIBRARIES "${Qt6Gui_LIBRARIES};${Qt6Core_LIBRARIES}")
|
||||
endif()
|
||||
check_cxx_source_compiles("
|
||||
#include <QtGui/QIcon>
|
||||
@@ -64,17 +67,22 @@ include_directories(
|
||||
${CMAKE_BINARY_DIR}/src
|
||||
)
|
||||
|
||||
-if (NOT USE_QT5)
|
||||
+if (NOT USE_QT5 AND NOT USE_QT6)
|
||||
qt4_automoc(${dbusmenu_qt_SRCS})
|
||||
qt4_add_dbus_adaptor(dbusmenu_qt_SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/com.canonical.dbusmenu.xml
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/dbusmenuexporterdbus_p.h DBusMenuExporterDBus
|
||||
)
|
||||
-else()
|
||||
+elseif(USE_QT5)
|
||||
qt5_add_dbus_adaptor(dbusmenu_qt_SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/com.canonical.dbusmenu.xml
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/dbusmenuexporterdbus_p.h DBusMenuExporterDBus
|
||||
)
|
||||
+else()
|
||||
+ qt6_add_dbus_adaptor(dbusmenu_qt_SRCS
|
||||
+ ${CMAKE_CURRENT_SOURCE_DIR}/com.canonical.dbusmenu.xml
|
||||
+ ${CMAKE_CURRENT_SOURCE_DIR}/dbusmenuexporterdbus_p.h DBusMenuExporterDBus
|
||||
+ )
|
||||
endif()
|
||||
|
||||
configure_file(dbusmenu_version.h.in
|
||||
@@ -88,7 +96,7 @@ set_target_properties(dbusmenu-${QT_SUFFIX} PROPERTIES
|
||||
)
|
||||
|
||||
|
||||
-if (NOT USE_QT5)
|
||||
+if (NOT USE_QT5 AND NOT USE_QT6)
|
||||
target_link_libraries(dbusmenu-${QT_SUFFIX}
|
||||
${QT_QTGUI_LIBRARIES}
|
||||
${QT_QTDBUS_LIBRARIES}
|
||||
@@ -96,10 +104,10 @@ if (NOT USE_QT5)
|
||||
)
|
||||
else()
|
||||
target_link_libraries(dbusmenu-${QT_SUFFIX}
|
||||
- ${Qt5Gui_LIBRARIES}
|
||||
- ${Qt5Core_LIBRARIES}
|
||||
- ${Qt5DBus_LIBRARIES}
|
||||
- ${Qt5Widgets_LIBRARIES}
|
||||
+ Qt::Gui
|
||||
+ Qt::Core
|
||||
+ Qt::DBus
|
||||
+ Qt::Widgets
|
||||
)
|
||||
endif()
|
||||
|
||||
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
|
||||
index 6be27f5..4f21cb7 100644
|
||||
--- a/tests/CMakeLists.txt
|
||||
+++ b/tests/CMakeLists.txt
|
||||
@@ -1,9 +1,9 @@
|
||||
-if (NOT USE_QT5)
|
||||
+if (NOT USE_QT5 AND NOT USE_QT6)
|
||||
qt4_automoc(slowmenu.cpp)
|
||||
endif()
|
||||
add_executable(slowmenu slowmenu.cpp)
|
||||
|
||||
-if (NOT USE_QT5)
|
||||
+if (NOT USE_QT5 AND NOT USE_QT6)
|
||||
target_link_libraries(slowmenu
|
||||
${QT_QTGUI_LIBRARIES}
|
||||
${QT_QTDBUS_LIBRARIES}
|
||||
@@ -26,7 +26,7 @@ if (NOT USE_QT5)
|
||||
${QT_QTTEST_INCLUDE_DIR}
|
||||
${QT_QTDBUS_INCLUDE_DIR}
|
||||
)
|
||||
-else()
|
||||
+elseif(USE_QT5)
|
||||
find_package(Qt5Test REQUIRED)
|
||||
|
||||
target_link_libraries(slowmenu
|
||||
@@ -51,6 +51,31 @@ else()
|
||||
${Qt5Test_INCLUDE_DIRS}
|
||||
${Qt5DBus_INCLUDE_DIRS}
|
||||
)
|
||||
+else()
|
||||
+ find_package(Qt6Test REQUIRED)
|
||||
+
|
||||
+ target_link_libraries(slowmenu
|
||||
+ ${Qt6Gui_LIBRARIES}
|
||||
+ ${Qt6Core_LIBRARIES}
|
||||
+ ${Qt6DBus_LIBRARIES}
|
||||
+ dbusmenu-qt6
|
||||
+ )
|
||||
+
|
||||
+ set(test_LIBRARIES
|
||||
+ ${Qt6Gui_LIBRARIES}
|
||||
+ ${Qt6Core_LIBRARIES}
|
||||
+ ${Qt6DBus_LIBRARIES}
|
||||
+ ${Qt6Test_LIBRARIES}
|
||||
+ dbusmenu-qt6
|
||||
+ )
|
||||
+
|
||||
+ include_directories(
|
||||
+ ${CMAKE_CURRENT_SOURCE_DIR}/../src
|
||||
+ ${CMAKE_CURRENT_BINARY_DIR}/../src
|
||||
+ ${CMAKE_CURRENT_BINARY_DIR}
|
||||
+ ${Qt6Test_INCLUDE_DIRS}
|
||||
+ ${Qt6DBus_INCLUDE_DIRS}
|
||||
+ )
|
||||
endif()
|
||||
|
||||
# Macros to create "check" target
|
||||
@@ -77,7 +102,7 @@ set(dbusmenuexportertest_SRCS
|
||||
testutils.cpp
|
||||
)
|
||||
|
||||
-if (NOT USE_QT5)
|
||||
+if (NOT USE_QT5 AND NOT USE_QT6)
|
||||
qt4_automoc(${dbusmenuexportertest_SRCS})
|
||||
endif()
|
||||
|
||||
@@ -94,7 +119,7 @@ set(dbusmenuimportertest_SRCS
|
||||
testutils.cpp
|
||||
)
|
||||
|
||||
-if (NOT USE_QT5)
|
||||
+if (NOT USE_QT5 AND NOT USE_QT6)
|
||||
qt4_automoc(${dbusmenuimportertest_SRCS})
|
||||
endif()
|
||||
|
||||
@@ -110,7 +135,7 @@ set(dbusmenushortcuttest_SRCS
|
||||
dbusmenushortcuttest.cpp
|
||||
)
|
||||
|
||||
-if (NOT USE_QT5)
|
||||
+if (NOT USE_QT5 AND NOT USE_QT6)
|
||||
qt4_automoc(${dbusmenushortcuttest_SRCS})
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user