mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-09 00:58:15 +03:00
add myView.action() to reach view actions
-this way things are more clear how the actions are applied and reordered
This commit is contained in:
parent
a44c5fa821
commit
87ae24dae1
@ -465,7 +465,7 @@ void View::removeView()
|
||||
if (m_layout) {
|
||||
m_inDelete = true;
|
||||
|
||||
QAction *removeAct = this->containment()->actions()->action(QStringLiteral("remove"));
|
||||
QAction *removeAct = action("remove");
|
||||
|
||||
if (removeAct) {
|
||||
removeAct->trigger();
|
||||
@ -1497,6 +1497,15 @@ void View::releaseGrab()
|
||||
QCoreApplication::instance()->sendEvent(this, &e);
|
||||
}
|
||||
|
||||
QAction *View::action(const QString &name)
|
||||
{
|
||||
if (!containment()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return this->containment()->actions()->action(name);
|
||||
}
|
||||
|
||||
QVariantList View::containmentActions() const
|
||||
{
|
||||
QVariantList actions;
|
||||
@ -1505,11 +1514,6 @@ QVariantList View::containmentActions() const
|
||||
return actions;
|
||||
}
|
||||
|
||||
/*if (containment()->corona()->immutability() != Plasma::Types::Mutable) {
|
||||
return actions;
|
||||
}*/
|
||||
//FIXME: the trigger string it should be better to be supported this way
|
||||
//const QString trigger = Plasma::ContainmentActions::eventToString(event);
|
||||
const QString trigger = "RightButton;NoModifier";
|
||||
Plasma::ContainmentActions *plugin = this->containment()->containmentActions().value(trigger);
|
||||
|
||||
|
@ -279,6 +279,7 @@ public slots:
|
||||
void updateAbsoluteGeometry(bool bypassChecks = false);
|
||||
|
||||
Q_INVOKABLE bool isHighestPriorityView();
|
||||
Q_INVOKABLE QAction *action(const QString &name);
|
||||
|
||||
protected slots:
|
||||
void showConfigurationInterface(Plasma::Applet *applet) override;
|
||||
|
@ -37,6 +37,12 @@
|
||||
#include <Plasma/ServiceJob>
|
||||
|
||||
const int LAYOUTSPOS = 3;
|
||||
const char LAYOUTSNAME[] = "layouts";
|
||||
const char PREFERENCESNAME[] = "preferences";
|
||||
const char QUITLATTENAME[] = "quit latte";
|
||||
const char ADDWIDGETSNAME[] = "add latte widgets";
|
||||
const char EDITVIEWNAME[] = "edit view";
|
||||
const char REMOVEVIEWNAME[] = "remove view";
|
||||
|
||||
enum ViewType
|
||||
{
|
||||
@ -93,6 +99,8 @@ void Menu::makeActions()
|
||||
m_addWidgetsAction = new QAction(QIcon::fromTheme("list-add"), i18n("&Add Widgets..."), this);
|
||||
m_addWidgetsAction->setStatusTip(i18n("Show Widget Explorer"));
|
||||
connect(m_addWidgetsAction, &QAction::triggered, this, &Menu::requestWidgetExplorer);
|
||||
this->containment()->actions()->addAction(ADDWIDGETSNAME, m_addWidgetsAction);
|
||||
|
||||
/*connect(m_addWidgetsAction, &QAction::triggered, [ = ]() {
|
||||
QDBusInterface iface("org.kde.plasmashell", "/PlasmaShell", "", QDBusConnection::sessionBus());
|
||||
|
||||
@ -104,11 +112,13 @@ void Menu::makeActions()
|
||||
//! Edit Dock/Panel...
|
||||
m_configureAction = new QAction(QIcon::fromTheme("document-edit"), "Edit Dock...", this);
|
||||
connect(m_configureAction, &QAction::triggered, this, &Menu::requestConfiguration);
|
||||
this->containment()->actions()->addAction(EDITVIEWNAME, m_configureAction);
|
||||
|
||||
|
||||
//! Quit Application
|
||||
m_quitApplication = new QAction(QIcon::fromTheme("application-exit"), i18nc("quit application", "Quit &Latte"));
|
||||
connect(m_quitApplication, &QAction::triggered, this, &Menu::quitApplication);
|
||||
this->containment()->actions()->addAction(QUITLATTENAME, m_quitApplication);
|
||||
|
||||
//! Layouts submenu
|
||||
m_switchLayoutsMenu = new QMenu;
|
||||
@ -116,12 +126,14 @@ void Menu::makeActions()
|
||||
m_layoutsAction->setText(i18n("&Layouts"));
|
||||
m_layoutsAction->setIcon(QIcon::fromTheme("user-identity"));
|
||||
m_layoutsAction->setStatusTip(i18n("Switch to another layout"));
|
||||
this->containment()->actions()->addAction(LAYOUTSNAME, m_layoutsAction);
|
||||
|
||||
connect(m_switchLayoutsMenu, &QMenu::aboutToShow, this, &Menu::populateLayouts);
|
||||
connect(m_switchLayoutsMenu, &QMenu::triggered, this, &Menu::switchToLayout);
|
||||
|
||||
//! Configure Latte
|
||||
m_preferenceAction = new QAction(QIcon::fromTheme("configure"), i18nc("global settings window", "&Configure Latte..."), this);
|
||||
this->containment()->actions()->addAction(PREFERENCESNAME, m_preferenceAction);
|
||||
connect(m_preferenceAction, &QAction::triggered, [=](){
|
||||
QDBusInterface iface("org.kde.lattedock", "/Latte", "", QDBusConnection::sessionBus());
|
||||
|
||||
@ -140,12 +152,12 @@ void Menu::makeActions()
|
||||
iface.call("removeView", containment()->id());
|
||||
}
|
||||
});
|
||||
this->containment()->actions()->addAction(REMOVEVIEWNAME, m_removeAction);
|
||||
|
||||
//! Signals
|
||||
connect(this->containment(), &Plasma::Containment::userConfiguringChanged, this, &Menu::onUserConfiguringChanged);
|
||||
}
|
||||
|
||||
|
||||
void Menu::requestConfiguration()
|
||||
{
|
||||
if (this->containment()) {
|
||||
@ -209,15 +221,17 @@ QList<QAction *> Menu::contextualActions()
|
||||
|
||||
QAction *Menu::action(const QString &name)
|
||||
{
|
||||
if (name == "add widgets") {
|
||||
if (name == ADDWIDGETSNAME) {
|
||||
return m_addWidgetsAction;
|
||||
} else if (name == "configure") {
|
||||
} else if (name == EDITVIEWNAME) {
|
||||
return m_configureAction;
|
||||
} else if (name == "layouts") {
|
||||
} else if (name == LAYOUTSNAME) {
|
||||
return m_layoutsAction;
|
||||
} else if (name == "quit application") {
|
||||
} else if (name == PREFERENCESNAME) {
|
||||
return m_preferenceAction;
|
||||
} else if (name == QUITLATTENAME) {
|
||||
return m_quitApplication;
|
||||
} else if (name == "remove") {
|
||||
} else if (name == REMOVEVIEWNAME) {
|
||||
return m_removeAction;
|
||||
}
|
||||
|
||||
|
@ -87,10 +87,10 @@ AbilityDefinition.MyView {
|
||||
}
|
||||
|
||||
function inCurrentLayout() {
|
||||
if (bridge && bridge.myView.isReady) {
|
||||
return bridge.myView.inCurrentLayout();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return bridge && ref.myView.isReady ? ref.myView.inCurrentLayout() : true;
|
||||
}
|
||||
|
||||
function action(name) {
|
||||
return bridge && ref.myView.isReady ? ref.myView.action(name) : null;
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,10 @@ AbilityDefinition.MyView {
|
||||
return view && view.layout && view.layout.isCurrent();
|
||||
}
|
||||
|
||||
function action(name) {
|
||||
return view ? view.action(name) : null;
|
||||
}
|
||||
|
||||
readonly property Item publicApi: Item {
|
||||
readonly property alias isReady: apis.isReady
|
||||
|
||||
@ -62,6 +66,10 @@ AbilityDefinition.MyView {
|
||||
|
||||
readonly property alias palette: apis.palette
|
||||
|
||||
function action(name) {
|
||||
return apis.action(name);
|
||||
}
|
||||
|
||||
function inCurrentLayout() {
|
||||
return apis.inCurrentLayout();
|
||||
}
|
||||
|
@ -43,8 +43,6 @@ PlasmaComponents.ContextMenu {
|
||||
property var modelIndex
|
||||
readonly property var atm: TaskManager.AbstractTasksModel
|
||||
|
||||
readonly property var containmentActions: appletAbilities.myView.isReady ? appletAbilities.myView.containmentActions : []
|
||||
|
||||
placement: {
|
||||
if (root.location === PlasmaCore.Types.LeftEdge) {
|
||||
return PlasmaCore.Types.RightPosedTopAlignedPopup;
|
||||
@ -884,22 +882,19 @@ PlasmaComponents.ContextMenu {
|
||||
|
||||
PlasmaComponents.MenuItem {
|
||||
id: layoutsMenuItem
|
||||
|
||||
action: appletAbilities.myView.isReady ? containmentActions[1] : plasmoid.action("configure")
|
||||
action: appletAbilities.myView.isReady ? appletAbilities.myView.action("layouts") : plasmoid.action("configure")
|
||||
enabled: visible
|
||||
visible: appletAbilities.myView.isReady && containmentActions[1].visible
|
||||
}
|
||||
|
||||
PlasmaComponents.MenuItem {
|
||||
id: preferenceMenuItem
|
||||
|
||||
action: appletAbilities.myView.isReady ? containmentActions[2] : plasmoid.action("configure")
|
||||
action: appletAbilities.myView.isReady ? appletAbilities.myView.action("preferences") : plasmoid.action("configure")
|
||||
visible: appletAbilities.myView.isReady
|
||||
}
|
||||
|
||||
PlasmaComponents.MenuItem {
|
||||
id: quitApplicationItem
|
||||
action: appletAbilities.myView.isReady ? containmentActions[3] : plasmoid.action("configure")
|
||||
action: appletAbilities.myView.isReady ? appletAbilities.myView.action("quit latte") : plasmoid.action("configure")
|
||||
visible: appletAbilities.myView.isReady
|
||||
}
|
||||
|
||||
@ -919,18 +914,18 @@ PlasmaComponents.ContextMenu {
|
||||
|
||||
PlasmaComponents.MenuItem {
|
||||
id: addWidgets
|
||||
action: appletAbilities.myView.isReady ? containmentActions[5] : plasmoid.action("configure");
|
||||
action: appletAbilities.myView.isReady ? appletAbilities.myView.action("add latte widgets") : plasmoid.action("configure");
|
||||
visible: appletAbilities.myView.isReady
|
||||
}
|
||||
|
||||
PlasmaComponents.MenuItem {
|
||||
id: configureItem
|
||||
action: appletAbilities.myView.isReady ? containmentActions[6] : plasmoid.action("configure")
|
||||
action: appletAbilities.myView.isReady ? appletAbilities.myView.action("edit view") : plasmoid.action("configure")
|
||||
}
|
||||
|
||||
PlasmaComponents.MenuItem {
|
||||
id: removeItem
|
||||
action: appletAbilities.myView.isReady ? containmentActions[7] : plasmoid.action("remove")
|
||||
action: appletAbilities.myView.isReady ? appletAbilities.myView.action("remove view") : plasmoid.action("remove")
|
||||
}
|
||||
|
||||
//! BEGIN: Plasmoid actions when it isnt inside a Latte dock
|
||||
|
Loading…
x
Reference in New Issue
Block a user