diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 513eaeb..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -build -*.kdev4 diff --git a/AUTHORS b/AUTHORS index 06a7892..717d2f2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -3,8 +3,7 @@ Upstream Authors: Hong Jen Yee (PCMan) Copyright: - Copyright (c) 2013-2014 LXQt team + Copyright (c) 2013-2016 LXQt team License: LGPL-2.1+ The full text of the licenses can be found in the 'COPYING' file. -src/qiconloader_p.h is under LGPL-2.1 or 3 with Digia Qt LGPL Exception version 1.1 diff --git a/Digia-Qt-LGPL-Exception-version-1.1 b/Digia-Qt-LGPL-Exception-version-1.1 deleted file mode 100644 index 6e6fb3a..0000000 --- a/Digia-Qt-LGPL-Exception-version-1.1 +++ /dev/null @@ -1,25 +0,0 @@ -Digia Qt LGPL Exception version 1.1 -=================================== - -As an additional permission to the GNU Lesser General Public License version -2.1, the object code form of a "work that uses the Library" may incorporate -material from a header file that is part of the Library. You may distribute -such object code under terms of your choice, provided that: - - (i) the header files of the Library have not been modified; and - (ii) the incorporated material is limited to numerical parameters, data - structure layouts, accessors, macros, inline functions and - templates; and - (iii) you comply with the terms of Section 6 of the GNU Lesser General - Public License version 2.1. - -Moreover, you may apply this exception to a modified version of the Library, -provided that such modification does not involve copying material from the -Library into the modified Library's header files unless such material is -limited to (i) numerical parameters; (ii) data structure layouts; -(iii) accessors; and (iv) small macros, templates and inline functions of -five lines or less in length. - -Furthermore, you are not required to apply this additional permission to a -modified version of the Library. - diff --git a/debian/changelog b/debian/changelog index 006c28d..f225d09 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +lxqt-qtplugin (0.10.96~8-g411f696-1) UNRELEASED; urgency=medium + + * Cherry-picking upstream version 0.10.96~8-g411f696. + + -- Alf Gaida Tue, 19 Jul 2016 15:46:17 +0200 + lxqt-qtplugin (0.10.0-3) unstable; urgency=medium * Remove dbg package in favor of dbgsym. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7922b83..094f9d3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,6 +31,7 @@ target_link_libraries(qtlxqt Qt5::DBus dbusmenu-qt5 lxqt + Qt5XdgIconLoader ) # there is no standard way to get the plugin dir of Qt5 with cmake diff --git a/src/lxqtplatformtheme.cpp b/src/lxqtplatformtheme.cpp index 679ed2a..34d38cb 100644 --- a/src/lxqtplatformtheme.cpp +++ b/src/lxqtplatformtheme.cpp @@ -44,7 +44,7 @@ #include #include #include -#include "qiconloader_p.h" +#include LXQtPlatformTheme::LXQtPlatformTheme(): settingsWatcher_(NULL) @@ -162,7 +162,7 @@ void LXQtPlatformTheme::onSettingsChanged() { } if(iconTheme_ != oldIconTheme) { // the icon theme is changed - QIconLoader::instance()->updateSystemTheme(); // this is a private internal API of Qt5. + XdgIconLoader::instance()->updateSystemTheme(); // this is a private internal API of Qt5. } // if font is changed @@ -294,22 +294,40 @@ QVariant LXQtPlatformTheme::themeHint(ThemeHint hint) const { return QPlatformTheme::themeHint(hint); } +QIconEngine *LXQtPlatformTheme::createIconEngine(const QString &iconName) const +{ + return new XdgIconLoaderEngine(iconName); +} + // Helper to return the icon theme paths from XDG. QStringList LXQtPlatformTheme::xdgIconThemePaths() const { QStringList paths; + QStringList xdgDirs; + // Add home directory first in search path const QFileInfo homeIconDir(QDir::homePath() + QStringLiteral("/.icons")); if (homeIconDir.isDir()) paths.prepend(homeIconDir.absoluteFilePath()); - QString xdgDirString = QFile::decodeName(qgetenv("XDG_DATA_DIRS")); - if (xdgDirString.isEmpty()) - xdgDirString = QLatin1String("/usr/local/share/:/usr/share/"); - foreach (const QString &xdgDir, xdgDirString.split(QLatin1Char(':'))) { - const QFileInfo xdgIconsDir(xdgDir + QStringLiteral("/icons")); - if (xdgIconsDir.isDir()) - paths.append(xdgIconsDir.absoluteFilePath()); + QString xdgDataHome = QFile::decodeName(qgetenv("XDG_DATA_HOME")); + if (xdgDataHome.isEmpty()) + xdgDataHome = QDir::homePath() + QLatin1String("/.local/share"); + xdgDirs.append(xdgDataHome); + + QString xdgDataDirs = QFile::decodeName(qgetenv("XDG_DATA_DIRS")); + if (xdgDataDirs.isEmpty()) + xdgDataDirs = QLatin1String("/usr/local/share/:/usr/share/"); + xdgDirs.append(xdgDataDirs); + + foreach (const QString &s, xdgDirs) { + const QStringList r = s.split(QLatin1Char(':'), QString::SkipEmptyParts); + foreach (const QString &xdgDir, r) { + const QFileInfo xdgIconsDir(xdgDir + QStringLiteral("/icons")); + if (xdgIconsDir.isDir()) + paths.append(xdgIconsDir.absoluteFilePath()); + } } + paths.removeDuplicates(); return paths; } diff --git a/src/lxqtplatformtheme.h b/src/lxqtplatformtheme.h index 5ad6d34..956d11c 100644 --- a/src/lxqtplatformtheme.h +++ b/src/lxqtplatformtheme.h @@ -72,7 +72,7 @@ public: // virtual QPixmap fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size, // QPlatformTheme::IconOptions iconOptions = 0) const; - // virtual QIconEngine *createIconEngine(const QString &iconName) const; + virtual QIconEngine *createIconEngine(const QString &iconName) const; // virtual QList keyBindings(QKeySequence::StandardKey key) const; diff --git a/src/lxqtsystemtrayicon.cpp b/src/lxqtsystemtrayicon.cpp index 1df4dd0..fd9e5b5 100644 --- a/src/lxqtsystemtrayicon.cpp +++ b/src/lxqtsystemtrayicon.cpp @@ -286,7 +286,7 @@ void LXQtSystemTrayIcon::init() // default menu QPlatformMenu *menu = createMenu(); - menu->setParent(this); + menu->setParent(mSni); QPlatformMenuItem *menuItem = menu->createMenuItem(); menuItem->setParent(menu); menuItem->setText(tr("Quit")); diff --git a/src/qiconloader_p.h b/src/qiconloader_p.h deleted file mode 100644 index 419d93d..0000000 --- a/src/qiconloader_p.h +++ /dev/null @@ -1,194 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QICONLOADER_P_H -#define QICONLOADER_P_H - -#include - -#ifndef QT_NO_ICON -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QIconLoader; - -struct QIconDirInfo -{ - enum Type { Fixed, Scalable, Threshold }; - QIconDirInfo(const QString &_path = QString()) : - path(_path), - size(0), - maxSize(0), - minSize(0), - threshold(0), - type(Threshold) {} - QString path; - short size; - short maxSize; - short minSize; - short threshold; - Type type : 4; -}; - -class QIconLoaderEngineEntry - { -public: - virtual ~QIconLoaderEngineEntry() {} - virtual QPixmap pixmap(const QSize &size, - QIcon::Mode mode, - QIcon::State state) = 0; - QString filename; - QIconDirInfo dir; - static int count; -}; - -struct ScalableEntry : public QIconLoaderEngineEntry -{ - QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state); - QIcon svgIcon; -}; - -struct PixmapEntry : public QIconLoaderEngineEntry -{ - QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state); - QPixmap basePixmap; -}; - -typedef QList QThemeIconEntries; - -class QIconLoaderEngine : public QIconEngine -{ -public: - QIconLoaderEngine(const QString& iconName = QString()); - ~QIconLoaderEngine(); - - void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state); - QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state); - QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state); - QIconEngine *clone() const; - bool read(QDataStream &in); - bool write(QDataStream &out) const; - -private: - QString key() const; - bool hasIcon() const; - void ensureLoaded(); - void virtual_hook(int id, void *data); - QIconLoaderEngineEntry *entryForSize(const QSize &size); - QIconLoaderEngine(const QIconLoaderEngine &other); - QThemeIconEntries m_entries; - QString m_iconName; - uint m_key; - - friend class QIconLoader; -}; - -class QIconTheme -{ -public: - QIconTheme(const QString &name); - QIconTheme() : m_valid(false) {} - QStringList parents() { return m_parents; } - QList keyList() { return m_keyList; } - QString contentDir() { return m_contentDir; } - bool isValid() { return m_valid; } - -private: - QString m_contentDir; - QList m_keyList; - QStringList m_parents; - bool m_valid; -}; - -class Q_GUI_EXPORT QIconLoader : public QObject -{ -public: - QIconLoader(); - QThemeIconEntries loadIcon(const QString &iconName) const; - uint themeKey() const { return m_themeKey; } - - QString themeName() const { return m_userTheme.isEmpty() ? m_systemTheme : m_userTheme; } - void setThemeName(const QString &themeName); - QIconTheme theme() { return themeList.value(themeName()); } - void setThemeSearchPath(const QStringList &searchPaths); - QStringList themeSearchPaths() const; - QIconDirInfo dirInfo(int dirindex); - static QIconLoader *instance(); - void updateSystemTheme(); - void invalidateKey() { m_themeKey++; } - void ensureInitialized(); - -private: - QThemeIconEntries findIconHelper(const QString &themeName, - const QString &iconName, - QStringList &visited) const; - uint m_themeKey; - bool m_supportsSvg; - bool m_initialized; - - mutable QString m_userTheme; - mutable QString m_systemTheme; - mutable QStringList m_iconDirs; - mutable QHash themeList; -}; - -QT_END_NAMESPACE - -#endif // QT_NO_ICON - -#endif // QICONLOADER_P_H diff --git a/src/statusnotifieritem/statusnotifieritem.cpp b/src/statusnotifieritem/statusnotifieritem.cpp index 8d24f97..88b9d7f 100644 --- a/src/statusnotifieritem/statusnotifieritem.cpp +++ b/src/statusnotifieritem/statusnotifieritem.cpp @@ -42,7 +42,8 @@ StatusNotifierItem::StatusNotifierItem(QString id, QObject *parent) mId(id), mTitle("Test"), mStatus("Active"), - mMenu(nullptr) + mMenu(nullptr), + mMenuExporter(nullptr) { // register service QDBusConnection::sessionBus().registerService(mService); @@ -64,8 +65,6 @@ StatusNotifierItem::~StatusNotifierItem() QDBusConnection::sessionBus().unregisterObject("/StatusNotifierItem"); QDBusConnection::sessionBus().unregisterService(mService); QDBusConnection::sessionBus().disconnectFromBus(mService); - - delete mMenu; } void StatusNotifierItem::registerToHost() @@ -84,6 +83,12 @@ void StatusNotifierItem::onServiceOwnerChanged(const QString& service, const QSt registerToHost(); } +void StatusNotifierItem::onMenuDestroyed() +{ + mMenu = nullptr; + mMenuExporter = nullptr; //mMenu is a QObject parent of the mMenuExporter +} + void StatusNotifierItem::setTitle(const QString &title) { if (mTitle == title) @@ -210,12 +215,20 @@ void StatusNotifierItem::setContextMenu(QMenu* menu) if (mMenu == menu) return; - delete mMenu; + if (nullptr != mMenu) + { + disconnect(mMenu, &QObject::destroyed, this, &StatusNotifierItem::onMenuDestroyed); + } mMenu = menu; - mMenu->setParent(nullptr); setMenuPath("/MenuBar"); - new DBusMenuExporter(this->menu().path(), mMenu); + //Note: we need to destroy menu exporter before creating new one -> to free the DBus object path for new menu + delete mMenuExporter; + if (nullptr != mMenu) + { + connect(mMenu, &QObject::destroyed, this, &StatusNotifierItem::onMenuDestroyed); + mMenuExporter = new DBusMenuExporter{this->menu().path(), mMenu}; + } } void StatusNotifierItem::Activate(int x, int y) diff --git a/src/statusnotifieritem/statusnotifieritem.h b/src/statusnotifieritem/statusnotifieritem.h index e55eedd..8706c19 100644 --- a/src/statusnotifieritem/statusnotifieritem.h +++ b/src/statusnotifieritem/statusnotifieritem.h @@ -36,6 +36,7 @@ #include "dbustypes.h" class StatusNotifierItemAdaptor; +class DBusMenuExporter; class StatusNotifierItem : public QObject { @@ -126,6 +127,9 @@ public: return tt; } + /*! + * \Note: we don't take ownership for the \param menu + */ void setContextMenu(QMenu *menu); public slots: @@ -143,6 +147,7 @@ private: private slots: void onServiceOwnerChanged(const QString &service, const QString &oldOwner, const QString &newOwner); + void onMenuDestroyed(); signals: void activateRequested(const QPoint &pos); @@ -170,6 +175,7 @@ private: // menu QMenu *mMenu; QDBusObjectPath mMenuPath; + DBusMenuExporter *mMenuExporter; static int mServiceCounter; };