Пример #1
0
void
Gui::setQMessageBoxAppropriateFont(QMessageBox* widget)
{
    QGridLayout* grid = dynamic_cast<QGridLayout*>( widget->layout() );

    assert(grid);
    if (!grid) {
        return;
    }
    int count = grid->count();
    for (int i = 0; i < count; ++i) {
        QLayoutItem* item = grid->itemAt(i);
        if (item) {
            QWidget* w = item->widget();
            if (w) {
                QLabel* isLabel = dynamic_cast<QLabel*>(w);
                if (isLabel) {
                    isLabel->setFont( QApplication::font() ); // necessary, or the labels will get the default font size
                }
            }
        }
    }

    QList<QAbstractButton *> buttonsList = widget->buttons();
    Q_FOREACH(QAbstractButton* b, buttonsList) {
        b->setAttribute(Qt::WA_LayoutUsesWidgetRect); // Don't use the layout rect calculated from QMacStyle.
        b->setFont( QApplication::font() ); // necessary, or the labels will get the default font size
    }
Пример #2
0
TaskFemConstraint::TaskFemConstraint(ViewProviderFemConstraint *ConstraintView,QWidget *parent,const char* pixmapname)
    : TaskBox(Gui::BitmapFactory().pixmap(pixmapname),tr("FEM constraint parameters"),true, parent),ConstraintView(ConstraintView)
{
    selectionMode = selref;

    // Setup the dialog inside the Shaft Wizard dialog
    if ((ConstraintView->wizardWidget != NULL) && (ConstraintView->wizardSubLayout != NULL)) {
        // Hide the shaft wizard table widget to make more space
        ConstraintView->wizardSubLayout->itemAt(0)->widget()->hide();
        QGridLayout* buttons = ConstraintView->wizardSubLayout->findChild<QGridLayout*>();
        for (int b = 0; b < buttons->count(); b++)
            buttons->itemAt(b)->widget()->hide();

        // Show this dialog for the FEM constraint
        ConstraintView->wizardWidget->addWidget(this);

        // Add buttons to finish editing the constraint without closing the shaft wizard dialog
        okButton = new QPushButton(QObject::tr("Ok"));
        cancelButton = new QPushButton(QObject::tr("Cancel"));
        buttonBox = new QDialogButtonBox();
        buttonBox->addButton(okButton, QDialogButtonBox::AcceptRole);
        buttonBox->addButton(cancelButton, QDialogButtonBox::RejectRole);
        QObject::connect(okButton, SIGNAL(clicked()), this, SLOT(onButtonWizOk()));
        QObject::connect(cancelButton, SIGNAL(clicked()), this, SLOT(onButtonWizCancel()));
        ConstraintView->wizardWidget->addWidget(buttonBox);
    }
}
Пример #3
0
int QGridLayoutProto::count() const
{
  QGridLayout *item = qscriptvalue_cast<QGridLayout*>(thisObject());
  if (item)
    return item->count();
  return 0;
}
Пример #4
0
void TilesetGroupEditor::redrawAll()
{
    util::memclear(ui->tilesetList);
    //QGroupBox* preview = ui->PreviewBox;
    util::clearLayoutItems(layout);
    for(int i = 0; i < tilesets.size(); ++i)
    {
        QListWidgetItem *xxx = new QListWidgetItem;
        xxx->setText(tilesets[i].first);
        xxx->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
        ui->tilesetList->addItem(xxx);

        QGroupBox *f = new QGroupBox;
        QGridLayout *l = new QGridLayout();
        l->setContentsMargins(4, 4, 4, 4);
        l->setSpacing(2);
        f->setLayout(l);
        f->setTitle(tilesets[i].second.tileSetName);
        SimpleTileset *items = &tilesets[i].second;
        for(int j = 0; j < items->items.size(); ++j)
        {
            SimpleTilesetItem *item = &items->items[j];
            TilesetItemButton *ib = new TilesetItemButton(m_configs, scn);
            ib->applySize(32, 32);
            ib->applyItem(items->type, item->id);
            l->addWidget(ib, item->row, item->col);
        }
        DevConsole::log(QString("Current GridLayout Items: %1").arg(l->count()), QString("Tileset"));
        layout->addWidget(f);
        DevConsole::log(QString("Current FlowLayout Items: %1").arg(layout->count()), QString("Tileset"));
    }
}
Пример #5
0
void ComplexplotWrapper::addToWindowSlot(QString window, int row, int column)
{
  if(destroyed_)
    return;
  if(window != "")
  {
    QWidgetList widgets = qApp->topLevelWidgets();
    for(QWidgetList::iterator i = widgets.begin(); i != widgets.end(); ++i)
    {
      if ((*i)->objectName() == window)
      {
        QGridLayout *l = (QGridLayout*)(*i)->layout();
        if(row<0)    row    = l->count()/3;
        if(column<0) column = l->count()%3;
        l->addWidget(widget_, row, column);
        return;
      }
    }

    QWidget *p = new QWidget();
    p->setObjectName(window);
    QGridLayout *layout = new QGridLayout();
    p->setLayout(layout);
    if(row<0)    row    = 0;
    if(column<0) column = 0;
    layout->addWidget(widget_, row, column);
    p->show();
  }
}
void DeviceStatusForm::updateGUIPorts (void)
{
	// refresh device informations
	m_pDevice->setDevice(m_pDevice->deviceType(), m_pDevice->deviceID());
	DevicePortList ports = m_pDevice->ports();

	// clear the GUI
	QGridLayout *pLayout = static_cast<QGridLayout *> (layout());
	for (int i = pLayout->count() - 1; i >= 0; --i) {
		QLayoutItem *pItem = pLayout->itemAt(i);
		if (pItem) {
			pLayout->removeItem(pItem);
			if (pItem->widget())
				delete pItem->widget();
			delete pItem;
		}
	}

	m_midiActivityLEDs.clear();

	// rebuild the GUI
	for (int i = 0; i < ports.size(); ++i) {
		MidiActivityLED *pLED = new MidiActivityLED();
		m_midiActivityLEDs.push_back(pLED);
		pLayout->addWidget(pLED, i, 0);
		QLabel *pLabel = new QLabel(
			m_pDevice->deviceTypeName()
			+ ' ' + m_pDevice->driverName()
			+ ' ' + ports[i]->portName());
		pLayout->addWidget(pLabel, i, 1, Qt::AlignLeft);
	}
}
Пример #7
0
void TaskFemConstraint::onButtonWizOk()
{
    // Remove dialog elements
    buttonBox->removeButton(okButton);
    delete okButton;
    buttonBox->removeButton(cancelButton);
    delete cancelButton;
    ConstraintView->wizardWidget->removeWidget(buttonBox);
    delete buttonBox;
    ConstraintView->wizardWidget->removeWidget(this);

    // Show the wizard shaft dialog again
    ConstraintView->wizardSubLayout->itemAt(0)->widget()->show();
    QGridLayout* buttons = ConstraintView->wizardSubLayout->findChild<QGridLayout*>();
    for (int b = 0; b < buttons->count(); b++)
        buttons->itemAt(b)->widget()->show();

    Gui::Application::Instance->activeDocument()->resetEdit(); // Reaches ViewProviderFemConstraint::unsetEdit() eventually
}
void MyView::ChnageLayout(const int rows, const int columns)
{
    if (layout_.count() > 0)
    {
        for(NodeViewPtrIter it = views.begin(); it != views.end(); ++it)
        {
            layout_.removeWidget(it->get());
            (*it)->hide();
        }
    }

    for(int i = 0; i < rows; ++i)
    {
        for(int j = 0; j < columns; ++j)
        {
            layout_.addWidget(views[i * columns + j].get(), i, j);
            views[i * columns + j]->SetViewMode(mode_);
            views[i * columns + j]->show();
        }
    }
}
Пример #9
0
/*
 * Update the QtSensoryRegion grid display to reflect the current input
 * pattern by changing the brush color of the QtUnits.
 */
void QtFront::UpdateInputDisplay(SensoryRegion *newPattern)
{
    QGridLayout *currSensoryGrid =
        (QGridLayout *)sensoryGroup->layout();
    QGridLayout *newSensoryGrid =
        CurrentInput->SensoryUnitGrid();
    int w = newPattern->GetWidth();
    int h = newPattern->GetHeight();

    SensoryRegion *mp = newPattern->GetMotorPattern();
    //QGridLayout *currMotorGrid =
    //    (QGridLayout *)motorGroup->layout();
    //QGridLayout *newMotorGrid =
    //    CurrentInput->MotorUnitGrid();

    SensoryRegion *lp = newPattern->GetLocationPattern();
    QGridLayout *currLocGrid =
        (QGridLayout *)locGroup->layout();
    QGridLayout *newLocGrid =
        CurrentInput->LocationUnitGrid();

    int r, g, b;
    QColor rgb;
    QtUnit *oldqtunit = NULL, *newqtunit = NULL;

/*
 The old way of updating the sensory input unit grid. This had very,
 very poor performance, so I am leaving the code here as a reminder.

    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            // getting the qlayout item with itemAtPosition has very
            // poor performance.
            qtunit = (QtUnit *)newSensoryGrid->itemAtPosition(i, j)->widget();
            rgb = qtunit->getBrushColor();
            rgb.getRgb(&r, &g, &b);
            qtunit = (QtUnit *)currSensoryGrid->itemAtPosition(i, j)->widget();
            qtunit->setBrushColor(QColor(r, g, b));
        }
    }
*/

    /* sensory input display grid */
    for (int i=0; i<newSensoryGrid->count(); i++) {
        int row, col, rs, cs;
        newSensoryGrid->getItemPosition(i, &row, &col, &rs, &cs);
        newqtunit = (QtUnit *)newSensoryGrid->itemAt(i)->widget();
        rgb = newqtunit->getBrushColor();
        rgb.getRgb(&r, &g, &b);
        oldqtunit = (QtUnit *)currSensoryGrid->itemAt(i)->widget();
        oldqtunit->setBrushColor(QColor(r, g, b));
    }
    /* motor input display grid */
    /*
    for (int i=0; i<newMotorGrid->count(); i++) {
        int row, col, rs, cs;
        newMotorGrid->getItemPosition(i, &row, &col, &rs, &cs);
        newqtunit = (QtUnit *)newMotorGrid->itemAt(i)->widget();
        rgb = newqtunit->getBrushColor();
        rgb.getRgb(&r, &g, &b);
        oldqtunit = (QtUnit *)currMotorGrid->itemAt(i)->widget();
        oldqtunit->setBrushColor(QColor(r, g, b));
        oldqtunit->SetActive(newqtunit->IsActive());
    }
    */

    /* location input display grid */
    for (unsigned int i=0; i<newLocGrid->count(); i++) {
        int row, col, rs, cs;
        newLocGrid->getItemPosition(i, &row, &col, &rs, &cs);
        newqtunit = (QtUnit *)newLocGrid->itemAt(i)->widget();
        rgb = newqtunit->getBrushColor();
        rgb.getRgb(&r, &g, &b);
        oldqtunit = (QtUnit *)currLocGrid->itemAt(i)->widget();
        oldqtunit->setBrushColor(QColor(r, g, b));
        oldqtunit->SetActive(newqtunit->IsActive());
    }
}
Пример #10
0
void PhotoDrop::reorderPhotos()
{
	std::cerr << "PhotoDrop::reorderPhotos()";
	std::cerr << std::endl;

	/* now move the qwidgets around */
	QLayout *alayout = layout();
	QGridLayout *glayout = dynamic_cast<QGridLayout *>(alayout);
	if (!glayout)
	{
		std::cerr << "PhotoDrop::reorderPhotos() not GridLayout... not much we can do!";
		std::cerr << std::endl;
		return;
	}

	/* grab the first PhotoItem - and get it size */
	std::map<gridIndex, PhotoItem *> photoItems;
	std::map<gridIndex, PhotoItem *>::iterator pit;

	int count = glayout->count();
	int i = 0;
	for(i = 0; i < count; i++)
	{
		QLayoutItem *litem = glayout->itemAt(i);
		if (!litem)
		{
			std::cerr << "PhotoDrop::reorderPhotos() missing litem";
			std::cerr << std::endl;
			continue;
		}

		PhotoItem *item = dynamic_cast<PhotoItem *>(litem->widget());
		if (item)
		{
			
			int selectedRow;
			int selectedColumn;
			int rowSpan;
			int colSpan;
			glayout->getItemPosition(i, &selectedRow, &selectedColumn, &rowSpan, &colSpan);

			std::cerr << "PhotoDrop::reorderPhotos() item: " << item;
			std::cerr << " layoutIdx: " << i;
			std::cerr << " item pos(" << selectedRow << ", " << selectedColumn;
			std::cerr << ")" << std::endl;
			
			gridIndex idx(selectedRow, selectedColumn);
			photoItems[idx] = item;
	
		}
		else
		{
			std::cerr << "PhotoDrop::reorderPhotos() Found Child, which is not a PhotoItem???";
			std::cerr << std::endl;
		}
	}

	pit = photoItems.begin(); 
	if (pit == photoItems.end())
	{
		std::cerr << "PhotoDrop::reorderPhotos() No PhotoItems.";
		std::cerr << std::endl;

		mColumns = 1;

		// no PhotoItems here.
		return;
	}

	int minWidth = (pit->second)->minimumWidth();

#define EXPECTED_WIDTH 	(200)
	if (minWidth < EXPECTED_WIDTH)
	{
		minWidth = EXPECTED_WIDTH;
	}
	int space = width();
	mColumns = space / minWidth;
	// incase its too thin!
	if (mColumns < 1)
	{
		mColumns = 1;
	}

	std::cerr << "PhotoDrop::reorderPhotos() minWidth: " << minWidth << " space: " << space;
	std::cerr << " columns: " << mColumns;
	std::cerr << std::endl;

	std::cerr << "PhotoDrop::reorderPhotos() Getting ordered Items from Layout";
	std::cerr << std::endl;


	for(pit = photoItems.begin(); pit != photoItems.end(); pit++)
	{
		glayout->removeWidget(pit->second);
	}
	
	for(pit = photoItems.begin(), i = 0; pit != photoItems.end(); pit++, i++)
	{
		int row = i / mColumns;
		int column = i % mColumns;

		std::cerr << "Inserting item: " << pit->second << " at (" << row << "," << column << ")";
		std::cerr << std::endl;
		glayout->addWidget(pit->second, row, column, Qt::AlignCenter);
	}
}
Пример #11
0
gNodeComponentWidget::gNodeComponentWidget(sJarvisNodeComponent* comp,QWidget *parent) :
    QGroupBox(parent), m_component(comp),
    ui(new Ui::gNodeComponentWidget)
{
    ui->setupUi(this);

    this->setTitle(m_component->getId());

    QList<jarvisActions> actions = m_component->getActions();
    for(int i = 0 ; i < actions.count() ; i++)
    {
        jarvisActions action = actions[i];
        //qDebug() << QString::number(int(action));
        QToolButton* b = new QToolButton(ui->actionsBox);
        QGridLayout* l = (QGridLayout*)ui->actionsBox->layout();

        if      (action == A_DIMM){
            b->deleteLater();
            QSlider* w = new QSlider(this);
            w->setMaximum(100);
            w->setValue(50);
            l->addWidget(w,l->count()/2,l->count()%2);
            connect(w,SIGNAL(valueChanged(int)),m_component,SLOT(dimm(int)));

        }else if(action == A_SET_COLOR){
            connect(b,SIGNAL(clicked()),this,SLOT(selectComponentColor()));
            b->setText(m_component->actionName((m_component->getActions()[i])));
            l->addWidget(b,l->count()/2,l->count()%2);

        }else if(action == A_SET_LEDS){
            connect(b,SIGNAL(clicked()),this,SLOT(sendImage()));
            b->setText(m_component->actionName((m_component->getActions()[i])));
            l->addWidget(b,l->count()/2,l->count()%2);

        }else if(action == A_DISPLAY){
            connect(b,SIGNAL(clicked()),this,SLOT(sendImage()));
            b->setText(m_component->actionName((m_component->getActions()[i])));
            l->addWidget(b,l->count()/2,l->count()%2);
        }else if(action == A_PLAYRTTTL){
            connect(b,SIGNAL(clicked()),this,SLOT(openRtttlPlayer()));
            b->setText(m_component->actionName((m_component->getActions()[i])));
            l->addWidget(b,l->count()/2,l->count()%2);
        }else{
            QString slotName = m_component->slotName(m_component->getActions()[i]);
            b->setText(m_component->actionName((m_component->getActions()[i])));
            l->addWidget(b,l->count()/2,l->count()%2);
            connect(b,SIGNAL(clicked()),m_component,slotName.toStdString().c_str());
        }
    }

    QList<jarvisEvents> events = m_component->getCapableEvents();
    for(int i = 0 ; i < events.count() ; i++)
    {
        gBlinkWidget* w = new gBlinkWidget(ui->eventsBox);
        QLabel* label = new QLabel(ui->eventsBox);
        QGridLayout* l = (QGridLayout*)ui->eventsBox->layout();
        l->addWidget(label,i,0);
        l->addWidget(w,i,1);
        w->setMaximumHeight(50);
        if(events[i] == E_RAW_READ)
        {
            connect(m_component,SIGNAL(rawRead()),w,SLOT(blink()));
            connect(m_component,SIGNAL(rawRead(QStringList)),w,SLOT(displayRead(QStringList)));
            label->setText(m_component->eventName((m_component->getCapableEvents()[i])));

        }else if(events[i] == E_DATA_READ)
        {
            connect(m_component,SIGNAL(dataRead()),w,SLOT(blink()));
            connect(m_component,SIGNAL(dataRead(QStringList)),w,SLOT(displayRead(QStringList)));
            label->setText(m_component->eventName((m_component->getCapableEvents()[i])));

        }else
        {
            QString signalName = m_component->signalName(m_component->getCapableEvents()[i]);
            label->setText(m_component->eventName((m_component->getCapableEvents()[i])));
            connect(m_component,signalName.toStdString().c_str(),w,SLOT(blink()));
        }
        //w->setMinimumSize(32,32);
        //w->setMaximumSize(32,32);
    }
}