void StatusBarMessageLabel::paintEvent(QPaintEvent*) { QPainter painter(this); // draw background QColor backgroundColor; if (m_state == Default || m_illumination < 0) backgroundColor = palette().window().color(); else { backgroundColor = KStatefulBrush(KColorScheme::Window, KColorScheme::NegativeBackground, KSharedConfig::openConfig(KdenliveSettings::colortheme())).brush(this).color(); } if (m_state == Desaturate && m_illumination > 0) { backgroundColor.setAlpha(qMin(m_illumination * 2, 255)); } painter.fillRect(0, 0, width(), height(), backgroundColor); // draw pixmap int x = BorderGap; int y = (height() - m_pixmap.height()) / 2; if (!m_pixmap.isNull()) { painter.drawPixmap(x, y, m_pixmap); x += m_pixmap.width() + BorderGap * 2; } // draw text painter.setPen(palette().text().color()); int flags = Qt::AlignVCenter; if (height() > m_minTextHeight) { flags = flags | Qt::TextWordWrap; } painter.drawText(QRect(x, 0, availableTextWidth(), height()), flags, m_currentMessage.text); painter.end(); }
SmallRuler::SmallRuler(MonitorManager *manager, QWidget *parent) : QWidget(parent) ,m_cursorFramePosition(0) ,m_scale(1) ,m_maxval(25) ,m_manager(manager) ,m_overCursor(false) { m_zoneStart = 10; m_zoneEnd = 60; KSharedConfigPtr config = KSharedConfig::openConfig(KdenliveSettings::colortheme()); m_zoneBrush = KStatefulBrush(KColorScheme::View, KColorScheme::PositiveBackground, config); setMouseTracking(true); setMinimumHeight(10); }
QVariant KDEPixmapManipulation::contactPhoto(Contact* c, const QSize& size, bool displayPresence) { const QString hash = QString("photo2%1%2%3").arg(size.width()).arg(size.height()).arg(c->isPresent()); QVariant preRendered = c->property(hash.toAscii()); if (preRendered.isValid()) return preRendered; else connect(c,SIGNAL(rebased(Contact*)),this,SLOT(clearCache())); const int radius = (size.height() > 35) ? 7 : 5; const QPixmap* pxmPtr = c->photo(); bool isTracked = displayPresence && c->isTracked(); bool isPresent = displayPresence && c->isPresent(); static QColor presentBrush = KStatefulBrush( KColorScheme::Window, KColorScheme::PositiveText ).brush(QPalette::Normal).color(); static QColor awayBrush = KStatefulBrush( KColorScheme::Window, KColorScheme::NegativeText ).brush(QPalette::Normal).color(); QPixmap pxm; if (pxmPtr) { QPixmap contactPhoto(pxmPtr->scaledToWidth(size.height()-6)); pxm = QPixmap(size); pxm.fill(Qt::transparent); QPainter painter(&pxm); //Clear the pixmap painter.setCompositionMode(QPainter::CompositionMode_Clear); painter.fillRect(0,0,size.width(),size.height(),QBrush(Qt::white)); painter.setCompositionMode(QPainter::CompositionMode_SourceOver); //Add corner radius to the Pixmap QRect pxRect = contactPhoto.rect(); QBitmap mask(pxRect.size()); QPainter customPainter(&mask); customPainter.setRenderHint (QPainter::Antialiasing, true ); customPainter.fillRect (pxRect , Qt::white ); customPainter.setBackground (Qt::black ); customPainter.setBrush (Qt::black ); customPainter.drawRoundedRect(pxRect,radius,radius); contactPhoto.setMask(mask); painter.drawPixmap(3,3,contactPhoto); painter.setBrush(Qt::NoBrush); QPen pen(QApplication::palette().color(QPalette::Disabled,QPalette::Text)); pen.setWidth(isTracked?1:2); painter.setPen(pen); painter.setRenderHint (QPainter::Antialiasing, true ); painter.drawRoundedRect(3,3,pxm.height()-6,pxm.height()-6,radius,radius); //Draw the glow around pixmaps if (isTracked) { if (isPresent) pen.setColor(presentBrush); else pen.setColor(awayBrush); for (int i=2;i<=7;i+=2) { pen.setWidth(i); painter.setPen(pen); painter.setOpacity(0.3f-(((i-2)*0.8f)/10.0f)); painter.drawRoundedRect(3,3,pxm.height()-6,pxm.height()-6,radius,radius); } } } else { pxm = drawDefaultUserPixmap(size,isTracked,isPresent); } c->setProperty(hash.toAscii(),pxm); return pxm; }
QColor ColorScheme::border() const { return KStatefulBrush(KColorScheme::View, KColorScheme::NormalText) .brush(QPalette::Active).color(); }
QColor ColorScheme::foreground() const { return KStatefulBrush(KColorScheme::Tooltip, KColorScheme::NormalText) .brush(QPalette::Active).color(); }
void SmallRuler::updatePalette() { KSharedConfigPtr config = KSharedConfig::openConfig(KdenliveSettings::colortheme()); m_zoneBrush = KStatefulBrush(KColorScheme::View, KColorScheme::PositiveBackground, config); updatePixmap(); }