mirror of
https://github.com/KDE/latte-dock.git
synced 2025-02-04 13:47:19 +03:00
Import and Load layout runtime through dbus
--switchToLayout dbus interface is used in order to switch at specific layout that it is already imported. With this commit the same dbus interface can be used in order to import and load afterwards any latte layout file by sending its absolute filepath
This commit is contained in:
parent
61e9b10f95
commit
dc0a9a8f22
@ -1004,7 +1004,37 @@ void Corona::updateDockItemBadge(QString identifier, QString value)
|
||||
|
||||
void Corona::switchToLayout(QString layout)
|
||||
{
|
||||
m_layoutsManager->switchToLayout(layout);
|
||||
if ((layout.startsWith("file:/") || layout.startsWith("/")) && layout.endsWith(".layout.latte")) {
|
||||
//! Import and load runtime a layout through dbus interface
|
||||
//! It can be used from external programs that want to update runtime
|
||||
//! the Latte shown layout
|
||||
QString layoutPath = layout;
|
||||
|
||||
//! cleanup layout path
|
||||
if (layoutPath.startsWith("file:///")) {
|
||||
layoutPath = layout.remove("file://");
|
||||
} else if (layoutPath.startsWith("file://")) {
|
||||
layoutPath = layout.remove("file:/");
|
||||
}
|
||||
|
||||
//! check out layoutpath existence
|
||||
if (QFileInfo(layoutPath).exists()) {
|
||||
qDebug() << " Layout is going to be imported and loaded from file :: " << layoutPath;
|
||||
|
||||
QString importedLayout = m_layoutsManager->importer()->importLayoutHelper(layoutPath);
|
||||
|
||||
if (importedLayout.isEmpty()) {
|
||||
qDebug() << i18n("The layout cannot be imported from file :: ") << layoutPath;
|
||||
} else {
|
||||
m_layoutsManager->synchronizer()->loadLayouts();
|
||||
m_layoutsManager->switchToLayout(importedLayout);
|
||||
}
|
||||
} else {
|
||||
qDebug() << " Layout from missing file can not be imported and loaded :: " << layoutPath;
|
||||
}
|
||||
} else {
|
||||
m_layoutsManager->switchToLayout(layout);
|
||||
}
|
||||
}
|
||||
|
||||
void Corona::showSettingsWindow(int page)
|
||||
|
Loading…
x
Reference in New Issue
Block a user