Mat: Clean-up code in DlgDisplayPropertiesImp
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <QDockWidget>
|
||||
#include <QSignalBlocker>
|
||||
#include <algorithm>
|
||||
#include <boost_signals2.hpp>
|
||||
@@ -50,17 +49,12 @@ namespace sp = std::placeholders;
|
||||
|
||||
/* TRANSLATOR Gui::Dialog::DlgDisplayPropertiesImp */
|
||||
|
||||
#if 0 // needed for Qt's lupdate utility
|
||||
qApp->translate("QDockWidget", "Display properties");
|
||||
#endif
|
||||
|
||||
class DlgDisplayPropertiesImp::Private
|
||||
{
|
||||
using DlgDisplayPropertiesImp_Connection = boost::signals2::connection;
|
||||
|
||||
public:
|
||||
Ui::DlgDisplayProperties ui;
|
||||
bool floating;
|
||||
DlgDisplayPropertiesImp_Connection connectChangedObject;
|
||||
|
||||
static void setElementColor(const std::vector<Gui::ViewProvider*>& views,
|
||||
@@ -141,14 +135,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructs a DlgDisplayPropertiesImp which is a child of 'parent', with the
|
||||
* name 'name' and widget flags set to 'f'
|
||||
*
|
||||
* The dialog will by default be modeless, unless you set 'modal' to
|
||||
* true to construct a modal dialog.
|
||||
*/
|
||||
DlgDisplayPropertiesImp::DlgDisplayPropertiesImp(bool floating, QWidget* parent, Qt::WindowFlags fl)
|
||||
DlgDisplayPropertiesImp::DlgDisplayPropertiesImp(QWidget* parent, Qt::WindowFlags fl)
|
||||
: QDialog(parent, fl)
|
||||
, d(new Private)
|
||||
{
|
||||
@@ -159,7 +146,6 @@ DlgDisplayPropertiesImp::DlgDisplayPropertiesImp(bool floating, QWidget* parent,
|
||||
d->ui.changePlot->hide();
|
||||
d->ui.buttonLineColor->setModal(false);
|
||||
d->ui.buttonPointColor->setModal(false);
|
||||
d->floating = floating;
|
||||
|
||||
// Create a filter to only include current format materials
|
||||
// that contain the basic render model.
|
||||
@@ -170,16 +156,6 @@ DlgDisplayPropertiesImp::DlgDisplayPropertiesImp(bool floating, QWidget* parent,
|
||||
setPropertiesFromSelection();
|
||||
}
|
||||
|
||||
// embed this dialog into a dockable widget container
|
||||
if (floating) {
|
||||
Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
|
||||
QDockWidget* dw =
|
||||
pDockMgr->addDockWindow("Display properties", this, Qt::AllDockWidgetAreas);
|
||||
dw->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
|
||||
dw->setFloating(true);
|
||||
dw->show();
|
||||
}
|
||||
|
||||
Gui::Selection().Attach(this);
|
||||
|
||||
// NOLINTBEGIN
|
||||
@@ -188,9 +164,6 @@ DlgDisplayPropertiesImp::DlgDisplayPropertiesImp(bool floating, QWidget* parent,
|
||||
// NOLINTEND
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the object and frees any allocated resources
|
||||
*/
|
||||
DlgDisplayPropertiesImp::~DlgDisplayPropertiesImp()
|
||||
{
|
||||
// no need to delete child widgets, Qt does it all for us
|
||||
@@ -340,16 +313,12 @@ void DlgDisplayPropertiesImp::slotChangedObject(const Gui::ViewProvider& obj,
|
||||
App::Color value = static_cast<const App::PropertyColor&>(prop).getValue();
|
||||
if (prop_name == "LineColor") {
|
||||
bool blocked = d->ui.buttonLineColor->blockSignals(true);
|
||||
d->ui.buttonLineColor->setColor(QColor((int)(255.0f * value.r),
|
||||
(int)(255.0f * value.g),
|
||||
(int)(255.0f * value.b)));
|
||||
d->ui.buttonLineColor->setColor(value.asValue<QColor>());
|
||||
d->ui.buttonLineColor->blockSignals(blocked);
|
||||
}
|
||||
else if (prop_name == "PointColor") {
|
||||
bool blocked = d->ui.buttonPointColor->blockSignals(true);
|
||||
d->ui.buttonPointColor->setColor(QColor((int)(255.0f * value.r),
|
||||
(int)(255.0f * value.g),
|
||||
(int)(255.0f * value.b)));
|
||||
d->ui.buttonPointColor->setColor(value.asValue<QColor>());
|
||||
d->ui.buttonPointColor->blockSignals(blocked);
|
||||
}
|
||||
}
|
||||
@@ -395,16 +364,8 @@ void DlgDisplayPropertiesImp::slotChangedObject(const Gui::ViewProvider& obj,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the dock window this object is embedded into without destroying itself.
|
||||
*/
|
||||
void DlgDisplayPropertiesImp::reject()
|
||||
{
|
||||
if (d->floating) {
|
||||
// closes the dock window
|
||||
Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
|
||||
pDockMgr->removeDockWindow(this);
|
||||
}
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
@@ -518,7 +479,8 @@ void DlgDisplayPropertiesImp::onButtonLineColorChanged()
|
||||
{
|
||||
std::vector<Gui::ViewProvider*> Provider = getSelection();
|
||||
QColor s = d->ui.buttonLineColor->color();
|
||||
App::Color c(s.red() / 255.0, s.green() / 255.0, s.blue() / 255.0);
|
||||
App::Color c {};
|
||||
c.setValue<QColor>(s);
|
||||
for (auto it : Provider) {
|
||||
if (auto* prop = dynamic_cast<App::PropertyColor*>(it->getPropertyByName("LineColor"))) {
|
||||
prop->setValue(c);
|
||||
@@ -530,7 +492,8 @@ void DlgDisplayPropertiesImp::onButtonPointColorChanged()
|
||||
{
|
||||
std::vector<Gui::ViewProvider*> Provider = getSelection();
|
||||
QColor s = d->ui.buttonPointColor->color();
|
||||
App::Color c(s.red() / 255.0, s.green() / 255.0, s.blue() / 255.0);
|
||||
App::Color c {};
|
||||
c.setValue<QColor>(s);
|
||||
for (auto it : Provider) {
|
||||
if (auto* prop = dynamic_cast<App::PropertyColor*>(it->getPropertyByName("PointColor"))) {
|
||||
prop->setValue(c);
|
||||
@@ -551,7 +514,8 @@ void DlgDisplayPropertiesImp::onSpinLineTransparencyValueChanged(int transparenc
|
||||
|
||||
void DlgDisplayPropertiesImp::setDisplayModes(const std::vector<Gui::ViewProvider*>& views)
|
||||
{
|
||||
QStringList commonModes, modes;
|
||||
QStringList commonModes;
|
||||
QStringList modes;
|
||||
for (auto it = views.begin(); it != views.end(); ++it) {
|
||||
if (auto* prop =
|
||||
dynamic_cast<App::PropertyEnumeration*>((*it)->getPropertyByName("DisplayMode"))) {
|
||||
@@ -693,7 +657,7 @@ void DlgDisplayPropertiesImp::onMaterialSelected(
|
||||
TaskDisplayProperties::TaskDisplayProperties()
|
||||
{
|
||||
this->setButtonPosition(TaskDisplayProperties::North);
|
||||
widget = new DlgDisplayPropertiesImp(false);
|
||||
widget = new DlgDisplayPropertiesImp();
|
||||
addTaskBox(widget);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,8 +56,7 @@ class DlgDisplayPropertiesImp: public QDialog, public Gui::SelectionSingleton::O
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgDisplayPropertiesImp(bool floating,
|
||||
QWidget* parent = nullptr,
|
||||
explicit DlgDisplayPropertiesImp(QWidget* parent = nullptr,
|
||||
Qt::WindowFlags fl = Qt::WindowFlags());
|
||||
~DlgDisplayPropertiesImp() override;
|
||||
/// Observer message from the Selection
|
||||
|
||||
Reference in New Issue
Block a user