+ Set number of deciamls with GUI

This commit is contained in:
wmayer 2014-02-16 12:39:03 +01:00
parent 1be3308c21
commit 2d511524ac
3 changed files with 56 additions and 27 deletions

View File

@ -19,8 +19,8 @@
<property name="title">
<string>Units settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
@ -50,7 +50,28 @@
</item>
</layout>
</item>
<item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Number of decimals:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBoxDecimals">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QTableWidget" name="tableWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
@ -73,6 +94,19 @@
</column>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>79</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>

View File

@ -27,6 +27,7 @@
# include <QRegExp>
#endif
#include "ui_DlgSettingsUnits.h"
#include "DlgSettingsUnitsImp.h"
#include "NavigationStyle.h"
#include "PrefWidgets.h"
@ -45,18 +46,12 @@ using namespace Base;
* name 'name' and widget flags set to 'f'
*/
DlgSettingsUnitsImp::DlgSettingsUnitsImp(QWidget* parent)
: PreferencePage( parent )
: PreferencePage( parent ), ui(new Ui_DlgSettingsUnits)
{
this->setupUi(this);
//this->setEnabled(false);
retranslate();
ui->setupUi(this);
//fillUpListBox();
QObject::connect(comboBox_ViewSystem, SIGNAL(currentIndexChanged(int)), this, SLOT(currentIndexChanged(int)));
tableWidget->setVisible(false);
ui->tableWidget->setVisible(false);
}
/**
@ -65,6 +60,7 @@ DlgSettingsUnitsImp::DlgSettingsUnitsImp(QWidget* parent)
DlgSettingsUnitsImp::~DlgSettingsUnitsImp()
{
// no need to delete child widgets, Qt does it all for us
delete ui;
}
void DlgSettingsUnitsImp::fillUpListBox()
@ -79,11 +75,10 @@ void DlgSettingsUnitsImp::fillUpListBox()
//}
}
void DlgSettingsUnitsImp::currentIndexChanged(int index)
void DlgSettingsUnitsImp::on_comboBox_ViewSystem_currentIndexChanged(int index)
{
if (index < 0)
return; // happens when clearing the combo box in retranslateUi()
assert(index>-1 && index <3);
UnitsApi::setSchema((UnitSystem)index);
@ -96,15 +91,17 @@ void DlgSettingsUnitsImp::saveSettings()
// where we set some attributes afterwards
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Units");
hGrp->SetInt("UserSchema", comboBox_ViewSystem->currentIndex());
hGrp->SetInt("UserSchema", ui->comboBox_ViewSystem->currentIndex());
hGrp->SetInt("Decimals", ui->spinBoxDecimals->value());
Base::UnitsApi::setDecimals(ui->spinBoxDecimals->value());
}
void DlgSettingsUnitsImp::loadSettings()
{
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Units");
comboBox_ViewSystem->setCurrentIndex(hGrp->GetInt("UserSchema",0));
ui->comboBox_ViewSystem->setCurrentIndex(hGrp->GetInt("UserSchema",0));
ui->spinBoxDecimals->setValue(hGrp->GetInt("Decimals",Base::UnitsApi::getDecimals()));
}
/**
@ -113,16 +110,13 @@ void DlgSettingsUnitsImp::loadSettings()
void DlgSettingsUnitsImp::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange) {
retranslateUi(this);
retranslate();
int index = ui->comboBox_ViewSystem->currentIndex();
ui->retranslateUi(this);
ui->comboBox_ViewSystem->setCurrentIndex(index);
}
else {
QWidget::changeEvent(e);
}
}
void DlgSettingsUnitsImp::retranslate()
{
}
#include "moc_DlgSettingsUnitsImp.cpp"

View File

@ -24,7 +24,6 @@
#ifndef GUI_DIALOG_DLGSETTINGSUnitsIMP_H
#define GUI_DIALOG_DLGSETTINGSUnitsIMP_H
#include "ui_DlgSettingsUnits.h"
#include "PropertyPage.h"
namespace Gui {
@ -35,7 +34,8 @@ namespace Dialog {
* for the Unit system.
* \author Jürgen Riegel
*/
class DlgSettingsUnitsImp : public PreferencePage, public Ui_DlgSettingsUnits
class Ui_DlgSettingsUnits;
class DlgSettingsUnitsImp : public PreferencePage
{
Q_OBJECT
@ -48,13 +48,14 @@ public:
protected:
void changeEvent(QEvent *e);
void retranslate();
void fillUpListBox(void);
public Q_SLOTS:
void currentIndexChanged(int index);
void on_comboBox_ViewSystem_currentIndexChanged(int index);
private:
Ui_DlgSettingsUnits* ui;
};
} // namespace Dialog