| 1 |
#include <QApplication> |
| 2 |
#include <QTranslator> |
| 3 |
#include <QTime> |
| 4 |
#include <QDir> |
| 5 |
#include <QStandardPaths> |
| 6 |
#include <QLibraryInfo> |
| 7 |
|
| 8 |
#include "config_puzzle.h" |
| 9 |
#include "MainWindow.h" |
| 10 |
|
| 11 |
|
| 12 |
int main(int argc, char *argv[]) { |
| 13 |
QApplication app(argc, argv); |
| 14 |
|
| 15 |
QCoreApplication::setOrganizationName("DanSoft"); |
| 16 |
QCoreApplication::setOrganizationDomain("dansoft.ru"); |
| 17 |
QCoreApplication::setApplicationVersion(PUZZLE_VERSION); |
| 18 |
QCoreApplication::setApplicationName("Puzzle jigsaw"); |
| 19 |
|
| 20 |
// create folder AppConfigLocation |
| 21 |
QDir dirConfig(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)); |
| 22 |
if (dirConfig.exists()==false) dirConfig.mkpath(dirConfig.path()); |
| 23 |
|
| 24 |
|
| 25 |
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) |
| 26 |
// initialization for rnd |
| 27 |
qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); |
| 28 |
#endif |
| 29 |
|
| 30 |
QTranslator translator; |
| 31 |
QString locale = QLocale::system().name(); |
| 32 |
|
| 33 |
translator.load(QString(PATH_USERDATA)+QString("/langs/puzzle-jigsaw_") + locale); |
| 34 |
app.installTranslator(&translator); |
| 35 |
|
| 36 |
//set translator for default widget's text (for example: QMessageBox's buttons) |
| 37 |
QTranslator qtTranslator; |
| 38 |
qtTranslator.load("qt_"+locale,QLibraryInfo::location(QLibraryInfo::TranslationsPath)); |
| 39 |
app.installTranslator(&qtTranslator); |
| 40 |
|
| 41 |
|
| 42 |
MainWindow w; |
| 43 |
w.show(); |
| 44 |
|
| 45 |
return app.exec(); |
| 46 |
} |
| 47 |
|