2019-09-28 01:18:08 +08:00
|
|
|
#include "mainwindow.h"
|
|
|
|
#include <QApplication>
|
2019-10-01 10:37:14 +08:00
|
|
|
#include <QCommandLineParser>
|
2020-01-05 14:30:33 +08:00
|
|
|
#include <QDir>
|
2019-10-06 17:31:27 +08:00
|
|
|
#include <QTranslator>
|
2019-10-01 10:37:14 +08:00
|
|
|
#include <QUrl>
|
2019-09-28 01:18:08 +08:00
|
|
|
|
2020-01-05 15:22:47 +08:00
|
|
|
// QM_FILE_INSTALL_DIR should be defined from the CMakeLists file.
|
|
|
|
#ifndef QM_FILE_INSTALL_DIR
|
|
|
|
#define QM_FILE_INSTALL_DIR ":/i18n/"
|
|
|
|
#endif // QM_FILE_INSTALL_DIR
|
|
|
|
|
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
|
|
|
|
2019-10-06 17:31:27 +08:00
|
|
|
QTranslator translator;
|
2020-01-05 14:30:33 +08:00
|
|
|
QString qmDir;
|
|
|
|
#ifdef _WIN32
|
|
|
|
qmDir = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath("translations");
|
|
|
|
#else
|
2020-01-05 15:22:47 +08:00
|
|
|
qmDir = QT_STRINGIFY(QM_FILE_INSTALL_DIR);
|
2020-01-05 14:30:33 +08:00
|
|
|
#endif
|
|
|
|
translator.load(QString("PineapplePictures_%1").arg(QLocale::system().name()), qmDir);
|
2019-10-06 17:31:27 +08:00
|
|
|
a.installTranslator(&translator);
|
2020-07-21 20:47:06 +08:00
|
|
|
a.setApplicationName("Pineapple Pictures");
|
|
|
|
a.setApplicationDisplayName(QCoreApplication::translate("main", "Pineapple Pictures"));
|
2019-10-06 17:31:27 +08:00
|
|
|
|
2019-10-01 10:37:14 +08:00
|
|
|
// parse commandline arguments
|
|
|
|
QCommandLineParser parser;
|
|
|
|
parser.addPositionalArgument("File list", QCoreApplication::translate("main", "File list."));
|
2019-10-06 17:31:27 +08:00
|
|
|
parser.addHelpOption();
|
2019-10-01 10:37:14 +08:00
|
|
|
|
|
|
|
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();
|
|
|
|
|
2019-10-01 10:37:14 +08:00
|
|
|
if (!urlList.isEmpty()) {
|
|
|
|
w.showUrls(urlList);
|
2019-10-01 11:44:35 +08:00
|
|
|
w.adjustWindowSizeBySceneRect();
|
2019-10-01 10:37:14 +08:00
|
|
|
}
|
|
|
|
|
2019-09-28 01:18:08 +08:00
|
|
|
return a.exec();
|
|
|
|
}
|