-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.cpp
executable file
·62 lines (55 loc) · 2.29 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "datatex.h"
#include <QApplication>
#include <QCoreApplication>
#include <QSplashScreen>
#include <QTranslator>
#include <QSettings>
#include <qtsingleapplication/qtsingleapplication.h>
#include <QLocalSocket>
#include <QLocalServer>
#include <QtCore>
int main(int argc, char *argv[])
{
QSettings::setDefaultFormat(QSettings::IniFormat);
QApplication::setOrganizationName("CSMathematics");
QApplication::setApplicationName("DataTex");
QtSingleApplication a(argc, argv);
QPixmap pixmap("/home/spyros/Πληροφορική/Qt_Projects/DataTex/Git Ignore Folder/Icons/splash_dark.png");
QSplashScreen splash(pixmap, Qt::WindowStaysOnTopHint);
if(!a.isRunning()){
splash.show();
QTimer::singleShot(4000, &splash, &QWidget::close);
Qt::Alignment topRight = Qt::AlignRight | Qt::AlignTop;
splash.showMessage(QObject::tr("loading modules..."), topRight, Qt::black);
splash.showMessage(QObject::tr("Establishing Connections..."), topRight, Qt::black);
}
QSettings settings;
QString theme = settings.value("Application_Settings/Theme").toString();
QString language = settings.value("Application_Settings/Language").toString();
bool isThemeDark = settings.value("Application_Settings/IsThemeDark").toBool();
QIcon::setThemeName( "datatex" );
QString IconPath = (isThemeDark) ? ":images/Dark_Theme/" : ":images/Light_Theme/";
QIcon::setFallbackSearchPaths(QIcon::fallbackSearchPaths() << IconPath << ":images/ToolBar_Icons/");
QFile styleFile(":/qdarkstyle/"+theme+"/"+theme+".qss");
if(styleFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
a.setStyleSheet(styleFile.readAll());
styleFile.close();
}
QTranslator translator;
translator.load(":/languages/DataTex_"+language+".qm");
QApplication::installTranslator(&translator);
DataTex *w = new DataTex(nullptr);
QObject::connect(&a, SIGNAL(messageReceived(QString)),
w, SLOT(onOtherInstanceMessage(QString)));
if(a.isRunning()){
a.sendMessage(QApplication::arguments().last());
return 0;
}
w->initialize(QApplication::arguments().last());
// w->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
w->show();
// splash->finish(w);
// delete splash;
return a.exec();
}