mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-09 00:58:15 +03:00
add quit application to contextmenu actions
--easier way for some to quit Latte by just right clicking on the docks/panels BUG:417486
This commit is contained in:
parent
e2596b905c
commit
57d1bf1f43
@ -3,6 +3,8 @@
|
||||
<interface name="org.kde.LatteDock">
|
||||
<method name="activateLauncherMenu">
|
||||
</method>
|
||||
<method name="quitApplication">
|
||||
</method>
|
||||
<method name="updateDockItemBadge">
|
||||
<arg name="identifier" type="s" direction="in"/>
|
||||
<arg name="value" type="s" direction="in"/>
|
||||
|
@ -820,7 +820,7 @@ int Corona::primaryScreenId() const
|
||||
return m_screenPool->id(qGuiApp->primaryScreen()->name());
|
||||
}
|
||||
|
||||
void Corona::closeApplication()
|
||||
void Corona::quitApplication()
|
||||
{
|
||||
//! this code must be called asynchronously because it is called
|
||||
//! also from qml (Settings window).
|
||||
|
@ -125,8 +125,6 @@ public:
|
||||
|
||||
int screenForContainment(const Plasma::Containment *containment) const override;
|
||||
|
||||
void closeApplication();
|
||||
|
||||
KActivities::Consumer *activityConsumer() const;
|
||||
KWayland::Client::PlasmaShell *waylandCoronaInterface() const;
|
||||
|
||||
@ -146,6 +144,7 @@ public:
|
||||
PanelShadows *dialogShadows() const;
|
||||
|
||||
//! these functions are used from context menu through containmentactions
|
||||
void quitApplication();
|
||||
void switchToLayout(QString layout);
|
||||
void showSettingsWindow(int page);
|
||||
void setContextMenuView(int id);
|
||||
|
@ -243,7 +243,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, Latte::Corona *corona)
|
||||
|
||||
connect(quitAction, &QAction::triggered, this, [&]() {
|
||||
close();
|
||||
m_corona->closeApplication();
|
||||
m_corona->quitApplication();
|
||||
});
|
||||
|
||||
connect(m_editLayoutAction, &QAction::triggered, this, [&]() {
|
||||
|
@ -57,6 +57,7 @@ Menu::~Menu()
|
||||
m_switchLayoutsMenu->deleteLater();
|
||||
m_layoutsAction->deleteLater();
|
||||
m_preferenceAction->deleteLater();
|
||||
m_quitApplication->deleteLater();
|
||||
}
|
||||
|
||||
void Menu::makeActions()
|
||||
@ -91,6 +92,9 @@ void Menu::makeActions()
|
||||
m_configureAction->setEnabled(true);
|
||||
});
|
||||
|
||||
m_quitApplication = new QAction(QIcon::fromTheme("application-exit"), i18nc("quit application", "Quit &Latte"));
|
||||
connect(m_quitApplication, &QAction::triggered, this, &Menu::quitApplication);
|
||||
|
||||
m_switchLayoutsMenu = new QMenu;
|
||||
m_layoutsAction = m_switchLayoutsMenu->menuAction();
|
||||
m_layoutsAction->setText(i18n("&Layouts"));
|
||||
@ -127,11 +131,12 @@ QList<QAction *> Menu::contextualActions()
|
||||
//actions << m_printAction;
|
||||
actions << m_layoutsAction;
|
||||
actions << m_preferenceAction;
|
||||
actions << m_quitApplication;
|
||||
|
||||
actions << m_separator2;
|
||||
actions << m_addWidgetsAction;
|
||||
actions << m_configureAction;
|
||||
|
||||
actions << m_configureAction;
|
||||
|
||||
m_data.clear();
|
||||
QDBusInterface iface("org.kde.lattedock", "/Latte", "", QDBusConnection::sessionBus());
|
||||
|
||||
@ -169,6 +174,8 @@ QAction *Menu::action(const QString &name)
|
||||
return m_configureAction;
|
||||
} else if (name == "layouts") {
|
||||
return m_layoutsAction;
|
||||
} else if (name == "quit application") {
|
||||
return m_quitApplication;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@ -244,6 +251,15 @@ void Menu::switchToLayout(QAction *action)
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::quitApplication()
|
||||
{
|
||||
QDBusInterface iface("org.kde.lattedock", "/Latte", "", QDBusConnection::sessionBus());
|
||||
|
||||
if (iface.isValid()) {
|
||||
iface.call("quitApplication");
|
||||
}
|
||||
}
|
||||
|
||||
K_EXPORT_PLASMA_CONTAINMENTACTIONS_WITH_JSON(lattecontextmenu, Menu, "plasma-containmentactions-lattecontextmenu.json")
|
||||
|
||||
#include "menu.moc"
|
||||
|
@ -44,6 +44,7 @@ private Q_SLOTS:
|
||||
void makeActions();
|
||||
void populateLayouts();
|
||||
void requestConfiguration();
|
||||
void quitApplication();
|
||||
void switchToLayout(QAction *action);
|
||||
|
||||
|
||||
@ -60,6 +61,7 @@ private:
|
||||
QAction *m_printAction{nullptr};
|
||||
QAction *m_layoutsAction{nullptr};
|
||||
QAction *m_preferenceAction{nullptr};
|
||||
QAction *m_quitApplication{nullptr};
|
||||
|
||||
QMenu *m_switchLayoutsMenu{nullptr};
|
||||
};
|
||||
|
@ -42,6 +42,8 @@ PlasmaComponents.ContextMenu {
|
||||
property var modelIndex
|
||||
readonly property var atm: TaskManager.AbstractTasksModel
|
||||
|
||||
readonly property var containmentActions: latteView ? latteView.containmentActions() : []
|
||||
|
||||
placement: {
|
||||
if (plasmoid.location === PlasmaCore.Types.LeftEdge) {
|
||||
return PlasmaCore.Types.RightPosedTopAlignedPopup;
|
||||
@ -930,7 +932,7 @@ PlasmaComponents.ContextMenu {
|
||||
PlasmaComponents.MenuItem {
|
||||
id: layoutsMenuItem
|
||||
|
||||
action: latteView ? latteView.containmentActions()[1] : plasmoid.action("configure")
|
||||
action: latteView ? containmentActions[1] : plasmoid.action("configure")
|
||||
enabled: visible
|
||||
visible: latteView && latteView.layoutsManager.menuLayouts.length>1
|
||||
}
|
||||
@ -938,10 +940,16 @@ PlasmaComponents.ContextMenu {
|
||||
PlasmaComponents.MenuItem {
|
||||
id: preferenceMenuItem
|
||||
|
||||
action: latteView ? latteView.containmentActions()[2] : plasmoid.action("configure")
|
||||
action: latteView ? containmentActions[2] : plasmoid.action("configure")
|
||||
visible: latteView
|
||||
}
|
||||
|
||||
PlasmaComponents.MenuItem {
|
||||
id: quitApplicationItem
|
||||
action: latteView ? containmentActions[3] : plasmoid.action("configure")
|
||||
visible: latteView
|
||||
}
|
||||
|
||||
PlasmaComponents.MenuItem {
|
||||
separator: true
|
||||
visible: preferenceMenuItem.visible
|
||||
@ -959,15 +967,14 @@ PlasmaComponents.ContextMenu {
|
||||
PlasmaComponents.MenuItem {
|
||||
id: addWidgets
|
||||
|
||||
action: latteView ? latteView.containmentActions()[4] : plasmoid.action("configure");
|
||||
action: latteView ? containmentActions[5] : plasmoid.action("configure");
|
||||
visible: latteView
|
||||
}
|
||||
|
||||
|
||||
PlasmaComponents.MenuItem {
|
||||
id: configureItem
|
||||
|
||||
action: latteView ? latteView.containmentActions()[5] : plasmoid.action("configure")
|
||||
action: latteView ? containmentActions[6] : plasmoid.action("configure")
|
||||
}
|
||||
|
||||
//! BEGIN: Plasmoid actions when it isnt inside a Latte dock
|
||||
|
Loading…
x
Reference in New Issue
Block a user