VirtualBox

Changeset 46976 in vbox


Ignore:
Timestamp:
Jul 4, 2013 10:26:22 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
86984
Message:

FE/Qt: Popup-center: Support for top-level popup-stacks, used in *seamless* mode.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPopupCenter.cpp

    r45939 r46976  
    4141    /* Create instance: */
    4242    new UIPopupCenter;
     43    /* Prepare instance: */
     44    m_spInstance->prepare();
    4345}
    4446
     
    6870}
    6971
     72void UIPopupCenter::prepare()
     73{
     74    /* Embedded by default: */
     75    m_type = UIPopupIntegrationType_Embedded;
     76}
     77
    7078void UIPopupCenter::cleanup()
    7179{
     
    7684        m_stacks.remove(strPopupStackID);
    7785    }
     86}
     87
     88void UIPopupCenter::setStackIntegrationType(UIPopupIntegrationType type)
     89{
     90    /* Make sure type changed: */
     91    if (m_type == type)
     92        return;
     93
     94    /* Assign new type:  */
     95    m_type = type;
    7896}
    7997
     
    229247        return;
    230248
    231     /* Install stack to passed parent: */
     249    /* Assign stack with passed parent: */
    232250    UIPopupStack *pPopupStack = m_stacks[strPopupStackID];
    233     pParent->installEventFilter(pPopupStack);
    234     pPopupStack->setParent(pParent);
     251    assignPopupStackParent(pPopupStack, pParent);
    235252    pPopupStack->show();
    236253}
     
    250267        return;
    251268
    252     /* Uninstall stack from passed parent: */
     269    /* Unassign stack with passed parent: */
    253270    UIPopupStack *pPopupStack = m_stacks[strPopupStackID];
    254271    pPopupStack->hide();
     272    unassignPopupStackParent(pPopupStack, pParent);
     273}
     274
     275void UIPopupCenter::assignPopupStackParent(UIPopupStack *pPopupStack, QWidget *pParent)
     276{
     277    /* Make sure parent is not NULL: */
     278    AssertMsg(pParent, ("Invalid parent passed!"));
     279
     280    /* Assign event-filter: */
     281    pParent->installEventFilter(pPopupStack);
     282
     283    /* Assign parent depending on *integration* type: */
     284    switch (m_type)
     285    {
     286        case UIPopupIntegrationType_Embedded:
     287        {
     288            pPopupStack->setParent(pParent);
     289            break;
     290        }
     291        case UIPopupIntegrationType_Toplevel:
     292        {
     293            pPopupStack->setParent(pParent, Qt::Window | Qt::FramelessWindowHint);
     294            break;
     295        }
     296        default: break;
     297    }
     298}
     299
     300void UIPopupCenter::unassignPopupStackParent(UIPopupStack *pPopupStack, QWidget *pParent)
     301{
     302    /* Make sure parent is not NULL: */
     303    AssertMsg(pParent, ("Invalid parent passed!"));
     304
     305    /* Unassign parent: */
    255306    pPopupStack->setParent(0);
     307
     308    /* Unassign event-filter: */
    256309    pParent->removeEventFilter(pPopupStack);
    257310}
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPopupCenter.h

    r45939 r46976  
    2929class UIPopupStack;
    3030
     31/* Popup integration types: */
     32enum UIPopupIntegrationType
     33{
     34    UIPopupIntegrationType_Embedded,
     35    UIPopupIntegrationType_Toplevel
     36};
     37
    3138/* Popup-center singleton: */
    3239class UIPopupCenter: public QObject
     
    4451    static void create();
    4552    static void destroy();
     53
     54    /* API: Stack layout stuff: */
     55    void setStackIntegrationType(UIPopupIntegrationType type);
    4656
    4757    /* API: Main message function.
     
    104114    ~UIPopupCenter();
    105115
    106     /* Helper: Cleanup stuff: */
     116    /* Helpers: Prepare/cleanup stuff: */
     117    void prepare();
    107118    void cleanup();
    108119
     
    117128    void showPopupStack(QWidget *pParent);
    118129    void hidePopupStack(QWidget *pParent);
     130    void assignPopupStackParent(UIPopupStack *pPopupStack, QWidget *pParent);
     131    void unassignPopupStackParent(UIPopupStack *pPopupStack, QWidget *pParent);
    119132
    120133    /* Static helper: Popup-stack stuff: */
     
    122135
    123136    /* Variable: Popup-stack stuff: */
     137    UIPopupIntegrationType m_type;
    124138    QMap<QString, QPointer<UIPopupStack> > m_stacks;
    125139
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r46813 r46976  
    535535{
    536536    /* Register popup-center connections: */
    537     connect(this, SIGNAL(sigMachineWidnowsCreated()),
     537    connect(this, SIGNAL(sigMachineWindowsCreated()),
    538538            &popupCenter(), SLOT(sltShowPopupStack()));
    539     connect(this, SIGNAL(sigMachineWidnowsDestroyed()),
     539    connect(this, SIGNAL(sigMachineWindowsDestroyed()),
    540540            &popupCenter(), SLOT(sltHidePopupStack()));
    541541}
     
    544544{
    545545    /* Unregister popup-center connections: */
    546     disconnect(this, SIGNAL(sigMachineWidnowsCreated()),
     546    disconnect(this, SIGNAL(sigMachineWindowsCreated()),
    547547               &popupCenter(), SLOT(sltShowPopupStack()));
    548     disconnect(this, SIGNAL(sigMachineWidnowsDestroyed()),
     548    disconnect(this, SIGNAL(sigMachineWindowsDestroyed()),
    549549               &popupCenter(), SLOT(sltHidePopupStack()));
    550550}
     
    561561        /* We emit this signal *before* the remembering new value
    562562         * because we want UIMachineLogic::activeMachineWindow() to be yet alive. */
    563         emit sigMachineWidnowsDestroyed();
     563        emit sigMachineWindowsDestroyed();
    564564    }
    565565
     
    572572        /* We emit this signal *after* the remembering new value
    573573         * because we want UIMachineLogic::activeMachineWindow() to be already alive. */
    574         emit sigMachineWidnowsCreated();
     574        emit sigMachineWindowsCreated();
    575575    }
    576576}
     
    649649# endif /* VBOX_WITH_ICHAT_THEATER */
    650650#endif /* Q_WS_MAC */
     651
     652    /* Switch popup-center into default integration mode: */
     653    popupCenter().setStackIntegrationType(UIPopupIntegrationType_Embedded);
    651654}
    652655
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r46599 r46976  
    5656
    5757    /* Notifiers: Machine-window(s) stuff: */
    58     void sigMachineWidnowsCreated();
    59     void sigMachineWidnowsDestroyed();
     58    void sigMachineWindowsCreated();
     59    void sigMachineWindowsDestroyed();
    6060
    6161public:
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.cpp

    r46924 r46976  
    2424#include "VBoxGlobal.h"
    2525#include "UIMessageCenter.h"
     26#include "UIPopupCenter.h"
    2627#include "UISession.h"
    2728#include "UIActionPoolRuntime.h"
     
    112113}
    113114
     115void UIMachineLogicSeamless::prepareRequiredFeatures()
     116{
     117    /* Call to base-class: */
     118    UIMachineLogic::prepareRequiredFeatures();
     119
     120    /* Switch popup-center into 'top-level' integration mode: */
     121    popupCenter().setStackIntegrationType(UIPopupIntegrationType_Toplevel);
     122}
     123
    114124void UIMachineLogicSeamless::prepareActionGroups()
    115125{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.h

    r44982 r46976  
    5252
    5353    /* Prepare helpers: */
     54    void prepareRequiredFeatures();
    5455    void prepareActionGroups();
    5556    void prepareMachineWindows();
     
    6061    void cleanupMachineWindows();
    6162    void cleanupActionGroups();
     63    //void cleanupRequiredFeatures();
    6264
    6365    /* Variables: */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.cpp

    r45939 r46976  
    3434    : m_iLayoutMargin(1), m_iLayoutSpacing(1)
    3535{
     36#if defined(Q_WS_WIN) || defined (Q_WS_MAC)
     37    /* Using Qt API to enable translucent background for the Win/Mac host.
     38     * - Under x11 host Qt 4.8.3 has it broken wih KDE 4.9 for now: */
     39    setAttribute(Qt::WA_TranslucentBackground);
     40#endif /* Q_WS_WIN || Q_WS_MAC */
    3641}
    3742
     
    109114}
    110115
     116void UIPopupStack::setParent(QWidget *pParent, Qt::WindowFlags flags)
     117{
     118    /* Call to base-class: */
     119    QWidget::setParent(pParent, flags);
     120    /* Recalculate parent status-bar height: */
     121    m_iParentStatusBarHeight = parentStatusBarHeight(pParent);
     122}
     123
    111124void UIPopupStack::sltAdjustGeometry()
    112125{
     
    119132    const int iHeight = minimumHeightHint();
    120133
    121     /* Move according parent: */
    122     move(0, parentWidget()->height() - iHeight - m_iParentStatusBarHeight);
    123     /* Resize according parent: */
    124     resize(iWidth, iHeight);
     134    /* Move/resize according parent: */
     135    setGeometry(0, parentWidget()->height() - iHeight - m_iParentStatusBarHeight,
     136                iWidth, iHeight);
    125137
    126138    /* Layout content: */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.h

    r45939 r46976  
    5656    /* API: Parent stuff: */
    5757    void setParent(QWidget *pParent);
     58    void setParent(QWidget *pParent, Qt::WindowFlags flags);
    5859
    5960private slots:
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