Example #1
0
QWidget* ComboDelegate::createEditor( QWidget* parent,
									 const QStyleOptionViewItem&,
									 const QModelIndex&) const {

	QComboBox* combo = new QComboBox(parent);
	combo->setSizeAdjustPolicy(QComboBox::AdjustToContents);
	combo->setMinimumHeight(ComboDelegate::MINIMUM_EDITOR_HEIGHT);
	return combo;
}
void QgsVectorLayerProperties::setRow( int row, int idx, const QgsField &field )
{
  tblAttributes->setItem( row, 0, new QTableWidgetItem( QString::number( idx ) ) );
  tblAttributes->setItem( row, 1, new QTableWidgetItem( field.name() ) );
  tblAttributes->setItem( row, 2, new QTableWidgetItem( field.typeName() ) );
  tblAttributes->setItem( row, 3, new QTableWidgetItem( QString::number( field.length() ) ) );
  tblAttributes->setItem( row, 4, new QTableWidgetItem( QString::number( field.precision() ) ) );
  tblAttributes->setItem( row, 5, new QTableWidgetItem( field.comment() ) );

  for ( int i = 0; i < 6; i++ )
    tblAttributes->item( row, i )->setFlags( tblAttributes->item( row, i )->flags() & ~Qt::ItemIsEditable );

  QComboBox *cb = new QComboBox();
  cb->addItem( tr( "line edit" ), QgsVectorLayer::LineEdit );
  cb->addItem( tr( "unique values" ), QgsVectorLayer::UniqueValues );
  cb->addItem( tr( "unique values (editable)" ), QgsVectorLayer::UniqueValuesEditable );
  cb->addItem( tr( "value map" ), QgsVectorLayer::ValueMap );
  cb->addItem( tr( "classification" ), QgsVectorLayer::Classification );
  cb->addItem( tr( "range (editable)" ), QgsVectorLayer::EditRange );
  cb->addItem( tr( "range (slider)" ), QgsVectorLayer::SliderRange );
  cb->addItem( tr( "file name" ), QgsVectorLayer::FileName );
  cb->setSizeAdjustPolicy( QComboBox::AdjustToContentsOnFirstShow );
  cb->setCurrentIndex( layer->editType( idx ) );

  tblAttributes->setCellWidget( row, 6, cb );

  if ( layer->editType( idx ) == QgsVectorLayer::ValueMap )
  {
    // TODO: create a gui for value maps
    QStringList mapList;
    QMap<QString, QVariant> &map = layer->valueMap( idx );
    for ( QMap<QString, QVariant>::iterator mit = map.begin(); mit != map.end(); mit++ )
    {
      QgsDebugMsg( QString( "idx:%1 key:%2 value:%3" ).arg( idx ).arg( mit.key() ).arg( mit.value().toString() ) );
      if ( mit.value().isNull() )
        mapList << mit.key();
      else
        mapList << QString( "%1=%2" ).arg( mit.key() ).arg( mit.value().toString() );
    }

    tblAttributes->setItem( row, 7, new QTableWidgetItem( mapList.join( ";" ) ) );
  }
  else if ( layer->editType( idx ) == QgsVectorLayer::EditRange ||
            layer->editType( idx ) == QgsVectorLayer::SliderRange )
  {
    tblAttributes->setItem(
      row, 7,
      new QTableWidgetItem( QString( "%1;%2;%3" )
                            .arg( layer->range( idx ).mMin.toString() )
                            .arg( layer->range( idx ).mMax.toString() )
                            .arg( layer->range( idx ).mStep.toString() )
                          )
    );
  }
}
Example #3
0
//-----------------------------------------------------------------------------
// Function: PortsDelegate::createSelectorWithVHDLStandardLibraries()
//-----------------------------------------------------------------------------
QWidget* PortsDelegate::createSelectorWithVHDLStandardLibraries(QWidget* parent) const
{
    QComboBox* combo = new QComboBox(parent);
    combo->setEditable(true);
    combo->setSizeAdjustPolicy(QComboBox::AdjustToContents);

    for (unsigned int i = 0;i < VhdlGeneral::VHDL_TYPEDEF_COUNT; ++i)
    {
        combo->addItem(VhdlGeneral::VHDL_TYPE_DEFINITIONS[i]);
    }

    return combo;
}
QWidget* MashStepItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &/*option*/, const QModelIndex &index) const
{
   if( index.column() == MASHSTEPTYPECOL )
   {
      QComboBox *box = new QComboBox(parent);

      box->addItem("Infusion");
      box->addItem("Temperature");
      box->addItem("Decoction");
      box->setSizeAdjustPolicy(QComboBox::AdjustToContents);

      return box;
   }
   else
      return new QLineEdit(parent);
}
Example #5
0
lcQFindDialog::lcQFindDialog(QWidget *parent, void *data) :
    QDialog(parent),
    ui(new Ui::lcQFindDialog)
{
	ui->setupUi(this);

	QComboBox *parts = ui->ID;
	parts->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
	parts->setMinimumContentsLength(1);

	lcPiecesLibrary* library = lcGetPiecesLibrary();
	for (int partIdx = 0; partIdx < library->mPieces.GetSize(); partIdx++)
		parts->addItem(library->mPieces[partIdx]->m_strDescription, qVariantFromValue((void*)library->mPieces[partIdx]));
	parts->model()->sort(0);

	options = (lcSearchOptions*)data;

	ui->findColor->setChecked(options->MatchColor);
	ui->color->setCurrentColor(options->ColorIndex);
	ui->findID->setChecked(options->MatchInfo);
	parts->setCurrentIndex(parts->findData(qVariantFromValue((void*)options->Info)));
	ui->findName->setChecked(options->MatchName);
	ui->name->setText(options->Name);
}
Example #6
0
void ItemHandlerCombobox::Handle (const QDomElement& item, QWidget *pwidget)
{
    QGridLayout *lay = qobject_cast<QGridLayout*> (pwidget->layout ());

    QHBoxLayout *hboxLay = new QHBoxLayout;
    QComboBox *box = new QComboBox (XSD_->GetWidget ());

    hboxLay->addWidget (box);

    XSD_->SetTooltip (box, item);
    box->setObjectName (item.attribute ("property"));
    box->setSizeAdjustPolicy (QComboBox::AdjustToContents);
    if (item.hasAttribute ("maxVisibleItems"))
        box->setMaxVisibleItems (item.attribute ("maxVisibleItems").toInt ());

    bool mayHaveDataSource = item.hasAttribute ("mayHaveDataSource") &&
                             item.attribute ("mayHaveDataSource").toLower () == "true";
    if (mayHaveDataSource)
    {
        const QString& prop = item.attribute ("property");
        Factory_->RegisterDatasourceSetter (prop,
                                            [this] (const QString& str, QAbstractItemModel *m, Util::XmlSettingsDialog *xsd)
        {
            SetDataSource (str, m, xsd);
        });
        Propname2Combobox_ [prop] = box;
        Propname2Item_ [prop] = item;
    }

    hboxLay->addStretch ();

    if (item.hasAttribute ("moreThisStuff"))
    {
        QPushButton *moreButt = new QPushButton (tr ("More stuff..."));
        hboxLay->addWidget (moreButt);

        moreButt->setObjectName (item.attribute ("moreThisStuff"));
        connect (moreButt,
                 SIGNAL (released ()),
                 XSD_,
                 SLOT (handleMoreThisStuffRequested ()));
    }

    QDomElement option = item.firstChildElement ("option");
    while (!option.isNull ())
    {
        const auto& images = XSD_->GetImages (option);
        const auto& name = option.attribute ("name");

        auto label = XSD_->GetLabel (option);
        if (label.isEmpty ())
            label = name;

        if (!images.isEmpty ())
            box->addItem (QPixmap::fromImage (images.at (0)), label, name);
        else
            box->addItem (label, name);

        auto setColor = [&option, box] (const QString& attr, Qt::ItemDataRole role) -> void
        {
            if (option.hasAttribute (attr))
            {
                const QColor color (option.attribute (attr));
                box->setItemData (box->count () - 1, color, role);
            }
        };
        setColor ("color", Qt::ForegroundRole);
        setColor ("bgcolor", Qt::BackgroundRole);

        option = option.nextSiblingElement ("option");
    }

    connect (box,
             SIGNAL (currentIndexChanged (int)),
             this,
             SLOT (updatePreferences ()));

    QDomElement scriptContainer = item.firstChildElement ("scripts");
    if (!scriptContainer.isNull ())
    {
        Scripter scripter (scriptContainer);

        for (const auto& elm : scripter.GetOptions ())
            box->addItem (scripter.HumanReadableOption (elm), elm);
    }

    int pos = box->findData (XSD_->GetValue (item));
    if (pos != -1)
        box->setCurrentIndex (pos);
    else if (!mayHaveDataSource)
        qWarning () << Q_FUNC_INFO
                    << box
                    << XSD_->GetValue (item)
                    << "not found (and this item may not have a datasource)";

    QLabel *label = new QLabel (XSD_->GetLabel (item));
    label->setWordWrap (false);

    box->setProperty ("ItemHandler", QVariant::fromValue<QObject*> (this));
    box->setProperty ("SearchTerms", label->text ());

    int row = lay->rowCount ();
    lay->addWidget (label, row, 0, Qt::AlignRight);
    lay->addLayout (hboxLay, row, 1);
}
Example #7
0
void PartyEditor::buildWidget()
{
	QGroupBox *partyGBE = new QGroupBox(tr("Équipe"), this);
	QGridLayout *partyGBL = new QGridLayout(partyGBE);
	partyGBL->addWidget(new QLabel(tr("Menus :")), 0, 0);
	partyGBL->addWidget(new QLabel(tr("À l'écran :")), 1, 0);
	QList<QIcon> icons;
	int i, j;
	for(j=0 ; j<11 ; ++j) {
		icons.append(QIcon(QString(":/images/icons/perso%1.png").arg(j)));
	}
	QComboBox *comboBox;

	for(i=0 ; i<3 ; ++i)
	{
		partyE.append(comboBox = new QComboBox(partyGBE));
		comboBox->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
		comboBox->addItem("-", 255);
		for(j=0 ; j<8 ; ++j) {
			comboBox->addItem(icons.at(j), Data::names().at(j), j);
		}
		partyGBL->addWidget(comboBox, 0, i+1);

		partySortE.append(comboBox = new QComboBox(partyGBE));
		comboBox->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
		comboBox->addItem("-", 255);
		for(j=0 ; j<11 ; ++j) {
			comboBox->addItem(icons.at(j), Data::names().at(j), j);
		}
		partyGBL->addWidget(comboBox, 1, i+1);
	}

	dreamE = new QCheckBox(tr("Seule l'équipe principale est visible (rêve avec Laguna)"), partyGBE);
	partyGBL->addWidget(dreamE, 2, 0, 1, 4, Qt::AlignLeft);

	QGroupBox *positionGBE = new QGroupBox(tr("Position"), this);

	QSpinBox *spinBox;
	QGridLayout *positionGBL = new QGridLayout(positionGBE);
	positionGBL->addWidget(new QLabel(tr("X :")), 0, 1);
	positionGBL->addWidget(new QLabel(tr("Y :")), 0, 2);
	positionGBL->addWidget(new QLabel(tr("Triangle ID :")), 0, 3);
	positionGBL->addWidget(new QLabel(tr("Direction :")), 0, 4);

	for(i=0 ; i<3 ; ++i) {
		positionGBL->addWidget(new QLabel(tr("Membre %1 :").arg(i+1)), i+1, 0);

		xE.append(spinBox = new QSpinBox(positionGBE));
		spinBox->setRange(-32768, 32767);
		positionGBL->addWidget(spinBox, i+1, 1);

		yE.append(spinBox = new QSpinBox(positionGBE));
		spinBox->setRange(-32768, 32767);
		positionGBL->addWidget(spinBox, i+1, 2);

		idE.append(spinBox = new SpinBox16(positionGBE));
		positionGBL->addWidget(spinBox, i+1, 3);

		dirE.append(spinBox = new SpinBox8(positionGBE));
		positionGBL->addWidget(spinBox, i+1, 4);
	}

	moduleE = new QComboBox(positionGBE);
	moduleE->addItem(tr("Terrain"), 0);
	moduleE->addItem(tr("Terrain"), 1);
	moduleE->addItem(tr("Mappemonde"), 2);
	moduleE->addItem(tr("Combat"), 3);

	mapE = new QComboBox(positionGBE);
	mapE->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
	QStringList mapList = Data::maplist();
	i=0;
	foreach(const QString &mapName, mapList) {
		mapE->addItem(mapName, i++);
	}
Example #8
0
EditorTools::EditorTools(EditorWorkspace * parent)
  :QGroupBox((QWidget *)parent)
{
  editor = parent;
  setTitle(tr("Tools"));
  QGridLayout * layout = new QGridLayout(this);
  this->setLayout(layout);
  QSize iconSize = QSize(22,22);
  QToolButton * pointer = new QToolButton(this);
  pointer->setIcon(QIcon(":images/cursor_arrow.png"));
  pointer->setToolTip(tr("Drag/Scale Image\n(Shift to activate)"));
  pointer->setIconSize(iconSize);
  pointer->setCheckable(true);
  pointer->setAutoExclusive(true);
  if(editor->editorView()->editorMode() == ImageEditorView::EditorDefaultMode){
    pointer->setChecked(true);
  }
  connect(pointer,SIGNAL(clicked(bool)),this,SLOT(onPointerClicked()));
  layout->addWidget(pointer,0,0);
  QToolButton * bullseye = new QToolButton(this);
  bullseye->setIcon(QIcon(":images/bullseye.png"));
  bullseye->setToolTip(tr("Set Image Center"));
  bullseye->setIconSize(iconSize);
  bullseye->setCheckable(true);
  bullseye->setAutoExclusive(true);
  connect(bullseye,SIGNAL(toggled(bool)),this,SLOT(onBullseyeToggled(bool)));
  layout->addWidget(bullseye,0,1);
  QToolButton * drop = new QToolButton(this);
  drop->setIcon(QIcon(":images/water_drop.png"));
  drop->setToolTip(tr("Blur Image"));
  drop->setIconSize(iconSize);
  drop->setCheckable(true);
  drop->setAutoExclusive(true);
  if(editor->editorView()->editorMode() == ImageEditorView::EditorBlurMode){
    drop->setChecked(true);
  }
  connect(drop,SIGNAL(clicked(bool)),this,SLOT(onDropClicked()));
  layout->addWidget(drop,0,2);
  QToolButton * mathEdit = new QToolButton(this);
  mathEdit->setIcon(QIcon(":images/formula_pi.png"));
  mathEdit->setToolTip(tr("Evaluate Expression"));
  mathEdit->setIconSize(iconSize);
  connect(mathEdit,SIGNAL(clicked(bool)),this,SLOT(onMathEdit()));
  layout->addWidget(mathEdit,0,3);


  QToolButton * editMask = new QToolButton(this);
  editMask->setIcon(QIcon(":images/mask_happy.png"));
  editMask->setToolTip(tr("Edit image mask"));
  editMask->setIconSize(iconSize);
  editMask->setCheckable(true);
  editMask->setAutoExclusive(true);
  connect(editMask,SIGNAL(clicked(bool)),this,SLOT(onEditMaskClicked()));
  layout->addWidget(editMask,0,4);

  /*  QToolButton * filter = new QToolButton(this);
  filter->setIcon(QIcon(":images/optical_filter.png"));
  filter->setToolTip(tr("Filter Image"));
  filter->setIconSize(iconSize);
  filter->setCheckable(true);
  filter->setAutoExclusive(true);
  connect(filter,SIGNAL(clicked(bool)),this,SLOT(onFilterClicked()));
  layout->addWidget(filter,0,4);*/

  QToolButton * selection = new QToolButton(this);
  selection->setIcon(QIcon(":images/selection.png"));
  selection->setToolTip(tr("Select image section"));
  selection->setIconSize(iconSize);
  selection->setCheckable(true);
  selection->setAutoExclusive(true);
  connect(selection,SIGNAL(clicked(bool)),this,SLOT(onSelectionClicked()));
  layout->addWidget(selection,0,5);

  QToolButton * lineout = new QToolButton(this);
  lineout->setIcon(QIcon(":images/lineout_plot.png"));
  lineout->setToolTip(tr("Plot linear profile"));
  lineout->setIconSize(iconSize);
  lineout->setCheckable(true);
  lineout->setAutoExclusive(true);
  connect(lineout,SIGNAL(clicked(bool)),this,SLOT(onLineoutClicked()));
  layout->addWidget(lineout,0,6);

  QToolButton * undo = new QToolButton(this);
  undo->setIcon(QIcon(":images/undo.png"));
  undo->setToolTip(tr("Undo last edit"));
  undo->setIconSize(iconSize);
  undo->setEnabled(false);
  connect(undo,SIGNAL(clicked(bool)),this,SLOT(onUndoClicked()));
  layout->addWidget(undo,1,0);

  QToolButton * redo = new QToolButton(this);
  redo->setIcon(QIcon(":images/redo.png"));
  redo->setToolTip(tr("Redo last undone edit"));
  redo->setIconSize(iconSize);
  redo->setEnabled(false);
  connect(redo,SIGNAL(clicked(bool)),this,SLOT(onRedoClicked()));
  layout->addWidget(redo,1,1);

  QToolButton * removeElectronics = new QToolButton(this);
  removeElectronics->setIcon(QIcon(":images/hardware.png"));
  removeElectronics->setToolTip(tr("Remove electronic noise"));
  removeElectronics->setIconSize(iconSize);
  removeElectronics->setCheckable(true);
  removeElectronics->setAutoExclusive(true);
  connect(removeElectronics,SIGNAL(clicked(bool)),this,SLOT(onRemoveElectronicsClicked()));
  layout->addWidget(removeElectronics,1,2);

  QToolButton * xcamMagic = new QToolButton(this);
  xcamMagic->setIcon(QIcon(":images/xcam.png"));
  xcamMagic->setToolTip(tr("Remove overscan and noise from xcam data"));
  xcamMagic->setIconSize(iconSize);
  connect(xcamMagic,SIGNAL(clicked(bool)),this,SLOT(onXcamMagicClicked()));
  layout->addWidget(xcamMagic,1,3);

  QToolButton * fillEmpty = new QToolButton(this);
  fillEmpty->setIcon(QIcon(":images/magic.png"));
  fillEmpty->setToolTip(tr("Fill data on the missing regions by interpolation"));
  fillEmpty->setIconSize(iconSize);
  fillEmpty->setCheckable(true);
  fillEmpty->setAutoExclusive(true);
  connect(fillEmpty,SIGNAL(clicked(bool)),this,SLOT(onFillEmptyClicked()));
  layout->addWidget(fillEmpty,1,4);

  QToolButton * crop = new QToolButton(this);
  crop->setIcon(QIcon(":images/crop.png"));
  crop->setToolTip(tr("Crop image to selection"));
  crop->setIconSize(iconSize);
  connect(crop,SIGNAL(clicked(bool)),this,SLOT(onCropClicked()));
  layout->addWidget(crop,1,5);

  //  connect(mathEdit,SIGNAL(clicked(bool)),this,SLOT(onMathEdit()));
  
  toolOptions = new QWidget(this);
  QVBoxLayout * vbox = new QVBoxLayout(toolOptions);
  toolOptions->setLayout(vbox);
  QFrame * separator = new QFrame(toolOptions);
  separator->setFrameStyle(QFrame::HLine|QFrame::Raised);
  separator->setLineWidth(1);


  vbox->addWidget(separator);
  toolOptionsLayout = new QStackedLayout();
  vbox->addLayout(toolOptionsLayout);
  toolOptionsLayout->addWidget(new QWidget(toolOptions));
  toolOptionsLayout->addWidget(new QWidget(toolOptions));

  dropToolOptions = new QWidget(toolOptions);
  QGridLayout * grid = new QGridLayout(dropToolOptions);
  dropToolOptions->setLayout(grid);
  grid->addWidget(new QLabel(tr("Brush Radius:"),dropToolOptions),0,0);
  QDoubleSpinBox * spinBox = new QDoubleSpinBox(dropToolOptions);
  connect(spinBox,SIGNAL(valueChanged(double)),editor->editorView(),SLOT(setDropBrushRadius(double)));
  spinBox->setMinimum(0);
  spinBox->setValue(editor->editorView()->getDropBrushRadius());
  grid->addWidget(spinBox,0,1);
  grid->addWidget(new QLabel(tr("Blur Radius:"),dropToolOptions),1,0);
  spinBox = new QDoubleSpinBox(dropToolOptions);
  spinBox->setMinimum(0);
  spinBox->setValue(editor->editorView()->getDropBlurRadius());
  connect(spinBox,SIGNAL(valueChanged(double)),editor->editorView(),SLOT(setDropBlurRadius(double)));
  grid->addWidget(spinBox,1,1);
  toolOptionsLayout->addWidget(dropToolOptions);

  
  editMaskToolOptions = new QWidget(toolOptions);
  grid = new QGridLayout(editMaskToolOptions);
  editMaskToolOptions->setLayout(grid);
  QLabel * label = new QLabel(tr("Mode:"),editMaskToolOptions);
  label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
  grid->addWidget(label,1,1);
  editMaskIncludeButton = new QToolButton(editMaskToolOptions);
  editMaskIncludeButton->setIcon(QIcon(":images/mask_happy.png"));
  editMaskIncludeButton->setToolTip("Include in mask");
  editMaskIncludeButton->setCheckable(true);
  editMaskIncludeButton->setChecked(true);
  editMaskIncludeButton->setAutoExclusive(true);
  grid->addWidget(editMaskIncludeButton,1,2);
  editMaskExcludeButton = new QToolButton(editMaskToolOptions);
  editMaskExcludeButton->setIcon(QIcon(":images/mask_sad.png"));
  editMaskExcludeButton->setToolTip("Exclude from mask");
  editMaskExcludeButton->setCheckable(true);
  editMaskExcludeButton->setAutoExclusive(true);
  grid->addWidget(editMaskExcludeButton,1,3);
  label = new QLabel(tr("Brush Radius:"),editMaskToolOptions);
  label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
  grid->addWidget(label,2,1);

  m_editMaskBrushRadius =  new QSpinBox(editMaskToolOptions);
  connect(m_editMaskBrushRadius,SIGNAL(valueChanged(int)),editor->editorView(),SLOT(updateEditMaskCursor(int)));
  m_editMaskBrushRadius->setValue(5);
  
  grid->addWidget(m_editMaskBrushRadius,2,2,1,2);

  QPushButton * loadMaskFromFile = new QPushButton("Load mask from file",
						   editMaskToolOptions);
  loadMaskFromFile->setToolTip("Load a mask from a black and white png file.\n"
			       "White is included in the mask and black excluded.");
  connect(loadMaskFromFile,SIGNAL(clicked()),this,SLOT(onLoadMaskFromFile()));
  grid->addWidget(loadMaskFromFile,3,1,1,3);

  QPushButton * invertMask = new QPushButton("Invert mask",
					     editMaskToolOptions);
  invertMask->setToolTip("Inverts the mask of the current image.");
  connect(invertMask,SIGNAL(clicked()),this,SLOT(onInvertMask()));
  grid->addWidget(invertMask,4,1,1,3);

  grid->setRowStretch(0,100);
  grid->setColumnStretch(0,100);
  grid->setRowStretch(5,100);
  grid->setColumnStretch(5,100);
  toolOptionsLayout->addWidget(editMaskToolOptions);

  filterToolOptions = new QWidget(toolOptions);
  grid = new QGridLayout(filterToolOptions);
  filterToolOptions->setLayout(grid);
  grid->addWidget(new QLabel(tr("Filter Type:"),filterToolOptions),0,0);
  QComboBox * comboBox = new QComboBox(filterToolOptions);
  comboBox->addItem("Gaussian Radial");
  comboBox->addItem("Horizontal bands removal");
  comboBox->setMinimumContentsLength(10);
  comboBox->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
  grid->addWidget(comboBox,0,1);
  grid->setRowStretch(2,100);
  grid->setColumnStretch(2,100);
  toolOptionsLayout->addWidget(filterToolOptions);

  selectionToolOptions = new QWidget(toolOptions);
  grid = new QGridLayout(selectionToolOptions);
  selectionToolOptions->setLayout(grid);
  label = new QLabel("Mode:",selectionToolOptions);
  label->setAlignment(Qt::AlignRight);
  grid->addWidget(label,0,0);
  QToolButton *  button = new QToolButton(selectionToolOptions);
  button->setIcon(QIcon(":images/selection.png"));
  button->setToolTip("Set selection");
  button->setCheckable(true);
  button->setChecked(true);
  button->setAutoExclusive(true);
  connect(button,SIGNAL(clicked()),this,SLOT(setSelectionModeSet()));
  grid->addWidget(button,0,1);
  button = new QToolButton(selectionToolOptions);
  button->setIcon(QIcon(":images/selection_union.png"));
  button->setToolTip("Add to selection");
  button->setCheckable(true);
  button->setAutoExclusive(true);
  connect(button,SIGNAL(clicked()),this,SLOT(setSelectionModeUnite()));
  grid->addWidget(button,0,2);
  button = new QToolButton(selectionToolOptions);
  button->setIcon(QIcon(":images/selection_subtract.png"));
  button->setToolTip("Remove from selection");  
  button->setCheckable(true);
  button->setAutoExclusive(true);
  connect(button,SIGNAL(clicked()),this,SLOT(setSelectionModeSubtract()));
  grid->addWidget(button,0,3);
  label = new QLabel("Expression:",selectionToolOptions);
  label->setAlignment(Qt::AlignRight);
  grid->addWidget(label,1,0);
  selectExpression = new QLineEdit("A > 10",selectionToolOptions);
  grid->addWidget(selectExpression,1,1,1,3);
  QPushButton * evalExpression = new QPushButton("Select by Expression",selectionToolOptions);
  connect(evalExpression,SIGNAL(clicked()),this,SLOT(onSelectByExpression()));
  grid->addWidget(evalExpression,2,0,1,4);
  grid->setRowStretch(5,100);
  grid->setColumnStretch(5,100);
  _selectionMode = SelectionSet;
  toolOptionsLayout->addWidget(selectionToolOptions);

  electronicsToolOptions = new QWidget(toolOptions);
  grid = new QGridLayout(electronicsToolOptions);
  electronicsToolOptions->setLayout(grid);
  QPushButton * push = new QPushButton("Remove Vertical Lines",electronicsToolOptions);
  grid->addWidget(push,0,0);
  connect(push,SIGNAL(clicked()),this,SLOT(onRemoveVerticalLinesClicked()));
  push = new QPushButton("Remove Horizontal Lines",electronicsToolOptions);
  grid->addWidget(push,1,0);
  connect(push,SIGNAL(clicked()),this,SLOT(onRemoveHorizontalLinesClicked()));
  toolOptionsLayout->addWidget(electronicsToolOptions);

  fillEmptyToolOptions = new QWidget(toolOptions);
  grid = new QGridLayout(fillEmptyToolOptions);
  fillEmptyToolOptions->setLayout(grid);
  grid->addWidget(new QLabel("Blur Radius (px)",0,0));
  fillBlurRadius =  new QDoubleSpinBox(fillEmptyToolOptions);
  grid->addWidget(fillBlurRadius,0,1);

  grid->addWidget(new QLabel("Iterations"),1,0);
  fillIterations =  new QSpinBox(fillEmptyToolOptions);
  fillIterations->setMinimum(1);
  grid->addWidget(fillIterations,1,1);

  grid->addWidget(new QLabel("Blur Kernel"),2,0);
  fillBlurKernel = new QComboBox(fillEmptyToolOptions);
  fillBlurKernel->addItem("Gaussian");
  fillBlurKernel->addItem("Sinc");
  grid->addWidget(fillBlurKernel,2,1);

  push = new QPushButton("Interpolate",fillEmptyToolOptions);
  grid->addWidget(push,3,0,1,2);
  connect(push,SIGNAL(clicked()),this,SLOT(onInterpolateEmptyClicked()));
  toolOptionsLayout->addWidget(fillEmptyToolOptions);



  toolOptions->hide();
  layout->addWidget(toolOptions,2,0,1,11);
  layout->setColumnStretch(11,100);
  layout->setRowStretch(3,100);
}
Example #9
0
void
fixComboBoxViewWidth(QComboBox &comboBox) {
  comboBox.setSizeAdjustPolicy(QComboBox::AdjustToContents);
  comboBox.view()->setMinimumWidth(comboBox.sizeHint().width());
}
Example #10
0
void PreviewEditor::buildWidget()
{
	previewWidget = new PreviewWidget(this);

	locationIDE = new QComboBox(this);
	int i=0;
	foreach(const QString &loc, Data::locations().list())
		locationIDE->addItem(loc, i++);
	saveCountE = new SpinBox16(this);
	curSaveE = new SpinBox32(this);

	autoGroup = new QGroupBox(tr("Auto."));
	autoGroup->setCheckable(true);

	hpLeaderE = new SpinBox16(autoGroup);
	hpMaxLeaderE = new SpinBox16(autoGroup);
	gilsE = new SpinBox32(autoGroup);
	timeE = new TimeWidget(autoGroup);
	nivLeaderE = new SpinBox8(autoGroup);
	discE = new SpinBox32(autoGroup);
	discE->setRange(1, double(MAX_INT32) + 1.0);

	QComboBox *comboBox;
	QList<QIcon> icons;

	for(int i=0 ; i<16 ; ++i) {
		icons.append(QIcon(QString(":/images/icons/perso%1.png").arg(i)));
	}

	for(int i=0 ; i<3 ; ++i) {
		partyE.append(comboBox = new QComboBox(autoGroup));
		comboBox->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
		comboBox->addItem("-", 255);
		for(int j=0 ; j<16 ; ++j) {
			comboBox->addItem(icons.at(j), Data::names().at(j), j);
		}
	}

	QHBoxLayout *partyL = new QHBoxLayout;
	partyL->addWidget(partyE.first());
	partyL->addWidget(partyE.at(1));
	partyL->addWidget(partyE.last());
	partyL->setContentsMargins(QMargins());

	QGridLayout *autoL = new QGridLayout(autoGroup);
	autoL->addWidget(new QLabel(tr("HP leader (inutilisé)"), autoGroup), 0, 0);
	autoL->addWidget(hpLeaderE, 0, 1);
	autoL->addWidget(new QLabel(tr("HP max. leader (inutilisé)"), autoGroup), 0, 2);
	autoL->addWidget(hpMaxLeaderE, 0, 3);
	autoL->addWidget(new QLabel(tr("Niveau leader"), autoGroup), 0, 4);
	autoL->addWidget(nivLeaderE, 0, 5);
	autoL->addWidget(new QLabel(tr("Argent"), autoGroup), 1, 0);
	autoL->addWidget(gilsE, 1, 1);
	autoL->addWidget(new QLabel(tr("Temps"), autoGroup), 1, 2);
	autoL->addWidget(timeE, 1, 3);
	autoL->addWidget(new QLabel(tr("Disque"), autoGroup), 1, 4);
	autoL->addWidget(discE, 1, 5);
	autoL->addWidget(new QLabel(tr("Équipe"), autoGroup), 2, 0);
	autoL->addLayout(partyL, 2, 1, 1, 5);

	QGridLayout *layout = new QGridLayout(this);
	layout->addWidget(previewWidget, 0, 0, 1, 6, Qt::AlignCenter);
	layout->addWidget(new QLabel(tr("Lieu affiché")), 1, 0);
	layout->addWidget(locationIDE, 1, 1);
	layout->addWidget(new QLabel(tr("Nombre de sauvegardes")), 1, 2);
	layout->addWidget(saveCountE, 1, 3);
	layout->addWidget(new QLabel(tr("Sauvegarde courante")), 1, 4);
	layout->addWidget(curSaveE, 1, 5);
	layout->addWidget(autoGroup, 2, 0, 1, 6);
	layout->setRowStretch(3, 1);

	connect(autoGroup, SIGNAL(toggled(bool)), SLOT(setGroupDisabled(bool)));
	connect(nivLeaderE, SIGNAL(valueChanged(int)), SLOT(updatePreview()));
	connect(gilsE, SIGNAL(valueChanged(double)), SLOT(updatePreview()));
	connect(timeE, SIGNAL(valueChanged()), SLOT(updatePreview()));
	connect(discE, SIGNAL(valueChanged(double)), SLOT(updatePreview()));
	connect(locationIDE, SIGNAL(currentIndexChanged(int)), SLOT(updatePreview()));
	foreach(QComboBox *cb, partyE) {
		connect(cb, SIGNAL(currentIndexChanged(int)), SLOT(updatePreview()));
	}
Example #11
0
QWidget*  MultiDelegate::createEditor( QWidget* parent,
                                     const QStyleOptionViewItem& option,
                                     const QModelIndex& index)  const
{
    const QAbstractItemModel*  model = index.model();
    QVariant  value = model->data( index, Qt::EditRole);
    switch (value.type()) {
    case QMetaType::QTime:
    {
        QTimeEdit*  editor = new QTimeEdit( parent);
        editor->setMaximumWidth( editor->sizeHint().width());

        //// Get value snapshot into editor
        editor->setTime( value.toTime());
        return editor;
    }
    case QMetaType::QDate:
    {
        QDateEdit*  editor = new QDateEdit( parent);
        setupCalenderWidget( editor);
        editor->setMaximumWidth( editor->sizeHint().width());

        //// Get value snapshot into editor
        editor->setDate( value.toDate());
        return editor;
    }
    case QMetaType::QDateTime:
    {
        QDateTimeEdit*  editor = new QDateTimeEdit( parent);
        setupCalenderWidget( editor);
        editor->setMaximumWidth( editor->sizeHint().width());

        editor->setDateTime( value.toDateTime());
        return editor;
    }
    case QMetaType::QImage:
        // Fall throu
    case QMetaType::QPixmap:
        // Fall throu
    case QMetaType::QIcon:
    {
        PixmapViewer*  editor = new PixmapViewer( parent);
        connect( editor, SIGNAL(finished(int)), this, SLOT(closeEmittingEditor()));
        return editor;
    }
    case QMetaType::QStringList:
    {
        QVariant  varList = index.model()->data( index, ItemDataRole::EnumList);
        if (varList.isNull())  break;  // Not a enum-list, fall to std

        QListWidget*  editor = new QListWidget( parent);
        foreach (const QString& bitItemText, varList.toStringList()) {
            QListWidgetItem* bitItem = new QListWidgetItem( bitItemText, editor);
            bitItem->setFlags(bitItem->flags() | Qt::ItemIsUserCheckable);
            bitItem->setCheckState(Qt::Unchecked);
        }
        int width  = editor->sizeHintForColumn(0) + 25;
        int height = editor->sizeHintForRow(0) * editor->count() + 10;
        editor->setMinimumWidth( width);
        editor->setMaximumWidth( width);
        editor->setMinimumHeight( height);
        editor->setMaximumHeight( height);

        //// Get value snapshot into editor
        QStringList  valList = value.toStringList();
        int  itemCount = editor->count();
        for (int i = 0; i < itemCount; ++i) {
            QListWidgetItem*  bitItem = editor->item(i);
            bool  isActive = valList.contains( bitItem->text());
            bitItem->setCheckState( isActive ? Qt::Checked : Qt::Unchecked);
        }
        return editor;
    }
    case QMetaType::QString:
    {
        QVariant  varList = index.model()->data( index, ItemDataRole::EnumList);
        if (varList.isNull())  break;  // Not a enum-list, fall to std

        QComboBox*  editor = new QComboBox( parent);
        editor->setSizeAdjustPolicy(QComboBox::AdjustToContents);
        editor->addItems( varList.toStringList());
        editor->setMaximumWidth( editor->minimumSizeHint().width());

        //// Get value snapshot into editor
        editor->setCurrentIndex( editor->findText( value.toString()));
        return editor;
    }
    default:;
    }

    if (index.column() == 0) {
        emit itemEditTrigged( index);
        return 0;  // No inline editor
    }

    QWidget*  editor = QItemDelegate::createEditor( parent, option, index);

    //// Get value snapshot into editor
    QItemDelegate::setEditorData( editor, index);
    return editor;
}
Example #12
0
	void ItemHandlerCombobox::Handle (const QDomElement& item, QWidget *pwidget)
	{
		QGridLayout *lay = qobject_cast<QGridLayout*> (pwidget->layout ());

		QHBoxLayout *hboxLay = new QHBoxLayout;
		QComboBox *box = new QComboBox (XSD_);

		hboxLay->addWidget (box);

		XSD_->SetTooltip (box, item);
		box->setObjectName (item.attribute ("property"));
		box->setSizeAdjustPolicy (QComboBox::AdjustToContents);
		if (item.hasAttribute ("maxVisibleItems"))
			box->setMaxVisibleItems (item.attribute ("maxVisibleItems").toInt ());

		bool mayHaveDataSource = item.hasAttribute ("mayHaveDataSource") &&
				item.attribute ("mayHaveDataSource").toLower () == "true";
		if (mayHaveDataSource)
		{
			const QString& prop = item.attribute ("property");
			Factory_->RegisterDatasourceSetter (prop,
					[this] (const QString& str, QAbstractItemModel *m, Util::XmlSettingsDialog *xsd)
						{ SetDataSource (str, m, xsd); });
			Propname2Combobox_ [prop] = box;
			Propname2Item_ [prop] = item;
		}

		hboxLay->addStretch ();

		if (item.hasAttribute ("moreThisStuff"))
		{
			QPushButton *moreButt = new QPushButton (tr ("More stuff..."));
			hboxLay->addWidget (moreButt);

			moreButt->setObjectName (item.attribute ("moreThisStuff"));
			connect (moreButt,
					SIGNAL (released ()),
					XSD_,
					SLOT (handleMoreThisStuffRequested ()));
		}

		QDomElement option = item.firstChildElement ("option");
		while (!option.isNull ())
		{
			const auto& images = XSD_->GetImages (option);
			if (!images.isEmpty ())
			{
				const QIcon icon (QPixmap::fromImage (images.at (0)));
				box->addItem (icon,
						XSD_->GetLabel (option),
						option.attribute ("name"));
			}
			else
				box->addItem (XSD_->GetLabel (option),
						option.attribute ("name"));

			auto setColor = [&option, box] (const QString& attr, Qt::ItemDataRole role) -> void
			{
				if (option.hasAttribute (attr))
				{
					const QColor color (option.attribute (attr));
					box->setItemData (box->count () - 1, color, role);
				}
			};
			setColor ("color", Qt::ForegroundRole);
			setColor ("bgcolor", Qt::BackgroundRole);

			option = option.nextSiblingElement ("option");
		}

		connect (box,
				SIGNAL (currentIndexChanged (int)),
				this,
				SLOT (updatePreferences ()));

		QDomElement scriptContainer = item.firstChildElement ("scripts");
		if (!scriptContainer.isNull ())
		{
			Scripter scripter (scriptContainer);

			QStringList fromScript = scripter.GetOptions ();
			Q_FOREACH (const QString& elm, scripter.GetOptions ())
				box->addItem (scripter.HumanReadableOption (elm),
						elm);
		}
Example #13
0
bool QVideoCapture::open_resolutionDialog()
{
    if (m_cvCapture.isOpened() && deviceFlag)
    {
        //GUI CONSTRUCTION//
        QDialog dialog;
        dialog.setFixedSize(200,180);
        dialog.setWindowTitle(tr("Camcorder resolution"));

        QVBoxLayout toplevellayout;
        toplevellayout.setMargin(5);

        QVBoxLayout layout;
        layout.setMargin(5);
        QGroupBox groupbox;
        groupbox.setTitle("Resolution & framerate");
        QVBoxLayout comboboxes;
        comboboxes.setMargin(5);
        QComboBox CBresolution;
        CBresolution.addItem("640 x 360"); // 0
        CBresolution.addItem("640 x 480"); // 1
        CBresolution.addItem("800 x 600"); // 2
        CBresolution.addItem("960 x 720"); // 3
        CBresolution.addItem("1280 x 720"); // 4
        CBresolution.addItem("1920 x 1080"); // 5
        CBresolution.setSizeAdjustPolicy(QComboBox::AdjustToContents);
        CBresolution.setCurrentIndex(1);
        QLabel Lresolution("Set resolution:");
        QComboBox CBm_framerate(&dialog);
        CBm_framerate.addItem("30 fps"); // 0
        CBm_framerate.addItem("25 fps"); // 1
        CBm_framerate.addItem("20 fps"); // 2
        CBm_framerate.addItem("15 fps"); // 3
        CBm_framerate.addItem("60 fps"); // 4
        CBm_framerate.setSizeAdjustPolicy(QComboBox::AdjustToContents);
        CBm_framerate.setCurrentIndex(0);
        QLabel Lm_framerate("Set framerate:");
        comboboxes.addWidget(&Lresolution,1,Qt::AlignLeft);
        comboboxes.addWidget(&CBresolution);
        comboboxes.addWidget(&Lm_framerate,1,Qt::AlignLeft);
        comboboxes.addWidget(&CBm_framerate);
        groupbox.setLayout(&comboboxes);
        layout.addWidget(&groupbox);

        QHBoxLayout buttons;
        buttons.setMargin(5);
        QPushButton Baccept;
        Baccept.setText("Accept");
        connect(&Baccept, SIGNAL(clicked()), &dialog, SLOT(accept()));
        QPushButton Bcancel;
        Bcancel.setText("Cancel");
        connect(&Bcancel, SIGNAL(clicked()), &dialog, SLOT(reject()));
        buttons.addWidget(&Baccept);
        buttons.addWidget(&Bcancel);

        toplevellayout.addLayout(&layout);
        toplevellayout.addLayout(&buttons);
        dialog.setLayout(&toplevellayout);
        //GUI CONSTRUCTION END//

        if(dialog.exec() == QDialog::Accepted)
        {
            m_cvCapture.set( CV_CAP_PROP_FRAME_WIDTH, CBresolution.itemText(CBresolution.currentIndex()).section(" x ",0,0).toDouble() );
            m_cvCapture.set( CV_CAP_PROP_FRAME_HEIGHT, CBresolution.itemText(CBresolution.currentIndex()).section(" x ",1,1).toDouble() );
            pt_timer->setInterval( 1000/CBm_framerate.itemText(CBm_framerate.currentIndex()).section(" ",0,0).toDouble() );
        }
        return true;
    }
    return false; // will return false if device was not opened or dialog.exec() == QDialog::Rejected
}