Ticket #44944: streamline-systray-menu.patch

File streamline-systray-menu.patch, 3.5 KB (added by RJVB (René Bertin), 10 years ago)
  • kdelibs-4.12.5/kdeui/notifications/kstatusnotifieritem.cpp

    diff --git kdeui/notifications/kstatusnotifieritem.cpp kdeui/notifications/kstatusnotifieritem.cpp
    index 1b15d40..9cb8405 100644
    KStatusNotifierItemPrivate::KStatusNotifierItemPrivate(KStatusNotifierItem *item 
    722722{
    723723}
    724724
     725#ifdef Q_OS_MAC
     726#   include <kconfiggroup.h>
     727#endif
     728
    725729void KStatusNotifierItemPrivate::init(const QString &extraId)
    726730{
    727731    // Ensure that closing the last KMainWindow doesn't exit the application
    void KStatusNotifierItemPrivate::init(const QString &extraId) 
    745749
    746750    //create a default menu, just like in KSystemtrayIcon
    747751    KMenu *m = new KMenu(associatedWidget);
     752#ifdef Q_OS_MAC
     753    // emulate addTitle/setTitle by adding an inactive menu item.
     754    titleAction = new QAction( KGlobal::mainComponent().aboutData()->programName(), NULL );
     755    titleAction->setEnabled(false);
     756    m->addAction( titleAction );
     757    m->addSeparator();
     758#else
    748759    titleAction = m->addTitle(qApp->windowIcon(), KGlobal::caption());
    749760    m->setTitle(KGlobal::mainComponent().aboutData()->programName());
     761#endif
    750762    q->setContextMenu(m);
    751763
    752764    KStandardAction::quit(q, SLOT(maybeQuit()), actionCollection);
  • kdelibs-4.12.5/kdeui/widgets/kmenu.cpp

    diff --git kdeui/widgets/kmenu.cpp kdeui/widgets/kmenu.cpp
    index 7dab149..94a7751 100644
    KMenu::~KMenu() 
    167167    delete d;
    168168}
    169169
     170#ifdef Q_OS_MAC
     171void KMenu::addAction(QAction *action)
     172{
     173    if( action ){
     174        if( !action->isIconVisibleInMenu() ){
     175            action->setIcon(QIcon());
     176        }
     177        QMenu::addAction(action);
     178    }
     179}
     180
     181#   ifdef Q_NO_USING_KEYWORD
     182QAction *KMenu::addAction(const QString &text)
     183{
     184    return QMenu::addAction(text);
     185}
     186
     187QAction *KMenu::addAction(const QIcon &icon, const QString &text)
     188{
     189    return QMenu::addAction(icon,text);
     190}
     191
     192QAction *KMenu::addAction(const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut)
     193{
     194    return QMenu::addAction(text, receiver, member, shortcut);
     195}
     196
     197QAction *KMenu::addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut)
     198{
     199    return QMenu::addAction(icon, text, receiver, member, shortcut);
     200}
     201#   endif // Q_NO_USING_KEYWORD
     202#endif // Q_OS_MAC
     203
    170204QAction* KMenu::addTitle(const QString &text, QAction* before)
    171205{
    172206    return addTitle(QIcon(), text, before);
  • kdelibs-4.12.5/kdeui/widgets/kmenu.h

    diff --git kdeui/widgets/kmenu.h kdeui/widgets/kmenu.h
    index f96e263..79be594 100644
    public: 
    6060     */
    6161    ~KMenu();
    6262
     63#ifdef Q_OS_MAC
     64#   ifndef Q_NO_USING_KEYWORD
     65    using QMenu::addAction;
     66#   endif
     67    /**
     68     * Appends the action action to the menu's list of actions.
     69     * Overloaded from QMenu to force Qt to honour action->isIconVisibleInMenu().
     70     */
     71    void addAction(QAction *action);
     72#   ifdef Q_NO_USING_KEYWORD
     73    QAction *addAction(const QString &text);
     74    QAction *addAction(const QIcon &icon, const QString &text);
     75    QAction *addAction(const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut = 0);
     76    QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut = 0);
     77#   endif //Q_NO_USING_KEYWORD
     78#endif //Q_OS_MAC
    6379    /**
    6480     * Inserts a title item with no icon.
    6581     */