LimeReport/designer/main.cpp

50 lines
1.6 KiB
C++
Raw Normal View History

#include <QApplication>
#include <LimeReport>
#include <QTranslator>
#include <QDebug>
#include "designersettingmanager.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
DesignerSettingManager manager;
2018-05-22 00:24:38 +03:00
LimeReport::ReportEngine report;
QTranslator limeReportTranslator;
2018-05-22 00:24:38 +03:00
QTranslator qtTranslator;
QString translationPath = QApplication::applicationDirPath();
translationPath.append("/languages");
QString designerTranslation = QLocale(manager.getCurrentDefaultLanguage()).name();
2018-05-22 00:24:38 +03:00
if (limeReportTranslator.load("limereport_"+designerTranslation, translationPath)){
2018-05-22 00:24:38 +03:00
qtTranslator.load("qt_" + designerTranslation, translationPath);
a.installTranslator(&qtTranslator);
a.installTranslator(&limeReportTranslator);
2018-05-22 00:24:38 +03:00
Qt::LayoutDirection layoutDirection = QLocale(manager.getCurrentDefaultLanguage()).textDirection();
a.setLayoutDirection(layoutDirection);
report.setPreviewLayoutDirection(layoutDirection);
}
if (a.arguments().count()>1){
report.loadFromFile(a.arguments().at(1));
}
QObject::connect(&report, SIGNAL(getAviableLanguages(QList<QLocale::Language>*)),
&manager, SLOT(getAviableLanguages(QList<QLocale::Language>*)));
QObject::connect(&report, SIGNAL(getCurrentDefaultLanguage()),
&manager, SLOT(getCurrentDefaultLanguage()));
QObject::connect(&report, SIGNAL(currentDefaulLanguageChanged(QLocale::Language)),
&manager, SLOT(currentDefaulLanguageChanged(QLocale::Language)));
report.designReport();
return a.exec();
}