mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-01 00:58:24 +03:00
add presets on startup
This commit is contained in:
parent
b39dc2b72a
commit
93deb7d3cc
@ -71,6 +71,7 @@ void LayoutManager::load()
|
||||
if (configVer < 2 && QFile(QDir::homePath() + "/.config/lattedockrc").exists()) {
|
||||
qDebug() << "Latte must update its configuration...";
|
||||
m_importer->updateOldConfiguration();
|
||||
importPresets(false);
|
||||
} else if (!QFile(QDir::homePath() + "/.config/lattedockrc").exists()) {
|
||||
//startup create what is necessary....
|
||||
QDir layoutDir(QDir::homePath() + "/.config/latte");
|
||||
@ -80,6 +81,7 @@ void LayoutManager::load()
|
||||
}
|
||||
|
||||
newLayout(i18n("My Layout"));
|
||||
importPresets(false);
|
||||
m_corona->universalSettings()->setCurrentLayoutName(i18n("My Layout"));
|
||||
m_corona->universalSettings()->setVersion(2);
|
||||
}
|
||||
@ -270,6 +272,29 @@ QString LayoutManager::newLayout(QString layoutName, QString preset)
|
||||
return newLayoutPath;
|
||||
}
|
||||
|
||||
void LayoutManager::importPresets(bool includeDefault)
|
||||
{
|
||||
int start = 1;
|
||||
|
||||
if (!includeDefault) {
|
||||
start = 2;
|
||||
}
|
||||
|
||||
for (int i = start; i <= 4; ++i) {
|
||||
QByteArray presetNameOrig = QString("preset" + QString::number(i)).toUtf8();
|
||||
QString presetPath = m_corona->kPackage().filePath(presetNameOrig);
|
||||
QString presetName = LayoutSettings::layoutName(presetPath);
|
||||
QByteArray presetNameChars = presetName.toUtf8();
|
||||
presetName = i18n(presetNameChars);
|
||||
|
||||
QString newLayoutFile = QDir::homePath() + "/.config/latte/" + presetName + ".layout.latte";
|
||||
|
||||
if (!QFile(newLayoutFile).exists()) {
|
||||
QFile(presetPath).copy(newLayoutFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LayoutManager::showLayoutConfigDialog()
|
||||
{
|
||||
if (!m_layoutConfigDialog)
|
||||
|
@ -74,6 +74,8 @@ public:
|
||||
|
||||
QStringList activities();
|
||||
|
||||
void importPresets(bool includeDefault = false);
|
||||
|
||||
public slots:
|
||||
//! switch to specified layout
|
||||
Q_INVOKABLE bool switchToLayout(QString layoutName);
|
||||
|
Loading…
x
Reference in New Issue
Block a user