aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop/qmpmainwindow.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2016-04-16 21:03:44 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2016-04-16 21:03:44 +0800
commitf3694385610a66215b65fafc1e05680baddeb090 (patch)
treea183da31372ce97c3e02d34d50647e565062e1f1 /qmidiplayer-desktop/qmpmainwindow.cpp
parent56374529448b63cc5d94b344da14e8d90ee6e17d (diff)
downloadQMidiPlayer-f3694385610a66215b65fafc1e05680baddeb090.tar.xz
Fixed two bugs in initialization process.
Documentation...
Diffstat (limited to 'qmidiplayer-desktop/qmpmainwindow.cpp')
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.cpp33
1 files changed, 19 insertions, 14 deletions
diff --git a/qmidiplayer-desktop/qmpmainwindow.cpp b/qmidiplayer-desktop/qmpmainwindow.cpp
index 45ab634..b01df10 100644
--- a/qmidiplayer-desktop/qmpmainwindow.cpp
+++ b/qmidiplayer-desktop/qmpmainwindow.cpp
@@ -1,5 +1,6 @@
#include <cstdio>
#include <QUrl>
+#include <QFileInfo>
#include <QMimeData>
#include <QDirIterator>
#include <QDesktopWidget>
@@ -45,9 +46,20 @@ qmpMainWindow::qmpMainWindow(QWidget *parent) :
ui->lbFileName->setText("");ref=this;
playing=false;stopped=true;dragging=false;
settingsw=new qmpSettingsWindow(this);
+ plistw=new qmpPlistWindow(this);player=NULL;timer=NULL;
singleFS=qmpSettingsWindow::getSettingsIntf()->value("Behavior/SingleInstance",0).toInt();
+}
+
+qmpMainWindow::~qmpMainWindow()
+{
+ if(player)delete player;
+ if(timer)delete timer;
+ delete ui;
+}
+
+void qmpMainWindow::init()
+{
player=new CMidiPlayer(singleFS);
- plistw=new qmpPlistWindow(this);
chnlw=new qmpChannelsWindow(this);
efxw=new qmpEfxWindow(this);
infow=new qmpInfoWindow(this);
@@ -81,18 +93,12 @@ qmpMainWindow::qmpMainWindow(QWidget *parent) :
connect(timer,SIGNAL(timeout()),this,SLOT(updateWidgets()));
connect(timer,SIGNAL(timeout()),chnlw,SLOT(channelWindowsUpdate()));
connect(timer,SIGNAL(timeout()),infow,SLOT(updateInfo()));
-}
-
-qmpMainWindow::~qmpMainWindow()
-{
- delete player;
- delete timer;
- delete ui;
+ if(havemidi)on_pbPlayPause_clicked();
}
int qmpMainWindow::pharseArgs(int argc,char** argv)
{
- bool havemidi=false,loadfolder=false;
+ bool loadfolder=false;havemidi=false;
for(int i=1;i<argc;++i)
{
if(argv[i][0]=='-')
@@ -101,9 +107,9 @@ int qmpMainWindow::pharseArgs(int argc,char** argv)
{
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");
+ 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"))
@@ -120,7 +126,7 @@ int qmpMainWindow::pharseArgs(int argc,char** argv)
if(!havemidi){havemidi=true;plistw->emptyList();}
if(loadfolder||qmpSettingsWindow::getSettingsIntf()->value("Behavior/LoadFolder",0).toInt())
{
- QDirIterator di(QUrl(argv[i]).adjusted(QUrl::RemoveFilename).toString());
+ QDirIterator di(QFileInfo(argv[i]).absolutePath());
while(di.hasNext())
{
QString c=di.next();
@@ -132,7 +138,6 @@ int qmpMainWindow::pharseArgs(int argc,char** argv)
plistw->insertItem(argv[i]);
}
}
- if(havemidi)on_pbPlayPause_clicked();
return 0;
}