Make org name configurable for Studio
This commit is contained in:
parent
6f31e645ec
commit
3097e12e98
@ -36,12 +36,11 @@ const QString MainWindow::StateFilePath = "studio_state.json";
|
|||||||
MainWindow::MainWindow(QString profilePath) {
|
MainWindow::MainWindow(QString profilePath) {
|
||||||
m_profilePath = profilePath;
|
m_profilePath = profilePath;
|
||||||
// load in profile file
|
// load in profile file
|
||||||
NostalgiaStudioProfile profile;
|
|
||||||
QFile file(profilePath);
|
QFile file(profilePath);
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
file.open(QIODevice::ReadOnly);
|
file.open(QIODevice::ReadOnly);
|
||||||
QTextStream in(&file);
|
QTextStream in(&file);
|
||||||
readJson(in.readAll(), &profile);
|
readJson(in.readAll(), &m_profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto screenSize = QApplication::desktop()->screenGeometry();
|
auto screenSize = QApplication::desktop()->screenGeometry();
|
||||||
@ -52,7 +51,7 @@ MainWindow::MainWindow(QString profilePath) {
|
|||||||
move(-x(), -y());
|
move(-x(), -y());
|
||||||
move(screenSize.width() * (1 - sizePct) / 2, screenSize.height() * (1 - sizePct) / 2);
|
move(screenSize.width() * (1 - sizePct) / 2, screenSize.height() * (1 - sizePct) / 2);
|
||||||
|
|
||||||
setWindowTitle(profile.appName);
|
setWindowTitle(m_profile.appName);
|
||||||
|
|
||||||
m_tabbar = new QTabBar(this);
|
m_tabbar = new QTabBar(this);
|
||||||
setCentralWidget(m_tabbar);
|
setCentralWidget(m_tabbar);
|
||||||
@ -61,7 +60,7 @@ MainWindow::MainWindow(QString profilePath) {
|
|||||||
setupProjectExplorer();
|
setupProjectExplorer();
|
||||||
statusBar(); // setup status bar
|
statusBar(); // setup status bar
|
||||||
|
|
||||||
loadPlugins(profile);
|
loadPlugins();
|
||||||
|
|
||||||
readState();
|
readState();
|
||||||
}
|
}
|
||||||
@ -73,8 +72,8 @@ MainWindow::~MainWindow() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::loadPlugins(NostalgiaStudioProfile profile) {
|
void MainWindow::loadPlugins() {
|
||||||
for (auto p : profile.plugins) {
|
for (auto p : m_profile.plugins) {
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
auto libName = p.libName + ".dll";
|
auto libName = p.libName + ".dll";
|
||||||
#elif defined(Q_OS_MAC)
|
#elif defined(Q_OS_MAC)
|
||||||
@ -198,7 +197,7 @@ QAction *MainWindow::addAction(QMenu *menu, QString text, QString toolTip,
|
|||||||
int MainWindow::readState(QString path) {
|
int MainWindow::readState(QString path) {
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
QSettings settings("Drinking Tea", "nostalgia-studio");
|
QSettings settings(m_profile.orgName, m_profile.appName);
|
||||||
settings.beginGroup("MainWindow");
|
settings.beginGroup("MainWindow");
|
||||||
restoreGeometry(settings.value("geometry").toByteArray());
|
restoreGeometry(settings.value("geometry").toByteArray());
|
||||||
restoreState(settings.value("windowState").toByteArray());
|
restoreState(settings.value("windowState").toByteArray());
|
||||||
@ -218,7 +217,7 @@ int MainWindow::writeState(QString path) {
|
|||||||
QString json;
|
QString json;
|
||||||
err |= writeJson(&json, &m_state);
|
err |= writeJson(&json, &m_state);
|
||||||
|
|
||||||
QSettings settings("Drinking Tea", "nostalgia-studio");
|
QSettings settings(m_profile.orgName, m_profile.appName);
|
||||||
settings.beginGroup("MainWindow");
|
settings.beginGroup("MainWindow");
|
||||||
settings.setValue("geometry", saveGeometry());
|
settings.setValue("geometry", saveGeometry());
|
||||||
settings.setValue("windowState", saveState());
|
settings.setValue("windowState", saveState());
|
||||||
|
@ -60,14 +60,16 @@ ox::Error ioOp(T *io, NostalgiaStudioPluginDef *obj) {
|
|||||||
|
|
||||||
struct NostalgiaStudioProfile {
|
struct NostalgiaStudioProfile {
|
||||||
QString appName;
|
QString appName;
|
||||||
|
QString orgName;
|
||||||
QVector<NostalgiaStudioPluginDef> plugins;
|
QVector<NostalgiaStudioPluginDef> plugins;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ox::Error ioOp(T *io, NostalgiaStudioProfile *obj) {
|
ox::Error ioOp(T *io, NostalgiaStudioProfile *obj) {
|
||||||
ox::Error err = 0;
|
ox::Error err = 0;
|
||||||
io->setFields(2);
|
io->setFields(3);
|
||||||
err |= io->op("app_name", &obj->appName);
|
err |= io->op("app_name", &obj->appName);
|
||||||
|
err |= io->op("org_name", &obj->orgName);
|
||||||
err |= io->op("plugins", &obj->plugins);
|
err |= io->op("plugins", &obj->plugins);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -82,6 +84,7 @@ class MainWindow: public QMainWindow {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_profilePath;
|
QString m_profilePath;
|
||||||
|
NostalgiaStudioProfile m_profile;
|
||||||
NostalgiaStudioState m_state;
|
NostalgiaStudioState m_state;
|
||||||
QAction *m_importAction = nullptr;
|
QAction *m_importAction = nullptr;
|
||||||
Project *m_project = nullptr;
|
Project *m_project = nullptr;
|
||||||
@ -99,7 +102,7 @@ class MainWindow: public QMainWindow {
|
|||||||
virtual ~MainWindow();
|
virtual ~MainWindow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loadPlugins(NostalgiaStudioProfile profile);
|
void loadPlugins();
|
||||||
|
|
||||||
void setupDockWidgets();
|
void setupDockWidgets();
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"app_name": "Nostalgia Studio",
|
"app_name": "Nostalgia Studio",
|
||||||
|
"org_name": "Drinking Tea",
|
||||||
"plugins": [
|
"plugins": [
|
||||||
{
|
{
|
||||||
"dir": "./",
|
"dir": "./",
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"app_name": "Nostalgia Studio",
|
"app_name": "Nostalgia Studio",
|
||||||
|
"org_name": "Drinking Tea",
|
||||||
"plugins": [
|
"plugins": [
|
||||||
{
|
{
|
||||||
"dir": "../lib/nostalgia",
|
"dir": "../lib/nostalgia",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user