open project from command line

master
zetaPRIME 2022-03-13 19:04:27 -04:00
parent 59f45ab382
commit ba6683cd2d
2 changed files with 14 additions and 4 deletions

5
notes
View File

@ -36,9 +36,12 @@ TODO {
- keep list of active windows
- quit (just trigger close on all sequentially)
- if opening project already in other window, focus/flash that window
open project from command line
- open project from command line
IPC to open/new window in existing instance
revert action
xdg mime package + desktop file association
application/x-xybrid-project
}
clear song info on loading template?

View File

@ -7,9 +7,10 @@
#include <vector>
#include <QDebug>
#include <QFontDatabase>
#include <QApplication>
#include <QCommandLineParser>
#include <QSurfaceFormat>
#include <QFontDatabase>
int main(int argc, char *argv[]) {
qRegisterMetaType<Xybrid::Data::Port>();
@ -20,8 +21,14 @@ int main(int argc, char *argv[]) {
QSurfaceFormat::setDefaultFormat(fmt);
QApplication a(argc, argv);
QCommandLineParser cl;
cl.addHelpOption();
cl.addVersionOption();
cl.addPositionalArgument("project", QApplication::translate("main", "Project file to open."));
cl.process(a);
auto args = cl.positionalArguments();
QString fileName = args.size() >= 1 ? args.at(0) : QString();
// make sure bundled fonts are loaded
QFontDatabase::addApplicationFont(":/fonts/iosevka-term-light.ttf");
@ -33,7 +40,7 @@ int main(int argc, char *argv[]) {
Xybrid::Config::PluginRegistry::init();
Xybrid::Audio::AudioEngine::init();
auto* w = new Xybrid::MainWindow();
auto* w = new Xybrid::MainWindow(nullptr, fileName);
w->show();
// hook up exit event