From 2147e9fd9785e034b7a8904c565b832261aad238 Mon Sep 17 00:00:00 2001 From: dismine Date: Sat, 21 Jun 2014 10:59:43 +0300 Subject: [PATCH] Config pages in separate files. --HG-- branch : develop --- src/app/dialogs/app/configdialog.h | 2 +- .../dialogs/app/configpages/communitypage.cpp | 193 +++++++ .../{pages.h => configpages/communitypage.h} | 52 +- .../app/configpages/configurationpage.cpp | 241 +++++++++ .../app/configpages/configurationpage.h | 62 +++ src/app/dialogs/app/configpages/pages.h | 36 ++ .../dialogs/app/configpages/patternpage.cpp | 148 +++++ src/app/dialogs/app/configpages/patternpage.h | 56 ++ src/app/dialogs/app/pages.cpp | 512 ------------------ src/app/dialogs/dialogs.pri | 15 +- 10 files changed, 753 insertions(+), 564 deletions(-) create mode 100644 src/app/dialogs/app/configpages/communitypage.cpp rename src/app/dialogs/app/{pages.h => configpages/communitypage.h} (67%) create mode 100644 src/app/dialogs/app/configpages/configurationpage.cpp create mode 100644 src/app/dialogs/app/configpages/configurationpage.h create mode 100644 src/app/dialogs/app/configpages/pages.h create mode 100644 src/app/dialogs/app/configpages/patternpage.cpp create mode 100644 src/app/dialogs/app/configpages/patternpage.h delete mode 100644 src/app/dialogs/app/pages.cpp diff --git a/src/app/dialogs/app/configdialog.h b/src/app/dialogs/app/configdialog.h index 7b18578d8..7832ebd4d 100644 --- a/src/app/dialogs/app/configdialog.h +++ b/src/app/dialogs/app/configdialog.h @@ -30,7 +30,7 @@ #define CONFIGDIALOG_H #include -#include "pages.h" +#include "configpages/pages.h" class QListWidgetItem; class QStackedWidget; diff --git a/src/app/dialogs/app/configpages/communitypage.cpp b/src/app/dialogs/app/configpages/communitypage.cpp new file mode 100644 index 000000000..0959609ca --- /dev/null +++ b/src/app/dialogs/app/configpages/communitypage.cpp @@ -0,0 +1,193 @@ +/************************************************************************ + ** + ** @file communitypage.cpp + ** @author Roman Telezhynskyi + ** @date 21 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "communitypage.h" +#include "../../../options.h" +#include "../../../widgets/vapplication.h" +#include +#include +#include +#include +#include + + +//--------------------------------------------------------------------------------------------------------------------- +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) +{ + QGroupBox *serverGroup = ServerGroup(); + QGroupBox *proxyGroup = ProxyGroup(); + QGroupBox *userGroup = UserGroup(); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(serverGroup); + mainLayout->addWidget(userGroup); + mainLayout->addWidget(proxyGroup); + mainLayout->addStretch(1); + setLayout(mainLayout); +} + +//--------------------------------------------------------------------------------------------------------------------- +void CommunityPage::Apply() +{ + QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), + QApplication::applicationName()); + settings.setValue("community/server", this->server->text()); + settings.setValue("community/serverSecure", this->secureComm->isChecked()); + settings.setValue("community/useProxy", this->useProxy->isChecked()); + settings.setValue("community/proxyAddress", this->proxyAddress->text()); + settings.setValue("community/proxyPort", this->proxyPort->text()); + settings.setValue("community/proxyUser", this->proxyUser->text()); + settings.setValue("community/proxyPass", this->proxyPass->text()); + + settings.setValue("community/username", this->username->text()); + settings.setValue("community/savePassword", this->savePassword->isChecked()); + settings.setValue("community/userpassword", this->userpassword->text()); + +} + +//--------------------------------------------------------------------------------------------------------------------- +void CommunityPage::ProxyCheckChanged() +{ + if (this->useProxy->isChecked() == false) + { + this->proxyAddress->setEnabled(false); + this->proxyPort->setEnabled(false); + this->proxyUser->setEnabled(false); + this->proxyPass->setEnabled(false); + } + else + { + this->proxyAddress->setEnabled(true); + this->proxyPort->setEnabled(true); + this->proxyUser->setEnabled(true); + this->proxyPass->setEnabled(true); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void CommunityPage::PasswordCheckChanged() +{ + this->userpassword->setEnabled(this->savePassword->isChecked()); +} + +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *CommunityPage::ServerGroup() +{ + QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), + QApplication::applicationName()); + + QGroupBox *ServerGroup = new QGroupBox(tr("Server")); + QFormLayout *serverLayout = new QFormLayout; + + CommunityPage::add_lineedit(&this->server, serverLayout, + settings.value("community/server", "community.valentina-project.org").toString(), tr("Server name/IP")); + + CommunityPage::add_checkbox(&this->secureComm, serverLayout, + settings.value("community/serverSecure", 0).toBool(), tr("Secure connection")); + + ServerGroup->setLayout(serverLayout); + return ServerGroup; +} + +//--------------------------------------------------------------------------------------------------------------------- +void CommunityPage::add_checkbox(QCheckBox** thebox, QFormLayout *layout, bool checked, QString label) +{ + QLabel *labelbox = new QLabel(label); + (*thebox)= new QCheckBox; + (*thebox)->setChecked(checked); + layout->addRow(labelbox, *thebox); +} + +//--------------------------------------------------------------------------------------------------------------------- +void CommunityPage::add_lineedit(QLineEdit** theline, QFormLayout *layout, QString value, QString label) +{ + QLabel *labelbox = new QLabel(label); + (*theline)= new QLineEdit; + (*theline)->setText(value); + layout->addRow(labelbox, *theline); +} + +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *CommunityPage::ProxyGroup() +{ + QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), + QApplication::applicationName()); + QGroupBox *proxyGroup = new QGroupBox(tr("Proxy settings")); + + QFormLayout *proxyLayout = new QFormLayout; + + CommunityPage::add_checkbox(&this->useProxy, proxyLayout, + settings.value("community/useProxy", 0).toBool(), tr("Use Proxy")); + + CommunityPage::add_lineedit(&this->proxyAddress, proxyLayout, + settings.value("community/proxyAddress", "").toString(), tr("Proxy address")); + + CommunityPage::add_lineedit(&this->proxyPort, proxyLayout, + settings.value("community/proxyPort", "").toString(), tr("Proxy port")); + + CommunityPage::add_lineedit(&this->proxyUser, proxyLayout, + settings.value("community/proxyUser", "").toString(), tr("Proxy user")); + + CommunityPage::add_lineedit(&this->proxyPass, proxyLayout, + settings.value("community/proxyPass", "").toString(), tr("Proxy pass")); + + connect(this->useProxy, &QCheckBox::stateChanged, this, &CommunityPage::ProxyCheckChanged); + this->ProxyCheckChanged(); + + proxyGroup->setLayout(proxyLayout); + + return proxyGroup; +} + +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *CommunityPage::UserGroup() +{ + QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), + QApplication::applicationName()); + QGroupBox *userGroup = new QGroupBox(tr("User settings")); + QFormLayout *userLayout = new QFormLayout; + + CommunityPage::add_lineedit(&this->username, userLayout, + settings.value("community/username", "").toString(), tr("User Name")); + + CommunityPage::add_checkbox(&this->savePassword, userLayout, + settings.value("community/savePassword", 0).toBool(), tr("Save password")); + + CommunityPage::add_lineedit(&this->userpassword, userLayout, + settings.value("community/userpassword", "").toString(), tr("Password")); + + connect(this->savePassword, &QCheckBox::stateChanged, this, &CommunityPage::PasswordCheckChanged); + this->PasswordCheckChanged(); + + userGroup->setLayout(userLayout); + + return userGroup; +} diff --git a/src/app/dialogs/app/pages.h b/src/app/dialogs/app/configpages/communitypage.h similarity index 67% rename from src/app/dialogs/app/pages.h rename to src/app/dialogs/app/configpages/communitypage.h index 1474cf662..6af2a1560 100644 --- a/src/app/dialogs/app/pages.h +++ b/src/app/dialogs/app/configpages/communitypage.h @@ -1,14 +1,14 @@ /************************************************************************ ** - ** @file pages.h + ** @file communitypage.h ** @author Roman Telezhynskyi - ** @date 12 2, 2014 + ** @date 21 6, 2014 ** ** @brief ** @copyright ** This source code is part of the Valentine project, a pattern making ** program, whose allow create and modeling patterns of clothing. - ** Copyright (C) 2013 Valentina project + ** Copyright (C) 2014 Valentina project ** All Rights Reserved. ** ** Valentina is free software: you can redistribute it and/or modify @@ -26,57 +26,17 @@ ** *************************************************************************/ -#ifndef PAGES_H -#define PAGES_H +#ifndef COMMUNITYPAGE_H +#define COMMUNITYPAGE_H #include #include #include class QCheckBox; -class QSpinBox; -class QComboBox; class QGroupBox; class QLineEdit; -class ConfigurationPage : public QWidget -{ - Q_OBJECT -public: - ConfigurationPage(QWidget *parent = nullptr); - void Apply(); -public slots: - void LangChanged(); - void UnitChanged(); -private: - Q_DISABLE_COPY(ConfigurationPage) - QCheckBox *autoSaveCheck; - QSpinBox *autoTime; - QComboBox *langCombo; - QComboBox *unitCombo; - QCheckBox *osOptionCheck; - bool langChanged; - bool unitChanged; - QGroupBox *SaveGroup(); - QGroupBox *LangGroup(); -}; - -class PatternPage : public QWidget -{ - Q_OBJECT -public: - PatternPage(QWidget *parent = nullptr); - void Apply(); -private: - Q_DISABLE_COPY(PatternPage) - QLineEdit *userName; - QCheckBox *graphOutputCheck; - QSpinBox *undoCount; - QGroupBox *UserGroup(); - QGroupBox *GraphOutputGroup(); - QGroupBox *UndoGroup(); -}; - class CommunityPage : public QWidget { Q_OBJECT @@ -112,4 +72,4 @@ private: QGroupBox *UserGroup(); }; -#endif // PAGES_H +#endif // COMMUNITYPAGE_H diff --git a/src/app/dialogs/app/configpages/configurationpage.cpp b/src/app/dialogs/app/configpages/configurationpage.cpp new file mode 100644 index 000000000..e8617ddeb --- /dev/null +++ b/src/app/dialogs/app/configpages/configurationpage.cpp @@ -0,0 +1,241 @@ +/************************************************************************ + ** + ** @file configurationpage.cpp + ** @author Roman Telezhynskyi + ** @date 21 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "configurationpage.h" +#include "../../../options.h" +#include "../../../widgets/vapplication.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +ConfigurationPage::ConfigurationPage(QWidget *parent) + : QWidget(parent), autoSaveCheck(nullptr), autoTime(nullptr), langCombo(nullptr), unitCombo(nullptr), + osOptionCheck(nullptr), langChanged(false), unitChanged(false) +{ + QGroupBox *saveGroup = SaveGroup(); + QGroupBox *langGroup = LangGroup(); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(saveGroup); + mainLayout->addWidget(langGroup); + mainLayout->addStretch(1); + setLayout(mainLayout); +} + +//--------------------------------------------------------------------------------------------------------------------- +void ConfigurationPage::Apply() +{ + QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), + QApplication::applicationName()); + settings.setValue("configuration/autosave/state", autoSaveCheck->isChecked()); + settings.setValue("configuration/autosave/time", autoTime->value()); + + QTimer *autoSaveTimer = qApp->getAutoSaveTimer(); + SCASSERT(autoSaveTimer); + + if (autoSaveCheck->isChecked()) + { + autoSaveTimer->start(autoTime->value()*60000); + } + else + { + autoSaveTimer->stop(); + } + + settings.setValue("configuration/osSeparator", osOptionCheck->isChecked()); + + if (langChanged) + { + QString locale = qvariant_cast(langCombo->itemData(langCombo->currentIndex())); + settings.setValue("configuration/locale", locale); + langChanged = false; + QString text = QString(tr("Setup user interface language updated and will be used the next time start") + " " + + QApplication::applicationName()); + QMessageBox::information(this, QApplication::applicationName(), text); + } + if (this->unitChanged) + { + QString unit = qvariant_cast(this->unitCombo->itemData(this->unitCombo->currentIndex())); + settings.setValue("configuration/unit", unit); + this->unitChanged = false; + QString text = QString(tr("Default unit updated and will be used the next pattern load")); + QMessageBox::information(this, QApplication::applicationName(), text); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void ConfigurationPage::LangChanged() +{ + langChanged = true; +} + +//--------------------------------------------------------------------------------------------------------------------- +void ConfigurationPage::UnitChanged() +{ + this->unitChanged = true; +} + +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *ConfigurationPage::SaveGroup() +{ + QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), + QApplication::applicationName()); + + QGroupBox *saveGroup = new QGroupBox(tr("Save")); + + autoSaveCheck = new QCheckBox(tr("Auto-save modified pattern")); + bool autoSaveValue = settings.value("configuration/autosave/state", 1).toBool(); + autoSaveCheck->setChecked(autoSaveValue); + + QLabel *intervalLabel = new QLabel(tr("Interval:")); + + autoTime = new QSpinBox(); + bool ok = true; + qint32 autoTimeValue = settings.value("configuration/autosave/time", 5).toInt(&ok); + if (ok == false) + { + autoTimeValue = 5; + } + autoTime->setRange(1, 60); + autoTime->setValue(autoTimeValue); + autoTime->setSuffix(tr("min")); + + QHBoxLayout *autosaveLayout = new QHBoxLayout; + autosaveLayout->addWidget(autoSaveCheck); + autosaveLayout->addWidget(intervalLabel); + autosaveLayout->addWidget(autoTime); + + QVBoxLayout *saveLayout = new QVBoxLayout; + saveLayout->addLayout(autosaveLayout); + saveGroup->setLayout(saveLayout); + return saveGroup; +} + +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *ConfigurationPage::LangGroup() +{ + QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), + QApplication::applicationName()); + + QGroupBox *langGroup = new QGroupBox(tr("Language")); + QLabel *guiLabel = new QLabel(tr("GUI language")); + langCombo = new QComboBox; + + // format systems language + QString defaultLocale = QLocale::system().name(); // e.g. "de_DE" + defaultLocale.truncate(defaultLocale.lastIndexOf('_')); // e.g. "de" + QString checkedLocale = settings.value("configuration/locale", defaultLocale).toString(); + + QString m_langPath = qApp->translationsPath(); + QDir dir(m_langPath); + QStringList fileNames = dir.entryList(QStringList("valentina_*.qm")); + + for (int i = 0; i < fileNames.size(); ++i) + { + // get locale extracted by filename + QString locale; + locale = fileNames.at(i); // "valentina_de.qm" + locale.truncate(locale.lastIndexOf('.')); // "valentina_de" + locale.remove(0, locale.indexOf('_') + 1); // "de" + + QString lang = QLocale(locale).nativeLanguageName(); + QIcon ico(QString("%1/%2.png").arg("://icon/flags").arg(locale)); + + langCombo->addItem(ico, lang, locale); + } + + QIcon ico(QString("%1/%2.png").arg("://icon/flags").arg("en")); + QString lang = QLocale("en").nativeLanguageName(); + langCombo->addItem(ico, lang, "en"); + + // set default translators and language checked + qint32 index = langCombo->findData(checkedLocale); + if (index != -1) + { + langCombo->setCurrentIndex(index); + } + connect(langCombo, static_cast(&QComboBox::currentIndexChanged), this, + &ConfigurationPage::LangChanged); + + QHBoxLayout *guiLangLayout = new QHBoxLayout; + guiLangLayout->addWidget(guiLabel); + guiLangLayout->addWidget(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())); + bool osOptionValue = settings.value("configuration/osSeparator", 1).toBool(); + osOptionCheck->setChecked(osOptionValue); + + QHBoxLayout *separatorLayout = new QHBoxLayout; + separatorLayout->addWidget(separatorLabel); + separatorLayout->addWidget(osOptionCheck); + + //----------------------- Unit setup + this->unitCombo = new QComboBox; + QLabel *unitLabel = new QLabel(tr("Default unit")); + + QString checkedUnit = settings.value("configuration/unit", "cm").toString(); + + this->unitCombo->addItem(tr("Centimeters"), "cm"); + this->unitCombo->addItem(tr("Milimiters"), "mm"); + this->unitCombo->addItem(tr("Inches"), "in"); + + // set default unit + qint32 indexUnit = this->unitCombo->findData(checkedUnit); + if (indexUnit != -1) + { + this->unitCombo->setCurrentIndex(indexUnit); + } + connect(this->unitCombo, static_cast(&QComboBox::currentIndexChanged), this, + &ConfigurationPage::UnitChanged); + + QHBoxLayout *UnitLayout = new QHBoxLayout; + UnitLayout->addWidget(unitLabel); + UnitLayout->addWidget(this->unitCombo); + + //----------------------- Unit setup + + QVBoxLayout *langLayout = new QVBoxLayout; + langLayout->addLayout(guiLangLayout); + langLayout->addLayout(separatorLayout); + langLayout->addLayout(UnitLayout); + langGroup->setLayout(langLayout); + + return langGroup; +} diff --git a/src/app/dialogs/app/configpages/configurationpage.h b/src/app/dialogs/app/configpages/configurationpage.h new file mode 100644 index 000000000..9e32fee0e --- /dev/null +++ b/src/app/dialogs/app/configpages/configurationpage.h @@ -0,0 +1,62 @@ +/************************************************************************ + ** + ** @file configurationpage.h + ** @author Roman Telezhynskyi + ** @date 21 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef CONFIGURATIONPAGE_H +#define CONFIGURATIONPAGE_H + +#include +#include + +class QCheckBox; +class QSpinBox; +class QComboBox; +class QGroupBox; + +class ConfigurationPage : public QWidget +{ + Q_OBJECT +public: + ConfigurationPage(QWidget *parent = nullptr); + void Apply(); +public slots: + void LangChanged(); + void UnitChanged(); +private: + Q_DISABLE_COPY(ConfigurationPage) + QCheckBox *autoSaveCheck; + QSpinBox *autoTime; + QComboBox *langCombo; + QComboBox *unitCombo; + QCheckBox *osOptionCheck; + bool langChanged; + bool unitChanged; + QGroupBox *SaveGroup(); + QGroupBox *LangGroup(); +}; + +#endif // CONFIGURATIONPAGE_H diff --git a/src/app/dialogs/app/configpages/pages.h b/src/app/dialogs/app/configpages/pages.h new file mode 100644 index 000000000..e2d8c836c --- /dev/null +++ b/src/app/dialogs/app/configpages/pages.h @@ -0,0 +1,36 @@ +/************************************************************************ + ** + ** @file pages.h + ** @author Roman Telezhynskyi + ** @date 12 2, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2013 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef PAGES_H +#define PAGES_H + +#include "configurationpage.h" +#include "patternpage.h" +#include "communitypage.h" + +#endif // PAGES_H diff --git a/src/app/dialogs/app/configpages/patternpage.cpp b/src/app/dialogs/app/configpages/patternpage.cpp new file mode 100644 index 000000000..7cdbff966 --- /dev/null +++ b/src/app/dialogs/app/configpages/patternpage.cpp @@ -0,0 +1,148 @@ +/************************************************************************ + ** + ** @file patternpage.cpp + ** @author Roman Telezhynskyi + ** @date 21 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "patternpage.h" +#include "../../../options.h" +#include "../../../widgets/vapplication.h" +#include "../../../widgets/vmaingraphicsview.h" +#include +#include +#include +#include +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +PatternPage::PatternPage(QWidget *parent): + QWidget(parent), userName(0), graphOutputCheck(0), undoCount(0) +{ + QGroupBox *userGroup = UserGroup(); + QGroupBox *graphOutputGroup = GraphOutputGroup(); + QGroupBox *undoGroup = UndoGroup(); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(userGroup); + mainLayout->addWidget(graphOutputGroup); + mainLayout->addWidget(undoGroup); + mainLayout->addStretch(1); + setLayout(mainLayout); +} + +//--------------------------------------------------------------------------------------------------------------------- +void PatternPage::Apply() +{ + QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), + QApplication::applicationName()); + settings.setValue("pattern/user", userName->text()); + + // Scene antialiasing + settings.setValue("pattern/graphicalOutput", graphOutputCheck->isChecked()); + qApp->getSceneView()->setRenderHint(QPainter::Antialiasing, graphOutputCheck->isChecked()); + qApp->getSceneView()->setRenderHint(QPainter::SmoothPixmapTransform, graphOutputCheck->isChecked()); + + /* Maximum number of commands in undo stack may only be set when the undo stack is empty, since setting it on a + * non-empty stack might delete the command at the current index. Calling setUndoLimit() on a non-empty stack + * prints a warning and does nothing.*/ + settings.setValue("pattern/undo", undoCount->value()); +} + +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *PatternPage::UserGroup() +{ + QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), + QApplication::applicationName()); + + QGroupBox *userGroup = new QGroupBox(tr("User")); + QLabel *nameLabel = new QLabel(tr("User name")); + + userName = new QLineEdit; +#ifdef Q_OS_WIN + QString user = settings.value("pattern/user", QString::fromLocal8Bit(qgetenv("USERNAME").constData())).toString(); +#else + QString user = settings.value("pattern/user", QString::fromLocal8Bit(qgetenv("USER").constData())).toString(); +#endif + userName->setText(user); + + QHBoxLayout *nameLayout = new QHBoxLayout; + nameLayout->addWidget(nameLabel); + nameLayout->addWidget(userName); + + QVBoxLayout *userLayout = new QVBoxLayout; + userLayout->addLayout(nameLayout); + userGroup->setLayout(userLayout); + return userGroup; +} + +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *PatternPage::GraphOutputGroup() +{ + QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), + QApplication::applicationName()); + + QGroupBox *graphOutputGroup = new QGroupBox(tr("Graphical output")); + + graphOutputCheck = new QCheckBox(tr("Use antialiasing")); + bool graphOutputValue = settings.value("pattern/graphicalOutput", 1).toBool(); + graphOutputCheck->setChecked(graphOutputValue); + + QHBoxLayout *graphLayout = new QHBoxLayout; + graphLayout->addWidget(graphOutputCheck); + + QVBoxLayout *graphOutputLayout = new QVBoxLayout; + graphOutputLayout->addLayout(graphLayout); + graphOutputGroup->setLayout(graphOutputLayout); + return graphOutputGroup; +} + +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *PatternPage::UndoGroup() +{ + QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), + QApplication::applicationName()); + + QGroupBox *undoGroup = new QGroupBox(tr("Undo")); + QLabel *undoLabel = new QLabel(tr("Count steps (0 - no limit)")); + undoCount = new QSpinBox; + undoCount->setMinimum(0); + bool ok = true; + qint32 count = settings.value("pattern/undo", 0).toInt(&ok); + if (ok == false) + { + count = 0; + } + undoCount->setValue(count); + + QHBoxLayout *countLayout = new QHBoxLayout; + countLayout->addWidget(undoLabel); + countLayout->addWidget(undoCount); + + QVBoxLayout *undoLayout = new QVBoxLayout; + undoLayout->addLayout(countLayout); + undoGroup->setLayout(undoLayout); + return undoGroup; +} diff --git a/src/app/dialogs/app/configpages/patternpage.h b/src/app/dialogs/app/configpages/patternpage.h new file mode 100644 index 000000000..5040c7924 --- /dev/null +++ b/src/app/dialogs/app/configpages/patternpage.h @@ -0,0 +1,56 @@ +/************************************************************************ + ** + ** @file patternpage.h + ** @author Roman Telezhynskyi + ** @date 21 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef PATTERNPAGE_H +#define PATTERNPAGE_H + +#include +#include + +class QCheckBox; +class QSpinBox; +class QGroupBox; +class QLineEdit; + +class PatternPage : public QWidget +{ + Q_OBJECT +public: + PatternPage(QWidget *parent = nullptr); + void Apply(); +private: + Q_DISABLE_COPY(PatternPage) + QLineEdit *userName; + QCheckBox *graphOutputCheck; + QSpinBox *undoCount; + QGroupBox *UserGroup(); + QGroupBox *GraphOutputGroup(); + QGroupBox *UndoGroup(); +}; + +#endif // PATTERNPAGE_H diff --git a/src/app/dialogs/app/pages.cpp b/src/app/dialogs/app/pages.cpp deleted file mode 100644 index 01044635f..000000000 --- a/src/app/dialogs/app/pages.cpp +++ /dev/null @@ -1,512 +0,0 @@ -/************************************************************************ - ** - ** @file pages.cpp - ** @author Roman Telezhynskyi - ** @date 12 2, 2014 - ** - ** @brief - ** @copyright - ** This source code is part of the Valentine project, a pattern making - ** program, whose allow create and modeling patterns of clothing. - ** Copyright (C) 2013 Valentina project - ** All Rights Reserved. - ** - ** Valentina is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** Valentina is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with Valentina. If not, see . - ** - *************************************************************************/ - -#include "pages.h" -#include "../../options.h" -#include "../../widgets/vapplication.h" -#include "../../widgets/vmaingraphicsview.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//--------------------------------------------------------------------------------------------------------------------- -ConfigurationPage::ConfigurationPage(QWidget *parent) - : QWidget(parent), autoSaveCheck(nullptr), autoTime(nullptr), langCombo(nullptr), unitCombo(nullptr), - osOptionCheck(nullptr), langChanged(false), unitChanged(false) -{ - QGroupBox *saveGroup = SaveGroup(); - QGroupBox *langGroup = LangGroup(); - - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addWidget(saveGroup); - mainLayout->addWidget(langGroup); - mainLayout->addStretch(1); - setLayout(mainLayout); -} - -//--------------------------------------------------------------------------------------------------------------------- -void ConfigurationPage::Apply() -{ - QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), - QApplication::applicationName()); - settings.setValue("configuration/autosave/state", autoSaveCheck->isChecked()); - settings.setValue("configuration/autosave/time", autoTime->value()); - - QTimer *autoSaveTimer = qApp->getAutoSaveTimer(); - SCASSERT(autoSaveTimer); - - if (autoSaveCheck->isChecked()) - { - autoSaveTimer->start(autoTime->value()*60000); - } - else - { - autoSaveTimer->stop(); - } - - settings.setValue("configuration/osSeparator", osOptionCheck->isChecked()); - - if (langChanged) - { - QString locale = qvariant_cast(langCombo->itemData(langCombo->currentIndex())); - settings.setValue("configuration/locale", locale); - langChanged = false; - QString text = QString(tr("Setup user interface language updated and will be used the next time start") + " " + - QApplication::applicationName()); - QMessageBox::information(this, QApplication::applicationName(), text); - } - if (this->unitChanged) - { - QString unit = qvariant_cast(this->unitCombo->itemData(this->unitCombo->currentIndex())); - settings.setValue("configuration/unit", unit); - this->unitChanged = false; - QString text = QString(tr("Default unit updated and will be used the next pattern load")); - QMessageBox::information(this, QApplication::applicationName(), text); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -void ConfigurationPage::LangChanged() -{ - langChanged = true; -} - -//--------------------------------------------------------------------------------------------------------------------- -void ConfigurationPage::UnitChanged() -{ - this->unitChanged = true; -} - -//--------------------------------------------------------------------------------------------------------------------- -QGroupBox *ConfigurationPage::SaveGroup() -{ - QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), - QApplication::applicationName()); - - QGroupBox *saveGroup = new QGroupBox(tr("Save")); - - autoSaveCheck = new QCheckBox(tr("Auto-save modified pattern")); - bool autoSaveValue = settings.value("configuration/autosave/state", 1).toBool(); - autoSaveCheck->setChecked(autoSaveValue); - - QLabel *intervalLabel = new QLabel(tr("Interval:")); - - autoTime = new QSpinBox(); - bool ok = true; - qint32 autoTimeValue = settings.value("configuration/autosave/time", 5).toInt(&ok); - if (ok == false) - { - autoTimeValue = 5; - } - autoTime->setRange(1, 60); - autoTime->setValue(autoTimeValue); - autoTime->setSuffix(tr("min")); - - QHBoxLayout *autosaveLayout = new QHBoxLayout; - autosaveLayout->addWidget(autoSaveCheck); - autosaveLayout->addWidget(intervalLabel); - autosaveLayout->addWidget(autoTime); - - QVBoxLayout *saveLayout = new QVBoxLayout; - saveLayout->addLayout(autosaveLayout); - saveGroup->setLayout(saveLayout); - return saveGroup; -} - -//--------------------------------------------------------------------------------------------------------------------- -QGroupBox *ConfigurationPage::LangGroup() -{ - QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), - QApplication::applicationName()); - - QGroupBox *langGroup = new QGroupBox(tr("Language")); - QLabel *guiLabel = new QLabel(tr("GUI language")); - langCombo = new QComboBox; - - // format systems language - QString defaultLocale = QLocale::system().name(); // e.g. "de_DE" - defaultLocale.truncate(defaultLocale.lastIndexOf('_')); // e.g. "de" - QString checkedLocale = settings.value("configuration/locale", defaultLocale).toString(); - - QString m_langPath = qApp->translationsPath(); - QDir dir(m_langPath); - QStringList fileNames = dir.entryList(QStringList("valentina_*.qm")); - - for (int i = 0; i < fileNames.size(); ++i) - { - // get locale extracted by filename - QString locale; - locale = fileNames.at(i); // "valentina_de.qm" - locale.truncate(locale.lastIndexOf('.')); // "valentina_de" - locale.remove(0, locale.indexOf('_') + 1); // "de" - - QString lang = QLocale(locale).nativeLanguageName(); - QIcon ico(QString("%1/%2.png").arg("://icon/flags").arg(locale)); - - langCombo->addItem(ico, lang, locale); - } - - QIcon ico(QString("%1/%2.png").arg("://icon/flags").arg("en")); - QString lang = QLocale("en").nativeLanguageName(); - langCombo->addItem(ico, lang, "en"); - - // set default translators and language checked - qint32 index = langCombo->findData(checkedLocale); - if (index != -1) - { - langCombo->setCurrentIndex(index); - } - connect(langCombo, static_cast(&QComboBox::currentIndexChanged), this, - &ConfigurationPage::LangChanged); - - QHBoxLayout *guiLangLayout = new QHBoxLayout; - guiLangLayout->addWidget(guiLabel); - guiLangLayout->addWidget(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())); - bool osOptionValue = settings.value("configuration/osSeparator", 1).toBool(); - osOptionCheck->setChecked(osOptionValue); - - QHBoxLayout *separatorLayout = new QHBoxLayout; - separatorLayout->addWidget(separatorLabel); - separatorLayout->addWidget(osOptionCheck); - - //----------------------- Unit setup - this->unitCombo = new QComboBox; - QLabel *unitLabel = new QLabel(tr("Default unit")); - - QString checkedUnit = settings.value("configuration/unit", "cm").toString(); - - this->unitCombo->addItem(tr("Centimeters"), "cm"); - this->unitCombo->addItem(tr("Milimiters"), "mm"); - this->unitCombo->addItem(tr("Inches"), "in"); - - // set default unit - qint32 indexUnit = this->unitCombo->findData(checkedUnit); - if (indexUnit != -1) - { - this->unitCombo->setCurrentIndex(indexUnit); - } - connect(this->unitCombo, static_cast(&QComboBox::currentIndexChanged), this, - &ConfigurationPage::UnitChanged); - - QHBoxLayout *UnitLayout = new QHBoxLayout; - UnitLayout->addWidget(unitLabel); - UnitLayout->addWidget(this->unitCombo); - - //----------------------- Unit setup - - QVBoxLayout *langLayout = new QVBoxLayout; - langLayout->addLayout(guiLangLayout); - langLayout->addLayout(separatorLayout); - langLayout->addLayout(UnitLayout); - langGroup->setLayout(langLayout); - - return langGroup; -} - -//--------------------------------------------------------------------------------------------------------------------- -//---------------------- Pattern Class -PatternPage::PatternPage(QWidget *parent): - QWidget(parent), userName(0), graphOutputCheck(0), undoCount(0) -{ - QGroupBox *userGroup = UserGroup(); - QGroupBox *graphOutputGroup = GraphOutputGroup(); - QGroupBox *undoGroup = UndoGroup(); - - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addWidget(userGroup); - mainLayout->addWidget(graphOutputGroup); - mainLayout->addWidget(undoGroup); - mainLayout->addStretch(1); - setLayout(mainLayout); -} - -//--------------------------------------------------------------------------------------------------------------------- -void PatternPage::Apply() -{ - QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), - QApplication::applicationName()); - settings.setValue("pattern/user", userName->text()); - - // Scene antialiasing - settings.setValue("pattern/graphicalOutput", graphOutputCheck->isChecked()); - qApp->getSceneView()->setRenderHint(QPainter::Antialiasing, graphOutputCheck->isChecked()); - qApp->getSceneView()->setRenderHint(QPainter::SmoothPixmapTransform, graphOutputCheck->isChecked()); - - /* Maximum number of commands in undo stack may only be set when the undo stack is empty, since setting it on a - * non-empty stack might delete the command at the current index. Calling setUndoLimit() on a non-empty stack - * prints a warning and does nothing.*/ - settings.setValue("pattern/undo", undoCount->value()); -} - -//--------------------------------------------------------------------------------------------------------------------- -QGroupBox *PatternPage::UserGroup() -{ - QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), - QApplication::applicationName()); - - QGroupBox *userGroup = new QGroupBox(tr("User")); - QLabel *nameLabel = new QLabel(tr("User name")); - - userName = new QLineEdit; -#ifdef Q_OS_WIN - QString user = settings.value("pattern/user", QString::fromLocal8Bit(qgetenv("USERNAME").constData())).toString(); -#else - QString user = settings.value("pattern/user", QString::fromLocal8Bit(qgetenv("USER").constData())).toString(); -#endif - userName->setText(user); - - QHBoxLayout *nameLayout = new QHBoxLayout; - nameLayout->addWidget(nameLabel); - nameLayout->addWidget(userName); - - QVBoxLayout *userLayout = new QVBoxLayout; - userLayout->addLayout(nameLayout); - userGroup->setLayout(userLayout); - return userGroup; -} - -//--------------------------------------------------------------------------------------------------------------------- -QGroupBox *PatternPage::GraphOutputGroup() -{ - QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), - QApplication::applicationName()); - - QGroupBox *graphOutputGroup = new QGroupBox(tr("Graphical output")); - - graphOutputCheck = new QCheckBox(tr("Use antialiasing")); - bool graphOutputValue = settings.value("pattern/graphicalOutput", 1).toBool(); - graphOutputCheck->setChecked(graphOutputValue); - - QHBoxLayout *graphLayout = new QHBoxLayout; - graphLayout->addWidget(graphOutputCheck); - - QVBoxLayout *graphOutputLayout = new QVBoxLayout; - graphOutputLayout->addLayout(graphLayout); - graphOutputGroup->setLayout(graphOutputLayout); - return graphOutputGroup; -} - -//--------------------------------------------------------------------------------------------------------------------- -QGroupBox *PatternPage::UndoGroup() -{ - QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), - QApplication::applicationName()); - - QGroupBox *undoGroup = new QGroupBox(tr("Undo")); - QLabel *undoLabel = new QLabel(tr("Count steps (0 - no limit)")); - undoCount = new QSpinBox; - undoCount->setMinimum(0); - bool ok = true; - qint32 count = settings.value("pattern/undo", 0).toInt(&ok); - if (ok == false) - { - count = 0; - } - undoCount->setValue(count); - - QHBoxLayout *countLayout = new QHBoxLayout; - countLayout->addWidget(undoLabel); - countLayout->addWidget(undoCount); - - QVBoxLayout *undoLayout = new QVBoxLayout; - undoLayout->addLayout(countLayout); - undoGroup->setLayout(undoLayout); - return undoGroup; -} - - -//--------------------------------------------------------------------------------------------------------------------- -//---------------------- Community Class -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) -{ - QGroupBox *serverGroup = ServerGroup(); - QGroupBox *proxyGroup = ProxyGroup(); - QGroupBox *userGroup = UserGroup(); - - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addWidget(serverGroup); - mainLayout->addWidget(userGroup); - mainLayout->addWidget(proxyGroup); - mainLayout->addStretch(1); - setLayout(mainLayout); -} - -//--------------------------------------------------------------------------------------------------------------------- -void CommunityPage::Apply() -{ - QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), - QApplication::applicationName()); - settings.setValue("community/server", this->server->text()); - settings.setValue("community/serverSecure", this->secureComm->isChecked()); - settings.setValue("community/useProxy", this->useProxy->isChecked()); - settings.setValue("community/proxyAddress", this->proxyAddress->text()); - settings.setValue("community/proxyPort", this->proxyPort->text()); - settings.setValue("community/proxyUser", this->proxyUser->text()); - settings.setValue("community/proxyPass", this->proxyPass->text()); - - settings.setValue("community/username", this->username->text()); - settings.setValue("community/savePassword", this->savePassword->isChecked()); - settings.setValue("community/userpassword", this->userpassword->text()); - -} - -//--------------------------------------------------------------------------------------------------------------------- -void CommunityPage::ProxyCheckChanged() -{ - if (this->useProxy->isChecked() == false) - { - this->proxyAddress->setEnabled(false); - this->proxyPort->setEnabled(false); - this->proxyUser->setEnabled(false); - this->proxyPass->setEnabled(false); - } - else - { - this->proxyAddress->setEnabled(true); - this->proxyPort->setEnabled(true); - this->proxyUser->setEnabled(true); - this->proxyPass->setEnabled(true); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -void CommunityPage::PasswordCheckChanged() -{ - this->userpassword->setEnabled(this->savePassword->isChecked()); -} - -//--------------------------------------------------------------------------------------------------------------------- -QGroupBox *CommunityPage::ServerGroup() -{ - QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), - QApplication::applicationName()); - - QGroupBox *ServerGroup = new QGroupBox(tr("Server")); - QFormLayout *serverLayout = new QFormLayout; - - CommunityPage::add_lineedit(&this->server, serverLayout, - settings.value("community/server", "community.valentina-project.org").toString(), tr("Server name/IP")); - - CommunityPage::add_checkbox(&this->secureComm, serverLayout, - settings.value("community/serverSecure", 0).toBool(), tr("Secure connection")); - - ServerGroup->setLayout(serverLayout); - return ServerGroup; -} - -//--------------------------------------------------------------------------------------------------------------------- -void CommunityPage::add_checkbox(QCheckBox** thebox, QFormLayout *layout, bool checked, QString label) -{ - QLabel *labelbox = new QLabel(label); - (*thebox)= new QCheckBox; - (*thebox)->setChecked(checked); - layout->addRow(labelbox, *thebox); -} - -//--------------------------------------------------------------------------------------------------------------------- -void CommunityPage::add_lineedit(QLineEdit** theline, QFormLayout *layout, QString value, QString label) -{ - QLabel *labelbox = new QLabel(label); - (*theline)= new QLineEdit; - (*theline)->setText(value); - layout->addRow(labelbox, *theline); -} - -//--------------------------------------------------------------------------------------------------------------------- -QGroupBox *CommunityPage::ProxyGroup() -{ - QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), - QApplication::applicationName()); - QGroupBox *proxyGroup = new QGroupBox(tr("Proxy settings")); - - QFormLayout *proxyLayout = new QFormLayout; - - CommunityPage::add_checkbox(&this->useProxy, proxyLayout, - settings.value("community/useProxy", 0).toBool(), tr("Use Proxy")); - - CommunityPage::add_lineedit(&this->proxyAddress, proxyLayout, - settings.value("community/proxyAddress", "").toString(), tr("Proxy address")); - - CommunityPage::add_lineedit(&this->proxyPort, proxyLayout, - settings.value("community/proxyPort", "").toString(), tr("Proxy port")); - - CommunityPage::add_lineedit(&this->proxyUser, proxyLayout, - settings.value("community/proxyUser", "").toString(), tr("Proxy user")); - - CommunityPage::add_lineedit(&this->proxyPass, proxyLayout, - settings.value("community/proxyPass", "").toString(), tr("Proxy pass")); - - connect(this->useProxy, &QCheckBox::stateChanged, this, &CommunityPage::ProxyCheckChanged); - this->ProxyCheckChanged(); - - proxyGroup->setLayout(proxyLayout); - - return proxyGroup; -} - -//--------------------------------------------------------------------------------------------------------------------- -QGroupBox *CommunityPage::UserGroup() -{ - QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), - QApplication::applicationName()); - QGroupBox *userGroup = new QGroupBox(tr("User settings")); - QFormLayout *userLayout = new QFormLayout; - - CommunityPage::add_lineedit(&this->username, userLayout, - settings.value("community/username", "").toString(), tr("User Name")); - - CommunityPage::add_checkbox(&this->savePassword, userLayout, - settings.value("community/savePassword", 0).toBool(), tr("Save password")); - - CommunityPage::add_lineedit(&this->userpassword, userLayout, - settings.value("community/userpassword", "").toString(), tr("Password")); - - connect(this->savePassword, &QCheckBox::stateChanged, this, &CommunityPage::PasswordCheckChanged); - this->PasswordCheckChanged(); - - userGroup->setLayout(userLayout); - - return userGroup; -} diff --git a/src/app/dialogs/dialogs.pri b/src/app/dialogs/dialogs.pri index 8bbb24693..225479f43 100644 --- a/src/app/dialogs/dialogs.pri +++ b/src/app/dialogs/dialogs.pri @@ -24,14 +24,17 @@ HEADERS += \ dialogs/app/dialogincrements.h \ dialogs/app/dialoghistory.h \ dialogs/app/configdialog.h \ - dialogs/app/pages.h \ + dialogs/app/configpages/pages.h \ dialogs/app/dialogpatternproperties.h \ dialogs/app/dialogmeasurements.h \ dialogs/app/dialogstandardmeasurements.h \ dialogs/app/dialogindividualmeasurements.h \ dialogs/app/dialogaboutapp.h \ dialogs/tools/dialogeditwrongformula.h \ - dialogs/app/dialogpatternxmledit.h + dialogs/app/dialogpatternxmledit.h \ + dialogs/app/configpages/configurationpage.h \ + dialogs/app/configpages/patternpage.h \ + dialogs/app/configpages/communitypage.h SOURCES += \ dialogs/tools/dialogtriangle.cpp \ @@ -58,14 +61,16 @@ SOURCES += \ dialogs/app/dialogincrements.cpp \ dialogs/app/dialoghistory.cpp \ dialogs/app/configdialog.cpp \ - dialogs/app/pages.cpp \ dialogs/app/dialogpatternproperties.cpp \ dialogs/app/dialogmeasurements.cpp \ dialogs/app/dialogstandardmeasurements.cpp \ dialogs/app/dialogindividualmeasurements.cpp \ dialogs/app/dialogaboutapp.cpp \ dialogs/app/dialogpatternxmledit.cpp \ - dialogs/tools/dialogeditwrongformula.cpp + dialogs/tools/dialogeditwrongformula.cpp \ + dialogs/app/configpages/configurationpage.cpp \ + dialogs/app/configpages/patternpage.cpp \ + dialogs/app/configpages/communitypage.cpp FORMS += \ dialogs/tools/dialogtriangle.ui \ @@ -96,4 +101,4 @@ FORMS += \ dialogs/app/dialogindividualmeasurements.ui \ dialogs/app/dialogaboutapp.ui \ dialogs/app/dialogpatternxmledit.ui \ - dialogs/tools/dialogeditwrongformula.ui + dialogs/tools/dialogeditwrongformula.ui