53 #include "ui_preferencesconfigurationpage.h"
54 #include "../../core/vapplication.h"
55 #include "../vpatterndb/pmsystems.h"
56 #include "../vwidgets/export_format_combobox.h"
59 #include <QDirIterator>
60 #include <QMessageBox>
68 , m_langChanged(false)
70 , m_unitChanged(false)
71 , m_labelLangChanged(false)
72 , m_selectionSoundChanged(false)
73 , m_moveSuffixChanged(false)
74 , m_rotateSuffixChanged(false)
75 , m_mirrorByAxisSuffixChanged(false)
76 , m_mirrorByLineSuffixChanged(false)
77 , m_defaultExportFormatChanged(false)
80 setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
84 ui->undoCount_SpinBox->setValue(
qApp->Seamly2DSettings()->GetUndoCount());
87 int index =
ui->selectionSound_ComboBox->findText(
qApp->Seamly2DSettings()->getSound());
90 ui->selectionSound_ComboBox->setCurrentIndex(index);
92 connect(
ui->selectionSound_ComboBox,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
this, [
this]()
94 m_selectionSoundChanged = true;
95 QSound::play(
"qrc:/sounds/" + ui->selectionSound_ComboBox->currentText() +
".wav");
99 ui->confirmItemDelete_CheckBox->setChecked(
qApp->Seamly2DSettings()->getConfirmItemDelete());
100 ui->confirmFormatRewriting_CheckBox->setChecked(
qApp->Seamly2DSettings()->getConfirmFormatRewriting());
111 ui->systemBookValueLabel->setFixedHeight(4 * QFontMetrics(
ui->systemBookValueLabel->font()).lineSpacing());
112 connect(
ui->systemCombo,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
this, [
this]()
114 m_systemChanged = true;
115 QString text = qApp->TrVars()->PMSystemAuthor(ui->systemCombo->currentData().toString());
116 ui->systemAuthorValueLabel->setText(text);
117 ui->systemAuthorValueLabel->setToolTip(text);
119 text = qApp->TrVars()->PMSystemBook(ui->systemCombo->currentData().toString());
120 ui->systemBookValueLabel->setPlainText(text);
124 index =
ui->systemCombo->findData(
qApp->Seamly2DSettings()->GetPMSystemCode());
127 ui->systemCombo->setCurrentIndex(index);
131 ui->moveSuffix_ComboBox->addItem(tr(
"None"),
"");
132 ui->moveSuffix_ComboBox->addItem(tr(
"_M"),
"_M");
133 ui->moveSuffix_ComboBox->addItem(tr(
"_MOV"),
"_MOV");
134 index =
ui->moveSuffix_ComboBox->findData(
qApp->Seamly2DSettings()->getMoveSuffix());
137 ui->moveSuffix_ComboBox->setCurrentIndex(index);
139 connect(
ui->moveSuffix_ComboBox,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
this, [
this]()
141 m_moveSuffixChanged = true;
143 ui->rotateSuffix_ComboBox->addItem(tr(
"None"),
"");
144 ui->rotateSuffix_ComboBox->addItem(tr(
"_R"),
"_R");
145 ui->rotateSuffix_ComboBox->addItem(tr(
"_ROT"),
"_ROT");
146 index =
ui->rotateSuffix_ComboBox->findData(
qApp->Seamly2DSettings()->getRotateSuffix());
149 ui->rotateSuffix_ComboBox->setCurrentIndex(index);
151 connect(
ui->rotateSuffix_ComboBox,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
this, [
this]()
153 m_rotateSuffixChanged = true;
156 ui->mirrorByAxisSuffix_ComboBox->addItem(tr(
"None"),
"");
157 ui->mirrorByAxisSuffix_ComboBox->addItem(tr(
"_MA"),
"_MA");
158 ui->mirrorByAxisSuffix_ComboBox->addItem(tr(
"_MBA"),
"_MBA");
159 index =
ui->mirrorByAxisSuffix_ComboBox->findData(
qApp->Seamly2DSettings()->getMirrorByAxisSuffix());
162 ui->mirrorByAxisSuffix_ComboBox->setCurrentIndex(index);
164 connect(
ui->mirrorByAxisSuffix_ComboBox,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
this, [
this]()
166 m_mirrorByAxisSuffixChanged = true;
169 ui->mirrorByLineSuffix_ComboBox->addItem(tr(
"None"),
"");
170 ui->mirrorByLineSuffix_ComboBox->addItem(tr(
"_MB"),
"_MB");
171 ui->mirrorByLineSuffix_ComboBox->addItem(tr(
"_MBL"),
"_MBL");
172 index =
ui->mirrorByLineSuffix_ComboBox->findData(
qApp->Seamly2DSettings()->getMirrorByLineSuffix());
175 ui->mirrorByLineSuffix_ComboBox->setCurrentIndex(index);
177 connect(
ui->mirrorByLineSuffix_ComboBox,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
this, [
this]()
179 m_mirrorByLineSuffixChanged = true;
184 ui->autoSave_CheckBox->setChecked(
qApp->Seamly2DSettings()->GetAutosaveState());
185 ui->autoInterval_Spinbox->setValue(
qApp->Seamly2DSettings()->getAutosaveInterval());
188 ui->useModeType_CheckBox->setChecked(
qApp->Seamly2DSettings()->useModeType());
189 ui->uselastExportFormat_CheckBox->setChecked(
qApp->Seamly2DSettings()->useLastExportFormat());
190 index =
ui->defaultExportFormat_ComboBox->findText(
qApp->Seamly2DSettings()->getExportFormat());
193 ui->defaultExportFormat_ComboBox->setCurrentIndex(index);
195 connect(
ui->defaultExportFormat_ComboBox,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
this, [
this]()
197 m_defaultExportFormatChanged = true;
202 connect(
ui->langCombo,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
this, [
this]()
204 m_langChanged = true;
208 ui->osOptionCheck->setText(tr(
"With OS options") + QString(
" (%1)").arg(QLocale().decimalPoint()));
209 ui->osOptionCheck->setChecked(
qApp->Seamly2DSettings()->GetOsSeparator());
213 connect(
ui->unitCombo,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
this, [
this]()
215 m_unitChanged = true;
219 index =
ui->labelCombo->findData(
qApp->Seamly2DSettings()->GetLabelLanguage());
222 ui->labelCombo->setCurrentIndex(index);
224 connect(
ui->labelCombo,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
this, [
this]()
226 m_labelLangChanged = true;
246 const QString locale = qvariant_cast<QString>(
ui->selectionSound_ComboBox->currentText());
256 QTimer *autoSaveTimer =
qApp->getAutoSaveTimer();
259 ui->autoSave_CheckBox->isChecked() ? autoSaveTimer->start(
ui->autoInterval_Spinbox->value()*60000) : autoSaveTimer->stop();
265 const QString format = qvariant_cast<QString>(
ui->defaultExportFormat_ComboBox->currentText());
275 const QString locale = qvariant_cast<QString>(
ui->langCombo->currentData());
279 const QString code = qvariant_cast<QString>(
ui->systemCombo->currentData());
283 qApp->loadTranslations(locale);
287 const QString unit = qvariant_cast<QString>(
ui->unitCombo->currentData());
290 const QString text = tr(
"The Default unit has been updated and will be used as the default for the next "
291 "pattern you create.");
292 QMessageBox::information(
this, QCoreApplication::applicationName(), text);
296 const QString locale = qvariant_cast<QString>(
ui->labelCombo->currentData());
302 const QString locale = qvariant_cast<QString>(
ui->moveSuffix_ComboBox->currentData());
308 const QString locale = qvariant_cast<QString>(
ui->rotateSuffix_ComboBox->currentData());
314 const QString locale = qvariant_cast<QString>(
ui->mirrorByAxisSuffix_ComboBox->currentData());
320 const QString locale = qvariant_cast<QString>(
ui->mirrorByLineSuffix_ComboBox->currentData());
329 if (event->type() == QEvent::LanguageChange)
335 QWidget::changeEvent(event);
341 for (
int i = 0; i < list.size(); ++i)
343 QLocale loc = QLocale(list.at(i));
344 QString country = QLocale::countryToString(loc.country());
345 QIcon ico(QString(
"%1/%2.png").arg(
":/flags").arg(country));
346 ui->labelCombo->addItem(ico, loc.nativeLanguageName(), list.at(i));
353 ui->unitCombo->addItem(tr(
"Centimeters"),
unitCM);
354 ui->unitCombo->addItem(tr(
"Millimeters"),
unitMM);
355 ui->unitCombo->addItem(tr(
"Inches"),
unitINCH);
358 const qint32 indexUnit =
ui->unitCombo->findData(
qApp->Seamly2DSettings()->GetUnit());
361 ui->unitCombo->setCurrentIndex(indexUnit);
368 ui->osOptionCheck->setText(tr(
"With OS options") + QString(
" (%1)").arg(QLocale().decimalPoint()));
PreferencesConfigurationPage(QWidget *parent=nullptr)
bool m_rotateSuffixChanged
bool m_selectionSoundChanged
bool m_mirrorByLineSuffixChanged
void SetLabelComboBox(const QStringList &list)
virtual ~PreferencesConfigurationPage()
bool m_defaultExportFormatChanged
bool m_mirrorByAxisSuffixChanged
Ui::PreferencesConfigurationPage * ui
virtual void changeEvent(QEvent *event) Q_DECL_OVERRIDE
static QStringList LabelLanguages()
void setRotateSuffix(const QString &value)
void SetUndoCount(const int &value)
void setMirrorByAxisSuffix(const QString &value)
void SetPMSystemCode(const QString &value)
void setUseLastExportFormat(const bool &value)
void setAutosaveInterval(const int &value)
void setConfirmFormatRewriting(const bool &value)
void setExportFormat(const QString &value)
void setConfirmItemDelete(const bool &value)
void SetUnit(const QString &value)
void SetOsSeparator(const bool &value)
void setMirrorByLineSuffix(const QString &value)
void setMoveSuffix(const QString &value)
void setSelectionSound(const QString &value)
void setUseModeType(const bool &value)
void SetAutosaveState(const bool &value)
void SetLocale(const QString &value)
void SetLabelLanguage(const QString &value)
void InitLanguages(QComboBox *combobox)
void InitPMSystems(QComboBox *systemCombo)