All: Reformat according to new standard
This commit is contained in:
committed by
Kacper Donat
parent
eafd18dac0
commit
25c3ba7338
@@ -21,11 +21,11 @@
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
# include <QApplication>
|
||||
# include <QMessageBox>
|
||||
# include <QOffscreenSurface>
|
||||
# include <QOpenGLContext>
|
||||
# include <QSurfaceFormat>
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
#include <QOffscreenSurface>
|
||||
#include <QOpenGLContext>
|
||||
#include <QSurfaceFormat>
|
||||
|
||||
|
||||
#include <App/Application.h>
|
||||
@@ -44,7 +44,7 @@ using namespace Gui::Dialog;
|
||||
/* TRANSLATOR Gui::Dialog::DlgSettings3DViewImp */
|
||||
|
||||
DlgSettings3DViewImp::DlgSettings3DViewImp(QWidget* parent)
|
||||
: PreferencePage( parent )
|
||||
: PreferencePage(parent)
|
||||
, ui(new Ui_DlgSettings3DView)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@@ -134,14 +134,19 @@ void DlgSettings3DViewImp::loadAntiAliasing()
|
||||
}
|
||||
|
||||
// connect after setting current item of the combo box
|
||||
connect(ui->comboAliasing, qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
this, &DlgSettings3DViewImp::onAliasingChanged);
|
||||
connect(
|
||||
ui->comboAliasing,
|
||||
qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
this,
|
||||
&DlgSettings3DViewImp::onAliasingChanged
|
||||
);
|
||||
}
|
||||
|
||||
void DlgSettings3DViewImp::saveRenderCache()
|
||||
{
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/View");
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/View"
|
||||
);
|
||||
|
||||
int cache = ui->renderCache->currentIndex();
|
||||
hGrp->SetInt("RenderCache", cache);
|
||||
@@ -149,8 +154,9 @@ void DlgSettings3DViewImp::saveRenderCache()
|
||||
|
||||
void DlgSettings3DViewImp::loadRenderCache()
|
||||
{
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/View");
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/View"
|
||||
);
|
||||
|
||||
long cache = hGrp->GetInt("RenderCache", 0);
|
||||
ui->renderCache->setCurrentIndex(int(cache));
|
||||
@@ -158,17 +164,19 @@ void DlgSettings3DViewImp::loadRenderCache()
|
||||
|
||||
void DlgSettings3DViewImp::saveMarkerSize()
|
||||
{
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/View");
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/View"
|
||||
);
|
||||
|
||||
QVariant const &vBoxMarkerSize = ui->boxMarkerSize->itemData(ui->boxMarkerSize->currentIndex());
|
||||
QVariant const& vBoxMarkerSize = ui->boxMarkerSize->itemData(ui->boxMarkerSize->currentIndex());
|
||||
hGrp->SetInt("MarkerSize", vBoxMarkerSize.toInt());
|
||||
}
|
||||
|
||||
void DlgSettings3DViewImp::loadMarkerSize()
|
||||
{
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/View");
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/View"
|
||||
);
|
||||
|
||||
// NOLINTBEGIN
|
||||
int marker = hGrp->GetInt("MarkerSize", 9L);
|
||||
@@ -193,21 +201,21 @@ void DlgSettings3DViewImp::resetSettingsToDefaults()
|
||||
{
|
||||
ParameterGrp::handle hGrp;
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
|
||||
//reset "AntiAliasing" parameter
|
||||
// reset "AntiAliasing" parameter
|
||||
hGrp->RemoveInt("AntiAliasing");
|
||||
//reset "RenderCache" parameter
|
||||
// reset "RenderCache" parameter
|
||||
hGrp->RemoveInt("RenderCache");
|
||||
//reset "MarkerSize" parameter
|
||||
// reset "MarkerSize" parameter
|
||||
hGrp->RemoveInt("MarkerSize");
|
||||
|
||||
//finally reset all the parameters associated to Gui::Pref* widgets
|
||||
// finally reset all the parameters associated to Gui::Pref* widgets
|
||||
PreferencePage::resetSettingsToDefaults();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the strings of the subwidgets using the current language.
|
||||
*/
|
||||
void DlgSettings3DViewImp::changeEvent(QEvent *e)
|
||||
void DlgSettings3DViewImp::changeEvent(QEvent* e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->comboAliasing->blockSignals(true);
|
||||
@@ -233,12 +241,13 @@ void DlgSettings3DViewImp::onAliasingChanged(int index)
|
||||
static bool showMsg = true;
|
||||
if (showMsg) {
|
||||
showMsg = false;
|
||||
QMessageBox::information(this, tr("Anti-aliasing"),
|
||||
QMessageBox::information(
|
||||
this,
|
||||
tr("Anti-aliasing"),
|
||||
tr("Open a new viewer or restart %1 to apply anti-aliasing changes.")
|
||||
.arg(qApp->applicationName()));
|
||||
.arg(qApp->applicationName())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_DlgSettings3DViewImp.cpp"
|
||||
|
||||
|
||||
|
||||
@@ -29,8 +29,10 @@
|
||||
|
||||
class QDoubleSpinBox;
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
namespace Gui
|
||||
{
|
||||
namespace Dialog
|
||||
{
|
||||
class Ui_DlgSettings3DView;
|
||||
|
||||
/**
|
||||
@@ -38,7 +40,7 @@ class Ui_DlgSettings3DView;
|
||||
* for the Inventor viewer.
|
||||
* \author Jürgen Riegel
|
||||
*/
|
||||
class DlgSettings3DViewImp : public PreferencePage
|
||||
class DlgSettings3DViewImp: public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -54,7 +56,7 @@ private Q_SLOTS:
|
||||
void onAliasingChanged(int);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
void changeEvent(QEvent* e) override;
|
||||
|
||||
private:
|
||||
void addAntiAliasing();
|
||||
@@ -71,7 +73,7 @@ private:
|
||||
Q_DISABLE_COPY_MOVE(DlgSettings3DViewImp)
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGS3DVIEWIMP_H
|
||||
#endif // GUI_DIALOG_DLGSETTINGS3DVIEWIMP_H
|
||||
|
||||
@@ -30,12 +30,12 @@ DlgSettingsAdvanced.define()
|
||||
]]]*/
|
||||
|
||||
// Auto generated code (Tools/params_utils.py:567)
|
||||
# include <QApplication>
|
||||
# include <QLabel>
|
||||
# include <QGroupBox>
|
||||
# include <QGridLayout>
|
||||
# include <QVBoxLayout>
|
||||
# include <QHBoxLayout>
|
||||
#include <QApplication>
|
||||
#include <QLabel>
|
||||
#include <QGroupBox>
|
||||
#include <QGridLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include <Gui/TreeParams.h>
|
||||
#include <Gui/OverlayParams.h>
|
||||
@@ -46,7 +46,7 @@ using namespace Gui::Dialog;
|
||||
|
||||
// Auto generated code (Tools/params_utils.py:598)
|
||||
DlgSettingsAdvanced::DlgSettingsAdvanced(QWidget* parent)
|
||||
: PreferencePage( parent )
|
||||
: PreferencePage(parent)
|
||||
{
|
||||
|
||||
auto layout = new QVBoxLayout(this);
|
||||
@@ -267,7 +267,9 @@ DlgSettingsAdvanced::DlgSettingsAdvanced(QWidget* parent)
|
||||
layoutOverlay->addWidget(labelDockOverlaySplitterHandleTimeout, 14, 0);
|
||||
DockOverlaySplitterHandleTimeout = new Gui::PrefSpinBox(this);
|
||||
layoutOverlay->addWidget(DockOverlaySplitterHandleTimeout, 14, 1);
|
||||
DockOverlaySplitterHandleTimeout->setValue(Gui::OverlayParams::defaultDockOverlaySplitterHandleTimeout());
|
||||
DockOverlaySplitterHandleTimeout->setValue(
|
||||
Gui::OverlayParams::defaultDockOverlaySplitterHandleTimeout()
|
||||
);
|
||||
DockOverlaySplitterHandleTimeout->setEntryName("DockOverlaySplitterHandleTimeout");
|
||||
DockOverlaySplitterHandleTimeout->setParamGrpPath("View");
|
||||
// Auto generated code (Tools/params_utils.py:1135)
|
||||
@@ -322,8 +324,9 @@ DlgSettingsAdvanced::DlgSettingsAdvanced(QWidget* parent)
|
||||
DockOverlayAnimationCurve->setEntryName("DockOverlayAnimationCurve");
|
||||
DockOverlayAnimationCurve->setParamGrpPath("View");
|
||||
// Auto generated code (Gui/OverlayParams.py:94)
|
||||
for (const auto &item : OverlayParams::AnimationCurveTypes)
|
||||
for (const auto& item : OverlayParams::AnimationCurveTypes) {
|
||||
DockOverlayAnimationCurve->addItem(item);
|
||||
}
|
||||
DockOverlayAnimationCurve->setCurrentIndex(Gui::OverlayParams::defaultDockOverlayAnimationCurve());
|
||||
layout->addItem(new QSpacerItem(40, 20, QSizePolicy::Fixed, QSizePolicy::Expanding));
|
||||
retranslateUi();
|
||||
@@ -333,8 +336,7 @@ DlgSettingsAdvanced::DlgSettingsAdvanced(QWidget* parent)
|
||||
|
||||
// Auto generated code (Tools/params_utils.py:614)
|
||||
DlgSettingsAdvanced::~DlgSettingsAdvanced()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
// Auto generated code (Tools/params_utils.py:622)
|
||||
void DlgSettingsAdvanced::saveSettings()
|
||||
@@ -391,65 +393,106 @@ void DlgSettingsAdvanced::retranslateUi()
|
||||
{
|
||||
setWindowTitle(QObject::tr("Advanced"));
|
||||
groupOverlay->setTitle(QObject::tr("Overlay"));
|
||||
DockOverlayWheelDelay->setToolTip(QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayWheelDelay()));
|
||||
DockOverlayWheelDelay->setToolTip(
|
||||
QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayWheelDelay())
|
||||
);
|
||||
labelDockOverlayWheelDelay->setText(QObject::tr("Delay mouse wheel pass through"));
|
||||
labelDockOverlayWheelDelay->setToolTip(DockOverlayWheelDelay->toolTip());
|
||||
DockOverlayAlphaRadius->setToolTip(QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayAlphaRadius()));
|
||||
DockOverlayAlphaRadius->setToolTip(
|
||||
QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayAlphaRadius())
|
||||
);
|
||||
labelDockOverlayAlphaRadius->setText(QObject::tr("Alpha test radius"));
|
||||
labelDockOverlayAlphaRadius->setToolTip(DockOverlayAlphaRadius->toolTip());
|
||||
DockOverlayCheckNaviCube->setToolTip(QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayCheckNaviCube()));
|
||||
DockOverlayCheckNaviCube->setToolTip(
|
||||
QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayCheckNaviCube())
|
||||
);
|
||||
DockOverlayCheckNaviCube->setText(QObject::tr("Check navigation cube"));
|
||||
DockOverlayHintTriggerSize->setToolTip(QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayHintTriggerSize()));
|
||||
DockOverlayHintTriggerSize->setToolTip(
|
||||
QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayHintTriggerSize())
|
||||
);
|
||||
labelDockOverlayHintTriggerSize->setText(QObject::tr("Hint trigger size"));
|
||||
labelDockOverlayHintTriggerSize->setToolTip(DockOverlayHintTriggerSize->toolTip());
|
||||
DockOverlayHintSize->setToolTip(QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayHintSize()));
|
||||
DockOverlayHintSize->setToolTip(
|
||||
QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayHintSize())
|
||||
);
|
||||
labelDockOverlayHintSize->setText(QObject::tr("Hint width"));
|
||||
labelDockOverlayHintSize->setToolTip(DockOverlayHintSize->toolTip());
|
||||
DockOverlayHintLeftOffset->setToolTip(QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayHintLeftOffset()));
|
||||
DockOverlayHintLeftOffset->setToolTip(
|
||||
QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayHintLeftOffset())
|
||||
);
|
||||
labelDockOverlayHintLeftOffset->setText(QObject::tr("Left panel hint offset"));
|
||||
labelDockOverlayHintLeftOffset->setToolTip(DockOverlayHintLeftOffset->toolTip());
|
||||
DockOverlayHintLeftLength->setToolTip(QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayHintLeftLength()));
|
||||
DockOverlayHintLeftLength->setToolTip(
|
||||
QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayHintLeftLength())
|
||||
);
|
||||
labelDockOverlayHintLeftLength->setText(QObject::tr("Left panel hint length"));
|
||||
labelDockOverlayHintLeftLength->setToolTip(DockOverlayHintLeftLength->toolTip());
|
||||
DockOverlayHintRightOffset->setToolTip(QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayHintRightOffset()));
|
||||
DockOverlayHintRightOffset->setToolTip(
|
||||
QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayHintRightOffset())
|
||||
);
|
||||
labelDockOverlayHintRightOffset->setText(QObject::tr("Right panel hint offset"));
|
||||
labelDockOverlayHintRightOffset->setToolTip(DockOverlayHintRightOffset->toolTip());
|
||||
DockOverlayHintRightLength->setToolTip(QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayHintRightLength()));
|
||||
DockOverlayHintRightLength->setToolTip(
|
||||
QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayHintRightLength())
|
||||
);
|
||||
labelDockOverlayHintRightLength->setText(QObject::tr("Right panel hint length"));
|
||||
labelDockOverlayHintRightLength->setToolTip(DockOverlayHintRightLength->toolTip());
|
||||
DockOverlayHintTopOffset->setToolTip(QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayHintTopOffset()));
|
||||
DockOverlayHintTopOffset->setToolTip(
|
||||
QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayHintTopOffset())
|
||||
);
|
||||
labelDockOverlayHintTopOffset->setText(QObject::tr("Top panel hint offset"));
|
||||
labelDockOverlayHintTopOffset->setToolTip(DockOverlayHintTopOffset->toolTip());
|
||||
DockOverlayHintTopLength->setToolTip(QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayHintTopLength()));
|
||||
DockOverlayHintTopLength->setToolTip(
|
||||
QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayHintTopLength())
|
||||
);
|
||||
labelDockOverlayHintTopLength->setText(QObject::tr("Top panel hint length"));
|
||||
labelDockOverlayHintTopLength->setToolTip(DockOverlayHintTopLength->toolTip());
|
||||
DockOverlayHintBottomOffset->setToolTip(QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayHintBottomOffset()));
|
||||
DockOverlayHintBottomOffset->setToolTip(
|
||||
QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayHintBottomOffset())
|
||||
);
|
||||
labelDockOverlayHintBottomOffset->setText(QObject::tr("Bottom panel hint offset"));
|
||||
labelDockOverlayHintBottomOffset->setToolTip(DockOverlayHintBottomOffset->toolTip());
|
||||
DockOverlayHintBottomLength->setToolTip(QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayHintBottomLength()));
|
||||
DockOverlayHintBottomLength->setToolTip(
|
||||
QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayHintBottomLength())
|
||||
);
|
||||
labelDockOverlayHintBottomLength->setText(QObject::tr("Bottom panel hint length"));
|
||||
labelDockOverlayHintBottomLength->setToolTip(DockOverlayHintBottomLength->toolTip());
|
||||
DockOverlayHintDelay->setToolTip(QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayHintDelay()));
|
||||
DockOverlayHintDelay->setToolTip(
|
||||
QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayHintDelay())
|
||||
);
|
||||
labelDockOverlayHintDelay->setText(QObject::tr("Hint delay"));
|
||||
labelDockOverlayHintDelay->setToolTip(DockOverlayHintDelay->toolTip());
|
||||
DockOverlaySplitterHandleTimeout->setToolTip(QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlaySplitterHandleTimeout()));
|
||||
DockOverlaySplitterHandleTimeout->setToolTip(
|
||||
QApplication::translate(
|
||||
"OverlayParams",
|
||||
Gui::OverlayParams::docDockOverlaySplitterHandleTimeout()
|
||||
)
|
||||
);
|
||||
labelDockOverlaySplitterHandleTimeout->setText(QObject::tr("Splitter auto hide delay"));
|
||||
labelDockOverlaySplitterHandleTimeout->setToolTip(DockOverlaySplitterHandleTimeout->toolTip());
|
||||
DockOverlayActivateOnHover->setToolTip(QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayActivateOnHover()));
|
||||
DockOverlayActivateOnHover->setToolTip(
|
||||
QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayActivateOnHover())
|
||||
);
|
||||
DockOverlayActivateOnHover->setText(QObject::tr("Activate on hover"));
|
||||
DockOverlayDelay->setToolTip(QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayDelay()));
|
||||
DockOverlayDelay->setToolTip(
|
||||
QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayDelay())
|
||||
);
|
||||
labelDockOverlayDelay->setText(QObject::tr("Layout delay"));
|
||||
labelDockOverlayDelay->setToolTip(DockOverlayDelay->toolTip());
|
||||
DockOverlayAnimationDuration->setToolTip(QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayAnimationDuration()));
|
||||
DockOverlayAnimationDuration->setToolTip(
|
||||
QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayAnimationDuration())
|
||||
);
|
||||
labelDockOverlayAnimationDuration->setText(QObject::tr("Animation duration"));
|
||||
labelDockOverlayAnimationDuration->setToolTip(DockOverlayAnimationDuration->toolTip());
|
||||
DockOverlayAnimationCurve->setToolTip(QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayAnimationCurve()));
|
||||
DockOverlayAnimationCurve->setToolTip(
|
||||
QApplication::translate("OverlayParams", Gui::OverlayParams::docDockOverlayAnimationCurve())
|
||||
);
|
||||
labelDockOverlayAnimationCurve->setText(QObject::tr("Animation curve type"));
|
||||
labelDockOverlayAnimationCurve->setToolTip(DockOverlayAnimationCurve->toolTip());
|
||||
}
|
||||
|
||||
// Auto generated code (Tools/params_utils.py:657)
|
||||
void DlgSettingsAdvanced::changeEvent(QEvent *e)
|
||||
void DlgSettingsAdvanced::changeEvent(QEvent* e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
retranslateUi();
|
||||
@@ -471,12 +514,17 @@ void DlgSettingsAdvanced::init()
|
||||
|
||||
animator1 = new QPropertyAnimation(this, "offset1", this);
|
||||
QObject::connect(animator1, &QPropertyAnimation::stateChanged, [this]() {
|
||||
if (animator1->state() != QAbstractAnimation::Running)
|
||||
if (animator1->state() != QAbstractAnimation::Running) {
|
||||
timer->start(1000);
|
||||
}
|
||||
});
|
||||
|
||||
QObject::connect(DockOverlayAnimationCurve, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this, &DlgSettingsAdvanced::onCurveChange);
|
||||
QObject::connect(
|
||||
DockOverlayAnimationCurve,
|
||||
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this,
|
||||
&DlgSettingsAdvanced::onCurveChange
|
||||
);
|
||||
|
||||
QObject::connect(timer, &QTimer::timeout, [this]() {
|
||||
if (animator1->state() != QAbstractAnimation::Running) {
|
||||
@@ -493,10 +541,11 @@ qreal DlgSettingsAdvanced::offset1() const
|
||||
|
||||
void DlgSettingsAdvanced::setOffset1(qreal t)
|
||||
{
|
||||
if (t == this->t1)
|
||||
if (t == this->t1) {
|
||||
return;
|
||||
}
|
||||
this->t1 = t;
|
||||
QLabel *label = this->labelDockOverlayAnimationCurve;
|
||||
QLabel* label = this->labelDockOverlayAnimationCurve;
|
||||
if (this->a1 == this->b1) {
|
||||
this->a1 = label->x();
|
||||
QPoint pos(width(), 0);
|
||||
@@ -506,9 +555,10 @@ void DlgSettingsAdvanced::setOffset1(qreal t)
|
||||
|
||||
void DlgSettingsAdvanced::onCurveChange(int index)
|
||||
{
|
||||
if (sender() != DockOverlayAnimationCurve)
|
||||
if (sender() != DockOverlayAnimationCurve) {
|
||||
return;
|
||||
double value = DockOverlayAnimationDuration->value()*2;
|
||||
}
|
||||
double value = DockOverlayAnimationDuration->value() * 2;
|
||||
auto animator = animator1;
|
||||
animator->setStartValue(0.0);
|
||||
animator->setEndValue(1.0);
|
||||
|
||||
@@ -38,8 +38,10 @@ DlgSettingsAdvanced.declare_begin()
|
||||
class QLabel;
|
||||
class QGroupBox;
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
namespace Gui
|
||||
{
|
||||
namespace Dialog
|
||||
{
|
||||
/** Preference dialog for various advanced UI settings
|
||||
|
||||
* This class is auto generated by Gui/PreferencePages/DlgSettingsAdvanced.py. Modify that file
|
||||
@@ -51,15 +53,16 @@ namespace Dialog {
|
||||
*
|
||||
* Once modified, you can regenerate the header and the source file,
|
||||
* @code
|
||||
* python3 -m cogapp -r Gui/PreferencePages/DlgSettingsAdvanced.h Gui/PreferencePages/DlgSettingsAdvanced.cpp
|
||||
* python3 -m cogapp -r Gui/PreferencePages/DlgSettingsAdvanced.h
|
||||
Gui/PreferencePages/DlgSettingsAdvanced.cpp
|
||||
* @endcode
|
||||
*/
|
||||
class DlgSettingsAdvanced : public Gui::Dialog::PreferencePage
|
||||
class DlgSettingsAdvanced: public Gui::Dialog::PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DlgSettingsAdvanced( QWidget* parent = 0 );
|
||||
DlgSettingsAdvanced(QWidget* parent = 0);
|
||||
~DlgSettingsAdvanced();
|
||||
|
||||
void saveSettings();
|
||||
@@ -67,49 +70,48 @@ public:
|
||||
void retranslateUi();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
void changeEvent(QEvent* e);
|
||||
|
||||
private:
|
||||
|
||||
// Auto generated code (Tools/params_utils.py:400)
|
||||
QGroupBox * groupOverlay = nullptr;
|
||||
QLabel *labelDockOverlayWheelDelay = nullptr;
|
||||
Gui::PrefSpinBox *DockOverlayWheelDelay = nullptr;
|
||||
QLabel *labelDockOverlayAlphaRadius = nullptr;
|
||||
Gui::PrefSpinBox *DockOverlayAlphaRadius = nullptr;
|
||||
Gui::PrefCheckBox *DockOverlayCheckNaviCube = nullptr;
|
||||
QLabel *labelDockOverlayHintTriggerSize = nullptr;
|
||||
Gui::PrefSpinBox *DockOverlayHintTriggerSize = nullptr;
|
||||
QLabel *labelDockOverlayHintSize = nullptr;
|
||||
Gui::PrefSpinBox *DockOverlayHintSize = nullptr;
|
||||
QLabel *labelDockOverlayHintLeftOffset = nullptr;
|
||||
Gui::PrefSpinBox *DockOverlayHintLeftOffset = nullptr;
|
||||
QLabel *labelDockOverlayHintLeftLength = nullptr;
|
||||
Gui::PrefSpinBox *DockOverlayHintLeftLength = nullptr;
|
||||
QLabel *labelDockOverlayHintRightOffset = nullptr;
|
||||
Gui::PrefSpinBox *DockOverlayHintRightOffset = nullptr;
|
||||
QLabel *labelDockOverlayHintRightLength = nullptr;
|
||||
Gui::PrefSpinBox *DockOverlayHintRightLength = nullptr;
|
||||
QLabel *labelDockOverlayHintTopOffset = nullptr;
|
||||
Gui::PrefSpinBox *DockOverlayHintTopOffset = nullptr;
|
||||
QLabel *labelDockOverlayHintTopLength = nullptr;
|
||||
Gui::PrefSpinBox *DockOverlayHintTopLength = nullptr;
|
||||
QLabel *labelDockOverlayHintBottomOffset = nullptr;
|
||||
Gui::PrefSpinBox *DockOverlayHintBottomOffset = nullptr;
|
||||
QLabel *labelDockOverlayHintBottomLength = nullptr;
|
||||
Gui::PrefSpinBox *DockOverlayHintBottomLength = nullptr;
|
||||
QLabel *labelDockOverlayHintDelay = nullptr;
|
||||
Gui::PrefSpinBox *DockOverlayHintDelay = nullptr;
|
||||
QLabel *labelDockOverlaySplitterHandleTimeout = nullptr;
|
||||
Gui::PrefSpinBox *DockOverlaySplitterHandleTimeout = nullptr;
|
||||
Gui::PrefCheckBox *DockOverlayActivateOnHover = nullptr;
|
||||
QLabel *labelDockOverlayDelay = nullptr;
|
||||
Gui::PrefSpinBox *DockOverlayDelay = nullptr;
|
||||
QLabel *labelDockOverlayAnimationDuration = nullptr;
|
||||
Gui::PrefSpinBox *DockOverlayAnimationDuration = nullptr;
|
||||
QLabel *labelDockOverlayAnimationCurve = nullptr;
|
||||
Gui::PrefComboBox *DockOverlayAnimationCurve = nullptr;
|
||||
//[[[end]]]
|
||||
QGroupBox* groupOverlay = nullptr;
|
||||
QLabel* labelDockOverlayWheelDelay = nullptr;
|
||||
Gui::PrefSpinBox* DockOverlayWheelDelay = nullptr;
|
||||
QLabel* labelDockOverlayAlphaRadius = nullptr;
|
||||
Gui::PrefSpinBox* DockOverlayAlphaRadius = nullptr;
|
||||
Gui::PrefCheckBox* DockOverlayCheckNaviCube = nullptr;
|
||||
QLabel* labelDockOverlayHintTriggerSize = nullptr;
|
||||
Gui::PrefSpinBox* DockOverlayHintTriggerSize = nullptr;
|
||||
QLabel* labelDockOverlayHintSize = nullptr;
|
||||
Gui::PrefSpinBox* DockOverlayHintSize = nullptr;
|
||||
QLabel* labelDockOverlayHintLeftOffset = nullptr;
|
||||
Gui::PrefSpinBox* DockOverlayHintLeftOffset = nullptr;
|
||||
QLabel* labelDockOverlayHintLeftLength = nullptr;
|
||||
Gui::PrefSpinBox* DockOverlayHintLeftLength = nullptr;
|
||||
QLabel* labelDockOverlayHintRightOffset = nullptr;
|
||||
Gui::PrefSpinBox* DockOverlayHintRightOffset = nullptr;
|
||||
QLabel* labelDockOverlayHintRightLength = nullptr;
|
||||
Gui::PrefSpinBox* DockOverlayHintRightLength = nullptr;
|
||||
QLabel* labelDockOverlayHintTopOffset = nullptr;
|
||||
Gui::PrefSpinBox* DockOverlayHintTopOffset = nullptr;
|
||||
QLabel* labelDockOverlayHintTopLength = nullptr;
|
||||
Gui::PrefSpinBox* DockOverlayHintTopLength = nullptr;
|
||||
QLabel* labelDockOverlayHintBottomOffset = nullptr;
|
||||
Gui::PrefSpinBox* DockOverlayHintBottomOffset = nullptr;
|
||||
QLabel* labelDockOverlayHintBottomLength = nullptr;
|
||||
Gui::PrefSpinBox* DockOverlayHintBottomLength = nullptr;
|
||||
QLabel* labelDockOverlayHintDelay = nullptr;
|
||||
Gui::PrefSpinBox* DockOverlayHintDelay = nullptr;
|
||||
QLabel* labelDockOverlaySplitterHandleTimeout = nullptr;
|
||||
Gui::PrefSpinBox* DockOverlaySplitterHandleTimeout = nullptr;
|
||||
Gui::PrefCheckBox* DockOverlayActivateOnHover = nullptr;
|
||||
QLabel* labelDockOverlayDelay = nullptr;
|
||||
Gui::PrefSpinBox* DockOverlayDelay = nullptr;
|
||||
QLabel* labelDockOverlayAnimationDuration = nullptr;
|
||||
Gui::PrefSpinBox* DockOverlayAnimationDuration = nullptr;
|
||||
QLabel* labelDockOverlayAnimationCurve = nullptr;
|
||||
Gui::PrefComboBox* DockOverlayAnimationCurve = nullptr;
|
||||
//[[[end]]]
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// user code start
|
||||
@@ -123,22 +125,22 @@ private:
|
||||
void onCurveChange(int index);
|
||||
|
||||
private:
|
||||
QTimer *timer;
|
||||
QPropertyAnimation *animator1;
|
||||
QTimer* timer;
|
||||
QPropertyAnimation* animator1;
|
||||
qreal t1 = 0;
|
||||
qreal a1 = 0, b1 = 0;
|
||||
|
||||
// user code end
|
||||
// -----------------------------------------------------------------------------------
|
||||
|
||||
/*[[[cog
|
||||
import DlgSettingsAdvanced
|
||||
DlgSettingsAdvanced.declare_end()
|
||||
]]]*/
|
||||
/*[[[cog
|
||||
import DlgSettingsAdvanced
|
||||
DlgSettingsAdvanced.declare_end()
|
||||
]]]*/
|
||||
|
||||
// Auto generated code (Tools/params_utils.py:536)
|
||||
// Auto generated code (Tools/params_utils.py:536)
|
||||
};
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
//[[[end]]]
|
||||
#endif // GUI_DIALOG_DLGSETTINGSADVANCED_H
|
||||
#endif // GUI_DIALOG_DLGSETTINGSADVANCED_H
|
||||
|
||||
@@ -18,60 +18,66 @@
|
||||
# * USA *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
'''Auto code generator for preference page of Display/UI
|
||||
'''
|
||||
"""Auto code generator for preference page of Display/UI"""
|
||||
import cog, sys
|
||||
from os import sys, path
|
||||
|
||||
# import Tools/params_utils.py
|
||||
sys.path.append(path.join(path.dirname(
|
||||
path.dirname(path.dirname(path.abspath(__file__)))), 'Tools'))
|
||||
sys.path.append(
|
||||
path.join(path.dirname(path.dirname(path.dirname(path.abspath(__file__)))), "Tools")
|
||||
)
|
||||
import params_utils
|
||||
from params_utils import auto_comment
|
||||
|
||||
sys.path.append(path.join(path.dirname(
|
||||
path.dirname(path.dirname(path.abspath(__file__)))), 'Gui'))
|
||||
sys.path.append(path.join(path.dirname(path.dirname(path.dirname(path.abspath(__file__)))), "Gui"))
|
||||
import OverlayParams
|
||||
|
||||
Title = 'Advanced'
|
||||
NameSpace = 'Gui'
|
||||
ClassName = 'DlgSettingsAdvanced'
|
||||
ClassDoc = 'Preference dialog for various advanced UI settings'
|
||||
UserInit = 'init();'
|
||||
Title = "Advanced"
|
||||
NameSpace = "Gui"
|
||||
ClassName = "DlgSettingsAdvanced"
|
||||
ClassDoc = "Preference dialog for various advanced UI settings"
|
||||
UserInit = "init();"
|
||||
|
||||
_OverlayParams = { param.name : param for param in OverlayParams.Params }
|
||||
_OverlayParams = {param.name: param for param in OverlayParams.Params}
|
||||
|
||||
ParamGroup = (
|
||||
|
||||
('Overlay', [_OverlayParams[name] for name in (
|
||||
'DockOverlayWheelDelay',
|
||||
'DockOverlayAlphaRadius',
|
||||
'DockOverlayCheckNaviCube',
|
||||
'DockOverlayHintTriggerSize',
|
||||
'DockOverlayHintSize',
|
||||
'DockOverlayHintLeftOffset',
|
||||
'DockOverlayHintLeftLength',
|
||||
'DockOverlayHintRightOffset',
|
||||
'DockOverlayHintRightLength',
|
||||
'DockOverlayHintTopOffset',
|
||||
'DockOverlayHintTopLength',
|
||||
'DockOverlayHintBottomOffset',
|
||||
'DockOverlayHintBottomLength',
|
||||
'DockOverlayHintDelay',
|
||||
'DockOverlaySplitterHandleTimeout',
|
||||
'DockOverlayActivateOnHover',
|
||||
'DockOverlayDelay',
|
||||
'DockOverlayAnimationDuration',
|
||||
'DockOverlayAnimationCurve',
|
||||
)]),
|
||||
(
|
||||
"Overlay",
|
||||
[
|
||||
_OverlayParams[name]
|
||||
for name in (
|
||||
"DockOverlayWheelDelay",
|
||||
"DockOverlayAlphaRadius",
|
||||
"DockOverlayCheckNaviCube",
|
||||
"DockOverlayHintTriggerSize",
|
||||
"DockOverlayHintSize",
|
||||
"DockOverlayHintLeftOffset",
|
||||
"DockOverlayHintLeftLength",
|
||||
"DockOverlayHintRightOffset",
|
||||
"DockOverlayHintRightLength",
|
||||
"DockOverlayHintTopOffset",
|
||||
"DockOverlayHintTopLength",
|
||||
"DockOverlayHintBottomOffset",
|
||||
"DockOverlayHintBottomLength",
|
||||
"DockOverlayHintDelay",
|
||||
"DockOverlaySplitterHandleTimeout",
|
||||
"DockOverlayActivateOnHover",
|
||||
"DockOverlayDelay",
|
||||
"DockOverlayAnimationDuration",
|
||||
"DockOverlayAnimationCurve",
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def declare_begin():
|
||||
params_utils.preference_dialog_declare_begin(sys.modules[__name__])
|
||||
|
||||
|
||||
def declare_end():
|
||||
params_utils.preference_dialog_declare_end(sys.modules[__name__])
|
||||
|
||||
|
||||
def define():
|
||||
params_utils.preference_dialog_define(sys.modules[__name__])
|
||||
|
||||
@@ -20,17 +20,17 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
# include <cmath>
|
||||
# include <limits>
|
||||
# include <vector>
|
||||
# include <QCoreApplication>
|
||||
# include <QDate>
|
||||
# include <QDesktopServices>
|
||||
# include <QDir>
|
||||
# include <QLocale>
|
||||
# include <QMessageBox>
|
||||
# include <QSettings>
|
||||
# include <QUrl>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
#include <QCoreApplication>
|
||||
#include <QDate>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QLocale>
|
||||
#include <QMessageBox>
|
||||
#include <QSettings>
|
||||
#include <QUrl>
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
@@ -48,13 +48,14 @@ using namespace Gui::Dialog;
|
||||
QString DlgSettingsCacheDirectory::currentSize;
|
||||
|
||||
DlgSettingsCacheDirectory::DlgSettingsCacheDirectory(QWidget* parent)
|
||||
: PreferencePage(parent)
|
||||
, ui(new Ui_DlgSettingsCacheDirectory)
|
||||
: PreferencePage(parent)
|
||||
, ui(new Ui_DlgSettingsCacheDirectory)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->labelCache->setToolTip(tr("Notify the user if the cache size exceeds the specified limit"));
|
||||
if (currentSize.isEmpty())
|
||||
if (currentSize.isEmpty()) {
|
||||
currentSize = tr("Unknown");
|
||||
}
|
||||
setCurrentCacheSize(currentSize);
|
||||
|
||||
QString path = QString::fromStdString(App::Application::getUserCachePath());
|
||||
@@ -82,8 +83,9 @@ void DlgSettingsCacheDirectory::saveSettings()
|
||||
void DlgSettingsCacheDirectory::loadSettings()
|
||||
{
|
||||
int period = ApplicationCacheSettings::getCheckPeriod();
|
||||
if (period >= 0 && period < ui->comboBoxPeriod->count())
|
||||
if (period >= 0 && period < ui->comboBoxPeriod->count()) {
|
||||
ui->comboBoxPeriod->setCurrentIndex(period);
|
||||
}
|
||||
unsigned int limit = ApplicationCacheSettings::getCacheSizeLimit();
|
||||
int index = ui->comboBoxLimit->findData(limit);
|
||||
|
||||
@@ -99,16 +101,16 @@ void DlgSettingsCacheDirectory::resetSettingsToDefaults()
|
||||
{
|
||||
ParameterGrp::handle hGrp;
|
||||
hGrp = WindowParameter::getDefaultParameter()->GetGroup("CacheDirectory");
|
||||
//reset "Limit" parameter
|
||||
// reset "Limit" parameter
|
||||
hGrp->RemoveUnsigned("Limit");
|
||||
//reset "Period" parameter
|
||||
// reset "Period" parameter
|
||||
hGrp->RemoveInt("Period");
|
||||
|
||||
//finally reset all the parameters associated to Gui::Pref* widgets
|
||||
// finally reset all the parameters associated to Gui::Pref* widgets
|
||||
PreferencePage::resetSettingsToDefaults();
|
||||
}
|
||||
|
||||
void DlgSettingsCacheDirectory::changeEvent(QEvent *e)
|
||||
void DlgSettingsCacheDirectory::changeEvent(QEvent* e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
int period = ui->comboBoxPeriod->currentIndex();
|
||||
@@ -163,24 +165,24 @@ ApplicationCache::ApplicationCache()
|
||||
void ApplicationCache::setPeriod(ApplicationCache::Period period)
|
||||
{
|
||||
switch (period) {
|
||||
case Period::Always:
|
||||
numDays = -1;
|
||||
break;
|
||||
case Period::Daily:
|
||||
numDays = 1;
|
||||
break;
|
||||
case Period::Weekly:
|
||||
numDays = 7;
|
||||
break;
|
||||
case Period::Monthly:
|
||||
numDays = 31;
|
||||
break;
|
||||
case Period::Yearly:
|
||||
numDays = 365;
|
||||
break;
|
||||
case Period::Never:
|
||||
numDays = std::numeric_limits<int>::max();
|
||||
break;
|
||||
case Period::Always:
|
||||
numDays = -1;
|
||||
break;
|
||||
case Period::Daily:
|
||||
numDays = 1;
|
||||
break;
|
||||
case Period::Weekly:
|
||||
numDays = 7;
|
||||
break;
|
||||
case Period::Monthly:
|
||||
numDays = 31;
|
||||
break;
|
||||
case Period::Yearly:
|
||||
numDays = 365;
|
||||
break;
|
||||
case Period::Never:
|
||||
numDays = std::numeric_limits<int>::max();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,10 +239,12 @@ bool ApplicationCache::performAction(qint64 total)
|
||||
msgBox.setIcon(QMessageBox::Warning);
|
||||
msgBox.setWindowTitle(tr("Cache Directory"));
|
||||
|
||||
QString hint = tr("The cache directory %1 exceeds the size of %2.").arg(path, ApplicationCache::toString(limit));
|
||||
QString hint = tr("The cache directory %1 exceeds the size of %2.")
|
||||
.arg(path, ApplicationCache::toString(limit));
|
||||
QString ask = tr("Clear it now?");
|
||||
QString warn = tr("Warning: Make sure that this is the only running %1 instance "
|
||||
"and that no documents are opened as this may result into data loss!").arg(QCoreApplication::applicationName());
|
||||
"and that no documents are opened as this may result into data loss!")
|
||||
.arg(QCoreApplication::applicationName());
|
||||
|
||||
msgBox.setText(QStringLiteral("%1 %2\n\n\n%3").arg(hint, ask, warn));
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Open);
|
||||
@@ -318,8 +322,9 @@ qint64 ApplicationCache::dirSize(QString dirPath) const
|
||||
// traverse sub-directories recursively
|
||||
QDir::Filters dirFilters = QDir::Dirs | QDir::NoDotAndDotDot;
|
||||
const auto& dirs = dir.entryList(dirFilters);
|
||||
for (const QString& subDirPath : dirs)
|
||||
for (const QString& subDirPath : dirs) {
|
||||
total += dirSize(dirPath + QDir::separator() + subDirPath);
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
@@ -344,15 +349,14 @@ qint64 ApplicationCache::toBytes(unsigned int sizeInMB)
|
||||
|
||||
QString ApplicationCache::toString(qint64 size)
|
||||
{
|
||||
QStringList units = {QStringLiteral("Bytes"),
|
||||
QStringLiteral("KB"),
|
||||
QStringLiteral("MB"),
|
||||
QStringLiteral("GB")};
|
||||
QStringList units
|
||||
= {QStringLiteral("Bytes"), QStringLiteral("KB"), QStringLiteral("MB"), QStringLiteral("GB")};
|
||||
int i;
|
||||
double outputSize = size;
|
||||
for (i=0; i<units.size()-1; i++) {
|
||||
if (outputSize < 1024)
|
||||
for (i = 0; i < units.size() - 1; i++) {
|
||||
if (outputSize < 1024) {
|
||||
break;
|
||||
}
|
||||
outputSize /= 1024;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,10 @@
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
namespace Gui
|
||||
{
|
||||
namespace Dialog
|
||||
{
|
||||
class Ui_DlgSettingsCacheDirectory;
|
||||
|
||||
/**
|
||||
@@ -36,7 +38,7 @@ class Ui_DlgSettingsCacheDirectory;
|
||||
* for the cache directory handling.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class DlgSettingsCacheDirectory : public PreferencePage
|
||||
class DlgSettingsCacheDirectory: public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -49,7 +51,7 @@ public:
|
||||
void resetSettingsToDefaults() override;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
void changeEvent(QEvent* e) override;
|
||||
|
||||
private:
|
||||
void runCheck();
|
||||
@@ -61,12 +63,13 @@ private:
|
||||
std::unique_ptr<Ui_DlgSettingsCacheDirectory> ui;
|
||||
};
|
||||
|
||||
class ApplicationCache : public QObject
|
||||
class ApplicationCache: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum class Period {
|
||||
enum class Period
|
||||
{
|
||||
Always,
|
||||
Daily,
|
||||
Weekly,
|
||||
@@ -104,7 +107,7 @@ public:
|
||||
static void setCheckPeriod(int);
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSCACHEDIRECTORY_H
|
||||
#endif // GUI_DIALOG_DLGSETTINGSCACHEDIRECTORY_H
|
||||
|
||||
@@ -48,23 +48,30 @@ DlgSettingsDocumentImp::DlgSettingsDocumentImp(QWidget* parent)
|
||||
ui->prefSaveTransaction->hide();
|
||||
ui->prefDiscardTransaction->hide();
|
||||
|
||||
QString tip = QStringLiteral("<html><head/><body><p>%1</p>"
|
||||
"<p>%2: %Y%m%d-%H%M%S</p>"
|
||||
"</p></body></html>")
|
||||
QString tip = QStringLiteral(
|
||||
"<html><head/><body><p>%1</p>"
|
||||
"<p>%2: %Y%m%d-%H%M%S</p>"
|
||||
"</p></body></html>"
|
||||
)
|
||||
.arg(tr("The format of the date to use."), tr("Default"));
|
||||
QString link =
|
||||
QString::fromLatin1("<html><head/><body>"
|
||||
"<a href=\"http://www.cplusplus.com/reference/ctime/strftime/\">%1</a>"
|
||||
"</body></html>")
|
||||
.arg(tr("Show format documentation"));
|
||||
QString link = QString::fromLatin1(
|
||||
"<html><head/><body>"
|
||||
"<a href=\"http://www.cplusplus.com/reference/ctime/strftime/\">%1</a>"
|
||||
"</body></html>"
|
||||
)
|
||||
.arg(tr("Show format documentation"));
|
||||
ui->prefSaveBackupDateFormat->setToolTip(tip);
|
||||
ui->FormatTimeDocsLabel->setText(link);
|
||||
|
||||
ui->prefCountBackupFiles->setMaximum(std::numeric_limits<int>::max());
|
||||
ui->prefCompression->setMinimum(Z_NO_COMPRESSION);
|
||||
ui->prefCompression->setMaximum(Z_BEST_COMPRESSION);
|
||||
connect(ui->prefLicenseType, qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
this, &DlgSettingsDocumentImp::onLicenseTypeChanged);
|
||||
connect(
|
||||
ui->prefLicenseType,
|
||||
qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
this,
|
||||
&DlgSettingsDocumentImp::onLicenseTypeChanged
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,8 +108,9 @@ void DlgSettingsDocumentImp::saveSettings()
|
||||
ui->prefCanAbortRecompute->onSave();
|
||||
|
||||
int timeout = ui->prefAutoSaveTimeout->value();
|
||||
if (!ui->prefAutoSaveEnabled->isChecked())
|
||||
if (!ui->prefAutoSaveEnabled->isChecked()) {
|
||||
timeout = 0;
|
||||
}
|
||||
AutoSaver::instance()->setTimeout(timeout * 60000);
|
||||
}
|
||||
|
||||
@@ -138,7 +146,7 @@ void DlgSettingsDocumentImp::loadSettings()
|
||||
/**
|
||||
* Sets the strings of the subwidgets using the current language.
|
||||
*/
|
||||
void DlgSettingsDocumentImp::changeEvent(QEvent *e)
|
||||
void DlgSettingsDocumentImp::changeEvent(QEvent* e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
@@ -154,8 +162,7 @@ void DlgSettingsDocumentImp::changeEvent(QEvent *e)
|
||||
void DlgSettingsDocumentImp::addLicenseTypes()
|
||||
{
|
||||
auto add = [&](const char* what) {
|
||||
ui->prefLicenseType->addItem(
|
||||
QApplication::translate("Gui::Dialog::DlgSettingsDocument", what));
|
||||
ui->prefLicenseType->addItem(QApplication::translate("Gui::Dialog::DlgSettingsDocument", what));
|
||||
};
|
||||
|
||||
ui->prefLicenseType->clear();
|
||||
|
||||
@@ -27,8 +27,10 @@
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
namespace Gui
|
||||
{
|
||||
namespace Dialog
|
||||
{
|
||||
class Ui_DlgSettingsDocument;
|
||||
|
||||
/**
|
||||
@@ -36,12 +38,12 @@ class Ui_DlgSettingsDocument;
|
||||
* for the document.
|
||||
* \author Jürgen Riegel
|
||||
*/
|
||||
class DlgSettingsDocumentImp : public PreferencePage
|
||||
class DlgSettingsDocumentImp: public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgSettingsDocumentImp( QWidget* parent = nullptr );
|
||||
explicit DlgSettingsDocumentImp(QWidget* parent = nullptr);
|
||||
~DlgSettingsDocumentImp() override;
|
||||
|
||||
void saveSettings() override;
|
||||
@@ -51,14 +53,14 @@ protected Q_SLOTS:
|
||||
void onLicenseTypeChanged(int index);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
void changeEvent(QEvent* e) override;
|
||||
void addLicenseTypes();
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgSettingsDocument> ui;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSDOCUMENT_IMP_H
|
||||
#endif // GUI_DIALOG_DLGSETTINGSDOCUMENT_IMP_H
|
||||
|
||||
@@ -80,65 +80,77 @@ DlgSettingsEditor::DlgSettingsEditor(QWidget* parent)
|
||||
QColor col;
|
||||
col = qApp->palette().windowText().color();
|
||||
unsigned int lText = Base::Color::asPackedRGB<QColor>(col);
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Text")), lText));
|
||||
d->colormap.push_back(QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Text")), lText));
|
||||
|
||||
unsigned int lBookmarks = Base::Color::asPackedRGB<QColor>(QColor(Qt::cyan));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Bookmark")), lBookmarks));
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Bookmark")), lBookmarks)
|
||||
);
|
||||
|
||||
unsigned int lBreakpnts = Base::Color::asPackedRGB<QColor>(QColor(Qt::red));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Breakpoint")), lBreakpnts));
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Breakpoint")), lBreakpnts)
|
||||
);
|
||||
|
||||
unsigned int lKeywords = Base::Color::asPackedRGB<QColor>(QColor(Qt::blue));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Keyword")), lKeywords));
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Keyword")), lKeywords)
|
||||
);
|
||||
|
||||
unsigned int lComments = Base::Color::asPackedRGB<QColor>(QColor(0, 170, 0));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Comment")), lComments));
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Comment")), lComments)
|
||||
);
|
||||
|
||||
unsigned int lBlockCom = Base::Color::asPackedRGB<QColor>(QColor(160, 160, 164));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Block comment")), lBlockCom));
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Block comment")), lBlockCom)
|
||||
);
|
||||
|
||||
unsigned int lNumbers = Base::Color::asPackedRGB<QColor>(QColor(Qt::blue));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Number")), lNumbers));
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Number")), lNumbers)
|
||||
);
|
||||
|
||||
unsigned int lStrings = Base::Color::asPackedRGB<QColor>(QColor(Qt::red));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("String")), lStrings));
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("String")), lStrings)
|
||||
);
|
||||
|
||||
unsigned int lCharacter = Base::Color::asPackedRGB<QColor>(QColor(Qt::red));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Character")), lCharacter));
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Character")), lCharacter)
|
||||
);
|
||||
|
||||
unsigned int lClass = Base::Color::asPackedRGB<QColor>(QColor(255, 170, 0));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Class name")), lClass));
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Class name")), lClass)
|
||||
);
|
||||
|
||||
unsigned int lDefine = Base::Color::asPackedRGB<QColor>(QColor(255, 170, 0));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Define name")), lDefine));
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Define name")), lDefine)
|
||||
);
|
||||
|
||||
unsigned int lOperat = Base::Color::asPackedRGB<QColor>(QColor(160, 160, 164));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Operator")), lOperat));
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Operator")), lOperat)
|
||||
);
|
||||
|
||||
unsigned int lPyOutput = Base::Color::asPackedRGB<QColor>(QColor(170, 170, 127));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Python output")), lPyOutput));
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Python output")), lPyOutput)
|
||||
);
|
||||
|
||||
unsigned int lPyError = Base::Color::asPackedRGB<QColor>(QColor(Qt::red));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Python error")), lPyError));
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Python error")), lPyError)
|
||||
);
|
||||
|
||||
unsigned int lCLine = Base::Color::asPackedRGB<QColor>(QColor(224, 224, 224));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Current line highlight")),
|
||||
lCLine));
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Current line highlight")), lCLine)
|
||||
);
|
||||
|
||||
QStringList labels;
|
||||
labels << tr("Items");
|
||||
@@ -236,18 +248,20 @@ void DlgSettingsEditor::loadSettings()
|
||||
ui->radioSpaces->onRestore();
|
||||
|
||||
setEditorTabWidth(ui->tabSize->value());
|
||||
ui->textEdit1->setPlainText(QStringLiteral("# Short Python sample\n"
|
||||
"import sys\n"
|
||||
"\n"
|
||||
"def foo(begin, end):\n"
|
||||
" i = begin\n"
|
||||
" while i < end:\n"
|
||||
" print(i)\n"
|
||||
" i = i + 1\n"
|
||||
" print(\"Text\")\n"
|
||||
" return None\n"
|
||||
"\n"
|
||||
"foo(0, 20)\n"));
|
||||
ui->textEdit1->setPlainText(QStringLiteral(
|
||||
"# Short Python sample\n"
|
||||
"import sys\n"
|
||||
"\n"
|
||||
"def foo(begin, end):\n"
|
||||
" i = begin\n"
|
||||
" while i < end:\n"
|
||||
" print(i)\n"
|
||||
" i = i + 1\n"
|
||||
" print(\"Text\")\n"
|
||||
" return None\n"
|
||||
"\n"
|
||||
"foo(0, 20)\n"
|
||||
));
|
||||
|
||||
// Restores the color map
|
||||
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("Editor");
|
||||
@@ -274,8 +288,7 @@ void DlgSettingsEditor::loadSettings()
|
||||
// cursor.pcf was removed to cope with a problem with the Qt Font Manager
|
||||
// See https://github.com/FreeCAD/FreeCAD/issues/10514 for details
|
||||
if (name.compare(QLatin1String("8514oem"), Qt::CaseInsensitive) != 0
|
||||
&& name.compare(QLatin1String("cursor.pcf"), Qt::CaseInsensitive) != 0)
|
||||
{
|
||||
&& name.compare(QLatin1String("cursor.pcf"), Qt::CaseInsensitive) != 0) {
|
||||
fixedFamilyNames.append(name);
|
||||
}
|
||||
}
|
||||
@@ -288,8 +301,7 @@ void DlgSettingsEditor::loadSettings()
|
||||
// cursor.pcf was removed to cope with a problem with the Qt Font Manager
|
||||
// See https://github.com/FreeCAD/FreeCAD/issues/10514 for details
|
||||
if (name.compare(QLatin1String("8514oem"), Qt::CaseInsensitive) != 0
|
||||
&& name.compare(QLatin1String("cursor.pcf"), Qt::CaseInsensitive) != 0)
|
||||
{
|
||||
&& name.compare(QLatin1String("cursor.pcf"), Qt::CaseInsensitive) != 0) {
|
||||
fixedFamilyNames.append(name);
|
||||
}
|
||||
}
|
||||
@@ -297,7 +309,8 @@ void DlgSettingsEditor::loadSettings()
|
||||
#endif
|
||||
ui->fontFamily->addItems(fixedFamilyNames);
|
||||
int index = fixedFamilyNames.indexOf(
|
||||
QString::fromLatin1(hGrp->GetASCII("Font", defaultMonospaceFont).c_str()));
|
||||
QString::fromLatin1(hGrp->GetASCII("Font", defaultMonospaceFont).c_str())
|
||||
);
|
||||
if (index < 0) {
|
||||
index = 0;
|
||||
}
|
||||
|
||||
@@ -29,10 +29,12 @@
|
||||
|
||||
class QTreeWidgetItem;
|
||||
|
||||
namespace Gui {
|
||||
namespace Gui
|
||||
{
|
||||
class PythonSyntaxHighlighter;
|
||||
|
||||
namespace Dialog {
|
||||
namespace Dialog
|
||||
{
|
||||
class Ui_DlgSettingsEditor;
|
||||
|
||||
/** This class implements a preferences page for the editor settings.
|
||||
@@ -40,12 +42,12 @@ class Ui_DlgSettingsEditor;
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
struct DlgSettingsEditorP;
|
||||
class DlgSettingsEditor : public PreferencePage
|
||||
class DlgSettingsEditor: public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgSettingsEditor( QWidget* parent = nullptr );
|
||||
explicit DlgSettingsEditor(QWidget* parent = nullptr);
|
||||
~DlgSettingsEditor() override;
|
||||
|
||||
public:
|
||||
@@ -55,13 +57,13 @@ public:
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
void onDisplayItemsCurrentItemChanged(QTreeWidgetItem *i);
|
||||
void onDisplayItemsCurrentItemChanged(QTreeWidgetItem* i);
|
||||
void onColorButtonChanged();
|
||||
void onFontFamilyActivated(const QString&);
|
||||
void onFontSizeValueChanged(const QString&);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
void changeEvent(QEvent* e) override;
|
||||
void setEditorTabWidth(int);
|
||||
|
||||
private:
|
||||
@@ -69,11 +71,11 @@ private:
|
||||
DlgSettingsEditorP* d;
|
||||
Gui::PythonSyntaxHighlighter* pythonSyntax;
|
||||
|
||||
DlgSettingsEditor( const DlgSettingsEditor & );
|
||||
DlgSettingsEditor& operator=( const DlgSettingsEditor & );
|
||||
DlgSettingsEditor(const DlgSettingsEditor&);
|
||||
DlgSettingsEditor& operator=(const DlgSettingsEditor&);
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSEDITOR_H
|
||||
#endif // GUI_DIALOG_DLGSETTINGSEDITOR_H
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
/****************************************************************************
|
||||
* Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* Copyright (c) 2023 FreeCAD Project Association *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD 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 *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
/****************************************************************************
|
||||
* Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* Copyright (c) 2023 FreeCAD Project Association *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD 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 *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
# include <cmath>
|
||||
# include <limits>
|
||||
# include <QApplication>
|
||||
# include <QFileDialog>
|
||||
# include <QLocale>
|
||||
# include <QMessageBox>
|
||||
# include <QString>
|
||||
# include <algorithm>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <QApplication>
|
||||
#include <QFileDialog>
|
||||
#include <QLocale>
|
||||
#include <QMessageBox>
|
||||
#include <QString>
|
||||
#include <algorithm>
|
||||
|
||||
#include <App/Document.h>
|
||||
#include <Base/Parameter.h>
|
||||
@@ -59,8 +59,8 @@
|
||||
using namespace Gui;
|
||||
using namespace Gui::Dialog;
|
||||
namespace fs = std::filesystem;
|
||||
using Base::UnitsApi;
|
||||
using Base::QuantityFormat;
|
||||
using Base::UnitsApi;
|
||||
|
||||
/* TRANSLATOR Gui::Dialog::DlgSettingsGeneral */
|
||||
|
||||
@@ -71,17 +71,17 @@ using Base::QuantityFormat;
|
||||
* The dialog will by default be modeless, unless you set 'modal' to
|
||||
* true to construct a modal dialog.
|
||||
*/
|
||||
DlgSettingsGeneral::DlgSettingsGeneral( QWidget* parent )
|
||||
: PreferencePage(parent)
|
||||
, localeIndex(0)
|
||||
, themeChanged(false)
|
||||
, ui(new Ui_DlgSettingsGeneral)
|
||||
DlgSettingsGeneral::DlgSettingsGeneral(QWidget* parent)
|
||||
: PreferencePage(parent)
|
||||
, localeIndex(0)
|
||||
, themeChanged(false)
|
||||
, ui(new Ui_DlgSettingsGeneral)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
recreatePreferencePackMenu();
|
||||
|
||||
for(const char* option : Translator::formattingOptions) {
|
||||
for (const char* option : Translator::formattingOptions) {
|
||||
ui->UseLocaleFormatting->addItem(tr(option));
|
||||
}
|
||||
|
||||
@@ -102,19 +102,39 @@ DlgSettingsGeneral::DlgSettingsGeneral( QWidget* parent )
|
||||
}
|
||||
if (ui->themesCombobox->isEnabled()) {
|
||||
connect(ui->ImportConfig, &QPushButton::clicked, this, &DlgSettingsGeneral::onImportConfigClicked);
|
||||
connect(ui->SaveNewPreferencePack, &QPushButton::clicked, this, &DlgSettingsGeneral::saveAsNewPreferencePack);
|
||||
connect(
|
||||
ui->SaveNewPreferencePack,
|
||||
&QPushButton::clicked,
|
||||
this,
|
||||
&DlgSettingsGeneral::saveAsNewPreferencePack
|
||||
);
|
||||
ui->ManagePreferencePacks->setToolTip(tr("Manage preference packs"));
|
||||
connect(ui->ManagePreferencePacks, &QPushButton::clicked, this, &DlgSettingsGeneral::onManagePreferencePacksClicked);
|
||||
connect(ui->themesCombobox, qOverload<int>(&QComboBox::activated), this, &DlgSettingsGeneral::onThemeChanged);
|
||||
connect(
|
||||
ui->ManagePreferencePacks,
|
||||
&QPushButton::clicked,
|
||||
this,
|
||||
&DlgSettingsGeneral::onManagePreferencePacksClicked
|
||||
);
|
||||
connect(
|
||||
ui->themesCombobox,
|
||||
qOverload<int>(&QComboBox::activated),
|
||||
this,
|
||||
&DlgSettingsGeneral::onThemeChanged
|
||||
);
|
||||
connect(ui->moreThemesLabel, &QLabel::linkActivated, this, &DlgSettingsGeneral::onLinkActivated);
|
||||
}
|
||||
|
||||
// If there are any saved config file backs, show the revert button, otherwise hide it:
|
||||
const auto & backups = Application::Instance->prefPackManager()->configBackups();
|
||||
const auto& backups = Application::Instance->prefPackManager()->configBackups();
|
||||
ui->RevertToSavedConfig->setEnabled(backups.empty());
|
||||
connect(ui->RevertToSavedConfig, &QPushButton::clicked, this, &DlgSettingsGeneral::revertToSavedConfig);
|
||||
|
||||
connect(ui->comboBox_UnitSystem, qOverload<int>(&QComboBox::currentIndexChanged), this, &DlgSettingsGeneral::onUnitSystemIndexChanged);
|
||||
connect(
|
||||
ui->comboBox_UnitSystem,
|
||||
qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
this,
|
||||
&DlgSettingsGeneral::onUnitSystemIndexChanged
|
||||
);
|
||||
ui->spinBoxDecimals->setMaximum(std::numeric_limits<double>::digits10 + 1);
|
||||
|
||||
auto addItem = [&, index {0}](const std::string& item) mutable {
|
||||
@@ -128,7 +148,8 @@ DlgSettingsGeneral::DlgSettingsGeneral( QWidget* parent )
|
||||
ui->comboBox_FracInch->setVisible(visible);
|
||||
ui->fractionalInchLabel->setVisible(visible);
|
||||
ui->moreThemesLabel->setEnabled(
|
||||
Application::Instance->commandManager().getCommandByName("Std_AddonMgr") != nullptr);
|
||||
Application::Instance->commandManager().getCommandByName("Std_AddonMgr") != nullptr
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,8 +163,7 @@ DlgSettingsGeneral::~DlgSettingsGeneral() = default;
|
||||
*/
|
||||
void DlgSettingsGeneral::setRecentFileSize()
|
||||
{
|
||||
auto recent = getMainWindow()->findChild<RecentFilesAction *>
|
||||
(QLatin1String("recentFiles"));
|
||||
auto recent = getMainWindow()->findChild<RecentFilesAction*>(QLatin1String("recentFiles"));
|
||||
if (recent) {
|
||||
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("RecentFiles");
|
||||
recent->resizeList(hGrp->GetInt("RecentFiles", 4));
|
||||
@@ -164,7 +184,7 @@ bool DlgSettingsGeneral::setLanguage()
|
||||
return false;
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::setNumberLocale(bool force/* = false*/)
|
||||
void DlgSettingsGeneral::setNumberLocale(bool force /* = false*/)
|
||||
{
|
||||
int localeFormat = ui->UseLocaleFormatting->currentIndex();
|
||||
|
||||
@@ -178,8 +198,9 @@ void DlgSettingsGeneral::setNumberLocale(bool force/* = false*/)
|
||||
|
||||
void DlgSettingsGeneral::saveUnitSystemSettings()
|
||||
{
|
||||
ParameterGrp::handle hGrpu = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/Units");
|
||||
ParameterGrp::handle hGrpu = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Units"
|
||||
);
|
||||
hGrpu->SetInt("UserSchema", ui->comboBox_UnitSystem->currentIndex());
|
||||
hGrpu->SetInt("Decimals", ui->spinBoxDecimals->value());
|
||||
hGrpu->SetBool("IgnoreProjectSchema", ui->checkBox_projectUnitSystemIgnore->isChecked());
|
||||
@@ -241,14 +262,16 @@ void DlgSettingsGeneral::saveSettings()
|
||||
QVariant size = ui->toolbarIconSize->itemData(ui->toolbarIconSize->currentIndex());
|
||||
int pixel = size.toInt();
|
||||
hGrp->SetInt("ToolbarIconSize", pixel);
|
||||
getMainWindow()->setIconSize(QSize(pixel,pixel));
|
||||
getMainWindow()->setIconSize(QSize(pixel, pixel));
|
||||
|
||||
int blinkTime{hGrp->GetBool("EnableCursorBlinking", true) ? -1 : 0};
|
||||
int blinkTime {hGrp->GetBool("EnableCursorBlinking", true) ? -1 : 0};
|
||||
qApp->setCursorFlashTime(blinkTime);
|
||||
|
||||
saveDockWindowVisibility();
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/MainWindow");
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/MainWindow"
|
||||
);
|
||||
hGrp->SetBool("TiledBackground", ui->tiledBackground->isChecked());
|
||||
|
||||
if (themeChanged) {
|
||||
@@ -264,8 +287,9 @@ void DlgSettingsGeneral::loadSettings()
|
||||
int FracInch;
|
||||
int cbIndex;
|
||||
|
||||
ParameterGrp::handle hGrpu = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/Units");
|
||||
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", UnitsApi::getDecimals()));
|
||||
ui->checkBox_projectUnitSystemIgnore->setChecked(hGrpu->GetBool("IgnoreProjectSchema", false));
|
||||
@@ -309,8 +333,9 @@ void DlgSettingsGeneral::loadSettings()
|
||||
QLocale locale(QString::fromLatin1(it->second.c_str()));
|
||||
QString native = locale.nativeLanguageName();
|
||||
if (!native.isEmpty()) {
|
||||
if (native[0].isLetter())
|
||||
if (native[0].isLetter()) {
|
||||
native[0] = native[0].toUpper();
|
||||
}
|
||||
langname = native;
|
||||
}
|
||||
|
||||
@@ -327,10 +352,12 @@ void DlgSettingsGeneral::loadSettings()
|
||||
|
||||
addIconSizes(getCurrentIconSize());
|
||||
|
||||
//TreeMode combobox setup.
|
||||
// TreeMode combobox setup.
|
||||
loadDockWindowVisibility();
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/MainWindow");
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/MainWindow"
|
||||
);
|
||||
ui->tiledBackground->setChecked(hGrp->GetBool("TiledBackground", false));
|
||||
|
||||
loadThemes();
|
||||
@@ -340,43 +367,49 @@ void DlgSettingsGeneral::resetSettingsToDefaults()
|
||||
{
|
||||
ParameterGrp::handle hGrp;
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Units");
|
||||
//reset "UserSchema" parameter
|
||||
// reset "UserSchema" parameter
|
||||
hGrp->RemoveInt("UserSchema");
|
||||
//reset "Decimals" parameter
|
||||
// reset "Decimals" parameter
|
||||
hGrp->RemoveInt("Decimals");
|
||||
//reset "IgnoreProjectSchema" parameter
|
||||
// reset "IgnoreProjectSchema" parameter
|
||||
hGrp->RemoveBool("IgnoreProjectSchema");
|
||||
//reset "FracInch" parameter
|
||||
// reset "FracInch" parameter
|
||||
hGrp->RemoveInt("FracInch");
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/MainWindow");
|
||||
//reset "Theme" parameter
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/MainWindow"
|
||||
);
|
||||
// reset "Theme" parameter
|
||||
hGrp->RemoveASCII("Theme");
|
||||
//reset "TiledBackground" parameter
|
||||
// reset "TiledBackground" parameter
|
||||
hGrp->RemoveBool("TiledBackground");
|
||||
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/DockWindows");
|
||||
//reset "ComboView" parameters
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/DockWindows"
|
||||
);
|
||||
// reset "ComboView" parameters
|
||||
hGrp->GetGroup("ComboView")->RemoveBool("Enabled");
|
||||
//reset "TreeView" parameters
|
||||
// reset "TreeView" parameters
|
||||
hGrp->GetGroup("TreeView")->RemoveBool("Enabled");
|
||||
//reset "PropertyView" parameters
|
||||
// reset "PropertyView" parameters
|
||||
hGrp->GetGroup("PropertyView")->RemoveBool("Enabled");
|
||||
|
||||
hGrp = WindowParameter::getDefaultParameter()->GetGroup("General");
|
||||
//reset "Language" parameter
|
||||
// reset "Language" parameter
|
||||
hGrp->RemoveASCII("Language");
|
||||
//reset "ToolbarIconSize" parameter
|
||||
// reset "ToolbarIconSize" parameter
|
||||
hGrp->RemoveInt("ToolbarIconSize");
|
||||
|
||||
//finally reset all the parameters associated to Gui::Pref* widgets
|
||||
// finally reset all the parameters associated to Gui::Pref* widgets
|
||||
PreferencePage::resetSettingsToDefaults();
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::saveThemes()
|
||||
{
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/MainWindow");
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/MainWindow"
|
||||
);
|
||||
|
||||
// First we check if the theme has actually changed.
|
||||
std::string previousTheme = hGrp->GetASCII("Theme", "").c_str();
|
||||
@@ -398,9 +431,10 @@ void DlgSettingsGeneral::saveThemes()
|
||||
if (pack.first == newTheme) {
|
||||
|
||||
if (Application::Instance->prefPackManager()->apply(pack.first)) {
|
||||
auto parentDialog = qobject_cast<DlgPreferencesImp*> (this->window());
|
||||
if (parentDialog)
|
||||
auto parentDialog = qobject_cast<DlgPreferencesImp*>(this->window());
|
||||
if (parentDialog) {
|
||||
parentDialog->reload();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -414,7 +448,8 @@ void DlgSettingsGeneral::loadThemes()
|
||||
ui->themesCombobox->clear();
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/MainWindow");
|
||||
"User parameter:BaseApp/Preferences/MainWindow"
|
||||
);
|
||||
|
||||
QString currentTheme = QString::fromLatin1(hGrp->GetASCII("Theme", "").c_str());
|
||||
|
||||
@@ -440,8 +475,8 @@ void DlgSettingsGeneral::loadThemes()
|
||||
}
|
||||
|
||||
if (currentTheme.isEmpty()) {
|
||||
if (!currentStyleSheet.isEmpty()
|
||||
&& !similarTheme.isEmpty()) { // a user upgrading from 0.21 or earlier
|
||||
if (!currentStyleSheet.isEmpty() && !similarTheme.isEmpty()) { // a user upgrading from
|
||||
// 0.21 or earlier
|
||||
hGrp->SetASCII("Theme", similarTheme.toStdString());
|
||||
currentTheme = QString::fromLatin1(hGrp->GetASCII("Theme", "").c_str());
|
||||
}
|
||||
@@ -468,7 +503,7 @@ void DlgSettingsGeneral::addIconSizes(int current)
|
||||
{
|
||||
ui->toolbarIconSize->clear();
|
||||
|
||||
QList<int> sizes{16, 24, 32, 48};
|
||||
QList<int> sizes {16, 24, 32, 48};
|
||||
if (!sizes.contains(current)) {
|
||||
sizes.append(current);
|
||||
}
|
||||
@@ -511,7 +546,7 @@ void DlgSettingsGeneral::retranslateUnits()
|
||||
std::for_each(descriptions.begin(), descriptions.end(), setItem);
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::changeEvent(QEvent *event)
|
||||
void DlgSettingsGeneral::changeEvent(QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::LanguageChange) {
|
||||
translateIconSizes();
|
||||
@@ -527,7 +562,9 @@ void DlgSettingsGeneral::changeEvent(QEvent *event)
|
||||
|
||||
void DlgSettingsGeneral::saveDockWindowVisibility()
|
||||
{
|
||||
auto hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/DockWindows");
|
||||
auto hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/DockWindows"
|
||||
);
|
||||
bool treeView = hGrp->GetGroup("TreeView")->GetBool("Enabled", false);
|
||||
bool propertyView = hGrp->GetGroup("PropertyView")->GetBool("Enabled", false);
|
||||
bool comboView = hGrp->GetGroup("ComboView")->GetBool("Enabled", true);
|
||||
@@ -545,14 +582,14 @@ void DlgSettingsGeneral::saveDockWindowVisibility()
|
||||
}
|
||||
|
||||
switch (ui->treeMode->currentIndex()) {
|
||||
case 0:
|
||||
comboView = true;
|
||||
treeView = propertyView = false;
|
||||
break;
|
||||
case 1:
|
||||
treeView = propertyView = true;
|
||||
comboView = false;
|
||||
break;
|
||||
case 0:
|
||||
comboView = true;
|
||||
treeView = propertyView = false;
|
||||
break;
|
||||
case 1:
|
||||
treeView = propertyView = true;
|
||||
comboView = false;
|
||||
break;
|
||||
}
|
||||
|
||||
hGrp->GetGroup("ComboView")->SetBool("Enabled", comboView);
|
||||
@@ -566,7 +603,9 @@ void DlgSettingsGeneral::loadDockWindowVisibility()
|
||||
ui->treeMode->addItem(tr("Combined"));
|
||||
ui->treeMode->addItem(tr("Independent"));
|
||||
|
||||
auto hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/DockWindows");
|
||||
auto hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/DockWindows"
|
||||
);
|
||||
bool propertyView = hGrp->GetGroup("PropertyView")->GetBool("Enabled", false);
|
||||
bool treeView = hGrp->GetGroup("TreeView")->GetBool("Enabled", false);
|
||||
bool comboView = hGrp->GetGroup("ComboView")->GetBool("Enabled", true);
|
||||
@@ -582,18 +621,20 @@ void DlgSettingsGeneral::loadDockWindowVisibility()
|
||||
|
||||
void DlgSettingsGeneral::recreatePreferencePackMenu()
|
||||
{
|
||||
ui->PreferencePacks->setRowCount(0); // Begin by clearing whatever is there
|
||||
ui->PreferencePacks->setRowCount(0); // Begin by clearing whatever is there
|
||||
ui->PreferencePacks->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
|
||||
ui->PreferencePacks->setColumnCount(3);
|
||||
ui->PreferencePacks->setSelectionMode(QAbstractItemView::SelectionMode::NoSelection);
|
||||
ui->PreferencePacks->horizontalHeader()->setStretchLastSection(false);
|
||||
ui->PreferencePacks->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeMode::Stretch);
|
||||
ui->PreferencePacks->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeMode::Stretch);
|
||||
ui->PreferencePacks->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeMode::ResizeToContents);
|
||||
ui->PreferencePacks->horizontalHeader()->setSectionResizeMode(
|
||||
2,
|
||||
QHeaderView::ResizeMode::ResizeToContents
|
||||
);
|
||||
QStringList columnHeaders;
|
||||
columnHeaders << tr("Preference Pack Name")
|
||||
<< tr("Tags")
|
||||
<< QString(); // for the "Load" buttons
|
||||
columnHeaders << tr("Preference Pack Name") << tr("Tags")
|
||||
<< QString(); // for the "Load" buttons
|
||||
ui->PreferencePacks->setHorizontalHeaderLabels(columnHeaders);
|
||||
|
||||
// Populate the Preference Packs list
|
||||
@@ -604,11 +645,11 @@ void DlgSettingsGeneral::recreatePreferencePackMenu()
|
||||
std::vector<std::string> packsToRemove;
|
||||
for (const auto& pack : packs) {
|
||||
if (pack.second.metadata().type() == "Theme") {
|
||||
packsToRemove.push_back(pack.first); // Store the keys to remove later
|
||||
packsToRemove.push_back(pack.first); // Store the keys to remove later
|
||||
}
|
||||
}
|
||||
for (const auto& key : packsToRemove) {
|
||||
packs.erase(key); // Remove the elements from the map
|
||||
packs.erase(key); // Remove the elements from the map
|
||||
}
|
||||
|
||||
ui->PreferencePacks->setRowCount(packs.size());
|
||||
@@ -622,10 +663,12 @@ void DlgSettingsGeneral::recreatePreferencePackMenu()
|
||||
auto tags = pack.second.metadata().tag();
|
||||
QString tagString;
|
||||
for (const auto& tag : tags) {
|
||||
if (tagString.isEmpty())
|
||||
if (tagString.isEmpty()) {
|
||||
tagString.append(QString::fromStdString(tag));
|
||||
else
|
||||
}
|
||||
else {
|
||||
tagString.append(QStringLiteral(", ") + QString::fromStdString(tag));
|
||||
}
|
||||
}
|
||||
auto kind = new QTableWidgetItem(tagString);
|
||||
ui->PreferencePacks->setItem(row, 1, kind);
|
||||
@@ -642,8 +685,12 @@ void DlgSettingsGeneral::recreatePreferencePackMenu()
|
||||
}
|
||||
}
|
||||
if (button->isEnabled()) {
|
||||
button->setToolTip(tr("Applies the %1 preference pack").arg(QString::fromStdString(pack.first)));
|
||||
connect(button, &QPushButton::clicked, this, [this, pack]() { onLoadPreferencePackClicked(pack.first); });
|
||||
button->setToolTip(
|
||||
tr("Applies the %1 preference pack").arg(QString::fromStdString(pack.first))
|
||||
);
|
||||
connect(button, &QPushButton::clicked, this, [this, pack]() {
|
||||
onLoadPreferencePackClicked(pack.first);
|
||||
});
|
||||
}
|
||||
ui->PreferencePacks->setCellWidget(row, 2, button);
|
||||
++row;
|
||||
@@ -655,9 +702,16 @@ void DlgSettingsGeneral::saveAsNewPreferencePack()
|
||||
// Create and run a modal New PreferencePack dialog box
|
||||
auto packs = Application::Instance->prefPackManager()->preferencePackNames();
|
||||
newPreferencePackDialog = std::make_unique<DlgCreateNewPreferencePackImp>(this);
|
||||
newPreferencePackDialog->setPreferencePackTemplates(Application::Instance->prefPackManager()->templateFiles());
|
||||
newPreferencePackDialog->setPreferencePackTemplates(
|
||||
Application::Instance->prefPackManager()->templateFiles()
|
||||
);
|
||||
newPreferencePackDialog->setPreferencePackNames(packs);
|
||||
connect(newPreferencePackDialog.get(), &DlgCreateNewPreferencePackImp::accepted, this, &DlgSettingsGeneral::newPreferencePackDialogAccepted);
|
||||
connect(
|
||||
newPreferencePackDialog.get(),
|
||||
&DlgCreateNewPreferencePackImp::accepted,
|
||||
this,
|
||||
&DlgSettingsGeneral::newPreferencePackDialogAccepted
|
||||
);
|
||||
newPreferencePackDialog->open();
|
||||
}
|
||||
|
||||
@@ -665,7 +719,7 @@ void DlgSettingsGeneral::revertToSavedConfig()
|
||||
{
|
||||
revertToBackupConfigDialog = std::make_unique<DlgRevertToBackupConfigImp>(this);
|
||||
connect(revertToBackupConfigDialog.get(), &DlgRevertToBackupConfigImp::accepted, this, [this]() {
|
||||
auto parentDialog = qobject_cast<DlgPreferencesImp*> (this->window());
|
||||
auto parentDialog = qobject_cast<DlgPreferencesImp*>(this->window());
|
||||
if (parentDialog) {
|
||||
parentDialog->reload();
|
||||
}
|
||||
@@ -678,17 +732,23 @@ void DlgSettingsGeneral::newPreferencePackDialogAccepted()
|
||||
auto preferencePackTemplates = Application::Instance->prefPackManager()->templateFiles();
|
||||
auto selection = newPreferencePackDialog->selectedTemplates();
|
||||
std::vector<PreferencePackManager::TemplateFile> selectedTemplates;
|
||||
std::copy_if(preferencePackTemplates.begin(), preferencePackTemplates.end(), std::back_inserter(selectedTemplates), [selection](PreferencePackManager::TemplateFile& tf) {
|
||||
for (const auto& item : selection) {
|
||||
if (item.group == tf.group && item.name == tf.name) {
|
||||
return true;
|
||||
std::copy_if(
|
||||
preferencePackTemplates.begin(),
|
||||
preferencePackTemplates.end(),
|
||||
std::back_inserter(selectedTemplates),
|
||||
[selection](PreferencePackManager::TemplateFile& tf) {
|
||||
for (const auto& item : selection) {
|
||||
if (item.group == tf.group && item.name == tf.name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
);
|
||||
auto preferencePackName = newPreferencePackDialog->preferencePackName();
|
||||
auto preferencePackDirectory = newPreferencePackDialog->preferencePackDirectory();
|
||||
Application::Instance->prefPackManager()->save(preferencePackName, preferencePackDirectory, selectedTemplates);
|
||||
Application::Instance->prefPackManager()
|
||||
->save(preferencePackName, preferencePackDirectory, selectedTemplates);
|
||||
recreatePreferencePackMenu();
|
||||
}
|
||||
|
||||
@@ -696,29 +756,39 @@ void DlgSettingsGeneral::onManagePreferencePacksClicked()
|
||||
{
|
||||
if (!this->preferencePackManagementDialog) {
|
||||
this->preferencePackManagementDialog = std::make_unique<DlgPreferencePackManagementImp>(this);
|
||||
connect(this->preferencePackManagementDialog.get(), &DlgPreferencePackManagementImp::packVisibilityChanged,
|
||||
this, &DlgSettingsGeneral::recreatePreferencePackMenu);
|
||||
connect(
|
||||
this->preferencePackManagementDialog.get(),
|
||||
&DlgPreferencePackManagementImp::packVisibilityChanged,
|
||||
this,
|
||||
&DlgSettingsGeneral::recreatePreferencePackMenu
|
||||
);
|
||||
}
|
||||
this->preferencePackManagementDialog->show();
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::onImportConfigClicked()
|
||||
{
|
||||
auto path = fs::path(QFileDialog::getOpenFileName(this,
|
||||
tr("Choose a FreeCAD config file to import"),
|
||||
QString(),
|
||||
QStringLiteral("*.cfg")).toStdString());
|
||||
auto path = fs::path(
|
||||
QFileDialog::getOpenFileName(
|
||||
this,
|
||||
tr("Choose a FreeCAD config file to import"),
|
||||
QString(),
|
||||
QStringLiteral("*.cfg")
|
||||
)
|
||||
.toStdString()
|
||||
);
|
||||
if (!path.empty()) {
|
||||
// Create a name from the filename:
|
||||
auto packName = path.filename().stem().string();
|
||||
std::replace(packName.begin(), packName.end(), '_', ' ');
|
||||
auto existingPacks = Application::Instance->prefPackManager()->preferencePackNames();
|
||||
if (std::ranges::find(existingPacks, packName)
|
||||
!= existingPacks.end()) {
|
||||
if (std::ranges::find(existingPacks, packName) != existingPacks.end()) {
|
||||
auto result = QMessageBox::question(
|
||||
this, tr("File exists"),
|
||||
tr("A preference pack with that name already exists. Overwrite?"));
|
||||
if (result == QMessageBox::No) { // Maybe someday ask for a new name?
|
||||
this,
|
||||
tr("File exists"),
|
||||
tr("A preference pack with that name already exists. Overwrite?")
|
||||
);
|
||||
if (result == QMessageBox::No) { // Maybe someday ask for a new name?
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -730,9 +800,10 @@ void DlgSettingsGeneral::onImportConfigClicked()
|
||||
void DlgSettingsGeneral::onLoadPreferencePackClicked(const std::string& packName)
|
||||
{
|
||||
if (Application::Instance->prefPackManager()->apply(packName)) {
|
||||
auto parentDialog = qobject_cast<DlgPreferencesImp*> (this->window());
|
||||
if (parentDialog)
|
||||
auto parentDialog = qobject_cast<DlgPreferencesImp*>(this->window());
|
||||
if (parentDialog) {
|
||||
parentDialog->reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -749,7 +820,8 @@ void DlgSettingsGeneral::onUnitSystemIndexChanged(const int index)
|
||||
ui->fractionalInchLabel->setVisible(visible);
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::onThemeChanged(int index) {
|
||||
void DlgSettingsGeneral::onThemeChanged(int index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
themeChanged = true;
|
||||
}
|
||||
@@ -764,36 +836,44 @@ void DlgSettingsGeneral::onLinkActivated(const QString& link)
|
||||
|
||||
// Set the user preferences to include only preference packs.
|
||||
// This is a quick and dirty way to open Addon Manager with only themes.
|
||||
auto pref = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Addons");
|
||||
pref->SetInt("PackageTypeSelection", 3); // 3 stands for Preference Packs
|
||||
pref->SetInt("StatusSelection", 0); // 0 stands for any installation status
|
||||
auto pref = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Addons"
|
||||
);
|
||||
pref->SetInt("PackageTypeSelection", 3); // 3 stands for Preference Packs
|
||||
pref->SetInt("StatusSelection", 0); // 0 stands for any installation status
|
||||
|
||||
Gui::Application::Instance->commandManager().runCommandByName("Std_AddonMgr");
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
namespace {
|
||||
namespace
|
||||
{
|
||||
|
||||
class ApplyDockWidget: public ParamHandler {
|
||||
class ApplyDockWidget: public ParamHandler
|
||||
{
|
||||
public:
|
||||
bool onChange(const ParamKey *) override {
|
||||
bool onChange(const ParamKey*) override
|
||||
{
|
||||
OverlayManager::instance()->reload(OverlayManager::ReloadMode::ReloadPause);
|
||||
return true;
|
||||
}
|
||||
|
||||
void onTimer() override {
|
||||
void onTimer() override
|
||||
{
|
||||
getMainWindow()->initDockWindows(true);
|
||||
OverlayManager::instance()->reload(OverlayManager::ReloadMode::ReloadResume);
|
||||
}
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
} // anonymous namespace
|
||||
|
||||
void DlgSettingsGeneral::attachObserver()
|
||||
{
|
||||
static ParamHandlers handlers;
|
||||
|
||||
auto hDockWindows = App::GetApplication().GetUserParameter().GetGroup("BaseApp/Preferences/DockWindows");
|
||||
auto hDockWindows = App::GetApplication().GetUserParameter().GetGroup(
|
||||
"BaseApp/Preferences/DockWindows"
|
||||
);
|
||||
auto applyDockWidget = std::shared_ptr<ParamHandler>(new ApplyDockWidget);
|
||||
handlers.addHandler(ParamKey(hDockWindows->GetGroup("ComboView"), "Enabled"), applyDockWidget);
|
||||
handlers.addHandler(ParamKey(hDockWindows->GetGroup("TreeView"), "Enabled"), applyDockWidget);
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
/****************************************************************************
|
||||
* Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* Copyright (c) 2023 FreeCAD Project Association *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD 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 *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
/****************************************************************************
|
||||
* Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* Copyright (c) 2023 FreeCAD Project Association *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD 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 *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef GUI_DIALOG_DLGSETTINGSGENERAL_H
|
||||
@@ -32,8 +32,10 @@
|
||||
|
||||
class QTabWidget;
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
namespace Gui
|
||||
{
|
||||
namespace Dialog
|
||||
{
|
||||
class Ui_DlgSettingsGeneral;
|
||||
class DlgCreateNewPreferencePackImp;
|
||||
class DlgPreferencePackManagementImp;
|
||||
@@ -43,12 +45,12 @@ class DlgRevertToBackupConfigImp;
|
||||
* You can change window style, size of pixmaps, size of recent file list and so on
|
||||
* \author Werner Mayer
|
||||
*/
|
||||
class DlgSettingsGeneral : public PreferencePage
|
||||
class DlgSettingsGeneral: public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgSettingsGeneral( QWidget* parent = nullptr );
|
||||
explicit DlgSettingsGeneral(QWidget* parent = nullptr);
|
||||
~DlgSettingsGeneral() override;
|
||||
|
||||
void saveSettings() override;
|
||||
@@ -61,10 +63,10 @@ public:
|
||||
static void attachObserver();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *event) override;
|
||||
void changeEvent(QEvent* event) override;
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onLoadPreferencePackClicked(const std::string &packName);
|
||||
void onLoadPreferencePackClicked(const std::string& packName);
|
||||
void recreatePreferencePackMenu();
|
||||
void newPreferencePackDialogAccepted();
|
||||
void onManagePreferencePacksClicked();
|
||||
@@ -82,7 +84,7 @@ private:
|
||||
void setRecentFileSize();
|
||||
void saveAsNewPreferencePack();
|
||||
void revertToSavedConfig();
|
||||
bool setLanguage(); //Returns true if language has been changed
|
||||
bool setLanguage(); // Returns true if language has been changed
|
||||
void setNumberLocale(bool force = false);
|
||||
void setDecimalPointConversion(bool on);
|
||||
void retranslateUnits();
|
||||
@@ -99,7 +101,7 @@ private:
|
||||
std::unique_ptr<DlgRevertToBackupConfigImp> revertToBackupConfigDialog;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSGENERAL_H
|
||||
#endif // GUI_DIALOG_DLGSETTINGSGENERAL_H
|
||||
|
||||
@@ -54,113 +54,127 @@ DlgSettingsLightSources::DlgSettingsLightSources(QWidget* parent)
|
||||
|
||||
configureViewer();
|
||||
|
||||
const auto connectLightEvents = [this](QuantitySpinBox* horizontalAngleSpinBox,
|
||||
QuantitySpinBox* verticalAngleSpinBox,
|
||||
QSpinBox* intensitySpinBox,
|
||||
ColorButton* colorButton,
|
||||
QCheckBox* enabledCheckbox,
|
||||
auto updateLightFunction) {
|
||||
connect(horizontalAngleSpinBox,
|
||||
qOverload<double>(&QuantitySpinBox::valueChanged),
|
||||
this,
|
||||
updateLightFunction);
|
||||
connect(verticalAngleSpinBox,
|
||||
qOverload<double>(&QuantitySpinBox::valueChanged),
|
||||
this,
|
||||
updateLightFunction);
|
||||
connect(intensitySpinBox,
|
||||
qOverload<int>(&QSpinBox::valueChanged),
|
||||
this,
|
||||
updateLightFunction);
|
||||
const auto connectLightEvents = [this](
|
||||
QuantitySpinBox* horizontalAngleSpinBox,
|
||||
QuantitySpinBox* verticalAngleSpinBox,
|
||||
QSpinBox* intensitySpinBox,
|
||||
ColorButton* colorButton,
|
||||
QCheckBox* enabledCheckbox,
|
||||
auto updateLightFunction
|
||||
) {
|
||||
connect(
|
||||
horizontalAngleSpinBox,
|
||||
qOverload<double>(&QuantitySpinBox::valueChanged),
|
||||
this,
|
||||
updateLightFunction
|
||||
);
|
||||
connect(
|
||||
verticalAngleSpinBox,
|
||||
qOverload<double>(&QuantitySpinBox::valueChanged),
|
||||
this,
|
||||
updateLightFunction
|
||||
);
|
||||
connect(intensitySpinBox, qOverload<int>(&QSpinBox::valueChanged), this, updateLightFunction);
|
||||
connect(colorButton, &ColorButton::changed, this, updateLightFunction);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6,7,0)
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
|
||||
connect(enabledCheckbox, &QCheckBox::checkStateChanged, this, updateLightFunction);
|
||||
#else
|
||||
connect(enabledCheckbox, &QCheckBox::stateChanged, this, updateLightFunction);
|
||||
#endif
|
||||
};
|
||||
|
||||
const auto updateLight = [this](SoDirectionalLight* light,
|
||||
QuantitySpinBox* horizontalAngleSpinBox,
|
||||
QuantitySpinBox* verticalAngleSpinBox,
|
||||
QSpinBox* intensitySpinBox,
|
||||
ColorButton* colorButton,
|
||||
QCheckBox* enabledCheckbox,
|
||||
std::function<void(bool)> setLightEnabled) {
|
||||
const auto updateLight = [this](
|
||||
SoDirectionalLight* light,
|
||||
QuantitySpinBox* horizontalAngleSpinBox,
|
||||
QuantitySpinBox* verticalAngleSpinBox,
|
||||
QSpinBox* intensitySpinBox,
|
||||
ColorButton* colorButton,
|
||||
QCheckBox* enabledCheckbox,
|
||||
std::function<void(bool)> setLightEnabled
|
||||
) {
|
||||
light->color = Base::convertTo<SbColor>(colorButton->color());
|
||||
light->intensity = Base::fromPercent(intensitySpinBox->value());
|
||||
light->direction =
|
||||
Base::convertTo<SbVec3f>(azimuthElevationToDirection(horizontalAngleSpinBox->rawValue(),
|
||||
verticalAngleSpinBox->rawValue()));
|
||||
light->direction = Base::convertTo<SbVec3f>(azimuthElevationToDirection(
|
||||
horizontalAngleSpinBox->rawValue(),
|
||||
verticalAngleSpinBox->rawValue()
|
||||
));
|
||||
setLightEnabled(enabledCheckbox->isChecked());
|
||||
};
|
||||
|
||||
const auto updateHeadLight = [this, updateLight] {
|
||||
updateLight(view->getHeadlight(),
|
||||
ui->mainLightHorizontalAngle,
|
||||
ui->mainLightVerticalAngle,
|
||||
ui->mainLightIntensitySpinBox,
|
||||
ui->mainLightColor,
|
||||
ui->mainLightEnable,
|
||||
[this](bool enabled) {
|
||||
view->setHeadlightEnabled(enabled);
|
||||
});
|
||||
updateLight(
|
||||
view->getHeadlight(),
|
||||
ui->mainLightHorizontalAngle,
|
||||
ui->mainLightVerticalAngle,
|
||||
ui->mainLightIntensitySpinBox,
|
||||
ui->mainLightColor,
|
||||
ui->mainLightEnable,
|
||||
[this](bool enabled) { view->setHeadlightEnabled(enabled); }
|
||||
);
|
||||
};
|
||||
|
||||
const auto updateFillLight = [this, updateLight] {
|
||||
updateLight(view->getFillLight(),
|
||||
ui->fillLightHorizontalAngle,
|
||||
ui->fillLightVerticalAngle,
|
||||
ui->fillLightIntensitySpinBox,
|
||||
ui->fillLightColor,
|
||||
ui->fillLightEnable,
|
||||
[this](bool enabled) {
|
||||
view->setFillLightEnabled(enabled);
|
||||
});
|
||||
updateLight(
|
||||
view->getFillLight(),
|
||||
ui->fillLightHorizontalAngle,
|
||||
ui->fillLightVerticalAngle,
|
||||
ui->fillLightIntensitySpinBox,
|
||||
ui->fillLightColor,
|
||||
ui->fillLightEnable,
|
||||
[this](bool enabled) { view->setFillLightEnabled(enabled); }
|
||||
);
|
||||
};
|
||||
|
||||
const auto updateBackLight = [this, updateLight] {
|
||||
updateLight(view->getBacklight(),
|
||||
ui->backLightHorizontalAngle,
|
||||
ui->backLightVerticalAngle,
|
||||
ui->backLightIntensitySpinBox,
|
||||
ui->backLightColor,
|
||||
ui->backLightEnable,
|
||||
[this](bool enabled) {
|
||||
view->setBacklightEnabled(enabled);
|
||||
});
|
||||
updateLight(
|
||||
view->getBacklight(),
|
||||
ui->backLightHorizontalAngle,
|
||||
ui->backLightVerticalAngle,
|
||||
ui->backLightIntensitySpinBox,
|
||||
ui->backLightColor,
|
||||
ui->backLightEnable,
|
||||
[this](bool enabled) { view->setBacklightEnabled(enabled); }
|
||||
);
|
||||
};
|
||||
|
||||
connectLightEvents(ui->mainLightHorizontalAngle,
|
||||
ui->mainLightVerticalAngle,
|
||||
ui->mainLightIntensitySpinBox,
|
||||
ui->mainLightColor,
|
||||
ui->mainLightEnable,
|
||||
updateHeadLight);
|
||||
connectLightEvents(ui->backLightHorizontalAngle,
|
||||
ui->backLightVerticalAngle,
|
||||
ui->backLightIntensitySpinBox,
|
||||
ui->backLightColor,
|
||||
ui->backLightEnable,
|
||||
updateBackLight);
|
||||
connectLightEvents(ui->fillLightHorizontalAngle,
|
||||
ui->fillLightVerticalAngle,
|
||||
ui->fillLightIntensitySpinBox,
|
||||
ui->fillLightColor,
|
||||
ui->fillLightEnable,
|
||||
updateFillLight);
|
||||
connectLightEvents(
|
||||
ui->mainLightHorizontalAngle,
|
||||
ui->mainLightVerticalAngle,
|
||||
ui->mainLightIntensitySpinBox,
|
||||
ui->mainLightColor,
|
||||
ui->mainLightEnable,
|
||||
updateHeadLight
|
||||
);
|
||||
connectLightEvents(
|
||||
ui->backLightHorizontalAngle,
|
||||
ui->backLightVerticalAngle,
|
||||
ui->backLightIntensitySpinBox,
|
||||
ui->backLightColor,
|
||||
ui->backLightEnable,
|
||||
updateBackLight
|
||||
);
|
||||
connectLightEvents(
|
||||
ui->fillLightHorizontalAngle,
|
||||
ui->fillLightVerticalAngle,
|
||||
ui->fillLightIntensitySpinBox,
|
||||
ui->fillLightColor,
|
||||
ui->fillLightEnable,
|
||||
updateFillLight
|
||||
);
|
||||
|
||||
const auto updateAmbientLight = [this] {
|
||||
view->getEnvironment()->ambientColor =
|
||||
Base::convertTo<SbColor>(ui->ambientLightColor->color());
|
||||
view->getEnvironment()->ambientIntensity =
|
||||
Base::fromPercent(ui->ambientLightIntensitySpinBox->value());
|
||||
view->getEnvironment()->ambientColor = Base::convertTo<SbColor>(ui->ambientLightColor->color());
|
||||
view->getEnvironment()->ambientIntensity = Base::fromPercent(
|
||||
ui->ambientLightIntensitySpinBox->value()
|
||||
);
|
||||
};
|
||||
|
||||
connect(ui->ambientLightIntensitySpinBox,
|
||||
qOverload<int>(&QSpinBox::valueChanged),
|
||||
this,
|
||||
updateAmbientLight);
|
||||
connect(
|
||||
ui->ambientLightIntensitySpinBox,
|
||||
qOverload<int>(&QSpinBox::valueChanged),
|
||||
this,
|
||||
updateAmbientLight
|
||||
);
|
||||
connect(ui->ambientLightColor, &ColorButton::changed, this, updateAmbientLight);
|
||||
|
||||
connect(ui->zoomInButton, &QToolButton::clicked, this, &DlgSettingsLightSources::zoomIn);
|
||||
@@ -220,10 +234,10 @@ void DlgSettingsLightSources::configureViewer()
|
||||
|
||||
const auto callback = new SoEventCallback();
|
||||
root->addChild(callback);
|
||||
callback->addEventCallback(SoEvent::getClassTypeId(),
|
||||
[]([[maybe_unused]] void* ud, SoEventCallback* cb) {
|
||||
cb->setHandled();
|
||||
});
|
||||
callback->addEventCallback(
|
||||
SoEvent::getClassTypeId(),
|
||||
[]([[maybe_unused]] void* ud, SoEventCallback* cb) { cb->setHandled(); }
|
||||
);
|
||||
|
||||
view->setCameraType(SoOrthographicCamera::getClassTypeId());
|
||||
view->setViewDirection(defaultViewDirection);
|
||||
@@ -235,28 +249,29 @@ void DlgSettingsLightSources::configureViewer()
|
||||
zoomStep = cameraHeight / 14.0f;
|
||||
}
|
||||
|
||||
Base::Vector3d DlgSettingsLightSources::azimuthElevationToDirection(double azimuth,
|
||||
double elevation)
|
||||
Base::Vector3d DlgSettingsLightSources::azimuthElevationToDirection(double azimuth, double elevation)
|
||||
{
|
||||
azimuth = Base::toRadians(azimuth);
|
||||
elevation = Base::toRadians(elevation);
|
||||
|
||||
auto direction = Base::Vector3d {std::sin(azimuth) * std::cos(elevation),
|
||||
std::cos(azimuth) * std::cos(elevation),
|
||||
std::sin(elevation)};
|
||||
auto direction = Base::Vector3d {
|
||||
std::sin(azimuth) * std::cos(elevation),
|
||||
std::cos(azimuth) * std::cos(elevation),
|
||||
std::sin(elevation)
|
||||
};
|
||||
|
||||
direction.Normalize();
|
||||
|
||||
return direction;
|
||||
}
|
||||
|
||||
std::pair<double, double>
|
||||
DlgSettingsLightSources::directionToAzimuthElevation(Base::Vector3d direction)
|
||||
std::pair<double, double> DlgSettingsLightSources::directionToAzimuthElevation(Base::Vector3d direction)
|
||||
{
|
||||
const auto azimuth = std::atan2(direction[0], direction[1]);
|
||||
const auto elevation =
|
||||
std::atan2(direction[2],
|
||||
std::sqrt(direction[1] * direction[1] + direction[0] * direction[0]));
|
||||
const auto elevation = std::atan2(
|
||||
direction[2],
|
||||
std::sqrt(direction[1] * direction[1] + direction[0] * direction[0])
|
||||
);
|
||||
|
||||
return {Base::toDegrees(azimuth), Base::toDegrees(elevation)};
|
||||
}
|
||||
@@ -269,15 +284,18 @@ void DlgSettingsLightSources::saveSettings()
|
||||
}
|
||||
}
|
||||
|
||||
const auto saveAngles = [this](QuantitySpinBox* horizontalAngleSpinBox,
|
||||
QuantitySpinBox* verticalAngleSpinBox,
|
||||
const char* parameter) {
|
||||
const auto saveAngles = [this](
|
||||
QuantitySpinBox* horizontalAngleSpinBox,
|
||||
QuantitySpinBox* verticalAngleSpinBox,
|
||||
const char* parameter
|
||||
) {
|
||||
try {
|
||||
const auto direction = azimuthElevationToDirection(horizontalAngleSpinBox->rawValue(),
|
||||
verticalAngleSpinBox->rawValue());
|
||||
const auto direction = azimuthElevationToDirection(
|
||||
horizontalAngleSpinBox->rawValue(),
|
||||
verticalAngleSpinBox->rawValue()
|
||||
);
|
||||
|
||||
hGrp->SetASCII(parameter,
|
||||
Base::vectorToString(Base::convertTo<Base::Vector3f>(direction)));
|
||||
hGrp->SetASCII(parameter, Base::vectorToString(Base::convertTo<Base::Vector3f>(direction)));
|
||||
}
|
||||
catch (...) {
|
||||
}
|
||||
@@ -296,13 +314,16 @@ void DlgSettingsLightSources::loadSettings()
|
||||
}
|
||||
}
|
||||
|
||||
const auto loadAngles = [this](QuantitySpinBox* horizontalAngleSpinBox,
|
||||
QuantitySpinBox* verticalAngleSpinBox,
|
||||
const char* parameter) {
|
||||
const auto loadAngles = [this](
|
||||
QuantitySpinBox* horizontalAngleSpinBox,
|
||||
QuantitySpinBox* verticalAngleSpinBox,
|
||||
const char* parameter
|
||||
) {
|
||||
try {
|
||||
const auto direction = Base::stringToVector(hGrp->GetASCII(parameter));
|
||||
const auto [azimuth, elevation] =
|
||||
directionToAzimuthElevation(Base::convertTo<Base::Vector3d>(direction));
|
||||
const auto [azimuth, elevation] = directionToAzimuthElevation(
|
||||
Base::convertTo<Base::Vector3d>(direction)
|
||||
);
|
||||
|
||||
horizontalAngleSpinBox->setValue(azimuth);
|
||||
verticalAngleSpinBox->setValue(elevation);
|
||||
|
||||
@@ -37,9 +37,11 @@ class SbRotation;
|
||||
class SoDirectionalLightDragger;
|
||||
class SoOrthographicCamera;
|
||||
|
||||
namespace Gui {
|
||||
namespace Gui
|
||||
{
|
||||
class View3DInventorViewer;
|
||||
namespace Dialog {
|
||||
namespace Dialog
|
||||
{
|
||||
class Ui_DlgSettingsLightSources;
|
||||
|
||||
/**
|
||||
@@ -47,7 +49,7 @@ class Ui_DlgSettingsLightSources;
|
||||
* for the light sources of a 3D view.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class DlgSettingsLightSources : public PreferencePage
|
||||
class DlgSettingsLightSources: public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -74,15 +76,17 @@ private:
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgSettingsLightSources> ui;
|
||||
QPointer <View3DInventorViewer> view;
|
||||
SoOrthographicCamera *camera = nullptr;
|
||||
QPointer<View3DInventorViewer> view;
|
||||
SoOrthographicCamera* camera = nullptr;
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View/LightSources");
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/View/LightSources"
|
||||
);
|
||||
|
||||
float zoomStep = 3.0f;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSLIGHTSOURCES_H
|
||||
#endif // GUI_DIALOG_DLGSETTINGSLIGHTSOURCES_H
|
||||
|
||||
@@ -36,9 +36,9 @@ using namespace Gui::Dialog;
|
||||
* Constructs a DlgSettingsMacroImp which is a child of 'parent', with the
|
||||
* name 'name' and widget flags set to 'f'
|
||||
*/
|
||||
DlgSettingsMacroImp::DlgSettingsMacroImp( QWidget* parent )
|
||||
: PreferencePage( parent )
|
||||
, ui(new Ui_DlgSettingsMacro)
|
||||
DlgSettingsMacroImp::DlgSettingsMacroImp(QWidget* parent)
|
||||
: PreferencePage(parent)
|
||||
, ui(new Ui_DlgSettingsMacro)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -63,7 +63,7 @@ DlgSettingsMacroImp::~DlgSettingsMacroImp() = default;
|
||||
*/
|
||||
void DlgSettingsMacroImp::setRecentMacroSize()
|
||||
{
|
||||
auto recent = getMainWindow()->findChild<RecentMacrosAction *>(QLatin1String("recentMacros"));
|
||||
auto recent = getMainWindow()->findChild<RecentMacrosAction*>(QLatin1String("recentMacros"));
|
||||
if (recent) {
|
||||
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("RecentMacros");
|
||||
recent->resizeList(hGrp->GetInt("RecentMacros", 4));
|
||||
@@ -97,7 +97,9 @@ void DlgSettingsMacroImp::loadSettings()
|
||||
ui->MacroPath_2->onRestore();
|
||||
ui->RecentMacros->onRestore();
|
||||
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("RecentMacros");
|
||||
ui->ShortcutModifiers->setText(QString::fromStdString(hGrp->GetASCII("ShortcutModifiers", "Ctrl+Shift+")));
|
||||
ui->ShortcutModifiers->setText(
|
||||
QString::fromStdString(hGrp->GetASCII("ShortcutModifiers", "Ctrl+Shift+"))
|
||||
);
|
||||
ui->ShortcutCount->onRestore();
|
||||
}
|
||||
|
||||
@@ -105,17 +107,17 @@ void DlgSettingsMacroImp::resetSettingsToDefaults()
|
||||
{
|
||||
ParameterGrp::handle hGrp;
|
||||
hGrp = WindowParameter::getDefaultParameter()->GetGroup("RecentMacros");
|
||||
//reset "ShortcutModifiers" parameter
|
||||
// reset "ShortcutModifiers" parameter
|
||||
hGrp->RemoveASCII("ShortcutModifiers");
|
||||
|
||||
//finally reset all the parameters associated to Gui::Pref* widgets
|
||||
// finally reset all the parameters associated to Gui::Pref* widgets
|
||||
PreferencePage::resetSettingsToDefaults();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the strings of the subwidgets using the current language.
|
||||
*/
|
||||
void DlgSettingsMacroImp::changeEvent(QEvent *e)
|
||||
void DlgSettingsMacroImp::changeEvent(QEvent* e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
|
||||
@@ -27,8 +27,10 @@
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
namespace Gui
|
||||
{
|
||||
namespace Dialog
|
||||
{
|
||||
class Ui_DlgSettingsMacro;
|
||||
|
||||
/**
|
||||
@@ -36,12 +38,12 @@ class Ui_DlgSettingsMacro;
|
||||
* for macro stuff.
|
||||
* \author Jürgen Riegel
|
||||
*/
|
||||
class DlgSettingsMacroImp : public PreferencePage
|
||||
class DlgSettingsMacroImp: public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgSettingsMacroImp( QWidget* parent = nullptr );
|
||||
explicit DlgSettingsMacroImp(QWidget* parent = nullptr);
|
||||
~DlgSettingsMacroImp() override;
|
||||
|
||||
void saveSettings() override;
|
||||
@@ -49,14 +51,14 @@ public:
|
||||
void resetSettingsToDefaults() override;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
void changeEvent(QEvent* e) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgSettingsMacro> ui;
|
||||
void setRecentMacroSize();
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSMACROIMP_H
|
||||
#endif // GUI_DIALOG_DLGSETTINGSMACROIMP_H
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
# include <QApplication>
|
||||
# include <QDoubleSpinBox>
|
||||
# include <QGridLayout>
|
||||
# include <memory>
|
||||
#include <QApplication>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QGridLayout>
|
||||
#include <memory>
|
||||
|
||||
|
||||
#include <App/Application.h>
|
||||
@@ -50,9 +50,12 @@ using namespace Gui::Dialog;
|
||||
* name 'name' and widget flags set to 'f'
|
||||
*/
|
||||
DlgSettingsNavigation::DlgSettingsNavigation(QWidget* parent)
|
||||
: PreferencePage( parent )
|
||||
: PreferencePage(parent)
|
||||
, ui(new Ui_DlgSettingsNavigation)
|
||||
, q0(0), q1(0), q2(0), q3(1)
|
||||
, q0(0)
|
||||
, q1(0)
|
||||
, q2(0)
|
||||
, q3(1)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->naviCubeBaseColor->setAllowTransparency(true);
|
||||
@@ -75,10 +78,11 @@ void DlgSettingsNavigation::saveSettings()
|
||||
{
|
||||
// must be done as very first because we create a new instance of NavigatorStyle
|
||||
// where we set some attributes afterwards
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/View");
|
||||
QVariant data = ui->comboNavigationStyle->itemData(ui->comboNavigationStyle->currentIndex(),
|
||||
Qt::UserRole);
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/View"
|
||||
);
|
||||
QVariant data
|
||||
= ui->comboNavigationStyle->itemData(ui->comboNavigationStyle->currentIndex(), Qt::UserRole);
|
||||
hGrp->SetASCII("NavigationStyle", (const char*)data.toByteArray());
|
||||
|
||||
int index = ui->comboOrbitStyle->currentIndex();
|
||||
@@ -117,8 +121,7 @@ void DlgSettingsNavigation::saveSettings()
|
||||
bool useNavigationAnimations = ui->groupBoxAnimations->isChecked();
|
||||
hGrp->SetBool("UseNavigationAnimations", useNavigationAnimations);
|
||||
|
||||
QVariant camera = ui->comboNewDocView->itemData(ui->comboNewDocView->currentIndex(),
|
||||
Qt::UserRole);
|
||||
QVariant camera = ui->comboNewDocView->itemData(ui->comboNewDocView->currentIndex(), Qt::UserRole);
|
||||
hGrp->SetASCII("NewDocumentCameraOrientation", (const char*)camera.toByteArray());
|
||||
if (camera == QByteArray("Custom")) {
|
||||
ParameterGrp::handle hCustom = hGrp->GetGroup("Custom");
|
||||
@@ -127,11 +130,11 @@ void DlgSettingsNavigation::saveSettings()
|
||||
hCustom->SetFloat("Q2", q2);
|
||||
hCustom->SetFloat("Q3", q3);
|
||||
}
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/NaviCube");
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/NaviCube");
|
||||
if (ui->naviCubeFontName->currentIndex()) {
|
||||
hGrp->SetASCII("FontString", ui->naviCubeFontName->currentText().toLatin1());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hGrp->RemoveASCII("FontString");
|
||||
}
|
||||
}
|
||||
@@ -158,14 +161,18 @@ void DlgSettingsNavigation::loadSettings()
|
||||
ui->legacySpaceMouseDevices->onRestore();
|
||||
setProperty("LegacySpaceMouse", ui->legacySpaceMouseDevices->isChecked());
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/View");
|
||||
std::string model = hGrp->GetASCII("NavigationStyle", CADNavigationStyle::getClassTypeId().getName());
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/View"
|
||||
);
|
||||
std::string model
|
||||
= hGrp->GetASCII("NavigationStyle", CADNavigationStyle::getClassTypeId().getName());
|
||||
int index = ui->comboNavigationStyle->findData(QByteArray(model.c_str()));
|
||||
if (index > -1) ui->comboNavigationStyle->setCurrentIndex(index);
|
||||
if (index > -1) {
|
||||
ui->comboNavigationStyle->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
index = hGrp->GetInt("OrbitStyle", int(NavigationStyle::RoundedArcball));
|
||||
index = Base::clamp(index, 0, ui->comboOrbitStyle->count()-1);
|
||||
index = Base::clamp(index, 0, ui->comboOrbitStyle->count() - 1);
|
||||
ui->comboOrbitStyle->setCurrentIndex(index);
|
||||
|
||||
index = hGrp->GetInt("RotationMode", 0);
|
||||
@@ -182,8 +189,7 @@ void DlgSettingsNavigation::loadSettings()
|
||||
|
||||
addOrientations();
|
||||
|
||||
connect(ui->mouseButton, &QPushButton::clicked,
|
||||
this, &DlgSettingsNavigation::onMouseButtonClicked);
|
||||
connect(ui->mouseButton, &QPushButton::clicked, this, &DlgSettingsNavigation::onMouseButtonClicked);
|
||||
|
||||
// fill up font styles
|
||||
|
||||
@@ -195,12 +201,9 @@ void DlgSettingsNavigation::loadSettings()
|
||||
#endif
|
||||
ui->naviCubeFontName->addItems(familyNames);
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/NaviCube");
|
||||
int indexFamilyNames = familyNames.indexOf(
|
||||
QString::fromStdString(hGrp->GetASCII("FontString")));
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/NaviCube");
|
||||
int indexFamilyNames = familyNames.indexOf(QString::fromStdString(hGrp->GetASCII("FontString")));
|
||||
ui->naviCubeFontName->setCurrentIndex(indexFamilyNames + 1);
|
||||
|
||||
}
|
||||
|
||||
void DlgSettingsNavigation::addOrientations()
|
||||
@@ -216,11 +219,14 @@ void DlgSettingsNavigation::addOrientations()
|
||||
ui->comboNewDocView->addItem(tr("Bottom"), QByteArray("Bottom"));
|
||||
ui->comboNewDocView->addItem(tr("Custom"), QByteArray("Custom"));
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/View");
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/View"
|
||||
);
|
||||
std::string camera = hGrp->GetASCII("NewDocumentCameraOrientation", "Trimetric");
|
||||
int index = ui->comboNewDocView->findData(QByteArray(camera.c_str()));
|
||||
if (index > -1) ui->comboNewDocView->setCurrentIndex(index);
|
||||
if (index > -1) {
|
||||
ui->comboNewDocView->setCurrentIndex(index);
|
||||
}
|
||||
if (camera == "Custom") {
|
||||
ParameterGrp::handle hCustom = hGrp->GetGroup("Custom");
|
||||
q0 = hCustom->GetFloat("Q0", q0);
|
||||
@@ -229,8 +235,12 @@ void DlgSettingsNavigation::addOrientations()
|
||||
q3 = hCustom->GetFloat("Q3", q3);
|
||||
}
|
||||
|
||||
connect(ui->comboNewDocView, qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
this, &DlgSettingsNavigation::onNewDocViewChanged);
|
||||
connect(
|
||||
ui->comboNewDocView,
|
||||
qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
this,
|
||||
&DlgSettingsNavigation::onNewDocViewChanged
|
||||
);
|
||||
}
|
||||
|
||||
void DlgSettingsNavigation::translateOrientations()
|
||||
@@ -251,32 +261,32 @@ void DlgSettingsNavigation::resetSettingsToDefaults()
|
||||
{
|
||||
ParameterGrp::handle hGrp;
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
|
||||
//reset "NavigationStyle" parameter
|
||||
// reset "NavigationStyle" parameter
|
||||
hGrp->RemoveASCII("NavigationStyle");
|
||||
//reset "OrbitStyle" parameter
|
||||
// reset "OrbitStyle" parameter
|
||||
hGrp->RemoveInt("OrbitStyle");
|
||||
//reset "RotationMode" parameter
|
||||
// reset "RotationMode" parameter
|
||||
hGrp->RemoveInt("RotationMode");
|
||||
//reset "ShowNaviCube" parameter
|
||||
// reset "ShowNaviCube" parameter
|
||||
hGrp->RemoveBool("ShowNaviCube");
|
||||
//reset "ShowRotationCenter" parameter
|
||||
// reset "ShowRotationCenter" parameter
|
||||
hGrp->RemoveBool("ShowRotationCenter");
|
||||
//reset "UseNavigationAnimations" parameter
|
||||
// reset "UseNavigationAnimations" parameter
|
||||
hGrp->RemoveBool("UseNavigationAnimations");
|
||||
//reset "NewDocumentCameraOrientation" parameter
|
||||
// reset "NewDocumentCameraOrientation" parameter
|
||||
hGrp->RemoveASCII("NewDocumentCameraOrientation");
|
||||
|
||||
hGrp = hGrp->GetGroup("Custom");
|
||||
//reset "Q0" parameter
|
||||
// reset "Q0" parameter
|
||||
hGrp->RemoveFloat("Q0");
|
||||
//reset "Q1" parameter
|
||||
// reset "Q1" parameter
|
||||
hGrp->RemoveFloat("Q1");
|
||||
//reset "Q2" parameter
|
||||
// reset "Q2" parameter
|
||||
hGrp->RemoveFloat("Q2");
|
||||
//reset "Q3" parameter
|
||||
// reset "Q3" parameter
|
||||
hGrp->RemoveFloat("Q3");
|
||||
|
||||
//finally reset all the parameters associated to Gui::Pref* widgets
|
||||
// finally reset all the parameters associated to Gui::Pref* widgets
|
||||
PreferencePage::resetSettingsToDefaults();
|
||||
}
|
||||
|
||||
@@ -286,23 +296,30 @@ void DlgSettingsNavigation::onMouseButtonClicked()
|
||||
Ui_MouseButtons uimb;
|
||||
uimb.setupUi(&dlg);
|
||||
|
||||
QVariant data =
|
||||
ui->comboNavigationStyle->itemData(ui->comboNavigationStyle->currentIndex(), Qt::UserRole);
|
||||
QVariant data
|
||||
= ui->comboNavigationStyle->itemData(ui->comboNavigationStyle->currentIndex(), Qt::UserRole);
|
||||
void* instance = Base::Type::createInstanceByName((const char*)data.toByteArray());
|
||||
std::unique_ptr<UserNavigationStyle> ns(static_cast<UserNavigationStyle*>(instance));
|
||||
uimb.groupBox->setTitle(uimb.groupBox->title() + QStringLiteral(" ")
|
||||
+ ui->comboNavigationStyle->currentText());
|
||||
uimb.groupBox->setTitle(
|
||||
uimb.groupBox->title() + QStringLiteral(" ") + ui->comboNavigationStyle->currentText()
|
||||
);
|
||||
QString descr;
|
||||
descr = qApp->translate((const char*)data.toByteArray(),ns->mouseButtons(NavigationStyle::SELECTION));
|
||||
descr = qApp->translate(
|
||||
(const char*)data.toByteArray(),
|
||||
ns->mouseButtons(NavigationStyle::SELECTION)
|
||||
);
|
||||
descr.replace(QLatin1String("\n"), QLatin1String("<p>"));
|
||||
uimb.selectionLabel->setText(QStringLiteral("<b>%1</b>").arg(descr));
|
||||
descr = qApp->translate((const char*)data.toByteArray(),ns->mouseButtons(NavigationStyle::PANNING));
|
||||
descr = qApp->translate((const char*)data.toByteArray(), ns->mouseButtons(NavigationStyle::PANNING));
|
||||
descr.replace(QLatin1String("\n"), QLatin1String("<p>"));
|
||||
uimb.panningLabel->setText(QStringLiteral("<b>%1</b>").arg(descr));
|
||||
descr = qApp->translate((const char*)data.toByteArray(),ns->mouseButtons(NavigationStyle::DRAGGING));
|
||||
descr = qApp->translate(
|
||||
(const char*)data.toByteArray(),
|
||||
ns->mouseButtons(NavigationStyle::DRAGGING)
|
||||
);
|
||||
descr.replace(QLatin1String("\n"), QLatin1String("<p>"));
|
||||
uimb.rotationLabel->setText(QStringLiteral("<b>%1</b>").arg(descr));
|
||||
descr = qApp->translate((const char*)data.toByteArray(),ns->mouseButtons(NavigationStyle::ZOOMING));
|
||||
descr = qApp->translate((const char*)data.toByteArray(), ns->mouseButtons(NavigationStyle::ZOOMING));
|
||||
descr.replace(QLatin1String("\n"), QLatin1String("<p>"));
|
||||
uimb.zoomingLabel->setText(QStringLiteral("<b>%1</b>").arg(descr));
|
||||
dlg.exec();
|
||||
@@ -311,7 +328,7 @@ void DlgSettingsNavigation::onMouseButtonClicked()
|
||||
/**
|
||||
* Sets the strings of the subwidgets using the current language.
|
||||
*/
|
||||
void DlgSettingsNavigation::changeEvent(QEvent *e)
|
||||
void DlgSettingsNavigation::changeEvent(QEvent* e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
int navigation = ui->comboNavigationStyle->currentIndex();
|
||||
@@ -335,7 +352,7 @@ void DlgSettingsNavigation::retranslate()
|
||||
|
||||
// add submenu at the end to select navigation style
|
||||
std::map<Base::Type, std::string> styles = UserNavigationStyle::getUserFriendlyNames();
|
||||
for (const auto & style : styles) {
|
||||
for (const auto& style : styles) {
|
||||
QByteArray data(style.first.getName());
|
||||
QString name = QApplication::translate(style.first.getName(), style.second.c_str());
|
||||
|
||||
@@ -362,21 +379,21 @@ CameraDialog::CameraDialog(QWidget* parent)
|
||||
{
|
||||
this->setWindowTitle(tr("Camera Settings"));
|
||||
|
||||
QGridLayout *gridLayout;
|
||||
QGridLayout* gridLayout;
|
||||
gridLayout = new QGridLayout(this);
|
||||
|
||||
QGroupBox *groupBox;
|
||||
QGroupBox* groupBox;
|
||||
groupBox = new QGroupBox(this);
|
||||
groupBox->setTitle(tr("Orientation"));
|
||||
gridLayout->addWidget(groupBox, 0, 0, 1, 1);
|
||||
|
||||
QDialogButtonBox *buttonBox;
|
||||
QDialogButtonBox* buttonBox;
|
||||
buttonBox = new QDialogButtonBox(this);
|
||||
buttonBox->setOrientation(Qt::Horizontal);
|
||||
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
||||
buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
|
||||
gridLayout->addWidget(buttonBox, 3, 0, 1, 1);
|
||||
|
||||
QGridLayout *layout;
|
||||
QGridLayout* layout;
|
||||
layout = new QGridLayout(groupBox);
|
||||
|
||||
// Q0
|
||||
@@ -426,8 +443,7 @@ CameraDialog::CameraDialog(QWidget* parent)
|
||||
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
connect(currentViewButton, &QPushButton::clicked, this,
|
||||
&CameraDialog::onCurrentViewClicked);
|
||||
connect(currentViewButton, &QPushButton::clicked, this, &CameraDialog::onCurrentViewClicked);
|
||||
}
|
||||
|
||||
CameraDialog::~CameraDialog() = default;
|
||||
|
||||
@@ -30,8 +30,10 @@
|
||||
|
||||
class QDoubleSpinBox;
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
namespace Gui
|
||||
{
|
||||
namespace Dialog
|
||||
{
|
||||
class Ui_DlgSettingsNavigation;
|
||||
|
||||
/**
|
||||
@@ -39,7 +41,7 @@ class Ui_DlgSettingsNavigation;
|
||||
* for the Inventor viewer.
|
||||
* \author Werner Mayer
|
||||
*/
|
||||
class DlgSettingsNavigation : public PreferencePage
|
||||
class DlgSettingsNavigation: public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -56,7 +58,7 @@ private:
|
||||
void onNewDocViewChanged(int);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
void changeEvent(QEvent* e) override;
|
||||
void retranslate();
|
||||
void addOrientations();
|
||||
void translateOrientations();
|
||||
@@ -66,12 +68,12 @@ private:
|
||||
double q0, q1, q2, q3;
|
||||
};
|
||||
|
||||
class CameraDialog : public QDialog
|
||||
class CameraDialog: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CameraDialog(QWidget* parent=nullptr);
|
||||
explicit CameraDialog(QWidget* parent = nullptr);
|
||||
~CameraDialog() override;
|
||||
void setValues(double q0, double q1, double q2, double q3);
|
||||
void getValues(double& q0, double& q1, double& q2, double& q3) const;
|
||||
@@ -87,7 +89,7 @@ private:
|
||||
QDoubleSpinBox* sb3;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSNAVIGATION_H
|
||||
#endif // GUI_DIALOG_DLGSETTINGSNAVIGATION_H
|
||||
|
||||
@@ -35,13 +35,12 @@ using namespace Gui::Dialog;
|
||||
/* TRANSLATOR Gui::Dialog::DlgSettingsNotificationArea */
|
||||
|
||||
DlgSettingsNotificationArea::DlgSettingsNotificationArea(QWidget* parent)
|
||||
: PreferencePage(parent),
|
||||
ui(new Ui_DlgSettingsNotificationArea)
|
||||
: PreferencePage(parent)
|
||||
, ui(new Ui_DlgSettingsNotificationArea)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->NotificationAreaEnabled, &QGroupBox::toggled, [this](int on) {
|
||||
|
||||
bool enabled = on;
|
||||
|
||||
if (enabled) {
|
||||
@@ -56,8 +55,9 @@ void DlgSettingsNotificationArea::saveSettings()
|
||||
{
|
||||
// must be done as very first because we create a new instance of NavigatorStyle
|
||||
// where we set some attributes afterwards
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/NotificationArea");
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/NotificationArea"
|
||||
);
|
||||
|
||||
bool isNotificationAreaEnabled = ui->NotificationAreaEnabled->isChecked();
|
||||
hGrp->SetBool("NotificationAreaEnabled", isNotificationAreaEnabled);
|
||||
@@ -78,8 +78,9 @@ void DlgSettingsNotificationArea::saveSettings()
|
||||
|
||||
void DlgSettingsNotificationArea::loadSettings()
|
||||
{
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/NotificationArea");
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/NotificationArea"
|
||||
);
|
||||
|
||||
bool isNotificationAreaEnabled = hGrp->GetBool("NotificationAreaEnabled", true);
|
||||
ui->NotificationAreaEnabled->setChecked(isNotificationAreaEnabled);
|
||||
|
||||
@@ -27,15 +27,17 @@
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
namespace Gui
|
||||
{
|
||||
namespace Dialog
|
||||
{
|
||||
class Ui_DlgSettingsNotificationArea;
|
||||
|
||||
/**
|
||||
* The DlgSettingsNotificationArea class implements a preference page to change settings
|
||||
* for the Notification Area.
|
||||
*/
|
||||
class DlgSettingsNotificationArea : public PreferencePage
|
||||
class DlgSettingsNotificationArea: public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -47,13 +49,13 @@ public:
|
||||
void loadSettings() override;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
void changeEvent(QEvent* e) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgSettingsNotificationArea> ui;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSNOTIFICATIONAREA_H
|
||||
#endif // GUI_DIALOG_DLGSETTINGSNOTIFICATIONAREA_H
|
||||
|
||||
@@ -1,27 +1,29 @@
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <Base/Console.h>
|
||||
|
||||
|
||||
#include "DlgSettingsPDF.h"
|
||||
#include "ui_DlgSettingsPDF.h"
|
||||
|
||||
|
||||
|
||||
|
||||
using namespace Gui::Dialog;
|
||||
|
||||
|
||||
/* TRANSLATOR Gui::Dialog::DlgSettingsPDF */
|
||||
|
||||
|
||||
DlgSettingsPDF::DlgSettingsPDF(QWidget* parent)
|
||||
: PreferencePage( parent )
|
||||
: PreferencePage(parent)
|
||||
, ui(new Ui_DlgSettingsPDF)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->warningLabel->setWordWrap(true);
|
||||
connect(ui->comboBox,
|
||||
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this,
|
||||
&DlgSettingsPDF::onComboBoxIndexChanged);
|
||||
connect(
|
||||
ui->comboBox,
|
||||
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this,
|
||||
&DlgSettingsPDF::onComboBoxIndexChanged
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
DlgSettingsPDF::~DlgSettingsPDF() = default;
|
||||
|
||||
void DlgSettingsPDF::saveSettings()
|
||||
@@ -33,9 +35,12 @@ void DlgSettingsPDF::loadSettings()
|
||||
{
|
||||
ui->comboBox->onRestore();
|
||||
int currentIndex = ui->comboBox->currentIndex();
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6,8,0)
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0)
|
||||
if (currentIndex == 3) {
|
||||
Base::Console().warning("When using another copy of FreeCAD you had set the PDF version to X4, but this build of FreeCAD does not support it. Using 1.4 instead.\n");
|
||||
Base::Console().warning(
|
||||
"When using another copy of FreeCAD you had set the PDF version to X4, but this build "
|
||||
"of FreeCAD does not support it. Using 1.4 instead.\n"
|
||||
);
|
||||
currentIndex = 0;
|
||||
ui->comboBox->setCurrentIndex(0);
|
||||
}
|
||||
@@ -59,7 +64,7 @@ QPagedPaintDevice::PdfVersion DlgSettingsPDF::evaluatePDFVersion()
|
||||
return QPagedPaintDevice::PdfVersion_A1b;
|
||||
case 2:
|
||||
return QPagedPaintDevice::PdfVersion_1_6;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6,8,0)
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||
case 3:
|
||||
return QPagedPaintDevice::PdfVersion_X4;
|
||||
#endif
|
||||
@@ -73,19 +78,27 @@ void DlgSettingsPDF::onComboBoxIndexChanged(int index)
|
||||
switch (index) {
|
||||
case 1:
|
||||
ui->warningLabel->setText(
|
||||
tr("This archival PDF format does not support transparency or layers. All content must be self-contained and static."));
|
||||
tr("This archival PDF format does not support transparency or layers. All content "
|
||||
"must be self-contained and static.")
|
||||
);
|
||||
break;
|
||||
case 2:
|
||||
ui->warningLabel->setText(
|
||||
tr("While this version supports more modern features, older PDF readers may not fully handle it."));
|
||||
tr("While this version supports more modern features, older PDF readers may not "
|
||||
"fully handle it.")
|
||||
);
|
||||
break;
|
||||
case 3:
|
||||
ui->warningLabel->setText(
|
||||
tr("This PDF format is intended for professional printing and requires all fonts to be embedded; some interactive features may not be supported."));
|
||||
tr("This PDF format is intended for professional printing and requires all fonts "
|
||||
"to be embedded; some interactive features may not be supported.")
|
||||
);
|
||||
break;
|
||||
default:
|
||||
ui->warningLabel->setText(
|
||||
tr("This PDF version has limited support for modern features like embedded multimedia and advanced transparency effects."));
|
||||
tr("This PDF version has limited support for modern features like embedded "
|
||||
"multimedia and advanced transparency effects.")
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -98,5 +111,5 @@ void DlgSettingsPDF::changeEvent(QEvent* e)
|
||||
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
|
||||
|
||||
#include "moc_DlgSettingsPDF.cpp"
|
||||
|
||||
@@ -1,42 +1,44 @@
|
||||
#ifndef GUI_DIALOG_DLGSETTINGSPDF_H
|
||||
#define GUI_DIALOG_DLGSETTINGSPDF_H
|
||||
|
||||
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <QPagedPaintDevice>
|
||||
#include <memory>
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
|
||||
namespace Gui
|
||||
{
|
||||
namespace Dialog
|
||||
{
|
||||
class Ui_DlgSettingsPDF;
|
||||
|
||||
|
||||
/**
|
||||
* The DlgSettingsPDF class implements a preference page to change settings
|
||||
* for the PDF Import-Export.
|
||||
*/
|
||||
* The DlgSettingsPDF class implements a preference page to change settings
|
||||
* for the PDF Import-Export.
|
||||
*/
|
||||
class GuiExport DlgSettingsPDF: public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
explicit DlgSettingsPDF(QWidget* parent = nullptr);
|
||||
~DlgSettingsPDF() override;
|
||||
|
||||
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
static QPagedPaintDevice::PdfVersion evaluatePDFVersion();
|
||||
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
|
||||
void changeEvent(QEvent* e) override;
|
||||
|
||||
private:
|
||||
void onComboBoxIndexChanged(int index);
|
||||
|
||||
std::unique_ptr<Ui_DlgSettingsPDF> ui;
|
||||
|
||||
// Q_DISABLE_COPY_MOVE(DlgSettingsPDF)
|
||||
|
||||
// Q_DISABLE_COPY_MOVE(DlgSettingsPDF)
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSPDF_H
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSPDF_H
|
||||
|
||||
@@ -30,8 +30,8 @@ using namespace Gui::Dialog;
|
||||
/* TRANSLATOR Gui::Dialog::DlgSettingsPythonConsole */
|
||||
|
||||
DlgSettingsPythonConsole::DlgSettingsPythonConsole(QWidget* parent)
|
||||
: PreferencePage(parent)
|
||||
, ui(new Ui_DlgSettingsPythonConsole)
|
||||
: PreferencePage(parent)
|
||||
, ui(new Ui_DlgSettingsPythonConsole)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
@@ -27,8 +27,10 @@
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
namespace Gui
|
||||
{
|
||||
namespace Dialog
|
||||
{
|
||||
class Ui_DlgSettingsPythonConsole;
|
||||
|
||||
/**
|
||||
@@ -36,7 +38,7 @@ class Ui_DlgSettingsPythonConsole;
|
||||
* for the Python console.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class DlgSettingsPythonConsole : public PreferencePage
|
||||
class DlgSettingsPythonConsole: public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -48,13 +50,13 @@ public:
|
||||
void loadSettings() override;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
void changeEvent(QEvent* e) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgSettingsPythonConsole> ui;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSPYTHONCONSOLE_H
|
||||
#endif // GUI_DIALOG_DLGSETTINGSPYTHONCONSOLE_H
|
||||
|
||||
@@ -36,9 +36,9 @@ using namespace Gui::Dialog;
|
||||
* The dialog will by default be modeless, unless you set 'modal' to
|
||||
* true to construct a modal dialog.
|
||||
*/
|
||||
DlgSettingsReportView::DlgSettingsReportView( QWidget* parent )
|
||||
: PreferencePage(parent)
|
||||
, ui(new Ui_DlgSettingsReportView)
|
||||
DlgSettingsReportView::DlgSettingsReportView(QWidget* parent)
|
||||
: PreferencePage(parent)
|
||||
, ui(new Ui_DlgSettingsReportView)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->colorText->setColor(qApp->palette().windowText().color());
|
||||
@@ -94,7 +94,7 @@ void DlgSettingsReportView::loadSettings()
|
||||
/**
|
||||
* Sets the strings of the subwidgets using the current language.
|
||||
*/
|
||||
void DlgSettingsReportView::changeEvent(QEvent *e)
|
||||
void DlgSettingsReportView::changeEvent(QEvent* e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
|
||||
@@ -27,33 +27,35 @@
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
namespace Gui
|
||||
{
|
||||
namespace Dialog
|
||||
{
|
||||
class Ui_DlgSettingsReportView;
|
||||
|
||||
/** The DlgSettingsReportView class implements the available settings for the
|
||||
* Report View to change.
|
||||
* \author Werner Mayer
|
||||
*/
|
||||
class DlgSettingsReportView : public PreferencePage
|
||||
class DlgSettingsReportView: public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgSettingsReportView( QWidget* parent = nullptr );
|
||||
explicit DlgSettingsReportView(QWidget* parent = nullptr);
|
||||
~DlgSettingsReportView() override;
|
||||
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
void changeEvent(QEvent* e) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgSettingsReportView> ui;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif //GUI_DIALOG_DLG_SETTINGS_REPORT_VIEW
|
||||
#endif // GUI_DIALOG_DLG_SETTINGS_REPORT_VIEW
|
||||
|
||||
@@ -68,7 +68,7 @@ void DlgSettingsSelection::loadSettings()
|
||||
ui->checkBoxSelectionCheckBoxes->onRestore();
|
||||
}
|
||||
|
||||
void DlgSettingsSelection::changeEvent(QEvent *e)
|
||||
void DlgSettingsSelection::changeEvent(QEvent* e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
|
||||
@@ -29,8 +29,10 @@
|
||||
|
||||
class QDoubleSpinBox;
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
namespace Gui
|
||||
{
|
||||
namespace Dialog
|
||||
{
|
||||
class Ui_DlgSettingsSelection;
|
||||
|
||||
/**
|
||||
@@ -38,7 +40,7 @@ class Ui_DlgSettingsSelection;
|
||||
* for the selection.
|
||||
* \author Werner Mayer
|
||||
*/
|
||||
class DlgSettingsSelection : public PreferencePage
|
||||
class DlgSettingsSelection: public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -50,13 +52,13 @@ public:
|
||||
void loadSettings() override;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
void changeEvent(QEvent* e) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgSettingsSelection> ui;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSSELECTION_H
|
||||
#endif // GUI_DIALOG_DLGSETTINGSSELECTION_H
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
# include <QPushButton>
|
||||
#include <QPushButton>
|
||||
|
||||
|
||||
#include <Gui/Application.h>
|
||||
@@ -48,9 +48,7 @@ DlgSettingsUI::DlgSettingsUI(QWidget* parent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->themeEditorButton, &QPushButton::clicked, [this]() {
|
||||
openThemeEditor();
|
||||
});
|
||||
connect(ui->themeEditorButton, &QPushButton::clicked, [this]() { openThemeEditor(); });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,14 +124,17 @@ void DlgSettingsUI::loadStyleSheet()
|
||||
populateStylesheets("OverlayActiveStyleSheet", "overlay", ui->OverlayStyleSheets, "Auto");
|
||||
}
|
||||
|
||||
void DlgSettingsUI::populateStylesheets(const char* key,
|
||||
const char* path,
|
||||
PrefComboBox* combo,
|
||||
const char* def,
|
||||
QStringList filter)
|
||||
void DlgSettingsUI::populateStylesheets(
|
||||
const char* key,
|
||||
const char* path,
|
||||
PrefComboBox* combo,
|
||||
const char* def,
|
||||
QStringList filter
|
||||
)
|
||||
{
|
||||
auto hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/MainWindow");
|
||||
"User parameter:BaseApp/Preferences/MainWindow"
|
||||
);
|
||||
// List all .qss/.css files
|
||||
QMap<QString, QString> cssFiles;
|
||||
QDir dir;
|
||||
@@ -194,7 +195,7 @@ void DlgSettingsUI::openThemeEditor()
|
||||
/**
|
||||
* Sets the strings of the subwidgets using the current language.
|
||||
*/
|
||||
void DlgSettingsUI::changeEvent(QEvent *e)
|
||||
void DlgSettingsUI::changeEvent(QEvent* e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
@@ -206,4 +207,3 @@ void DlgSettingsUI::changeEvent(QEvent *e)
|
||||
}
|
||||
|
||||
#include "moc_DlgSettingsUI.cpp"
|
||||
|
||||
|
||||
@@ -27,45 +27,50 @@
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Gui {
|
||||
namespace Gui
|
||||
{
|
||||
|
||||
class PrefComboBox;
|
||||
|
||||
namespace Dialog {
|
||||
namespace Dialog
|
||||
{
|
||||
class Ui_DlgSettingsUI;
|
||||
|
||||
/**
|
||||
* The DlgSettingsUI class implements a preference page to change theme settings.
|
||||
* @author Pierre-Louis Boyer
|
||||
*/
|
||||
class DlgSettingsUI : public PreferencePage
|
||||
class DlgSettingsUI: public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgSettingsUI(QWidget* parent = nullptr);
|
||||
~DlgSettingsUI() override;
|
||||
explicit DlgSettingsUI(QWidget* parent = nullptr);
|
||||
~DlgSettingsUI() override;
|
||||
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
|
||||
void loadStyleSheet();
|
||||
void loadStyleSheet();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
void changeEvent(QEvent* e) override;
|
||||
|
||||
void populateStylesheets(const char *key,
|
||||
const char *path,
|
||||
PrefComboBox *combo,
|
||||
const char *def,
|
||||
QStringList filter = QStringList());
|
||||
void populateStylesheets(
|
||||
const char* key,
|
||||
const char* path,
|
||||
PrefComboBox* combo,
|
||||
const char* def,
|
||||
QStringList filter = QStringList()
|
||||
);
|
||||
|
||||
void openThemeEditor();
|
||||
|
||||
void openThemeEditor();
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgSettingsUI> ui;
|
||||
std::unique_ptr<Ui_DlgSettingsUI> ui;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DlgSettingsUI_H
|
||||
#endif // GUI_DIALOG_DlgSettingsUI_H
|
||||
|
||||
@@ -27,8 +27,10 @@
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
namespace Gui
|
||||
{
|
||||
namespace Dialog
|
||||
{
|
||||
class Ui_DlgSettingsViewColor;
|
||||
|
||||
/**
|
||||
@@ -36,35 +38,35 @@ class Ui_DlgSettingsViewColor;
|
||||
* for the Inventor viewer like background and selection.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class DlgSettingsViewColor : public PreferencePage
|
||||
class DlgSettingsViewColor: public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgSettingsViewColor(QWidget* parent = nullptr);
|
||||
~DlgSettingsViewColor() override;
|
||||
explicit DlgSettingsViewColor(QWidget* parent = nullptr);
|
||||
~DlgSettingsViewColor() override;
|
||||
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
void changeEvent(QEvent* e) override;
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onSwitchGradientColorsPressed();
|
||||
void onRadioButtonSimpleToggled(bool val);
|
||||
void onRadioButtonGradientToggled(bool val);
|
||||
void onRadioButtonRadialGradientToggled(bool val);
|
||||
void onCheckMidColorToggled(bool val);
|
||||
void onSwitchGradientColorsPressed();
|
||||
void onRadioButtonSimpleToggled(bool val);
|
||||
void onRadioButtonGradientToggled(bool val);
|
||||
void onRadioButtonRadialGradientToggled(bool val);
|
||||
void onCheckMidColorToggled(bool val);
|
||||
|
||||
private:
|
||||
void setGradientColorVisibility(bool val);
|
||||
void setGradientColorVisibility(bool val);
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgSettingsViewColor> ui;
|
||||
std::unique_ptr<Ui_DlgSettingsViewColor> ui;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSVIEWCOLOR_H
|
||||
#endif // GUI_DIALOG_DLGSETTINGSVIEWCOLOR_H
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
/****************************************************************************
|
||||
/****************************************************************************
|
||||
* Copyright (c) 2020 Chris Hennes (chennes@pioneerlibrarysystem.org) *
|
||||
* Copyright (c) 2023 FreeCAD Project Association *
|
||||
* *
|
||||
@@ -39,13 +39,21 @@
|
||||
|
||||
using namespace Gui::Dialog;
|
||||
|
||||
namespace Gui::Dialog {
|
||||
class wbListItem : public QWidget
|
||||
namespace Gui::Dialog
|
||||
{
|
||||
class wbListItem: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit wbListItem(const QString& wbName, bool enabled, bool startupWb, bool autoLoad, int index, QWidget* parent = nullptr);
|
||||
explicit wbListItem(
|
||||
const QString& wbName,
|
||||
bool enabled,
|
||||
bool startupWb,
|
||||
bool autoLoad,
|
||||
int index,
|
||||
QWidget* parent = nullptr
|
||||
);
|
||||
~wbListItem() override;
|
||||
|
||||
bool isEnabled();
|
||||
@@ -70,9 +78,17 @@ private:
|
||||
QLabel* loadLabel;
|
||||
QPushButton* loadButton;
|
||||
};
|
||||
}
|
||||
} // namespace Gui::Dialog
|
||||
|
||||
wbListItem::wbListItem(const QString& wbName, bool enabled, bool startupWb, bool autoLoad, int index, QWidget* parent) : QWidget(parent)
|
||||
wbListItem::wbListItem(
|
||||
const QString& wbName,
|
||||
bool enabled,
|
||||
bool startupWb,
|
||||
bool autoLoad,
|
||||
int index,
|
||||
QWidget* parent
|
||||
)
|
||||
: QWidget(parent)
|
||||
{
|
||||
this->setObjectName(wbName);
|
||||
|
||||
@@ -81,7 +97,9 @@ wbListItem::wbListItem(const QString& wbName, bool enabled, bool startupWb, bool
|
||||
|
||||
// 1: Enable checkbox
|
||||
enableCheckBox = new QCheckBox(this);
|
||||
enableCheckBox->setToolTip(tr("Toggles the visibility of %1 in the available workbenches").arg(wbDisplayName));
|
||||
enableCheckBox->setToolTip(
|
||||
tr("Toggles the visibility of %1 in the available workbenches").arg(wbDisplayName)
|
||||
);
|
||||
enableCheckBox->setChecked(enabled);
|
||||
if (startupWb) {
|
||||
enableCheckBox->setChecked(true);
|
||||
@@ -94,9 +112,13 @@ wbListItem::wbListItem(const QString& wbName, bool enabled, bool startupWb, bool
|
||||
// 2: Workbench Icon
|
||||
auto wbIcon = Application::Instance->workbenchIcon(wbName);
|
||||
iconLabel = new QLabel(wbDisplayName, this);
|
||||
iconLabel->setPixmap(wbIcon.scaled(QSize(20, 20), Qt::AspectRatioMode::KeepAspectRatio, Qt::TransformationMode::SmoothTransformation));
|
||||
iconLabel->setPixmap(wbIcon.scaled(
|
||||
QSize(20, 20),
|
||||
Qt::AspectRatioMode::KeepAspectRatio,
|
||||
Qt::TransformationMode::SmoothTransformation
|
||||
));
|
||||
iconLabel->setToolTip(wbTooltip);
|
||||
iconLabel->setContentsMargins(5, 0, 0, 5); // Left, top, right, bottom
|
||||
iconLabel->setContentsMargins(5, 0, 0, 5); // Left, top, right, bottom
|
||||
iconLabel->setEnabled(enableCheckBox->isChecked());
|
||||
|
||||
// 3: Workbench Display Name
|
||||
@@ -128,7 +150,7 @@ wbListItem::wbListItem(const QString& wbName, bool enabled, bool startupWb, bool
|
||||
autoloadCheckBox->setToolTip(tr("Loads %1 automatically when FreeCAD starts").arg(wbDisplayName));
|
||||
autoloadCheckBox->setEnabled(enableCheckBox->isChecked());
|
||||
|
||||
if (startupWb) { // Figure out whether to check and/or disable this checkBox:
|
||||
if (startupWb) { // Figure out whether to check and/or disable this checkBox:
|
||||
autoloadCheckBox->setChecked(true);
|
||||
autoloadCheckBox->setEnabled(false);
|
||||
autoloadCheckBox->setToolTip(tr("This is the current startup module, and must be autoloaded."));
|
||||
@@ -142,7 +164,10 @@ wbListItem::wbListItem(const QString& wbName, bool enabled, bool startupWb, bool
|
||||
loadLabel->setAlignment(Qt::AlignCenter);
|
||||
loadLabel->setEnabled(enableCheckBox->isChecked());
|
||||
loadButton = new QPushButton(tr("Load"), this);
|
||||
loadButton->setToolTip(tr("To preserve resources, FreeCAD does not load workbenches until they are used. Loading them may provide access to additional preferences related to their functionality."));
|
||||
loadButton->setToolTip(
|
||||
tr("To preserve resources, FreeCAD does not load workbenches until they are used. Loading "
|
||||
"them may provide access to additional preferences related to their functionality.")
|
||||
);
|
||||
loadButton->setEnabled(enableCheckBox->isChecked());
|
||||
connect(loadButton, &QPushButton::clicked, this, [this]() { onLoadClicked(); });
|
||||
if (WorkbenchManager::instance()->getWorkbench(wbName.toStdString())) {
|
||||
@@ -176,8 +201,9 @@ bool wbListItem::isAutoLoading()
|
||||
|
||||
void wbListItem::setStartupWb(bool val)
|
||||
{
|
||||
if(val)
|
||||
if (val) {
|
||||
autoloadCheckBox->setChecked(true);
|
||||
}
|
||||
|
||||
enableCheckBox->setEnabled(!val);
|
||||
autoloadCheckBox->setEnabled(!val && textLabel->isEnabled());
|
||||
@@ -220,8 +246,8 @@ void wbListItem::onWbToggled(bool checked)
|
||||
/**
|
||||
* Constructs a DlgSettingsWorkbenchesImp
|
||||
*/
|
||||
DlgSettingsWorkbenchesImp::DlgSettingsWorkbenchesImp( QWidget* parent )
|
||||
: PreferencePage( parent )
|
||||
DlgSettingsWorkbenchesImp::DlgSettingsWorkbenchesImp(QWidget* parent)
|
||||
: PreferencePage(parent)
|
||||
, ui(new Ui_DlgSettingsWorkbenches)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@@ -239,12 +265,25 @@ DlgSettingsWorkbenchesImp::DlgSettingsWorkbenchesImp( QWidget* parent )
|
||||
QMenu* contextMenu = new QMenu(ui->wbList);
|
||||
contextMenu->addAction(sortAction);
|
||||
ui->wbList->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(ui->wbList, &QListWidget::customContextMenuRequested, this, [this, contextMenu](const QPoint& pos) {
|
||||
contextMenu->exec(ui->wbList->mapToGlobal(pos));
|
||||
});
|
||||
connect(
|
||||
ui->wbList,
|
||||
&QListWidget::customContextMenuRequested,
|
||||
this,
|
||||
[this, contextMenu](const QPoint& pos) { contextMenu->exec(ui->wbList->mapToGlobal(pos)); }
|
||||
);
|
||||
|
||||
connect(ui->wbList->model(), &QAbstractItemModel::rowsMoved, this, &DlgSettingsWorkbenchesImp::wbItemMoved);
|
||||
connect(ui->AutoloadModuleCombo, qOverload<int>(&QComboBox::activated), this, &DlgSettingsWorkbenchesImp::onStartWbChanged);
|
||||
connect(
|
||||
ui->wbList->model(),
|
||||
&QAbstractItemModel::rowsMoved,
|
||||
this,
|
||||
&DlgSettingsWorkbenchesImp::wbItemMoved
|
||||
);
|
||||
connect(
|
||||
ui->AutoloadModuleCombo,
|
||||
qOverload<int>(&QComboBox::activated),
|
||||
this,
|
||||
&DlgSettingsWorkbenchesImp::onStartWbChanged
|
||||
);
|
||||
connect(ui->CheckBox_WbByTab, &QCheckBox::toggled, this, &DlgSettingsWorkbenchesImp::onWbByTabToggled);
|
||||
}
|
||||
|
||||
@@ -268,8 +307,9 @@ void DlgSettingsWorkbenchesImp::saveSettings()
|
||||
|
||||
for (int i = 0; i < ui->wbList->count(); i++) {
|
||||
wbListItem* wbItem = qobject_cast<wbListItem*>(ui->wbList->itemWidget(ui->wbList->item(i)));
|
||||
if (!wbItem)
|
||||
if (!wbItem) {
|
||||
continue;
|
||||
}
|
||||
std::string wbName = wbItem->objectName().toStdString();
|
||||
|
||||
if (wbItem->isEnabled()) {
|
||||
@@ -284,32 +324,40 @@ void DlgSettingsWorkbenchesImp::saveSettings()
|
||||
}
|
||||
}
|
||||
|
||||
if (orderedStr.str().empty()) //make sure that we have at least one enabled workbench. This should not be necessary because startup wb cannot be disabled.
|
||||
if (orderedStr.str().empty()) { // make sure that we have at least one enabled workbench. This
|
||||
// should not be necessary because startup wb cannot be disabled.
|
||||
orderedStr << "NoneWorkbench";
|
||||
}
|
||||
else {
|
||||
if (!disabledStr.str().empty())
|
||||
if (!disabledStr.str().empty()) {
|
||||
disabledStr << ",";
|
||||
}
|
||||
disabledStr << "NoneWorkbench";
|
||||
}
|
||||
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Workbenches");
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Workbenches"
|
||||
);
|
||||
hGrp->SetASCII("Ordered", orderedStr.str().c_str());
|
||||
hGrp->SetASCII("Disabled", disabledStr.str().c_str());
|
||||
|
||||
//Update the list of workbenches in the WorkbenchGroup and in the WorkbenchComboBox & workbench QMenu
|
||||
// Update the list of workbenches in the WorkbenchGroup and in the WorkbenchComboBox & workbench
|
||||
// QMenu
|
||||
Application::Instance->signalRefreshWorkbenches();
|
||||
|
||||
App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")->
|
||||
SetASCII("BackgroundAutoloadModules", autoloadStr.str().c_str());
|
||||
App::GetApplication()
|
||||
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")
|
||||
->SetASCII("BackgroundAutoloadModules", autoloadStr.str().c_str());
|
||||
|
||||
saveWorkbenchSelector();
|
||||
|
||||
int index = ui->AutoloadModuleCombo->currentIndex();
|
||||
QVariant data = ui->AutoloadModuleCombo->itemData(index);
|
||||
QString startWbName = data.toString();
|
||||
App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")->
|
||||
SetASCII("AutoloadModule", startWbName.toLatin1());
|
||||
App::GetApplication()
|
||||
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")
|
||||
->SetASCII("AutoloadModule", startWbName.toLatin1());
|
||||
|
||||
ui->CheckBox_WbByTab->onSave();
|
||||
}
|
||||
@@ -321,23 +369,26 @@ void DlgSettingsWorkbenchesImp::loadSettings()
|
||||
// There are two different "autoload" settings: the first, in FreeCAD since 2004,
|
||||
// controls the module the user sees first when starting FreeCAD, and defaults to the Start workbench
|
||||
std::string start = App::Application::Config()["StartWorkbench"];
|
||||
_startupModule = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")->
|
||||
GetASCII("AutoloadModule", start.c_str());
|
||||
_startupModule = App::GetApplication()
|
||||
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")
|
||||
->GetASCII("AutoloadModule", start.c_str());
|
||||
|
||||
// The second autoload setting does a background autoload of any number of other modules
|
||||
std::string autoloadCSV = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")->
|
||||
GetASCII("BackgroundAutoloadModules", "");
|
||||
std::string autoloadCSV = App::GetApplication()
|
||||
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")
|
||||
->GetASCII("BackgroundAutoloadModules", "");
|
||||
|
||||
// Tokenize the comma-separated list
|
||||
_backgroundAutoloadedModules.clear();
|
||||
std::stringstream stream(autoloadCSV);
|
||||
std::string workbench;
|
||||
while (std::getline(stream, workbench, ','))
|
||||
while (std::getline(stream, workbench, ',')) {
|
||||
_backgroundAutoloadedModules.push_back(workbench);
|
||||
}
|
||||
|
||||
buildWorkbenchList();
|
||||
|
||||
//We set the startup setting after building the list so that we can put only the enabled wb.
|
||||
// We set the startup setting after building the list so that we can put only the enabled wb.
|
||||
setStartWorkbenchComboItems();
|
||||
|
||||
{
|
||||
@@ -349,7 +400,9 @@ void DlgSettingsWorkbenchesImp::loadSettings()
|
||||
void DlgSettingsWorkbenchesImp::resetSettingsToDefaults()
|
||||
{
|
||||
ParameterGrp::handle hGrp;
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Workbenches");
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Workbenches"
|
||||
);
|
||||
hGrp->RemoveASCII("Ordered");
|
||||
hGrp->RemoveASCII("Disabled");
|
||||
hGrp->RemoveASCII("WorkbenchSelectorType");
|
||||
@@ -359,14 +412,16 @@ void DlgSettingsWorkbenchesImp::resetSettingsToDefaults()
|
||||
hGrp->RemoveASCII("BackgroundAutoloadModules");
|
||||
hGrp->RemoveASCII("AutoloadModule");
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/MainWindow");
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/MainWindow"
|
||||
);
|
||||
hGrp->RemoveASCII("WSPosition");
|
||||
|
||||
//finally reset all the parameters associated to Gui::Pref* widgets
|
||||
// finally reset all the parameters associated to Gui::Pref* widgets
|
||||
PreferencePage::resetSettingsToDefaults();
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
|
||||
if (ui->CheckBox_WbByTab->isChecked() != hGrp->GetBool("SaveWBbyTab", 0)) {
|
||||
if (ui->CheckBox_WbByTab->isChecked() != hGrp->GetBool("SaveWBbyTab", 0)) {
|
||||
requireRestart();
|
||||
}
|
||||
}
|
||||
@@ -383,11 +438,11 @@ void DlgSettingsWorkbenchesImp::buildWorkbenchList()
|
||||
QStringList enabledWbs = getEnabledWorkbenches();
|
||||
QStringList disabledWbs = getDisabledWorkbenches();
|
||||
|
||||
//First we add the enabled wbs in their saved order.
|
||||
// First we add the enabled wbs in their saved order.
|
||||
for (const auto& wbName : enabledWbs) {
|
||||
addWorkbench(wbName, true);
|
||||
}
|
||||
//Second we add workbenches that are disabled in alphabetical order.
|
||||
// Second we add workbenches that are disabled in alphabetical order.
|
||||
for (const auto& wbName : disabledWbs) {
|
||||
if (wbName.toStdString() != "NoneWorkbench") {
|
||||
addWorkbench(wbName, false);
|
||||
@@ -400,7 +455,8 @@ void DlgSettingsWorkbenchesImp::addWorkbench(const QString& wbName, bool enabled
|
||||
const bool isStartupWb = wbName.toStdString() == _startupModule;
|
||||
const bool autoLoad = std::ranges::find(_backgroundAutoloadedModules, wbName.toStdString())
|
||||
!= _backgroundAutoloadedModules.end();
|
||||
const auto widget = new wbListItem(wbName, enabled, isStartupWb, autoLoad, ui->wbList->count(), this);
|
||||
const auto widget
|
||||
= new wbListItem(wbName, enabled, isStartupWb, autoLoad, ui->wbList->count(), this);
|
||||
connect(widget, &wbListItem::wbToggled, this, &DlgSettingsWorkbenchesImp::wbToggled);
|
||||
const auto wItem = new QListWidgetItem();
|
||||
wItem->setSizeHint(widget->sizeHint());
|
||||
@@ -416,7 +472,9 @@ QStringList DlgSettingsWorkbenchesImp::getEnabledWorkbenches()
|
||||
QString wbs_ordered;
|
||||
ParameterGrp::handle hGrp;
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Workbenches");
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Workbenches"
|
||||
);
|
||||
wbs_ordered = QString::fromStdString(hGrp->GetASCII("Ordered", ""));
|
||||
|
||||
wbs_ordered_list = wbs_ordered.split(QLatin1String(","), Qt::SkipEmptyParts);
|
||||
@@ -424,20 +482,25 @@ QStringList DlgSettingsWorkbenchesImp::getEnabledWorkbenches()
|
||||
QStringList workbenches = Application::Instance->workbenches();
|
||||
workbenches.sort();
|
||||
|
||||
//First we add the wb that are ordered.
|
||||
for(auto& wbName : wbs_ordered_list) {
|
||||
if (workbenches.contains(wbName) && !disabled_wbs_list.contains(wbName)) { //Some wb may have been removed
|
||||
// First we add the wb that are ordered.
|
||||
for (auto& wbName : wbs_ordered_list) {
|
||||
if (workbenches.contains(wbName)
|
||||
&& !disabled_wbs_list.contains(wbName)) { // Some wb may have been removed
|
||||
enabled_wbs_list.append(wbName);
|
||||
}
|
||||
else {
|
||||
Base::Console().log("Ignoring unknown %s workbench found in user preferences.\n", wbName.toStdString().c_str());
|
||||
Base::Console().log(
|
||||
"Ignoring unknown %s workbench found in user preferences.\n",
|
||||
wbName.toStdString().c_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//Then we add the wbs that are not ordered and not disabled in alphabetical order
|
||||
for(auto& wbName : workbenches) {
|
||||
if (!enabled_wbs_list.contains(wbName) && !disabled_wbs_list.contains(wbName))
|
||||
// Then we add the wbs that are not ordered and not disabled in alphabetical order
|
||||
for (auto& wbName : workbenches) {
|
||||
if (!enabled_wbs_list.contains(wbName) && !disabled_wbs_list.contains(wbName)) {
|
||||
enabled_wbs_list.append(wbName);
|
||||
}
|
||||
}
|
||||
|
||||
return enabled_wbs_list;
|
||||
@@ -450,19 +513,27 @@ QStringList DlgSettingsWorkbenchesImp::getDisabledWorkbenches()
|
||||
QStringList disabled_wbs_list;
|
||||
ParameterGrp::handle hGrp;
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Workbenches");
|
||||
disabled_wbs = QString::fromStdString(hGrp->GetASCII("Disabled", "NoneWorkbench,TestWorkbench,InspectionWorkbench,RobotWorkbench,OpenSCADWorkbench"));
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Workbenches"
|
||||
);
|
||||
disabled_wbs = QString::fromStdString(hGrp->GetASCII(
|
||||
"Disabled",
|
||||
"NoneWorkbench,TestWorkbench,InspectionWorkbench,RobotWorkbench,OpenSCADWorkbench"
|
||||
));
|
||||
|
||||
unfiltered_disabled_wbs_list = disabled_wbs.split(QLatin1String(","), Qt::SkipEmptyParts);
|
||||
|
||||
QStringList workbenches = Application::Instance->workbenches();
|
||||
|
||||
for (auto& wbName : unfiltered_disabled_wbs_list) {
|
||||
if (workbenches.contains(wbName)) { //Some wb may have been removed
|
||||
if (workbenches.contains(wbName)) { // Some wb may have been removed
|
||||
disabled_wbs_list.append(wbName);
|
||||
}
|
||||
else {
|
||||
Base::Console().log("Ignoring unknown %s workbench found in user preferences.\n", wbName.toStdString().c_str());
|
||||
Base::Console().log(
|
||||
"Ignoring unknown %s workbench found in user preferences.\n",
|
||||
wbName.toStdString().c_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,7 +545,7 @@ QStringList DlgSettingsWorkbenchesImp::getDisabledWorkbenches()
|
||||
/**
|
||||
* Sets the strings of the subwidgets using the current language.
|
||||
*/
|
||||
void DlgSettingsWorkbenchesImp::changeEvent(QEvent *e)
|
||||
void DlgSettingsWorkbenchesImp::changeEvent(QEvent* e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
@@ -487,9 +558,11 @@ void DlgSettingsWorkbenchesImp::changeEvent(QEvent *e)
|
||||
|
||||
void DlgSettingsWorkbenchesImp::saveWorkbenchSelector()
|
||||
{
|
||||
//save workbench selector type
|
||||
// save workbench selector type
|
||||
ParameterGrp::handle hGrp;
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Workbenches");
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Workbenches"
|
||||
);
|
||||
int prevIndex = hGrp->GetInt("WorkbenchSelectorType", 0);
|
||||
int index = ui->WorkbenchSelectorType->currentIndex();
|
||||
if (prevIndex != index) {
|
||||
@@ -508,9 +581,11 @@ void DlgSettingsWorkbenchesImp::saveWorkbenchSelector()
|
||||
|
||||
void DlgSettingsWorkbenchesImp::loadWorkbenchSelector()
|
||||
{
|
||||
//workbench selector type setup
|
||||
// workbench selector type setup
|
||||
ParameterGrp::handle hGrp;
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Workbenches");
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Workbenches"
|
||||
);
|
||||
int widgetTypeIndex = hGrp->GetInt("WorkbenchSelectorType", 0);
|
||||
ui->WorkbenchSelectorType->clear();
|
||||
ui->WorkbenchSelectorType->addItem(tr("ComboBox"));
|
||||
@@ -540,7 +615,7 @@ void DlgSettingsWorkbenchesImp::wbToggled(const QString& wbName, bool enabled)
|
||||
{
|
||||
setStartWorkbenchComboItems();
|
||||
|
||||
//reorder the list of items.
|
||||
// reorder the list of items.
|
||||
int wbIndex = 0;
|
||||
for (int i = 0; i < ui->wbList->count(); i++) {
|
||||
wbListItem* wbItem = qobject_cast<wbListItem*>(ui->wbList->itemWidget(ui->wbList->item(i)));
|
||||
@@ -553,15 +628,16 @@ void DlgSettingsWorkbenchesImp::wbToggled(const QString& wbName, bool enabled)
|
||||
|
||||
for (int i = 0; i < ui->wbList->count(); i++) {
|
||||
wbListItem* wbItem = qobject_cast<wbListItem*>(ui->wbList->itemWidget(ui->wbList->item(i)));
|
||||
if (wbItem && !wbItem->isEnabled() && (enabled || ((wbItem->objectName()).toStdString() > wbName.toStdString()))) {
|
||||
//If the wb was enabled, then it was in the disabled wbs. So it moves to the row of the currently first disabled wb
|
||||
//If the wb was disabled. Then it goes to the disabled wb where it belongs alphabetically.
|
||||
if (wbItem && !wbItem->isEnabled()
|
||||
&& (enabled || ((wbItem->objectName()).toStdString() > wbName.toStdString()))) {
|
||||
// If the wb was enabled, then it was in the disabled wbs. So it moves to the row of the
|
||||
// currently first disabled wb If the wb was disabled. Then it goes to the disabled wb
|
||||
// where it belongs alphabetically.
|
||||
destinationIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ui->wbList->model()->moveRow(QModelIndex(), wbIndex, QModelIndex(), destinationIndex);
|
||||
|
||||
}
|
||||
|
||||
void DlgSettingsWorkbenchesImp::setStartWorkbenchComboItems()
|
||||
@@ -583,7 +659,7 @@ void DlgSettingsWorkbenchesImp::setStartWorkbenchComboItems()
|
||||
menuText[text] = it;
|
||||
}
|
||||
|
||||
{ // add special workbench to selection
|
||||
{ // add special workbench to selection
|
||||
QPixmap px = Application::Instance->workbenchIcon(QStringLiteral("NoneWorkbench"));
|
||||
QString key = QStringLiteral("<last>");
|
||||
QString value = QStringLiteral("$LastModule");
|
||||
@@ -605,7 +681,9 @@ void DlgSettingsWorkbenchesImp::setStartWorkbenchComboItems()
|
||||
}
|
||||
}
|
||||
|
||||
ui->AutoloadModuleCombo->setCurrentIndex(ui->AutoloadModuleCombo->findData(QString::fromStdString(_startupModule)));
|
||||
ui->AutoloadModuleCombo->setCurrentIndex(
|
||||
ui->AutoloadModuleCombo->findData(QString::fromStdString(_startupModule))
|
||||
);
|
||||
}
|
||||
|
||||
void DlgSettingsWorkbenchesImp::wbItemMoved()
|
||||
@@ -620,12 +698,12 @@ void DlgSettingsWorkbenchesImp::wbItemMoved()
|
||||
|
||||
void DlgSettingsWorkbenchesImp::onStartWbChanged(int index)
|
||||
{
|
||||
//Update _startupModule
|
||||
// Update _startupModule
|
||||
QVariant data = ui->AutoloadModuleCombo->itemData(index);
|
||||
QString wbName = data.toString();
|
||||
_startupModule = wbName.toStdString();
|
||||
|
||||
//Change wb that user can't deactivate.
|
||||
// Change wb that user can't deactivate.
|
||||
for (int i = 0; i < ui->wbList->count(); i++) {
|
||||
wbListItem* wbItem = qobject_cast<wbListItem*>(ui->wbList->itemWidget(ui->wbList->item(i)));
|
||||
if (wbItem) {
|
||||
@@ -644,7 +722,9 @@ void DlgSettingsWorkbenchesImp::sortEnabledWorkbenches()
|
||||
{
|
||||
ParameterGrp::handle hGrp;
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Workbenches");
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Workbenches"
|
||||
);
|
||||
hGrp->SetASCII("Ordered", "");
|
||||
|
||||
buildWorkbenchList();
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
/****************************************************************************
|
||||
* Copyright (c) 2020 Chris Hennes (chennes@pioneerlibrarysystem.org) *
|
||||
* Copyright (c) 2023 FreeCAD Project Association *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD 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 *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
* Copyright (c) 2020 Chris Hennes (chennes@pioneerlibrarysystem.org) *
|
||||
* Copyright (c) 2023 FreeCAD Project Association *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD 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 *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef GUI_DIALOG_DLGSETTINGSWORKBENCHES_IMP_H
|
||||
@@ -29,8 +29,10 @@
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Gui{
|
||||
namespace Dialog {
|
||||
namespace Gui
|
||||
{
|
||||
namespace Dialog
|
||||
{
|
||||
class Ui_DlgSettingsWorkbenches;
|
||||
|
||||
/**
|
||||
@@ -38,12 +40,12 @@ class Ui_DlgSettingsWorkbenches;
|
||||
* the remaining preference pages aren't loaded yet, and to help the user do so on demand.
|
||||
* \author Jürgen Riegel
|
||||
*/
|
||||
class DlgSettingsWorkbenchesImp : public PreferencePage
|
||||
class DlgSettingsWorkbenchesImp: public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgSettingsWorkbenchesImp( QWidget* parent = nullptr );
|
||||
explicit DlgSettingsWorkbenchesImp(QWidget* parent = nullptr);
|
||||
~DlgSettingsWorkbenchesImp() override;
|
||||
|
||||
void saveSettings() override;
|
||||
@@ -61,7 +63,7 @@ protected Q_SLOTS:
|
||||
|
||||
protected:
|
||||
void buildWorkbenchList();
|
||||
void changeEvent(QEvent *e) override;
|
||||
void changeEvent(QEvent* e) override;
|
||||
|
||||
private:
|
||||
void addWorkbench(const QString& it, bool enabled);
|
||||
@@ -80,7 +82,7 @@ private:
|
||||
std::unique_ptr<Ui_DlgSettingsWorkbenches> ui;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSWORKBENCHES_IMP_H
|
||||
#endif // GUI_DIALOG_DLGSETTINGSWORKBENCHES_IMP_H
|
||||
|
||||
@@ -1,44 +1,43 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
/****************************************************************************
|
||||
* Copyright (c) 2023 Boyer Pierre-louis <pierrelouis.boyer@gmail.com> *
|
||||
* Copyright (c) 2023 FreeCAD Project Association *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD 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 *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
/****************************************************************************
|
||||
* Copyright (c) 2023 Boyer Pierre-louis <pierrelouis.boyer@gmail.com> *
|
||||
* Copyright (c) 2023 FreeCAD Project Association *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD 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 *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
# include <QDragMoveEvent>
|
||||
#include <QDragMoveEvent>
|
||||
|
||||
|
||||
#include "ListWidgetDragBugFix.h"
|
||||
|
||||
|
||||
ListWidgetDragBugFix::ListWidgetDragBugFix(QWidget * parent)
|
||||
: QListWidget(parent)
|
||||
{
|
||||
}
|
||||
ListWidgetDragBugFix::ListWidgetDragBugFix(QWidget* parent)
|
||||
: QListWidget(parent)
|
||||
{}
|
||||
|
||||
ListWidgetDragBugFix::~ListWidgetDragBugFix() = default;
|
||||
|
||||
void ListWidgetDragBugFix::dragMoveEvent(QDragMoveEvent *event)
|
||||
void ListWidgetDragBugFix::dragMoveEvent(QDragMoveEvent* event)
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QPoint pos = event->pos();
|
||||
#else
|
||||
QPoint pos = event->position().toPoint();
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
/****************************************************************************
|
||||
* Copyright (c) 2023 Boyer Pierre-louis <pierrelouis.boyer@gmail.com> *
|
||||
* Copyright (c) 2023 FreeCAD Project Association *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD 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 *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
/****************************************************************************
|
||||
* Copyright (c) 2023 Boyer Pierre-louis <pierrelouis.boyer@gmail.com> *
|
||||
* Copyright (c) 2023 FreeCAD Project Association *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD 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 *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef QLISTWIDGETDRAGBUGFIX_HPP
|
||||
#define QLISTWIDGETDRAGBUGFIX_HPP
|
||||
@@ -28,24 +28,24 @@
|
||||
#include <QDragMoveEvent>
|
||||
#include <QListWidget>
|
||||
|
||||
/* Qt has a recent bug (2023, https://bugreports.qt.io/browse/QTBUG-100128)
|
||||
/* Qt has a recent bug (2023, https://bugreports.qt.io/browse/QTBUG-100128)
|
||||
* where the items disappears in certain conditions when drag and dropping.
|
||||
* Here we prevent the situation where this happens.
|
||||
* 1 - If the item is dropped on the item below such that the item doesn't move (ie superior half of the below item)
|
||||
* 2 - The item is the last one and user drop it on the empty space below.
|
||||
* In both those cases the item widget was lost.
|
||||
* When Qt solve this bug, this class should not be required anymore.
|
||||
*/
|
||||
class ListWidgetDragBugFix : public QListWidget
|
||||
* 1 - If the item is dropped on the item below such that the item doesn't move (ie superior half of
|
||||
* the below item) 2 - The item is the last one and user drop it on the empty space below. In both
|
||||
* those cases the item widget was lost. When Qt solve this bug, this class should not be required
|
||||
* anymore.
|
||||
*/
|
||||
class ListWidgetDragBugFix: public QListWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ListWidgetDragBugFix(QWidget *parent);
|
||||
explicit ListWidgetDragBugFix(QWidget* parent);
|
||||
~ListWidgetDragBugFix() override;
|
||||
|
||||
protected:
|
||||
void dragMoveEvent(QDragMoveEvent *e) override;
|
||||
void dragMoveEvent(QDragMoveEvent* e) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user