53 #include "ui_preferencespatternpage.h"
55 #include "../dialogdatetimeformats.h"
56 #include "../ifc/xml/vabstractpattern.h"
57 #include "../../core/vapplication.h"
61 #include <QFileDialog>
62 #include <QMessageBox>
71 QStringList itemsInComboBox;
72 for (
int index = 0; index < combo->count(); ++index)
74 itemsInComboBox << combo->itemText(index);
77 return itemsInComboBox;
87 setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
154 ui->forbidFlipping_CheckBox->setChecked(
qApp->Seamly2DSettings()->getForbidPieceFlipping());
155 ui->hideSeamLine_CheckBox->setChecked(
qApp->Seamly2DSettings()->isHideSeamLine());
156 ui->showSeamAllowances_CheckBox->setChecked(
qApp->Seamly2DSettings()->getDefaultSeamAllowanceVisibilty());
157 ui->defaultSeamAllowance_DoubleSpinBox->setValue(
qApp->Seamly2DSettings()->GetDefaultSeamAllowance());
160 int index =
ui->defaultSeamColor_ComboBox->findData(
qApp->Seamly2DSettings()->getDefaultSeamColor());
163 ui->defaultSeamColor_ComboBox->setCurrentIndex(index);
165 index =
ui->defaultSeamLinetype_ComboBox->findData(
qApp->Seamly2DSettings()->getDefaultSeamLinetype());
168 ui->defaultSeamLinetype_ComboBox->setCurrentIndex(index);
170 index =
ui->defaultSeamLineweight_ComboBox->findData(
qApp->Seamly2DSettings()->getDefaultSeamLineweight());
173 ui->defaultSeamLineweight_ComboBox->setCurrentIndex(index);
177 index =
ui->defaultCutColor_ComboBox->findData(
qApp->Seamly2DSettings()->getDefaultCutColor());
180 ui->defaultCutColor_ComboBox->setCurrentIndex(index);
182 index =
ui->defaultCutLinetype_ComboBox->findData(
qApp->Seamly2DSettings()->getDefaultCutLinetype());
185 ui->defaultCutLinetype_ComboBox->setCurrentIndex(index);
187 index =
ui->defaultCutLineweight_ComboBox->findData(
qApp->Seamly2DSettings()->getDefaultCutLineweight());
190 ui->defaultCutLineweight_ComboBox->setCurrentIndex(index);
193 index =
ui->defaultInternalColor_ComboBox->findData(
qApp->Seamly2DSettings()->getDefaultInternalColor());
196 ui->defaultInternalColor_ComboBox->setCurrentIndex(index);
198 index =
ui->defaultInternalLinetype_ComboBox->findData(
qApp->Seamly2DSettings()->getDefaultInternalLinetype());
201 ui->defaultInternalLinetype_ComboBox->setCurrentIndex(index);
203 index =
ui->defaultInternalLineweight_ComboBox->findData(
qApp->Seamly2DSettings()->getDefaultInternalLineweight());
206 ui->defaultInternalLineweight_ComboBox->setCurrentIndex(index);
209 index =
ui->defaultCutoutColor_ComboBox->findData(
qApp->Seamly2DSettings()->getDefaultCutoutColor());
212 ui->defaultCutoutColor_ComboBox->setCurrentIndex(index);
214 index =
ui->defaultCutoutLinetype_ComboBox->findData(
qApp->Seamly2DSettings()->getDefaultCutoutLinetype());
217 ui->defaultCutoutLinetype_ComboBox->setCurrentIndex(index);
219 index =
ui->defaultCutoutLineweight_ComboBox->findData(
qApp->Seamly2DSettings()->getDefaultCutoutLineweight());
222 ui->defaultCutoutLineweight_ComboBox->setCurrentIndex(index);
231 QPushButton *button = qobject_cast<QPushButton *>(sender());
232 if (button ==
ui->editDateFormats_PushButton)
237 else if (button ==
ui->editTimeFormats_PushButton)
247 QToolButton *button = qobject_cast<QToolButton *>(sender());
250 QString filter(tr(
"Label template") + QLatin1String(
"(*.xml)"));
251 const QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Import template"),
253 QFileDialog::DontUseNativeDialog);
256 if (button ==
ui->patternTemplate_ToolButton)
258 ui->patternTemplate_LineEdit->setText(fileName);
261 else if (button ==
ui->pieceTemplate_ToolButton)
263 ui->pieceTemplate_LineEdit->setText(fileName);
273 ui->showPatternLabels_CheckBox->setChecked(
qApp->Seamly2DSettings()->showPatternLabels());
274 ui->showPieceLabels_CheckBox->setChecked(
qApp->Seamly2DSettings()->showPieceLabels());
276 ui->defaultLabelWidth_DoubleSpinBox->setValue(
qApp->Seamly2DSettings()->getDefaultLabelWidth());
278 ui->defaultLabelHeight_DoubleSpinBox->setValue(
qApp->Seamly2DSettings()->getDefaultLabelHeight());
281 int index =
ui->defaultLabelColor_ComboBox->findData(
qApp->Seamly2DSettings()->getDefaultLabelColor());
284 ui->defaultLabelColor_ComboBox->setCurrentIndex(index);
306 ui->defaultNotchType_ComboBox->addItem(QIcon(), tr(
"Slit"),
"slit");
307 ui->defaultNotchType_ComboBox->addItem(QIcon(), tr(
"T Notch"),
"tNotch");
308 ui->defaultNotchType_ComboBox->addItem(QIcon(), tr(
"U Notch"),
"uNotch");
309 ui->defaultNotchType_ComboBox->addItem(QIcon(), tr(
"V Internal"),
"vInternal");
310 ui->defaultNotchType_ComboBox->addItem(QIcon(), tr(
"V External"),
"vExternal");
311 ui->defaultNotchType_ComboBox->addItem(QIcon(), tr(
"Castle"),
"castle");
312 ui->defaultNotchType_ComboBox->addItem(QIcon(), tr(
"Diamond"),
"diamond");
315 int index =
ui->defaultNotchType_ComboBox->findData(
qApp->Seamly2DSettings()->getDefaultNotchType());
318 ui->defaultNotchType_ComboBox->setCurrentIndex(index);
321 index =
ui->defaultNotchColor_ComboBox->findData(
qApp->Seamly2DSettings()->getDefaultNotchColor());
324 ui->defaultNotchColor_ComboBox->setCurrentIndex(index);
326 ui->showSeamlineNotch_CheckBox->setChecked(
qApp->Seamly2DSettings()->showSeamlineNotch());
327 ui->showSeamAllowanceNotch_CheckBox->setChecked(
qApp->Seamly2DSettings()->showSeamAllowanceNotch());
328 ui->defaultNotchLength_DoubleSpinBox->setValue(
qApp->Seamly2DSettings()->getDefaultNotchLength());
330 ui->defaultNotchWidth_DoubleSpinBox->setValue(
qApp->Seamly2DSettings()->getDefaultNotchWidth());
337 ui->showGrainlines_CheckBox->setChecked(
qApp->Seamly2DSettings()->getDefaultGrainlineVisibilty());
339 ui->defaultGrainlineLength_DoubleSpinBox->setValue(
qApp->Seamly2DSettings()->getDefaultGrainlineLength());
342 int index =
ui->defaultGrainlineColor_ComboBox->findData(
qApp->Seamly2DSettings()->getDefaultGrainlineColor());
345 ui->defaultGrainlineColor_ComboBox->setCurrentIndex(index);
347 index =
ui->defaultGrainlineLineweight_ComboBox->findData(
qApp->Seamly2DSettings()->getDefaultGrainlineLineweight());
350 ui->defaultGrainlineLineweight_ComboBox->setCurrentIndex(index);
358 box->addItems(items);
359 int index = box->findText(currentFormat);
362 box->setCurrentIndex(index);
366 box->setCurrentIndex(0);
371 template <
typename T>
373 const QStringList &userDefinedFormats, QComboBox *box)
379 if (QDialog::Accepted == dialog.exec())
381 const QString currentFormat = box->currentText();
385 int index = box->findText(currentFormat);
388 box->setCurrentIndex(index);
392 box->setCurrentIndex(0);
void editDateTimeFormats()
void callDateTimeFormatEditor(const T &type, const QStringList &predefinedFormats, const QStringList &userDefinedFormats, QComboBox *box)
void initializeLabelsTab()
PreferencesPatternPage(QWidget *parent=nullptr)
void initComboBoxFormats(QComboBox *box, const QStringList &items, const QString ¤tFormat)
Ui::PreferencesPatternPage * ui
virtual ~PreferencesPatternPage()
void setDefaultTemplate()
void initDefaultSeamAllowance()
void SetDefaultSeamAllowance(double value)
void setDefaultGrainlineLength(const qreal &value)
void setDefaultSeamLinetype(const QString &value)
void setDefaultGrainlineColor(const QString &value)
void setDefaultSeamLineweight(const qreal &value)
void setDefaultCutLinetype(const QString &value)
void setDefaultCutoutLinetype(const QString &value)
void setForbidPieceFlipping(bool value)
QString getDefaultPatternTemplate() const
void setDefaultCutColor(const QString &value)
void setDefaultInternalLinetype(const QString &value)
void setDefaultLabelHeight(const qreal &value)
QString GetLabelDateFormat() const
void SetLabelTimeFormat(const QString &format)
void setShowPieceLabels(const bool &value)
void setDefaultSeamColor(const QString &value)
void setDefaultInternalColor(const QString &value)
void setDefaultPieceTemplate(const QString &text)
void setDefaultCutoutColor(const QString &value)
void setDefaultPatternTemplate(const QString &text)
void setDefaultInternalLineweight(const qreal &value)
void setDefaultNotchColor(const QString &value)
void setDefaultCutoutLineweight(const qreal &value)
QStringList GetUserDefinedTimeFormats() const
void setShowSeamlineNotch(bool value)
QString GetPathLabelTemplate() const
void SetUserDefinedDateFormats(const QStringList &formats)
void setHideSeamLine(bool value)
void setDefaultSeamAllowanceVisibilty(const bool &value)
QString GetLabelTimeFormat() const
void setDefaultGrainlineLineweight(const qreal &value)
void setShowSeamAllowanceNotch(bool value)
void setDefaultLabelColor(const QString &value)
void setShowPatternLabels(const bool &value)
void setDefaultNotchWidth(const qreal &value)
static QStringList PredefinedTimeFormats()
QString getDefaultPieceTemplate() const
void SetLabelDateFormat(const QString &format)
void setDefaultLabelWidth(const qreal &value)
static QStringList PredefinedDateFormats()
QStringList GetUserDefinedDateFormats() const
void setDefaultGrainlineVisibilty(const bool &value)
void setDefaultNotchType(const QString &value)
void setDefaultNotchLength(const qreal &value)
void SetUserDefinedTimeFormats(const QStringList &formats)
void setDefaultCutLineweight(const qreal &value)
Unit StrToUnits(const QString &unit)
QString UnitsToStr(const Unit &unit, const bool translate)
UnitsToStr translate unit to string.
QStringList initAllStringsComboBox(QComboBox *combo)