Retranslate configdialog.

--HG--
branch : feature
This commit is contained in:
Valentina Zhuravska 2016-01-06 07:34:30 +02:00
parent 2623af8881
commit 4e12484725
2 changed files with 38 additions and 4 deletions

View File

@ -38,7 +38,8 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
ConfigDialog::ConfigDialog(QWidget *parent) : ConfigDialog::ConfigDialog(QWidget *parent) :
QDialog(parent), contentsWidget(nullptr), pagesWidget(nullptr), configurationPage(nullptr), patternPage(nullptr), QDialog(parent), contentsWidget(nullptr), pagesWidget(nullptr), configurationPage(nullptr), patternPage(nullptr),
communityPage(nullptr), pathPage(nullptr), isInitialized(false) communityPage(nullptr), pathPage(nullptr), applyButton(nullptr), cancelButton(nullptr), okButton(nullptr),
isInitialized(false)
{ {
contentsWidget = new QListWidget; contentsWidget = new QListWidget;
contentsWidget->setViewMode(QListView::IconMode); contentsWidget->setViewMode(QListView::IconMode);
@ -62,9 +63,9 @@ ConfigDialog::ConfigDialog(QWidget *parent) :
pathPage = new PathPage(); pathPage = new PathPage();
pagesWidget->addWidget(pathPage); pagesWidget->addWidget(pathPage);
QPushButton *applyButton = new QPushButton(tr("Apply")); applyButton = new QPushButton(tr("Apply"));
QPushButton *cancelButton = new QPushButton(tr("&Cancel")); cancelButton = new QPushButton(tr("&Cancel"));
QPushButton *okButton = new QPushButton(tr("&Ok")); okButton = new QPushButton(tr("&Ok"));
createIcons(); createIcons();
contentsWidget->setCurrentRow(0); contentsWidget->setCurrentRow(0);
@ -115,6 +116,19 @@ void ConfigDialog::closeEvent(QCloseEvent *event)
event->accept(); event->accept();
} }
//---------------------------------------------------------------------------------------------------------------------
void ConfigDialog::changeEvent(QEvent *event)
{
if (event->type() == QEvent::LanguageChange)
{
// retranslate designer form (single inheritance approach)
RetranslateUi();
}
// remember to call base class implementation
QDialog::changeEvent(event);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void ConfigDialog::showEvent(QShowEvent *event) void ConfigDialog::showEvent(QShowEvent *event)
{ {
@ -188,3 +202,17 @@ void ConfigDialog::Ok()
Apply(); Apply();
done(QDialog::Accepted); done(QDialog::Accepted);
} }
//---------------------------------------------------------------------------------------------------------------------
void ConfigDialog::RetranslateUi()
{
applyButton->setText(tr("Apply"));
cancelButton->setText(tr("&Cancel"));
okButton->setText(tr("&Ok"));
setWindowTitle(tr("Config Dialog"));
contentsWidget->item(0)->setText(tr("Configuration"));
contentsWidget->item(1)->setText(tr("Pattern"));
contentsWidget->item(2)->setText(tr("Community"));
contentsWidget->item(3)->setText(tr("Paths"));
}

View File

@ -47,6 +47,7 @@ signals:
void UpdateProperties(); void UpdateProperties();
protected: protected:
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
private: private:
Q_DISABLE_COPY(ConfigDialog) Q_DISABLE_COPY(ConfigDialog)
@ -56,11 +57,16 @@ private:
PatternPage *patternPage; PatternPage *patternPage;
CommunityPage *communityPage; CommunityPage *communityPage;
PathPage *pathPage; PathPage *pathPage;
QPushButton *applyButton;
QPushButton *cancelButton;
QPushButton *okButton;
bool isInitialized; bool isInitialized;
void createIcons(); void createIcons();
void createIcon(const QString &icon, const QString &text); void createIcon(const QString &icon, const QString &text);
void Apply(); void Apply();
void Ok(); void Ok();
void RetranslateUi();
}; };
#endif // CONFIGDIALOG_H #endif // CONFIGDIALOG_H