mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-05 12:58:18 +03:00
expose dock settings into tasks plasmoid
This commit is contained in:
parent
8e4b4f36bc
commit
4152535e51
@ -33,6 +33,7 @@
|
|||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
|
||||||
#include <Plasma/Containment>
|
#include <Plasma/Containment>
|
||||||
|
#include <Plasma/ContainmentActions>
|
||||||
#include <KActionCollection>
|
#include <KActionCollection>
|
||||||
#include <KLocalizedContext>
|
#include <KLocalizedContext>
|
||||||
|
|
||||||
@ -567,6 +568,41 @@ void DockView::restoreConfig()
|
|||||||
// setAlignment(static_cast<Dock::Alignment>(readEntry("alignment", Dock::Center).toInt()));
|
// setAlignment(static_cast<Dock::Alignment>(readEntry("alignment", Dock::Center).toInt()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariantList DockView::containmentActions()
|
||||||
|
{
|
||||||
|
QVariantList 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 = containment()->containmentActions().value(trigger);
|
||||||
|
|
||||||
|
if (!plugin) {
|
||||||
|
return actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin->containment() != containment()) {
|
||||||
|
plugin->setContainment(containment());
|
||||||
|
|
||||||
|
// now configure it
|
||||||
|
KConfigGroup cfg(containment()->corona()->config(), "ActionPlugins");
|
||||||
|
cfg = KConfigGroup(&cfg, QString::number(containment()->containmentType()));
|
||||||
|
KConfigGroup pluginConfig = KConfigGroup(&cfg, trigger);
|
||||||
|
plugin->restore(pluginConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (QAction *ac, plugin->contextualActions()) {
|
||||||
|
actions << QVariant::fromValue<QAction *>(ac);
|
||||||
|
}
|
||||||
|
|
||||||
|
return actions;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//!END SLOTS
|
//!END SLOTS
|
||||||
//!END namespace
|
//!END namespace
|
||||||
|
@ -103,6 +103,7 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
Q_INVOKABLE void addNewDock();
|
Q_INVOKABLE void addNewDock();
|
||||||
|
Q_INVOKABLE QVariantList containmentActions();
|
||||||
//used from the configuration window
|
//used from the configuration window
|
||||||
Q_INVOKABLE QList<int> freeEdges() const;
|
Q_INVOKABLE QList<int> freeEdges() const;
|
||||||
Q_INVOKABLE void initialize();
|
Q_INVOKABLE void initialize();
|
||||||
|
@ -732,6 +732,10 @@ DragDrop.DropArea {
|
|||||||
root.clearZoomSignal();
|
root.clearZoomSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function containmentActions(){
|
||||||
|
return dock.containmentActions();
|
||||||
|
}
|
||||||
|
|
||||||
function containsMouse(){
|
function containsMouse(){
|
||||||
var result = root.outsideContainsMouse();
|
var result = root.outsideContainsMouse();
|
||||||
|
|
||||||
|
@ -590,12 +590,10 @@ PlasmaComponents.ContextMenu {
|
|||||||
onClicked: tasksModel.requestRemoveLauncher(visualParent.m.LauncherUrlWithoutIcon);
|
onClicked: tasksModel.requestRemoveLauncher(visualParent.m.LauncherUrlWithoutIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PlasmaComponents.MenuItem {
|
PlasmaComponents.MenuItem {
|
||||||
property QtObject configureAction: null
|
property QtObject configureAction: null
|
||||||
|
|
||||||
|
visible: !nowDockPanel
|
||||||
enabled: configureAction && configureAction.enabled
|
enabled: configureAction && configureAction.enabled
|
||||||
|
|
||||||
text: configureAction ? configureAction.text : ""
|
text: configureAction ? configureAction.text : ""
|
||||||
@ -606,6 +604,37 @@ PlasmaComponents.ContextMenu {
|
|||||||
Component.onCompleted: configureAction = plasmoid.action("configure")
|
Component.onCompleted: configureAction = plasmoid.action("configure")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlasmaComponents.MenuItem {
|
||||||
|
id: containmentMenuItem
|
||||||
|
|
||||||
|
visible: nowDockPanel
|
||||||
|
enabled: visible
|
||||||
|
|
||||||
|
icon: "latte-dock"
|
||||||
|
text: "Latte"
|
||||||
|
|
||||||
|
PlasmaComponents.ContextMenu {
|
||||||
|
id: containmentSubMenu
|
||||||
|
|
||||||
|
visualParent: containmentMenuItem.action
|
||||||
|
|
||||||
|
function refresh() {
|
||||||
|
clearMenuItems();
|
||||||
|
|
||||||
|
var actionList = nowDockPanel.containmentActions();
|
||||||
|
|
||||||
|
for (var i=0; i<actionList.length; ++i){
|
||||||
|
var item = menu.newMenuItem(containmentSubMenu);
|
||||||
|
item.visible = false;
|
||||||
|
item.action = actionList[i];
|
||||||
|
containmentSubMenu.addMenuItem(item,containmentMenuItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PlasmaComponents.MenuItem {
|
PlasmaComponents.MenuItem {
|
||||||
separator: true
|
separator: true
|
||||||
}
|
}
|
||||||
@ -621,4 +650,5 @@ PlasmaComponents.ContextMenu {
|
|||||||
|
|
||||||
onClicked: tasksModel.requestClose(visualParent.modelIndex())
|
onClicked: tasksModel.requestClose(visualParent.modelIndex())
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user