New setting "Default height and size".

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-12-12 13:11:39 +02:00
parent 3aa1ccaea4
commit e8a93ddc2b
6 changed files with 246 additions and 42 deletions

View File

@ -29,6 +29,7 @@
#include "tapeconfigurationpage.h" #include "tapeconfigurationpage.h"
#include "../../mapplication.h" #include "../../mapplication.h"
#include "../vmisc/vtapesettings.h" #include "../vmisc/vtapesettings.h"
#include "../vpatterndb/variables/vmeasurement.h"
#include <QDir> #include <QDir>
#include <QGroupBox> #include <QGroupBox>
#include <QLabel> #include <QLabel>
@ -52,6 +53,7 @@ TapeConfigurationPage::TapeConfigurationPage(QWidget *parent)
osOptionCheck(nullptr), osOptionCheck(nullptr),
langChanged(false), langChanged(false),
systemChanged(false), systemChanged(false),
defGradationChanged(false),
unitChanged(false), unitChanged(false),
labelLangChanged(false), labelLangChanged(false),
sendReportCheck(nullptr), sendReportCheck(nullptr),
@ -61,15 +63,25 @@ TapeConfigurationPage::TapeConfigurationPage(QWidget *parent)
systemBookValueLabel(nullptr), systemBookValueLabel(nullptr),
langGroup(nullptr), langGroup(nullptr),
guiLabel(nullptr), guiLabel(nullptr),
separatorLabel(nullptr),
pmSystemGroup(nullptr),
systemLabel(nullptr), systemLabel(nullptr),
systemAuthorLabel(nullptr), systemAuthorLabel(nullptr),
systemBookLabel(nullptr), systemBookLabel(nullptr),
separatorLabel(nullptr) gradationGroup(nullptr),
defHeightLabel(nullptr),
defSizeLabel(nullptr),
defHeightCombo(nullptr),
defSizeCombo(nullptr)
{ {
QGroupBox *langGroup = LangGroup(); QGroupBox *langGroup = LangGroup();
QGroupBox *pmSystemGroup = PMSystemGroup();
QGroupBox *gradationBox = GradationGroup();
QVBoxLayout *mainLayout = new QVBoxLayout; QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(langGroup); mainLayout->addWidget(langGroup);
mainLayout->addWidget(pmSystemGroup);
mainLayout->addWidget(gradationBox);
mainLayout->addStretch(1); mainLayout->addStretch(1);
setLayout(mainLayout); setLayout(mainLayout);
} }
@ -96,6 +108,13 @@ void TapeConfigurationPage::Apply()
qApp->RetranslateTables(); qApp->RetranslateTables();
qApp->RetranslateGroups(); qApp->RetranslateGroups();
} }
if (defGradationChanged)
{
settings->SetDefHeight(defHeightCombo->currentText().toInt());
settings->SetDefSize(defSizeCombo->currentText().toInt());
defGradationChanged = false;
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -123,6 +142,12 @@ void TapeConfigurationPage::SystemChanged()
systemBookValueLabel->setPlainText(text); systemBookValueLabel->setPlainText(text);
} }
//---------------------------------------------------------------------------------------------------------------------
void TapeConfigurationPage::DefGradationChanged()
{
defGradationChanged = true;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TapeConfigurationPage::UnitChanged() void TapeConfigurationPage::UnitChanged()
{ {
@ -200,38 +225,6 @@ QGroupBox *TapeConfigurationPage::LangGroup()
langLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); langLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
langLayout->addRow(guiLabel, langCombo); langLayout->addRow(guiLabel, langCombo);
//-------------------- Pattern making system
systemLabel = new QLabel(tr("Pattern making system:"));
systemCombo = new QComboBox;
InitPMSystems(systemCombo);
langLayout->addRow(systemLabel, systemCombo);
//----
systemAuthorLabel = new QLabel(tr("Author:"));
systemAuthorValueLabel = new QLabel("");
langLayout->addRow(systemAuthorLabel, systemAuthorValueLabel);
//----
systemBookLabel = new QLabel(tr("Book:"));
systemBookValueLabel = new QPlainTextEdit("");
systemBookValueLabel->setReadOnly(true);
systemBookValueLabel->setFixedHeight(4 * QFontMetrics(systemBookValueLabel->font()).lineSpacing());
langLayout->addRow(systemBookLabel, systemBookValueLabel);
connect(systemCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&TapeConfigurationPage::SystemChanged);
// set default pattern making system
index = systemCombo->findData(settings->GetPMSystemCode());
if (index != -1)
{
systemCombo->setCurrentIndex(index);
}
//-------------------- Decimal separator setup //-------------------- Decimal separator setup
separatorLabel = new QLabel(tr("Decimal separator parts:")); separatorLabel = new QLabel(tr("Decimal separator parts:"));
@ -245,6 +238,88 @@ QGroupBox *TapeConfigurationPage::LangGroup()
return langGroup; return langGroup;
} }
//---------------------------------------------------------------------------------------------------------------------
QGroupBox *TapeConfigurationPage::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,
&TapeConfigurationPage::SystemChanged);
// set default pattern making system
const VTapeSettings *settings = qApp->TapeSettings();
const int index = systemCombo->findData(settings->GetPMSystemCode());
if (index != -1)
{
systemCombo->setCurrentIndex(index);
}
pmSystemGroup->setLayout(pmSystemLayout);
return pmSystemGroup;
}
//---------------------------------------------------------------------------------------------------------------------
QGroupBox *TapeConfigurationPage::GradationGroup()
{
gradationGroup = new QGroupBox(tr("Default height and size"));
QFormLayout *gradationLayout = new QFormLayout;
gradationLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
const VTapeSettings *settings = qApp->TapeSettings();
defHeightLabel = new QLabel(tr("Default height:"));
defHeightCombo = new QComboBox;
defHeightCombo->addItems(VMeasurement::WholeListHeights(Unit::Cm));
int index = defHeightCombo->findText(QString().setNum(settings->GetDefHeight()));
if (index != -1)
{
defHeightCombo->setCurrentIndex(index);
}
connect(defHeightCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&TapeConfigurationPage::DefGradationChanged);
gradationLayout->addRow(defHeightLabel, defHeightCombo);
defSizeLabel = new QLabel(tr("Default size:"));
defSizeCombo = new QComboBox;
defSizeCombo->addItems(VMeasurement::WholeListSizes(Unit::Cm));
index = defSizeCombo->findText(QString().setNum(settings->GetDefSize()));
if (index != -1)
{
defSizeCombo->setCurrentIndex(index);
}
connect(defHeightCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&TapeConfigurationPage::DefGradationChanged);
gradationLayout->addRow(defSizeLabel, defSizeCombo);
gradationGroup->setLayout(gradationLayout);
return gradationGroup;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TapeConfigurationPage::SetLabelComboBox(const QStringList &list) void TapeConfigurationPage::SetLabelComboBox(const QStringList &list)
{ {
@ -259,8 +334,12 @@ void TapeConfigurationPage::SetLabelComboBox(const QStringList &list)
void TapeConfigurationPage::RetranslateUi() void TapeConfigurationPage::RetranslateUi()
{ {
langGroup->setTitle(tr("Language")); langGroup->setTitle(tr("Language"));
guiLabel->setText(tr("GUI language")); guiLabel->setText(tr("GUI language:"));
systemLabel->setText(tr("Pattern making system")); separatorLabel->setText(tr("Decimal separator parts:"));
osOptionCheck = new QCheckBox(tr("With OS options (%1)").arg(QLocale::system().decimalPoint().toLatin1()));
pmSystemGroup->setTitle(tr("Pattern making system"));
systemLabel->setText(tr("Pattern making system:"));
const int index = systemCombo->currentIndex(); const int index = systemCombo->currentIndex();
systemCombo->blockSignals(true); systemCombo->blockSignals(true);
@ -286,6 +365,7 @@ void TapeConfigurationPage::RetranslateUi()
#endif #endif
systemBookValueLabel->setPlainText(text); systemBookValueLabel->setPlainText(text);
separatorLabel->setText(tr("Decimal separator parts")); gradationGroup->setTitle(tr("Default height and size"));
osOptionCheck = new QCheckBox(tr("With OS options (%1)").arg(QLocale::system().decimalPoint().toLatin1())); defHeightLabel->setText(tr("Default height:"));
defSizeLabel->setText(tr("Default size:"));
} }

View File

@ -48,6 +48,7 @@ public:
public slots: public slots:
void LangChanged(); void LangChanged();
void SystemChanged(); void SystemChanged();
void DefGradationChanged();
void UnitChanged(); void UnitChanged();
void LabelLangChanged(); void LabelLangChanged();
protected: protected:
@ -61,6 +62,7 @@ private:
QCheckBox *osOptionCheck; QCheckBox *osOptionCheck;
bool langChanged; bool langChanged;
bool systemChanged; bool systemChanged;
bool defGradationChanged;
bool unitChanged; bool unitChanged;
bool labelLangChanged; bool labelLangChanged;
QCheckBox *sendReportCheck; QCheckBox *sendReportCheck;
@ -71,12 +73,22 @@ private:
QGroupBox *langGroup; QGroupBox *langGroup;
QLabel *guiLabel; QLabel *guiLabel;
QLabel *separatorLabel;
QGroupBox *pmSystemGroup;
QLabel *systemLabel; QLabel *systemLabel;
QLabel *systemAuthorLabel; QLabel *systemAuthorLabel;
QLabel *systemBookLabel; QLabel *systemBookLabel;
QLabel *separatorLabel;
QGroupBox *gradationGroup;
QLabel *defHeightLabel;
QLabel *defSizeLabel;
QComboBox *defHeightCombo;
QComboBox *defSizeCombo;
QGroupBox *LangGroup(); QGroupBox *LangGroup();
QGroupBox *PMSystemGroup();
QGroupBox *GradationGroup();
void SetLabelComboBox(const QStringList &list); void SetLabelComboBox(const QStringList &list);
void RetranslateUi(); void RetranslateUi();
}; };

View File

@ -30,6 +30,8 @@
#include "ui_dialognewmeasurements.h" #include "ui_dialognewmeasurements.h"
#include "../vpatterndb/variables/vmeasurement.h" #include "../vpatterndb/variables/vmeasurement.h"
#include "../vmisc/vtapesettings.h"
#include "../mapplication.h"
#include <QShowEvent> #include <QShowEvent>
@ -46,6 +48,22 @@ DialogNewMeasurements::DialogNewMeasurements(QWidget *parent)
InitHeightsList(); InitHeightsList();
InitSizesList(); InitSizesList();
const VTapeSettings *settings = qApp->TapeSettings();
const int height = static_cast<int>(UnitConvertor(settings->GetDefHeight(), Unit::Cm, MUnit()));
int index = ui->comboBoxBaseHeight->findText(QString().setNum(height));
if (index != -1)
{
ui->comboBoxBaseHeight->setCurrentIndex(index);
}
const int size = static_cast<int>(UnitConvertor(settings->GetDefSize(), Unit::Cm, MUnit()));
index = ui->comboBoxBaseSize->findText(QString().setNum(size));
if (index != -1)
{
ui->comboBoxBaseSize->setCurrentIndex(index);
}
connect(ui->comboBoxMType, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, connect(ui->comboBoxMType, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogNewMeasurements::CurrentTypeChanged); &DialogNewMeasurements::CurrentTypeChanged);
@ -155,8 +173,17 @@ void DialogNewMeasurements::CurrentTypeChanged(int index)
void DialogNewMeasurements::CurrentUnitChanged(int index) void DialogNewMeasurements::CurrentUnitChanged(int index)
{ {
Q_UNUSED(index); Q_UNUSED(index);
InitHeightsList();
InitSizesList(); if (MUnit() != Unit::Inch)
{
int i = ui->comboBoxBaseHeight->currentIndex();
InitHeightsList();
ui->comboBoxBaseHeight->setCurrentIndex(i);
i = ui->comboBoxBaseSize->currentIndex();
InitSizesList();
ui->comboBoxBaseSize->setCurrentIndex(i);
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -222,6 +249,7 @@ void DialogNewMeasurements::InitUnits(const MeasurementsType &type)
{ {
ui->comboBoxUnit->addItem(tr("Inches"), static_cast<int>(Unit::Inch)); ui->comboBoxUnit->addItem(tr("Inches"), static_cast<int>(Unit::Inch));
} }
ui->comboBoxUnit->setCurrentIndex(-1);
ui->comboBoxUnit->blockSignals(false); ui->comboBoxUnit->blockSignals(false);
int index = ui->comboBoxUnit->findData(val); int index = ui->comboBoxUnit->findData(val);
@ -229,4 +257,9 @@ void DialogNewMeasurements::InitUnits(const MeasurementsType &type)
{ {
ui->comboBoxUnit->setCurrentIndex(index); ui->comboBoxUnit->setCurrentIndex(index);
} }
else
{
index = ui->comboBoxUnit->findData(static_cast<int>(Unit::Cm));
ui->comboBoxUnit->setCurrentIndex(index);
}
} }

View File

@ -34,7 +34,14 @@
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QComboBox" name="comboBoxMType"/> <widget class="QComboBox" name="comboBoxMType">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label_5">
@ -44,7 +51,14 @@
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QComboBox" name="comboBoxUnit"/> <widget class="QComboBox" name="comboBoxUnit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
@ -58,6 +72,21 @@
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="minimumContentsLength">
<number>3</number>
</property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
@ -72,6 +101,21 @@
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="minimumContentsLength">
<number>4</number>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@ -33,6 +33,9 @@
const QString VTapeSettings::SettingDataBaseGeometry = QStringLiteral("database/geometry"); const QString VTapeSettings::SettingDataBaseGeometry = QStringLiteral("database/geometry");
const QString VTapeSettings::SettingDefHeight = QStringLiteral("gradation/defHeight");
const QString VTapeSettings::SettingDefSize = QStringLiteral("gradation/defHeight");
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VTapeSettings::VTapeSettings(Format format, Scope scope, const QString &organization, const QString &application, VTapeSettings::VTapeSettings(Format format, Scope scope, const QString &organization, const QString &application,
QObject *parent) QObject *parent)
@ -51,3 +54,27 @@ void VTapeSettings::SetDataBaseGeometry(const QByteArray &value)
{ {
setValue(SettingDataBaseGeometry, value); setValue(SettingDataBaseGeometry, value);
} }
//---------------------------------------------------------------------------------------------------------------------
void VTapeSettings::SetDefHeight(int value)
{
setValue(SettingDefHeight, value);
}
//---------------------------------------------------------------------------------------------------------------------
int VTapeSettings::GetDefHeight() const
{
return value(SettingDefHeight, 176).toInt();
}
//---------------------------------------------------------------------------------------------------------------------
void VTapeSettings::SetDefSize(int value)
{
setValue(SettingDefSize, value);
}
//---------------------------------------------------------------------------------------------------------------------
int VTapeSettings::GetDefSize() const
{
return value(SettingDefSize, 50).toInt();
}

View File

@ -41,10 +41,18 @@ public:
QByteArray GetDataBaseGeometry() const; QByteArray GetDataBaseGeometry() const;
void SetDataBaseGeometry(const QByteArray &value); void SetDataBaseGeometry(const QByteArray &value);
void SetDefHeight(int value);
int GetDefHeight() const;
void SetDefSize(int value);
int GetDefSize() const;
private: private:
Q_DISABLE_COPY(VTapeSettings) Q_DISABLE_COPY(VTapeSettings)
static const QString SettingDataBaseGeometry; static const QString SettingDataBaseGeometry;
static const QString SettingDefHeight;
static const QString SettingDefSize;
}; };
#endif // VTAPESETTINGS_H #endif // VTAPESETTINGS_H