Commit 6b687516 authored by Marco Martin's avatar Marco Martin

export org.kde.appmenuview

Summary:
drop the global settings and export the service wich will activate
the appmenu kded

Test Plan:
adding the menu button makes new apps export it,
removing it makes new apps using the interlal one again

Reviewers: #kwin, #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: ngraham, davidedmundson, broulik, plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9216
parent 7ac8a30c
......@@ -25,11 +25,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <appmenu_interface.h>
#include <QDBusObjectPath>
#include <QDBusServiceWatcher>
using namespace KWin;
KWIN_SINGLETON_FACTORY(ApplicationMenu)
static const QString s_viewService(QStringLiteral("org.kde.kappmenuview"));
ApplicationMenu::ApplicationMenu(QObject *parent)
: QObject(parent)
, m_appmenuInterface(new OrgKdeKappmenuInterface(QStringLiteral("org.kde.kappmenu"), QStringLiteral("/KAppMenu"), QDBusConnection::sessionBus(), this))
......@@ -37,9 +40,22 @@ ApplicationMenu::ApplicationMenu(QObject *parent)
connect(m_appmenuInterface, &OrgKdeKappmenuInterface::showRequest, this, &ApplicationMenu::slotShowRequest);
connect(m_appmenuInterface, &OrgKdeKappmenuInterface::menuShown, this, &ApplicationMenu::slotMenuShown);
connect(m_appmenuInterface, &OrgKdeKappmenuInterface::menuHidden, this, &ApplicationMenu::slotMenuHidden);
connect(m_appmenuInterface, &OrgKdeKappmenuInterface::reconfigured, this, &ApplicationMenu::slotReconfigured);
updateApplicationMenuEnabled();
m_kappMenuWatcher = new QDBusServiceWatcher(QStringLiteral("org.kde.kappmenu"), QDBusConnection::sessionBus(),
QDBusServiceWatcher::WatchForRegistration|QDBusServiceWatcher::WatchForUnregistration, this);
connect(m_kappMenuWatcher, &QDBusServiceWatcher::serviceRegistered,
this, [this] () {
m_applicationMenuEnabled = true;
emit applicationMenuEnabledChanged(true);
});
connect(m_kappMenuWatcher, &QDBusServiceWatcher::serviceUnregistered,
this, [this] () {
m_applicationMenuEnabled = false;
emit applicationMenuEnabledChanged(false);
});
m_applicationMenuEnabled = QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("org.kde.kappmenu"));
}
ApplicationMenu::~ApplicationMenu()
......@@ -47,28 +63,19 @@ ApplicationMenu::~ApplicationMenu()
s_self = nullptr;
}
void ApplicationMenu::slotReconfigured()
{
updateApplicationMenuEnabled();
}
bool ApplicationMenu::applicationMenuEnabled() const
{
return m_applicationMenuEnabled;
}
void ApplicationMenu::updateApplicationMenuEnabled()
void ApplicationMenu::setViewEnabled(bool enabled)
{
const bool old_enabled = m_applicationMenuEnabled;
KConfigGroup config(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), QStringLiteral("Appmenu Style"));
const QString &menuStyle = config.readEntry(QStringLiteral("Style"));
const bool enabled = (menuStyle == QLatin1String("Decoration"));
if (old_enabled != enabled) {
m_applicationMenuEnabled = enabled;
emit applicationMenuEnabledChanged(enabled);
if (enabled) {
QDBusConnection::sessionBus().interface()->registerService(s_viewService,
QDBusConnectionInterface::QueueService,
QDBusConnectionInterface::DontAllowReplacement);
} else {
QDBusConnection::sessionBus().interface()->unregisterService(s_viewService);
}
}
......
......@@ -31,6 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
class QPoint;
class OrgKdeKappmenuInterface;
class QDBusObjectPath;
class QDBusServiceWatcher;
namespace KWin
{
......@@ -48,19 +49,19 @@ public:
bool applicationMenuEnabled() const;
void setViewEnabled(bool enabled);
signals:
void applicationMenuEnabledChanged(bool enabled);
private Q_SLOTS:
void slotReconfigured();
void slotShowRequest(const QString &serviceName, const QDBusObjectPath &menuObjectPath, int actionId);
void slotMenuShown(const QString &serviceName, const QDBusObjectPath &menuObjectPath);
void slotMenuHidden(const QString &serviceName, const QDBusObjectPath &menuObjectPath);
private:
void updateApplicationMenuEnabled();
OrgKdeKappmenuInterface *m_appmenuInterface;
QDBusServiceWatcher *m_kappMenuWatcher;
AbstractClient *findAbstractClientWithApplicationMenu(const QString &serviceName, const QDBusObjectPath &menuObjectPath);
......
......@@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "composite.h"
#include "virtualdesktops.h"
#include "workspace.h"
#include "appmenu.h"
#include <config-kwin.h>
......@@ -155,7 +156,6 @@ void SettingsImpl::readSettings()
KConfigGroup config = kwinApp()->config()->group(QStringLiteral("org.kde.kdecoration2"));
const auto &left = readDecorationButtons(config, "ButtonsOnLeft", QVector<KDecoration2::DecorationButtonType >({
KDecoration2::DecorationButtonType::Menu,
KDecoration2::DecorationButtonType::ApplicationMenu,
KDecoration2::DecorationButtonType::OnAllDesktops
}));
if (left != m_leftButtons) {
......@@ -172,6 +172,7 @@ void SettingsImpl::readSettings()
m_rightButtons = right;
emit decorationSettings()->decorationButtonsRightChanged(m_rightButtons);
}
ApplicationMenu::self()->setViewEnabled(left.contains(KDecoration2::DecorationButtonType::ApplicationMenu) || right.contains(KDecoration2::DecorationButtonType::ApplicationMenu));
const bool close = config.readEntry("CloseOnDoubleClickOnMenu", false);
if (close != m_closeDoubleClickMenu) {
m_closeDoubleClickMenu = close;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment