/*virtual*/ bool ChoiceFilter::eventFilter(QObject *obj, QEvent *event) { QPalette palette; QLabel *label; if (event->type() == QEvent::Enter) { label = qobject_cast<QLabel*>(obj); palette = label->palette(); this->usualColor = palette.color(QPalette::Text); palette.setColor(label->foregroundRole(), QColor(Qt::cyan)); label->setPalette(palette); return true; } if (event->type() == QEvent::Leave) { label = qobject_cast<QLabel*>(obj); palette = label->palette(); palette.setColor(label->foregroundRole(), this->usualColor); label->setPalette(palette); return true; } return false; }
/** * 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(); }
/** 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); }
void CertificateDisplayDialog::setLabelStatus(QLabel& l, bool ok) { QPalette palette; palette.setColor(l.foregroundRole(), ok ? QColor("#2A993B") : QColor("#810000")); l.setPalette(palette); }