Changeset 35424 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jan 7, 2011 1:05:41 PM (14 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIImageTools.cpp
r35417 r35424 204 204 } 205 205 206 QPixmap betaLabel()206 static QImage betaLabelImage(const QSize& ls) 207 207 { 208 208 /* Beta label */ 209 QSize ls(80, 16);210 209 QColor bgc(246, 179, 0); 211 210 QImage i(ls, QImage::Format_ARGB32); … … 218 217 p.drawRect(0, 0, ls.width(), ls.height()); 219 218 /* The black stripes */ 220 p.setPen(QPen(QColor(70, 70, 70), 3));221 int c = 6;219 p.setPen(QPen(QColor(70, 70, 70), 5)); 220 float c = ((float)ls.width() / ls.height()) + 1; 222 221 float g = (ls.width() / (c - 1)); 223 222 for (int i = 0; i < c; ++i) … … 239 238 p.drawPath(tp); 240 239 p.end(); 240 241 /* Smoothing */ 242 QImage i1(ls, QImage::Format_ARGB32); 243 i1.fill(Qt::transparent); 244 QPainter p1(&i1); 245 p1.setCompositionMode(QPainter::CompositionMode_Source); 246 p1.drawImage(0, 0, i); 247 p1.setCompositionMode(QPainter::CompositionMode_DestinationIn); 248 QLinearGradient lg(0, 0, ls.width(), 0); 249 lg.setColorAt(0, QColor(Qt::transparent)); 250 lg.setColorAt(0.20, QColor(Qt::white)); 251 lg.setColorAt(0.80, QColor(Qt::white)); 252 lg.setColorAt(1, QColor(Qt::transparent)); 253 p1.fillRect(0, 0, ls.width(), ls.height(), lg); 254 p1.end(); 255 256 return i1; 257 } 258 259 QPixmap betaLabel(const QSize &ls /* = QSize(80, 16) */) 260 { 261 return QPixmap::fromImage(betaLabelImage(ls)); 262 } 263 264 QPixmap betaLabelSleeve(const QSize &ls /* = QSize(80, 16) */) 265 { 266 const QImage &i = betaLabelImage(ls); 241 267 /* Create a secondary image which will contain the rotated banner. */ 242 268 int w = sqrtf(powf(ls.width(), 2) / 2); … … 245 271 QPainter p1(&i1); 246 272 p1.setRenderHints(QPainter::SmoothPixmapTransform); 247 p1.translate(0, w); 248 p1.rotate(-45); 249 p1.drawImage(0, 0, i); 273 p1.rotate(45); 274 p1.drawImage(0, -ls.height(), i); 250 275 p1.end(); 251 276 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIImageTools.h
r35415 r35424 29 29 void blurImageVertical(const QImage &source, QImage &dest, int r); 30 30 31 QPixmap betaLabel(); 31 QPixmap betaLabel(const QSize &ls = QSize(80, 16)); 32 QPixmap betaLabelSleeve(const QSize &ls = QSize(80, 16)); 32 33 33 34 #endif /* !__UIImageTools_h__ */ -
trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxUtils-darwin-cocoa.mm
r35415 r35424 96 96 } 97 97 98 void darwinLabelToolbar(NativeNSWindowRef pWindow, NativeNSImageRef pImage) 99 { 100 NSToolbar *tb = [pWindow toolbar]; 101 if ([tb respondsToSelector:@selector(_toolbarView)]) 102 { 103 NSView *tbv = [tb performSelector:@selector(_toolbarView)]; 104 if (tbv) 105 { 106 NSSize s = [pImage size]; 107 NSSize s1 = [tbv frame].size; 108 NSImageView *iv = [[NSImageView alloc] initWithFrame:NSMakeRect(s1.width - s.width, s1.height - s.height - 1, s.width, s.height)]; 109 [iv setImage:pImage]; 110 [iv setAutoresizesSubviews:true]; 111 [iv setAutoresizingMask:NSViewMinXMargin | NSViewMaxYMargin]; 112 [tbv addSubview:iv positioned:NSWindowBelow relativeTo:nil]; 113 } 98 void darwinLabelWindow(NativeNSWindowRef pWindow, NativeNSImageRef pImage, bool fCenter) 99 { 100 /* Get the parent view of the close button. */ 101 NSView *wv = [[pWindow standardWindowButton:NSWindowCloseButton] superview]; 102 if (wv) 103 { 104 /* We have to calculate the size of the title bar for the center case. */ 105 NSSize s = [pImage size]; 106 NSSize s1 = [wv frame].size; 107 NSSize s2 = [[pWindow contentView] frame].size; 108 /* Correctly position the label. */ 109 NSImageView *iv = [[NSImageView alloc] initWithFrame:NSMakeRect(s1.width - s.width - (fCenter ? 10 : 0), 110 fCenter ? s2.height + (s1.height - s2.height - s.height) / 2 : s1.height - s.height - 1, 111 s.width, s.height)]; 112 /* Configure the NSImageView for auto moving. */ 113 [iv setImage:pImage]; 114 [iv setAutoresizesSubviews:true]; 115 [iv setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin]; 116 /* Add it to the parent of the close button. */ 117 [wv addSubview:iv positioned:NSWindowBelow relativeTo:nil]; 114 118 } 115 119 } -
trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxUtils-darwin.cpp
r35415 r35424 67 67 } 68 68 69 void darwinLabel Toolbar(QWidget *pWidget, QPixmap *pPixmap)70 { 71 ::darwinLabel Toolbar(::darwinToNativeWindow(pWidget), ::darwinToNSImageRef(pPixmap));69 void darwinLabelWindow(QWidget *pWidget, QPixmap *pPixmap, bool fCenter) 70 { 71 ::darwinLabelWindow(::darwinToNativeWindow(pWidget), ::darwinToNSImageRef(pPixmap), fCenter); 72 72 } 73 73 -
trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxUtils-darwin.h
r35415 r35424 59 59 void darwinSetShowsResizeIndicatorImpl(NativeNSWindowRef pWindow, bool fEnabled); 60 60 void darwinSetHidesAllTitleButtonsImpl(NativeNSWindowRef pWindow); 61 void darwinLabel Toolbar(NativeNSWindowRef pWindow, NativeNSImageRef pImage);61 void darwinLabelWindow(NativeNSWindowRef pWindow, NativeNSImageRef pImage, bool fCenter); 62 62 void darwinSetShowsWindowTransparentImpl(NativeNSWindowRef pWindow, bool fEnabled); 63 63 void darwinSetMouseCoalescingEnabled(bool fEnabled); … … 175 175 ********************************************************************************/ 176 176 void darwinSetShowsToolbarButton(QToolBar *aToolBar, bool fEnabled); 177 void darwinLabel Toolbar(QWidget *pWidget, QPixmap *pPixmap);177 void darwinLabelWindow(QWidget *pWidget, QPixmap *pPixmap, bool fCenter); 178 178 void darwinSetShowsResizeIndicator(QWidget *pWidget, bool fEnabled); 179 179 void darwinSetHidesAllTitleButtons(QWidget *pWidget); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineMenuBar.cpp
r34158 r35424 25 25 #include "VBoxProblemReporter.h" 26 26 #include "UIExtraDataEventHandler.h" 27 #include "UIImageTools.h" 27 28 28 29 /* Global includes */ 29 30 #include <QMenuBar> 31 #include <QPainter> 32 #include <QPaintEvent> 33 #include <QPixmapCache> 30 34 31 35 /* Helper QMenu reimplementation which allows … … 48 52 QMenu::focusNextChild(); 49 53 } 54 }; 55 56 class UIMenuBar: public QMenuBar 57 { 58 public: 59 60 UIMenuBar(QWidget *pParent = 0) 61 : QMenuBar(pParent) 62 , m_fShowBetaLabel(false) 63 { 64 /* Check for beta versions */ 65 if (vboxGlobal().isBeta()) 66 m_fShowBetaLabel = true; 67 } 68 69 protected: 70 71 void paintEvent(QPaintEvent *pEvent) 72 { 73 QMenuBar::paintEvent(pEvent); 74 if (m_fShowBetaLabel) 75 { 76 QPixmap betaLabel; 77 const QString key("vbox:betaLabel"); 78 if (!QPixmapCache::find(key, betaLabel)) 79 { 80 betaLabel = ::betaLabel(); 81 QPixmapCache::insert(key, betaLabel); 82 } 83 QSize s = size(); 84 QPainter painter(this); 85 painter.setClipRect(pEvent->rect()); 86 painter.drawPixmap(s.width() - betaLabel.width() - 10, (height() - betaLabel.height()) / 2, betaLabel); 87 } 88 } 89 90 private: 91 92 /* Private member vars */ 93 bool m_fShowBetaLabel; 50 94 }; 51 95 … … 73 117 { 74 118 /* Create empty menubar: */ 75 QMenuBar *pMenuBar = new QMenuBar;119 QMenuBar *pMenuBar = new UIMenuBar; 76 120 77 121 /* Fill menubar with prepared items: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp
r30930 r35424 39 39 #include "UIDownloaderAdditions.h" 40 40 #include "UIDownloaderUserManual.h" 41 #ifdef Q_WS_MAC 42 # include "UIImageTools.h" 43 #endif /* Q_WS_MAC */ 41 44 42 45 #include "QIStatusBar.h" … … 89 92 /* Update all the elements: */ 90 93 updateAppearanceOf(UIVisualElement_AllStuff); 94 95 #ifdef Q_WS_MAC 96 /* Beta label? */ 97 if (vboxGlobal().isBeta()) 98 { 99 QPixmap betaLabel = ::betaLabel(QSize(100, 16)); 100 ::darwinLabelWindow(this, &betaLabel, true); 101 } 102 #endif /* Q_WS_MAC */ 91 103 92 104 /* Show window: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineWindowScale.cpp
r35247 r35424 34 34 #include "UIMachineView.h" 35 35 #include "UIMachineWindowScale.h" 36 #ifdef Q_WS_MAC 37 # include "UIImageTools.h" 38 #endif /* Q_WS_MAC */ 36 39 37 40 UIMachineWindowScale::UIMachineWindowScale(UIMachineLogic *pMachineLogic, ulong uScreenId) … … 73 76 /* Update all the elements: */ 74 77 updateAppearanceOf(UIVisualElement_AllStuff); 78 79 #ifdef Q_WS_MAC 80 /* Beta label? */ 81 if (vboxGlobal().isBeta()) 82 { 83 QPixmap betaLabel = ::betaLabel(QSize(100, 16)); 84 ::darwinLabelWindow(this, &betaLabel, true); 85 } 86 #endif /* Q_WS_MAC */ 87 75 88 76 89 /* Show window: */ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIBar.cpp
r35416 r35424 122 122 { 123 123 UIBar::paintEvent(pEvent); 124 QPainter painter(this);125 painter.setClipRect(pEvent->rect());126 127 124 if (m_fShowBetaLabel) 128 125 { 129 126 QPixmap betaLabel; 130 const QString key("vbox:betaLabel ");127 const QString key("vbox:betaLabelSleeve"); 131 128 if (!QPixmapCache::find(key, betaLabel)) 132 129 { 133 betaLabel = ::betaLabel ();130 betaLabel = ::betaLabelSleeve(); 134 131 QPixmapCache::insert(key, betaLabel); 135 132 } 136 133 QSize s = size(); 137 painter.drawPixmap(s.width() - betaLabel.width(), s.height() - betaLabel.height() - 1, betaLabel); 134 QPainter painter(this); 135 painter.setClipRect(pEvent->rect()); 136 painter.drawPixmap(s.width() - betaLabel.width(), 0, betaLabel); 138 137 } 139 138 }
Note:
See TracChangeset
for help on using the changeset viewer.