Gui: refactor DlgSettingsColorGradientImp
This commit is contained in:
@@ -43,7 +43,8 @@ using namespace Gui::Dialog;
|
||||
* Constructs a DlgSettingsColorGradientImp as a child of 'parent', with the
|
||||
* name 'name' and widget flags set to 'f'.
|
||||
*/
|
||||
DlgSettingsColorGradientImp::DlgSettingsColorGradientImp( QWidget* parent, Qt::WindowFlags fl )
|
||||
DlgSettingsColorGradientImp::DlgSettingsColorGradientImp(const App::ColorGradient& cg,
|
||||
QWidget* parent, Qt::WindowFlags fl)
|
||||
: QDialog( parent, fl )
|
||||
, ui(new Ui_DlgSettingsColorGradient)
|
||||
{
|
||||
@@ -59,6 +60,10 @@ DlgSettingsColorGradientImp::DlgSettingsColorGradientImp( QWidget* parent, Qt::W
|
||||
// assure that the LineEdit is as wide to contain numbers with 4 digits and 6 decimals
|
||||
QFontMetrics fm(ui->floatLineEditMax->font());
|
||||
ui->floatLineEditMax->setMinimumWidth(QtTools::horizontalAdvance(fm, QString::fromLatin1("-8000.000000")));
|
||||
|
||||
setColorModelNames(cg.getColorModelNames());
|
||||
setProfile(cg.getProfile());
|
||||
setupConnections();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,6 +74,11 @@ DlgSettingsColorGradientImp::~DlgSettingsColorGradientImp()
|
||||
// no need to delete child widgets, Qt does it all for us
|
||||
}
|
||||
|
||||
void DlgSettingsColorGradientImp::setupConnections()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
App::ColorGradientProfile DlgSettingsColorGradientImp::getProfile() const
|
||||
{
|
||||
App::ColorGradientProfile profile;
|
||||
|
||||
@@ -44,7 +44,9 @@ class DlgSettingsColorGradientImp : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DlgSettingsColorGradientImp(QWidget* parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags());
|
||||
DlgSettingsColorGradientImp(const App::ColorGradient& cg,
|
||||
QWidget* parent = nullptr,
|
||||
Qt::WindowFlags fl = Qt::WindowFlags());
|
||||
~DlgSettingsColorGradientImp();
|
||||
|
||||
void accept();
|
||||
@@ -54,18 +56,18 @@ public:
|
||||
App::ColorGradientProfile getProfile() const;
|
||||
void setProfile(const App::ColorGradientProfile& pro);
|
||||
//@}
|
||||
/** @name Color model */
|
||||
//@{
|
||||
void setColorModelNames(const std::vector<std::string>&);
|
||||
//@}
|
||||
/** @name Parameter range and scale */
|
||||
//@{
|
||||
void setNumberOfDecimals(int);
|
||||
int numberOfDecimals() const;
|
||||
//@}
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
|
||||
/** @name Color model */
|
||||
//@{
|
||||
void setColorModelNames(const std::vector<std::string>&);
|
||||
void setColorModel(std::size_t tModel);
|
||||
std::size_t colorModel() const;
|
||||
//@}
|
||||
@@ -89,6 +91,9 @@ private:
|
||||
int numberOfLabels() const;
|
||||
//@}
|
||||
|
||||
Q_SIGNALS:
|
||||
void colorModelChanged();
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgSettingsColorGradient> ui;
|
||||
QDoubleValidator* validator;
|
||||
|
||||
@@ -297,15 +297,13 @@ bool SoFCColorGradient::isVisible (float fVal) const
|
||||
void SoFCColorGradient::customize(SoFCColorBarBase* parentNode)
|
||||
{
|
||||
QWidget* parent = Gui::getMainWindow()->activeWindow();
|
||||
Gui::Dialog::DlgSettingsColorGradientImp dlg(parent);
|
||||
dlg.setColorModelNames(_cColGrad.getColorModelNames());
|
||||
App::ColorGradientProfile profile = _cColGrad.getProfile();
|
||||
dlg.setProfile(profile);
|
||||
Gui::Dialog::DlgSettingsColorGradientImp dlg(_cColGrad, parent);
|
||||
//App::ColorGradientProfile profile = _cColGrad.getProfile();
|
||||
dlg.setNumberOfDecimals(_precision);
|
||||
|
||||
QPoint pos(QCursor::pos());
|
||||
pos += QPoint((int)(-1.1 * dlg.width()), (int)(-0.1 * dlg.height()));
|
||||
dlg.move( pos );
|
||||
pos += QPoint(int(-1.1 * dlg.width()), int(-0.1 * dlg.height()));
|
||||
dlg.move(pos);
|
||||
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
App::ColorGradientProfile profileMod = dlg.getProfile();
|
||||
|
||||
Reference in New Issue
Block a user