Esempio n. 1
0
/**
 * Shows a context menu for the layer widget. Launched with a right click.
 */
void QG_LayerWidget::contextMenuEvent(QContextMenuEvent *e) {

    if (actionHandler) {
        QMenu* contextMenu = new QMenu(this);
        QLabel* caption = new QLabel(tr("Layer Menu"), this);
        QPalette palette;
        palette.setColor(caption->backgroundRole(), RS_Color(0,0,0));
        palette.setColor(caption->foregroundRole(), RS_Color(255,255,255));
        caption->setPalette(palette);
        caption->setAlignment( Qt::AlignCenter );
        contextMenu->addAction( tr("&Defreeze all Layers"), actionHandler,
                                 SLOT(slotLayersDefreezeAll()), 0);
        contextMenu->addAction( tr("&Freeze all Layers"), actionHandler,
                                 SLOT(slotLayersFreezeAll()), 0);
        contextMenu->addSeparator();
        contextMenu->addAction( tr("&Add Layer"), actionHandler,
                                 SLOT(slotLayersAdd()), 0);
        contextMenu->addAction( tr("&Remove Layer"), actionHandler,
                                 SLOT(slotLayersRemove()), 0);
        contextMenu->addAction( tr("Edit Layer &Attributes"), actionHandler,
                                 SLOT(slotLayersEdit()), 0);
        contextMenu->addAction( tr("Toggle Layer &Visibility"), actionHandler,
                                 SLOT(slotLayersToggleView()), 0);
        contextMenu->addAction( tr("Toggle Layer &Printing"), actionHandler,
                                 SLOT(slotLayersTogglePrint()), 0);
        contextMenu->addAction( tr("Toggle &Construction Layer"), actionHandler,
                                 SLOT(slotLayersToggleConstruction()), 0);
        contextMenu->exec(QCursor::pos());
        delete contextMenu;
    }

    e->accept();
}
/**
 * Shows a context menu for the block widget. Launched with a right click.
 */
void QG_BlockWidget::contextMenuEvent(QContextMenuEvent *e) {

    QMenu* contextMenu = new QMenu(this);
    QLabel* caption = new QLabel(tr("Block Menu"), this);
    QPalette palette;
    palette.setColor(caption->backgroundRole(), RS_Color(0,0,0));
    palette.setColor(caption->foregroundRole(), RS_Color(255,255,255));
    caption->setPalette(palette);
    caption->setAlignment( Qt::AlignCenter );
    contextMenu->addAction( tr("&Defreeze all Blocks"), actionHandler,
                             SLOT(slotBlocksDefreezeAll()), 0);
    contextMenu->addAction( tr("&Freeze all Blocks"), actionHandler,
                             SLOT(slotBlocksFreezeAll()), 0);
    contextMenu->addAction( tr("&Add Block"), actionHandler,
                             SLOT(slotBlocksAdd()), 0);
    contextMenu->addAction( tr("&Remove Block"), actionHandler,
                             SLOT(slotBlocksRemove()), 0);
    contextMenu->addAction( tr("&Rename Block"), actionHandler,
                             SLOT(slotBlocksAttributes()), 0);
    contextMenu->addAction( tr("&Edit Block"), actionHandler,
                             SLOT(slotBlocksEdit()), 0);
    contextMenu->addAction( tr("&Insert Block"), actionHandler,
                             SLOT(slotBlocksInsert()), 0);
    contextMenu->addAction( tr("&Toggle Visibility"), actionHandler,
                             SLOT(slotBlocksToggleView()), 0);
    contextMenu->addAction( tr("&Create New Block"), actionHandler,
                             SLOT(slotBlocksCreate()), 0);
    contextMenu->exec(QCursor::pos());
    delete contextMenu;

    e->accept();
}
Esempio n. 3
0
void TimeAnalysisWidget::updateLegend()
{
    std::vector<std::string> &labels = _selectedScalar->labels();

    // removinb previous legend
    QFormLayout *layout = (QFormLayout *)_ui->legendGroupBox->layout();
    QLayoutItem *child;
    while (layout->count()!=0 && (child = layout->takeAt(0)) != 0) {
        child->widget()->deleteLater();
        delete child;
    }

    for (unsigned i=0; i<labels.size(); ++i) {
        QLabel *colorLabel = new QLabel;
        colorLabel->setAutoFillBackground(true);
        colorLabel->setMinimumSize(70, 15);
        QPalette palette = colorLabel->palette();

        float denom = _selectedScalar->max() - _selectedScalar->min();
        float normalizedValue = ( i - _selectedScalar->min() ) / ( denom == 0 ? 1.f : denom );

        palette.setColor(colorLabel->backgroundRole(), _ui->projectionWidget->colorScale()->getColor(normalizedValue));
        colorLabel->setPalette(palette);

        layout->addRow(new QLabel(labels[i].c_str()), colorLabel);
    }

    repaint();
}
Esempio n. 4
0
void ray_options::set_color(qint32 red, qint32 green, qint32 blue)
{
	QLabel *l = ui->color_preview;
	QColor col(red, green, blue);
	QPalette pal = l->palette();
	pal.setColor(l->backgroundRole(), col);
	l->setPalette(pal);
	r->set_color(col);
	backgroung->update();
}
Esempio n. 5
0
/** Add the optional message in a light yellow box to the layout
 *
 * @param mainLay :: layout
 */
void AlgorithmDialog::addOptionalMessage(QVBoxLayout *mainLay) {
  QLabel *inputMessage = new QLabel(this);
  inputMessage->setFrameStyle(QFrame::Panel | QFrame::Sunken);
  QPalette pal = inputMessage->palette();
  pal.setColor(inputMessage->backgroundRole(),
               QColor(255, 255, 224)); // Light yellow
  pal.setColor(inputMessage->foregroundRole(), Qt::black);
  inputMessage->setPalette(pal);
  inputMessage->setAutoFillBackground(true);
  inputMessage->setWordWrap(true);
  inputMessage->setAlignment(Qt::AlignJustify);
  inputMessage->setMargin(3);
  inputMessage->setText(getOptionalMessage());
  QHBoxLayout *msgArea = new QHBoxLayout;
  msgArea->addWidget(inputMessage);
  mainLay->addLayout(msgArea, 0);
}
Esempio n. 6
0
/**
 * Constructor of the class
 * @param parent
 * @param name
 * @return
 */
NMGModuleToolBoxItem::NMGModuleToolBoxItem( QWidget *parent, QString modName, const QColor & backgroundColor )
		: QWidget( parent )
{
	setObjectName( modName );
	setMouseTracking( true );

	QPalette palette;
	palette.setColor( backgroundRole(), backgroundColor );
	setPalette( palette );

	moduleName = modName;

	QVBoxLayout * layoutVertical = new QVBoxLayout( this );
	layoutVertical->setMargin( 0 );
	layoutVertical->setSpacing( 0 );
	layoutVertical->setObjectName( moduleName + "LayoutVertical" );

	QHBoxLayout * layoutHoritzontal = new QHBoxLayout( 0 );
	layoutHoritzontal->setMargin( 0 );
	layoutHoritzontal->setSpacing( 0 );
	layoutHoritzontal->setObjectName( moduleName + "LayoutHoritzontal" );

	QSpacerItem * leftSpacer = new QSpacerItem( 1, 21, QSizePolicy::Maximum, QSizePolicy::Minimum );
	layoutHoritzontal->addItem( leftSpacer );

	QString toolTip = (( NMGModuleParent * ) NMGModuleManager::self()->getModule( moduleName ) )->getModuleToolTip().c_str();

	QLabel * pixmapLabel1 = new QLabel( this );
	pixmapLabel1->setMaximumSize( QSize( 64, 64 ) );
	pixmapLabel1->setAlignment( Qt::AlignHCenter );
	pixmapLabel1->setObjectName( moduleName + "Label" );

	if ( !toolTip.isEmpty() )
	{
		pixmapLabel1->setToolTip( toolTip );
		pixmapLabel1->setWhatsThis( toolTip );
	}

	QString iconFile = (( NMGModuleParent * ) NMGModuleManager::self()->getModule( moduleName ) )->getModuleIcon().c_str();
	if ( iconFile.isEmpty() ) iconFile = DEFAULT_ICON_NAME;
	pixmapLabel1->setPixmap( * ( NMGImageManager::loadPixmap( iconFile ) ) );
	pixmapLabel1->setScaledContents( TRUE );
	layoutHoritzontal->addWidget( pixmapLabel1 );
	pixmapLabel1->setMouseTracking( true );

	QSpacerItem * rightSpacer = new QSpacerItem( 1, 21, QSizePolicy::Maximum, QSizePolicy::Minimum );
	layoutHoritzontal->addItem( rightSpacer );
	layoutVertical->addLayout( layoutHoritzontal );


	QLabel * txtModuleLabel = new QLabel( "<p align=\"center\">" + moduleName + "</p>", this );
	txtModuleLabel->setObjectName( moduleName + "Label" );
	if ( !toolTip.isEmpty() )
	{
		txtModuleLabel->setToolTip( toolTip );
		txtModuleLabel->setWhatsThis( toolTip );
	}

	QSizePolicy policy1( QSizePolicy::Preferred, QSizePolicy::Preferred );
	policy1.setHorizontalStretch( 0 );
	policy1.setVerticalStretch( 0 );
	policy1.setHeightForWidth( txtModuleLabel->sizePolicy().hasHeightForWidth() );
	txtModuleLabel->setSizePolicy( policy1 );

	/** Size of the label for the plugin's name at toolbar **/
	txtModuleLabel->adjustSize(); //setMaximumSize( QSize( 100, 150 ) );
	QPalette palettelabel;
	palettelabel.setColor( txtModuleLabel->backgroundRole(), backgroundColor );
	txtModuleLabel->setPalette( palettelabel );
	txtModuleLabel->setAlignment( Qt::AlignVCenter ); //how to 'or' with Qt::TextWordWrap ??
	layoutVertical->addWidget( txtModuleLabel );
}