fix #565,full dynamic reload the layout

--the new layout is loaded without closing
Latte and with properly loading globalSettings
and screen from the layout file. The layout
new files are updated when Latte is closing
pull/1/head
Michail Vourlakos 8 years ago
parent b417ae52c3
commit 67d1f1d4f9

@ -137,14 +137,16 @@ DockCorona::~DockCorona()
const auto homeLatterc = QDir::homePath() + "/.config/lattedockrc";
const auto homeAppletsrc = QDir::homePath() + "/.config/lattedock-appletsrc";
QFile::copy(latterc.fileName() , homeLatterc);
QFile::copy(appletsrc.fileName() , homeAppletsrc);
if (QFile::remove(homeLatterc) && QFile::remove(homeAppletsrc)){
QFile::copy(latterc.fileName() , homeLatterc);
QFile::copy(appletsrc.fileName() , homeAppletsrc);
}
QDir tempLayoutDir(m_layoutDir);
if (tempLayoutDir.exists() && m_layoutDir.startsWith("/tmp")) {
qDebug()<< "old layout directory should be deleted...";
//tempLayoutDir.removeRecursively();
qDebug()<< "old layout directory should be deleted... - " << tempLayoutDir.absolutePath();
tempLayoutDir.removeRecursively();
}
}
}
@ -203,15 +205,17 @@ bool DockCorona::reloadLayout(QString path)
qDebug() << "reloadLayout: loading new layout - " << appletsrc.fileName();
m_screenPool->reload(m_layoutDir);
loadLayout(appletsrc.fileName());
m_globalSettings->reload();
foreach (auto containment, containments())
addDock(containment);
if (oldLayoutDir.exists() && oldLayoutDir.absolutePath().startsWith("/tmp")
&& oldLayoutDir.absolutePath() != path) {
qDebug()<< "old layout directory should be deleted...";
// oldLayoutDir.removeRecursively();
qDebug()<< "old layout directory should be deleted... - "<< oldLayoutDir.absolutePath();
oldLayoutDir.removeRecursively();
}
return true;

@ -66,6 +66,12 @@ void GlobalSettings::init()
initExtConfiguration();
}
void GlobalSettings::reload()
{
m_configGroup = m_corona->config()->group("General");
load(false);
}
void GlobalSettings::initExtConfiguration()
{
KSharedConfigPtr extConfig = KSharedConfig::openConfig(QDir::homePath() + "/.config/lattedockextrc");
@ -208,7 +214,7 @@ void GlobalSettings::setCurrentSession(Dock::SessionType session)
}
//!BEGIN configuration functions
void GlobalSettings::load()
void GlobalSettings::load(bool all)
{
m_exposeAltSession = m_configGroup.readEntry("exposeAltSession", false);
@ -219,7 +225,9 @@ void GlobalSettings::load()
emit exposeAltSessionChanged();
loadExtConfiguration();
if (all) {
loadExtConfiguration();
}
}
void GlobalSettings::loadLaunchers()

@ -51,7 +51,8 @@ public:
GlobalSettings(QObject *parent = nullptr);
~GlobalSettings() override;
void load();
void load(bool all=true);
void reload();
bool autostart() const;
void setAutostart(bool state);

@ -21,6 +21,7 @@
#include <config-latte.h>
#include <QDebug>
#include <QFile>
#include <QGuiApplication>
#include <QScreen>
@ -93,6 +94,22 @@ ScreenPool::~ScreenPool()
m_configGroup.sync();
}
void ScreenPool::reload(QString path)
{
QFile rcfile(QString(path + "/lattedockrc"));
if (rcfile.exists()){
qDebug() << "load screen connectors from ::: " << rcfile.fileName();
KSharedConfigPtr newFile = KSharedConfig::openConfig(rcfile.fileName());
m_configGroup = KConfigGroup(newFile, QStringLiteral("ScreenConnectors"));
load();
}
}
QString ScreenPool::primaryConnector() const
{
return m_primaryConnector;

@ -42,6 +42,7 @@ public:
void setPrimaryConnector(const QString &primary);
void insertScreenMapping(int id, const QString &connector);
void reload(QString path);
int id(const QString &connector) const;

Loading…
Cancel
Save