mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-09 00:58:15 +03:00
update launchers based on group correctly
--this isnt the plasmoid part but the c++ and configuration window one
This commit is contained in:
parent
111d004e47
commit
d4b2f3d15b
@ -371,47 +371,57 @@ void DockConfigView::hideConfigWindow()
|
||||
}
|
||||
}
|
||||
|
||||
void DockConfigView::setSyncLaunchers(bool sync)
|
||||
void DockConfigView::updateLaunchersForGroup(int groupInt)
|
||||
{
|
||||
Dock::LaunchersGroup group = (Dock::LaunchersGroup)groupInt;
|
||||
|
||||
auto *dockCorona = qobject_cast<DockCorona *>(m_dockView->corona());
|
||||
|
||||
//when the global launchers list is empty then the current dock launchers are used
|
||||
if (sync && dockCorona && dockCorona->layoutManager() && dockCorona->layoutManager()->currentLayout()) {
|
||||
//update the global launchers
|
||||
Plasma::Containment *c = m_dockView->containment();
|
||||
//! when the layout/global launchers list is empty then the current dock launchers are used for them
|
||||
//! as a start point
|
||||
if (dockCorona && dockCorona->layoutManager() && dockCorona->layoutManager()->currentLayout()) {
|
||||
if ((group == Dock::LayoutLaunchers && dockCorona->layoutManager()->currentLayout()->launchers().isEmpty())
|
||||
|| group == Dock::GlobalLaunchers && dockCorona->universalSettings()->launchers().isEmpty()) {
|
||||
|
||||
const auto &applets = c->applets();
|
||||
Plasma::Containment *c = m_dockView->containment();
|
||||
|
||||
for (auto *applet : applets) {
|
||||
KPluginMetaData meta = applet->kPackage().metadata();
|
||||
const auto &applets = c->applets();
|
||||
|
||||
if (meta.pluginId() == "org.kde.latte.plasmoid") {
|
||||
if (QQuickItem *appletInterface = applet->property("_plasma_graphicObject").value<QQuickItem *>()) {
|
||||
const auto &childItems = appletInterface->childItems();
|
||||
for (auto *applet : applets) {
|
||||
KPluginMetaData meta = applet->kPackage().metadata();
|
||||
|
||||
if (childItems.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if (meta.pluginId() == "org.kde.latte.plasmoid") {
|
||||
if (QQuickItem *appletInterface = applet->property("_plasma_graphicObject").value<QQuickItem *>()) {
|
||||
const auto &childItems = appletInterface->childItems();
|
||||
|
||||
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
|
||||
if (childItems.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int methodIndex = metaObject->indexOfMethod("getLauncherList()");
|
||||
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
|
||||
|
||||
if (methodIndex == -1) {
|
||||
continue;
|
||||
}
|
||||
int methodIndex = metaObject->indexOfMethod("getLauncherList()");
|
||||
|
||||
QMetaMethod method = metaObject->method(methodIndex);
|
||||
if (methodIndex == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QVariant launchers;
|
||||
QMetaMethod method = metaObject->method(methodIndex);
|
||||
|
||||
if (method.invoke(item, Q_RETURN_ARG(QVariant, launchers))) {
|
||||
dockCorona->layoutManager()->currentLayout()->setLaunchers(launchers.toStringList());
|
||||
QVariant launchers;
|
||||
|
||||
if (method.invoke(item, Q_RETURN_ARG(QVariant, launchers))) {
|
||||
if (group == Dock::LayoutLaunchers) {
|
||||
dockCorona->layoutManager()->currentLayout()->setLaunchers(launchers.toStringList());
|
||||
} else if (group == Dock::GlobalLaunchers) {
|
||||
dockCorona->universalSettings()->setLaunchers(launchers.toStringList());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,8 +61,8 @@ public slots:
|
||||
Q_INVOKABLE void addPanelSpacer();
|
||||
Q_INVOKABLE void hideConfigWindow();
|
||||
Q_INVOKABLE void setSticker(bool blockFocusLost);
|
||||
Q_INVOKABLE void setSyncLaunchers(bool sync);
|
||||
Q_INVOKABLE void syncGeometry();
|
||||
Q_INVOKABLE void updateLaunchersForGroup(int groupInt);
|
||||
|
||||
signals:
|
||||
void raiseDocksTemporaryChanged();
|
||||
|
@ -204,6 +204,8 @@ void LayoutSettings::saveConfig()
|
||||
m_layoutGroup.writeEntry("color", m_color);
|
||||
m_layoutGroup.writeEntry("launchers", m_launchers);
|
||||
m_layoutGroup.writeEntry("activities", m_activities);
|
||||
|
||||
m_layoutGroup.sync();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -179,6 +179,14 @@
|
||||
</choices>
|
||||
<default>2</default>
|
||||
</entry>
|
||||
<entry name="launchersGroup" type="Enum">
|
||||
<choices>
|
||||
<choice name="Unique"/>
|
||||
<choice name="Layout"/>
|
||||
<choice name="Global"/>
|
||||
</choices>
|
||||
<default>0</default>
|
||||
</entry>
|
||||
<entry name="smartLaunchersEnabled" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
|
@ -129,7 +129,7 @@ PlasmaComponents.Page {
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaComponents.CheckBox {
|
||||
/*PlasmaComponents.CheckBox {
|
||||
id: syncLaunchersChk
|
||||
Layout.leftMargin: units.smallSpacing * 2
|
||||
text: i18n("Sync launchers between all docks")
|
||||
@ -139,7 +139,7 @@ PlasmaComponents.Page {
|
||||
onClicked: {
|
||||
dockConfig.setSyncLaunchers(checked);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
PlasmaComponents.CheckBox {
|
||||
id: smartLaunchersChk
|
||||
@ -255,6 +255,67 @@ PlasmaComponents.Page {
|
||||
}
|
||||
//! END: Tasks Interaction
|
||||
|
||||
//! BEGIN: Launchers Group
|
||||
ColumnLayout {
|
||||
spacing: units.smallSpacing
|
||||
Layout.rightMargin: units.smallSpacing * 2
|
||||
visible: plasmoid.configuration.advanced
|
||||
|
||||
Header {
|
||||
text: i18n("Launchers")
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: units.smallSpacing * 2
|
||||
Layout.rightMargin: units.smallSpacing * 2
|
||||
spacing: 2
|
||||
|
||||
property int group: plasmoid.configuration.launchersGroup
|
||||
|
||||
ExclusiveGroup {
|
||||
id: launchersGroup
|
||||
onCurrentChanged: {
|
||||
if (current.checked) {
|
||||
dockConfig.updateLaunchersForGroup(current.group);
|
||||
plasmoid.configuration.launchersGroup = current.group;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaComponents.Button {
|
||||
Layout.fillWidth: true
|
||||
text: i18nc("unique launchers","Unique")
|
||||
checked: parent.group === group
|
||||
checkable: true
|
||||
exclusiveGroup: launchersGroup
|
||||
|
||||
readonly property int group: 0
|
||||
}
|
||||
|
||||
PlasmaComponents.Button {
|
||||
Layout.fillWidth: true
|
||||
text: i18nc("layout launchers","Layout")
|
||||
checked: parent.group === group
|
||||
checkable: true
|
||||
exclusiveGroup: launchersGroup
|
||||
|
||||
readonly property int group: 1
|
||||
}
|
||||
|
||||
PlasmaComponents.Button {
|
||||
Layout.fillWidth: true
|
||||
text: i18nc("global launchers","Global")
|
||||
checked: parent.group === group
|
||||
checkable: true
|
||||
exclusiveGroup: launchersGroup
|
||||
|
||||
readonly property int group: 2
|
||||
}
|
||||
}
|
||||
}
|
||||
//! END: Launchers Group
|
||||
|
||||
//! BEGIN: Tasks Filters
|
||||
ColumnLayout {
|
||||
spacing: units.smallSpacing
|
||||
|
Loading…
x
Reference in New Issue
Block a user