Changeset 35415 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jan 6, 2011 5:33:14 PM (14 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIImageTools.cpp
r30692 r35415 21 21 #include "UIImageTools.h" 22 22 23 /* Qt includes */ 24 #include <QPainter> 25 26 /* System includes */ 27 #include <math.h> 28 23 29 /* Todo: Think about the naming convention and if the images should be 24 30 * processed in place or return changed copies. Make it more uniform. Add … … 142 148 } 143 149 } 150 144 151 void blurImageVertical(const QImage &source, QImage &dest, int r) 145 152 { … … 197 204 } 198 205 206 QPixmap betaLabel() 207 { 208 /* Beta label */ 209 QSize ls(80, 16); 210 QColor bgc(246, 179, 0); 211 QImage i(ls, QImage::Format_ARGB32); 212 i.fill(Qt::transparent); 213 QPainter p(&i); 214 p.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); 215 p.setPen(Qt::NoPen); 216 /* Background */ 217 p.setBrush(bgc); 218 p.drawRect(0, 0, ls.width(), ls.height()); 219 /* The black stripes */ 220 p.setPen(QPen(QColor(70, 70, 70), 3)); 221 int c = 6; 222 float g = (ls.width() / (c - 1)); 223 for (int i = 0; i < c; ++i) 224 p.drawLine(-g / 2 + g * i, ls.height(), -g / 2 + g * (i + 1), 0); 225 /* The text */ 226 QFont f = p.font(); 227 f.setBold(true); 228 QPainterPath tp; 229 tp.addText(0, 0, f, "BETA"); 230 QRectF r = tp.boundingRect(); 231 /* Center the text path */ 232 p.translate((ls.width() - r.width()) / 2, ls.height() - (ls.height() - r.height()) / 2); 233 QPainterPathStroker pps; 234 QPainterPath pp = pps.createStroke(tp); 235 p.setPen(QPen(bgc.darker(80), 2, Qt::SolidLine, Qt::RoundCap)); 236 p.drawPath(pp); 237 p.setBrush(Qt::black); 238 p.setPen(Qt::NoPen); 239 p.drawPath(tp); 240 p.end(); 241 /* Create a secondary image which will contain the rotated banner. */ 242 int w = sqrt(pow(ls.width(), 2) / 2); 243 QImage i1(w, w, QImage::Format_ARGB32); 244 i1.fill(Qt::transparent); 245 QPainter p1(&i1); 246 p1.setRenderHints(QPainter::SmoothPixmapTransform); 247 p1.translate(0, w); 248 p1.rotate(-45); 249 p1.drawImage(0, 0, i); 250 p1.end(); 251 252 return QPixmap::fromImage(i1); 253 } 254 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIImageTools.h
r30692 r35415 29 29 void blurImageVertical(const QImage &source, QImage &dest, int r); 30 30 31 QPixmap betaLabel(); 32 31 33 #endif /* !__UIImageTools_h__ */ 32 34 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r35191 r35415 362 362 (ct_ver_str.section ('.', 1, 1).toInt() << 8) + 363 363 ct_ver_str.section ('.', 2, 2).toInt(); 364 } 365 366 bool VBoxGlobal::isBeta() const 367 { 368 return mVBox.GetVersion().contains("BETA", Qt::CaseInsensitive); 364 369 } 365 370 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r35405 r35415 128 128 static uint qtCTVersion(); 129 129 130 QString versionString() { return mVerString; } 130 QString versionString() const { return mVerString; } 131 bool isBeta() const; 131 132 132 133 CVirtualBox virtualBox() const { return mVBox; } -
trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxUtils-darwin-cocoa.mm
r34401 r35415 94 94 { 95 95 [pWindow setShowsToolbarButton:fEnabled]; 96 } 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 } 114 } 96 115 } 97 116 -
trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxUtils-darwin.cpp
r34401 r35415 65 65 if (parent) 66 66 ::darwinSetShowsToolbarButtonImpl(::darwinToNativeWindow(parent), fEnabled); 67 } 68 69 void darwinLabelToolbar(QWidget *pWidget, QPixmap *pPixmap) 70 { 71 ::darwinLabelToolbar(::darwinToNativeWindow(pWidget), ::darwinToNSImageRef(pPixmap)); 67 72 } 68 73 -
trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxUtils-darwin.h
r34401 r35415 59 59 void darwinSetShowsResizeIndicatorImpl(NativeNSWindowRef pWindow, bool fEnabled); 60 60 void darwinSetHidesAllTitleButtonsImpl(NativeNSWindowRef pWindow); 61 void darwinLabelToolbar(NativeNSWindowRef pWindow, NativeNSImageRef pImage); 61 62 void darwinSetShowsWindowTransparentImpl(NativeNSWindowRef pWindow, bool fEnabled); 62 63 void darwinSetMouseCoalescingEnabled(bool fEnabled); … … 174 175 ********************************************************************************/ 175 176 void darwinSetShowsToolbarButton(QToolBar *aToolBar, bool fEnabled); 177 void darwinLabelToolbar(QWidget *pWidget, QPixmap *pPixmap); 176 178 void darwinSetShowsResizeIndicator(QWidget *pWidget, bool fEnabled); 177 179 void darwinSetHidesAllTitleButtons(QWidget *pWidget); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMDesktop.cpp
r33471 r35415 1358 1358 pToolBar->addWidget(m_pHeaderBtn); 1359 1359 QWidget *pSpace = new QWidget(this); 1360 pSpace->setFixedSize(10, 1); 1360 /* We need a little bit more space for the beta label. */ 1361 if (vboxGlobal().isBeta()) 1362 pSpace->setFixedSize(28, 1); 1363 else 1364 pSpace->setFixedSize(10, 1); 1361 1365 pToolBar->addWidget(pSpace); 1362 1366 pToolBar->updateLayout(); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp
r35270 r35415 49 49 # include "VBoxUtils.h" 50 50 # include "UIWindowMenuManager.h" 51 # include "UIImageTools.h" 51 52 #endif 52 53 … … 221 222 pLeftVLayout->setSpacing(0); 222 223 # ifdef BIG_TOOLBAR 223 m_pBar = new UI Bar(this);224 m_pBar = new UIMainBar(this); 224 225 m_pBar->setContentWidget(mVMToolBar); 225 226 pLeftVLayout->addWidget(m_pBar); … … 488 489 #ifdef Q_WS_MAC 489 490 UIWindowMenuManager::instance()->addWindow(this); 491 /* Beta label? */ 492 if (vboxGlobal().isBeta()) 493 { 494 QPixmap betaLabel = ::betaLabel(); 495 ::darwinLabelToolbar(this, &betaLabel); 496 } 490 497 #endif /* Q_WS_MAC */ 491 498 } -
trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.h
r34419 r35415 36 36 /* Local forward declarations */ 37 37 class QISplitter; 38 class UI Bar;38 class UIMainBar; 39 39 class UIVMDesktop; 40 40 class UIVMItem; … … 149 149 /* Main toolbar */ 150 150 #ifndef Q_WS_MAC 151 UI Bar *m_pBar;151 UIMainBar *m_pBar; 152 152 #endif /* !Q_WS_MAC */ 153 153 UIToolBar *mVMToolBar; -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIBar.cpp
r30868 r35415 20 20 /* Local includes */ 21 21 #include "UIBar.h" 22 #include "UIImageTools.h" 23 #include "VBoxGlobal.h" 22 24 23 25 /* Global includes */ … … 25 27 #include <QPainter> 26 28 #include <QVBoxLayout> 29 #include <QPixmapCache> 27 30 28 31 UIBar::UIBar(QWidget *pParent /* = 0 */) … … 107 110 #endif /* !Q_WS_MAC */ 108 111 112 UIMainBar::UIMainBar(QWidget *pParent /* = 0 */) 113 : UIBar(pParent) 114 , m_fShowBetaLabel(false) 115 { 116 /* Check for beta versions */ 117 if (vboxGlobal().isBeta()) 118 m_fShowBetaLabel = true; 119 } 120 121 void UIMainBar::paintEvent(QPaintEvent *pEvent) 122 { 123 UIBar::paintEvent(pEvent); 124 QPainter painter(this); 125 painter.setClipRect(pEvent->rect()); 126 127 if (m_fShowBetaLabel) 128 { 129 QPixmap betaLabel; 130 const QString key("vbox:betaLabel"); 131 if (!QPixmapCache::find(key, &betaLabel)) 132 { 133 betaLabel = ::betaLabel(); 134 QPixmapCache::insert(key, betaLabel); 135 } 136 QSize s = size(); 137 painter.drawPixmap(s.width() - betaLabel.width(), s.height() - betaLabel.height() - 1, betaLabel); 138 } 139 } 140 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIBar.h
r30868 r35415 51 51 }; 52 52 53 class UIMainBar: public UIBar 54 { 55 Q_OBJECT; 56 57 public: 58 59 UIMainBar(QWidget *pParent = 0); 60 61 protected: 62 63 void paintEvent(QPaintEvent *pEvent); 64 65 private: 66 67 /* Private member vars */ 68 bool m_fShowBetaLabel; 69 }; 70 53 71 #endif /* !__UIBar_h__ */ 54 72
Note:
See TracChangeset
for help on using the changeset viewer.