aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop/main.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2019-09-16 00:53:06 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2019-09-16 00:53:06 +0800
commitc944d7279bd3745f3391c56dc1dbc5e02f26c425 (patch)
treed96db563d7afb263faad5579286b025a5b4f0318 /qmidiplayer-desktop/main.cpp
parent9fecb429a37bcaa577aaa972139f6db3ce17ac50 (diff)
downloadQMidiPlayer-c944d7279bd3745f3391c56dc1dbc5e02f26c425.tar.xz
Use QCommandLineParser to parse arguments.
New argument for loading plugins from given files. Use functor whenever possible in QObject::connect. A little bit of code cleanups.
Diffstat (limited to 'qmidiplayer-desktop/main.cpp')
-rw-r--r--qmidiplayer-desktop/main.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/qmidiplayer-desktop/main.cpp b/qmidiplayer-desktop/main.cpp
index f62429c..602aedc 100644
--- a/qmidiplayer-desktop/main.cpp
+++ b/qmidiplayer-desktop/main.cpp
@@ -20,13 +20,17 @@
#include <QStyle>
#include <QTranslator>
#include <QLibraryInfo>
+#include <QCommandLineParser>
int main(int argc,char **argv)
{
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
+ QCoreApplication::setApplicationName("qmidiplayer");
+ QCoreApplication::setApplicationVersion(APP_VERSION);
if(!qgetenv("QT_SCALE_FACTOR").length()&&!qgetenv("QT_SCREEN_SCALE_FACTORS").length())
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication a(argc,argv);
+
QTranslator qtTranslator;
qtTranslator.load("qt_"+QLocale::system().name(),
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
@@ -34,7 +38,17 @@ int main(int argc,char **argv)
QTranslator qmpTranslator;
qmpTranslator.load("qmp_"+QLocale::system().name());
a.installTranslator(&qmpTranslator);
- qmpMainWindow w;
+
+ QCommandLineParser clp;
+ clp.setApplicationDescription("A cross-platform MIDI player.");
+ clp.addHelpOption();
+ clp.addVersionOption();
+ clp.addPositionalArgument("file",QCoreApplication::translate("main","midi files to play (optional)."),"[files...]");
+ clp.addOption(QCommandLineOption("plugin",QCoreApplication::translate("main","Load a plugin from <plugin library>."),"plugin library"));
+ clp.addOption(QCommandLineOption({"l","load-all-files"},QCoreApplication::translate("main","Load all files from the same folder.")));
+ clp.process(a);
+
+ qmpMainWindow w(&clp);
if(w.parseArgs()==1)return 0;
w.init();