VirtualBox

Ignore:
Timestamp:
Aug 13, 2014 5:30:32 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
95510
Message:

FE/Qt: Runtime UI: Mini-toolbar: Make it always separate tool window.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp

    r52327 r52370  
    221221    /* Create mini-toolbar: */
    222222    m_pMiniToolBar = new UIRuntimeMiniToolBar(this,
    223                                               IntegrationMode_Embedded,
     223                                              GeometryType_Full,
    224224                                              gEDataManager->miniToolbarAlignment(vboxGlobal().managedVMUuid()),
    225225                                              gEDataManager->autoHideMiniToolbar(vboxGlobal().managedVMUuid()));
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.cpp

    r52202 r52370  
    112112    /* Create mini-toolbar: */
    113113    m_pMiniToolBar = new UIRuntimeMiniToolBar(this,
    114                                               IntegrationMode_External,
     114                                              GeometryType_Available,
    115115                                              gEDataManager->miniToolbarAlignment(vboxGlobal().managedVMUuid()),
    116116                                              gEDataManager->autoHideMiniToolbar(vboxGlobal().managedVMUuid()));
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.cpp

    r52327 r52370  
    4242
    4343UIRuntimeMiniToolBar::UIRuntimeMiniToolBar(QWidget *pParent,
    44                                            IntegrationMode integrationMode,
     44                                           GeometryType geometryType,
    4545                                           Qt::Alignment alignment,
    4646                                           bool fAutoHide /* = true */)
    47     : QWidget(pParent)
     47    : QWidget(pParent, Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint)
    4848    /* Variables: General stuff: */
    49     , m_integrationMode(integrationMode)
     49    , m_geometryType(geometryType)
    5050    , m_alignment(alignment)
    5151    , m_fAutoHide(fAutoHide)
     
    8686}
    8787
    88 void UIRuntimeMiniToolBar::setIntegrationMode(IntegrationMode integrationMode)
    89 {
    90     /* Make sure integration-mode really changed: */
    91     if (m_integrationMode == integrationMode)
    92         return;
    93 
    94     /* Update integration-mode: */
    95     m_integrationMode = integrationMode;
    96 
    97     /* Re-integrate: */
    98     integrate();
    99 
    100     /* Re-initialize: */
    101     adjustGeometry();
    102 
    103     /* Propagate to child to update shape: */
    104     m_pToolbar->setIntegrationMode(m_integrationMode);
    105 }
    106 
    107 void UIRuntimeMiniToolBar::setAutoHide(bool fAutoHide, bool fPropagateToChild /* = true*/)
     88void UIRuntimeMiniToolBar::setAutoHide(bool fAutoHide, bool fPropagateToChild /* = true */)
    10889{
    10990    /* Make sure auto-hide really changed: */
     
    153134    QRect screenRect;
    154135    int iX = 0, iY = 0;
    155     switch (m_integrationMode)
    156     {
    157         case IntegrationMode_Embedded:
    158         {
    159             /* Screen geometry: */
    160             screenRect = QApplication::desktop()->screenGeometry(iHostScreen);
    161             /* Local coordinates, tool-bar is a child of the parent-widget: */
    162             iX = screenRect.width() / 2 - width() / 2;
    163             switch (m_alignment)
    164             {
    165                 case Qt::AlignTop:
    166                     iY = 0;
    167                     break;
    168                 case Qt::AlignBottom:
    169                     iY = screenRect.height() - height();
    170                     break;
    171             }
    172             break;
    173         }
    174         case IntegrationMode_External:
    175         {
    176             /* Available geometry: */
    177             screenRect = vboxGlobal().availableGeometry(iHostScreen);
    178             /* Global coordinates, tool-bar is tool-window aligned according the parent-widget: */
    179             iX = screenRect.x() + screenRect.width() / 2 - width() / 2;
    180             switch (m_alignment)
    181             {
    182                 case Qt::AlignTop:
    183                     iY = screenRect.y();
    184                     break;
    185                 case Qt::AlignBottom:
    186                     iY = screenRect.y() + screenRect.height() - height();
    187                     break;
    188             }
    189             break;
    190         }
     136    switch (m_geometryType)
     137    {
     138        case GeometryType_Available: screenRect = vboxGlobal().availableGeometry(iHostScreen); break;
     139        case GeometryType_Full:      screenRect = QApplication::desktop()->screenGeometry(iHostScreen); break;
     140        default: break;
     141    }
     142    iX = screenRect.x() + screenRect.width() / 2 - width() / 2;
     143    switch (m_alignment)
     144    {
     145        case Qt::AlignTop:    iY = screenRect.y(); break;
     146        case Qt::AlignBottom: iY = screenRect.y() + screenRect.height() - height(); break;
     147        default: break;
    191148    }
    192149    move(iX, iY);
     
    240197void UIRuntimeMiniToolBar::prepare()
    241198{
    242     /* Allow any size: */
    243     setMinimumSize(1, 1);
     199#ifdef VBOX_RUNTIME_UI_WITH_SHAPED_MINI_TOOLBAR
     200    /* Using Qt API to enable translucent background: */
     201    setAttribute(Qt::WA_TranslucentBackground, true);
     202#endif /* VBOX_RUNTIME_UI_WITH_SHAPED_MINI_TOOLBAR */
     203
    244204    /* Make sure we have no focus: */
    245205    setFocusPolicy(Qt::NoFocus);
     
    248208    m_pMdiArea = new QMdiArea;
    249209    {
     210        /* Allow any MDI area size: */
     211        m_pMdiArea->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    250212        /* Configure own background: */
    251213        QPalette pal = m_pMdiArea->palette();
     
    271233        m_pToolbar->setAutoHide(m_fAutoHide);
    272234        m_pToolbar->setAlignment(m_alignment);
    273         m_pToolbar->setIntegrationMode(m_integrationMode);
    274235        /* Configure own background: */
    275236        QPalette pal = m_pToolbar->palette();
     
    312273                                                         true);
    313274
    314     /* Integrate if necessary: */
    315     integrate();
    316 
    317275    /* Adjust geometry finally: */
    318276    adjustGeometry();
     277
     278    /* Show: */
     279    show();
    319280}
    320281
     
    421382    AssertPtrReturn(m_pEmbeddedToolbar, QPoint());
    422383    return m_pEmbeddedToolbar->pos();
    423 }
    424 
    425 void UIRuntimeMiniToolBar::integrate()
    426 {
    427     /* Reintegrate if necessary: */
    428     if (m_integrationMode == IntegrationMode_Embedded && isWindow())
    429     {
    430         setWindowFlags(Qt::Widget);
    431 #ifdef VBOX_RUNTIME_UI_WITH_SHAPED_MINI_TOOLBAR
    432         setAttribute(Qt::WA_TranslucentBackground, false);
    433 #endif /* VBOX_RUNTIME_UI_WITH_SHAPED_MINI_TOOLBAR */
    434         show();
    435     }
    436     else if (m_integrationMode == IntegrationMode_External && !isWindow())
    437     {
    438         setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
    439 #ifdef VBOX_RUNTIME_UI_WITH_SHAPED_MINI_TOOLBAR
    440         setAttribute(Qt::WA_TranslucentBackground, true);
    441 #endif /* VBOX_RUNTIME_UI_WITH_SHAPED_MINI_TOOLBAR */
    442         show();
    443     }
    444384}
    445385
     
    472412    /* Update alignment: */
    473413    m_alignment = alignment;
    474 
    475     /* Rebuild shape: */
    476     rebuildShape();
    477 }
    478 
    479 void UIMiniToolBar::setIntegrationMode(IntegrationMode integrationMode)
    480 {
    481     /* Make sure integration-mode really changed: */
    482     if (m_integrationMode == integrationMode)
    483         return;
    484 
    485     /* Update integration-mode: */
    486     m_integrationMode = integrationMode;
    487414
    488415    /* Rebuild shape: */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.h

    r52327 r52370  
    3636class UIAnimation;
    3737
    38 /* IntegrationMode enum: */
    39 enum IntegrationMode
     38/** Geometry types. */
     39enum GeometryType
    4040{
    41     IntegrationMode_Embedded,
    42     IntegrationMode_External
     41    GeometryType_Available,
     42    GeometryType_Full
    4343};
    4444
     
    7171    /* Constructor/destructor: */
    7272    UIRuntimeMiniToolBar(QWidget *pParent,
    73                          IntegrationMode integrationMode,
     73                         GeometryType geometryType,
    7474                         Qt::Alignment alignment,
    7575                         bool fAutoHide = true);
     
    7878    /* API: Alignment stuff: */
    7979    void setAlignment(Qt::Alignment alignment);
    80 
    81     /* API: Integration mode stuff: */
    82     void setIntegrationMode(IntegrationMode integrationMode);
    8380
    8481    /* API: Auto-hide stuff: */
     
    127124    QPoint shownToolbarPosition() const { return m_shownToolbarPosition; }
    128125
    129     /* Helper: Integration stuff: */
    130     void integrate();
    131 
    132126    /* Variables: General stuff: */
    133     IntegrationMode m_integrationMode;
     127    const GeometryType m_geometryType;
    134128    Qt::Alignment m_alignment;
    135129    bool m_fAutoHide;
     
    175169    void setAlignment(Qt::Alignment alignment);
    176170
    177     /* API: Integration mode stuff: */
    178     void setIntegrationMode(IntegrationMode integrationMode);
    179 
    180171    /* API: Auto-hide stuff: */
    181172    bool autoHide() const;
     
    207198    bool m_fPolished;
    208199    Qt::Alignment m_alignment;
    209     IntegrationMode m_integrationMode;
    210200    QPainterPath m_shape;
    211201
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