-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
55 lines (54 loc) · 1.87 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
#include "viewer_mainwin.h"
#include <QApplication>
#include <QTranslator>
#include <QLibraryInfo>
#include <QTextStream>
#include <QCommandLineParser>
#include <QCommandLineOption>
#include <QDebug>
#include <QFileInfo>
QString const extern APP_NAME=QObject::tr("Cute Light Text Previewer");
QString const extern VERSION="2.2";
QString const extern ORG_NAME="EnjoySoftware";
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTranslator qtTranslator;
qtTranslator.load("qt_" + QLocale::system().name(),QLibraryInfo::location(QLibraryInfo::TranslationsPath));
QTranslator translator;
translator.load("text-previewer_" + QLocale::system().name(), ":/translations");
a.installTranslator(&translator);
a.installTranslator(&qtTranslator);
QCoreApplication::setApplicationName(APP_NAME);
QCoreApplication::setApplicationVersion(VERSION);
QCoreApplication::setOrganizationName(ORG_NAME);
QCommandLineParser parser;
parser.addHelpOption();
parser.addVersionOption();
parser.setApplicationDescription(QObject::tr("This application loads, and translates file."));
parser.addPositionalArgument(QObject::tr("file"),QObject::tr("The file to open."));
parser.process(a);
viewer_mainwin w;
if(!parser.positionalArguments().isEmpty()){
qDebug() << "Load:" << parser.positionalArguments().first();
w.fileOpen(parser.positionalArguments().first());
}
#ifdef WITH_DARKSTYLE
QFile stylefile(":/QDarkStyleSheet/qdarkstyle/style.qss");
if (!stylefile.exists())
{
qDebug() << w.tr("Unable to set stylesheet, file not found\n");
}
else
{
if(stylefile.open(QFile::ReadOnly | QFile::Text)){
QTextStream ts(&stylefile);
a.setStyleSheet(ts.readAll());
}else{
qDebug() << w.tr("Unable to set stylesheet:\n%1").arg(stylefile.errorString());
}
}
#endif
w.show();
return a.exec();
}