Pref: Remove Unit tab and move settings back to main page.
This commit is contained in:
@@ -320,7 +320,6 @@ SET(Gui_UIC_SRCS
|
||||
DlgSettingsCacheDirectory.ui
|
||||
DlgSettingsNavigation.ui
|
||||
DlgSettingsSelection.ui
|
||||
DlgSettingsUnits.ui
|
||||
DlgSettingsViewColor.ui
|
||||
DlgSettingsColorGradient.ui
|
||||
DlgSettingsDocument.ui
|
||||
@@ -562,7 +561,6 @@ SET(Dialog_Settings_CPP_SRCS
|
||||
DlgSettingsCacheDirectory.cpp
|
||||
DlgSettingsNavigation.cpp
|
||||
DlgSettingsSelection.cpp
|
||||
DlgSettingsUnitsImp.cpp
|
||||
DlgSettingsViewColor.cpp
|
||||
DlgSettingsColorGradientImp.cpp
|
||||
DlgSettingsDocumentImp.cpp
|
||||
@@ -582,7 +580,6 @@ SET(Dialog_Settings_HPP_SRCS
|
||||
DlgSettingsCacheDirectory.h
|
||||
DlgSettingsNavigation.h
|
||||
DlgSettingsSelection.h
|
||||
DlgSettingsUnitsImp.h
|
||||
DlgSettingsViewColor.h
|
||||
DlgSettingsColorGradientImp.h
|
||||
DlgSettingsDocumentImp.h
|
||||
@@ -604,7 +601,6 @@ SET(Dialog_Settings_SRCS
|
||||
DlgSettingsCacheDirectory.ui
|
||||
DlgSettingsNavigation.ui
|
||||
DlgSettingsSelection.ui
|
||||
DlgSettingsUnits.ui
|
||||
DlgSettingsViewColor.ui
|
||||
DlgSettingsColorGradient.ui
|
||||
DlgSettingsDocument.ui
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<item>
|
||||
<widget class="QGroupBox" name="GroupBox7">
|
||||
<property name="title">
|
||||
<string>Language</string>
|
||||
<string>Language and number format</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
@@ -59,7 +59,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="TextLabel1_4">
|
||||
<property name="text">
|
||||
<string>Change language:</string>
|
||||
<string>Language:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -71,13 +71,100 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="unitSystemLabel">
|
||||
<property name="text">
|
||||
<string>Unit system:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="comboBox_UnitSystem">
|
||||
<property name="toolTip">
|
||||
<string>Unit system that should be used for all parts the application</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="decimalsLabel">
|
||||
<property name="text">
|
||||
<string>Number of decimals:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBoxDecimals">
|
||||
<property name="toolTip">
|
||||
<string>Number of decimals that should be shown for numbers and dimensions</string>
|
||||
</property>
|
||||
<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="QLabel" name="fractionalInchLabel">
|
||||
<property name="text">
|
||||
<string>Minimum fractional inch:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="comboBox_FracInch">
|
||||
<property name="toolTip">
|
||||
<string>Minimum fractional inch to be displayed</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">1/2"</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">1/4"</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">1/8"</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">1/16"</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">1/32"</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">1/64"</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">1/128"</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="TextLabel1_5">
|
||||
<property name="text">
|
||||
<string>Number format:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="3" column="1">
|
||||
<widget class="Gui::PrefComboBox" name="UseLocaleFormatting">
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>UseLocaleFormatting</cstring>
|
||||
@@ -102,7 +189,7 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<item row="3" column="2">
|
||||
<widget class="Gui::PrefCheckBox" name="SubstituteDecimal">
|
||||
<property name="toolTip">
|
||||
<string>If enabled, numerical keypad decimal separator
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <cmath>
|
||||
# include <limits>
|
||||
# include <QApplication>
|
||||
# include <QFileDialog>
|
||||
# include <QLocale>
|
||||
@@ -33,6 +35,9 @@
|
||||
# include <boost/filesystem.hpp>
|
||||
#endif
|
||||
|
||||
#include <Base/Parameter.h>
|
||||
#include <Base/UnitsApi.h>
|
||||
|
||||
#include "DlgGeneralImp.h"
|
||||
#include "ui_DlgGeneral.h"
|
||||
#include "Action.h"
|
||||
@@ -47,6 +52,7 @@
|
||||
|
||||
using namespace Gui::Dialog;
|
||||
namespace fs = boost::filesystem;
|
||||
using namespace Base;
|
||||
|
||||
/* TRANSLATOR Gui::Dialog::DlgGeneralImp */
|
||||
|
||||
@@ -76,6 +82,26 @@ DlgGeneralImp::DlgGeneralImp( QWidget* parent )
|
||||
const auto & backups = Application::Instance->prefPackManager()->configBackups();
|
||||
ui->RevertToSavedConfig->setEnabled(backups.empty());
|
||||
connect(ui->RevertToSavedConfig, &QPushButton::clicked, this, &DlgGeneralImp::revertToSavedConfig);
|
||||
|
||||
ui->spinBoxDecimals->setMaximum(std::numeric_limits<double>::digits10 + 1);
|
||||
|
||||
int num = static_cast<int>(Base::UnitSystem::NumUnitSystemTypes);
|
||||
for (int i = 0; i < num; i++) {
|
||||
QString item = qApp->translate("Gui::Dialog::DlgGeneralImp", Base::UnitsApi::getDescription(static_cast<Base::UnitSystem>(i)));
|
||||
ui->comboBox_UnitSystem->addItem(item, i);
|
||||
}
|
||||
|
||||
// Enable/disable the fractional inch option depending on system
|
||||
if (UnitsApi::getSchema() == UnitSystem::ImperialBuilding)
|
||||
{
|
||||
ui->comboBox_FracInch->setVisible(true);
|
||||
ui->fractionalInchLabel->setVisible(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->comboBox_FracInch->setVisible(false);
|
||||
ui->fractionalInchLabel->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,6 +174,35 @@ void DlgGeneralImp::setDecimalPointConversion(bool on)
|
||||
|
||||
void DlgGeneralImp::saveSettings()
|
||||
{
|
||||
// must be done as very first because we create a new instance of NavigatorStyle
|
||||
// where we set some attributes afterwards
|
||||
int FracInch; // minimum fractional inch to display
|
||||
int viewSystemIndex; // currently selected View System (unit system)
|
||||
|
||||
ParameterGrp::handle hGrpu = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/Units");
|
||||
hGrpu->SetInt("UserSchema", ui->comboBox_UnitSystem->currentIndex());
|
||||
hGrpu->SetInt("Decimals", ui->spinBoxDecimals->value());
|
||||
|
||||
// Set actual value
|
||||
Base::UnitsApi::setDecimals(ui->spinBoxDecimals->value());
|
||||
|
||||
// Convert the combobox index to the its integer denominator. Currently
|
||||
// with 1/2, 1/4, through 1/128, this little equation directly computes the
|
||||
// denominator given the combobox integer.
|
||||
//
|
||||
// The inverse conversion is done when loaded. That way only one thing (the
|
||||
// numerical fractional inch value) needs to be stored.
|
||||
FracInch = std::pow(2, ui->comboBox_FracInch->currentIndex() + 1);
|
||||
hGrpu->SetInt("FracInch", FracInch);
|
||||
|
||||
// Set the actual format value
|
||||
Base::QuantityFormat::setDefaultDenominator(FracInch);
|
||||
|
||||
// Set and save the Unit System
|
||||
viewSystemIndex = ui->comboBox_UnitSystem->currentIndex();
|
||||
UnitsApi::setSchema(static_cast<UnitSystem>(viewSystemIndex));
|
||||
|
||||
ui->SubstituteDecimal->onSave();
|
||||
ui->UseLocaleFormatting->onSave();
|
||||
ui->RecentFiles->onSave();
|
||||
@@ -197,6 +252,23 @@ void DlgGeneralImp::saveSettings()
|
||||
|
||||
void DlgGeneralImp::loadSettings()
|
||||
{
|
||||
int FracInch;
|
||||
int cbIndex;
|
||||
|
||||
ParameterGrp::handle hGrpu = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/Units");
|
||||
ui->comboBox_UnitSystem->setCurrentIndex(hGrpu->GetInt("UserSchema", 0));
|
||||
ui->spinBoxDecimals->setValue(hGrpu->GetInt("Decimals", Base::UnitsApi::getDecimals()));
|
||||
|
||||
// Get the current user setting for the minimum fractional inch
|
||||
FracInch = hGrpu->GetInt("FracInch", Base::QuantityFormat::getDefaultDenominator());
|
||||
|
||||
// Convert fractional inch to the corresponding combobox index using this
|
||||
// handy little equation.
|
||||
cbIndex = std::log2(FracInch) - 1;
|
||||
ui->comboBox_FracInch->setCurrentIndex(cbIndex);
|
||||
|
||||
|
||||
ui->SubstituteDecimal->onRestore();
|
||||
ui->UseLocaleFormatting->onRestore();
|
||||
ui->RecentFiles->onRestore();
|
||||
@@ -323,8 +395,10 @@ void DlgGeneralImp::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::LanguageChange) {
|
||||
int index = ui->UseLocaleFormatting->currentIndex();
|
||||
int index2 = ui->comboBox_UnitSystem->currentIndex();
|
||||
ui->retranslateUi(this);
|
||||
ui->UseLocaleFormatting->setCurrentIndex(index);
|
||||
ui->comboBox_UnitSystem->setCurrentIndex(index2);
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(event);
|
||||
@@ -462,4 +536,23 @@ void DlgGeneralImp::onLoadPreferencePackClicked(const std::string& packName)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DlgGeneralImp::on_comboBox_UnitSystem_currentIndexChanged(int index)
|
||||
{
|
||||
if (index < 0)
|
||||
return; // happens when clearing the combo box in retranslateUi()
|
||||
|
||||
// Enable/disable the fractional inch option depending on system
|
||||
if (static_cast<UnitSystem>(index) == UnitSystem::ImperialBuilding)
|
||||
{
|
||||
ui->comboBox_FracInch->setVisible(true);
|
||||
ui->fractionalInchLabel->setVisible(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->comboBox_FracInch->setVisible(false);
|
||||
ui->fractionalInchLabel->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_DlgGeneralImp.cpp"
|
||||
|
||||
@@ -64,6 +64,9 @@ protected Q_SLOTS:
|
||||
void onManagePreferencePacksClicked();
|
||||
void onImportConfigClicked();
|
||||
|
||||
public Q_SLOTS:
|
||||
void on_comboBox_UnitSystem_currentIndexChanged(int index);
|
||||
|
||||
private:
|
||||
void setRecentFileSize();
|
||||
void saveAsNewPreferencePack();
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Gui::Dialog::DlgSettingsUnits</class>
|
||||
<widget class="QWidget" name="Gui::Dialog::DlgSettingsUnits">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>484</width>
|
||||
<height>388</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Units</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="GroupBox6">
|
||||
<property name="title">
|
||||
<string>Units settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Unit system:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_ViewSystem">
|
||||
<property name="toolTip">
|
||||
<string>Unit system that should be used for all parts the application</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</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="toolTip">
|
||||
<string>Number of decimals that should be shown for numbers and dimensions</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>12</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Minimum fractional inch:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_FracInch">
|
||||
<property name="toolTip">
|
||||
<string>Minimum fractional inch to be displayed</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">1/2"</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">1/4"</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">1/8"</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">1/16"</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">1/32"</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">1/64"</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">1/128"</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QTableWidget" name="tableWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Magnitude</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Unit</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" 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>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -1,175 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2010 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <cmath>
|
||||
# include <limits>
|
||||
# include <QApplication>
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <Base/Parameter.h>
|
||||
#include <Base/UnitsApi.h>
|
||||
|
||||
#include "ui_DlgSettingsUnits.h"
|
||||
#include "DlgSettingsUnitsImp.h"
|
||||
|
||||
|
||||
using namespace Gui::Dialog;
|
||||
using namespace Base;
|
||||
|
||||
/* TRANSLATOR Gui::Dialog::DlgSettingsUnitsImp */
|
||||
|
||||
#if 0 // needed for Qt's lupdate utility
|
||||
qApp->translate("Gui::Dialog::DlgSettingsUnits", "Standard (mm/kg/s/degree)");
|
||||
qApp->translate("Gui::Dialog::DlgSettingsUnits", "MKS (m/kg/s/degree)");
|
||||
qApp->translate("Gui::Dialog::DlgSettingsUnits", "US customary (in/lb)");
|
||||
qApp->translate("Gui::Dialog::DlgSettingsUnits", "Imperial decimal (in/lb)");
|
||||
qApp->translate("Gui::Dialog::DlgSettingsUnits", "Building Euro (cm/m²/m³)");
|
||||
qApp->translate("Gui::Dialog::DlgSettingsUnits", "Building US (ft-in/sqft/cft)");
|
||||
qApp->translate("Gui::Dialog::DlgSettingsUnits", "Metric small parts & CNC(mm, mm/min)");
|
||||
qApp->translate("Gui::Dialog::DlgSettingsUnits", "Imperial for Civil Eng (ft, ft/sec)");
|
||||
qApp->translate("Gui::Dialog::DlgSettingsUnits", "FEM (mm, N, s)");
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Constructs a DlgSettingsUnitsImp which is a child of 'parent', with the
|
||||
* name 'name' and widget flags set to 'f'
|
||||
*/
|
||||
DlgSettingsUnitsImp::DlgSettingsUnitsImp(QWidget* parent)
|
||||
: PreferencePage( parent ), ui(new Ui_DlgSettingsUnits)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->spinBoxDecimals->setMaximum(std::numeric_limits<double>::digits10 + 1);
|
||||
|
||||
int num = static_cast<int>(Base::UnitSystem::NumUnitSystemTypes);
|
||||
for (int i = 0; i < num; i++) {
|
||||
QString item = qApp->translate("Gui::Dialog::DlgSettingsUnits", Base::UnitsApi::getDescription(static_cast<Base::UnitSystem>(i)));
|
||||
ui->comboBox_ViewSystem->addItem(item, i);
|
||||
}
|
||||
|
||||
ui->tableWidget->setVisible(false);
|
||||
//
|
||||
// Enable/disable the fractional inch option depending on system
|
||||
if( UnitsApi::getSchema() == UnitSystem::ImperialBuilding )
|
||||
{
|
||||
ui->comboBox_FracInch->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->comboBox_FracInch->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the object and frees any allocated resources
|
||||
*/
|
||||
DlgSettingsUnitsImp::~DlgSettingsUnitsImp()
|
||||
{
|
||||
// no need to delete child widgets, Qt does it all for us
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DlgSettingsUnitsImp::on_comboBox_ViewSystem_currentIndexChanged(int index)
|
||||
{
|
||||
if (index < 0)
|
||||
return; // happens when clearing the combo box in retranslateUi()
|
||||
|
||||
// Enable/disable the fractional inch option depending on system
|
||||
if( static_cast<UnitSystem>(index) == UnitSystem::ImperialBuilding )
|
||||
{
|
||||
ui->comboBox_FracInch->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->comboBox_FracInch->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsUnitsImp::saveSettings()
|
||||
{
|
||||
// must be done as very first because we create a new instance of NavigatorStyle
|
||||
// where we set some attributes afterwards
|
||||
int FracInch; // minimum fractional inch to display
|
||||
int viewSystemIndex; // currently selected View System (unit system)
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/Units");
|
||||
hGrp->SetInt("UserSchema", ui->comboBox_ViewSystem->currentIndex());
|
||||
hGrp->SetInt("Decimals", ui->spinBoxDecimals->value());
|
||||
|
||||
// Set actual value
|
||||
Base::UnitsApi::setDecimals(ui->spinBoxDecimals->value());
|
||||
|
||||
// Convert the combobox index to the its integer denominator. Currently
|
||||
// with 1/2, 1/4, through 1/128, this little equation directly computes the
|
||||
// denominator given the combobox integer.
|
||||
//
|
||||
// The inverse conversion is done when loaded. That way only one thing (the
|
||||
// numerical fractional inch value) needs to be stored.
|
||||
FracInch = std::pow(2, ui->comboBox_FracInch->currentIndex() + 1);
|
||||
hGrp->SetInt("FracInch", FracInch);
|
||||
|
||||
// Set the actual format value
|
||||
Base::QuantityFormat::setDefaultDenominator(FracInch);
|
||||
|
||||
// Set and save the Unit System
|
||||
viewSystemIndex = ui->comboBox_ViewSystem->currentIndex();
|
||||
UnitsApi::setSchema(static_cast<UnitSystem>(viewSystemIndex));
|
||||
}
|
||||
|
||||
void DlgSettingsUnitsImp::loadSettings()
|
||||
{
|
||||
int FracInch;
|
||||
int cbIndex;
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/Units");
|
||||
ui->comboBox_ViewSystem->setCurrentIndex(hGrp->GetInt("UserSchema",0));
|
||||
ui->spinBoxDecimals->setValue(hGrp->GetInt("Decimals",Base::UnitsApi::getDecimals()));
|
||||
|
||||
// Get the current user setting for the minimum fractional inch
|
||||
FracInch = hGrp->GetInt("FracInch", Base::QuantityFormat::getDefaultDenominator());
|
||||
|
||||
// Convert fractional inch to the corresponding combobox index using this
|
||||
// handy little equation.
|
||||
cbIndex = std::log2(FracInch) - 1;
|
||||
ui->comboBox_FracInch->setCurrentIndex(cbIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the strings of the subwidgets using the current language.
|
||||
*/
|
||||
void DlgSettingsUnitsImp::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
int index = ui->comboBox_ViewSystem->currentIndex();
|
||||
ui->retranslateUi(this);
|
||||
ui->comboBox_ViewSystem->setCurrentIndex(index);
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_DlgSettingsUnitsImp.cpp"
|
||||
@@ -1,62 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2010 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef GUI_DIALOG_DLGSETTINGSUnitsIMP_H
|
||||
#define GUI_DIALOG_DLGSETTINGSUnitsIMP_H
|
||||
|
||||
#include "PropertyPage.h"
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
|
||||
/**
|
||||
* The DlgSettingsUnitsImp class implements a preference page to change settings
|
||||
* for the Unit system.
|
||||
* \author Jürgen Riegel
|
||||
*/
|
||||
class Ui_DlgSettingsUnits;
|
||||
class DlgSettingsUnitsImp : public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgSettingsUnitsImp(QWidget* parent = nullptr);
|
||||
~DlgSettingsUnitsImp() override;
|
||||
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
|
||||
public Q_SLOTS:
|
||||
void on_comboBox_ViewSystem_currentIndexChanged(int index);
|
||||
|
||||
private:
|
||||
Ui_DlgSettingsUnits* ui;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSUnitsIMP_H
|
||||
@@ -53,7 +53,7 @@ DlgUnitsCalculator::DlgUnitsCalculator( QWidget* parent, Qt::WindowFlags fl )
|
||||
ui->comboBoxScheme->addItem(QString::fromLatin1("Preference system"), static_cast<int>(-1));
|
||||
int num = static_cast<int>(Base::UnitSystem::NumUnitSystemTypes);
|
||||
for (int i=0; i<num; i++) {
|
||||
QString item = qApp->translate("Gui::Dialog::DlgSettingsUnits", Base::UnitsApi::getDescription(static_cast<Base::UnitSystem>(i)));
|
||||
QString item = qApp->translate("Gui::Dialog::DlgGeneralImp", Base::UnitsApi::getDescription(static_cast<Base::UnitSystem>(i)));
|
||||
ui->comboBoxScheme->addItem(item, i);
|
||||
}
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ private:
|
||||
assert(actions.size() <= maxSchema);
|
||||
for(int i = 0; i < maxSchema ; i++)
|
||||
{
|
||||
actions[i]->setText(qApp->translate("Gui::Dialog::DlgSettingsUnits",
|
||||
actions[i]->setText(qApp->translate("Gui::Dialog::DlgGeneralImp",
|
||||
Base::UnitsApi::getDescription(static_cast<Base::UnitSystem>(i))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include "DlgSettingsNotificationArea.h"
|
||||
#include "DlgSettingsPythonConsole.h"
|
||||
#include "DlgSettingsMacroImp.h"
|
||||
#include "DlgSettingsUnitsImp.h"
|
||||
#include "DlgSettingsDocumentImp.h"
|
||||
#include "DlgReportViewImp.h"
|
||||
#include "DlgSettingsWorkbenchesImp.h"
|
||||
@@ -75,7 +74,6 @@ WidgetFactorySupplier::WidgetFactorySupplier()
|
||||
new PrefPageProducer<DlgSettingsPythonConsole> ( QT_TRANSLATE_NOOP("QObject","General") );
|
||||
new PrefPageProducer<DlgReportViewImp> ( QT_TRANSLATE_NOOP("QObject","General") );
|
||||
new PrefPageProducer<DlgSettingsMacroImp> ( QT_TRANSLATE_NOOP("QObject","General") );
|
||||
new PrefPageProducer<DlgSettingsUnitsImp> ( QT_TRANSLATE_NOOP("QObject","General") );
|
||||
new PrefPageProducer<DlgSettings3DViewImp> ( QT_TRANSLATE_NOOP("QObject","Display") );
|
||||
new PrefPageProducer<DlgSettingsNavigation> ( QT_TRANSLATE_NOOP("QObject","Display") );
|
||||
new PrefPageProducer<DlgSettingsViewColor> ( QT_TRANSLATE_NOOP("QObject","Display") );
|
||||
|
||||
Reference in New Issue
Block a user