From 9f3e41a6f68172a92f05012fe38e6c2334839ae2 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 1 Dec 2015 22:53:29 +0200 Subject: [PATCH] Optimization config dialog for Mac OS. --HG-- branch : develop --- src/app/valentina/dialogs/configdialog.cpp | 6 +-- .../dialogs/configpages/communitypage.cpp | 20 ++++++---- .../dialogs/configpages/configurationpage.cpp | 37 ++++--------------- .../dialogs/configpages/patternpage.cpp | 18 +++++---- 4 files changed, 34 insertions(+), 47 deletions(-) diff --git a/src/app/valentina/dialogs/configdialog.cpp b/src/app/valentina/dialogs/configdialog.cpp index 13528382d..684a94c5b 100644 --- a/src/app/valentina/dialogs/configdialog.cpp +++ b/src/app/valentina/dialogs/configdialog.cpp @@ -63,13 +63,13 @@ ConfigDialog::ConfigDialog(QWidget *parent) : pagesWidget->addWidget(pathPage); QPushButton *applyButton = new QPushButton(tr("Apply")); - QPushButton *canselButton = new QPushButton(tr("&Cancel")); + QPushButton *cancelButton = new QPushButton(tr("&Cancel")); QPushButton *okButton = new QPushButton(tr("&Ok")); createIcons(); contentsWidget->setCurrentRow(0); - connect(canselButton, &QPushButton::clicked, this, &ConfigDialog::close); + connect(cancelButton, &QPushButton::clicked, this, &ConfigDialog::close); connect(applyButton, &QPushButton::clicked, this, &ConfigDialog::Apply); connect(okButton, &QPushButton::clicked, this, &ConfigDialog::Ok); @@ -80,7 +80,7 @@ ConfigDialog::ConfigDialog(QWidget *parent) : QHBoxLayout *buttonsLayout = new QHBoxLayout; buttonsLayout->addStretch(1); buttonsLayout->addWidget(applyButton); - buttonsLayout->addWidget(canselButton); + buttonsLayout->addWidget(cancelButton); buttonsLayout->addWidget(okButton); QVBoxLayout *mainLayout = new QVBoxLayout; diff --git a/src/app/valentina/dialogs/configpages/communitypage.cpp b/src/app/valentina/dialogs/configpages/communitypage.cpp index 35822dbc6..b23b4e5a6 100644 --- a/src/app/valentina/dialogs/configpages/communitypage.cpp +++ b/src/app/valentina/dialogs/configpages/communitypage.cpp @@ -102,8 +102,9 @@ QGroupBox *CommunityPage::ServerGroup() { QGroupBox *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")); + CommunityPage::add_lineedit(&this->server, serverLayout, qApp->ValentinaSettings()->GetServer(), tr("Server name/IP:")); CommunityPage::add_checkbox(&this->secureComm, serverLayout, qApp->ValentinaSettings()->GetServerSecure(), tr("Secure connection")); @@ -126,6 +127,9 @@ void CommunityPage::add_lineedit(QLineEdit** theline, QFormLayout *layout, QStri { 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); } @@ -136,14 +140,15 @@ QGroupBox *CommunityPage::ProxyGroup() QGroupBox *proxyGroup = new QGroupBox(tr("Proxy settings")); QFormLayout *proxyLayout = new QFormLayout; + proxyLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); const VSettings *settings = qApp->ValentinaSettings(); CommunityPage::add_checkbox(&this->useProxy, proxyLayout, settings->GetProxy(), tr("Use Proxy")); 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")); + 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:")); connect(this->useProxy, &QCheckBox::stateChanged, this, &CommunityPage::ProxyCheckChanged); this->ProxyCheckChanged(); @@ -157,11 +162,12 @@ QGroupBox *CommunityPage::UserGroup() { QGroupBox *userGroup = new QGroupBox(tr("User settings")); QFormLayout *userLayout = new QFormLayout; + userLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); const VSettings *settings = qApp->ValentinaSettings(); - CommunityPage::add_lineedit(&this->username, userLayout, settings->GetUsername(), tr("User Name")); + 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->userpassword, userLayout, settings->GetUserPassword(), tr("Password:")); connect(this->savePassword, &QCheckBox::stateChanged, this, &CommunityPage::PasswordCheckChanged); this->PasswordCheckChanged(); diff --git a/src/app/valentina/dialogs/configpages/configurationpage.cpp b/src/app/valentina/dialogs/configpages/configurationpage.cpp index 1cbaef267..99e67432b 100644 --- a/src/app/valentina/dialogs/configpages/configurationpage.cpp +++ b/src/app/valentina/dialogs/configpages/configurationpage.cpp @@ -42,6 +42,7 @@ #include #include #include +#include //--------------------------------------------------------------------------------------------------------------------- ConfigurationPage::ConfigurationPage(QWidget *parent) @@ -153,7 +154,6 @@ QGroupBox *ConfigurationPage::SaveGroup() QGroupBox *ConfigurationPage::LangGroup() { QGroupBox *langGroup = new QGroupBox(tr("Language")); - QLabel *guiLabel = new QLabel(tr("GUI language")); langCombo = new QComboBox; QStringList fileNames; @@ -198,30 +198,23 @@ QGroupBox *ConfigurationPage::LangGroup() connect(langCombo, static_cast(&QComboBox::currentIndexChanged), this, &ConfigurationPage::LangChanged); - QHBoxLayout *guiLangLayout = new QHBoxLayout; - guiLangLayout->addWidget(guiLabel); - guiLangLayout->addWidget(langCombo); + QFormLayout *langLayout = new QFormLayout; + langLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); + langLayout->addRow(tr("GUI language:"), langCombo); //-------------------- Decimal separator setup - QLabel *separatorLabel = new QLabel(tr("Decimal separator parts")); - osOptionCheck = new QCheckBox(tr("With OS options (%1)").arg(QLocale::system().decimalPoint().toLatin1())); osOptionCheck->setChecked(settings->GetOsSeparator()); - - QHBoxLayout *separatorLayout = new QHBoxLayout; - separatorLayout->addWidget(separatorLabel); - separatorLayout->addWidget(osOptionCheck); + langLayout->addRow(tr("Decimal separator parts:"), osOptionCheck); //----------------------- Unit setup this->unitCombo = new QComboBox; - QLabel *unitLabel = new QLabel(tr("Default unit")); - this->unitCombo->addItem(tr("Centimeters"), "cm"); this->unitCombo->addItem(tr("Millimiters"), "mm"); this->unitCombo->addItem(tr("Inches"), "in"); // set default unit - qint32 indexUnit = this->unitCombo->findData(settings->GetUnit()); + const qint32 indexUnit = this->unitCombo->findData(settings->GetUnit()); if (indexUnit != -1) { this->unitCombo->setCurrentIndex(indexUnit); @@ -229,13 +222,9 @@ QGroupBox *ConfigurationPage::LangGroup() connect(this->unitCombo, static_cast(&QComboBox::currentIndexChanged), this, &ConfigurationPage::UnitChanged); - QHBoxLayout *UnitLayout = new QHBoxLayout; - UnitLayout->addWidget(unitLabel); - UnitLayout->addWidget(this->unitCombo); + langLayout->addRow(tr("Default unit:"), this->unitCombo); //----------------------- Label language - - QLabel *labelName = new QLabel(tr("Label language")); labelCombo = new QComboBox; SetLabelComboBox(VApplication::LabelLanguages()); @@ -248,19 +237,9 @@ QGroupBox *ConfigurationPage::LangGroup() connect(labelCombo, static_cast(&QComboBox::currentIndexChanged), this, &ConfigurationPage::LabelLangChanged); - QHBoxLayout *labelLangLayout = new QHBoxLayout; - labelLangLayout->addWidget(labelName); - labelLangLayout->addWidget(labelCombo); + langLayout->addRow(tr("Label language:"), labelCombo); - //----------------------- - - QVBoxLayout *langLayout = new QVBoxLayout; - langLayout->addLayout(guiLangLayout); - langLayout->addLayout(separatorLayout); - langLayout->addLayout(UnitLayout); - langLayout->addLayout(labelLangLayout); langGroup->setLayout(langLayout); - return langGroup; } diff --git a/src/app/valentina/dialogs/configpages/patternpage.cpp b/src/app/valentina/dialogs/configpages/patternpage.cpp index e515adbca..da9092867 100644 --- a/src/app/valentina/dialogs/configpages/patternpage.cpp +++ b/src/app/valentina/dialogs/configpages/patternpage.cpp @@ -38,6 +38,7 @@ #include #include #include +#include //--------------------------------------------------------------------------------------------------------------------- PatternPage::PatternPage(QWidget *parent): @@ -76,14 +77,16 @@ void PatternPage::Apply() QGroupBox *PatternPage::UserGroup() { QGroupBox *userGroup = new QGroupBox(tr("User")); - QLabel *nameLabel = new QLabel(tr("User name")); userName = new QLineEdit; +#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) + userName->setClearButtonEnabled(true); +#endif userName->setText(qApp->ValentinaSettings()->GetUser()); - QHBoxLayout *nameLayout = new QHBoxLayout; - nameLayout->addWidget(nameLabel); - nameLayout->addWidget(userName); + QFormLayout *nameLayout = new QFormLayout; + nameLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); + nameLayout->addRow(tr("User name:"), userName); QVBoxLayout *userLayout = new QVBoxLayout; userLayout->addLayout(nameLayout); @@ -112,14 +115,13 @@ QGroupBox *PatternPage::GraphOutputGroup() QGroupBox *PatternPage::UndoGroup() { QGroupBox *undoGroup = new QGroupBox(tr("Undo")); - QLabel *undoLabel = new QLabel(tr("Count steps (0 - no limit)")); undoCount = new QSpinBox; undoCount->setMinimum(0); undoCount->setValue(qApp->ValentinaSettings()->GetUndoCount()); - QHBoxLayout *countLayout = new QHBoxLayout; - countLayout->addWidget(undoLabel); - countLayout->addWidget(undoCount); + QFormLayout *countLayout = new QFormLayout; + countLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); + countLayout->addRow(tr("Count steps (0 - no limit):"), undoCount); QVBoxLayout *undoLayout = new QVBoxLayout; undoLayout->addLayout(countLayout);