aboutsummaryrefslogtreecommitdiff
path: root/qmpmainwindow.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2016-01-06 21:28:44 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2016-01-06 21:28:44 +0800
commit7fccb61519fe84b2ced274f1cc4859d5000e86c6 (patch)
treef66696e67d56e9e6015d613af84562364baaa9ed /qmpmainwindow.cpp
parent8099672c3fd0bfc7804b0a92d05c57dcd4307268 (diff)
downloadQMidiPlayer-7fccb61519fe84b2ced274f1cc4859d5000e86c6.tar.xz
Maple Dream. (WTF)
Diffstat (limited to 'qmpmainwindow.cpp')
-rw-r--r--qmpmainwindow.cpp49
1 files changed, 48 insertions, 1 deletions
diff --git a/qmpmainwindow.cpp b/qmpmainwindow.cpp
index 00e23ff..242e52f 100644
--- a/qmpmainwindow.cpp
+++ b/qmpmainwindow.cpp
@@ -1,5 +1,6 @@
#include <cstdio>
#include <QUrl>
+#include <QDirIterator>
#include <QDesktopWidget>
#include "qmpmainwindow.hpp"
#include "ui_qmpmainwindow.h"
@@ -33,7 +34,7 @@ qmpMainWindow::qmpMainWindow(QWidget *parent) :
else setGeometry(QStyle::alignedRect(
Qt::LeftToRight,Qt::AlignCenter,size(),
qApp->desktop()->availableGeometry()));
- }
+ }show();
if(qmpSettingsWindow::getSettingsIntf()->value("DialogStatus/PListWShown",0).toInt())
{ui->pbPList->setChecked(true);on_pbPList_clicked();}
if(qmpSettingsWindow::getSettingsIntf()->value("DialogStatus/ChnlWShown",0).toInt())
@@ -53,6 +54,52 @@ qmpMainWindow::~qmpMainWindow()
delete ui;
}
+int qmpMainWindow::pharseArgs(int argc,char** argv)
+{
+ bool havemidi=false,loadfolder=false;
+ for(int i=1;i<argc;++i)
+ {
+ if(argv[i][0]=='-')
+ {
+ if(!strcmp(argv[i],"--help"))
+ {
+ printf("Usage: %s [Options] [Midi Files]\n",argv[0]);
+ printf("Possible options are: \n");
+ printf("-l, --load-all-files Load all files from the same folder.\n");
+ printf("--help Show this help and exit.\n");
+ printf("--version Show this version information and exit.\n");
+ return 1;
+ }
+ if(!strcmp(argv[i],"--version"))
+ {
+ printf("QMidiPlayer %s\n",APP_VERSION);
+ return 1;
+ }
+ if(!strcmp(argv[i],"-l")||!strcmp(argv[i],"--load-all-files"))
+ loadfolder=true;
+ }
+ else
+ if(fluid_is_midifile(argv[i]))
+ {
+ if(!havemidi){havemidi=true;plistw->emptyList();}
+ if(loadfolder||qmpSettingsWindow::getSettingsIntf()->value("Behavior/LoadFolder",0).toInt())
+ {
+ QDirIterator di(QUrl(argv[i]).adjusted(QUrl::RemoveFilename).toString());
+ while(di.hasNext())
+ {
+ QString c=di.next();
+ if((c.endsWith(".mid")||c.endsWith(".midi"))&&fluid_is_midifile(c.toStdString().c_str()))
+ plistw->insertItem(c.toStdString().c_str());
+ }
+ }
+ else
+ plistw->insertItem(argv[i]);
+ }
+ }
+ if(havemidi)on_pbPlayPause_clicked();
+ return 0;
+}
+
void qmpMainWindow::closeEvent(QCloseEvent *event)
{
on_pbStop_clicked();fin=true;