Refactoring Valentina's preferences dialog.

Instead of manual declaring used Qt Designer.

--HG--
branch : release
This commit is contained in:
Roman Telezhynskyi 2017-04-12 13:31:11 +03:00
parent a1caf972a9
commit 1ee0988f8a
19 changed files with 1354 additions and 1310 deletions

View File

@ -1,221 +0,0 @@
/************************************************************************
**
** @file configdialog.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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-2015 Valentina project
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "configdialog.h"
#include <QListWidget>
#include <QPushButton>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QStackedWidget>
#include <QCloseEvent>
#include "../core/vapplication.h"
//---------------------------------------------------------------------------------------------------------------------
ConfigDialog::ConfigDialog(QWidget *parent) :
QDialog(parent), contentsWidget(nullptr), pagesWidget(nullptr), configurationPage(nullptr), patternPage(nullptr),
pathPage(nullptr), applyButton(nullptr), cancelButton(nullptr), okButton(nullptr),
isInitialized(false)
{
contentsWidget = new QListWidget;
contentsWidget->setViewMode(QListView::IconMode);
contentsWidget->setIconSize(QSize(96, 84));
contentsWidget->setMovement(QListView::Static);
contentsWidget->setMaximumWidth(128);
contentsWidget->setMinimumWidth(128);
contentsWidget->setMinimumHeight(500);
contentsWidget->setSpacing(12);
pagesWidget = new QStackedWidget;
configurationPage = new ConfigurationPage();
pagesWidget->addWidget(configurationPage);
patternPage = new PatternPage();
pagesWidget->addWidget(patternPage);
pathPage = new PathPage();
pagesWidget->addWidget(pathPage);
applyButton = new QPushButton(tr("Apply"));
cancelButton = new QPushButton(tr("&Cancel"));
okButton = new QPushButton(tr("&Ok"));
createIcons();
contentsWidget->setCurrentRow(0);
connect(cancelButton, &QPushButton::clicked, this, &ConfigDialog::close);
connect(applyButton, &QPushButton::clicked, this, &ConfigDialog::Apply);
connect(okButton, &QPushButton::clicked, this, &ConfigDialog::Ok);
QHBoxLayout *horizontalLayout = new QHBoxLayout;
horizontalLayout->addWidget(contentsWidget);
horizontalLayout->addWidget(pagesWidget, 1);
QHBoxLayout *buttonsLayout = new QHBoxLayout;
buttonsLayout->addStretch(1);
buttonsLayout->addWidget(applyButton);
buttonsLayout->addWidget(cancelButton);
buttonsLayout->addWidget(okButton);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(horizontalLayout);
mainLayout->addSpacing(12);
mainLayout->addLayout(buttonsLayout);
mainLayout->setStretch(0, 1);
setLayout(mainLayout);
setWindowTitle(tr("Config Dialog"));
qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
}
//---------------------------------------------------------------------------------------------------------------------
void ConfigDialog::closeEvent(QCloseEvent *event)
{
if (result() == QDialog::Accepted)
{
done(QDialog::Accepted);
}
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)
{
QDialog::showEvent( event );
if ( event->spontaneous() )
{
return;
}
if (isInitialized)
{
return;
}
// do your init stuff here
setMinimumSize(size());
QSize sz = qApp->Settings()->GetPreferenceDialogSize();
if (sz.isEmpty() == false)
{
resize(sz);
}
okButton->setFocus();
isInitialized = true;//first show windows are held
}
//---------------------------------------------------------------------------------------------------------------------
void ConfigDialog::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event)
// remember the size for the next time this dialog is opened, but only
// if widget was already initialized, which rules out the resize at
// dialog creating, which would
if (isInitialized == true)
{
qApp->Settings()->SetPreferenceDialogSize(size());
}
}
//---------------------------------------------------------------------------------------------------------------------
void ConfigDialog::createIcons()
{
createIcon("://icon/config.png", tr("Configuration"));
createIcon("://icon/pattern_config.png", tr("Pattern"));
createIcon("://icon/path_config.png", tr("Paths"));
connect(contentsWidget, &QListWidget::currentItemChanged,
RECEIVER(this)[this](QListWidgetItem *current, QListWidgetItem *previous)
{
if (current == nullptr)
{
current = previous;
}
pagesWidget->setCurrentIndex(contentsWidget->row(current));
});
}
//---------------------------------------------------------------------------------------------------------------------
void ConfigDialog::createIcon(const QString &icon, const QString &text)
{
SCASSERT(contentsWidget != nullptr)
QListWidgetItem *button = new QListWidgetItem(contentsWidget);
button->setIcon(QIcon(icon));
button->setText(text);
button->setTextAlignment(Qt::AlignHCenter);
button->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
}
//---------------------------------------------------------------------------------------------------------------------
void ConfigDialog::Apply()
{
configurationPage->Apply();
patternPage->Apply();
pathPage->Apply();
qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
emit UpdateProperties();
setResult(QDialog::Accepted);
}
//---------------------------------------------------------------------------------------------------------------------
void ConfigDialog::Ok()
{
Apply();
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("Paths"));
}

View File

@ -1,496 +0,0 @@
/************************************************************************
**
** @file configurationpage.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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-2015 Valentina project
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "configurationpage.h"
#include "../../options.h"
#include "../../core/vapplication.h"
#include "../vmisc/vsettings.h"
#include <QDir>
#include <QGroupBox>
#include <QLabel>
#include <QSettings>
#include <QTimer>
#include <QSpinBox>
#include <QComboBox>
#include <QMessageBox>
#include <QCheckBox>
#include <QIcon>
#include <QVBoxLayout>
#include <QDirIterator>
#include <QFormLayout>
#include <QPushButton>
//---------------------------------------------------------------------------------------------------------------------
ConfigurationPage::ConfigurationPage(QWidget *parent)
: QWidget(parent),
autoSaveCheck(nullptr),
autoTime(nullptr),
langCombo(nullptr),
labelCombo(nullptr),
unitCombo(nullptr),
osOptionCheck(nullptr),
langChanged(false),
systemChanged(),
unitChanged(false),
labelLangChanged(false),
sendReportCheck(nullptr),
resetWarningsButton(nullptr),
toolBarStyleCheck(nullptr),
saveGroup(nullptr),
intervalLabel(nullptr),
langGroup(nullptr),
guiLabel(nullptr),
separatorLabel(nullptr),
unitLabel(nullptr),
languageLabel(nullptr),
pmSystemGroup(nullptr),
systemLabel(nullptr),
systemCombo(nullptr),
systemAuthorLabel(nullptr),
systemBookLabel(nullptr),
systemAuthorValueLabel(nullptr),
systemBookValueLabel(nullptr),
sendGroup(nullptr),
description(nullptr),
drawGroup(nullptr),
toolBarGroup(nullptr)
{
QGroupBox *saveGroup = SaveGroup();
QGroupBox *langGroup = LangGroup();
QGroupBox *pmSystemGroup = PMSystemGroup();
QGroupBox *sendGroup = SendGroup();
QGroupBox *drawGroup = DrawGroup();
QGroupBox *toolBarGroup = ToolBarGroup();
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(saveGroup);
mainLayout->addWidget(langGroup);
mainLayout->addWidget(pmSystemGroup);
mainLayout->addWidget(sendGroup);
mainLayout->addWidget(drawGroup);
mainLayout->addWidget(toolBarGroup);
mainLayout->addStretch(1);
setLayout(mainLayout);
}
//---------------------------------------------------------------------------------------------------------------------
void ConfigurationPage::Apply()
{
VSettings *settings = qApp->ValentinaSettings();
settings->SetAutosaveState(autoSaveCheck->isChecked());
settings->SetAutosaveTime(autoTime->value());
QTimer *autoSaveTimer = qApp->getAutoSaveTimer();
SCASSERT(autoSaveTimer)
autoSaveCheck->isChecked() ? autoSaveTimer->start(autoTime->value()*60000) : autoSaveTimer->stop();
settings->SetOsSeparator(osOptionCheck->isChecked());
settings->SetSendReportState(sendReportCheck->isChecked());
settings->SetToolBarStyle(toolBarStyleCheck->isChecked());
if (langChanged || systemChanged)
{
const QString locale = qvariant_cast<QString>(langCombo->itemData(langCombo->currentIndex()));
settings->SetLocale(locale);
langChanged = false;
const QString code = qvariant_cast<QString>(systemCombo->itemData(systemCombo->currentIndex()));
settings->SetPMSystemCode(code);
systemChanged = false;
qApp->LoadTranslation(locale);
}
if (this->unitChanged)
{
const QString unit = qvariant_cast<QString>(this->unitCombo->itemData(this->unitCombo->currentIndex()));
settings->SetUnit(unit);
this->unitChanged = false;
const QString text = tr("The Default unit has been updated and will be used as the default for the next "
"pattern you create.");
QMessageBox::information(this, QApplication::applicationName(), text);
}
if (labelLangChanged)
{
const QString locale = qvariant_cast<QString>(labelCombo->itemData(labelCombo->currentIndex()));
settings->SetLabelLanguage(locale);
labelLangChanged = false;
}
}
//---------------------------------------------------------------------------------------------------------------------
void ConfigurationPage::LangChanged()
{
langChanged = true;
}
//---------------------------------------------------------------------------------------------------------------------
void ConfigurationPage::UnitChanged()
{
this->unitChanged = true;
}
//---------------------------------------------------------------------------------------------------------------------
void ConfigurationPage::LabelLangChanged()
{
labelLangChanged = true;
}
//---------------------------------------------------------------------------------------------------------------------
QGroupBox *ConfigurationPage::SaveGroup()
{
saveGroup = new QGroupBox(tr("Save"));
autoSaveCheck = new QCheckBox(tr("Auto-save modified pattern"));
autoSaveCheck->setChecked(qApp->ValentinaSettings()->GetAutosaveState());
autoTime = new QSpinBox();
autoTime->setRange(1, 60);
autoTime->setValue(qApp->ValentinaSettings()->GetAutosaveTime());
autoTime->setSuffix(tr("min"));
QHBoxLayout *autosaveLayout = new QHBoxLayout;
autosaveLayout->addWidget(autoSaveCheck);
intervalLabel = new QLabel(tr("Interval:"));
autosaveLayout->addWidget(intervalLabel);
autosaveLayout->addWidget(autoTime);
QVBoxLayout *saveLayout = new QVBoxLayout;
saveLayout->addLayout(autosaveLayout);
saveGroup->setLayout(saveLayout);
return saveGroup;
}
//---------------------------------------------------------------------------------------------------------------------
QGroupBox *ConfigurationPage::LangGroup()
{
langGroup = new QGroupBox(tr("Language"));
guiLabel = new QLabel(tr("GUI language:"));
langCombo = new QComboBox;
QStringList fileNames;
QDirIterator it(qApp->translationsPath(), QStringList() << QStringList("valentina_*.qm"), QDir::Files,
QDirIterator::Subdirectories);
while (it.hasNext())
{
it.next();
fileNames.append(it.fileName());
}
bool englishUS = false;
const QString en_US = QStringLiteral("en_US");
for (int i = 0; i < fileNames.size(); ++i)
{
// get locale extracted by filename
QString locale;
locale = fileNames.at(i); // "valentina_de_De.qm"
locale.truncate(locale.lastIndexOf('.')); // "valentina_de_De"
locale.remove(0, locale.indexOf('_') + 1); // "de_De"
if (not englishUS)
{
englishUS = (en_US == locale);
}
QLocale loc = QLocale(locale);
QString lang = loc.nativeLanguageName();
QIcon ico(QString("%1/%2.png").arg("://flags").arg(QLocale::countryToString(loc.country())));
langCombo->addItem(ico, lang, locale);
}
if (langCombo->count() == 0 || not englishUS)
{
// English language is internal and doens't have own *.qm file.
QIcon ico(QString("%1/%2.png").arg("://flags").arg(QLocale::countryToString(QLocale::UnitedStates)));
QString lang = QLocale(en_US).nativeLanguageName();
langCombo->addItem(ico, lang, en_US);
}
// set default translators and language checked
const VSettings *settings = qApp->ValentinaSettings();
qint32 index = langCombo->findData(settings->GetLocale());
if (index != -1)
{
langCombo->setCurrentIndex(index);
}
connect(langCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&ConfigurationPage::LangChanged);
QFormLayout *langLayout = new QFormLayout;
langLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
langLayout->addRow(guiLabel, langCombo);
//-------------------- Decimal separator setup
separatorLabel = new QLabel(tr("Decimal separator parts:"));
osOptionCheck = new QCheckBox(tr("With OS options (%1)").arg(QLocale().decimalPoint()));
osOptionCheck->setChecked(settings->GetOsSeparator());
langLayout->addRow(separatorLabel, osOptionCheck);
//----------------------- Unit setup
this->unitCombo = new QComboBox;
this->unitCombo->addItem(tr("Centimeters"), "cm");
this->unitCombo->addItem(tr("Millimiters"), "mm");
this->unitCombo->addItem(tr("Inches"), "in");
// set default unit
const qint32 indexUnit = this->unitCombo->findData(settings->GetUnit());
if (indexUnit != -1)
{
this->unitCombo->setCurrentIndex(indexUnit);
}
connect(this->unitCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&ConfigurationPage::UnitChanged);
unitLabel = new QLabel(tr("Default unit:"));
langLayout->addRow(unitLabel, this->unitCombo);
//----------------------- Label language
labelCombo = new QComboBox;
SetLabelComboBox(VApplication::LabelLanguages());
index = labelCombo->findData(settings->GetLabelLanguage());
if (index != -1)
{
labelCombo->setCurrentIndex(index);
}
connect(labelCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&ConfigurationPage::LabelLangChanged);
languageLabel = new QLabel(tr("Label language:"));
langLayout->addRow(languageLabel, labelCombo);
langGroup->setLayout(langLayout);
return langGroup;
}
//---------------------------------------------------------------------------------------------------------------------
QGroupBox *ConfigurationPage::PMSystemGroup()
{
pmSystemGroup = new QGroupBox(tr("Pattern making system"));
systemLabel = new QLabel(tr("Pattern making system:"));
systemCombo = new QComboBox;
InitPMSystems(systemCombo);
QFormLayout *pmSystemLayout = new QFormLayout;
pmSystemLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
pmSystemLayout->addRow(systemLabel, systemCombo);
//----
systemAuthorLabel = new QLabel(tr("Author:"));
systemAuthorValueLabel = new QLabel("");
pmSystemLayout->addRow(systemAuthorLabel, systemAuthorValueLabel);
//----
systemBookLabel = new QLabel(tr("Book:"));
systemBookValueLabel = new QPlainTextEdit("");
systemBookValueLabel->setReadOnly(true);
systemBookValueLabel->setFixedHeight(4 * QFontMetrics(systemBookValueLabel->font()).lineSpacing());
pmSystemLayout->addRow(systemBookLabel, systemBookValueLabel);
connect(systemCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&ConfigurationPage::SystemChanged);
// set default pattern making system
const VSettings *settings = qApp->ValentinaSettings();
const int index = systemCombo->findData(settings->GetPMSystemCode());
if (index != -1)
{
systemCombo->setCurrentIndex(index);
}
pmSystemGroup->setLayout(pmSystemLayout);
return pmSystemGroup;
}
//---------------------------------------------------------------------------------------------------------------------
QGroupBox *ConfigurationPage::SendGroup()
{
sendGroup = new QGroupBox(tr("Send crash reports"));
sendReportCheck = new QCheckBox(tr("Send crash reports (recommended)"));
sendReportCheck->setChecked(qApp->ValentinaSettings()->GetSendReportState());
description = new QLabel(tr("After each crash Valentina collects information that may help us fix the "
"problem. We do not collect any personal information. Find more about what %1"
"kind of information%2 we collect.")
.arg("<a href=\"https://wiki.valentinaproject.org/wiki/UserManual:Crash_reports\">")
.arg("</a>"));
description->setTextFormat(Qt::RichText);
description->setTextInteractionFlags(Qt::TextBrowserInteraction);
description->setOpenExternalLinks(true);
description->setWordWrap(true);
QVBoxLayout *sendLayout = new QVBoxLayout;
sendLayout->addWidget(sendReportCheck);
sendLayout->addWidget(description);
sendGroup->setLayout(sendLayout);
return sendGroup;
}
//---------------------------------------------------------------------------------------------------------------------
QGroupBox *ConfigurationPage::DrawGroup()
{
drawGroup = new QGroupBox(tr("Pattern Editing"));
resetWarningsButton = new QPushButton(tr("Reset warnings"));
QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(resetWarningsButton->sizePolicy().hasHeightForWidth());
resetWarningsButton->setSizePolicy(sizePolicy);
connect(resetWarningsButton, &QPushButton::released, this, &ConfigurationPage::ResetWarnings);
QVBoxLayout *editLayout = new QVBoxLayout;
editLayout->addWidget(resetWarningsButton);
drawGroup->setLayout(editLayout);
return drawGroup;
}
//---------------------------------------------------------------------------------------------------------------------
QGroupBox *ConfigurationPage::ToolBarGroup()
{
toolBarGroup = new QGroupBox(tr("Toolbar"));
toolBarStyleCheck = new QCheckBox(tr("The text appears under the icon (recommended for beginners)."));
toolBarStyleCheck->setChecked(qApp->ValentinaSettings()->GetToolBarStyle());
QVBoxLayout *editLayout = new QVBoxLayout;
editLayout->addWidget(toolBarStyleCheck);
toolBarGroup->setLayout(editLayout);
return toolBarGroup;
}
//---------------------------------------------------------------------------------------------------------------------
void ConfigurationPage::SystemChanged()
{
systemChanged = true;
QString text = qApp->TrVars()->PMSystemAuthor(CURRENT_DATA(systemCombo).toString());
systemAuthorValueLabel->setText(text);
systemAuthorValueLabel->setToolTip(text);
text = qApp->TrVars()->PMSystemBook(CURRENT_DATA(systemCombo).toString());
systemBookValueLabel->setPlainText(text);
}
//---------------------------------------------------------------------------------------------------------------------
void ConfigurationPage::SetLabelComboBox(const QStringList &list)
{
for (int i = 0; i < list.size(); ++i)
{
QLocale loc = QLocale(list.at(i));
labelCombo->addItem(loc.nativeLanguageName(), list.at(i));
}
}
//---------------------------------------------------------------------------------------------------------------------
void ConfigurationPage::changeEvent(QEvent *event)
{
if (event->type() == QEvent::LanguageChange)
{
// retranslate designer form (single inheritance approach)
RetranslateUi();
}
// remember to call base class implementation
QWidget::changeEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void ConfigurationPage::ResetWarnings()
{
VSettings *settings = qApp->ValentinaSettings();
settings->SetConfirmItemDelete(true);
settings->SetConfirmFormatRewriting(true);
}
//---------------------------------------------------------------------------------------------------------------------
void ConfigurationPage::RetranslateUi()
{
toolBarStyleCheck->setText(tr("The text appears under the icon (recommended for beginners)."));
resetWarningsButton->setText(tr("Reset warnings"));
saveGroup->setTitle(tr("Save"));
autoSaveCheck->setText(tr("Auto-save modified pattern"));
autoTime->setSuffix(tr("min"));
intervalLabel->setText(tr("Interval:"));
langGroup->setTitle(tr("Language"));
guiLabel->setText(tr("GUI language:"));
separatorLabel->setText(tr("Decimal separator parts:"));
osOptionCheck->setText(tr("With OS options (%1)").arg(QLocale().decimalPoint()));
unitLabel->setText(tr("Default unit:"));
this->unitCombo->setItemText(0, tr("Centimeters"));
this->unitCombo->setItemText(1, tr("Millimiters"));
this->unitCombo->setItemText(2, tr("Inches"));
languageLabel->setText(tr("Label language:"));
pmSystemGroup->setTitle(tr("Pattern making system"));
systemLabel->setText(tr("Pattern making system:"));
const int index = systemCombo->currentIndex();
systemCombo->blockSignals(true);
systemCombo->clear();
InitPMSystems(systemCombo);
systemCombo->setCurrentIndex(index);
systemCombo->blockSignals(false);
systemAuthorLabel->setText(tr("Author:"));
systemBookLabel->setText(tr("Book:"));
QString text = qApp->TrVars()->PMSystemAuthor(CURRENT_DATA(systemCombo).toString());
systemAuthorValueLabel->setText(text);
systemAuthorValueLabel->setToolTip(text);
text = qApp->TrVars()->PMSystemBook(CURRENT_DATA(systemCombo).toString());
systemBookValueLabel->setPlainText(text);
sendGroup->setTitle(tr("Send crash reports"));
sendReportCheck->setText(tr("Send crash reports (recommended)"));
description->setText(tr("After each crash Valentina collects information that may help us fix the "
"problem. We do not collect any personal information. Find more about what "
"<a href=\"https://bitbucket.org/dismine/valentina/wiki/manual/"
"Crash_reports\">kind of information</a> we collect."));
drawGroup->setTitle(tr("Pattern Editing"));
resetWarningsButton->setText(tr("Confirm item deletion"));
toolBarGroup->setTitle(tr("Toolbar"));
toolBarStyleCheck->setText(tr("The text appears under the icon (recommended for beginners)."));
}

View File

@ -1,107 +0,0 @@
/************************************************************************
**
** @file configurationpage.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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-2015 Valentina project
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef CONFIGURATIONPAGE_H
#define CONFIGURATIONPAGE_H
#include <QObject>
#include <QPlainTextEdit>
#include <QPushButton>
#include <QWidget>
class QCheckBox;
class QSpinBox;
class QComboBox;
class QGroupBox;
class QLabel;
class ConfigurationPage : public QWidget
{
Q_OBJECT
public:
explicit ConfigurationPage(QWidget *parent = nullptr);
void Apply();
public slots:
void LangChanged();
void SystemChanged();
void UnitChanged();
void LabelLangChanged();
protected:
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
private slots:
void ResetWarnings();
private:
Q_DISABLE_COPY(ConfigurationPage)
QCheckBox *autoSaveCheck;
QSpinBox *autoTime;
QComboBox *langCombo;
QComboBox *labelCombo;
QComboBox *unitCombo;
QCheckBox *osOptionCheck;
bool langChanged;
bool systemChanged;
bool unitChanged;
bool labelLangChanged;
QCheckBox *sendReportCheck;
QPushButton *resetWarningsButton;
QCheckBox *toolBarStyleCheck;
QGroupBox *saveGroup;
QLabel *intervalLabel;
QGroupBox *langGroup;
QLabel *guiLabel;
QLabel *separatorLabel;
QLabel *unitLabel;
QLabel *languageLabel;
QGroupBox *pmSystemGroup;
QLabel *systemLabel;
QComboBox *systemCombo;
QLabel *systemAuthorLabel;
QLabel *systemBookLabel;
QLabel *systemAuthorValueLabel;
QPlainTextEdit *systemBookValueLabel;
QGroupBox *sendGroup;
QLabel *description;
QGroupBox *drawGroup;
QGroupBox *toolBarGroup;
QGroupBox *SaveGroup() Q_REQUIRED_RESULT;
QGroupBox *LangGroup() Q_REQUIRED_RESULT;
QGroupBox *PMSystemGroup() Q_REQUIRED_RESULT;
QGroupBox *SendGroup() Q_REQUIRED_RESULT;
QGroupBox *DrawGroup() Q_REQUIRED_RESULT;
QGroupBox *ToolBarGroup() Q_REQUIRED_RESULT;
void SetLabelComboBox(const QStringList &list);
void RetranslateUi();
};
#endif // CONFIGURATIONPAGE_H

View File

@ -1,242 +0,0 @@
/************************************************************************
**
** @file patternpage.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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-2015 Valentina project
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "patternpage.h"
#include "../../options.h"
#include "../../core/vapplication.h"
#include "../vmisc/vsettings.h"
#include "../vwidgets/vmaingraphicsview.h"
#include "../ifc/xml/vabstractpattern.h"
#include <QGroupBox>
#include <QLabel>
#include <QSettings>
#include <QCheckBox>
#include <QSpinBox>
#include <QLineEdit>
#include <QVBoxLayout>
#include <QFormLayout>
#include <QMessageBox>
#include <QPushButton>
//---------------------------------------------------------------------------------------------------------------------
PatternPage::PatternPage(QWidget *parent):
QWidget(parent),
userGroup(nullptr),
userName(nullptr),
userNameLabel(nullptr),
graphOutputGroup(nullptr),
graphOutputCheck(nullptr),
undoGroup(nullptr),
undoCount(nullptr),
countStepsLabel(nullptr),
userMaterialsGroup(nullptr),
userMaterialClearButton(nullptr),
workpieceGroup(nullptr),
forbidFlippingCheck(nullptr),
doublePassmarkCheck(nullptr)
{
QGroupBox *userGroup = UserGroup();
QGroupBox *graphOutputGroup = GraphOutputGroup();
QGroupBox *undoGroup = UndoGroup();
QGroupBox *userMatGroup = UserMaterialGroup();
QGroupBox *workpieceGroup = UserWorkpieceGroup();
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(userGroup);
mainLayout->addWidget(graphOutputGroup);
mainLayout->addWidget(undoGroup);
mainLayout->addWidget(userMatGroup);
mainLayout->addWidget(workpieceGroup);
mainLayout->addStretch(1);
setLayout(mainLayout);
}
//---------------------------------------------------------------------------------------------------------------------
void PatternPage::Apply()
{
VSettings *settings = qApp->ValentinaSettings();
settings->SetUser(userName->text());
// Scene antialiasing
settings->SetGraphicalOutput(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->SetUndoCount(undoCount->value());
settings->SetForbidWorkpieceFlipping(forbidFlippingCheck->isChecked());
if (settings->IsDoublePassmark() != doublePassmarkCheck->isChecked())
{
settings->SetDoublePassmark(doublePassmarkCheck->isChecked());
qApp->getCurrentDocument()->LiteParseTree(Document::LiteParse);
}
}
//---------------------------------------------------------------------------------------------------------------------
void PatternPage::ClearUserDefinedMaterials()
{
VSettings* pSet = qApp->ValentinaSettings();
pSet->ClearUserDefinedMaterial();
pSet->sync();
QString qsMsg = tr("All user defined materials have been deleted!");
QMessageBox::information(this, QApplication::applicationName(), qsMsg);
}
//---------------------------------------------------------------------------------------------------------------------
void PatternPage::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 *PatternPage::UserGroup()
{
userGroup = new QGroupBox(tr("User"));
userName = new QLineEdit;
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
userName->setClearButtonEnabled(true);
#endif
userName->setText(qApp->ValentinaSettings()->GetUser());
QFormLayout *nameLayout = new QFormLayout;
userNameLabel = new QLabel(tr("User name:"));
nameLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
nameLayout->addRow(userNameLabel, userName);
QVBoxLayout *userLayout = new QVBoxLayout;
userLayout->addLayout(nameLayout);
userGroup->setLayout(userLayout);
return userGroup;
}
//---------------------------------------------------------------------------------------------------------------------
QGroupBox *PatternPage::GraphOutputGroup()
{
graphOutputGroup = new QGroupBox(tr("Graphical output"));
graphOutputCheck = new QCheckBox(tr("Use antialiasing"));
graphOutputCheck->setChecked(qApp->ValentinaSettings()->GetGraphicalOutput());
QHBoxLayout *graphLayout = new QHBoxLayout;
graphLayout->addWidget(graphOutputCheck);
QVBoxLayout *graphOutputLayout = new QVBoxLayout;
graphOutputLayout->addLayout(graphLayout);
graphOutputGroup->setLayout(graphOutputLayout);
return graphOutputGroup;
}
//---------------------------------------------------------------------------------------------------------------------
QGroupBox *PatternPage::UndoGroup()
{
undoGroup = new QGroupBox(tr("Undo"));
undoCount = new QSpinBox;
undoCount->setMinimum(0);
undoCount->setValue(qApp->ValentinaSettings()->GetUndoCount());
QFormLayout *countLayout = new QFormLayout;
countStepsLabel = new QLabel(tr("Count steps (0 - no limit):"));
countLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
countLayout->addRow(countStepsLabel, undoCount);
QVBoxLayout *undoLayout = new QVBoxLayout;
undoLayout->addLayout(countLayout);
undoGroup->setLayout(undoLayout);
return undoGroup;
}
//---------------------------------------------------------------------------------------------------------------------
QGroupBox *PatternPage::UserMaterialGroup()
{
userMaterialsGroup = new QGroupBox(tr("User defined materials"));
userMaterialClearButton = new QPushButton(tr("Delete all"));
connect(userMaterialClearButton, &QPushButton::clicked, this, &PatternPage::ClearUserDefinedMaterials);
QHBoxLayout* pLayout = new QHBoxLayout;
pLayout->addWidget(userMaterialClearButton);
pLayout->addStretch(1);
userMaterialsGroup->setLayout(pLayout);
return userMaterialsGroup;
}
//---------------------------------------------------------------------------------------------------------------------
QGroupBox *PatternPage::UserWorkpieceGroup()
{
workpieceGroup = new QGroupBox(tr("Workpiece"));
forbidFlippingCheck = new QCheckBox(tr("Forbid flipping"));
forbidFlippingCheck->setToolTip(tr("By default forbid flipping for all new created workpieces"));
forbidFlippingCheck->setChecked(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping());
doublePassmarkCheck = new QCheckBox(tr("Show second passmark on seam line"));
doublePassmarkCheck->setToolTip(tr("Show a passmark both in the seam allowance and on the seam line."));
doublePassmarkCheck->setChecked(qApp->ValentinaSettings()->IsDoublePassmark());
QVBoxLayout *editLayout = new QVBoxLayout;
editLayout->addWidget(forbidFlippingCheck);
editLayout->addWidget(doublePassmarkCheck);
workpieceGroup->setLayout(editLayout);
return workpieceGroup;
}
//---------------------------------------------------------------------------------------------------------------------
void PatternPage::RetranslateUi()
{
userGroup->setTitle(tr("User"));
userNameLabel->setText(tr("User name:"));
graphOutputGroup->setTitle(tr("Graphical output"));
graphOutputCheck->setText(tr("Use antialiasing"));
undoGroup->setTitle(tr("Undo"));
countStepsLabel->setText(tr("Count steps (0 - no limit):"));
userMaterialsGroup->setTitle(tr("User defined materials"));
userMaterialClearButton->setText(tr("Delete all"));
workpieceGroup->setTitle(tr("Workpiece"));
forbidFlippingCheck->setText(tr("Forbid flipping"));
forbidFlippingCheck->setToolTip(tr("By default forbid flipping for all new created workpieces"));
doublePassmarkCheck->setText(tr("Show second passmark on seam line"));
doublePassmarkCheck->setToolTip(tr("Show a passmark both in the seam allowance and on the seam line."));
}

View File

@ -0,0 +1,268 @@
/************************************************************************
**
** @file preferencesconfigurationpage.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 4, 2017
**
** @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) 2017 Valentina project
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "preferencesconfigurationpage.h"
#include "ui_preferencesconfigurationpage.h"
#include "../../core/vapplication.h"
#include <QDir>
#include <QDirIterator>
#include <QMessageBox>
#include <QTimer>
//---------------------------------------------------------------------------------------------------------------------
PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
: QWidget(parent),
ui(new Ui::PreferencesConfigurationPage),
m_langChanged(false),
m_systemChanged(),
m_unitChanged(false),
m_labelLangChanged(false)
{
ui->setupUi(this);
ui->autoSaveCheck->setChecked(qApp->ValentinaSettings()->GetAutosaveState());
InitLanguages();
connect(ui->langCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [this]()
{
m_langChanged = true;
});
//-------------------- Decimal separator setup
ui->osOptionCheck->setText(tr("With OS options") + QString(" (%1)").arg(QLocale().decimalPoint()));
ui->osOptionCheck->setChecked(qApp->ValentinaSettings()->GetOsSeparator());
//----------------------- Unit setup
InitUnits();
connect(ui->unitCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [this]()
{
m_unitChanged = true;
});
//----------------------- Label language
SetLabelComboBox(VApplication::LabelLanguages());
int index = ui->labelCombo->findData(qApp->ValentinaSettings()->GetLabelLanguage());
if (index != -1)
{
ui->labelCombo->setCurrentIndex(index);
}
connect(ui->labelCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [this]()
{
m_labelLangChanged = true;
});
//---------------------- Pattern making system
InitPMSystems(ui->systemCombo);
ui->systemBookValueLabel->setFixedHeight(4 * QFontMetrics(ui->systemBookValueLabel->font()).lineSpacing());
connect(ui->systemCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [this]()
{
m_systemChanged = true;
QString text = qApp->TrVars()->PMSystemAuthor(CURRENT_DATA(ui->systemCombo).toString());
ui->systemAuthorValueLabel->setText(text);
ui->systemAuthorValueLabel->setToolTip(text);
text = qApp->TrVars()->PMSystemBook(CURRENT_DATA(ui->systemCombo).toString());
ui->systemBookValueLabel->setPlainText(text);
});
// set default pattern making system
index = ui->systemCombo->findData(qApp->ValentinaSettings()->GetPMSystemCode());
if (index != -1)
{
ui->systemCombo->setCurrentIndex(index);
}
//---------------------- Send crash reports
ui->sendReportCheck->setChecked(qApp->ValentinaSettings()->GetSendReportState());
ui->description = new QLabel(tr("After each crash Valentina collects information that may help us fix the "
"problem. We do not collect any personal information. Find more about what %1"
"kind of information%2 we collect.")
.arg("<a href=\"https://wiki.valentinaproject.org/wiki/UserManual:Crash_reports\">")
.arg("</a>"));
//----------------------------- Pattern Editing
connect(ui->resetWarningsButton, &QPushButton::released, []()
{
VSettings *settings = qApp->ValentinaSettings();
settings->SetConfirmItemDelete(true);
settings->SetConfirmFormatRewriting(true);
});
//----------------------- Toolbar
ui->toolBarStyleCheck->setChecked(qApp->ValentinaSettings()->GetToolBarStyle());
}
//---------------------------------------------------------------------------------------------------------------------
PreferencesConfigurationPage::~PreferencesConfigurationPage()
{
delete ui;
}
//---------------------------------------------------------------------------------------------------------------------
void PreferencesConfigurationPage::Apply()
{
VSettings *settings = qApp->ValentinaSettings();
settings->SetAutosaveState(ui->autoSaveCheck->isChecked());
settings->SetAutosaveTime(ui->autoTime->value());
QTimer *autoSaveTimer = qApp->getAutoSaveTimer();
SCASSERT(autoSaveTimer)
ui->autoSaveCheck->isChecked() ? autoSaveTimer->start(ui->autoTime->value()*60000) : autoSaveTimer->stop();
settings->SetOsSeparator(ui->osOptionCheck->isChecked());
settings->SetSendReportState(ui->sendReportCheck->isChecked());
settings->SetToolBarStyle(ui->toolBarStyleCheck->isChecked());
if (m_langChanged || m_systemChanged)
{
const QString locale = qvariant_cast<QString>(ui->langCombo->currentData());
settings->SetLocale(locale);
m_langChanged = false;
const QString code = qvariant_cast<QString>(ui->systemCombo->currentData());
settings->SetPMSystemCode(code);
m_systemChanged = false;
qApp->LoadTranslation(locale);
}
if (m_unitChanged)
{
const QString unit = qvariant_cast<QString>(ui->unitCombo->currentData());
settings->SetUnit(unit);
m_unitChanged = false;
const QString text = tr("The Default unit has been updated and will be used as the default for the next "
"pattern you create.");
QMessageBox::information(this, QApplication::applicationName(), text);
}
if (m_labelLangChanged)
{
const QString locale = qvariant_cast<QString>(ui->labelCombo->currentData());
settings->SetLabelLanguage(locale);
m_labelLangChanged = false;
}
}
//---------------------------------------------------------------------------------------------------------------------
void PreferencesConfigurationPage::changeEvent(QEvent *event)
{
if (event->type() == QEvent::LanguageChange)
{
// retranslate designer form (single inheritance approach)
RetranslateUi();
}
// remember to call base class implementation
QWidget::changeEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void PreferencesConfigurationPage::SetLabelComboBox(const QStringList &list)
{
for (int i = 0; i < list.size(); ++i)
{
QLocale loc = QLocale(list.at(i));
ui->labelCombo->addItem(loc.nativeLanguageName(), list.at(i));
}
}
//---------------------------------------------------------------------------------------------------------------------
void PreferencesConfigurationPage::InitLanguages()
{
QStringList fileNames;
QDirIterator it(qApp->translationsPath(), QStringList("valentina_*.qm"), QDir::Files, QDirIterator::Subdirectories);
while (it.hasNext())
{
it.next();
fileNames.append(it.fileName());
}
bool englishUS = false;
const QString en_US = QStringLiteral("en_US");
for (int i = 0; i < fileNames.size(); ++i)
{
// get locale extracted by filename
QString locale;
locale = fileNames.at(i); // "valentina_de_De.qm"
locale.truncate(locale.lastIndexOf('.')); // "valentina_de_De"
locale.remove(0, locale.indexOf('_') + 1); // "de_De"
if (not englishUS)
{
englishUS = (en_US == locale);
}
QLocale loc = QLocale(locale);
QString lang = loc.nativeLanguageName();
QIcon ico(QString("%1/%2.png").arg("://flags").arg(QLocale::countryToString(loc.country())));
ui->langCombo->addItem(ico, lang, locale);
}
if (ui->langCombo->count() == 0 || not englishUS)
{
// English language is internal and doens't have own *.qm file.
QIcon ico(QString("%1/%2.png").arg("://flags").arg(QLocale::countryToString(QLocale::UnitedStates)));
QString lang = QLocale(en_US).nativeLanguageName();
ui->langCombo->addItem(ico, lang, en_US);
}
// set default translators and language checked
qint32 index = ui->langCombo->findData(qApp->ValentinaSettings()->GetLocale());
if (index != -1)
{
ui->langCombo->setCurrentIndex(index);
}
}
//---------------------------------------------------------------------------------------------------------------------
void PreferencesConfigurationPage::InitUnits()
{
ui->unitCombo->addItem(tr("Centimeters"), "cm");
ui->unitCombo->addItem(tr("Millimiters"), "mm");
ui->unitCombo->addItem(tr("Inches"), "in");
// set default unit
const qint32 indexUnit = ui->unitCombo->findData(qApp->ValentinaSettings()->GetUnit());
if (indexUnit != -1)
{
ui->unitCombo->setCurrentIndex(indexUnit);
}
}
//---------------------------------------------------------------------------------------------------------------------
void PreferencesConfigurationPage::RetranslateUi()
{
ui->osOptionCheck->setText(tr("With OS options") + QString(" (%1)").arg(QLocale().decimalPoint()));
ui->description->setText(tr("After each crash Valentina collects information that may help us fix the "
"problem. We do not collect any personal information. Find more about what %1"
"kind of information%2 we collect.")
.arg("<a href=\"https://wiki.valentinaproject.org/wiki/UserManual:Crash_reports\">")
.arg("</a>"));
}

View File

@ -1,14 +1,14 @@
/************************************************************************
**
** @file patternpage.h
** @file preferencesconfigurationpage.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 21 6, 2014
** @date 12 4, 2017
**
** @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-2015 Valentina project
** Copyright (C) 2017 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
@ -26,52 +26,41 @@
**
*************************************************************************/
#ifndef PATTERNPAGE_H
#define PATTERNPAGE_H
#ifndef PREFERENCESCONFIGURATIONPAGE_H
#define PREFERENCESCONFIGURATIONPAGE_H
#include <QObject>
#include <QWidget>
class QCheckBox;
class QSpinBox;
class QGroupBox;
class QLineEdit;
class QLabel;
class QPushButton;
namespace Ui
{
class PreferencesConfigurationPage;
}
class PatternPage : public QWidget
class PreferencesConfigurationPage : public QWidget
{
Q_OBJECT
public:
explicit PatternPage(QWidget *parent = nullptr);
void Apply();
public slots:
void ClearUserDefinedMaterials();
explicit PreferencesConfigurationPage(QWidget *parent = nullptr);
virtual ~PreferencesConfigurationPage();
void Apply();
protected:
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(PatternPage)
QGroupBox *userGroup;
QLineEdit *userName;
QLabel *userNameLabel;
QGroupBox *graphOutputGroup;
QCheckBox *graphOutputCheck;
QGroupBox *undoGroup;
QSpinBox *undoCount;
QLabel *countStepsLabel;
QGroupBox *userMaterialsGroup;
QPushButton* userMaterialClearButton;
QGroupBox *workpieceGroup;
QCheckBox *forbidFlippingCheck;
QCheckBox *doublePassmarkCheck;
Q_DISABLE_COPY(PreferencesConfigurationPage)
Ui::PreferencesConfigurationPage *ui;
bool m_langChanged;
bool m_systemChanged;
bool m_unitChanged;
bool m_labelLangChanged;
QGroupBox *UserGroup() Q_REQUIRED_RESULT;
QGroupBox *GraphOutputGroup() Q_REQUIRED_RESULT;
QGroupBox *UndoGroup() Q_REQUIRED_RESULT;
QGroupBox *UserMaterialGroup() Q_REQUIRED_RESULT;
QGroupBox *UserWorkpieceGroup() Q_REQUIRED_RESULT;
void SetLabelComboBox(const QStringList &list);
void RetranslateUi();
void InitLanguages();
void InitUnits();
void RetranslateUi();
};
#endif // PATTERNPAGE_H
#endif // PREFERENCESCONFIGURATIONPAGE_H

View File

@ -0,0 +1,267 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PreferencesConfigurationPage</class>
<widget class="QWidget" name="PreferencesConfigurationPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>501</width>
<height>640</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Configuration</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="saveGroup">
<property name="title">
<string>Save</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="autoSaveCheck">
<property name="text">
<string>Auto-save modified pattern</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Interval:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="autoTime">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="suffix">
<string>min</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>60</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Language</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>GUI language:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="langCombo"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Decimal separator parts:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="osOptionCheck">
<property name="text">
<string notr="true">&lt; With OS options &gt;</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Default unit:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Label language:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="unitCombo"/>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="labelCombo"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Pattern making system</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Pattern making system:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="systemCombo"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Author:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="systemAuthorValueLabel">
<property name="text">
<string notr="true">author</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Book:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPlainTextEdit" name="systemBookValueLabel">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Send crash reports</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="sendReportCheck">
<property name="text">
<string>Send crash reports (recommended)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="description">
<property name="text">
<string notr="true">TextLabel</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>Pattern editing</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QPushButton" name="resetWarningsButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Reset warnings</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_6">
<property name="title">
<string>Toolbar</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QCheckBox" name="toolBarStyleCheck">
<property name="text">
<string>The text appears under the icon (recommended for beginners).</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,14 +1,14 @@
/************************************************************************
**
** @file pathpage.cpp
** @file preferencespathpage.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 21 6, 2014
** @date 12 4, 2017
**
** @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-2015 Valentina project
** Copyright (C) 2017 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
@ -26,55 +26,45 @@
**
*************************************************************************/
#include "pathpage.h"
#include "preferencespathpage.h"
#include "ui_preferencespathpage.h"
#include "../vmisc/vsettings.h"
#include "../../options.h"
#include "../../core/vapplication.h"
#include "../vmisc/vsettings.h"
#include <QDir>
#include <QGroupBox>
#include <QLabel>
#include <QSettings>
#include <QTimer>
#include <QSpinBox>
#include <QComboBox>
#include <QMessageBox>
#include <QCheckBox>
#include <QIcon>
#include <QVBoxLayout>
#include <QTableWidget>
#include <QPushButton>
#include <QFileDialog>
#include <QHeaderView>
//---------------------------------------------------------------------------------------------------------------------
PathPage::PathPage(QWidget *parent)
: QWidget(parent), defaultButton(nullptr), editButton(nullptr), pathTable(nullptr), pathGroup(nullptr)
PreferencesPathPage::PreferencesPathPage(QWidget *parent)
: QWidget(parent),
ui(new Ui::PreferencesPathPage)
{
QGroupBox *pathGroup = PathGroup();
SCASSERT(pathGroup != nullptr)
ui->setupUi(this);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(pathGroup);
mainLayout->addStretch(1);
setLayout(mainLayout);
InitTable();
connect(ui->defaultButton, &QPushButton::clicked, this, &PreferencesPathPage::DefaultPath);
connect(ui->editButton, &QPushButton::clicked, this, &PreferencesPathPage::EditPath);
}
//---------------------------------------------------------------------------------------------------------------------
void PathPage::Apply()
PreferencesPathPage::~PreferencesPathPage()
{
VSettings *settings = qApp->ValentinaSettings();
settings->SetPathIndividualMeasurements(pathTable->item(0, 1)->text());
settings->SetPathStandardMeasurements(pathTable->item(1, 1)->text());
settings->SetPathPattern(pathTable->item(2, 1)->text());
settings->SetPathLayout(pathTable->item(3, 1)->text());
settings->SetPathTemplate(pathTable->item(4, 1)->text());
delete ui;
}
//---------------------------------------------------------------------------------------------------------------------
void PathPage::DefaultPath()
void PreferencesPathPage::Apply()
{
const int row = pathTable->currentRow();
QTableWidgetItem *item = pathTable->item(row, 1);
}
//---------------------------------------------------------------------------------------------------------------------
void PreferencesPathPage::DefaultPath()
{
const int row = ui->pathTable->currentRow();
QTableWidgetItem *item = ui->pathTable->item(row, 1);
SCASSERT(item != nullptr)
QString path;
@ -105,10 +95,10 @@ void PathPage::DefaultPath()
}
//---------------------------------------------------------------------------------------------------------------------
void PathPage::EditPath()
void PreferencesPathPage::EditPath()
{
const int row = pathTable->currentRow();
QTableWidgetItem *item = pathTable->item(row, 1);
const int row = ui->pathTable->currentRow();
QTableWidgetItem *item = ui->pathTable->item(row, 1);
SCASSERT(item != nullptr)
QString path;
@ -165,123 +155,58 @@ void PathPage::EditPath()
}
//---------------------------------------------------------------------------------------------------------------------
void PathPage::changeEvent(QEvent *event)
void PreferencesPathPage::InitTable()
{
if (event->type() == QEvent::LanguageChange)
{
// retranslate designer form (single inheritance approach)
RetranslateUi();
}
ui->pathTable->setRowCount(5);
ui->pathTable->setColumnCount(2);
// remember to call base class implementation
QWidget::changeEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
QGroupBox *PathPage::PathGroup()
{
pathGroup = new QGroupBox(tr("Path that use Valentina"));
InitTable();
defaultButton = new QPushButton(tr("Default"));
defaultButton->setEnabled(false);
connect(defaultButton, &QPushButton::clicked, this, &PathPage::DefaultPath);
editButton = new QPushButton(tr("Edit"));
editButton->setEnabled(false);
connect(editButton, &QPushButton::clicked, this, &PathPage::EditPath);
QHBoxLayout *buttonsLayout = new QHBoxLayout;
buttonsLayout->addWidget(defaultButton);
buttonsLayout->addWidget(editButton);
QVBoxLayout *pathLayout = new QVBoxLayout;
pathLayout->addWidget(pathTable);
pathLayout->addLayout(buttonsLayout);
pathGroup->setLayout(pathLayout);
return pathGroup;
}
//---------------------------------------------------------------------------------------------------------------------
void PathPage::InitTable()
{
pathTable = new QTableWidget();
pathTable->setRowCount(5);
pathTable->setColumnCount(2);
pathTable->verticalHeader()->setVisible(false);
pathTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
pathTable->setSelectionBehavior(QAbstractItemView::SelectRows);
pathTable->setSelectionMode(QAbstractItemView::SingleSelection);
pathTable->setShowGrid(false);
QStringList tableHeader = QStringList() << tr("Type") << tr("Path");
pathTable->setHorizontalHeaderLabels(tableHeader);
const VSettings *settings = qApp->ValentinaSettings();
{
pathTable->setItem(0, 0, new QTableWidgetItem(tr("My Individual Measurements")));
ui->pathTable->setItem(0, 0, new QTableWidgetItem(tr("My Individual Measurements")));
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathIndividualMeasurements());
item->setToolTip(settings->GetPathIndividualMeasurements());
pathTable->setItem(0, 1, item);
ui->pathTable->setItem(0, 1, item);
}
{
pathTable->setItem(1, 0, new QTableWidgetItem(tr("My Multisize Measurements")));
ui->pathTable->setItem(1, 0, new QTableWidgetItem(tr("My Multisize Measurements")));
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathStandardMeasurements());
item->setToolTip(settings->GetPathStandardMeasurements());
pathTable->setItem(1, 1, item);
ui->pathTable->setItem(1, 1, item);
}
{
pathTable->setItem(2, 0, new QTableWidgetItem(tr("My Patterns")));
ui->pathTable->setItem(2, 0, new QTableWidgetItem(tr("My Patterns")));
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathPattern());
item->setToolTip(settings->GetPathPattern());
pathTable->setItem(2, 1, item);
ui->pathTable->setItem(2, 1, item);
}
{
pathTable->setItem(3, 0, new QTableWidgetItem(tr("My Layouts")));
ui->pathTable->setItem(3, 0, new QTableWidgetItem(tr("My Layouts")));
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathLayout());
item->setToolTip(settings->GetPathLayout());
pathTable->setItem(3, 1, item);
ui->pathTable->setItem(3, 1, item);
}
{
pathTable->setItem(4, 0, new QTableWidgetItem(tr("My Templates")));
ui->pathTable->setItem(4, 0, new QTableWidgetItem(tr("My Templates")));
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathTemplate());
item->setToolTip(settings->GetPathTemplate());
pathTable->setItem(4, 1, item);
ui->pathTable->setItem(4, 1, item);
}
pathTable->verticalHeader()->setDefaultSectionSize(20);
pathTable->resizeColumnsToContents();
pathTable->resizeRowsToContents();
pathTable->horizontalHeader()->setStretchLastSection(true);
ui->pathTable->verticalHeader()->setDefaultSectionSize(20);
ui->pathTable->resizeColumnsToContents();
ui->pathTable->resizeRowsToContents();
connect(pathTable, &QTableWidget::itemSelectionChanged, RECEIVER(this)[this]()
connect(ui->pathTable, &QTableWidget::itemSelectionChanged, this, [this]()
{
defaultButton->setEnabled(true);
defaultButton->setDefault(false);
ui->defaultButton->setEnabled(true);
ui->defaultButton->setDefault(false);
editButton->setEnabled(true);
editButton->setDefault(true);
ui->editButton->setEnabled(true);
ui->editButton->setDefault(true);
});
}
//---------------------------------------------------------------------------------------------------------------------
void PathPage::RetranslateUi()
{
pathGroup->setTitle(tr("Path that use Valentina"));
defaultButton->setText(tr("Default"));
editButton->setText(tr("Edit"));
const QStringList tableHeader = QStringList() << tr("Type") << tr("Path");
pathTable->setHorizontalHeaderLabels(tableHeader);
pathTable->item(0, 0)->setText(tr("My Individual Measurements"));
pathTable->item(1, 0)->setText(tr("My Multisize Measurements"));
pathTable->item(2, 0)->setText(tr("My Patterns"));
pathTable->item(3, 0)->setText(tr("My Layouts"));
pathTable->item(4, 0)->setText(tr("My Templates"));
}

View File

@ -1,14 +1,14 @@
/************************************************************************
**
** @file pathpage.h
** @file preferencespathpage.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 21 6, 2014
** @date 12 4, 2017
**
** @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-2015 Valentina project
** Copyright (C) 2017 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
@ -26,37 +26,35 @@
**
*************************************************************************/
#ifndef PATHPAGE_H
#define PATHPAGE_H
#ifndef PREFERENCESPATHPAGE_H
#define PREFERENCESPATHPAGE_H
#include <QObject>
#include <QWidget>
class QGroupBox;
class QPushButton;
class QTableWidget;
namespace Ui
{
class PreferencesPathPage;
}
class PathPage : public QWidget
class PreferencesPathPage : public QWidget
{
Q_OBJECT
public:
explicit PathPage(QWidget *parent = nullptr);
void Apply();
protected:
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
explicit PreferencesPathPage(QWidget *parent = nullptr);
virtual ~PreferencesPathPage();
void Apply();
private slots:
void DefaultPath();
void EditPath();
private:
Q_DISABLE_COPY(PathPage)
QPushButton *defaultButton;
QPushButton *editButton;
QTableWidget *pathTable;
QGroupBox *pathGroup;
QGroupBox *PathGroup() Q_REQUIRED_RESULT;
void InitTable();
void RetranslateUi();
private:
Q_DISABLE_COPY(PreferencesPathPage)
Ui::PreferencesPathPage *ui;
void InitTable();
};
#endif // PATHPAGE_H
#endif // PREFERENCESPATHPAGE_H

View File

@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PreferencesPathPage</class>
<widget class="QWidget" name="PreferencesPathPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>422</width>
<height>295</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Path</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Paths that Valentina uses</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTableWidget" name="pathTable">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Type</string>
</property>
</column>
<column>
<property name="text">
<string>Path</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="defaultButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Default</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="editButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,88 @@
/************************************************************************
**
** @file preferencespatternpage.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 4, 2017
**
** @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) 2017 Valentina project
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "preferencespatternpage.h"
#include "ui_preferencespatternpage.h"
#include "../../core/vapplication.h"
#include "../ifc/xml/vabstractpattern.h"
#include <QMessageBox>
//---------------------------------------------------------------------------------------------------------------------
PreferencesPatternPage::PreferencesPatternPage(QWidget *parent)
: QWidget(parent),
ui(new Ui::PreferencesPatternPage)
{
ui->setupUi(this);
ui->userName->setText(qApp->ValentinaSettings()->GetUser());
ui->graphOutputCheck->setChecked(qApp->ValentinaSettings()->GetGraphicalOutput());
ui->undoCount->setValue(qApp->ValentinaSettings()->GetUndoCount());
connect(ui->userMaterialClearButton, &QPushButton::clicked, this, [this]()
{
VSettings* pSet = qApp->ValentinaSettings();
pSet->ClearUserDefinedMaterial();
pSet->sync();
QString qsMsg = tr("All user defined materials have been deleted!");
QMessageBox::information(this, QApplication::applicationName(), qsMsg);
});
ui->forbidFlippingCheck->setChecked(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping());
ui->doublePassmarkCheck->setChecked(qApp->ValentinaSettings()->IsDoublePassmark());
}
//---------------------------------------------------------------------------------------------------------------------
PreferencesPatternPage::~PreferencesPatternPage()
{
delete ui;
}
//---------------------------------------------------------------------------------------------------------------------
void PreferencesPatternPage::Apply()
{
VSettings *settings = qApp->ValentinaSettings();
settings->SetUser(ui->userName->text());
// Scene antialiasing
settings->SetGraphicalOutput(ui->graphOutputCheck->isChecked());
qApp->getSceneView()->setRenderHint(QPainter::Antialiasing, ui->graphOutputCheck->isChecked());
qApp->getSceneView()->setRenderHint(QPainter::SmoothPixmapTransform, ui->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->SetUndoCount(ui->undoCount->value());
settings->SetForbidWorkpieceFlipping(ui->forbidFlippingCheck->isChecked());
if (settings->IsDoublePassmark() != ui->doublePassmarkCheck->isChecked())
{
settings->SetDoublePassmark(ui->doublePassmarkCheck->isChecked());
qApp->getCurrentDocument()->LiteParseTree(Document::LiteParse);
}
}

View File

@ -1,14 +1,14 @@
/************************************************************************
**
** @file pages.h
** @file preferencespatternpage.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 2, 2014
** @date 12 4, 2017
**
** @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-2015 Valentina project
** Copyright (C) 2017 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
@ -26,11 +26,29 @@
**
*************************************************************************/
#ifndef PAGES_H
#define PAGES_H
#ifndef PREFERENCESPATTERNPAGE_H
#define PREFERENCESPATTERNPAGE_H
#include "configurationpage.h"
#include "patternpage.h"
#include "pathpage.h"
#include <QWidget>
#endif // PAGES_H
namespace Ui
{
class PreferencesPatternPage;
}
class PreferencesPatternPage : public QWidget
{
Q_OBJECT
public:
explicit PreferencesPatternPage(QWidget *parent = nullptr);
virtual ~PreferencesPatternPage();
void Apply();
private:
Q_DISABLE_COPY(PreferencesPatternPage)
Ui::PreferencesPatternPage *ui;
};
#endif // PREFERENCESPATTERNPAGE_H

View File

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PreferencesPatternPage</class>
<widget class="QWidget" name="PreferencesPatternPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>327</width>
<height>414</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Pattern</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>User</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>User name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="userName">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Graphical output</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="graphOutputCheck">
<property name="text">
<string>Use antialiasing</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Undo</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Count steps (0 - no limit):</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="undoCount"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>User defined materials</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QPushButton" name="userMaterialClearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Delete all</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>Workpiece</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QCheckBox" name="forbidFlippingCheck">
<property name="toolTip">
<string>By default forbid flipping for all new created workpieces&quot;</string>
</property>
<property name="text">
<string>Forbid flipping</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="doublePassmarkCheck">
<property name="toolTip">
<string>Show a passmark both in the seam allowance and on the seam line.</string>
</property>
<property name="text">
<string>Show second passmark on seam line</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,139 @@
/************************************************************************
**
** @file dialogpreferences.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 4, 2017
**
** @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) 2017 Valentina project
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "dialogpreferences.h"
#include "ui_dialogpreferences.h"
#include "../core/vapplication.h"
#include "configpages/preferencesconfigurationpage.h"
#include "configpages/preferencespatternpage.h"
#include "configpages/preferencespathpage.h"
#include <QPushButton>
//---------------------------------------------------------------------------------------------------------------------
DialogPreferences::DialogPreferences(QWidget *parent)
: QDialog(parent),
ui(new Ui::DialogPreferences),
m_isInitialized(false),
m_configurePage(new PreferencesConfigurationPage),
m_patternPage(new PreferencesPatternPage),
m_pathPage(new PreferencesPathPage)
{
ui->setupUi(this);
qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
SCASSERT(bOk != nullptr)
connect(bOk, &QPushButton::clicked, this, &DialogPreferences::Ok);
QPushButton *bApply = ui->buttonBox->button(QDialogButtonBox::Apply);
SCASSERT(bApply != nullptr)
connect(bApply, &QPushButton::clicked, this, &DialogPreferences::Apply);
ui->pagesWidget->insertWidget(0, m_configurePage);
ui->pagesWidget->insertWidget(1, m_patternPage);
ui->pagesWidget->insertWidget(2, m_pathPage);
connect(ui->contentsWidget, &QListWidget::currentItemChanged, this, &DialogPreferences::PageChanged);
ui->pagesWidget->setCurrentIndex(0);
}
//---------------------------------------------------------------------------------------------------------------------
DialogPreferences::~DialogPreferences()
{
delete ui;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPreferences::showEvent(QShowEvent *event)
{
QDialog::showEvent( event );
if ( event->spontaneous() )
{
return;
}
if (m_isInitialized)
{
return;
}
// do your init stuff here
setMinimumSize(size());
QSize sz = qApp->Settings()->GetPreferenceDialogSize();
if (sz.isEmpty() == false)
{
resize(sz);
}
m_isInitialized = true;//first show windows are held
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPreferences::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event)
// remember the size for the next time this dialog is opened, but only
// if widget was already initialized, which rules out the resize at
// dialog creating, which would
if (m_isInitialized)
{
qApp->Settings()->SetPreferenceDialogSize(size());
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPreferences::PageChanged(QListWidgetItem *current, QListWidgetItem *previous)
{
if (current == nullptr)
{
current = previous;
}
int rowIndex = ui->contentsWidget->row(current);
ui->pagesWidget->setCurrentIndex(rowIndex);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPreferences::Apply()
{
m_configurePage->Apply();
m_patternPage->Apply();
m_pathPage->Apply();
qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
emit UpdateProperties();
setResult(QDialog::Accepted);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPreferences::Ok()
{
Apply();
done(QDialog::Accepted);
}

View File

@ -1,14 +1,14 @@
/************************************************************************
**
** @file configdialog.h
** @file dialogpreferences.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 2, 2014
** @date 12 4, 2017
**
** @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-2015 Valentina project
** Copyright (C) 2017 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
@ -26,45 +26,45 @@
**
*************************************************************************/
#ifndef CONFIGDIALOG_H
#define CONFIGDIALOG_H
#ifndef DIALOGPREFERENCES_H
#define DIALOGPREFERENCES_H
#include <QDialog>
#include "configpages/pages.h"
namespace Ui
{
class DialogPreferences;
}
class PreferencesConfigurationPage;
class PreferencesPatternPage;
class PreferencesPathPage;
class QListWidgetItem;
class QStackedWidget;
class QListWidget;
class ConfigDialog : public QDialog
class DialogPreferences : public QDialog
{
Q_OBJECT
public:
explicit ConfigDialog(QWidget *parent = nullptr);
explicit DialogPreferences(QWidget *parent = nullptr);
virtual ~DialogPreferences();
signals:
void UpdateProperties();
protected:
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 resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
private slots:
void PageChanged(QListWidgetItem *current, QListWidgetItem *previous);
private:
Q_DISABLE_COPY(ConfigDialog)
QListWidget *contentsWidget;
QStackedWidget *pagesWidget;
ConfigurationPage *configurationPage;
PatternPage *patternPage;
PathPage *pathPage;
QPushButton *applyButton;
QPushButton *cancelButton;
QPushButton *okButton;
bool isInitialized;
void createIcons();
void createIcon(const QString &icon, const QString &text);
void Apply();
void Ok();
Q_DISABLE_COPY(DialogPreferences)
Ui::DialogPreferences *ui;
bool m_isInitialized;
PreferencesConfigurationPage *m_configurePage;
PreferencesPatternPage *m_patternPage;
PreferencesPathPage *m_pathPage;
void RetranslateUi();
void Apply();
void Ok();
};
#endif // CONFIGDIALOG_H
#endif // DIALOGPREFERENCES_H

View File

@ -0,0 +1,157 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogPreferences</class>
<widget class="QDialog" name="DialogPreferences">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>712</width>
<height>522</height>
</rect>
</property>
<property name="windowTitle">
<string>Preferences</string>
</property>
<property name="windowIcon">
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QListWidget" name="contentsWidget">
<property name="minimumSize">
<size>
<width>128</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>128</width>
<height>16777215</height>
</size>
</property>
<property name="iconSize">
<size>
<width>96</width>
<height>84</height>
</size>
</property>
<property name="textElideMode">
<enum>Qt::ElideMiddle</enum>
</property>
<property name="movement">
<enum>QListView::Static</enum>
</property>
<property name="spacing">
<number>12</number>
</property>
<property name="viewMode">
<enum>QListView::IconMode</enum>
</property>
<property name="currentRow">
<number>0</number>
</property>
<item>
<property name="text">
<string>Configuration</string>
</property>
<property name="textAlignment">
<set>AlignCenter</set>
</property>
<property name="icon">
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/config.png</normaloff>:/icon/config.png</iconset>
</property>
<property name="flags">
<set>ItemIsSelectable|ItemIsUserCheckable|ItemIsEnabled</set>
</property>
</item>
<item>
<property name="text">
<string>Pattern</string>
</property>
<property name="textAlignment">
<set>AlignCenter</set>
</property>
<property name="icon">
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/pattern_config.png</normaloff>:/icon/pattern_config.png</iconset>
</property>
<property name="flags">
<set>ItemIsSelectable|ItemIsUserCheckable|ItemIsEnabled</set>
</property>
</item>
<item>
<property name="text">
<string>Paths</string>
</property>
<property name="textAlignment">
<set>AlignCenter</set>
</property>
<property name="icon">
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/path_config.png</normaloff>:/icon/path_config.png</iconset>
</property>
<property name="flags">
<set>ItemIsSelectable|ItemIsUserCheckable|ItemIsEnabled</set>
</property>
</item>
</widget>
</item>
<item>
<widget class="QStackedWidget" name="pagesWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<widget class="QWidget" name="page_2"/>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../../libs/vmisc/share/resources/icon.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DialogPreferences</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -31,9 +31,9 @@
#include "dialoghistory.h"
#include "dialogincrements.h"
#include "configdialog.h"
#include "dialogpatternproperties.h"
#include "dialognewpattern.h"
#include "dialogaboutapp.h"
#include "dialogpreferences.h"
#endif // DIALOGS_H

View File

@ -5,35 +5,34 @@ HEADERS += \
$$PWD/dialogs.h \
$$PWD/dialogincrements.h \
$$PWD/dialoghistory.h \
$$PWD/configdialog.h \
$$PWD/configpages/pages.h \
$$PWD/dialogpatternproperties.h \
$$PWD/dialognewpattern.h \
$$PWD/dialogaboutapp.h \
$$PWD/configpages/configurationpage.h \
$$PWD/configpages/patternpage.h \
$$PWD/configpages/pathpage.h \
$$PWD/dialoglayoutsettings.h \
$$PWD/dialoglayoutprogress.h \
$$PWD/dialogsavelayout.h \
$$PWD/vwidgetgroups.h \
$$PWD/vwidgetdetails.h
$$PWD/vwidgetdetails.h \
$$PWD/dialogpreferences.h \
$$PWD/configpages/preferencesconfigurationpage.h \
$$PWD/configpages/preferencespatternpage.h \
$$PWD/configpages/preferencespathpage.h
SOURCES += \
$$PWD/dialogincrements.cpp \
$$PWD/dialoghistory.cpp \
$$PWD/configdialog.cpp \
$$PWD/dialogpatternproperties.cpp \
$$PWD/dialognewpattern.cpp \
$$PWD/dialogaboutapp.cpp \
$$PWD/configpages/configurationpage.cpp \
$$PWD/configpages/patternpage.cpp \
$$PWD/configpages/pathpage.cpp \
$$PWD/dialoglayoutsettings.cpp \
$$PWD/dialoglayoutprogress.cpp \
$$PWD/dialogsavelayout.cpp \
$$PWD/vwidgetgroups.cpp \
$$PWD/vwidgetdetails.cpp
$$PWD/vwidgetdetails.cpp \
$$PWD/dialogpreferences.cpp \
$$PWD/configpages/preferencesconfigurationpage.cpp \
$$PWD/configpages/preferencespatternpage.cpp \
$$PWD/configpages/preferencespathpage.cpp
FORMS += \
$$PWD/dialogincrements.ui \
@ -45,4 +44,8 @@ FORMS += \
$$PWD/dialoglayoutprogress.ui \
$$PWD/dialogsavelayout.ui \
$$PWD/vwidgetgroups.ui \
$$PWD/vwidgetdetails.ui
$$PWD/vwidgetdetails.ui \
$$PWD/dialogpreferences.ui \
$$PWD/configpages/preferencesconfigurationpage.ui \
$$PWD/configpages/preferencespatternpage.ui \
$$PWD/configpages/preferencespathpage.ui

View File

@ -4265,16 +4265,17 @@ void MainWindow::ShowPaper(int index)
void MainWindow::Preferences()
{
// Calling constructor of the dialog take some time. Because of this user have time to call the dialog twice.
static QPointer<ConfigDialog> guard;// Prevent any second run
static QPointer<DialogPreferences> guard;// Prevent any second run
if (guard.isNull())
{
ConfigDialog *config = new ConfigDialog(this);
DialogPreferences *preferences = new DialogPreferences(this);
// QScopedPointer needs to be sure any exception will never block guard
QScopedPointer<ConfigDialog> dlg(config);
guard = config;
connect(dlg.data(), &ConfigDialog::UpdateProperties, this, &MainWindow::WindowsLocale); // Must be first
connect(dlg.data(), &ConfigDialog::UpdateProperties, toolOptions, &VToolOptionsPropertyBrowser::RefreshOptions);
connect(dlg.data(), &ConfigDialog::UpdateProperties, this, &MainWindow::ToolBarStyles);
QScopedPointer<DialogPreferences> dlg(preferences);
guard = preferences;
connect(dlg.data(), &DialogPreferences::UpdateProperties, this, &MainWindow::WindowsLocale); // Must be first
connect(dlg.data(), &DialogPreferences::UpdateProperties, toolOptions,
&VToolOptionsPropertyBrowser::RefreshOptions);
connect(dlg.data(), &DialogPreferences::UpdateProperties, this, &MainWindow::ToolBarStyles);
if (guard->exec() == QDialog::Accepted)
{