mirror of
https://github.com/fralx/LimeReport.git
synced 2025-09-23 08:29:07 +03:00
Translation has been finished
This commit is contained in:
26
limereport/translationeditor/languageselectdialog.cpp
Normal file
26
limereport/translationeditor/languageselectdialog.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "languageselectdialog.h"
|
||||
#include "ui_languageselectdialog.h"
|
||||
#include <QLocale>
|
||||
#include <QSet>
|
||||
#include <QDebug>
|
||||
|
||||
LanguageSelectDialog::LanguageSelectDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::LanguageSelectDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
for (int i = 2; i<QLocale::LastLanguage; ++i){
|
||||
ui->comboBox->addItem(QLocale::languageToString(static_cast<QLocale::Language>(i)),static_cast<QLocale::Language>(i));
|
||||
}
|
||||
ui->comboBox->setCurrentText("");
|
||||
}
|
||||
|
||||
LanguageSelectDialog::~LanguageSelectDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QLocale::Language LanguageSelectDialog::getSelectedLanguage()
|
||||
{
|
||||
return ui->comboBox->itemData(ui->comboBox->currentIndex()).value<QLocale::Language>();
|
||||
}
|
23
limereport/translationeditor/languageselectdialog.h
Normal file
23
limereport/translationeditor/languageselectdialog.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef LANGUAGESELECTDIALOG_H
|
||||
#define LANGUAGESELECTDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QLocale>
|
||||
|
||||
namespace Ui {
|
||||
class LanguageSelectDialog;
|
||||
}
|
||||
|
||||
class LanguageSelectDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LanguageSelectDialog(QWidget *parent = 0);
|
||||
~LanguageSelectDialog();
|
||||
QLocale::Language getSelectedLanguage();
|
||||
private:
|
||||
Ui::LanguageSelectDialog *ui;
|
||||
};
|
||||
|
||||
#endif // LANGUAGESELECTDIALOG_H
|
88
limereport/translationeditor/languageselectdialog.ui
Normal file
88
limereport/translationeditor/languageselectdialog.ui
Normal file
@@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LanguageSelectDialog</class>
|
||||
<widget class="QDialog" name="LanguageSelectDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>336</width>
|
||||
<height>109</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Language</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>LanguageSelectDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>LanguageSelectDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@@ -3,12 +3,15 @@
|
||||
#include "lrreportengine.h"
|
||||
#include "lrreportengine_p.h"
|
||||
#include "lrreporttranslation.h"
|
||||
#include "languageselectdialog.h"
|
||||
#include <QShortcut>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
TranslationEditor::TranslationEditor(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::TranslationEditor), m_translationContainer(0)
|
||||
ui(new Ui::TranslationEditor), m_translationContainer(0),
|
||||
m_currentReportTranslation(0), m_currentPageTranslation(0), m_currentPropertyTranslation(0)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->splitter_3->setStretchFactor(1,10);
|
||||
@@ -25,6 +28,7 @@ TranslationEditor::TranslationEditor(QWidget *parent) :
|
||||
ui->tbStrings->setHorizontalHeaderItem(1,new QTableWidgetItem(tr("Report Item")));
|
||||
ui->tbStrings->setHorizontalHeaderItem(2,new QTableWidgetItem(tr("Property")));
|
||||
ui->tbStrings->setHorizontalHeaderItem(3,new QTableWidgetItem(tr("Source text")));
|
||||
new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Return), this, SLOT(slotItemChecked()));
|
||||
//ui->tbStrings->setSortingEnabled(true);
|
||||
|
||||
}
|
||||
@@ -32,6 +36,10 @@ TranslationEditor::TranslationEditor(QWidget *parent) :
|
||||
void TranslationEditor::setReportEngine(ITranslationContainer* translationContainer)
|
||||
{
|
||||
m_translationContainer = translationContainer;
|
||||
m_currentReportTranslation = 0;
|
||||
m_currentPageTranslation = 0;
|
||||
m_currentPropertyTranslation = 0;
|
||||
|
||||
if (m_translationContainer){
|
||||
m_translationContainer->updateTranslations();
|
||||
updateUi();
|
||||
@@ -43,10 +51,22 @@ TranslationEditor::~TranslationEditor()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QLocale::Language TranslationEditor::getLanguageByName(const QString& languageName){
|
||||
foreach(QLocale::Language language, m_translationContainer->translations()->keys()){
|
||||
if (QLocale::languageToString(language).compare(languageName) == 0){
|
||||
return language;
|
||||
}
|
||||
}
|
||||
return QLocale::AnyLanguage;
|
||||
}
|
||||
|
||||
void TranslationEditor::updateUi()
|
||||
{
|
||||
ui->lvLanguages->clear();
|
||||
ui->twPages->clear();
|
||||
ui->tbStrings->clearContents();
|
||||
ui->teTranslation->setPlainText("");
|
||||
ui->cbChecked->setEnabled(false);
|
||||
|
||||
Q_ASSERT(m_translationContainer != 0);
|
||||
if (m_translationContainer){
|
||||
@@ -54,11 +74,12 @@ void TranslationEditor::updateUi()
|
||||
Q_ASSERT(translations != 0);
|
||||
if (translations){
|
||||
foreach(QLocale::Language language, translations->keys()){
|
||||
ui->lvLanguages->addItem(QLocale::languageToString(language));
|
||||
if (language != QLocale::AnyLanguage)
|
||||
ui->lvLanguages->addItem(QLocale::languageToString(language));
|
||||
}
|
||||
if (!translations->keys().isEmpty()){
|
||||
ui->lvLanguages->item(0)->setSelected(true);
|
||||
activateLanguage(translations->keys().at(0));
|
||||
activateLanguage(getLanguageByName(ui->lvLanguages->item(0)->text()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,18 +159,22 @@ void TranslationEditor::activateTranslation(const QString& itemName, const QStri
|
||||
|
||||
void TranslationEditor::on_tbStrings_itemSelectionChanged()
|
||||
{
|
||||
activateTranslation(ui->tbStrings->item(ui->tbStrings->currentRow(),1)->text(), ui->tbStrings->item(ui->tbStrings->currentRow(),2)->text());
|
||||
if (m_currentPageTranslation)
|
||||
activateTranslation(ui->tbStrings->item(ui->tbStrings->currentRow(),1)->text(), ui->tbStrings->item(ui->tbStrings->currentRow(),2)->text());
|
||||
}
|
||||
|
||||
void TranslationEditor::on_teTranslation_textChanged()
|
||||
{
|
||||
m_currentPropertyTranslation->value = ui->teTranslation->toPlainText();
|
||||
if (m_currentPropertyTranslation)
|
||||
m_currentPropertyTranslation->value = ui->teTranslation->toPlainText();
|
||||
}
|
||||
|
||||
void TranslationEditor::on_cbChecked_toggled(bool checked)
|
||||
{
|
||||
m_currentPropertyTranslation->checked = checked;
|
||||
ui->tbStrings->item(ui->tbStrings->currentRow(),0)->setIcon(checked ? QIcon(":/translationeditor/images/checked.png"):QIcon());
|
||||
if (m_currentPropertyTranslation){
|
||||
m_currentPropertyTranslation->checked = checked;
|
||||
ui->tbStrings->item(ui->tbStrings->currentRow(),0)->setIcon(checked ? QIcon(":/translationeditor/images/checked.png"):QIcon());
|
||||
}
|
||||
}
|
||||
|
||||
void TranslationEditor::on_twPages_itemSelectionChanged()
|
||||
@@ -159,7 +184,42 @@ void TranslationEditor::on_twPages_itemSelectionChanged()
|
||||
}
|
||||
}
|
||||
|
||||
void TranslationEditor::on_tbAddLanguage_clicked()
|
||||
{
|
||||
LanguageSelectDialog dialog;
|
||||
if (dialog.exec()){
|
||||
m_translationContainer->addTranslationLanguage(dialog.getSelectedLanguage());
|
||||
updateUi();
|
||||
activateLanguage(dialog.getSelectedLanguage());
|
||||
}
|
||||
}
|
||||
|
||||
void TranslationEditor::on_tbDeleteLanguage_clicked()
|
||||
{
|
||||
m_translationContainer->removeTranslationLanguage(m_currentReportTranslation->language());
|
||||
updateUi();
|
||||
}
|
||||
|
||||
void TranslationEditor::slotItemChecked()
|
||||
{
|
||||
if (ui->tbStrings->currentRow()<ui->tbStrings->rowCount()){
|
||||
ui->cbChecked->setChecked(true);
|
||||
ui->tbStrings->selectRow(ui->tbStrings->currentRow()+1);
|
||||
ui->teTranslation->setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
void TranslationEditor::on_lvLanguages_itemSelectionChanged()
|
||||
{
|
||||
if (ui->lvLanguages->currentItem() && m_currentReportTranslation){
|
||||
activateLanguage(getLanguageByName(ui->lvLanguages->currentItem()->text()));
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace LimeReport
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -29,7 +29,14 @@ private slots:
|
||||
void on_tbStrings_itemSelectionChanged();
|
||||
void on_teTranslation_textChanged();
|
||||
void on_cbChecked_toggled(bool checked);
|
||||
void on_twPages_itemSelectionChanged();
|
||||
void on_twPages_itemSelectionChanged();
|
||||
void on_tbAddLanguage_clicked();
|
||||
void on_tbDeleteLanguage_clicked();
|
||||
void slotItemChecked();
|
||||
void on_lvLanguages_itemSelectionChanged();
|
||||
|
||||
private:
|
||||
QLocale::Language getLanguageByName(const QString& languageName);
|
||||
private:
|
||||
Ui::TranslationEditor *ui;
|
||||
ITranslationContainer* m_translationContainer;
|
||||
|
@@ -56,7 +56,7 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton">
|
||||
<widget class="QToolButton" name="tbAddLanguage">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
@@ -64,10 +64,13 @@
|
||||
<iconset resource="translationeditor.qrc">
|
||||
<normaloff>:/translationeditor/images/add.png</normaloff>:/translationeditor/images/add.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_2">
|
||||
<widget class="QToolButton" name="tbDeleteLanguage">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
@@ -75,6 +78,9 @@
|
||||
<iconset resource="translationeditor.qrc">
|
||||
<normaloff>:/translationeditor/images/remove.png</normaloff>:/translationeditor/images/remove.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
Reference in New Issue
Block a user