VirtualBox

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


Ignore:
Timestamp:
May 21, 2013 2:31:39 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
85905
Message:

FE/Qt: UI tool-bar cleanup.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMDesktop.cpp

    r44318 r46193  
    249249            pSpace->setFixedSize(10, 1);
    250250        pToolBar->addWidget(pSpace);
     251#ifdef Q_WS_MAC
    251252        pToolBar->updateLayout();
     253#endif /* Q_WS_MAC */
    252254    }
    253255    else
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIToolBar.cpp

    r32761 r46193  
     1/* $Id$ */
    12/** @file
    23 *
     
    67
    78/*
    8  * Copyright (C) 2006-2010 Oracle Corporation
     9 * Copyright (C) 2006-2013 Oracle Corporation
    910 *
    1011 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2122#ifdef Q_WS_MAC
    2223# include "VBoxUtils.h"
    23 #endif
     24#endif /* Q_WS_MAC */
    2425
    25 /* Global includes */
     26/* Qt includes: */
    2627#include <QLayout>
    2728#include <QMainWindow>
    28 /* Note: This styles are available on _all_ platforms. */
     29/* Note: These styles are available on _all_ platforms: */
    2930#include <QCleanlooksStyle>
    3031#include <QWindowsStyle>
    3132
    32 UIToolBar::UIToolBar(QWidget *pParent)
     33UIToolBar::UIToolBar(QWidget *pParent /*= 0*/)
    3334    : QToolBar(pParent)
    34     , m_pMainWindow(qobject_cast <QMainWindow*>(pParent))
     35    , m_pMainWindow(qobject_cast<QMainWindow*>(pParent))
    3536{
     37    /* Configure tool-bar: */
    3638    setFloatable(false);
    3739    setMovable(false);
     
    4345        setStyleSheet("QToolBar { border: 0px none black; }");
    4446
     47    /* Configure layout: */
    4548    if (layout())
    4649        layout()->setContentsMargins(0, 0, 0, 0);;
    4750
     51    /* Configure context-menu policy: */
    4852    setContextMenuPolicy(Qt::NoContextMenu);
    49 }
    50 
    51 #ifdef Q_WS_MAC
    52 void UIToolBar::setMacToolbar()
    53 {
    54     if (m_pMainWindow)
    55         m_pMainWindow->setUnifiedTitleAndToolBarOnMac(true);
    56 }
    57 
    58 void UIToolBar::setShowToolBarButton(bool fShow)
    59 {
    60     ::darwinSetShowsToolbarButton(this, fShow);
    61 }
    62 #endif /* Q_WS_MAC */
    63 
    64 void UIToolBar::updateLayout()
    65 {
    66 #ifdef Q_WS_MAC
    67     /* There is a bug in Qt Cocoa which result in showing a "more arrow" when
    68        the necessary size of the toolbar is increased. Also for some languages
    69        the with doesn't match if the text increase. So manually adjust the size
    70        after changing the text. */
    71     QSizePolicy sp = sizePolicy();
    72     setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
    73     adjustSize();
    74     setSizePolicy(sp);
    75     layout()->invalidate();
    76     layout()->activate();
    77 #endif /* Q_WS_MAC */
    7853}
    7954
     
    9065}
    9166
     67#ifdef Q_WS_MAC
     68void UIToolBar::setMacToolbar()
     69{
     70    if (m_pMainWindow)
     71        m_pMainWindow->setUnifiedTitleAndToolBarOnMac(true);
     72}
     73
     74void UIToolBar::setShowToolBarButton(bool fShow)
     75{
     76    ::darwinSetShowsToolbarButton(this, fShow);
     77}
     78
     79void UIToolBar::updateLayout()
     80{
     81    /* There is a bug in Qt Cocoa which result in showing a "more arrow" when
     82       the necessary size of the toolbar is increased. Also for some languages
     83       the with doesn't match if the text increase. So manually adjust the size
     84       after changing the text. */
     85    QSizePolicy sp = sizePolicy();
     86    setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
     87    adjustSize();
     88    setSizePolicy(sp);
     89    layout()->invalidate();
     90    layout()->activate();
     91}
     92#endif /* Q_WS_MAC */
     93
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIToolBar.h

    r32761 r46193  
    66
    77/*
    8  * Copyright (C) 2006-2010 Oracle Corporation
     8 * Copyright (C) 2006-2013 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2020#define ___UIToolBar_h___
    2121
    22 /* Global includes */
     22/* Qt includes: */
    2323#include <QToolBar>
    2424
    25 /* Global forward declarations */
     25/* Forward declarations: */
    2626class QMainWindow;
    2727
    28 /**
    29  *  The UIToolBar class is a simple QToolBar reimplementation to disable
    30  *  its built-in context menu and add some default behavior we need.
    31  */
     28/* UI tool-bar prototype class: */
    3229class UIToolBar : public QToolBar
    3330{
    3431public:
    3532
    36     UIToolBar(QWidget *pParent);
     33    /* Constructor: */
     34    UIToolBar(QWidget *pParent = 0);
     35
     36    /* API: Text-label stuff: */
     37    void setUsesTextLabel(bool fEnable);
    3738
    3839#ifdef Q_WS_MAC
     40    /* API: Mac toolbar stuff: */
    3941    void setMacToolbar();
    4042    void setShowToolBarButton(bool fShow);
     43    void updateLayout();
    4144#endif /* Q_WS_MAC */
    42 
    43     void updateLayout();
    44     void setUsesTextLabel(bool fEnable);
    4545
    4646private:
    4747
    48     /* Private member vars */
     48    /* Variables: */
    4949    QMainWindow *m_pMainWindow;
    5050};
    5151
    52 #endif // !___UIToolBar_h___
    53 
     52#endif /* !___UIToolBar_h___ */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette