Example #1
0
void Properties::showProterties()
{
	if( 0 == _target )
		return;

	// text
	QGroupBox* groupBoxText = new QGroupBox( "Text" );

	QLineEdit*	text = new QLineEdit();
				text->setText( _target->getText() );

	QVBoxLayout*	vBoxLayout1 = new QVBoxLayout( groupBoxText );
				vBoxLayout1->addWidget( text );

	// color
	_groupBoxColor = new QGroupBox( "Color" );

	_textColorButton = new QToolButton();
	_textColorButton->setPalette( _target->getTextColor() );
	_textColor = _target->getTextColor();
	connect( _textColorButton, SIGNAL(released()), this, SLOT(changeTextColor()) );

	_lineColorButton = new QToolButton();
	_lineColorButton->setPalette( _target->getLineColor() );
	_lineColor = _target->getLineColor();
	connect( _lineColorButton, SIGNAL(released()), this, SLOT(changeLineColor()) );

	_fillColorButton = new QToolButton();
	_fillColorButton->setPalette( _target->getFillColor() );
	_fillColor = _target->getFillColor();
	connect( _fillColorButton, SIGNAL(released()), this, SLOT(changeFillColor()) );

	QGridLayout*	gridLayout = new QGridLayout( _groupBoxColor );
				gridLayout->addWidget( new QLabel("Text Color"), 0, 0 );
				gridLayout->addWidget( _textColorButton        , 0, 1 );

				gridLayout->addWidget( new QLabel("Line Color"), 1, 0 );
				gridLayout->addWidget( _lineColorButton        , 1, 1 );

				gridLayout->addWidget( new QLabel("Fill Color"), 2, 0 );
				gridLayout->addWidget( _fillColorButton        , 2, 1 );

	_colorDialog = new QColorDialog();
	_colorDialog->hide();
	connect( _colorDialog, SIGNAL(finished(int)),                      this, SLOT(colorDialogFinished(int))           );
	connect( _colorDialog, SIGNAL(currentColorChanged(const QColor&)), this, SLOT(currentColorChanged(const QColor&)) );
	
	// assemble
	QDialog dialog;

	QDialogButtonBox* dialogButtonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );

	QObject::connect( dialogButtonBox, SIGNAL(accepted()), &dialog, SLOT(accept()) );
	QObject::connect( dialogButtonBox, SIGNAL(rejected()), &dialog, SLOT(reject()) );

	QVBoxLayout*	vBoxLayout = new QVBoxLayout( &dialog  );
				vBoxLayout->addWidget( groupBoxText    );
				vBoxLayout->addWidget( _groupBoxColor  );
				vBoxLayout->addWidget( _colorDialog   );
				vBoxLayout->addWidget( dialogButtonBox );

	if( QDialog::Accepted == dialog.exec() )
	{
		_target->setText ( text->text() );
		_target->setTextColor( _textColor );
		_target->setLineColor( _lineColor );
		_target->setFillColor( _fillColor );
	}
}
Example #2
0
UnitsClassWidget::UnitsClassWidget(const QString& ClassName,
                                   const std::list<openfluid::fluidx::DatastoreItemDescriptor*>& DSList,
                                   QWidget* Parent):
  QFrame(Parent),ui(new Ui::UnitsClassWidget),
  m_Selected(false), m_ClassName(ClassName), mp_LayerSource(nullptr)
{
  setObjectName("UnitsClassFrame");

  ui->setupUi(this);

  setSelected(false);

  ui->UnitClassLabel->setText(ClassName);

  ui->UpButton->setIcon(QIcon(":/ui/common/icons/go-up.png"));
  ui->UpButton->setIconSize(QSize(16,16));

  ui->DownButton->setIcon(QIcon(":/ui/common/icons/go-down.png"));
  ui->DownButton->setIconSize(QSize(16,16));

  ui->RemoveButton->setIcon(QIcon(":/ui/common/icons/remove.png"));
  ui->RemoveButton->setIconSize(QSize(16,16));

  connect(ui->UpButton,SIGNAL(clicked()),this,SLOT(notifyUpClicked()));
  connect(ui->DownButton,SIGNAL(clicked()),this,SLOT(notifyDownClicked()));
  connect(ui->RemoveButton,SIGNAL(clicked()),this,SLOT(notifyRemoveClicked()));

  ui->StyleWidget->setVisible(false);
  ui->ShowHideStyleLabel->setText(tr("Show map style"));
  connect(ui->ShowHideStyleLabel,SIGNAL(clicked()),this,SLOT(toggleShowHideStyle()));

  linkToDatastoreItem(DSList);

  // initialize line width

  QVariant TmpLineWidth =
      openfluid::base::RunContextManager::instance()->getProjectConfigValue("builder.spatial.unitsclasses",
                                                                            m_ClassName+".linewidth");

  if (TmpLineWidth.type() == QVariant::String)
  {
    m_LineWidth = TmpLineWidth.toString().toInt();
  }
  else
  {
    m_LineWidth = 1;

    openfluid::base::RunContextManager::instance()->setProjectConfigValue("builder.spatial.unitsclasses",
                                                                   m_ClassName+".linewidth",m_LineWidth);
  }


  // initialize line color

  QVariant TmpLineColor =
      openfluid::base::RunContextManager::instance()->getProjectConfigValue("builder.spatial.unitsclasses",
                                                                            m_ClassName+".linecolor");
  if (TmpLineColor.type() == QVariant::String)
  {
    m_LineColor = TmpLineColor.toString();
  }
  else
  {
    m_LineColor = openfluid::ui::common::getRandomColor();
    openfluid::base::RunContextManager::instance()->setProjectConfigValue("builder.spatial.unitsclasses",
                                                                          m_ClassName+".linecolor",m_LineColor.name());
  }


  // initialize fill color

  QVariant TmpFillColor =
      openfluid::base::RunContextManager::instance()->getProjectConfigValue("builder.spatial.unitsclasses",
                                                                            m_ClassName+".fillcolor");
  if (TmpFillColor.type() == QVariant::String)
  {
    m_FillColor = TmpFillColor.toString();
  }
  else
  {
    m_FillColor = openfluid::ui::common::getRandomColor();
    openfluid::base::RunContextManager::instance()->setProjectConfigValue("builder.spatial.unitsclasses",
                                                                          m_ClassName+".fillcolor",m_FillColor.name());
  }


  ui->LineColorButton->setStyleSheet(QString(m_ColorButtonStyleSheet).arg(m_LineColor.name()));
  ui->FillColorButton->setStyleSheet(QString(m_ColorButtonStyleSheet).arg(m_FillColor.name()));
  ui->LineWidthSpinBox->setValue(m_LineWidth);

  // TODO re-enable line width settings
  ui->LineWidthLabel->setVisible(false);
  ui->LineWidthSpinBox->setVisible(false);

  connect(ui->VisibleCheckBox,SIGNAL(toggled(bool)),this,SLOT(changeVisible()));
  connect(ui->LineColorButton,SIGNAL(clicked()),this,SLOT(changeLineColor()));
  connect(ui->FillColorButton,SIGNAL(clicked()),this,SLOT(changeFillColor()));
  connect(ui->LineWidthSpinBox,SIGNAL(valueChanged(int)),this,SLOT(changeLineWidth(int)));

}