fix #521,support syncing launchers for all docks

--this commit is the last for this to be supported.
It checks if the globalLauncherList is empty and in
such case when syncing is enabled the current dock
launchers are used
pull/1/head
Michail Vourlakos 8 years ago
parent 2ec210bf48
commit be83d54339

@ -367,5 +367,62 @@ void DockConfigView::hideConfigWindow()
hide();
}
void DockConfigView::setSyncLaunchers(bool sync)
{
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->globalSettings() && dockCorona->globalSettings()->globalLaunchers().count() == 0) {
//update the global launchers
//getLauncherList
Plasma::Containment *c = m_dockView->containment();
const auto &applets = c->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("getLauncherList()");
if (methodIndex == -1) {
continue;
}
QMetaMethod method = metaObject->method(methodIndex);
QVariant launchers;
if (method.invoke(item, Q_RETURN_ARG(QVariant, launchers))) {
dockCorona->globalSettings()->setGlobalLaunchers(launchers.toStringList());
}
}
}
}
}
}
}
dockCorona->globalSettings()->setSyncLaunchers(sync);
}
}
// kate: indent-mode cstyle; indent-width 4; replace-tabs on;

@ -61,6 +61,7 @@ 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();
signals:

@ -271,9 +271,9 @@ Item {
}
}
//is used to load correctly the launcherslist on startup
//is used to load correctly the global launcherslist on startup
onGlobalSettingsChanged: {
if (globalSettings === latteDock.globalSettings ) {
if (globalSettings && globalSettings === latteDock.globalSettings ) {
if (latteDock.globalSettings.syncLaunchers) {
tasksModel.launcherList = latteDock.globalSettings.globalLaunchers;
} else {
@ -1333,6 +1333,10 @@ Item {
}
}
function getLauncherList() {
return plasmoid.configuration.launchers59;
}
//! it is used to add the fake desktop file which represents
//! the separator (fake launcher)
function addSeparator(){

@ -511,7 +511,7 @@ MouseArea{
var badger = root.getBadger(launcherUrl);
if (badger && !isLauncher) {
badgeIndicator = badger.value;
badgeIndicator = parseInt(badger.value);
} else {
badgeIndicator = 0;
}

@ -136,7 +136,7 @@ PlasmaComponents.Page {
checked: globalSettings.syncLaunchers
onClicked: {
globalSettings.syncLaunchers = checked;
dockConfig.setSyncLaunchers(checked);
}
}

Loading…
Cancel
Save