diff -ur kdelibs-4.13.3-orig/kdeui/actions/kaction.cpp kdelibs-4.13.3/kdeui/actions/kaction.cpp --- kdelibs-4.13.3-orig/kdeui/actions/kaction.cpp 2014-07-11 15:42:13.000000000 +0900 +++ kdelibs-4.13.3/kdeui/actions/kaction.cpp 2014-09-20 23:58:07.000000000 +0900 @@ -142,11 +142,52 @@ d->init(this); } +#ifdef Q_OS_MAC + +#include +#include + +static void setTextWithCorrectMenuRole( KAction *action, const QString &text ) +{ + // texts containing "config, options, setup, settings or preferences" will get PreferencesRole + // from Qt unless they have a role set. We prevent that, because KDE has its own way of + // defining a the application preferences menu ("Configure ") which should go under the OS X Preferences menu. + // But when a KAction is created with the standard preferences title ("Configure ..."), this action + // is set to PreferencesRole . + // The compare actions using QMenuBar::tr are copied from Qt's own qmenu_mac.mm : + action->setText(text); + const KAboutData *aboutData = KGlobal::mainComponent().aboutData(); + QString appName = i18n( "%1...", (aboutData) ? aboutData->programName() : qApp->applicationName() ); + if( text.startsWith(QMenuBar::tr("Config").toLower()) || text.startsWith( "&" % QMenuBar::tr("Config").toLower()) ){ + if( text.endsWith(appName) ){ + kDebug() << "### Setting QAction::PreferencesRole from" << action->menuRole() << "for menuAction with text" << text; + action->setMenuRole(QAction::PreferencesRole); + } + else{ + kDebug() << "### Setting QAction::NoRole from" << action->menuRole() << "for menuAction with text" << text; + action->setMenuRole(QAction::NoRole); + } + } + else if( text.contains(QMenuBar::tr("Options").toLower()) + || text.contains(QMenuBar::tr("Setup").toLower()) + || text.contains(QMenuBar::tr("Settings").toLower()) + || text.contains(QMenuBar::tr("Preferences").toLower()) + ){ + kDebug() << "### Setting QAction::NoRole from" << action->menuRole() << "for menuAction with text" << text; + action->setMenuRole(QAction::NoRole); + } +} +#endif //Q_OS_MAC + KAction::KAction(const QString &text, QObject *parent) : QWidgetAction(parent), d(new KActionPrivate) { d->init(this); +#ifdef Q_OS_MAC + setTextWithCorrectMenuRole(this, text); +#else setText(text); +#endif } KAction::KAction(const KIcon &icon, const QString &text, QObject *parent) @@ -154,7 +195,11 @@ { d->init(this); setIcon(icon); +#ifdef Q_OS_MAC + setTextWithCorrectMenuRole(this, text); +#else setText(text); +#endif } KAction::~KAction() diff -ur kdelibs-4.13.3-orig/kdeui/notifications/kstatusnotifieritem.cpp kdelibs-4.13.3/kdeui/notifications/kstatusnotifieritem.cpp --- kdelibs-4.13.3-orig/kdeui/notifications/kstatusnotifieritem.cpp 2014-07-11 15:42:13.000000000 +0900 +++ kdelibs-4.13.3/kdeui/notifications/kstatusnotifieritem.cpp 2014-09-20 23:58:14.000000000 +0900 @@ -683,6 +683,9 @@ return false; } +#else + Q_UNUSED(pos); + Q_UNUSED(perform); #endif return true; @@ -722,6 +725,10 @@ { } +#ifdef Q_OS_MAC +# include +#endif + void KStatusNotifierItemPrivate::init(const QString &extraId) { // Ensure that closing the last KMainWindow doesn't exit the application @@ -745,8 +752,20 @@ //create a default menu, just like in KSystemtrayIcon KMenu *m = new KMenu(associatedWidget); +#ifdef Q_OS_MAC + // emulate addTitle/setTitle by adding an inactive menu item. + titleAction = m->addAction( qApp->windowIcon(), KGlobal::mainComponent().aboutData()->programName() ); + titleAction->setEnabled(false); + titleAction->setIconVisibleInMenu(true); + m->addAction( titleAction ); + m->addSeparator(); + kDebug() << "### Added SystemTray titleAction=" << titleAction; + kDebug() << "### SystemTray for app" << qApp << "=" << KGlobal::mainComponent().aboutData()->programName() + << "/" << KGlobal::caption() << "with icon" << qApp->windowIcon().name(); +#else titleAction = m->addTitle(qApp->windowIcon(), KGlobal::caption()); m->setTitle(KGlobal::mainComponent().aboutData()->programName()); +#endif q->setContextMenu(m); KStandardAction::quit(q, SLOT(maybeQuit()), actionCollection);