void EscapeDialog::paintEvent(QPaintEvent* e)
{
   QColor backgroundColor = palette().light().color();
    backgroundColor.setAlpha(50);
    QPainter customPainter(this);
    customPainter.fillRect(rect(), backgroundColor);
}
Beispiel #2
0
 virtual void paintEvent(QPaintEvent* /*event*/)
 {
    QColor backgroundColor = palette().light().color();
    backgroundColor.setAlpha(200);
    QPainter customPainter(this);
    customPainter.fillRect(rect(),backgroundColor);
 }
Beispiel #3
0
void AutoCompletion::paintEvent(QPaintEvent* event)
{
   QPainter customPainter(this);
   customPainter.setOpacity(0.1);
   customPainter.setPen(Qt::NoPen);
   customPainter.setRenderHint(QPainter::Antialiasing, true);
   customPainter.setBrush(QBrush(brightOrDarkBase()?Qt::black:Qt::white));
   customPainter.drawRoundedRect(0,0,width(),height(),10,10);
   QWidget::paintEvent(event);
}
Beispiel #4
0
///How to paint
void TranslucentButtons::paintEvent(QPaintEvent* event)
{
   Q_UNUSED(event)
   QPainter customPainter(this);
   customPainter.setBackground(m_CurrentColor);
   customPainter.setBrush(m_CurrentColor);
   customPainter.setPen(Qt::NoPen);
   customPainter.drawRoundedRect(rect(), 10, 10);
   customPainter.setPen(m_Pen);

   if (m_pImg) {
      customPainter.drawImage(QRect(QPoint(rect().x()+rect().width()-50,10),QSize(40,rect().height()-20)),*m_pImg, QRectF(m_pImg->rect()));
   }

   QFont font = customPainter.font();
   font.setBold(true);
   customPainter.setFont(font);
   customPainter.drawText (rect(), Qt::AlignVCenter|Qt::AlignHCenter, text().replace("&","") );
}
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;
}