--HG--
branch : develop
This commit is contained in:
dismine 2014-06-16 15:15:50 +03:00
commit 0101a6f56c
7 changed files with 258 additions and 5 deletions

View File

@ -45,6 +45,8 @@ ConfigDialog::ConfigDialog(QWidget *parent) :
pagesWidget->addWidget(configurationPage);
patternPage = new PatternPage();
pagesWidget->addWidget(patternPage);
communityPage = new CommunityPage();
pagesWidget->addWidget(communityPage);
QPushButton *applyButton = new QPushButton(tr("Apply"));
QPushButton *canselButton = new QPushButton(tr("&Cancel"));
@ -112,6 +114,12 @@ void ConfigDialog::createIcons()
patternButton->setTextAlignment(Qt::AlignHCenter);
patternButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QListWidgetItem *communityButton = new QListWidgetItem(contentsWidget);
communityButton->setIcon(QIcon("://icon/community_config.png"));
communityButton->setText(tr("Community"));
communityButton->setTextAlignment(Qt::AlignHCenter);
communityButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
connect(contentsWidget, &QListWidget::currentItemChanged, this, &ConfigDialog::changePage);
}
@ -126,6 +134,9 @@ void ConfigDialog::Apply()
case (1):
patternPage->Apply();
break;
case (2):
communityPage->Apply();
break;
default:
break;
}

View File

@ -51,6 +51,7 @@ private:
QStackedWidget *pagesWidget;
ConfigurationPage *configurationPage;
PatternPage *patternPage;
CommunityPage *communityPage;
void createIcons();
void Apply();
void Ok();

View File

@ -485,7 +485,7 @@ void DialogPatternXmlEdit::ButtonApplyChangesClicked()
currentChange=currentChange->next;
} while (currentChange != nullptr);
}
QMessageBox::information(this, "Changes (not REALLY applied for now)", Changes);
QMessageBox::information(this, "Changes : ", Changes);
// TODO : clear stack and apply
currentChange=this->changeStackRoot;

View File

@ -33,7 +33,8 @@
//---------------------------------------------------------------------------------------------------------------------
ConfigurationPage::ConfigurationPage(QWidget *parent):
QWidget(parent), autoSaveCheck(0), autoTime(0), langCombo(0), osOptionCheck(0), langChanged(false)
QWidget(parent), autoSaveCheck(nullptr), autoTime(nullptr), langCombo(nullptr), unitCombo(nullptr),
osOptionCheck(nullptr), langChanged(false), unitChanged(false)
{
QGroupBox *saveGroup = SaveGroup();
QGroupBox *langGroup = LangGroup();
@ -76,14 +77,28 @@ void ConfigurationPage::Apply()
QApplication::applicationName());
QMessageBox::information(this, QApplication::applicationName(), text);
}
if (this->unitChanged)
{
QString unit = qvariant_cast<QString>(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::LangChenged()
void ConfigurationPage::LangChanged()
{
langChanged = true;
}
//---------------------------------------------------------------------------------------------------------------------
void ConfigurationPage::UnitChanged()
{
this->unitChanged = true;
}
//---------------------------------------------------------------------------------------------------------------------
QGroupBox *ConfigurationPage::SaveGroup()
{
@ -164,12 +179,13 @@ QGroupBox *ConfigurationPage::LangGroup()
langCombo->setCurrentIndex(index);
}
connect(langCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&ConfigurationPage::LangChenged);
&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()));
@ -180,14 +196,42 @@ QGroupBox *ConfigurationPage::LangGroup()
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<void (QComboBox::*)(int)>(&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)
{
@ -296,3 +340,161 @@ QGroupBox *PatternPage::UndoGroup()
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;
}

View File

@ -44,14 +44,17 @@ public:
ConfigurationPage(QWidget *parent = nullptr);
void Apply();
public slots:
void LangChenged();
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();
};
@ -72,4 +75,39 @@ private:
QGroupBox *UndoGroup();
};
class CommunityPage : public QWidget
{
Q_OBJECT
public:
CommunityPage(QWidget *parent = nullptr);
void Apply();
private:
Q_DISABLE_COPY(CommunityPage)
// server name and https connection
QLineEdit *server;
QCheckBox *secureComm;
// proxy stuff
QCheckBox *useProxy;
QLineEdit *proxyAddress;
QLineEdit *proxyPort;
QLineEdit *proxyUser;
QLineEdit *proxyPass;
// username and password
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);
void ProxyCheckChanged();
void PasswordCheckChanged();
QGroupBox *ServerGroup();
QGroupBox *ProxyGroup();
QGroupBox *UserGroup();
};
#endif // PAGES_H

View File

@ -54,5 +54,6 @@
<file>icon/individual.png</file>
<file>icon/flags/nl.png</file>
<file>icon/flags/it.png</file>
<file>icon/community_config.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB