36 lines
1.2 KiB
C++
36 lines
1.2 KiB
C++
#include "ui/MainWindow.hpp"
|
|
|
|
#include <QApplication>
|
|
#include <QCoreApplication>
|
|
#include <QPixmap>
|
|
#include <QTimer>
|
|
|
|
int main(int argc, char** argv) {
|
|
QApplication application(argc, argv);
|
|
QCoreApplication::setApplicationName("DateToSpine");
|
|
QCoreApplication::setOrganizationName("DateToSpine");
|
|
|
|
dts::MainWindow window;
|
|
window.show();
|
|
const auto arguments = application.arguments();
|
|
for (int index = 1; index < arguments.size(); ++index) {
|
|
if (arguments[index] == "--screenshot") {
|
|
++index;
|
|
} else if (!arguments[index].startsWith('-')) {
|
|
window.openResourcePath(arguments[index]);
|
|
}
|
|
}
|
|
const int screenshotOption = arguments.indexOf("--screenshot");
|
|
if (screenshotOption >= 0 && screenshotOption + 1 < arguments.size()) {
|
|
const auto screenshotPath = arguments[screenshotOption + 1];
|
|
QTimer::singleShot(250, &application, [&application, &window, screenshotPath] {
|
|
window.grab().save(screenshotPath);
|
|
application.quit();
|
|
});
|
|
}
|
|
if (application.arguments().contains("--smoke-test")) {
|
|
QTimer::singleShot(100, &application, &QCoreApplication::quit);
|
|
}
|
|
return application.exec();
|
|
}
|