Make org name configurable for Studio

This commit is contained in:
Gary Talent 2017-10-21 02:44:53 -05:00
parent 6f31e645ec
commit 3097e12e98
4 changed files with 14 additions and 10 deletions

View File

@ -36,12 +36,11 @@ const QString MainWindow::StateFilePath = "studio_state.json";
MainWindow::MainWindow(QString profilePath) {
m_profilePath = profilePath;
// load in profile file
NostalgiaStudioProfile profile;
QFile file(profilePath);
if (file.exists()) {
file.open(QIODevice::ReadOnly);
QTextStream in(&file);
readJson(in.readAll(), &profile);
readJson(in.readAll(), &m_profile);
}
auto screenSize = QApplication::desktop()->screenGeometry();
@ -52,7 +51,7 @@ MainWindow::MainWindow(QString profilePath) {
move(-x(), -y());
move(screenSize.width() * (1 - sizePct) / 2, screenSize.height() * (1 - sizePct) / 2);
setWindowTitle(profile.appName);
setWindowTitle(m_profile.appName);
m_tabbar = new QTabBar(this);
setCentralWidget(m_tabbar);
@ -61,7 +60,7 @@ MainWindow::MainWindow(QString profilePath) {
setupProjectExplorer();
statusBar(); // setup status bar
loadPlugins(profile);
loadPlugins();
readState();
}
@ -73,8 +72,8 @@ MainWindow::~MainWindow() {
}
}
void MainWindow::loadPlugins(NostalgiaStudioProfile profile) {
for (auto p : profile.plugins) {
void MainWindow::loadPlugins() {
for (auto p : m_profile.plugins) {
#if defined(Q_OS_WIN)
auto libName = p.libName + ".dll";
#elif defined(Q_OS_MAC)
@ -198,7 +197,7 @@ QAction *MainWindow::addAction(QMenu *menu, QString text, QString toolTip,
int MainWindow::readState(QString path) {
int err = 0;
QSettings settings("Drinking Tea", "nostalgia-studio");
QSettings settings(m_profile.orgName, m_profile.appName);
settings.beginGroup("MainWindow");
restoreGeometry(settings.value("geometry").toByteArray());
restoreState(settings.value("windowState").toByteArray());
@ -218,7 +217,7 @@ int MainWindow::writeState(QString path) {
QString json;
err |= writeJson(&json, &m_state);
QSettings settings("Drinking Tea", "nostalgia-studio");
QSettings settings(m_profile.orgName, m_profile.appName);
settings.beginGroup("MainWindow");
settings.setValue("geometry", saveGeometry());
settings.setValue("windowState", saveState());

View File

@ -60,14 +60,16 @@ ox::Error ioOp(T *io, NostalgiaStudioPluginDef *obj) {
struct NostalgiaStudioProfile {
QString appName;
QString orgName;
QVector<NostalgiaStudioPluginDef> plugins;
};
template<typename T>
ox::Error ioOp(T *io, NostalgiaStudioProfile *obj) {
ox::Error err = 0;
io->setFields(2);
io->setFields(3);
err |= io->op("app_name", &obj->appName);
err |= io->op("org_name", &obj->orgName);
err |= io->op("plugins", &obj->plugins);
return err;
}
@ -82,6 +84,7 @@ class MainWindow: public QMainWindow {
private:
QString m_profilePath;
NostalgiaStudioProfile m_profile;
NostalgiaStudioState m_state;
QAction *m_importAction = nullptr;
Project *m_project = nullptr;
@ -99,7 +102,7 @@ class MainWindow: public QMainWindow {
virtual ~MainWindow();
private:
void loadPlugins(NostalgiaStudioProfile profile);
void loadPlugins();
void setupDockWidgets();

View File

@ -1,5 +1,6 @@
{
"app_name": "Nostalgia Studio",
"org_name": "Drinking Tea",
"plugins": [
{
"dir": "./",

View File

@ -1,5 +1,6 @@
{
"app_name": "Nostalgia Studio",
"org_name": "Drinking Tea",
"plugins": [
{
"dir": "../lib/nostalgia",