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 "../../mapplication.h"
#include "../vmisc/vtapesettings.h"
#include "../vpatterndb/variables/vmeasurement.h"
#include <QDir>
#include <QGroupBox>
#include <QLabel>
@ -52,6 +53,7 @@ TapeConfigurationPage::TapeConfigurationPage(QWidget *parent)
osOptionCheck(nullptr),
langChanged(false),
systemChanged(false),
defGradationChanged(false),
unitChanged(false),
labelLangChanged(false),
sendReportCheck(nullptr),
@ -61,15 +63,25 @@ TapeConfigurationPage::TapeConfigurationPage(QWidget *parent)
systemBookValueLabel(nullptr),
langGroup(nullptr),
guiLabel(nullptr),
separatorLabel(nullptr),
pmSystemGroup(nullptr),
systemLabel(nullptr),
systemAuthorLabel(nullptr),
systemBookLabel(nullptr),
separatorLabel(nullptr)
gradationGroup(nullptr),
defHeightLabel(nullptr),
defSizeLabel(nullptr),
defHeightCombo(nullptr),
defSizeCombo(nullptr)
{
QGroupBox *langGroup = LangGroup();
QGroupBox *pmSystemGroup = PMSystemGroup();
QGroupBox *gradationBox = GradationGroup();
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(langGroup);
mainLayout->addWidget(pmSystemGroup);
mainLayout->addWidget(gradationBox);
mainLayout->addStretch(1);
setLayout(mainLayout);
}
@ -96,6 +108,13 @@ void TapeConfigurationPage::Apply()
qApp->RetranslateTables();
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);
}
//---------------------------------------------------------------------------------------------------------------------
void TapeConfigurationPage::DefGradationChanged()
{
defGradationChanged = true;
}
//---------------------------------------------------------------------------------------------------------------------
void TapeConfigurationPage::UnitChanged()
{
@ -200,38 +225,6 @@ QGroupBox *TapeConfigurationPage::LangGroup()
langLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
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
separatorLabel = new QLabel(tr("Decimal separator parts:"));
@ -245,6 +238,88 @@ QGroupBox *TapeConfigurationPage::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)
{
@ -259,8 +334,12 @@ void TapeConfigurationPage::SetLabelComboBox(const QStringList &list)
void TapeConfigurationPage::RetranslateUi()
{
langGroup->setTitle(tr("Language"));
guiLabel->setText(tr("GUI language"));
systemLabel->setText(tr("Pattern making system"));
guiLabel->setText(tr("GUI language:"));
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();
systemCombo->blockSignals(true);
@ -286,6 +365,7 @@ void TapeConfigurationPage::RetranslateUi()
#endif
systemBookValueLabel->setPlainText(text);
separatorLabel->setText(tr("Decimal separator parts"));
osOptionCheck = new QCheckBox(tr("With OS options (%1)").arg(QLocale::system().decimalPoint().toLatin1()));
gradationGroup->setTitle(tr("Default height and size"));
defHeightLabel->setText(tr("Default height:"));
defSizeLabel->setText(tr("Default size:"));
}

View File

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

View File

@ -30,6 +30,8 @@
#include "ui_dialognewmeasurements.h"
#include "../vpatterndb/variables/vmeasurement.h"
#include "../vmisc/vtapesettings.h"
#include "../mapplication.h"
#include <QShowEvent>
@ -46,6 +48,22 @@ DialogNewMeasurements::DialogNewMeasurements(QWidget *parent)
InitHeightsList();
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,
&DialogNewMeasurements::CurrentTypeChanged);
@ -155,8 +173,17 @@ void DialogNewMeasurements::CurrentTypeChanged(int index)
void DialogNewMeasurements::CurrentUnitChanged(int 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->setCurrentIndex(-1);
ui->comboBoxUnit->blockSignals(false);
int index = ui->comboBoxUnit->findData(val);
@ -229,4 +257,9 @@ void DialogNewMeasurements::InitUnits(const MeasurementsType &type)
{
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>
</item>
<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 row="1" column="0">
<widget class="QLabel" name="label_5">
@ -44,7 +51,14 @@
</widget>
</item>
<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 row="2" column="0">
<widget class="QLabel" name="label_2">
@ -58,6 +72,21 @@
<property name="enabled">
<bool>false</bool>
</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>
</item>
<item row="3" column="0">
@ -72,6 +101,21 @@
<property name="enabled">
<bool>false</bool>
</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>
</item>
</layout>

View File

@ -33,6 +33,9 @@
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,
QObject *parent)
@ -51,3 +54,27 @@ void VTapeSettings::SetDataBaseGeometry(const QByteArray &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;
void SetDataBaseGeometry(const QByteArray &value);
void SetDefHeight(int value);
int GetDefHeight() const;
void SetDefSize(int value);
int GetDefSize() const;
private:
Q_DISABLE_COPY(VTapeSettings)
static const QString SettingDataBaseGeometry;
static const QString SettingDefHeight;
static const QString SettingDefSize;
};
#endif // VTAPESETTINGS_H