VirtualBox

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


Ignore:
Timestamp:
Jan 6, 2011 5:33:14 PM (14 years ago)
Author:
vboxsync
Message:

FE/Qt4: beta label

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  
    2121#include "UIImageTools.h"
    2222
     23/* Qt includes */
     24#include <QPainter>
     25
     26/* System includes */
     27#include <math.h>
     28
    2329/* Todo: Think about the naming convention and if the images should be
    2430 * processed in place or return changed copies. Make it more uniform. Add
     
    142148    }
    143149}
     150
    144151void blurImageVertical(const QImage &source, QImage &dest, int r)
    145152{
     
    197204}
    198205
     206QPixmap 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  
    2929void blurImageVertical(const QImage &source, QImage &dest, int r);
    3030
     31QPixmap betaLabel();
     32
    3133#endif /* !__UIImageTools_h__ */
    3234
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r35191 r35415  
    362362           (ct_ver_str.section ('.', 1, 1).toInt() << 8) +
    363363           ct_ver_str.section ('.', 2, 2).toInt();
     364}
     365
     366bool VBoxGlobal::isBeta() const
     367{
     368    return mVBox.GetVersion().contains("BETA", Qt::CaseInsensitive);
    364369}
    365370
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r35405 r35415  
    128128    static uint qtCTVersion();
    129129
    130     QString versionString() { return mVerString; }
     130    QString versionString() const { return mVerString; }
     131    bool isBeta() const;
    131132
    132133    CVirtualBox virtualBox() const { return mVBox; }
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxUtils-darwin-cocoa.mm

    r34401 r35415  
    9494{
    9595    [pWindow setShowsToolbarButton:fEnabled];
     96}
     97
     98void 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    }
    96115}
    97116
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxUtils-darwin.cpp

    r34401 r35415  
    6565    if (parent)
    6666        ::darwinSetShowsToolbarButtonImpl(::darwinToNativeWindow(parent), fEnabled);
     67}
     68
     69void darwinLabelToolbar(QWidget *pWidget, QPixmap *pPixmap)
     70{
     71    ::darwinLabelToolbar(::darwinToNativeWindow(pWidget), ::darwinToNSImageRef(pPixmap));
    6772}
    6873
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxUtils-darwin.h

    r34401 r35415  
    5959void darwinSetShowsResizeIndicatorImpl(NativeNSWindowRef pWindow, bool fEnabled);
    6060void darwinSetHidesAllTitleButtonsImpl(NativeNSWindowRef pWindow);
     61void darwinLabelToolbar(NativeNSWindowRef pWindow, NativeNSImageRef pImage);
    6162void darwinSetShowsWindowTransparentImpl(NativeNSWindowRef pWindow, bool fEnabled);
    6263void darwinSetMouseCoalescingEnabled(bool fEnabled);
     
    174175 ********************************************************************************/
    175176void darwinSetShowsToolbarButton(QToolBar *aToolBar, bool fEnabled);
     177void darwinLabelToolbar(QWidget *pWidget, QPixmap *pPixmap);
    176178void darwinSetShowsResizeIndicator(QWidget *pWidget, bool fEnabled);
    177179void darwinSetHidesAllTitleButtons(QWidget *pWidget);
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMDesktop.cpp

    r33471 r35415  
    13581358        pToolBar->addWidget(m_pHeaderBtn);
    13591359        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);
    13611365        pToolBar->addWidget(pSpace);
    13621366        pToolBar->updateLayout();
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp

    r35270 r35415  
    4949# include "VBoxUtils.h"
    5050# include "UIWindowMenuManager.h"
     51# include "UIImageTools.h"
    5152#endif
    5253
     
    221222    pLeftVLayout->setSpacing(0);
    222223# ifdef BIG_TOOLBAR
    223     m_pBar = new UIBar(this);
     224    m_pBar = new UIMainBar(this);
    224225    m_pBar->setContentWidget(mVMToolBar);
    225226    pLeftVLayout->addWidget(m_pBar);
     
    488489#ifdef Q_WS_MAC
    489490    UIWindowMenuManager::instance()->addWindow(this);
     491    /* Beta label? */
     492    if (vboxGlobal().isBeta())
     493    {
     494        QPixmap betaLabel = ::betaLabel();
     495        ::darwinLabelToolbar(this, &betaLabel);
     496    }
    490497#endif /* Q_WS_MAC */
    491498}
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.h

    r34419 r35415  
    3636/* Local forward declarations */
    3737class QISplitter;
    38 class UIBar;
     38class UIMainBar;
    3939class UIVMDesktop;
    4040class UIVMItem;
     
    149149    /* Main toolbar */
    150150#ifndef Q_WS_MAC
    151     UIBar *m_pBar;
     151    UIMainBar *m_pBar;
    152152#endif /* !Q_WS_MAC */
    153153    UIToolBar *mVMToolBar;
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIBar.cpp

    r30868 r35415  
    2020/* Local includes */
    2121#include "UIBar.h"
     22#include "UIImageTools.h"
     23#include "VBoxGlobal.h"
    2224
    2325/* Global includes */
     
    2527#include <QPainter>
    2628#include <QVBoxLayout>
     29#include <QPixmapCache>
    2730
    2831UIBar::UIBar(QWidget *pParent /* = 0 */)
     
    107110#endif /* !Q_WS_MAC */
    108111
     112UIMainBar::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
     121void 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  
    5151};
    5252
     53class UIMainBar: public UIBar
     54{
     55    Q_OBJECT;
     56
     57public:
     58
     59    UIMainBar(QWidget *pParent = 0);
     60
     61protected:
     62
     63    void paintEvent(QPaintEvent *pEvent);
     64
     65private:
     66
     67    /* Private member vars */
     68    bool m_fShowBetaLabel;
     69};
     70
    5371#endif /* !__UIBar_h__ */
    5472
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