Merge lp:~3v1n0/appmenu-qt5/xenial-sru2 into lp:appmenu-qt5/16.04

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 42
Proposed branch: lp:~3v1n0/appmenu-qt5/xenial-sru2
Merge into: lp:appmenu-qt5/16.04
Diff against target: 156 lines (+67/-13)
5 files modified
debian/changelog (+11/-0)
src/appmenuplatformmenubar.cpp (+13/-3)
src/appmenuplatformsystemtrayicon.cpp (+1/-1)
src/iconcache.cpp (+41/-7)
src/iconcache.h (+1/-2)
To merge this branch: bzr merge lp:~3v1n0/appmenu-qt5/xenial-sru2
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
Review via email: mp+317136@code.launchpad.net

This proposal supersedes a proposal from 2017-02-13.

Commit message

Releasing Xenial SRU2

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) wrote :

+1

review: Approve
lp:~3v1n0/appmenu-qt5/xenial-sru2 updated
43. By Marco Trevisan (Treviño)

IconCache: use $XDG_RUNTIME_DIR as preferred place where to save icons

Now that supports it, we can safely use it.

44. By Marco Trevisan (Treviño)

AppMenuPlatformMenuBar: Don't initialize X11 related functions in other environments

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2017-02-13 18:27:48 +0000
3+++ debian/changelog 2017-02-16 22:56:28 +0000
4@@ -1,3 +1,14 @@
5+appmenu-qt5 (0.3.0+16.04.20151130-0ubuntu3) UNRELEASED; urgency=medium
6+
7+ * IconCache: get the proper theme path based on the fact we're using a
8+ themed icon or not (LP: #1600136)
9+ * IconCache: use $XDG_RUNTIME_DIR as preferred place where to save
10+ icons
11+ * AppMenuPlatformMenuBar: Don't initialize X11 related functions in
12+ other environments (LP: #1606246)
13+
14+ -- Marco Trevisan (Treviño) <mail@3v1n0.net> Thu, 16 Feb 2017 23:48:55 +0100
15+
16 appmenu-qt5 (0.3.0+16.04.20151130-0ubuntu2) xenial; urgency=medium
17
18 * Fix for creating two or more system tray icons. (LP: #1573639, LP:
19
20=== modified file 'src/appmenuplatformmenubar.cpp'
21--- src/appmenuplatformmenubar.cpp 2014-12-13 15:38:51 +0000
22+++ src/appmenuplatformmenubar.cpp 2017-02-16 22:56:28 +0000
23@@ -229,6 +229,10 @@
24 /* Helper function, as copy-pasted from Qt 5.2.1 gtk2 platformthemeplugin */
25 static QString gtkSetting(const gchar *propertyName)
26 {
27+ if (qgetenv("DISPLAY").isEmpty()) {
28+ return QString();
29+ }
30+
31 GtkSettings *settings = gtk_settings_get_default();
32 gchararray value;
33 g_object_get(settings, propertyName, &value, NULL);
34@@ -261,13 +265,19 @@
35 GnomeAppMenuPlatformTheme::GnomeAppMenuPlatformTheme()
36 : QGnomeTheme()
37 {
38- int (*oldErrorHandler)(Display *, XErrorEvent *) = XSetErrorHandler(NULL);
39- gtk_init(0, 0);
40- XSetErrorHandler(oldErrorHandler);
41+ if (!qgetenv("DISPLAY").isEmpty()) {
42+ int (*oldErrorHandler)(Display *, XErrorEvent *) = XSetErrorHandler(NULL);
43+ gtk_init(0, 0);
44+ XSetErrorHandler(oldErrorHandler);
45+ }
46 }
47
48 QVariant GnomeAppMenuPlatformTheme::themeHint(QPlatformTheme::ThemeHint hint) const
49 {
50+ if (qgetenv("DISPLAY").isEmpty()) {
51+ return QVariant(QVariant::String);
52+ }
53+
54 switch (hint) {
55 case QPlatformTheme::SystemIconThemeName:
56 return QVariant(gtkSetting("gtk-icon-theme-name"));
57
58=== modified file 'src/appmenuplatformsystemtrayicon.cpp'
59--- src/appmenuplatformsystemtrayicon.cpp 2016-05-11 14:54:49 +0000
60+++ src/appmenuplatformsystemtrayicon.cpp 2017-02-16 22:56:28 +0000
61@@ -180,7 +180,7 @@
62
63 QString AppMenuPlatformSystemTrayIcon::iconThemePath() const
64 {
65- return iconCache.themePath();
66+ return iconCache.themePath(m_icon);
67 }
68
69 QString AppMenuPlatformSystemTrayIcon::iconName() const
70
71=== modified file 'src/iconcache.cpp'
72--- src/iconcache.cpp 2014-12-13 15:38:51 +0000
73+++ src/iconcache.cpp 2017-02-16 22:56:28 +0000
74@@ -29,8 +29,7 @@
75
76 IconCache::IconCache(QObject *parent):
77 QObject(parent),
78- m_temporaryDir(Q_NULLPTR),
79- m_initialized(false)
80+ m_temporaryDir(Q_NULLPTR)
81 {
82 }
83
84@@ -41,13 +40,48 @@
85 }
86 }
87
88-QString IconCache::themePath()
89+QString IconCache::themePath(const QIcon &icon)
90 {
91- if (!m_initialized) {
92- QString path = QDir::tempPath() + QStringLiteral("/iconcache-XXXXXX");
93+ if (!m_temporaryDir) {
94+ QString dir;
95+ QString runtimeDir = QString::fromUtf8(getenv("XDG_RUNTIME_DIR"));
96+
97+ if (!runtimeDir.isEmpty()) {
98+ dir = runtimeDir;
99+ QDir d(dir);
100+ if (!d.exists()) {
101+ d.mkpath(".");
102+ }
103+ } else if (!getenv("SNAP")) {
104+ dir = QDir::tempPath();
105+ } else {
106+ // Try to get the .cache from $XDG_CACHE_HOME, if it's not set,
107+ // it has to be in ~/.cache as per XDG standard
108+ dir = QString::fromUtf8(getenv("XDG_CACHE_HOME"));
109+ if (dir.isEmpty()) {
110+ dir = QDir::cleanPath(QDir::homePath() + QStringLiteral("/.cache"));
111+ }
112+
113+ QDir d(dir);
114+ if (!d.exists()) {
115+ d.mkpath(".");
116+ }
117+ }
118+
119+ QString path = dir + QStringLiteral("/qt-tray-iconcache-XXXXXX");
120 m_temporaryDir = new QTemporaryDir(path);
121- m_initialized = true;
122- }
123+ }
124+
125+ if (!icon.isNull() && !icon.name().isEmpty() && QIcon::hasThemeIcon(icon.name())) {
126+ QString dataHome = QString::fromUtf8(getenv("XDG_DATA_HOME"));
127+
128+ if (dataHome.isEmpty()) {
129+ dataHome = QDir::homePath() + "/.local/share";
130+ }
131+
132+ return QDir::cleanPath(dataHome + "/icons");
133+ }
134+
135 return m_temporaryDir->path();
136 }
137
138
139=== modified file 'src/iconcache.h'
140--- src/iconcache.h 2014-12-13 15:38:51 +0000
141+++ src/iconcache.h 2017-02-16 22:56:28 +0000
142@@ -39,13 +39,12 @@
143
144 static const int MaxIconCount;
145
146- QString themePath();
147+ QString themePath(const QIcon &icon = QIcon());
148 QString nameForIcon(const QIcon &icon);
149
150 private:
151 QTemporaryDir *m_temporaryDir;
152 mutable QList<qint64> m_cacheKeys;
153- bool m_initialized;
154
155 void cacheIcon(qint64 key, const QIcon &);
156 void trimCache();

Subscribers

People subscribed via source and target branches