Changeset 8568 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- May 5, 2008 12:24:08 PM (17 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox4
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/Makefile.kmk
r8556 r8568 413 413 include/QIAbstractWizard.h \ 414 414 include/QIAbstractDialog.h \ 415 include/QIListView.h \ 415 416 include/VBoxGlobalSettings.h \ 416 417 include/VBoxUtils.h \ … … 490 491 src/QIAbstractDialog.cpp \ 491 492 src/QIDialog.cpp \ 493 src/QIListView.cpp \ 492 494 src/VBoxDefs.cpp \ 493 495 src/VBoxGlobalSettings.cpp \ -
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxVMListView.h
r8221 r8568 25 25 26 26 #include "VBoxGlobal.h" 27 #include " VBoxDefs.h"27 #include "QIListView.h" 28 28 29 29 /* Qt includes */ 30 30 #include <QAbstractListModel> 31 #include <QListView>32 #include <QItemDelegate>33 31 #include <QDateTime> 34 32 … … 138 136 }; 139 137 140 class VBoxVMListView: public Q ListView138 class VBoxVMListView: public QIListView 141 139 { 142 140 Q_OBJECT; … … 161 159 void currentChanged (const QModelIndex &aCurrent, const QModelIndex &aPrevious); 162 160 void dataChanged (const QModelIndex &aTopLeft, const QModelIndex &aBottomRight); 163 void focusChanged (QWidget *aOld, QWidget *aNow);164 161 165 162 protected: … … 168 165 }; 169 166 170 class VBoxVMItemPainter: public QI temDelegate167 class VBoxVMItemPainter: public QIItemDelegate 171 168 { 172 169 public: 173 170 VBoxVMItemPainter (QObject *aParent = 0) 174 : QI temDelegate (aParent), mMargin (8), mSpacing (mMargin * 3 / 2) {}171 : QIItemDelegate (aParent), mMargin (8), mSpacing (mMargin * 3 / 2) {} 175 172 176 173 QSize sizeHint (const QStyleOptionViewItem &aOption, … … 179 176 void paint (QPainter *aPainter, const QStyleOptionViewItem &aOption, 180 177 const QModelIndex &aIndex) const; 181 182 protected:183 void drawBackground (QPainter *aPainter, const QStyleOptionViewItem &aOption,184 const QModelIndex &aIndex) const;185 178 186 179 private: -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMListView.cpp
r8221 r8568 30 30 #if defined (Q_WS_MAC) 31 31 # include <Carbon/Carbon.h> 32 # if MAC_LEOPARD_STYLE33 # include <qmacstyle_mac.h>34 # endif /* MAC_LEOPARD_STYLE */35 32 #endif 36 33 … … 612 609 613 610 VBoxVMListView::VBoxVMListView (QWidget *aParent /* = 0 */) 614 :Q ListView (aParent)611 :QIListView (aParent) 615 612 { 616 613 /* Create & set our delegation class */ … … 622 619 connect (this, SIGNAL (activated (const QModelIndex &)), 623 620 this, SIGNAL (activated ())); 624 /* Track if the application lost the focus */625 #if MAC_LEOPARD_STYLE626 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 interface634 * may change at any time! */635 static_cast<QMacStyle *> (style())->setFocusRectPolicy (this, QMacStyle::FocusDisabled);636 #endif /* MAC_LEOPARD_STYLE */637 621 } 638 622 … … 700 684 ensureCurrentVisible(); 701 685 emit currentChanged(); 702 }703 704 void VBoxVMListView::focusChanged (QWidget * /* aOld */, QWidget *aNow)705 {706 #if MAC_LEOPARD_STYLE707 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 */717 686 } 718 687 … … 861 830 } 862 831 863 void VBoxVMItemPainter::drawBackground (QPainter *aPainter, const QStyleOptionViewItem &aOption,864 const QModelIndex &aIndex) const865 {866 #if MAC_LEOPARD_STYLE867 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 905 832 QRect VBoxVMItemPainter::rect (const QStyleOptionViewItem &aOption, 906 833 const QModelIndex &aIndex, int aRole) const
Note:
See TracChangeset
for help on using the changeset viewer.