From b9f3e664dca2a91282c541af7ef1469cfa07e7f4 Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Wed, 6 Jan 2016 07:40:34 +0200 Subject: [PATCH] Retranslate communitypage. --HG-- branch : feature --- .../dialogs/configpages/communitypage.cpp | 113 ++++++++++++++---- .../dialogs/configpages/communitypage.h | 24 +++- 2 files changed, 111 insertions(+), 26 deletions(-) diff --git a/src/app/valentina/dialogs/configpages/communitypage.cpp b/src/app/valentina/dialogs/configpages/communitypage.cpp index b23b4e5a6..066915869 100644 --- a/src/app/valentina/dialogs/configpages/communitypage.cpp +++ b/src/app/valentina/dialogs/configpages/communitypage.cpp @@ -38,9 +38,30 @@ //--------------------------------------------------------------------------------------------------------------------- CommunityPage::CommunityPage(QWidget *parent): - QWidget(parent), server(nullptr), secureComm(nullptr), useProxy(nullptr), proxyAddress(nullptr), - proxyPort(nullptr), proxyUser(nullptr), proxyPass(nullptr), username(nullptr), savePassword(nullptr), - userpassword(nullptr) + QWidget(parent), + serverGroup(nullptr), + server(nullptr), + secureComm(nullptr), + serverNameLabel(nullptr), + secureConnectionLabel(nullptr), + proxyGroup(nullptr), + useProxy(nullptr), + proxyAddress(nullptr), + proxyPort(nullptr), + proxyUser(nullptr), + proxyPass(nullptr), + useProxyLabel(nullptr), + proxyAddressLabel(nullptr), + proxyPortLabel(nullptr), + proxyUserLabel(nullptr), + proxyPassLabel(nullptr), + userGroup(nullptr), + username(nullptr), + savePassword(nullptr), + userpassword(nullptr), + usernameLabel(nullptr), + savePasswordLabel(nullptr), + userpasswordLabel(nullptr) { QGroupBox *serverGroup = ServerGroup(); QGroupBox *proxyGroup = ProxyGroup(); @@ -100,55 +121,75 @@ void CommunityPage::PasswordCheckChanged() //--------------------------------------------------------------------------------------------------------------------- QGroupBox *CommunityPage::ServerGroup() { - QGroupBox *ServerGroup = new QGroupBox(tr("Server")); + serverGroup = new QGroupBox(tr("Server")); QFormLayout *serverLayout = new QFormLayout; serverLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); - CommunityPage::add_lineedit(&this->server, serverLayout, qApp->ValentinaSettings()->GetServer(), tr("Server name/IP:")); + serverNameLabel = new QLabel(tr("Server name/IP:")); + secureConnectionLabel = new QLabel(tr("Secure connection")); + + CommunityPage::add_lineedit(&this->server, serverLayout, qApp->ValentinaSettings()->GetServer(), serverNameLabel); CommunityPage::add_checkbox(&this->secureComm, serverLayout, qApp->ValentinaSettings()->GetServerSecure(), - tr("Secure connection")); + secureConnectionLabel); - ServerGroup->setLayout(serverLayout); - return ServerGroup; + serverGroup->setLayout(serverLayout); + return serverGroup; } //--------------------------------------------------------------------------------------------------------------------- -void CommunityPage::add_checkbox(QCheckBox** thebox, QFormLayout *layout, bool checked, QString label) +void CommunityPage::add_checkbox(QCheckBox** thebox, QFormLayout *layout, bool checked, QLabel *label) { - QLabel *labelbox = new QLabel(label); (*thebox)= new QCheckBox; (*thebox)->setChecked(checked); - layout->addRow(labelbox, *thebox); + layout->addRow(label, *thebox); } //--------------------------------------------------------------------------------------------------------------------- -void CommunityPage::add_lineedit(QLineEdit** theline, QFormLayout *layout, QString value, QString label) +void CommunityPage::add_lineedit(QLineEdit** theline, QFormLayout *layout, QString value, QLabel *label) { - QLabel *labelbox = new QLabel(label); (*theline)= new QLineEdit; #if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) (*theline)->setClearButtonEnabled(true); #endif (*theline)->setText(value); - layout->addRow(labelbox, *theline); + layout->addRow(label, *theline); +} + +//--------------------------------------------------------------------------------------------------------------------- +void CommunityPage::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 *CommunityPage::ProxyGroup() { - QGroupBox *proxyGroup = new QGroupBox(tr("Proxy settings")); + proxyGroup = new QGroupBox(tr("Proxy settings")); QFormLayout *proxyLayout = new QFormLayout; proxyLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); + useProxyLabel = new QLabel(tr("Use Proxy")); + proxyAddressLabel = new QLabel(tr("Proxy address:")); + proxyPortLabel = new QLabel(tr("Proxy port:")); + proxyUserLabel = new QLabel(tr("Proxy user:")); + proxyPassLabel = new QLabel(tr("Proxy pass:")); + const VSettings *settings = qApp->ValentinaSettings(); - CommunityPage::add_checkbox(&this->useProxy, proxyLayout, settings->GetProxy(), tr("Use Proxy")); + CommunityPage::add_checkbox(&this->useProxy, proxyLayout, settings->GetProxy(), useProxyLabel); CommunityPage::add_lineedit(&this->proxyAddress, proxyLayout, settings->GetProxyAddress(), - tr("Proxy address:")); - CommunityPage::add_lineedit(&this->proxyPort, proxyLayout, settings->GetProxyPort(), tr("Proxy port:")); - CommunityPage::add_lineedit(&this->proxyUser, proxyLayout, settings->GetProxyUser(), tr("Proxy user:")); - CommunityPage::add_lineedit(&this->proxyPass, proxyLayout, settings->GetProxyPass(), tr("Proxy pass:")); + proxyAddressLabel); + CommunityPage::add_lineedit(&this->proxyPort, proxyLayout, settings->GetProxyPort(), proxyPortLabel); + CommunityPage::add_lineedit(&this->proxyUser, proxyLayout, settings->GetProxyUser(), proxyUserLabel); + CommunityPage::add_lineedit(&this->proxyPass, proxyLayout, settings->GetProxyPass(), proxyPassLabel); connect(this->useProxy, &QCheckBox::stateChanged, this, &CommunityPage::ProxyCheckChanged); this->ProxyCheckChanged(); @@ -160,14 +201,18 @@ QGroupBox *CommunityPage::ProxyGroup() //--------------------------------------------------------------------------------------------------------------------- QGroupBox *CommunityPage::UserGroup() { - QGroupBox *userGroup = new QGroupBox(tr("User settings")); + userGroup = new QGroupBox(tr("User settings")); QFormLayout *userLayout = new QFormLayout; userLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); + usernameLabel = new QLabel(tr("User Name:")); + savePasswordLabel = new QLabel(tr("Save password")); + userpasswordLabel = new QLabel(tr("Password:")); + const VSettings *settings = qApp->ValentinaSettings(); - CommunityPage::add_lineedit(&this->username, userLayout, settings->GetUsername(), tr("User Name:")); - CommunityPage::add_checkbox(&this->savePassword, userLayout, settings->GetSavePassword(), tr("Save password")); - CommunityPage::add_lineedit(&this->userpassword, userLayout, settings->GetUserPassword(), tr("Password:")); + CommunityPage::add_lineedit(&this->username, userLayout, settings->GetUsername(), usernameLabel); + CommunityPage::add_checkbox(&this->savePassword, userLayout, settings->GetSavePassword(), savePasswordLabel); + CommunityPage::add_lineedit(&this->userpassword, userLayout, settings->GetUserPassword(), userpasswordLabel); connect(this->savePassword, &QCheckBox::stateChanged, this, &CommunityPage::PasswordCheckChanged); this->PasswordCheckChanged(); @@ -176,3 +221,23 @@ QGroupBox *CommunityPage::UserGroup() return userGroup; } + +//--------------------------------------------------------------------------------------------------------------------- +void CommunityPage::RetranslateUi() +{ + serverGroup->setTitle(tr("Server")); + serverNameLabel->setText(tr("Server name/IP:")); + secureConnectionLabel->setText(tr("Secure connection")); + + proxyGroup->setTitle(tr("Proxy settings")); + useProxyLabel->setText(tr("Use Proxy")); + proxyAddressLabel->setText(tr("Proxy address:")); + proxyPortLabel->setText(tr("Proxy port:")); + proxyUserLabel->setText(tr("Proxy user:")); + proxyPassLabel->setText(tr("Proxy pass:")); + + userGroup->setTitle(tr("User settings")); + usernameLabel->setText(tr("User Name:")); + savePasswordLabel->setText(tr("Save password")); + userpasswordLabel->setText(tr("Password:")); +} diff --git a/src/app/valentina/dialogs/configpages/communitypage.h b/src/app/valentina/dialogs/configpages/communitypage.h index 8d98bf75f..dc1baee83 100644 --- a/src/app/valentina/dialogs/configpages/communitypage.h +++ b/src/app/valentina/dialogs/configpages/communitypage.h @@ -36,6 +36,7 @@ class QCheckBox; class QGroupBox; class QLineEdit; +class QLabel; class CommunityPage : public QWidget { @@ -43,26 +44,43 @@ class CommunityPage : public QWidget public: explicit CommunityPage(QWidget *parent = nullptr); void Apply(); +protected: + virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(CommunityPage) // server name and https connection + QGroupBox *serverGroup; QLineEdit *server; QCheckBox *secureComm; + QLabel *serverNameLabel; + QLabel *secureConnectionLabel; // proxy stuff + QGroupBox *proxyGroup; QCheckBox *useProxy; QLineEdit *proxyAddress; QLineEdit *proxyPort; QLineEdit *proxyUser; QLineEdit *proxyPass; + QLabel *useProxyLabel; + QLabel *proxyAddressLabel; + QLabel *proxyPortLabel; + QLabel *proxyUserLabel; + QLabel *proxyPassLabel; + // username and password + QGroupBox *userGroup; QLineEdit *username; QCheckBox *savePassword; QLineEdit *userpassword; - static void add_checkbox(QCheckBox** thebox, QFormLayout *layout, bool checked, QString label); - static void add_lineedit(QLineEdit** theline, QFormLayout *layout, QString value, QString label); + QLabel *usernameLabel; + QLabel *savePasswordLabel; + QLabel *userpasswordLabel; + + static void add_checkbox(QCheckBox** thebox, QFormLayout *layout, bool checked, QLabel* label); + static void add_lineedit(QLineEdit** theline, QFormLayout *layout, QString value, QLabel *label); void ProxyCheckChanged(); void PasswordCheckChanged(); @@ -70,6 +88,8 @@ private: QGroupBox *ServerGroup(); QGroupBox *ProxyGroup(); QGroupBox *UserGroup(); + + void RetranslateUi(); }; #endif // COMMUNITYPAGE_H