diff --git a/include/lrreportengine.h b/include/lrreportengine.h index 589e359..97549f5 100644 --- a/include/lrreportengine.h +++ b/include/lrreportengine.h @@ -113,6 +113,10 @@ public: bool setReportLanguage(QLocale::Language language); Qt::LayoutDirection previewLayoutDirection(); void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection); + void addDesignerLanguage(QLocale::Language language); + void removeDesignerLanguage(QLocale::Language language); + QList* designerLanguages(); + QLocale::Language currentDesignerLanguage(); signals: void renderStarted(); void renderFinished(); diff --git a/limereport/lrreportdesignwidget.cpp b/limereport/lrreportdesignwidget.cpp index 2da64da..9fc328d 100644 --- a/limereport/lrreportdesignwidget.cpp +++ b/limereport/lrreportdesignwidget.cpp @@ -712,6 +712,7 @@ void ReportDesignWidget::editSetting() setting.setDefaultFont(m_defaultFont); setting.setSuppressAbsentFieldsAndVarsWarnings(m_report->suppressFieldAndVarError()); setting.setUseDarkTheme(m_useDarkTheme); + setting.setDesignerLanguages(m_report->designerLanguages(), m_report->currentDesignerLanguage()); if (setting.exec()){ m_horizontalGridStep = setting.horizontalGridStep(); @@ -719,6 +720,7 @@ void ReportDesignWidget::editSetting() m_defaultFont = setting.defaultFont(); m_useDarkTheme = setting.userDarkTheme(); m_report->setSuppressFieldAndVarError(setting.suppressAbsentFieldsAndVarsWarnings()); + m_report->setCurrentDesignerLanguage(setting.designerLanguage()); applySettings(); } } diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index d938b2e..0c8d92f 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -950,6 +950,42 @@ void ReportEnginePrivate::activateLanguage(QLocale::Language language) } } +QString ReportEnginePrivate::getLanguagesDir() const +{ + return m_languagesDir; +} + +void ReportEnginePrivate::setLanguagesDir(const QString& languagesDir) +{ + m_languagesDir = languagesDir; +} + +void ReportEnginePrivate::addDesignerLanguage(QLocale::Language language) +{ + if (!m_designerLanguages.contains(language)) + m_designerLanguages.append(language); +} + +void ReportEnginePrivate::removeDesignerLanguage(QLocale::Language language) +{ + m_designerLanguages.removeAll(language); +} + +QList* ReportEnginePrivate::designerLanguages() +{ + return &m_designerLanguages; +} + +QLocale::Language ReportEnginePrivate::currentDesignerLanguage() +{ + return m_currentDesignerLanguage; +} + +void ReportEnginePrivate::setCurrentDesignerLanguage(QLocale::Language language) +{ + m_currentDesignerLanguage = language; +} + QString ReportEnginePrivate::styleSheet() const { return m_styleSheet; @@ -1237,6 +1273,30 @@ bool ReportEngine::setReportLanguage(QLocale::Language language) return d->setReportLanguage(language); } +void ReportEngine::addDesignerLanguage(QLocale::Language language) +{ + Q_D(ReportEngine); + d->addDesignerLanguage(language); +} + +void ReportEngine::removeDesignerLanguage(QLocale::Language language) +{ + Q_D(ReportEngine); + d->removeDesignerLanguage(language); +} + +QList*ReportEngine::designerLanguages() +{ + Q_D(ReportEngine); + return d->designerLanguages(); +} + +QLocale::Language ReportEngine::currentDesignerLanguage() +{ + Q_D(ReportEngine); + return d->currentDesignerLanguage(); +} + void ReportEngine::setShowProgressDialog(bool value) { Q_D(ReportEngine); diff --git a/limereport/lrreportengine.h b/limereport/lrreportengine.h index 589e359..97549f5 100644 --- a/limereport/lrreportengine.h +++ b/limereport/lrreportengine.h @@ -113,6 +113,10 @@ public: bool setReportLanguage(QLocale::Language language); Qt::LayoutDirection previewLayoutDirection(); void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection); + void addDesignerLanguage(QLocale::Language language); + void removeDesignerLanguage(QLocale::Language language); + QList* designerLanguages(); + QLocale::Language currentDesignerLanguage(); signals: void renderStarted(); void renderFinished(); diff --git a/limereport/lrreportengine_p.h b/limereport/lrreportengine_p.h index 95ed764..eb4f611 100644 --- a/limereport/lrreportengine_p.h +++ b/limereport/lrreportengine_p.h @@ -33,6 +33,7 @@ #include #include #include +#include #include "lrreportengine.h" #include "lrcollection.h" #include "lrglobal.h" @@ -83,6 +84,9 @@ public: virtual void setSuppressFieldAndVarError(bool suppressFieldAndVarError) = 0; virtual void setStyleSheet(const QString& styleSheet) = 0; virtual QString styleSheet() const = 0; + virtual QList* designerLanguages() = 0; + virtual QLocale::Language currentDesignerLanguage() = 0; + virtual void setCurrentDesignerLanguage(QLocale::Language language) = 0; }; class ReportEnginePrivate : public QObject, public ICollectionContainer, public ITranslationContainer, @@ -178,7 +182,13 @@ public: void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection); QString styleSheet() const; void setStyleSheet(const QString &styleSheet); - + QString getLanguagesDir() const; + void setLanguagesDir(const QString& languagesDir); + void addDesignerLanguage(QLocale::Language language); + void removeDesignerLanguage(QLocale::Language language); + QList* designerLanguages(); + QLocale::Language currentDesignerLanguage(); + void setCurrentDesignerLanguage(QLocale::Language language); signals: void pagesLoadFinished(); void datasourceCollectionLoadFinished(const QString& collectionName); @@ -247,6 +257,9 @@ private: Qt::LayoutDirection m_previewLayoutDirection; LimeReportPluginInterface* m_designerFactory; QString m_styleSheet; + QString m_languagesDir; + QList m_designerLanguages; + QLocale::Language m_currentDesignerLanguage; }; } diff --git a/limereport/lrsettingdialog.cpp b/limereport/lrsettingdialog.cpp index ee34440..c1272f1 100644 --- a/limereport/lrsettingdialog.cpp +++ b/limereport/lrsettingdialog.cpp @@ -47,6 +47,15 @@ bool SettingDialog::suppressAbsentFieldsAndVarsWarnings() return ui->cbSuppressWarnings->isChecked(); } +QLocale::Language SettingDialog::designerLanguage() +{ + foreach (QLocale::Language language, *m_designerLanguages) { + if (ui->designerLanguage->currentText().compare(QLocale::languageToString(language)) == 0) + return language; + } + return QLocale().language(); +} + void SettingDialog::setSuppressAbsentFieldsAndVarsWarnings(bool value){ ui->cbSuppressWarnings->setChecked(value); } @@ -72,4 +81,14 @@ void SettingDialog::setUseDarkTheme(bool value) ui->cbbUseDarkTheme->setChecked(value); } +void SettingDialog::setDesignerLanguages(QList* languages, QLocale::Language currentLanguage) +{ + m_designerLanguages = languages; + ui->designerLanguage->addItem(QLocale::languageToString(currentLanguage)); + foreach (QLocale::Language language, *languages) { + if (language != currentLanguage) + ui->designerLanguage->addItem(QLocale::languageToString(language)); + } +} + } // namespace LimeReport diff --git a/limereport/lrsettingdialog.h b/limereport/lrsettingdialog.h index db908f9..20bbb0b 100644 --- a/limereport/lrsettingdialog.h +++ b/limereport/lrsettingdialog.h @@ -2,6 +2,7 @@ #define LRSETTINGDIALOG_H #include +#include namespace LimeReport{ @@ -21,13 +22,16 @@ public: QFont defaultFont(); bool userDarkTheme(); bool suppressAbsentFieldsAndVarsWarnings(); + QLocale::Language designerLanguage(); void setSuppressAbsentFieldsAndVarsWarnings(bool value); void setHorizontalGridStep(int value); void setVerticalGridStep(int value); void setDefaultFont(const QFont& value); void setUseDarkTheme(bool value); + void setDesignerLanguages(QList* languages, QLocale::Language currentLanguage); private: Ui::SettingDialog *ui; + QList* m_designerLanguages; }; } // namespace LimeReport diff --git a/limereport/lrsettingdialog.ui b/limereport/lrsettingdialog.ui index b0dd1ed..688ad14 100644 --- a/limereport/lrsettingdialog.ui +++ b/limereport/lrsettingdialog.ui @@ -6,10 +6,16 @@ 0 0 - 351 - 318 + 397 + 378 + + + 0 + 0 + + Designer setting @@ -108,6 +114,27 @@ + + + + + + Language + + + + + + + + 0 + 0 + + + + + +