mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2025-01-11 12:28:09 +03:00
Finish Interface_lang
This commit is contained in:
commit
fa4f18f3c6
@ -952,6 +952,7 @@ QDockWidget {
|
||||
QDockWidget::title{
|
||||
background: #383838;
|
||||
padding-left: 5px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
|
||||
|
@ -8,7 +8,8 @@ contains(CONFIG,release) {
|
||||
}
|
||||
TEMPLATE = app
|
||||
|
||||
SOURCES += main.cpp
|
||||
SOURCES += main.cpp \
|
||||
designersettingmanager.cpp
|
||||
|
||||
INCLUDEPATH += $$PWD/../include
|
||||
DEPENDPATH += $$PWD/../include
|
||||
@ -61,3 +62,6 @@ win32 {
|
||||
}
|
||||
}
|
||||
|
||||
HEADERS += \
|
||||
designersettingmanager.h
|
||||
|
||||
|
37
designer/designersettingmanager.cpp
Normal file
37
designer/designersettingmanager.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include "designersettingmanager.h"
|
||||
|
||||
DesignerSettingManager::DesignerSettingManager(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_setting = new QSettings("LimeReport",QCoreApplication::applicationName());
|
||||
}
|
||||
|
||||
DesignerSettingManager::~DesignerSettingManager()
|
||||
{
|
||||
delete m_setting;
|
||||
}
|
||||
|
||||
void DesignerSettingManager::getAviableLanguages(QList<QLocale::Language>* languages)
|
||||
{
|
||||
languages->append(QLocale::Russian);
|
||||
languages->append(QLocale::English);
|
||||
languages->append(QLocale::Arabic);
|
||||
}
|
||||
|
||||
QLocale::Language DesignerSettingManager::getCurrentDefaultLanguage()
|
||||
{
|
||||
m_setting->beginGroup("ReportDesigner");
|
||||
QVariant v = m_setting->value("DesignerLanguage");
|
||||
m_setting->endGroup();
|
||||
if (v.isValid()){
|
||||
return static_cast<QLocale::Language>(v.toInt()) ;
|
||||
} else {
|
||||
return QLocale::system().language();
|
||||
}
|
||||
}
|
||||
|
||||
void DesignerSettingManager::currentDefaulLanguageChanged(QLocale::Language language)
|
||||
{
|
||||
m_setting->beginGroup("ReportDesigner");
|
||||
m_setting->setValue("DesignerLanguage", (int)language);
|
||||
m_setting->endGroup();
|
||||
}
|
27
designer/designersettingmanager.h
Normal file
27
designer/designersettingmanager.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef DESIGNERSETTINGMANAGER_H
|
||||
#define DESIGNERSETTINGMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QLocale>
|
||||
#include <QApplication>
|
||||
#include <QSettings>
|
||||
|
||||
class DesignerSettingManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DesignerSettingManager(QObject *parent = 0);
|
||||
~DesignerSettingManager();
|
||||
void setApplicationInstance(QApplication* application);
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void getAviableLanguages(QList<QLocale::Language>* languages);
|
||||
QLocale::Language getCurrentDefaultLanguage();
|
||||
void currentDefaulLanguageChanged(QLocale::Language language);
|
||||
private:
|
||||
QApplication* m_app;
|
||||
QSettings* m_setting;
|
||||
};
|
||||
|
||||
#endif // DESIGNERSETTINGMANAGER_H
|
@ -1,25 +1,46 @@
|
||||
#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;
|
||||
QString translationPath = QApplication::applicationDirPath();
|
||||
translationPath.append("/languages");
|
||||
limeReportTranslator.load("limereport_"+QLocale::system().name(),translationPath);
|
||||
|
||||
QString designerTranslation = QLocale(manager.getCurrentDefaultLanguage()).name();
|
||||
|
||||
limeReportTranslator.load("limereport_"+designerTranslation, translationPath);
|
||||
a.installTranslator(&limeReportTranslator);
|
||||
|
||||
QTranslator qtTranslator;
|
||||
qtTranslator.load("qt_" + QLocale::system().name(),translationPath);
|
||||
qtTranslator.load("qt_" + designerTranslation, translationPath);
|
||||
a.installTranslator(&qtTranslator);
|
||||
|
||||
Qt::LayoutDirection layoutDirection = QLocale(manager.getCurrentDefaultLanguage()).textDirection();
|
||||
|
||||
LimeReport::ReportEngine report;
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -113,6 +113,8 @@ public:
|
||||
bool setReportLanguage(QLocale::Language language);
|
||||
Qt::LayoutDirection previewLayoutDirection();
|
||||
void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection);
|
||||
QList<QLocale::Language> designerLanguages();
|
||||
QLocale::Language currentDesignerLanguage();
|
||||
signals:
|
||||
void renderStarted();
|
||||
void renderFinished();
|
||||
@ -120,6 +122,9 @@ signals:
|
||||
void onLoad(bool& loaded);
|
||||
void onSave();
|
||||
void saveFinished();
|
||||
void getAviableLanguages(QList<QLocale::Language>* languages);
|
||||
void currentDefaulLanguageChanged(QLocale::Language);
|
||||
QLocale::Language getCurrentDefaultLanguage();
|
||||
public slots:
|
||||
void cancelRender();
|
||||
protected:
|
||||
|
@ -707,6 +707,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();
|
||||
@ -714,6 +715,9 @@ void ReportDesignWidget::editSetting()
|
||||
m_defaultFont = setting.defaultFont();
|
||||
m_useDarkTheme = setting.userDarkTheme();
|
||||
m_report->setSuppressFieldAndVarError(setting.suppressAbsentFieldsAndVarsWarnings());
|
||||
if (m_report->currentDesignerLanguage() != setting.designerLanguage() ){
|
||||
m_report->setCurrentDesignerLanguage(setting.designerLanguage());
|
||||
}
|
||||
applySettings();
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,6 @@ public:
|
||||
QSettings* settings();
|
||||
void restoreSetting();
|
||||
void setShowProgressDialog(bool value){m_showProgressDialog = value;}
|
||||
|
||||
private slots:
|
||||
void slotNewReport();
|
||||
void slotNewPage();
|
||||
|
@ -957,6 +957,27 @@ void ReportEnginePrivate::activateLanguage(QLocale::Language language)
|
||||
}
|
||||
}
|
||||
|
||||
QList<QLocale::Language> ReportEnginePrivate::designerLanguages()
|
||||
{
|
||||
|
||||
QList<QLocale::Language> result;
|
||||
emit getAviableLanguages(&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
QLocale::Language ReportEnginePrivate::currentDesignerLanguage()
|
||||
{
|
||||
QLocale::Language result = emit getCurrentDefaultLanguage();
|
||||
return result;
|
||||
}
|
||||
|
||||
void ReportEnginePrivate::setCurrentDesignerLanguage(QLocale::Language language)
|
||||
{
|
||||
m_currentDesignerLanguage = language;
|
||||
QMessageBox::information(m_designerWindow, tr("Warning") ,tr("The language will change after the application is restarted"));
|
||||
emit currentDefaulLanguageChanged(language);
|
||||
}
|
||||
|
||||
QString ReportEnginePrivate::styleSheet() const
|
||||
{
|
||||
return m_styleSheet;
|
||||
@ -1138,7 +1159,15 @@ ReportEngine::ReportEngine(QObject *parent)
|
||||
connect(d, SIGNAL(onSave()), this, SIGNAL(onSave()));
|
||||
connect(d, SIGNAL(onLoad(bool&)), this, SIGNAL(onLoad(bool&)));
|
||||
connect(d, SIGNAL(saveFinished()), this, SIGNAL(saveFinished()));
|
||||
connect(d, SIGNAL(loaded()), this, SIGNAL(loaded()));
|
||||
connect(d, SIGNAL(loaded()), this, SIGNAL(loaded()));
|
||||
|
||||
connect(d, SIGNAL(getAviableLanguages(QList<QLocale::Language>*)),
|
||||
this, SIGNAL(getAviableLanguages(QList<QLocale::Language>*)));
|
||||
connect(d, SIGNAL(currentDefaulLanguageChanged(QLocale::Language)),
|
||||
this, SIGNAL(currentDefaulLanguageChanged(QLocale::Language)));
|
||||
connect(d, SIGNAL(getCurrentDefaultLanguage()),
|
||||
this, SIGNAL(getCurrentDefaultLanguage()));
|
||||
|
||||
}
|
||||
|
||||
ReportEngine::~ReportEngine()
|
||||
@ -1245,6 +1274,30 @@ bool ReportEngine::setReportLanguage(QLocale::Language language)
|
||||
return d->setReportLanguage(language);
|
||||
}
|
||||
|
||||
Qt::LayoutDirection ReportEngine::previewLayoutDirection()
|
||||
{
|
||||
Q_D(ReportEngine);
|
||||
return d->previewLayoutDirection();
|
||||
}
|
||||
|
||||
void ReportEngine::setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection)
|
||||
{
|
||||
Q_D(ReportEngine);
|
||||
d->setPreviewLayoutDirection(previewLayoutDirection);
|
||||
}
|
||||
|
||||
QList<QLocale::Language> 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);
|
||||
|
@ -113,6 +113,8 @@ public:
|
||||
bool setReportLanguage(QLocale::Language language);
|
||||
Qt::LayoutDirection previewLayoutDirection();
|
||||
void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection);
|
||||
QList<QLocale::Language> designerLanguages();
|
||||
QLocale::Language currentDesignerLanguage();
|
||||
signals:
|
||||
void renderStarted();
|
||||
void renderFinished();
|
||||
@ -120,7 +122,10 @@ signals:
|
||||
void onLoad(bool& loaded);
|
||||
void onSave();
|
||||
void saveFinished();
|
||||
void loaded();
|
||||
void loaded();
|
||||
void getAviableLanguages(QList<QLocale::Language>* languages);
|
||||
void currentDefaulLanguageChanged(QLocale::Language);
|
||||
QLocale::Language getCurrentDefaultLanguage();
|
||||
public slots:
|
||||
void cancelRender();
|
||||
protected:
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
#include <QMainWindow>
|
||||
#include <QLocale>
|
||||
#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<QLocale::Language> 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,9 @@ public:
|
||||
void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection);
|
||||
QString styleSheet() const;
|
||||
void setStyleSheet(const QString &styleSheet);
|
||||
|
||||
QList<QLocale::Language> designerLanguages();
|
||||
QLocale::Language currentDesignerLanguage();
|
||||
void setCurrentDesignerLanguage(QLocale::Language language);
|
||||
signals:
|
||||
void pagesLoadFinished();
|
||||
void datasourceCollectionLoadFinished(const QString& collectionName);
|
||||
@ -189,7 +195,10 @@ signals:
|
||||
void onLoad(bool& loaded);
|
||||
void onSave();
|
||||
void saveFinished();
|
||||
void loaded();
|
||||
void loaded();
|
||||
void getAviableLanguages(QList<QLocale::Language>* languages);
|
||||
void currentDefaulLanguageChanged(QLocale::Language);
|
||||
QLocale::Language getCurrentDefaultLanguage();
|
||||
public slots:
|
||||
bool slotLoadFromFile(const QString& fileName);
|
||||
void cancelRender();
|
||||
@ -248,6 +257,7 @@ private:
|
||||
Qt::LayoutDirection m_previewLayoutDirection;
|
||||
LimeReportPluginInterface* m_designerFactory;
|
||||
QString m_styleSheet;
|
||||
QLocale::Language m_currentDesignerLanguage;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -47,6 +47,15 @@ bool SettingDialog::suppressAbsentFieldsAndVarsWarnings()
|
||||
return ui->cbSuppressWarnings->isChecked();
|
||||
}
|
||||
|
||||
QLocale::Language SettingDialog::designerLanguage()
|
||||
{
|
||||
foreach (QLocale::Language language, m_aviableLanguages) {
|
||||
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,22 @@ void SettingDialog::setUseDarkTheme(bool value)
|
||||
ui->cbbUseDarkTheme->setChecked(value);
|
||||
}
|
||||
|
||||
void SettingDialog::setDesignerLanguages(QList<QLocale::Language> languages, QLocale::Language currentLanguage)
|
||||
{
|
||||
m_aviableLanguages = languages;
|
||||
m_currentLanguage = currentLanguage;
|
||||
|
||||
if (languages.isEmpty()) {
|
||||
ui->designerLanguage->setVisible(false);
|
||||
ui->lblLanguage->setVisible(false);
|
||||
return;
|
||||
}
|
||||
ui->designerLanguage->addItem(QLocale::languageToString(currentLanguage));
|
||||
foreach (QLocale::Language language, languages) {
|
||||
if (language != currentLanguage)
|
||||
ui->designerLanguage->addItem(QLocale::languageToString(language));
|
||||
}
|
||||
ui->designerLanguage->setCurrentText(QLocale::languageToString(currentLanguage));
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define LRSETTINGDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QLocale>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
@ -21,13 +22,17 @@ 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<QLocale::Language> languages, QLocale::Language currentLanguage);
|
||||
private:
|
||||
Ui::SettingDialog *ui;
|
||||
QList<QLocale::Language> m_aviableLanguages;
|
||||
QLocale::Language m_currentLanguage;
|
||||
};
|
||||
} // namespace LimeReport
|
||||
|
||||
|
@ -6,10 +6,16 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>351</width>
|
||||
<height>318</height>
|
||||
<width>397</width>
|
||||
<height>378</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Designer setting</string>
|
||||
</property>
|
||||
@ -108,6 +114,27 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="hlLanguage">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblLanguage">
|
||||
<property name="text">
|
||||
<string>Language</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="designerLanguage">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbbUseDarkTheme">
|
||||
<property name="text">
|
||||
|
Loading…
Reference in New Issue
Block a user