本文整理汇总了C++中QColor::lighter方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::lighter方法的具体用法?C++ QColor::lighter怎么用?C++ QColor::lighter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColor
的用法示例。
在下文中一共展示了QColor::lighter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintEvent
void SampleTCOView::paintEvent( QPaintEvent * _pe )
{
QPainter p( this );
const QColor styleColor = p.pen().brush().color();
QColor c;
if( !( m_tco->getTrack()->isMuted() || m_tco->isMuted() ) )
c = isSelected() ? QColor( 0, 0, 224 )
: styleColor;
else c = QColor( 80, 80, 80 );
QLinearGradient grad( 0, 0, 0, height() );
grad.setColorAt( 1, c.darker( 300 ) );
grad.setColorAt( 0, c );
p.setBrush( grad );
p.setPen( c.lighter( 160 ) );
p.drawRect( 1, 1, width()-3, height()-3 );
p.setBrush( QBrush() );
p.setPen( c.darker( 300 ) );
p.drawRect( 0, 0, width()-1, height()-1 );
if( m_tco->getTrack()->isMuted() || m_tco->isMuted() )
{
p.setPen( QColor( 128, 128, 128 ) );
}
else
{
p.setPen( fgColor() );
}
QRect r = QRect( 1, 1,
qMax( static_cast<int>( m_tco->sampleLength() *
pixelsPerTact() / DefaultTicksPerTact ), 1 ),
height() - 4 );
p.setClipRect( QRect( 1, 1, width() - 2, height() - 2 ) );
m_tco->m_sampleBuffer->visualize( p, r, _pe->rect() );
if( r.width() < width() - 1 )
{
p.drawLine( r.x() + r.width(), r.y() + r.height() / 2,
width() - 2, r.y() + r.height() / 2 );
}
p.translate( 0, 0 );
if( m_tco->isMuted() )
{
p.drawPixmap( 3, 8, embed::getIconPixmap( "muted", 16, 16 ) );
}
if( m_tco->isRecord() )
{
p.setFont( pointSize<7>( p.font() ) );
p.setPen( QColor( 0, 0, 0 ) );
p.drawText( 10, p.fontMetrics().height()+1, "Rec" );
p.setPen( textColor() );
p.drawText( 9, p.fontMetrics().height(), "Rec" );
p.setBrush( QBrush( textColor() ) );
p.drawEllipse( 4, 5, 4, 4 );
}
}
示例2: summary_label_palette
if (qobject_cast<QLineEdit*>(widget)) {
connect(widget, SIGNAL(textChanged(QString)), SLOT(FieldValueEdited()));
} else if (qobject_cast<QPlainTextEdit*>(widget)) {
connect(widget, SIGNAL(textChanged()), SLOT(FieldValueEdited()));
} else if (qobject_cast<QSpinBox*>(widget)) {
connect(widget, SIGNAL(valueChanged(int)), SLOT(FieldValueEdited()));
}
}
}
// Set the colour of all the labels on the summary page
const bool light = palette().color(QPalette::Base).value() > 128;
const QColor color = palette().color(QPalette::Dark);
QPalette summary_label_palette(palette());
summary_label_palette.setColor(QPalette::WindowText,
light ? color.darker(150) : color.lighter(125));
foreach (QLabel* label, ui_->summary_tab->findChildren<QLabel*>()) {
if (label->property("field_label").toBool()) {
label->setPalette(summary_label_palette);
}
}
// Pretend the summary text is just a label
ui_->summary->setMaximumHeight(ui_->art->height() - ui_->summary_art_button->height() - 4);
connect(ui_->song_list->selectionModel(),
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
SLOT(SelectionChanged()));
connect(ui_->button_box, SIGNAL(clicked(QAbstractButton*)),
SLOT(ButtonClicked(QAbstractButton*)));
示例3: paintEvent
void BBTCOView::paintEvent( QPaintEvent * )
{
QPainter p( this );
QColor col;
if( m_bbTCO->getTrack()->isMuted() || m_bbTCO->isMuted() )
{
col = QColor( 160, 160, 160 );
}
else if ( m_bbTCO->m_useStyleColor )
{
col = p.pen().brush().color();
}
else
{
col = m_bbTCO->colorObj();
}
if( isSelected() == true )
{
col.setRgb( qMax( col.red() - 128, 0 ), qMax( col.green() - 128, 0 ), 255 );
}
QLinearGradient lingrad( 0, 0, 0, height() );
lingrad.setColorAt( 0, col.light( 130 ) );
lingrad.setColorAt( 1, col.light( 70 ) );
p.fillRect( rect(), lingrad );
tact_t t = Engine::getBBTrackContainer()->lengthOfBB( m_bbTCO->bbTrackIndex() );
if( m_bbTCO->length() > MidiTime::ticksPerTact() && t > 0 )
{
for( int x = static_cast<int>( t * pixelsPerTact() );
x < width()-2;
x += static_cast<int>( t * pixelsPerTact() ) )
{
p.setPen( col.light( 80 ) );
p.drawLine( x, 1, x, 5 );
p.setPen( col.light( 120 ) );
p.drawLine( x, height() - 6, x, height() - 2 );
}
}
p.setPen( col.lighter( 130 ) );
p.drawRect( 1, 1, rect().right()-2, rect().bottom()-2 );
p.setPen( col.darker( 300 ) );
p.drawRect( 0, 0, rect().right(), rect().bottom() );
p.setFont( pointSize<8>( p.font() ) );
p.setPen( QColor( 0, 0, 0 ) );
p.drawText( 4, p.fontMetrics().height()+1, m_bbTCO->name() );
p.setPen( textColor() );
p.drawText( 3, p.fontMetrics().height(), m_bbTCO->name() );
if( m_bbTCO->isMuted() )
{
p.drawPixmap( 3, p.fontMetrics().height() + 1,
embed::getIconPixmap( "muted", 16, 16 ) );
}
}
示例4: paintEvent
void ProgressBar::paintEvent(QPaintEvent *)
{
// TODO move font into Utils::StyleHelper
// TODO use Utils::StyleHelper white
double range = maximum() - minimum();
double percent = 0.;
if (!qFuzzyIsNull(range))
percent = qBound(0., (value() - minimum()) / range, 1.);
if (finished())
percent = 1;
QPainter p(this);
QFont fnt(titleFont());
p.setFont(fnt);
QFontMetrics fm(fnt);
int titleHeight = m_titleVisible ? fm.height() : 0;
// Draw separator
int separatorHeight = m_separatorVisible ? SEPARATOR_HEIGHT : 0;
if (m_separatorVisible) {
QRectF innerRect = QRectF(this->rect()).adjusted(0.5, 0.5, -0.5, -0.5);
p.setPen(StyleHelper::sidebarShadow());
p.drawLine(innerRect.topLeft(), innerRect.topRight());
if (creatorTheme()->flag(Theme::DrawToolBarHighlights)) {
p.setPen(StyleHelper::sidebarHighlight());
p.drawLine(innerRect.topLeft() + QPointF(1, 1), innerRect.topRight() + QPointF(0, 1));
}
}
if (m_titleVisible) {
QRect textBounds = fm.boundingRect(m_title);
textBounds.moveCenter(rect().center());
int alignment = Qt::AlignHCenter;
int textSpace = rect().width() - 8;
// If there is not enough room when centered, we left align and
// elide the text
QString elidedtitle = fm.elidedText(m_title, Qt::ElideRight, textSpace);
QRect textRect = rect().adjusted(3, separatorHeight - 1, -3, 0);
textRect.setHeight(titleHeight+5);
p.setPen(QColor(0, 0, 0, 120));
p.drawText(textRect, alignment | Qt::AlignBottom, elidedtitle);
p.translate(0, -1);
p.setPen(creatorTheme()->color(Theme::ProgressBarTitleColor));
p.drawText(textRect, alignment | Qt::AlignBottom, elidedtitle);
p.translate(0, 1);
}
m_progressHeight = PROGRESSBAR_HEIGHT;
m_progressHeight += ((m_progressHeight % 2) + 1) % 2; // make odd
// draw outer rect
const QRect rect(INDENT - 1, titleHeight + separatorHeight + (m_titleVisible ? 5 : 4),
size().width() - 2 * INDENT + 1, m_progressHeight);
QRectF inner = rect.adjusted(2, 2, -2, -2);
inner.adjust(0, 0, qRound((percent - 1) * inner.width()), 0);
// Show at least a hint of progress. Non-flat needs more pixels due to the borders.
inner.setWidth(qMax(qMin(3.0, qreal(rect.width())), inner.width()));
Theme::Color themeColor = Theme::ProgressBarColorNormal;
if (m_error)
themeColor = Theme::ProgressBarColorError;
else if (m_finished)
themeColor = Theme::ProgressBarColorFinished;
const QColor c = creatorTheme()->color(themeColor);
//draw the progress bar
if (creatorTheme()->flag(Theme::FlatToolBars)) {
p.fillRect(rect.adjusted(2, 2, -2, -2),
creatorTheme()->color(Theme::ProgressBarBackgroundColor));
p.fillRect(inner, c);
} else {
const static QImage bar(StyleHelper::dpiSpecificImageFile(
QLatin1String(":/core/images/progressbar.png")));
StyleHelper::drawCornerImage(bar, &p, rect, 3, 3, 3, 3);
// Draw line and shadow after the gradient fill
if (value() > 0 && value() < maximum()) {
p.fillRect(QRect(inner.right(), inner.top(), 2, inner.height()), QColor(0, 0, 0, 20));
p.fillRect(QRect(inner.right(), inner.top(), 1, inner.height()), QColor(0, 0, 0, 60));
}
QLinearGradient grad(inner.topLeft(), inner.bottomLeft());
grad.setColorAt(0, c.lighter(130));
grad.setColorAt(0.4, c.lighter(106));
grad.setColorAt(0.41, c.darker(106));
grad.setColorAt(1, c.darker(130));
p.setPen(Qt::NoPen);
p.setBrush(grad);
p.drawRect(inner);
p.setBrush(Qt::NoBrush);
p.setPen(QPen(QColor(0, 0, 0, 30), 1));
//.........这里部分代码省略.........
示例5: summary_label_palette
EditTagDialog::EditTagDialog(Application* app, QWidget* parent)
: QDialog(parent),
ui_(new Ui_EditTagDialog),
app_(app),
album_cover_choice_controller_(new AlbumCoverChoiceController(this)),
loading_(false),
abortRequested_(false),
ignore_edits_(false),
tag_fetcher_(new TagFetcher(this)),
cover_art_id_(0),
cover_art_is_set_(false),
results_dialog_(new TrackSelectionDialog(this)) {
QIcon nocover = IconLoader::Load("nocover", IconLoader::Other);
cover_options_.default_output_image_ =
AlbumCoverLoader::ScaleAndPad(cover_options_,
nocover.pixmap(nocover.availableSizes().last())
.toImage());
connect(app_->album_cover_loader(),
SIGNAL(ImageLoaded(quint64, QImage, QImage)),
SLOT(ArtLoaded(quint64, QImage, QImage)));
connect(tag_fetcher_, SIGNAL(ResultAvailable(Song, SongList)),
results_dialog_, SLOT(FetchTagFinished(Song, SongList)),
Qt::QueuedConnection);
connect(tag_fetcher_, SIGNAL(Progress(Song, QString)), results_dialog_,
SLOT(FetchTagProgress(Song, QString)));
connect(results_dialog_, SIGNAL(SongChosen(Song, Song)),
SLOT(FetchTagSongChosen(Song, Song)));
connect(results_dialog_, SIGNAL(finished(int)), tag_fetcher_, SLOT(Cancel()));
album_cover_choice_controller_->SetApplication(app_);
ui_->setupUi(this);
ui_->splitter->setSizes(QList<int>() << 200 << width() - 200);
ui_->loading_label->hide();
ui_->fetch_tag->setIcon(IconLoader::Load("musicbrainz",
IconLoader::Provider));
// An editable field is one that has a label as a buddy. The label is
// important because it gets turned bold when the field is changed.
for (QLabel* label : findChildren<QLabel*>()) {
QWidget* widget = label->buddy();
if (widget) {
// Store information about the field
fields_ << FieldData(label, widget, widget->objectName());
// Connect the Reset signal
if (dynamic_cast<ExtendedEditor*>(widget)) {
connect(widget, SIGNAL(Reset()), SLOT(ResetField()));
}
// Connect the changed signal (emitted when value is changed
// programmatically or non-programmatically)
if (qobject_cast<QLineEdit*>(widget)) {
connect(widget, SIGNAL(textChanged(QString)), SLOT(FieldValueEdited()));
} else if (qobject_cast<QPlainTextEdit*>(widget)) {
connect(widget, SIGNAL(textChanged()), SLOT(FieldValueEdited()));
} else if (qobject_cast<QSpinBox*>(widget)) {
connect(widget, SIGNAL(valueChanged(int)), SLOT(FieldValueEdited()));
}
}
}
// Set the colour of all the labels on the summary page
const bool light = palette().color(QPalette::Base).value() > 128;
const QColor color = palette().color(QPalette::WindowText);
QPalette summary_label_palette(palette());
summary_label_palette.setColor(
QPalette::WindowText, light ? color.lighter(150) : color.darker(150));
for (QLabel* label : ui_->summary_tab->findChildren<QLabel*>()) {
if (label->property("field_label").toBool()) {
label->setPalette(summary_label_palette);
}
}
// Pretend the summary text is just a label
ui_->summary->setMaximumHeight(ui_->art->height() -
ui_->summary_art_button->height() - 4);
connect(ui_->song_list->selectionModel(),
SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
SLOT(SelectionChanged()));
connect(ui_->button_box, SIGNAL(clicked(QAbstractButton*)),
SLOT(ButtonClicked(QAbstractButton*)));
connect(ui_->rating, SIGNAL(RatingChanged(float)), SLOT(SongRated(float)));
connect(ui_->playcount_reset, SIGNAL(clicked()), SLOT(ResetPlayCounts()));
connect(ui_->fetch_tag, SIGNAL(clicked()), SLOT(FetchTag()));
connect(ui_->abortSaveButton, SIGNAL(clicked()), SLOT(abortSave()));
// Set up the album cover menu
cover_menu_ = new QMenu(this);
QList<QAction*> actions = album_cover_choice_controller_->GetAllActions();
connect(album_cover_choice_controller_->cover_from_file_action(),
SIGNAL(triggered()), this, SLOT(LoadCoverFromFile()));
connect(album_cover_choice_controller_->cover_to_file_action(),
SIGNAL(triggered()), this, SLOT(SaveCoverToFile()));
//.........这里部分代码省略.........
示例6: drawPrimitive
//.........这里部分代码省略.........
else
hover.setAlpha(50);
painter->setPen(QPen(hover, 1));
painter->drawRect(option->rect.adjusted(1, 1, -2 ,-2));
}
painter->restore();
}
break;
case PE_FrameStatusBarItem:
break;
case PE_PanelButtonTool: {
Animation *anim = d->animator.widgetAnimation(widget);
if (!animating && anim) {
anim->paint(painter, option);
} else {
bool pressed = option->state & State_Sunken || option->state & State_On;
QColor shadow(0, 0, 0, 30);
painter->setPen(shadow);
if (pressed) {
QColor shade(0, 0, 0, 40);
painter->fillRect(rect, shade);
painter->drawLine(rect.topLeft() + QPoint(1, 0), rect.topRight() - QPoint(1, 0));
painter->drawLine(rect.topLeft(), rect.bottomLeft());
painter->drawLine(rect.topRight(), rect.bottomRight());
// painter->drawLine(rect.bottomLeft() + QPoint(1, 0), rect.bottomRight() - QPoint(1, 0));
QColor highlight(255, 255, 255, 30);
painter->setPen(highlight);
}
else if (option->state & State_Enabled &&
option->state & State_MouseOver) {
QColor lighter(255, 255, 255, 37);
painter->fillRect(rect, lighter);
}
if (option->state & State_HasFocus && (option->state & State_KeyboardFocusChange)) {
QColor highlight = option->palette.highlight().color();
highlight.setAlphaF(0.4);
painter->setPen(QPen(highlight.lighter(), 1));
highlight.setAlphaF(0.3);
painter->setBrush(highlight);
painter->setRenderHint(QPainter::Antialiasing);
QRectF rect = option->rect;
rect.translate(0.5, 0.5);
painter->drawRoundedRect(rect.adjusted(2, 2, -3, -3), 2, 2);
}
}
}
break;
case PE_PanelStatusBar:
{
painter->save();
QLinearGradient grad(option->rect.topLeft(), QPoint(rect.center().x(), rect.bottom()));
QColor startColor = Utils::StyleHelper::shadowColor().darker(164);
QColor endColor = Utils::StyleHelper::baseColor().darker(130);
grad.setColorAt(0, startColor);
grad.setColorAt(1, endColor);
painter->fillRect(option->rect, grad);
painter->setPen(QColor(255, 255, 255, 60));
painter->drawLine(rect.topLeft() + QPoint(0,1),
rect.topRight()+ QPoint(0,1));
painter->setPen(Utils::StyleHelper::borderColor().darker(110));
painter->drawLine(rect.topLeft(), rect.topRight());
painter->restore();
示例7: paintEvent
void PatternView::paintEvent( QPaintEvent * )
{
if( m_needsUpdate == false )
{
QPainter p( this );
p.drawPixmap( 0, 0, m_paintPixmap );
return;
}
QPainter _p( this );
const QColor styleColor = _p.pen().brush().color();
m_pat->changeLength( m_pat->length() );
m_needsUpdate = false;
if( m_paintPixmap.isNull() == true || m_paintPixmap.size() != size() )
{
m_paintPixmap = QPixmap( size() );
}
QPainter p( &m_paintPixmap );
QLinearGradient lingrad( 0, 0, 0, height() );
QColor c;
if(( m_pat->m_patternType != Pattern::BeatPattern ) &&
!( m_pat->getTrack()->isMuted() || m_pat->isMuted() ))
{
c = styleColor;
}
else
{
c = QColor( 80, 80, 80 );
}
if( isSelected() == true )
{
c.setRgb( qMax( c.red() - 128, 0 ), qMax( c.green() - 128, 0 ), 255 );
}
if( m_pat->m_patternType != Pattern::BeatPattern )
{
lingrad.setColorAt( 1, c.darker( 300 ) );
lingrad.setColorAt( 0, c );
}
else
{
lingrad.setColorAt( 0, c.darker( 300 ) );
lingrad.setColorAt( 1, c );
}
p.setBrush( lingrad );
if( gui->pianoRoll()->currentPattern() == m_pat && m_pat->m_patternType != Pattern::BeatPattern )
p.setPen( c.lighter( 130 ) );
else
p.setPen( c.darker( 300 ) );
p.drawRect( QRect( 0, 0, width() - 1, height() - 1 ) );
p.setBrush( QBrush() );
if( m_pat->m_patternType != Pattern::BeatPattern )
{
if( gui->pianoRoll()->currentPattern() == m_pat )
p.setPen( c.lighter( 160 ) );
else
p.setPen( c.lighter( 130 ) );
p.drawRect( QRect( 1, 1, width() - 3, height() - 3 ) );
}
const float ppt = fixedTCOs() ?
( parentWidget()->width() - 2 * TCO_BORDER_WIDTH )
/ (float) m_pat->length().getTact() :
( width() - 2 * TCO_BORDER_WIDTH )
/ (float) m_pat->length().getTact();
const int x_base = TCO_BORDER_WIDTH;
p.setPen( c.darker( 300 ) );
for( tact_t t = 1; t < m_pat->length().getTact(); ++t )
{
p.drawLine( x_base + static_cast<int>( ppt * t ) - 1,
TCO_BORDER_WIDTH, x_base + static_cast<int>(
ppt * t ) - 1, 5 );
p.drawLine( x_base + static_cast<int>( ppt * t ) - 1,
height() - ( 4 + 2 * TCO_BORDER_WIDTH ),
x_base + static_cast<int>( ppt * t ) - 1,
height() - 2 * TCO_BORDER_WIDTH );
}
// melody pattern paint event
if( m_pat->m_patternType == Pattern::MelodyPattern )
{
if( m_pat->m_notes.size() > 0 )
{
// first determine the central tone so that we can
// display the area where most of the m_notes are
// also calculate min/max tones so the tonal range can be
// properly stretched accross the pattern vertically
//.........这里部分代码省略.........
示例8: gradient
void
PartitionBarsView::drawSection( QPainter* painter, const QRect& rect_, int x, int width, const QModelIndex& index )
{
QColor color = index.isValid() ?
index.data( Qt::DecorationRole ).value< QColor >() :
ColorUtils::unknownDisklabelColor();
bool isFreeSpace = index.isValid() ?
index.data( PartitionModel::IsFreeSpaceRole ).toBool() :
true;
QRect rect = rect_;
const int y = rect.y();
const int height = rect.height();
const int radius = qMax( 1, CORNER_RADIUS - ( VIEW_HEIGHT - height ) / 2 );
painter->setClipRect( x, y, width, height );
painter->translate( 0.5, 0.5 );
rect.adjust( 0, 0, -1, -1 );
if ( selectionMode() != QAbstractItemView::NoSelection && // no hover without selection
m_hoveredIndex.isValid() &&
index == m_hoveredIndex )
{
if ( canBeSelected( index ) )
painter->setBrush( color.lighter( 115 ) );
else
painter->setBrush( color );
}
else
{
painter->setBrush( color );
}
QColor borderColor = color.darker();
painter->setPen( borderColor );
painter->drawRoundedRect( rect, radius, radius );
// Draw shade
if ( !isFreeSpace )
rect.adjust( 2, 2, -2, -2 );
QLinearGradient gradient( 0, 0, 0, height / 2 );
qreal c = isFreeSpace ? 0 : 1;
gradient.setColorAt( 0, QColor::fromRgbF( c, c, c, 0.3 ) );
gradient.setColorAt( 1, QColor::fromRgbF( c, c, c, 0 ) );
painter->setPen( Qt::NoPen );
painter->setBrush( gradient );
painter->drawRoundedRect( rect, radius, radius );
if ( selectionMode() != QAbstractItemView::NoSelection &&
index.isValid() &&
selectionModel() &&
!selectionModel()->selectedIndexes().isEmpty() &&
selectionModel()->selectedIndexes().first() == index )
{
painter->setPen( QPen( borderColor, 1 ) );
QColor highlightColor = QPalette().highlight().color();
highlightColor = highlightColor.lighter( 500 );
highlightColor.setAlpha( 120 );
painter->setBrush( highlightColor );
QRect selectionRect = rect;
selectionRect.setX( x + 1 );
selectionRect.setWidth( width - 3 ); //account for the previous rect.adjust
if ( rect.x() > selectionRect.x() ) //hack for first item
selectionRect.adjust( rect.x() - selectionRect.x(), 0, 0, 0 );
if ( rect.right() < selectionRect.right() ) //hack for last item
selectionRect.adjust( 0, 0, - ( selectionRect.right() - rect.right() ), 0 );
selectionRect.adjust( SELECTION_MARGIN,
SELECTION_MARGIN,
-SELECTION_MARGIN,
-SELECTION_MARGIN );
painter->drawRoundedRect( selectionRect,
radius - 1,
radius - 1 );
}
painter->translate( -0.5, -0.5 );
}
示例9: drawControl
void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *option,
QPainter *painter, const QWidget *widget) const
{
if (!panelWidget(widget) && !qobject_cast<const QMenu *>(widget))
return QProxyStyle::drawControl(element, option, painter, widget);
switch (element) {
case CE_TabBarTabShape:
// Most styles draw a single dark outline. This looks rather ugly when combined with our
// single pixel dark separator so we adjust the first tab to compensate for this
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
QStyleOptionTab adjustedTab = *tab;
if (tab->cornerWidgets == QStyleOptionTab::NoCornerWidgets && (
tab->position == QStyleOptionTab::Beginning ||
tab->position == QStyleOptionTab::OnlyOneTab))
{
if (option->direction == Qt::LeftToRight)
adjustedTab.rect = adjustedTab.rect.adjusted(-1, 0, 0, 0);
else
adjustedTab.rect = adjustedTab.rect.adjusted(0, 0, 1 ,0);
}
QProxyStyle::drawControl(element, &adjustedTab, painter, widget);
return;
}
break;
case CE_MenuItem:
painter->save();
if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
const bool enabled = mbi->state & State_Enabled;
QStyleOptionMenuItem item = *mbi;
item.rect = mbi->rect;
const QColor color = creatorTheme()->color(enabled
? Theme::MenuItemTextColorNormal
: Theme::MenuItemTextColorDisabled);
if (color.isValid()) {
QPalette pal = mbi->palette;
pal.setBrush(QPalette::Text, color);
item.palette = pal;
}
QProxyStyle::drawControl(element, &item, painter, widget);
}
painter->restore();
break;
case CE_MenuBarItem:
painter->save();
if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
const bool act = mbi->state & (State_Sunken | State_Selected);
const bool dis = !(mbi->state & State_Enabled);
if (creatorTheme()->widgetStyle() == Theme::StyleFlat)
painter->fillRect(option->rect, creatorTheme()->color(Theme::MenuBarItemBackgroundColor));
else
StyleHelper::menuGradient(painter, option->rect, option->rect);
QStyleOptionMenuItem item = *mbi;
item.rect = mbi->rect;
QPalette pal = mbi->palette;
pal.setBrush(QPalette::ButtonText, dis
? creatorTheme()->color(Theme::MenuBarItemTextColorDisabled)
: creatorTheme()->color(Theme::MenuBarItemTextColorNormal));
item.palette = pal;
QCommonStyle::drawControl(element, &item, painter, widget);
if (act) {
// Fill|
QColor baseColor = StyleHelper::baseColor();
QLinearGradient grad(option->rect.topLeft(), option->rect.bottomLeft());
grad.setColorAt(0, baseColor.lighter(120));
grad.setColorAt(1, baseColor.lighter(130));
painter->fillRect(option->rect, grad);
QPalette pal = mbi->palette;
uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
if (!styleHint(SH_UnderlineShortcut, mbi, widget))
alignment |= Qt::TextHideMnemonic;
pal.setBrush(QPalette::Text, dis ? Qt::gray : QColor(0, 0, 0, 60));
drawItemText(painter, item.rect.translated(0, 1), alignment, pal, mbi->state & State_Enabled, mbi->text, QPalette::Text);
pal.setBrush(QPalette::Text, dis ? Qt::gray : Qt::white);
drawItemText(painter, item.rect, alignment, pal, mbi->state & State_Enabled, mbi->text, QPalette::Text);
}
}
painter->restore();
break;
case CE_ComboBoxLabel:
if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
if (panelWidget(widget)) {
painter->save();
QRect editRect = subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget);
QPalette customPal = cb->palette;
bool drawIcon = !(widget && widget->property("hideicon").toBool());
if (!cb->currentIcon.isNull() && drawIcon) {
QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal
: QIcon::Disabled;
QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode);
QRect iconRect(editRect);
//.........这里部分代码省略.........
示例10: renderFullTree
void renderFullTree(QPaintDevice *paintdev, SketchXMLHandler* XMLHandlr,
QColor LineColor, std::uint16_t BaseFontSize, std::string SelectedGUID,
double Width, double Height, double PermaScale, double ScaleFactor, double PanX, double PanY,
QTransform *paintTransform = nullptr) {
QPainter paint(paintdev);
paint.resetTransform();
paint.translate(double(Width/2) + (PanX * ScaleFactor), double(Height/2) + (PanY * ScaleFactor));
paint.scale(PermaScale * Width * ScaleFactor, PermaScale * Width * ScaleFactor);
if (paintTransform != nullptr)
*paintTransform = paint.worldTransform();
paint.setRenderHint(QPainter::Antialiasing, true);
paint.setRenderHint(QPainter::TextAntialiasing, true);
paint.setRenderHint(QPainter::SmoothPixmapTransform, true);
QPen linepen (LineColor);
linepen.setWidth(5);
paint.setPen(linepen);
std::for_each(XMLHandlr->nodelinkmap.begin(), XMLHandlr->nodelinkmap.end(),
[&](std::pair<std::string, std::vector<std::string>> block) {
FlowNode fnparent = XMLHandlr->OrphanNodes[block.first];
std::for_each(block.second.begin(), block.second.end(), [&](std::string child) {
FlowNode fnchild = XMLHandlr->OrphanNodes[child];
if ((fnchild.Type == NodeType::NONE) || (fnparent.Type == NodeType::NONE))
return;
paint.drawLine(fnparent.CenterPosX, fnparent.CenterPosY,
fnchild.CenterPosX, fnchild.CenterPosY);
});
});
std::for_each(XMLHandlr->OrphanNodes.begin(), XMLHandlr->OrphanNodes.end(),
[&](std::pair<std::string, FlowNode> nodepair) {
if (nodepair.second.Type == NodeType::NONE)
return;
QFont basefont = QFont("sans-serif", BaseFontSize*nodepair.second.FontSizeMult);
QFont titlefont = QFont("sans-serif", BaseFontSize*nodepair.second.FontSizeMult*1.5);
NodeSize ns = getNodeSize(basefont, titlefont, nodepair.second);
int rectoriginx = nodepair.second.CenterPosX - (ns.Width/2);
int rectoriginy = nodepair.second.CenterPosY - (ns.Height/2);
QColor PrimColor = QColor(nodepair.second.ColorRGBA[0],
nodepair.second.ColorRGBA[1],
nodepair.second.ColorRGBA[2],
nodepair.second.ColorRGBA[3]);
paint.fillRect(rectoriginx, rectoriginy, ns.Width, ns.Height, PrimColor);
QColor SecColor;
if (PrimColor.toHsl().lightness() > 256)
SecColor = PrimColor.lighter(200);
else
SecColor = PrimColor.darker(300);
QPen textpen (SecColor);
textpen.setWidth(3);
paint.setPen(textpen);
paint.drawRect(rectoriginx, rectoriginy, ns.Width, ns.Height);
paint.setFont(titlefont);
paint.drawText(rectoriginx + BlockPadding, rectoriginy + BlockPadding,
ns.Width - (BlockPadding*2), ns.TitleBoundBox.height(),
Qt::AlignCenter, QString(nodepair.second.Title.c_str()));
paint.setFont(basefont);
paint.drawText(nodepair.second.CenterPosX - (ns.DescBoundBox.width()/2),
rectoriginy + BlockPadding + ns.TitleBoundBox.height() + BlockPadding,
ns.DescBoundBox.width(), ns.DescBoundBox.height(),
Qt::AlignCenter | Qt::TextWordWrap,
QString(nodepair.second.Desc.c_str()));
if (nodepair.second.GUID == SelectedGUID) {
//Edge blocks
paint.fillRect(rectoriginx + ns.Width - GripWidth/2, rectoriginy - GripWidth/2,
GripWidth, GripWidth,
Qt::black);
paint.fillRect(rectoriginx + ns.Width + 2 - GripWidth/2, rectoriginy + 2 - GripWidth/2,
GripWidth-4, GripWidth-4,
Qt::white);
}
});
paint.end();
}
示例11: buildStyleSheet
/**
* @brief Builds stylesheet for this WorkAreaTabBar widget.
*/
QString WorkAreaTabBar::buildStyleSheet()
{
QColor background = palette().window().color();
QColor gradientZero = QColor("#ffffff");//Qt::white;//.lighter(103);
QColor gradientOne = background.lighter(104);//Qt::white;//.lighter(103);
QColor gradientTwo = background.lighter(108);//.lighter(103);
QColor selectedBorder = background.darker(103);
QString aga1 = gradientOne.name();
QString aga2 = gradientTwo.name();
QString aga3 = background.name();
QString styles = QString(
"QTabBar::tab:first {"
"margin-left: 4px;"
"} "
"QTabBar::tab:last {"
"margin-right: 1px;"
"} "
"QTabBar::close-button { "
"image: url(:/robomongo/icons/close_2_16x16.png);"
"width: 10px;"
"height: 10px;"
"}"
"QTabBar::close-button:hover { "
"image: url(:/robomongo/icons/close_hover_16x16.png);"
"width: 15px;"
"height: 15px;"
"}"
"QTabBar::tab {"
"background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
"stop: 0 #F0F0F0, stop: 0.4 #DEDEDE,"
"stop: 0.5 #E6E6E6, stop: 1.0 #E1E1E1);"
"border: 1px solid #C4C4C3;"
"border-bottom-color: #B8B7B6;" // #C2C7CB same as the pane color
"border-top-left-radius: 6px;"
"border-top-right-radius: 6px;"
// "min-width: 8ex;"
"max-width: 200px;"
"padding: 4px 0px 5px 0px;"
"margin: 0px;"
"margin-left: 1px;"
"margin-right: -3px;" // it should be -(tab:first:margin-left + tab:last:margin-left) to fix incorrect text elidement
"}"
"QTabBar::tab:selected, QTabBar::tab:hover {"
"background: qlineargradient(x1: 0, y1: 1, x2: 0, y2: 0,"
"stop: 0 %1, stop: 0.3 %2," //#fafafa, #f4f4f4
"stop: 0.6 %3, stop: 1.0 %4);" //#e7e7e7, #fafafa
"}"
"QTabBar::tab:selected {"
"border-color: #9B9B9B;" //
"border-bottom-color: %4;" //#fafafa
"}"
"QTabBar::tab:!selected {"
"margin-top: 2px;" // make non-selected tabs look smaller
"} "
"QTabBar::tab:only-one { margin-top: 2px; margin-left:4px; }"
).arg(gradientZero.name(), gradientOne.name(), gradientTwo.name(), "#ffffff");
QString aga = palette().window().color().name();
return styles;
}
示例12: paintLineIndicator
void GenericCodeEditor::paintLineIndicator( QPaintEvent *e )
{
QPalette plt( mLineIndicator->palette() );
QRect r( e->rect() );
QPainter p( mLineIndicator );
p.fillRect( r, plt.color( QPalette::Mid ) );
p.setPen( plt.color(QPalette::Dark) );
p.drawLine( r.topRight(), r.bottomRight() );
p.setPen( plt.color(QPalette::ButtonText) );
QTextDocument *doc = QPlainTextEdit::document();
QTextCursor cursor(textCursor());
int selStartBlock, selEndBlock;
if (cursor.hasSelection()) {
selStartBlock = doc->findBlock(cursor.selectionStart()).blockNumber();
selEndBlock = doc->findBlock(cursor.selectionEnd()).blockNumber();
}
else
selStartBlock = selEndBlock = -1;
QTextBlock block = firstVisibleBlock();
int blockNumber = block.blockNumber();
qreal top = blockBoundingGeometry(block).translated(contentOffset()).top();
qreal bottom = top + blockBoundingRect(block).height();
while (block.isValid() && top <= e->rect().bottom()) {
if (block.isVisible() && bottom >= e->rect().top()) {
p.save();
QRectF numRect( 0, top, mLineIndicator->width() - 1, bottom - top );
int num = blockNumber;
if (num >= selStartBlock && num <= selEndBlock) {
num -= selStartBlock;
p.setPen(Qt::NoPen);
p.setBrush(plt.color(QPalette::Highlight));
p.drawRect(numRect);
p.setPen(plt.color(QPalette::HighlightedText));
}
QString number = QString::number(num + 1);
p.drawText(0, top, mLineIndicator->width() - 4, bottom - top,
Qt::AlignRight, number);
p.restore();
}
block = block.next();
top = bottom;
bottom = top + blockBoundingRect(block).height();
++blockNumber;
}
if(!mEditorBoxIsActive) {
QColor color = plt.color(QPalette::Mid);
if(color.lightness() >= 128)
color = color.darker(60);
else
color = color.lighter(50);
color.setAlpha(inactiveFadeAlpha());
p.fillRect( r, color );
}
}
示例13: paintEvent
void BBTCOView::paintEvent( QPaintEvent * )
{
QPainter painter( this );
if( !needsUpdate() )
{
painter.drawPixmap( 0, 0, m_paintPixmap );
return;
}
setNeedsUpdate( false );
m_paintPixmap = m_paintPixmap.isNull() == true || m_paintPixmap.size() != size()
? QPixmap( size() ) : m_paintPixmap;
QPainter p( &m_paintPixmap );
QLinearGradient lingrad( 0, 0, 0, height() );
QColor c;
bool muted = m_bbTCO->getTrack()->isMuted() || m_bbTCO->isMuted();
// state: selected, muted, default, user selected
c = isSelected() ? selectedColor() : ( muted ? mutedBackgroundColor()
: ( m_bbTCO->m_useStyleColor ? painter.background().color()
: m_bbTCO->colorObj() ) );
lingrad.setColorAt( 0, c.light( 130 ) );
lingrad.setColorAt( 1, c.light( 70 ) );
if( gradient() )
{
p.fillRect( rect(), lingrad );
}
else
{
p.fillRect( rect(), c );
}
// bar lines
const int lineSize = 3;
p.setPen( c.darker( 200 ) );
tact_t t = Engine::getBBTrackContainer()->lengthOfBB( m_bbTCO->bbTrackIndex() );
if( m_bbTCO->length() > MidiTime::ticksPerTact() && t > 0 )
{
for( int x = static_cast<int>( t * pixelsPerTact() );
x < width() - 2;
x += static_cast<int>( t * pixelsPerTact() ) )
{
p.drawLine( x, TCO_BORDER_WIDTH, x, TCO_BORDER_WIDTH + lineSize );
p.drawLine( x, rect().bottom() - ( TCO_BORDER_WIDTH + lineSize ),
x, rect().bottom() - TCO_BORDER_WIDTH );
}
}
// pattern name
p.setRenderHint( QPainter::TextAntialiasing );
if( m_staticTextName.text() != m_bbTCO->name() )
{
m_staticTextName.setText( m_bbTCO->name() );
}
QFont font;
font.setHintingPreference( QFont::PreferFullHinting );
font.setPointSize( 8 );
p.setFont( font );
const int textTop = TCO_BORDER_WIDTH + 1;
const int textLeft = TCO_BORDER_WIDTH + 1;
p.setPen( textShadowColor() );
p.drawStaticText( textLeft + 1, textTop + 1, m_staticTextName );
p.setPen( textColor() );
p.drawStaticText( textLeft, textTop, m_staticTextName );
// inner border
p.setPen( c.lighter( 130 ) );
p.drawRect( 1, 1, rect().right() - TCO_BORDER_WIDTH,
rect().bottom() - TCO_BORDER_WIDTH );
// outer border
p.setPen( c.darker( 300 ) );
p.drawRect( 0, 0, rect().right(), rect().bottom() );
// draw the 'muted' pixmap only if the pattern was manualy muted
if( m_bbTCO->isMuted() )
{
const int spacing = TCO_BORDER_WIDTH;
const int size = 14;
p.drawPixmap( spacing, height() - ( size + spacing ),
embed::getIconPixmap( "muted", size, size ) );
}
p.end();
painter.drawPixmap( 0, 0, m_paintPixmap );
}
示例14: optimizeColors
void Widget::optimizeColors(int polyIndex, QImage& predrawn)
{
/*
// Find the poly's bounding box
int minx,miny,maxx,maxy;
minx = maxx = poly.points[0].x();
miny = maxy = poly.points[0].y();
for (QPoint point : poly.points)
{
minx = min(minx, point.x());
maxx = max(maxx, point.x());
miny = min(miny, point.y());
maxy = max(maxy, point.y());
}
QRect box(minx, miny, maxx-minx, maxy-miny);
*/
int polysSize = polys.size();
Poly& poly = polys[polyIndex];
static QBrush brush(Qt::SolidPattern);
int processEventsRatelimit = 0;
// Check if the pic is better, commit and return if it is
auto validate = [&]()
{
QImage newGen = predrawn;
QPainter painter(&newGen);
painter.setPen(QPen(Qt::NoPen));
for (int i=polyIndex; i<polysSize; ++i)
{
brush.setColor(polys[i].color);
painter.setBrush(brush);
painter.drawPolygon(polys[i].points.data(), polys[i].points.size());
}
quint64 newFit = computeFitness(newGen);
generation++;
ui->generationLabel->setNum(generation);
if (newFit < fitness)
{
// Update data
generated = newGen;
fitness = newFit;
// Update GUI
if (processEventsRatelimit==0)
{
ui->imgBest->setPixmap(QPixmap::fromImage(generated));
updateGuiFitness();
}
return true;
}
else
return false;
};
app->processEvents();
int targetColor;
for (targetColor=0; targetColor <= 8; targetColor++)
{
do
{
if (processEventsRatelimit == GUI_REFRESH_RATE) // processEvents is a massive slowdown
{
processEventsRatelimit=0;
app->processEvents();
}
else
processEventsRatelimit++;
QColor color = poly.color;
if (targetColor == 0)
color = color.lighter(110); // Lighter
else if (targetColor == 1)
color = color.darker(110); // Darker
else if (targetColor == 2)
color.setRed(min(color.red()+N_COLOR_VAR,255)); // More red
else if (targetColor == 3)
color.setBlue(max(color.blue()-N_COLOR_VAR,0)); // Less blue
else if (targetColor == 4)
color.setGreen(min(color.green()+N_COLOR_VAR,255)); // More green
else if (targetColor == 5)
color.setRed(max(color.red()-N_COLOR_VAR,0)); // Less red
else if (targetColor == 6)
color.setBlue(min(color.blue()+N_COLOR_VAR,255)); // More blue
else if (targetColor == 7)
color.setGreen(max(color.green()-N_COLOR_VAR,0)); // Less green
else if (targetColor == 8)
color.setAlpha(max(color.alpha()-N_COLOR_VAR,0)); // Less alpha
else if (targetColor == 9 && OPT_INCREASE_ALPHA)
color.setAlpha(min(color.alpha()+N_COLOR_VAR,255)); // More alpha
poly.color = color;
} while (validate());
}
app->processEvents();
}
示例15: paintEvent
void HLed::paintEvent(QPaintEvent * /*event*/)
{
int width = ledWidth();
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
QColor color = m_d->isOn ? m_d->color
: m_d->color.darker(m_d->darkerFactor);
QBrush brush;
brush.setStyle(Qt::SolidPattern);
brush.setColor(color);
painter.setBrush(brush);
// draw plain
painter.drawEllipse(1, 1, width-1, width-1);
QPen pen;
pen.setWidth(2);
int pos = width / 5 + 1;
int lightWidth = width * 2 / 3;
int lightQuote = 130 * 2 / (lightWidth ? lightWidth : 1) + 100;
// draw bright spot
while (lightWidth) {
color = color.lighter(lightQuote);
pen.setColor(color);
painter.setPen(pen);
painter.drawEllipse(pos, pos, lightWidth, lightWidth);
lightWidth--;
if (!lightWidth)
break;
painter.drawEllipse(pos, pos, lightWidth, lightWidth);
lightWidth--;
if (!lightWidth)
break;
painter.drawEllipse(pos, pos, lightWidth, lightWidth);
pos++;
lightWidth--;
}
//draw border
painter.setBrush(Qt::NoBrush);
int angle = -720;
color = palette().color(QPalette::Light);
for (int arc=120; arc<2880; arc+=240) {
pen.setColor(color);
painter.setPen(pen);
int w = width - pen.width()/2;
painter.drawArc(pen.width()/2, pen.width()/2, w, w, angle+arc, 240);
painter.drawArc(pen.width()/2, pen.width()/2, w, w, angle-arc, 240);
color = color.darker(110);
}
}