68 lines
2.0 KiB
C++
68 lines
2.0 KiB
C++
#include "mainwindow.h"
|
|
|
|
#include <QApplication>
|
|
#include <QLocale>
|
|
#include <QTranslator>
|
|
#include <QSplashScreen>
|
|
#include <QTimer>
|
|
#include <QScreen>
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
QApplication a(argc, argv);
|
|
|
|
QCoreApplication::setOrganizationName("RedLine Solutions, LLC.");
|
|
QCoreApplication::setOrganizationDomain("redline.com");
|
|
QCoreApplication::setApplicationName("Sanguine Studio");
|
|
QCoreApplication::setApplicationVersion("1.0.2");
|
|
|
|
// Create splashscreen to show before main GUI
|
|
QPixmap splashImage(":/images/splashscreen");
|
|
splashImage = splashImage.scaledToHeight(500, Qt::SmoothTransformation);
|
|
QSplashScreen splashScreen(splashImage);
|
|
|
|
// Get the active screen to show splashscreen on
|
|
QScreen* activeScreen = a.screenAt(QCursor::pos());
|
|
if (!activeScreen)
|
|
{
|
|
activeScreen = a.primaryScreen();
|
|
}
|
|
|
|
// Calculate where in global coords the splash needs to be
|
|
const QRect availGeom = activeScreen->availableGeometry();
|
|
const QSize splashSize = splashScreen.size();
|
|
|
|
const QPoint topLeft(availGeom.x() + (availGeom.width() - splashSize.width()) / 2,
|
|
availGeom.y() + (availGeom.height() - splashSize.height()) / 2);
|
|
|
|
splashScreen.move(topLeft);
|
|
splashScreen.show();
|
|
|
|
// Show the splashscren for 3 seconds before disappearing
|
|
QTimer splashTimer;
|
|
QEventLoop splashLoop;
|
|
QObject::connect(&splashTimer, &QTimer::timeout, &splashLoop, &QEventLoop::quit);
|
|
|
|
splashTimer.start(3000);
|
|
splashLoop.exec();
|
|
|
|
// Hide splash and show main GUI
|
|
a.processEvents();
|
|
splashScreen.hide();
|
|
|
|
// Translate (only english for now)
|
|
QTranslator translator;
|
|
const QStringList uiLanguages = QLocale::system().uiLanguages();
|
|
for (const QString &locale : uiLanguages) {
|
|
const QString baseName = "Sanquine_Studio_" + QLocale(locale).name();
|
|
if (translator.load(":/i18n/" + baseName)) {
|
|
a.installTranslator(&translator);
|
|
break;
|
|
}
|
|
}
|
|
|
|
MainWindow w;
|
|
w.show();
|
|
return a.exec();
|
|
}
|