2018-03-10 06:57:14 +00:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QDesktopWidget>
|
2018-03-11 03:18:24 +00:00
|
|
|
#include <QStyleFactory>
|
2018-03-18 08:46:53 +00:00
|
|
|
#include <QFontDatabase>
|
2018-04-07 08:44:39 +00:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QtGlobal>
|
2018-10-04 12:51:01 +00:00
|
|
|
#include <QSurfaceFormat>
|
2019-03-17 06:23:39 +00:00
|
|
|
#include <QSettings>
|
2019-06-27 12:44:33 +00:00
|
|
|
#include <QTranslator>
|
2020-04-04 00:54:05 +00:00
|
|
|
#include <qtsingleapplication.h>
|
2018-10-25 00:19:38 +00:00
|
|
|
#include "documentwindow.h"
|
2018-04-07 08:44:39 +00:00
|
|
|
#include "theme.h"
|
2018-04-26 02:23:22 +00:00
|
|
|
#include "version.h"
|
2018-04-07 08:44:39 +00:00
|
|
|
|
2018-03-10 06:57:14 +00:00
|
|
|
int main(int argc, char ** argv)
|
|
|
|
{
|
2020-04-04 00:54:05 +00:00
|
|
|
QtSingleApplication app(argc, argv);
|
|
|
|
if (app.sendMessage("activateFromAnotherInstance"))
|
|
|
|
return 0;
|
2018-03-11 03:18:24 +00:00
|
|
|
|
2019-06-27 12:44:33 +00:00
|
|
|
QTranslator translator;
|
|
|
|
if (translator.load(QLocale(), QLatin1String("dust3d"), QLatin1String("_"), QLatin1String(":/languages")))
|
|
|
|
app.installTranslator(&translator);
|
|
|
|
|
2020-03-18 14:17:09 +00:00
|
|
|
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
|
|
|
|
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile);
|
|
|
|
format.setVersion(3, 3);
|
|
|
|
QSurfaceFormat::setDefaultFormat(format);
|
2018-10-04 12:51:01 +00:00
|
|
|
|
2018-03-11 03:18:24 +00:00
|
|
|
// QuantumCD/Qt 5 Dark Fusion Palette
|
|
|
|
// https://gist.github.com/QuantumCD/6245215
|
|
|
|
qApp->setStyle(QStyleFactory::create("Fusion"));
|
|
|
|
QPalette darkPalette;
|
2018-04-09 03:39:04 +00:00
|
|
|
darkPalette.setColor(QPalette::Window, Theme::black);
|
|
|
|
darkPalette.setColor(QPalette::WindowText, Theme::white);
|
2018-03-11 03:18:24 +00:00
|
|
|
darkPalette.setColor(QPalette::Base, QColor(25,25,25));
|
|
|
|
darkPalette.setColor(QPalette::AlternateBase, QColor(53,53,53));
|
2019-01-07 13:03:42 +00:00
|
|
|
//darkPalette.setColor(QPalette::ToolTipBase, Theme::white);
|
|
|
|
//darkPalette.setColor(QPalette::ToolTipText, Theme::white);
|
2018-04-09 03:39:04 +00:00
|
|
|
darkPalette.setColor(QPalette::Text, Theme::white);
|
2018-04-09 14:24:30 +00:00
|
|
|
darkPalette.setColor(QPalette::Disabled, QPalette::Text, Theme::black);
|
2018-03-11 03:18:24 +00:00
|
|
|
darkPalette.setColor(QPalette::Button, QColor(53,53,53));
|
2018-04-09 03:39:04 +00:00
|
|
|
darkPalette.setColor(QPalette::ButtonText, Theme::white);
|
|
|
|
darkPalette.setColor(QPalette::BrightText, Theme::red);
|
2018-03-11 03:18:24 +00:00
|
|
|
darkPalette.setColor(QPalette::Link, QColor(42, 130, 218));
|
2018-09-06 15:04:59 +00:00
|
|
|
darkPalette.setColor(QPalette::Highlight, Theme::red);
|
2019-11-07 12:08:47 +00:00
|
|
|
darkPalette.setColor(QPalette::HighlightedText, Theme::black);
|
2018-03-11 03:18:24 +00:00
|
|
|
qApp->setPalette(darkPalette);
|
2019-01-07 13:03:42 +00:00
|
|
|
//qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: #fc6621; border: 1px solid white; }");
|
2018-03-11 03:18:24 +00:00
|
|
|
|
2018-04-26 02:23:22 +00:00
|
|
|
QCoreApplication::setApplicationName(APP_NAME);
|
2019-03-17 06:23:39 +00:00
|
|
|
QCoreApplication::setOrganizationName(APP_COMPANY);
|
|
|
|
QCoreApplication::setOrganizationDomain(APP_HOMEPAGE_URL);
|
2018-03-13 12:49:24 +00:00
|
|
|
|
2018-03-20 03:31:05 +00:00
|
|
|
QFont font;
|
|
|
|
font.setWeight(QFont::Light);
|
2018-12-01 22:54:04 +00:00
|
|
|
//font.setPixelSize(11);
|
2018-03-26 12:41:46 +00:00
|
|
|
font.setBold(false);
|
2018-03-20 03:31:05 +00:00
|
|
|
QApplication::setFont(font);
|
2018-03-18 08:46:53 +00:00
|
|
|
|
2018-12-02 12:32:34 +00:00
|
|
|
Theme::initAwsomeBaseSizes();
|
|
|
|
|
2019-07-23 10:13:58 +00:00
|
|
|
DocumentWindow *firstWindow = DocumentWindow::createDocumentWindow();
|
2018-04-10 07:59:20 +00:00
|
|
|
|
2019-06-28 13:03:49 +00:00
|
|
|
qDebug() << "Language:" << QLocale().name();
|
|
|
|
|
2019-07-23 10:13:58 +00:00
|
|
|
QStringList openFileList;
|
|
|
|
QStringList waitingExportList;
|
2019-03-22 14:33:17 +00:00
|
|
|
for (int i = 1; i < argc; ++i) {
|
2019-07-23 10:13:58 +00:00
|
|
|
if ('-' == argv[i][0]) {
|
|
|
|
if (0 == strcmp(argv[i], "-output") ||
|
|
|
|
0 == strcmp(argv[i], "-o")) {
|
|
|
|
++i;
|
|
|
|
if (i < argc)
|
|
|
|
waitingExportList.append(argv[i]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
qDebug() << "Unknown option:" << argv[i];
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
QString arg = argv[i];
|
|
|
|
if (arg.endsWith(".ds3")) {
|
|
|
|
openFileList.append(arg);
|
|
|
|
continue;
|
2019-03-22 14:33:17 +00:00
|
|
|
}
|
|
|
|
}
|
2019-03-17 06:23:39 +00:00
|
|
|
|
2019-07-23 10:13:58 +00:00
|
|
|
int finishedExportFileNum = 0;
|
|
|
|
int totalExportFileNum = 0;
|
|
|
|
int succeedExportNum = 0;
|
|
|
|
if (!openFileList.empty()) {
|
|
|
|
std::vector<DocumentWindow *> windowList = {firstWindow};
|
|
|
|
for (int i = 1; i < openFileList.size(); ++i) {
|
|
|
|
windowList.push_back(DocumentWindow::createDocumentWindow());
|
|
|
|
}
|
|
|
|
if (!waitingExportList.empty() &&
|
|
|
|
openFileList.size() == 1) {
|
|
|
|
totalExportFileNum = openFileList.size() * waitingExportList.size();
|
|
|
|
for (int i = 0; i < openFileList.size(); ++i) {
|
|
|
|
QObject::connect(windowList[i], &DocumentWindow::waitingExportFinished, &app, [&](const QString &filename, bool succeed) {
|
|
|
|
qDebug() << "Export to" << filename << (succeed ? "succeed" : "failed");
|
|
|
|
++finishedExportFileNum;
|
|
|
|
if (succeed)
|
|
|
|
++succeedExportNum;
|
|
|
|
if (finishedExportFileNum == totalExportFileNum) {
|
|
|
|
if (succeedExportNum == totalExportFileNum) {
|
|
|
|
app.exit();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
app.exit(1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
for (int i = 0; i < openFileList.size(); ++i) {
|
|
|
|
QObject::connect(windowList[i]->document(), &Document::exportReady, windowList[i], &DocumentWindow::checkExportWaitingList);
|
|
|
|
windowList[i]->setExportWaitingList(waitingExportList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int i = 0; i < openFileList.size(); ++i) {
|
|
|
|
windowList[i]->openPathAs(openFileList[i], openFileList[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-10 06:57:14 +00:00
|
|
|
return app.exec();
|
|
|
|
}
|