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
=== modified file 'debian/changelog'
--- debian/changelog 2017-02-13 18:27:48 +0000
+++ debian/changelog 2017-02-16 22:56:28 +0000
@@ -1,3 +1,14 @@
1appmenu-qt5 (0.3.0+16.04.20151130-0ubuntu3) UNRELEASED; urgency=medium
2
3 * IconCache: get the proper theme path based on the fact we're using a
4 themed icon or not (LP: #1600136)
5 * IconCache: use $XDG_RUNTIME_DIR as preferred place where to save
6 icons
7 * AppMenuPlatformMenuBar: Don't initialize X11 related functions in
8 other environments (LP: #1606246)
9
10 -- Marco Trevisan (Treviño) <mail@3v1n0.net> Thu, 16 Feb 2017 23:48:55 +0100
11
1appmenu-qt5 (0.3.0+16.04.20151130-0ubuntu2) xenial; urgency=medium12appmenu-qt5 (0.3.0+16.04.20151130-0ubuntu2) xenial; urgency=medium
213
3 * Fix for creating two or more system tray icons. (LP: #1573639, LP:14 * Fix for creating two or more system tray icons. (LP: #1573639, LP:
415
=== modified file 'src/appmenuplatformmenubar.cpp'
--- src/appmenuplatformmenubar.cpp 2014-12-13 15:38:51 +0000
+++ src/appmenuplatformmenubar.cpp 2017-02-16 22:56:28 +0000
@@ -229,6 +229,10 @@
229/* Helper function, as copy-pasted from Qt 5.2.1 gtk2 platformthemeplugin */229/* Helper function, as copy-pasted from Qt 5.2.1 gtk2 platformthemeplugin */
230static QString gtkSetting(const gchar *propertyName)230static QString gtkSetting(const gchar *propertyName)
231{231{
232 if (qgetenv("DISPLAY").isEmpty()) {
233 return QString();
234 }
235
232 GtkSettings *settings = gtk_settings_get_default();236 GtkSettings *settings = gtk_settings_get_default();
233 gchararray value;237 gchararray value;
234 g_object_get(settings, propertyName, &value, NULL);238 g_object_get(settings, propertyName, &value, NULL);
@@ -261,13 +265,19 @@
261GnomeAppMenuPlatformTheme::GnomeAppMenuPlatformTheme()265GnomeAppMenuPlatformTheme::GnomeAppMenuPlatformTheme()
262 : QGnomeTheme()266 : QGnomeTheme()
263{267{
264 int (*oldErrorHandler)(Display *, XErrorEvent *) = XSetErrorHandler(NULL);268 if (!qgetenv("DISPLAY").isEmpty()) {
265 gtk_init(0, 0);269 int (*oldErrorHandler)(Display *, XErrorEvent *) = XSetErrorHandler(NULL);
266 XSetErrorHandler(oldErrorHandler);270 gtk_init(0, 0);
271 XSetErrorHandler(oldErrorHandler);
272 }
267}273}
268274
269QVariant GnomeAppMenuPlatformTheme::themeHint(QPlatformTheme::ThemeHint hint) const275QVariant GnomeAppMenuPlatformTheme::themeHint(QPlatformTheme::ThemeHint hint) const
270{276{
277 if (qgetenv("DISPLAY").isEmpty()) {
278 return QVariant(QVariant::String);
279 }
280
271 switch (hint) {281 switch (hint) {
272 case QPlatformTheme::SystemIconThemeName:282 case QPlatformTheme::SystemIconThemeName:
273 return QVariant(gtkSetting("gtk-icon-theme-name"));283 return QVariant(gtkSetting("gtk-icon-theme-name"));
274284
=== modified file 'src/appmenuplatformsystemtrayicon.cpp'
--- src/appmenuplatformsystemtrayicon.cpp 2016-05-11 14:54:49 +0000
+++ src/appmenuplatformsystemtrayicon.cpp 2017-02-16 22:56:28 +0000
@@ -180,7 +180,7 @@
180180
181QString AppMenuPlatformSystemTrayIcon::iconThemePath() const181QString AppMenuPlatformSystemTrayIcon::iconThemePath() const
182{182{
183 return iconCache.themePath();183 return iconCache.themePath(m_icon);
184}184}
185185
186QString AppMenuPlatformSystemTrayIcon::iconName() const186QString AppMenuPlatformSystemTrayIcon::iconName() const
187187
=== modified file 'src/iconcache.cpp'
--- src/iconcache.cpp 2014-12-13 15:38:51 +0000
+++ src/iconcache.cpp 2017-02-16 22:56:28 +0000
@@ -29,8 +29,7 @@
2929
30IconCache::IconCache(QObject *parent):30IconCache::IconCache(QObject *parent):
31 QObject(parent),31 QObject(parent),
32 m_temporaryDir(Q_NULLPTR),32 m_temporaryDir(Q_NULLPTR)
33 m_initialized(false)
34{33{
35}34}
3635
@@ -41,13 +40,48 @@
41 }40 }
42}41}
4342
44QString IconCache::themePath()43QString IconCache::themePath(const QIcon &icon)
45{44{
46 if (!m_initialized) {45 if (!m_temporaryDir) {
47 QString path = QDir::tempPath() + QStringLiteral("/iconcache-XXXXXX");46 QString dir;
47 QString runtimeDir = QString::fromUtf8(getenv("XDG_RUNTIME_DIR"));
48
49 if (!runtimeDir.isEmpty()) {
50 dir = runtimeDir;
51 QDir d(dir);
52 if (!d.exists()) {
53 d.mkpath(".");
54 }
55 } else if (!getenv("SNAP")) {
56 dir = QDir::tempPath();
57 } else {
58 // Try to get the .cache from $XDG_CACHE_HOME, if it's not set,
59 // it has to be in ~/.cache as per XDG standard
60 dir = QString::fromUtf8(getenv("XDG_CACHE_HOME"));
61 if (dir.isEmpty()) {
62 dir = QDir::cleanPath(QDir::homePath() + QStringLiteral("/.cache"));
63 }
64
65 QDir d(dir);
66 if (!d.exists()) {
67 d.mkpath(".");
68 }
69 }
70
71 QString path = dir + QStringLiteral("/qt-tray-iconcache-XXXXXX");
48 m_temporaryDir = new QTemporaryDir(path);72 m_temporaryDir = new QTemporaryDir(path);
49 m_initialized = true;73 }
50 }74
75 if (!icon.isNull() && !icon.name().isEmpty() && QIcon::hasThemeIcon(icon.name())) {
76 QString dataHome = QString::fromUtf8(getenv("XDG_DATA_HOME"));
77
78 if (dataHome.isEmpty()) {
79 dataHome = QDir::homePath() + "/.local/share";
80 }
81
82 return QDir::cleanPath(dataHome + "/icons");
83 }
84
51 return m_temporaryDir->path();85 return m_temporaryDir->path();
52}86}
5387
5488
=== modified file 'src/iconcache.h'
--- src/iconcache.h 2014-12-13 15:38:51 +0000
+++ src/iconcache.h 2017-02-16 22:56:28 +0000
@@ -39,13 +39,12 @@
3939
40 static const int MaxIconCount;40 static const int MaxIconCount;
4141
42 QString themePath();42 QString themePath(const QIcon &icon = QIcon());
43 QString nameForIcon(const QIcon &icon);43 QString nameForIcon(const QIcon &icon);
4444
45private:45private:
46 QTemporaryDir *m_temporaryDir;46 QTemporaryDir *m_temporaryDir;
47 mutable QList<qint64> m_cacheKeys;47 mutable QList<qint64> m_cacheKeys;
48 bool m_initialized;
4948
50 void cacheIcon(qint64 key, const QIcon &);49 void cacheIcon(qint64 key, const QIcon &);
51 void trimCache();50 void trimCache();

Subscribers

People subscribed via source and target branches