1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
From f3c2fb90e1c2b94e561ccf33e4c2049f96ce45e2 Mon Sep 17 00:00:00 2001
From: Aurelien Gateau <aurelien.gateau@canonical.com>
Date: Thu, 24 Jun 2010 10:04:35 +0200
Subject: [PATCH] Better build check for QIcon::name()
---
src/CMakeLists.txt | 21 +++++++++++++++++++++
src/dbusmenu_config.h.in | 2 ++
src/dbusmenuexporter.cpp | 3 ++-
3 files changed, 25 insertions(+), 1 deletions(-)
create mode 100644 src/dbusmenu_config.h.in
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2f4f5fd..ef555a3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,4 +1,7 @@
+include(CheckCXXSourceCompiles)
include (CheckCXXCompilerFlag)
+
+# Check some compiler flags
check_cxx_compiler_flag(-fvisibility=hidden __DBUSMENU_HAVE_GCC_VISIBILITY)
if (__DBUSMENU_HAVE_GCC_VISIBILITY AND NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
@@ -18,6 +21,24 @@ if (MSVC)
add_definitions(-D__PRETTY_FUNCTION__=__FUNCTION__)
endif (MSVC)
+# Check whether QIcon::name() exists. It was added in late Qt 4.7 cycle, and is
+# not present in betas.
+set(CMAKE_REQUIRED_INCLUDES "${QT_INCLUDE_DIR}")
+set(CMAKE_REQUIRED_LIBRARIES "QtGui")
+check_cxx_source_compiles("
+#include <QtGui/QIcon>
+int main() {
+ QIcon icon;
+ icon.name();
+ return 0;
+}
+" HAVE_QICON_NAME)
+if (NOT HAVE_QICON_NAME)
+ message(STATUS "QIcon::name() does not exist, DBusMenuExporter will not export icon names by itself")
+endif()
+configure_file(dbusmenu_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/dbusmenu_config.h @ONLY)
+
+
set(dbusmenu_qt_SRCS
dbusmenu_p.cpp
dbusmenuexporter.cpp
diff --git a/src/dbusmenu_config.h.in b/src/dbusmenu_config.h.in
new file mode 100644
index 0000000..c884fb7
--- /dev/null
+++ b/src/dbusmenu_config.h.in
@@ -0,0 +1,2 @@
+/* Whether QIcon::name() exists */
+#cmakedefine HAVE_QICON_NAME
diff --git a/src/dbusmenuexporter.cpp b/src/dbusmenuexporter.cpp
index af37eaa..e77681c 100644
--- a/src/dbusmenuexporter.cpp
+++ b/src/dbusmenuexporter.cpp
@@ -30,6 +30,7 @@
#include <QXmlStreamWriter>
// Local
+#include "dbusmenu_config.h"
#include "dbusmenu_p.h"
#include "dbusmenuexporterdbus_p.h"
#include "dbusmenuexporterprivate_p.h"
@@ -277,7 +278,7 @@ void DBusMenuExporter::doEmitLayoutUpdated()
QString DBusMenuExporter::iconNameForAction(QAction *action)
{
DMRETURN_VALUE_IF_FAIL(action, QString());
-#if QT_VERSION >= 0x040700
+#ifdef HAVE_QICON_NAME
QIcon icon = action->icon();
return icon.isNull() ? QString() : icon.name();
#else
--
1.6.1
|