aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop
diff options
context:
space:
mode:
Diffstat (limited to 'qmidiplayer-desktop')
-rw-r--r--qmidiplayer-desktop/main.cpp2
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.cpp54
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.hpp3
3 files changed, 42 insertions, 17 deletions
diff --git a/qmidiplayer-desktop/main.cpp b/qmidiplayer-desktop/main.cpp
index e763811..2ac275e 100644
--- a/qmidiplayer-desktop/main.cpp
+++ b/qmidiplayer-desktop/main.cpp
@@ -32,7 +32,7 @@ int main(int argc,char **argv)
qmpTranslator.load("qmp_"+QLocale::system().name());
a.installTranslator(&qmpTranslator);
qmpMainWindow w;
- if(w.pharseArgs(argc,argv)==1)return 0;
+ if(w.pharseArgs()==1)return 0;
w.init();
return a.exec();
diff --git a/qmidiplayer-desktop/qmpmainwindow.cpp b/qmidiplayer-desktop/qmpmainwindow.cpp
index 82537d2..e38ed2a 100644
--- a/qmidiplayer-desktop/qmpmainwindow.cpp
+++ b/qmidiplayer-desktop/qmpmainwindow.cpp
@@ -99,37 +99,60 @@ void qmpMainWindow::init()
if(havemidi)on_pbPlayPause_clicked();
}
-int qmpMainWindow::pharseArgs(int argc,char** argv)
+int qmpMainWindow::pharseArgs()
{
bool loadfolder=false;havemidi=false;
- for(int i=1;i<argc;++i)
+ QStringList args=QApplication::arguments();
+ for(int i=1;i<args.size();++i)
{
- if(argv[i][0]=='-')
+ if(args.at(i).at(0)=='-')
{
- if(!strcmp(argv[i],"--help"))
+ if(args.at(i)==QString("--help"))
{
- printf("Usage: %s [Options] [Midi Files]\n",argv[0]);
+ printf("Usage: %s [Options] [Midi Files]\n",args.at(0).toStdString().c_str());
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"))
+ if(args.at(i)==QString("--version"))
{
printf("QMidiPlayer %s\n",APP_VERSION);
return 1;
}
- if(!strcmp(argv[i],"-l")||!strcmp(argv[i],"--load-all-files"))
+ if(args.at(i)==QString("-l")||args.at(i)==QString("--load-all-files"))
loadfolder=true;
}
else
- if(fluid_is_midifile(argv[i]))
+#ifdef _WIN32
+ {
+ char* c=wcsto8bit(args.at(i).toStdWString().c_str());
+ if(fluid_is_midifile(c))
+ {
+ if(!havemidi){havemidi=true;plistw->emptyList();}
+ if(loadfolder||qmpSettingsWindow::getSettingsIntf()->value("Behavior/LoadFolder",0).toInt())
+ {
+ QDirIterator di(QFileInfo(args.at(i)).absolutePath());
+ while(di.hasNext())
+ {
+ QString c=di.next();char* cc=wcsto8bit(c.toStdWString().c_str());
+ if((c.endsWith(".mid")||c.endsWith(".midi"))&&fluid_is_midifile(cc))
+ plistw->insertItem(c);free(cc);
+ }
+ }
+ else
+ plistw->insertItem(args.at(i));
+ }
+ free(c);
+ }
+#else
+ if(fluid_is_midifile(args.at(i).toStdString().c_str()))
{
if(!havemidi){havemidi=true;plistw->emptyList();}
if(loadfolder||qmpSettingsWindow::getSettingsIntf()->value("Behavior/LoadFolder",0).toInt())
{
- QDirIterator di(QFileInfo(argv[i]).absolutePath());
+ QDirIterator di(QFileInfo(args.at(i)).absolutePath());
while(di.hasNext())
{
QString c=di.next();
@@ -138,8 +161,9 @@ int qmpMainWindow::pharseArgs(int argc,char** argv)
}
}
else
- plistw->insertItem(argv[i]);
+ plistw->insertItem(args.at(i).toStdString().c_str());
}
+#endif
}
return 0;
}
@@ -206,7 +230,7 @@ void qmpMainWindow::updateWidgets()
if(singleFS)player->playerPanic(true);
chnlw->on_pbUnmute_clicked();chnlw->on_pbUnsolo_clicked();
QString fns=plistw->getNextItem();
- ui->lbFileName->setText(QUrl(fns).fileName());
+ ui->lbFileName->setText(QUrl::fromLocalFile(fns).fileName());
LOAD_FILE;
char ts[100];
sprintf(ts,"%02d:%02d",(int)player->getFtime()/60,(int)player->getFtime()%60);
@@ -306,7 +330,7 @@ void qmpMainWindow::on_pbPlayPause_clicked()
fns=plistw->getFirstItem();
if(!fns.length())return(void)(playing=false);
}
- ui->lbFileName->setText(QUrl(fns).fileName());
+ ui->lbFileName->setText(QUrl::fromLocalFile(fns).fileName());
LOAD_FILE;
char ts[100];
sprintf(ts,"%02d:%02d",(int)player->getFtime()/60,(int)player->getFtime()%60);
@@ -430,7 +454,7 @@ void qmpMainWindow::on_pbPrev_clicked()
if(singleFS)player->playerPanic(true);
ui->hsTimer->setValue(0);chnlw->on_pbUnmute_clicked();chnlw->on_pbUnsolo_clicked();
QString fns=plistw->getPrevItem();if(fns.length()==0)return on_pbStop_clicked();
- ui->lbFileName->setText(QUrl(fns).fileName());
+ ui->lbFileName->setText(QUrl::fromLocalFile(fns).fileName());
LOAD_FILE;
char ts[100];
sprintf(ts,"%02d:%02d",(int)player->getFtime()/60,(int)player->getFtime()%60);
@@ -455,7 +479,7 @@ void qmpMainWindow::on_pbNext_clicked()
if(singleFS)player->playerPanic(true);
ui->hsTimer->setValue(0);chnlw->on_pbUnmute_clicked();chnlw->on_pbUnsolo_clicked();
QString fns=plistw->getNextItem();if(fns.length()==0)return on_pbStop_clicked();
- ui->lbFileName->setText(QUrl(fns).fileName());
+ ui->lbFileName->setText(QUrl::fromLocalFile(fns).fileName());
LOAD_FILE;
char ts[100];
sprintf(ts,"%02d:%02d",(int)player->getFtime()/60,(int)player->getFtime()%60);
@@ -483,7 +507,7 @@ void qmpMainWindow::selectionChanged()
ui->hsTimer->setValue(0);
chnlw->on_pbUnmute_clicked();chnlw->on_pbUnsolo_clicked();
QString fns=plistw->getSelectedItem();
- ui->lbFileName->setText(QUrl(fns).fileName());
+ ui->lbFileName->setText(QUrl::fromLocalFile(fns).fileName());
LOAD_FILE;
char ts[100];
sprintf(ts,"%02d:%02d",(int)player->getFtime()/60,(int)player->getFtime()%60);
diff --git a/qmidiplayer-desktop/qmpmainwindow.hpp b/qmidiplayer-desktop/qmpmainwindow.hpp
index 729eb7f..55e0b12 100644
--- a/qmidiplayer-desktop/qmpmainwindow.hpp
+++ b/qmidiplayer-desktop/qmpmainwindow.hpp
@@ -9,6 +9,7 @@
#include <QDragEnterEvent>
#include <QAction>
#include <QMenu>
+#include <QApplication>
#include <thread>
#include <chrono>
#include "../core/qmpmidiplay.hpp"
@@ -39,7 +40,7 @@ class qmpMainWindow:public QMainWindow
QTimer* getTimer(){return timer;}
bool isFinalizing(){return fin;}
QString getFileName();
- int pharseArgs(int argc,char** argv);
+ int pharseArgs();
private slots:
void on_pbPlayPause_clicked();