pineapple-music/main.cpp

49 lines
1.2 KiB
C++
Raw Normal View History

2020-04-06 15:15:13 +08:00
#include "mainwindow.h"
2020-04-11 19:54:51 +08:00
#include "singleapplicationmanager.h"
2020-04-06 15:15:13 +08:00
#include <QApplication>
#include <QCommandLineParser>
#include <QUrl>
2020-04-11 19:54:51 +08:00
#include <QDebug>
2020-06-05 00:20:36 +08:00
#include <QTranslator>
#include <QDir>
2020-04-06 15:15:13 +08:00
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
2020-06-05 00:20:36 +08:00
QTranslator translator;
if (translator.load(QLocale(), QLatin1String("pineapple-music"), QLatin1String("_"), QLatin1String(":/i18n"))) {
a.installTranslator(&translator);
}
2020-06-05 00:20:36 +08:00
a.installTranslator(&translator);
// parse commandline arguments
QCommandLineParser parser;
parser.addPositionalArgument("File list", QCoreApplication::translate("main", "File list."));
parser.addHelpOption();
parser.process(a);
QStringList urlStrList = parser.positionalArguments();
2020-04-11 19:54:51 +08:00
SingleApplicationManager sam("_pineapple_music_owo_");
if (sam.checkSingleInstance(QVariant::fromValue(urlStrList))) {
return 0;
} else {
sam.createSingleInstance();
}
2020-04-06 15:15:13 +08:00
MainWindow w;
w.show();
2020-04-11 19:54:51 +08:00
if (!urlStrList.isEmpty()) {
w.commandlinePlayAudioFiles(urlStrList);
}
2020-04-11 19:54:51 +08:00
QObject::connect(&sam, &SingleApplicationManager::dataReached, &w, &MainWindow::localSocketPlayAudioFiles);
2020-04-06 15:15:13 +08:00
return a.exec();
}