VirtualBox

Changeset 8568 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
May 5, 2008 12:24:08 PM (17 years ago)
Author:
vboxsync
Message:

FE/Qt4-OSX: Added extra base classes for the styling of the ListView in Leopard.

Location:
trunk/src/VBox/Frontends/VirtualBox4
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox4/Makefile.kmk

    r8556 r8568  
    413413        include/QIAbstractWizard.h \
    414414        include/QIAbstractDialog.h \
     415        include/QIListView.h \
    415416        include/VBoxGlobalSettings.h \
    416417        include/VBoxUtils.h \
     
    490491        src/QIAbstractDialog.cpp \
    491492        src/QIDialog.cpp \
     493        src/QIListView.cpp \
    492494        src/VBoxDefs.cpp \
    493495        src/VBoxGlobalSettings.cpp \
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxVMListView.h

    r8221 r8568  
    2525
    2626#include "VBoxGlobal.h"
    27 #include "VBoxDefs.h"
     27#include "QIListView.h"
    2828
    2929/* Qt includes */
    3030#include <QAbstractListModel>
    31 #include <QListView>
    32 #include <QItemDelegate>
    3331#include <QDateTime>
    3432
     
    138136};
    139137
    140 class VBoxVMListView: public QListView
     138class VBoxVMListView: public QIListView
    141139{
    142140    Q_OBJECT;
     
    161159    void currentChanged (const QModelIndex &aCurrent, const QModelIndex &aPrevious);
    162160    void dataChanged (const QModelIndex &aTopLeft, const QModelIndex &aBottomRight);
    163     void focusChanged (QWidget *aOld, QWidget *aNow);
    164161
    165162protected:
     
    168165};
    169166
    170 class VBoxVMItemPainter: public QItemDelegate
     167class VBoxVMItemPainter: public QIItemDelegate
    171168{
    172169public:
    173170    VBoxVMItemPainter (QObject *aParent = 0)
    174       : QItemDelegate (aParent), mMargin (8), mSpacing (mMargin * 3 / 2) {}
     171      : QIItemDelegate (aParent), mMargin (8), mSpacing (mMargin * 3 / 2) {}
    175172
    176173    QSize sizeHint (const QStyleOptionViewItem &aOption,
     
    179176    void paint (QPainter *aPainter, const QStyleOptionViewItem &aOption,
    180177                const QModelIndex &aIndex) const;
    181 
    182 protected:
    183     void drawBackground (QPainter *aPainter, const QStyleOptionViewItem &aOption,
    184                          const QModelIndex &aIndex) const;
    185178
    186179private:
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMListView.cpp

    r8221 r8568  
    3030#if defined (Q_WS_MAC)
    3131# include <Carbon/Carbon.h>
    32 # if MAC_LEOPARD_STYLE
    33 #  include <qmacstyle_mac.h>
    34 # endif /* MAC_LEOPARD_STYLE */
    3532#endif
    3633
     
    612609
    613610VBoxVMListView::VBoxVMListView (QWidget *aParent /* = 0 */)
    614     :QListView (aParent)
     611    :QIListView (aParent)
    615612{
    616613    /* Create & set our delegation class */
     
    622619    connect (this, SIGNAL (activated (const QModelIndex &)),
    623620             this, SIGNAL (activated ()));
    624     /* Track if the application lost the focus */
    625 #if MAC_LEOPARD_STYLE
    626     connect (QCoreApplication::instance(), SIGNAL (focusChanged (QWidget *, QWidget *)),
    627              this, SLOT (focusChanged (QWidget *, QWidget *)));
    628     /* 1 pixel line frame */
    629     setMidLineWidth (1);
    630     setLineWidth (0);
    631     setFrameShape (QFrame::Box);
    632     focusChanged (NULL, this);
    633     /* Nesty hack to disable the focus rect on the list view. This interface
    634      * may change at any time! */
    635     static_cast<QMacStyle *> (style())->setFocusRectPolicy (this, QMacStyle::FocusDisabled);
    636 #endif /* MAC_LEOPARD_STYLE */
    637621}
    638622
     
    700684    ensureCurrentVisible();
    701685    emit currentChanged();
    702 }
    703 
    704 void VBoxVMListView::focusChanged (QWidget * /* aOld */, QWidget *aNow)
    705 {
    706 #if MAC_LEOPARD_STYLE
    707     QColor bgColor (212, 221, 229);
    708     if (aNow == NULL)
    709         bgColor.setRgb (232, 232, 232);
    710     QPalette pal = viewport()->palette();
    711     pal.setColor (QPalette::Base, bgColor);
    712     viewport()->setPalette (pal);
    713     viewport()->setAutoFillBackground (true);
    714 #else /* MAC_LEOPARD_STYLE */
    715     NOREF (aNow);
    716 #endif /* MAC_LEOPARD_STYLE */
    717686}
    718687
     
    861830}
    862831
    863 void VBoxVMItemPainter::drawBackground (QPainter *aPainter, const QStyleOptionViewItem &aOption,
    864                                         const QModelIndex &aIndex) const
    865 {   
    866 #if MAC_LEOPARD_STYLE
    867     NOREF (aIndex);
    868     /* Macify for Leopard */
    869     if (aOption.state & QStyle::State_Selected)
    870     {   
    871         /* Standard color for selected items and focus on the widget */
    872         QColor topLineColor (69, 128, 200);
    873         QColor topGradColor (92, 147, 214);
    874         QColor bottomGradColor (21, 83, 169);
    875         /* Color for selected items and no focus on the widget */
    876         if (QWidget *p = qobject_cast<QWidget *> (parent()))
    877             if (!p->hasFocus())
    878             {
    879                 topLineColor.setRgb (145, 160, 192);
    880                 topGradColor.setRgb (162, 177, 207);
    881                 bottomGradColor.setRgb (110, 129, 169);
    882             }
    883         /* Color for selected items and no focus on the application at all */
    884         if (qApp->focusWidget() == NULL)
    885             {
    886                 topLineColor.setRgb (151, 151, 151);
    887                 topGradColor.setRgb (180, 180, 180);
    888                 bottomGradColor.setRgb (137, 137, 137);
    889             }
    890         /* Paint the background */
    891         QRect r = aOption.rect;
    892         r.setTop (r.top() + 1);
    893         QLinearGradient linearGrad (QPointF(0, r.top()), QPointF(0, r.bottom()));
    894         linearGrad.setColorAt (0, topGradColor);
    895         linearGrad.setColorAt (1, bottomGradColor);
    896         aPainter->setPen (topLineColor);
    897         aPainter->drawLine (r.left(), r.top() - 1, r.right(), r.top() - 1);
    898         aPainter->fillRect (r, linearGrad);
    899     }
    900 #else /* MAC_LEOPARD_STYLE */
    901     QItemDelegate::drawBackground (aPainter, aOption, aIndex);
    902 #endif /* MAC_LEOPARD_STYLE */
    903 }
    904 
    905832QRect VBoxVMItemPainter::rect (const QStyleOptionViewItem &aOption,
    906833                               const QModelIndex &aIndex, int aRole) const
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