コード例 #1
0
ファイル: Gui30.cpp プロジェクト: MrKepzie/Natron
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.cpp プロジェクト: Jonham/FreeCAD
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
QLayoutItem *QGridLayoutProto::itemAt(int index) const
{
  QGridLayout *item = qscriptvalue_cast<QGridLayout*>(thisObject());
  if (item)
    return item->itemAt(index);
  return 0;
}
コード例 #4
0
void QVariantListPropertyWidgetItem::setEditValue(const QVariant& value)
{
    QGridLayout* layout = qobject_cast<QGridLayout*>( editWidget()->layout() );

    // Clear out any old data...
    editorItems.clear();
    values.clear();
    layout->removeItem( layout->itemAt( layout->indexOf( listItems ) ) );
    listItems->deleteLater();

    // Set new value
    listItems = new QWidget( editWidget() );
    listItems->setContentsMargins( 0, 0, 0, 0 );
    listItems->setLayout( new QVBoxLayout() );
    listItems->layout()->setMargin( 0 );
    listItems->layout()->setSpacing( 0 );

    layout->addWidget( listItems, 1, 0, 1, 2 );

    // Rebuild list from this
    QVariantList items = value.toList();

    if( items.count() > 0 )
    {
        for( int i = 0; i < items.count(); ++i )
        {
            addItem( items[i] );
        }
    }

    GluonCreator::PropertyWidgetItem::setEditValue(value);
}
コード例 #5
0
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);
	}
}
コード例 #6
0
ファイル: TaskFemConstraint.cpp プロジェクト: Jonham/FreeCAD
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
}
コード例 #7
0
void WidgetHandle::changeGridLayoutItemSpan()
{
    QDesignerLayoutDecorationExtension *deco = qt_extension<QDesignerLayoutDecorationExtension*>(core()->extensionManager(), m_widget->parentWidget());
    if (!deco)
       return;
    QGridLayout *grid = managedLayoutOf<QGridLayout>(m_formWindow->core(), m_widget);
    if (!grid)
       return;

    const int index = deco->indexOf(m_widget);
    const QRect info = deco->itemInfo(index);
    const int top = deco->findItemAt(info.top() - 1, info.left());
    const int left = deco->findItemAt(info.top(), info.left() - 1);
    const int bottom = deco->findItemAt(info.bottom() + 1, info.left());
    const int right = deco->findItemAt(info.top(), info.right() + 1);

    const QPoint pt = m_origGeom.center() - m_widget->geometry().center();

    ChangeLayoutItemGeometry *cmd = 0;

    switch (m_type) {
    default:
       break;

    case WidgetHandle::Top: {
       if (pt.y() < 0 && info.height() > 1) {
           cmd = new ChangeLayoutItemGeometry(m_formWindow);
           cmd->init(m_widget, info.y() + 1, info.x(), info.height() - 1, info.width());
       } else if (pt.y() > 0 && top != -1 && grid->itemAt(top)->spacerItem()) {
           cmd = new ChangeLayoutItemGeometry(m_formWindow);
           cmd->init(m_widget, info.y() - 1, info.x(), info.height() + 1, info.width());
       }
    }
       break;

    case WidgetHandle::Left: {
       if (pt.x() < 0 && info.width() > 1) {
           cmd = new ChangeLayoutItemGeometry(m_formWindow);
           cmd->init(m_widget, info.y(), info.x() + 1, info.height(), info.width() - 1);
       } else if (pt.x() > 0 && left != -1 && grid->itemAt(left)->spacerItem()) {
           cmd = new ChangeLayoutItemGeometry(m_formWindow);
           cmd->init(m_widget, info.y(), info.x() - 1, info.height(), info.width() + 1);
       }
    }
       break;

    case WidgetHandle::Right: {
       if (pt.x() > 0 && info.width() > 1) {
           cmd = new ChangeLayoutItemGeometry(m_formWindow);
           cmd->init(m_widget, info.y(), info.x(), info.height(), info.width() - 1);
       } else if (pt.x() < 0 && right != -1 && grid->itemAt(right)->spacerItem()) {
           cmd = new ChangeLayoutItemGeometry(m_formWindow);
           cmd->init(m_widget, info.y(), info.x(), info.height(), info.width() + 1);
       }
    }
       break;

    case WidgetHandle::Bottom: {
       if (pt.y() > 0 && info.width() > 1) {
           cmd = new ChangeLayoutItemGeometry(m_formWindow);
           cmd->init(m_widget, info.y(), info.x(), info.height() - 1, info.width());
       } else if (pt.y() < 0 && bottom != -1 && grid->itemAt(bottom)->spacerItem()) {
           cmd = new ChangeLayoutItemGeometry(m_formWindow);
           cmd->init(m_widget, info.y(), info.x(), info.height() + 1, info.width());
       }
    }
       break;
    }

    if (cmd != 0) {
       m_formWindow->commandHistory()->push(cmd);
    } else {
       grid->invalidate();
       grid->activate();
       m_formWindow->clearSelection(false);
       m_formWindow->selectWidget(m_widget);
    }
}
コード例 #8
0
ファイル: qt.cpp プロジェクト: HackerSuid/ACE
/*
 * 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());
    }
}
コード例 #9
0
ファイル: PhotoDrop.cpp プロジェクト: RedCraig/retroshare
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);
	}
}