Retranslate patternpage.

--HG--
branch : feature
This commit is contained in:
Valentina Zhuravska 2016-01-06 07:59:01 +02:00
parent aa3197fbd3
commit c4fe05df11
2 changed files with 50 additions and 6 deletions

View file

@ -42,7 +42,15 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
PatternPage::PatternPage(QWidget *parent): PatternPage::PatternPage(QWidget *parent):
QWidget(parent), userName(nullptr), graphOutputCheck(nullptr), undoCount(nullptr) QWidget(parent),
userGroup(nullptr),
userName(nullptr),
userNameLabel(nullptr),
graphOutputGroup(nullptr),
graphOutputCheck(nullptr),
undoGroup(nullptr),
undoCount(nullptr),
countStepsLabel(nullptr)
{ {
QGroupBox *userGroup = UserGroup(); QGroupBox *userGroup = UserGroup();
QGroupBox *graphOutputGroup = GraphOutputGroup(); QGroupBox *graphOutputGroup = GraphOutputGroup();
@ -73,10 +81,23 @@ void PatternPage::Apply()
settings->SetUndoCount(undoCount->value()); settings->SetUndoCount(undoCount->value());
} }
//---------------------------------------------------------------------------------------------------------------------
void PatternPage::changeEvent(QEvent *event)
{
if (event->type() == QEvent::LanguageChange)
{
// retranslate designer form (single inheritance approach)
RetranslateUi();
}
// remember to call base class implementation
QWidget::changeEvent(event);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QGroupBox *PatternPage::UserGroup() QGroupBox *PatternPage::UserGroup()
{ {
QGroupBox *userGroup = new QGroupBox(tr("User")); userGroup = new QGroupBox(tr("User"));
userName = new QLineEdit; userName = new QLineEdit;
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
@ -85,8 +106,9 @@ QGroupBox *PatternPage::UserGroup()
userName->setText(qApp->ValentinaSettings()->GetUser()); userName->setText(qApp->ValentinaSettings()->GetUser());
QFormLayout *nameLayout = new QFormLayout; QFormLayout *nameLayout = new QFormLayout;
userNameLabel = new QLabel(tr("User name:"));
nameLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); nameLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
nameLayout->addRow(tr("User name:"), userName); nameLayout->addRow(userNameLabel, userName);
QVBoxLayout *userLayout = new QVBoxLayout; QVBoxLayout *userLayout = new QVBoxLayout;
userLayout->addLayout(nameLayout); userLayout->addLayout(nameLayout);
@ -97,7 +119,7 @@ QGroupBox *PatternPage::UserGroup()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QGroupBox *PatternPage::GraphOutputGroup() QGroupBox *PatternPage::GraphOutputGroup()
{ {
QGroupBox *graphOutputGroup = new QGroupBox(tr("Graphical output")); graphOutputGroup = new QGroupBox(tr("Graphical output"));
graphOutputCheck = new QCheckBox(tr("Use antialiasing")); graphOutputCheck = new QCheckBox(tr("Use antialiasing"));
graphOutputCheck->setChecked(qApp->ValentinaSettings()->GetGraphicalOutput()); graphOutputCheck->setChecked(qApp->ValentinaSettings()->GetGraphicalOutput());
@ -114,17 +136,29 @@ QGroupBox *PatternPage::GraphOutputGroup()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QGroupBox *PatternPage::UndoGroup() QGroupBox *PatternPage::UndoGroup()
{ {
QGroupBox *undoGroup = new QGroupBox(tr("Undo")); undoGroup = new QGroupBox(tr("Undo"));
undoCount = new QSpinBox; undoCount = new QSpinBox;
undoCount->setMinimum(0); undoCount->setMinimum(0);
undoCount->setValue(qApp->ValentinaSettings()->GetUndoCount()); undoCount->setValue(qApp->ValentinaSettings()->GetUndoCount());
QFormLayout *countLayout = new QFormLayout; QFormLayout *countLayout = new QFormLayout;
countStepsLabel = new QLabel(tr("Count steps (0 - no limit):"));
countLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); countLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
countLayout->addRow(tr("Count steps (0 - no limit):"), undoCount); countLayout->addRow(countStepsLabel, undoCount);
QVBoxLayout *undoLayout = new QVBoxLayout; QVBoxLayout *undoLayout = new QVBoxLayout;
undoLayout->addLayout(countLayout); undoLayout->addLayout(countLayout);
undoGroup->setLayout(undoLayout); undoGroup->setLayout(undoLayout);
return undoGroup; return undoGroup;
} }
//---------------------------------------------------------------------------------------------------------------------
void PatternPage::RetranslateUi()
{
userGroup->setTitle(tr("User"));
userNameLabel->setText(tr("User name:"));
graphOutputGroup->setTitle(tr("Graphical output"));
graphOutputCheck->setText(tr("Use antialiasing"));
undoGroup->setTitle(tr("Undo"));
countStepsLabel->setText(tr("Count steps (0 - no limit):"));
}

View file

@ -36,6 +36,7 @@ class QCheckBox;
class QSpinBox; class QSpinBox;
class QGroupBox; class QGroupBox;
class QLineEdit; class QLineEdit;
class QLabel;
class PatternPage : public QWidget class PatternPage : public QWidget
{ {
@ -43,14 +44,23 @@ class PatternPage : public QWidget
public: public:
explicit PatternPage(QWidget *parent = nullptr); explicit PatternPage(QWidget *parent = nullptr);
void Apply(); void Apply();
protected:
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
private: private:
Q_DISABLE_COPY(PatternPage) Q_DISABLE_COPY(PatternPage)
QGroupBox *userGroup;
QLineEdit *userName; QLineEdit *userName;
QLabel *userNameLabel;
QGroupBox *graphOutputGroup;
QCheckBox *graphOutputCheck; QCheckBox *graphOutputCheck;
QGroupBox *undoGroup;
QSpinBox *undoCount; QSpinBox *undoCount;
QLabel *countStepsLabel;
QGroupBox *UserGroup(); QGroupBox *UserGroup();
QGroupBox *GraphOutputGroup(); QGroupBox *GraphOutputGroup();
QGroupBox *UndoGroup(); QGroupBox *UndoGroup();
void RetranslateUi();
}; };
#endif // PATTERNPAGE_H #endif // PATTERNPAGE_H