GUI: option to imports settings (useful for instantly applying themes)
This commit is contained in:
parent
1c629cee71
commit
5b2e8e4346
|
@ -1712,3 +1712,38 @@ void MainWindow::setInitialzationScript()
|
|||
BridgeSettingSet("Engine", "InitializeScript", browseScript.path.toUtf8().constData());
|
||||
}
|
||||
}
|
||||
|
||||
#include "../src/bridge/Utf8Ini.h"
|
||||
|
||||
void MainWindow::on_actionImportSettings_triggered()
|
||||
{
|
||||
auto filename = QFileDialog::getOpenFileName(this, tr("Open file"), QCoreApplication::applicationDirPath(), tr("Settings (*.ini);;All files (*.*)"));
|
||||
if(!filename.length())
|
||||
return;
|
||||
QFile f(QDir::toNativeSeparators(filename));
|
||||
if(f.open(QFile::ReadOnly | QFile::Text))
|
||||
{
|
||||
QTextStream in(&f);
|
||||
auto style = in.readAll();
|
||||
f.close();
|
||||
Utf8Ini ini;
|
||||
int errorLine;
|
||||
if(ini.Deserialize(style.toStdString(), errorLine))
|
||||
{
|
||||
auto sections = ini.Sections();
|
||||
for(const auto & section : sections)
|
||||
{
|
||||
auto keys = ini.Keys(section);
|
||||
for(const auto & key : keys)
|
||||
BridgeSettingSet(section.c_str(), key.c_str(), ini.GetValue(section, key).c_str());
|
||||
}
|
||||
Config()->load();
|
||||
DbgSettingsUpdated();
|
||||
Config()->emitColorsUpdated();
|
||||
Config()->emitFontsUpdated();
|
||||
Config()->emitShortcutsUpdated();
|
||||
Config()->emitTokenizerConfigUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -234,6 +234,7 @@ public:
|
|||
private slots:
|
||||
void on_actionFaq_triggered();
|
||||
void on_actionReloadStylesheet_triggered();
|
||||
void on_actionImportSettings_triggered();
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
|
@ -161,6 +161,7 @@
|
|||
<addaction name="actionTopmost"/>
|
||||
<addaction name="actionReloadStylesheet"/>
|
||||
<addaction name="actionSetInitializationScript"/>
|
||||
<addaction name="actionImportSettings"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuFavourites">
|
||||
<property name="title">
|
||||
|
@ -1028,6 +1029,11 @@
|
|||
<string>Set Initialization Script</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionImportSettings">
|
||||
<property name="text">
|
||||
<string>Import settings...</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
|
|
|
@ -644,6 +644,11 @@ void Configuration::writeShortcuts()
|
|||
emit shortcutsUpdated();
|
||||
}
|
||||
|
||||
void Configuration::emitShortcutsUpdated()
|
||||
{
|
||||
emit shortcutsUpdated();
|
||||
}
|
||||
|
||||
const QColor Configuration::getColor(const QString id) const
|
||||
{
|
||||
if(Colors.contains(id))
|
||||
|
|
|
@ -51,6 +51,7 @@ public:
|
|||
void emitFontsUpdated();
|
||||
void readShortcuts();
|
||||
void writeShortcuts();
|
||||
void emitShortcutsUpdated();
|
||||
|
||||
const QColor getColor(const QString id) const;
|
||||
const bool getBool(const QString category, const QString id) const;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit cb47871b821891334a1c6c8ac1abf350e9a5eb74
|
||||
Subproject commit 42cfc5567edd52cfdad85f68a2be6822c6b37d65
|
Loading…
Reference in New Issue