VirtualBox

Changeset 74082 in vbox for trunk


Ignore:
Timestamp:
Sep 5, 2018 12:51:57 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: VirtualBox Manager UI: Details pane re-styling: Move painting stuff to appropriate place.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager/details
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsElement.cpp

    r74081 r74082  
    756756    pPainter->restore();
    757757}
     758
     759/* static */
     760void UIDetailsElement::configurePainterShape(QPainter *pPainter,
     761                                          const QStyleOptionGraphicsItem *pOptions,
     762                                          int iRadius)
     763{
     764    /* Rounded corners? */
     765    if (iRadius)
     766    {
     767        /* Setup clipping: */
     768        QPainterPath roundedPath;
     769        roundedPath.addRoundedRect(pOptions->rect, iRadius, iRadius);
     770        pPainter->setRenderHint(QPainter::Antialiasing);
     771        pPainter->setClipPath(roundedPath);
     772    }
     773}
     774
     775/* static */
     776void UIDetailsElement::paintFrameRect(QPainter *pPainter, const QRect &rect, int iRadius)
     777{
     778    pPainter->save();
     779    QPalette pal = QApplication::palette();
     780    QColor base = pal.color(QPalette::Active, QPalette::Window);
     781    pPainter->setPen(base.darker(160));
     782    if (iRadius)
     783        pPainter->drawRoundedRect(rect, iRadius, iRadius);
     784    else
     785        pPainter->drawRect(rect);
     786    pPainter->restore();
     787}
     788
     789/* static */
     790void UIDetailsElement::paintPixmap(QPainter *pPainter, const QRect &rect, const QPixmap &pixmap)
     791{
     792    pPainter->drawPixmap(rect, pixmap);
     793}
     794
     795/* static */
     796void UIDetailsElement::paintText(QPainter *pPainter, QPoint point,
     797                              const QFont &font, QPaintDevice *pPaintDevice,
     798                              const QString &strText, const QColor &color)
     799{
     800    /* Prepare variables: */
     801    QFontMetrics fm(font, pPaintDevice);
     802    point += QPoint(0, fm.ascent());
     803
     804    /* Draw text: */
     805    pPainter->save();
     806    pPainter->setFont(font);
     807    pPainter->setPen(color);
     808    pPainter->drawText(point, strText);
     809    pPainter->restore();
     810}
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsElement.h

    r74081 r74082  
    283283        /** Paints background using specified @a pPainter and certain @a pOptions. */
    284284        void paintBackground(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions);
     285
     286        /** Configures painting shape using passed @a pPainter, @a pOptions and spified @a iRadius. */
     287        static void configurePainterShape(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions, int iRadius);
     288        /** Paints frame @a rect using passed @a pPainter and spified @a iRadius. */
     289        static void paintFrameRect(QPainter *pPainter, const QRect &rect, int iRadius);
     290        /** Paints @a pixmap using passed @a pPainter and spified @a rect. */
     291        static void paintPixmap(QPainter *pPainter, const QRect &rect, const QPixmap &pixmap);
     292        /** Paints @a strText using passed @a pPainter, @a font, @a color, @a pPaintDevice and spified @a point. */
     293        static void paintText(QPainter *pPainter, QPoint point,
     294                              const QFont &font, QPaintDevice *pPaintDevice,
     295                              const QString &strText, const QColor &color);
    285296    /** @} */
    286297
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsItem.cpp

    r74042 r74082  
    276276}
    277277
    278 /* static */
    279 void UIDetailsItem::configurePainterShape(QPainter *pPainter,
    280                                           const QStyleOptionGraphicsItem *pOptions,
    281                                           int iRadius)
    282 {
    283     /* Rounded corners? */
    284     if (iRadius)
    285     {
    286         /* Setup clipping: */
    287         QPainterPath roundedPath;
    288         roundedPath.addRoundedRect(pOptions->rect, iRadius, iRadius);
    289         pPainter->setRenderHint(QPainter::Antialiasing);
    290         pPainter->setClipPath(roundedPath);
    291     }
    292 }
    293 
    294 /* static */
    295 void UIDetailsItem::paintFrameRect(QPainter *pPainter, const QRect &rect, int iRadius)
    296 {
    297     pPainter->save();
    298     QPalette pal = QApplication::palette();
    299     QColor base = pal.color(QPalette::Active, QPalette::Window);
    300     pPainter->setPen(base.darker(160));
    301     if (iRadius)
    302         pPainter->drawRoundedRect(rect, iRadius, iRadius);
    303     else
    304         pPainter->drawRect(rect);
    305     pPainter->restore();
    306 }
    307 
    308 /* static */
    309 void UIDetailsItem::paintPixmap(QPainter *pPainter, const QRect &rect, const QPixmap &pixmap)
    310 {
    311     pPainter->drawPixmap(rect, pixmap);
    312 }
    313 
    314 /* static */
    315 void UIDetailsItem::paintText(QPainter *pPainter, QPoint point,
    316                               const QFont &font, QPaintDevice *pPaintDevice,
    317                               const QString &strText, const QColor &color)
    318 {
    319     /* Prepare variables: */
    320     QFontMetrics fm(font, pPaintDevice);
    321     point += QPoint(0, fm.ascent());
    322 
    323     /* Draw text: */
    324     pPainter->save();
    325     pPainter->setFont(font);
    326     pPainter->setPen(color);
    327     pPainter->drawText(point, strText);
    328     pPainter->restore();
    329 }
    330 
    331278
    332279/*********************************************************************************************************************************
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsItem.h

    r74042 r74082  
    137137    /** @} */
    138138
    139     /** @name Painting stuff.
    140       * @{ */
    141         /** Configures painting shape using passed @a pPainter, @a pOptions and spified @a iRadius. */
    142         static void configurePainterShape(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions, int iRadius);
    143         /** Paints frame @a rect using passed @a pPainter and spified @a iRadius. */
    144         static void paintFrameRect(QPainter *pPainter, const QRect &rect, int iRadius);
    145         /** Paints @a pixmap using passed @a pPainter and spified @a rect. */
    146         static void paintPixmap(QPainter *pPainter, const QRect &rect, const QPixmap &pixmap);
    147         /** Paints @a strText using passed @a pPainter, @a font, @a color, @a pPaintDevice and spified @a point. */
    148         static void paintText(QPainter *pPainter, QPoint point,
    149                               const QFont &font, QPaintDevice *pPaintDevice,
    150                               const QString &strText, const QColor &color);
    151     /** @} */
    152 
    153139private:
    154140
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette