0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-24 00:33:02 +03:00
LimeReport/designer/main.cpp
Андрей Лухнов 0fca7169d3 Define code style and format all source file using clang-format-14
except those placed in 3rdparty directories.
2024-09-19 21:09:38 +03:00

59 lines
2.0 KiB
C++

#include "designersettingmanager.h"
#include <QApplication>
#include <QDebug>
#include <QTranslator>
#include <LimeReport>
int main(int argc, char* argv[])
{
QApplication a(argc, argv);
DesignerSettingManager manager;
QTranslator limeReportTranslator;
QTranslator qtBaseTranslator;
QTranslator qtDesignerTranslator;
QTranslator qtLinguistTranslator;
QString translationPath = QApplication::applicationDirPath();
translationPath.append("/translations");
Qt::LayoutDirection layoutDirection = QLocale::system().textDirection();
QString designerTranslation = QLocale(manager.getCurrentDefaultLanguage()).name();
if (limeReportTranslator.load("limereport_" + designerTranslation, translationPath)) {
static_cast<void>(qtBaseTranslator.load("qtbase_" + designerTranslation, translationPath));
static_cast<void>(
qtDesignerTranslator.load("designer_" + designerTranslation, translationPath));
a.installTranslator(&qtBaseTranslator);
a.installTranslator(&qtDesignerTranslator);
a.installTranslator(&limeReportTranslator);
Qt::LayoutDirection layoutDirection
= QLocale(manager.getCurrentDefaultLanguage()).textDirection();
a.setLayoutDirection(layoutDirection);
}
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>*)),
&manager, SLOT(getAvailableLanguages(QList<QLocale::Language>*)));
QObject::connect(&report, SIGNAL(getCurrentDefaultDesignerLanguage()), &manager,
SLOT(getCurrentDefaultLanguage()));
QObject::connect(&report, SIGNAL(currentDefaultDesignerLanguageChanged(QLocale::Language)),
&manager, SLOT(currentDefaultLanguageChanged(QLocale::Language)));
report.setShowDesignerModal(false);
report.designReport();
return a.exec();
}