mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-15 15:24:24 +03:00
access internal plasma separator from contextmenu
--all the functionality concerning the internal separator is moved completely into the plasmoid. Now the add/remove of the internal separator can be found through the Tasks contextmenu as long as we are in editMode (that is showing the configuration window)
This commit is contained in:
parent
debea91ddc
commit
b79b375715
@ -282,87 +282,6 @@ void DockConfigView::addPanelSpacer()
|
||||
}
|
||||
}
|
||||
|
||||
void DockConfigView::addTasksSeparator()
|
||||
{
|
||||
const auto &applets = m_dockView->containment()->applets();
|
||||
|
||||
for (auto *applet : applets) {
|
||||
KPluginMetaData meta = applet->kPackage().metadata();
|
||||
|
||||
if (meta.pluginId() == "org.kde.latte.plasmoid") {
|
||||
|
||||
if (QQuickItem *appletInterface = applet->property("_plasma_graphicObject").value<QQuickItem *>()) {
|
||||
const auto &childItems = appletInterface->childItems();
|
||||
|
||||
if (childItems.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (QQuickItem *item : childItems) {
|
||||
if (auto *metaObject = item->metaObject()) {
|
||||
// not using QMetaObject::invokeMethod to avoid warnings when calling
|
||||
// this on applets that don't have it or other child items since this
|
||||
// is pretty much trial and error.
|
||||
// Also, "var" arguments are treated as QVariant in QMetaObject
|
||||
int methodIndex = metaObject->indexOfMethod("addSeparator(QVariant)");
|
||||
|
||||
if (methodIndex == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QMetaMethod method = metaObject->method(methodIndex);
|
||||
|
||||
if (method.invoke(item, Q_ARG(QVariant, QString(m_dockView->corona()->kPackage().filePath("separator0"))))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DockConfigView::removeTasksSeparator()
|
||||
{
|
||||
const auto &applets = m_dockView->containment()->applets();
|
||||
|
||||
for (auto *applet : applets) {
|
||||
KPluginMetaData meta = applet->kPackage().metadata();
|
||||
|
||||
if (meta.pluginId() == "org.kde.latte.plasmoid") {
|
||||
|
||||
if (QQuickItem *appletInterface = applet->property("_plasma_graphicObject").value<QQuickItem *>()) {
|
||||
const auto &childItems = appletInterface->childItems();
|
||||
|
||||
if (childItems.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (QQuickItem *item : childItems) {
|
||||
if (auto *metaObject = item->metaObject()) {
|
||||
// not using QMetaObject::invokeMethod to avoid warnings when calling
|
||||
// this on applets that don't have it or other child items since this
|
||||
// is pretty much trial and error.
|
||||
// Also, "var" arguments are treated as QVariant in QMetaObject
|
||||
int methodIndex = metaObject->indexOfMethod("removeSeparator(QVariant)");
|
||||
|
||||
if (methodIndex == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QMetaMethod method = metaObject->method(methodIndex);
|
||||
|
||||
if (method.invoke(item, Q_ARG(QVariant, QString(m_dockView->corona()->kPackage().filePath("separator0"))))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DockConfigView::hideConfigWindow()
|
||||
{
|
||||
hide();
|
||||
|
@ -53,8 +53,6 @@ public:
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE void addPanelSpacer();
|
||||
Q_INVOKABLE void addTasksSeparator();
|
||||
Q_INVOKABLE void removeTasksSeparator();
|
||||
Q_INVOKABLE void hideConfigWindow();
|
||||
Q_INVOKABLE void setSticker(bool blockFocusLost);
|
||||
Q_INVOKABLE void syncGeometry();
|
||||
|
@ -186,9 +186,6 @@
|
||||
<entry name="showOnlyCurrentActivity" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="hasInternalSeparator" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="indicateAudioStreams" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
|
@ -234,8 +234,6 @@ DragDrop.DropArea {
|
||||
property int latteAppletHoveredIndex: latteApplet ? latteApplet.hoveredIndex : -1
|
||||
property int tasksCount: latteApplet ? latteApplet.tasksCount : 0
|
||||
|
||||
property bool hasInternalSeparator: latteApplet ? latteApplet.hasInternalSeparator : false
|
||||
|
||||
property real durationTime: {
|
||||
if (plasmoid.configuration.durationTime === 0 || plasmoid.configuration.durationTime === 2 )
|
||||
return plasmoid.configuration.durationTime;
|
||||
@ -433,11 +431,6 @@ DragDrop.DropArea {
|
||||
// dndSpacer.parent = root;
|
||||
}
|
||||
|
||||
//! it is used in order to provide to config window the internalSeparator state
|
||||
onHasInternalSeparatorChanged: {
|
||||
plasmoid.configuration.hasInternalSeparator = root.hasInternalSeparator;
|
||||
}
|
||||
|
||||
onLatteAppletChanged: {
|
||||
if (latteApplet) {
|
||||
latteApplet.signalAnimationsNeedBothAxis.connect(slotAnimationsNeedBothAxis);
|
||||
|
@ -829,6 +829,27 @@ PlasmaComponents.ContextMenu {
|
||||
separator: true
|
||||
}
|
||||
|
||||
PlasmaComponents.MenuItem {
|
||||
id: internalSeparatorItem
|
||||
visible: root.editMode
|
||||
|
||||
icon: "view-split-left-right"
|
||||
text: i18n("Internal Separator")
|
||||
checkable: true
|
||||
|
||||
Component.onCompleted: {
|
||||
checked = root.hasInternalSeparator;
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
if (checked) {
|
||||
root.addSeparator();
|
||||
} else {
|
||||
root.removeSeparator();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaComponents.MenuItem {
|
||||
id: altSession
|
||||
visible: root.exposeAltSession
|
||||
|
@ -1279,12 +1279,12 @@ Item {
|
||||
|
||||
//! it is used to add the fake desktop file which represents
|
||||
//! the separator (fake launcher)
|
||||
function addSeparator(filepath){
|
||||
tasksModel.requestAddLauncher(filepath);
|
||||
function addSeparator(){
|
||||
tasksModel.requestAddLauncher("file:///latte-separator.desktop");
|
||||
}
|
||||
|
||||
function removeSeparator(filepath){
|
||||
tasksModel.requestRemoveLauncher(filepath);
|
||||
function removeSeparator(){
|
||||
tasksModel.requestRemoveLauncher("file:///latte-separator.desktop");
|
||||
}
|
||||
|
||||
function previewContainsMouse() {
|
||||
|
@ -303,29 +303,6 @@ PlasmaComponents.Page {
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaComponents.Button {
|
||||
iconSource: plasmoid.configuration.hasInternalSeparator ? "edit-delete" : "list-add"
|
||||
text: i18n("Tasks Separator")
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignLeft
|
||||
visible: dock.tasksPresent()
|
||||
// tooltip: i18n("Add a separator for tasks")
|
||||
|
||||
onClicked: {
|
||||
if (plasmoid.configuration.hasInternalSeparator)
|
||||
dockConfig.removeTasksSeparator();
|
||||
else
|
||||
dockConfig.addTasksSeparator();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: units.smallSpacing * 2
|
||||
Layout.rightMargin: units.smallSpacing * 2
|
||||
spacing: units.smallSpacing
|
||||
|
||||
PlasmaComponents.Button {
|
||||
iconSource: "edit-delete"
|
||||
text: i18n("Remove Tasks")
|
||||
|
Loading…
x
Reference in New Issue
Block a user