0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-27 18:08:10 +03:00
LimeReport/designer/main.cpp

55 lines
2.0 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;
QTranslator limeReportTranslator;
2019-01-26 23:45:20 +03:00
QTranslator qtBaseTranslator;
QTranslator qtDesignerTranslator;
QTranslator qtLinguistTranslator;
QString translationPath = QApplication::applicationDirPath();
2019-01-26 23:45:20 +03:00
translationPath.append("/translations");
2018-05-24 02:25:26 +03:00
Qt::LayoutDirection layoutDirection = QLocale::system().textDirection();
QString designerTranslation = QLocale(manager.getCurrentDefaultLanguage()).name();
2018-05-22 00:24:38 +03:00
if (limeReportTranslator.load("limereport_"+designerTranslation, translationPath)){
2019-01-26 23:45:20 +03:00
qtBaseTranslator.load("qtbase_" + designerTranslation, translationPath);
qtDesignerTranslator.load("designer_"+designerTranslation,translationPath);
a.installTranslator(&qtBaseTranslator);
a.installTranslator(&qtDesignerTranslator);
2018-05-22 00:24:38 +03:00
a.installTranslator(&limeReportTranslator);
2019-01-26 23:45:20 +03:00
2018-05-22 00:24:38 +03:00
Qt::LayoutDirection layoutDirection = QLocale(manager.getCurrentDefaultLanguage()).textDirection();
a.setLayoutDirection(layoutDirection);
}
2018-05-24 02:25:26 +03:00
LimeReport::ReportEngine report;
report.setPreviewLayoutDirection(layoutDirection);
if (a.arguments().count()>1){
report.loadFromFile(a.arguments().at(1));
}
QObject::connect(&report, SIGNAL(getAvailableDesignerLanguages(QList<QLocale::Language>*)),
2019-06-11 21:28:58 +03:00
&manager, SLOT(getAvailableLanguages(QList<QLocale::Language>*)));
QObject::connect(&report, SIGNAL(getCurrentDefaultDesignerLanguage()),
&manager, SLOT(getCurrentDefaultLanguage()));
QObject::connect(&report, SIGNAL(currentDefaultDesignerLanguageChanged(QLocale::Language)),
2019-06-11 21:28:58 +03:00
&manager, SLOT(currentDefaultLanguageChanged(QLocale::Language)));
report.setShowDesignerModal(false);
report.designReport();
return a.exec();
}