Add Nostalgia Studio profile option
This commit is contained in:
parent
60b4a32995
commit
b447d4c329
@ -7,14 +7,33 @@
|
||||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include "studio/mainwindow.hpp"
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <ox/clargs/clargs.hpp>
|
||||
#include "json/json.hpp"
|
||||
#include "mainwindow.hpp"
|
||||
|
||||
using namespace nostalgia::studio;
|
||||
using namespace ox::clargs;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
QApplication app(argc, argv);
|
||||
int main(int argc, char **args) {
|
||||
ClArgs clargs(argc, (const char**) args);
|
||||
QString argProfilePath = clargs.getString("profile").c_str();
|
||||
|
||||
MainWindow w;
|
||||
NostalgiaStudioProfile config;
|
||||
|
||||
// load in config file
|
||||
QFile file(argProfilePath);
|
||||
if (file.exists()) {
|
||||
file.open(QIODevice::ReadOnly);
|
||||
QTextStream in(&file);
|
||||
read(in.readAll(), &config);
|
||||
}
|
||||
|
||||
QApplication app(argc, args);
|
||||
app.setApplicationName(config.app_name);
|
||||
|
||||
MainWindow w(config);
|
||||
w.show();
|
||||
|
||||
return app.exec();
|
||||
|
@ -8,21 +8,21 @@
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include "studio/mainwindow.hpp"
|
||||
#include "mainwindow.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
namespace studio {
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) {
|
||||
MainWindow::MainWindow(NostalgiaStudioProfile config, QWidget *parent) {
|
||||
auto screenSize = QApplication::desktop()->screenGeometry();
|
||||
|
||||
// set window to 70% of screen width, and center it
|
||||
// set window to 70% of screen width, and center NostalgiaStudioProfile
|
||||
auto sizePct = 0.7;
|
||||
resize(screenSize.width() * sizePct, screenSize.height() * sizePct);
|
||||
move(-x(), -y());
|
||||
move(screenSize.width() * (1 - sizePct) / 2, screenSize.height() * (1 - sizePct) / 2);
|
||||
|
||||
setWindowTitle("Nostalgia Studio");
|
||||
setWindowTitle(config.app_name);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
|
@ -7,6 +7,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <ox/std/types.hpp>
|
||||
#include <QModelIndex>
|
||||
#include <QMainWindow>
|
||||
#include <QPoint>
|
||||
@ -15,6 +16,18 @@
|
||||
namespace nostalgia {
|
||||
namespace studio {
|
||||
|
||||
struct NostalgiaStudioProfile {
|
||||
QString app_name;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
int ioOp(T *io, NostalgiaStudioProfile *obj) {
|
||||
ox::Error err = 0;
|
||||
err |= io->op("app_name", &obj->app_name);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
class MainWindow: public QMainWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
@ -25,7 +38,7 @@ class MainWindow: public QMainWindow {
|
||||
QString m_projectPath;
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
MainWindow(NostalgiaStudioProfile config, QWidget *parent = 0);
|
||||
virtual ~MainWindow();
|
||||
|
||||
void openProject(QString);
|
||||
|
Loading…
Reference in New Issue
Block a user