update currentLayout,create Alternative if !exists

pull/1/head
Michail Vourlakos 8 years ago
parent 0889d2224d
commit 14e61b3a59

@ -230,11 +230,16 @@ void DockCorona::loadLatteLayout(QString layoutName)
{
QString layoutPath = m_layoutManager->layoutPath(layoutName);
if (layoutPath.isEmpty() && layoutName == i18n("Alternative")) {
layoutPath = m_layoutManager->requestLayout(i18n("Alternative"), i18n("Default"));
}
if (!layoutPath.isEmpty()) {
qDebug() << "corona is unloading the interface...";
unload();
qDebug() << "loading config file for layout:" << layoutName << " - " << layoutPath;
loadLayout(layoutPath);
universalSettings()->setCurrentLayoutName(layoutName);
foreach (auto containment, containments())
addDock(containment);

@ -20,6 +20,11 @@
#include "layoutmanager.h"
#include <QDir>
#include <QFile>
#include <KLocalizedString>
namespace Latte {
LayoutManager::LayoutManager(QObject *parent)
@ -64,4 +69,19 @@ QString LayoutManager::layoutPath(QString layoutName)
}
QString LayoutManager::requestLayout(QString layoutName, QString preset)
{
QString newFile = QDir::homePath() + "/.config/latte/" + layoutName + ".layout.latte";
QString resFile;
qDebug() << "adding layout : " << layoutName << " based on preset:" << preset;
if (preset == i18n("Default") && !QFile(newFile).exists()) {
qDebug() << "adding layout : succeed";
QFile(m_corona->kPackage().filePath("preset1")).copy(newFile);
resFile = newFile;
}
return resFile;
}
}

@ -45,6 +45,9 @@ public:
QString layoutPath(QString layoutName);
//! creates a new layout with layoutName based on the preset
QString requestLayout(QString layoutName, QString preset);
private:
DockCorona *m_corona{nullptr};
Importer *m_importer{nullptr};

Loading…
Cancel
Save