pineapple-pictures/main.cpp

48 lines
1.2 KiB
C++
Raw Normal View History

2019-09-28 01:18:08 +08:00
#include "mainwindow.h"
#include <QApplication>
#include <QCommandLineParser>
2020-01-05 14:30:33 +08:00
#include <QDir>
#include <QTranslator>
#include <QUrl>
2019-09-28 01:18:08 +08:00
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
2019-09-29 23:53:29 +08:00
QTranslator translator;
2020-01-05 14:30:33 +08:00
QString qmDir;
#ifdef _WIN32
qmDir = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath("translations");
#else
qmDir = QString(QM_FILE_INSTALL_DIR);
#endif
translator.load(QString("PineapplePictures_%1").arg(QLocale::system().name()), qmDir);
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();
QList<QUrl> urlList;
for (const QString & str : urlStrList) {
QUrl url = QUrl::fromLocalFile(str);
if (url.isValid()) {
urlList.append(url);
}
}
2019-09-28 01:18:08 +08:00
MainWindow w;
w.show();
if (!urlList.isEmpty()) {
w.showUrls(urlList);
2019-10-01 11:44:35 +08:00
w.adjustWindowSizeBySceneRect();
}
2019-09-28 01:18:08 +08:00
return a.exec();
}