VirtualBox

Changeset 45290 in vbox for trunk/src


Ignore:
Timestamp:
Apr 2, 2013 3:23:00 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: VM selector: Make sure inaccessible medium warning will be shown even if medium-enumeration had finished before VM selector shown.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp

    r45274 r45290  
    583583}
    584584
     585/* static */
     586UIMediumManager* UIMediumManager::modelessInstance()
     587{
     588    return mModelessDialog;
     589}
     590
    585591QString UIMediumManager::selectedId() const
    586592{
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.h

    r44528 r45290  
    5757
    5858    static void showModeless (QWidget *aParent = NULL, bool aRefresh = true);
     59    static UIMediumManager* modelessInstance();
    5960
    6061    QString selectedId() const;
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r45282 r45290  
    2828#include <QResizeEvent>
    2929#include <QStackedWidget>
     30#include <QTimer>
    3031
    3132/* Local includes: */
     
    7677                                   Qt::WindowFlags flags /* = Qt::Window */)
    7778    : QIWithRetranslateUI2<QMainWindow>(pParent, flags)
     79    , m_fPolished(false)
     80    , m_fWarningAboutInaccessibleMediumShown(false)
    7881    , m_pSplitter(0)
    7982#ifndef Q_WS_MAC
     
    8588    , m_pDetails(0)
    8689    , m_pVMDesktop(0)
    87     , m_fDoneInaccessibleWarningOnce(false)
    8890{
    8991    /* Remember self: */
     
    169171}
    170172
    171 void UISelectorWindow::sltMediumEnumFinished(const VBoxMediaList &list)
    172 {
    173     /* We warn about inaccessible media only once
     173void UISelectorWindow::sltMediumEnumFinished()
     174{
     175    /* We try to warn about inaccessible mediums only once
    174176     * (after media emumeration started from main() at startup),
    175177     * to avoid annoying the user: */
    176     if (m_fDoneInaccessibleWarningOnce)
    177         return;
    178     m_fDoneInaccessibleWarningOnce = true;
    179 
    180     /* Ignore the signal if a modal widget is currently active
    181      * (we won't be able to properly show the modeless VDI manager window in this case): */
    182     // TODO: Not sure that is required at all...
    183     if (QApplication::activeModalWidget())
    184         return;
    185 
    186     /* Ignore the signal if a UIMediumManager window is active: */
    187     // TODO: Thats a very dirty way, rework required!
    188     if (qApp->activeWindow() &&
    189         !strcmp(qApp->activeWindow()->metaObject()->className(), "UIMediumManager"))
    190         return;
    191 
    192     /* Look for at least one inaccessible media: */
     178    if (m_fWarningAboutInaccessibleMediumShown)
     179        return;
     180    m_fWarningAboutInaccessibleMediumShown = true;
     181
     182    /* Make sure MM window is not opened: */
     183    if (UIMediumManager::modelessInstance())
     184        return;
     185
     186    /* Look for at least one inaccessible medium: */
     187    const VBoxMediaList &list = vboxGlobal().currentMediaList();
    193188    VBoxMediaList::const_iterator it;
    194189    for (it = list.begin(); it != list.end(); ++it)
    195190        if ((*it).state() == KMediumState_Inaccessible)
    196191            break;
    197     /* Ask the user about: */
     192
     193    /* Warn the user about inaccessible medium: */
    198194    if (it != list.end() && msgCenter().remindAboutInaccessibleMedia())
    199195    {
    200         /* Show the VMM dialog without refresh: */
     196        /* Open the MM window (without refresh): */
    201197        UIMediumManager::showModeless(this, false /* refresh? */);
    202198    }
     
    312308    m_pPreferencesDialogAction->setData(true);
    313309
     310    /* Don't show the inaccessible warning
     311     * if the user tries to open global settings: */
     312    m_fWarningAboutInaccessibleMediumShown = true;
     313
    314314    /* Create and execute global settings dialog: */
    315315    UISettingsDialogGlobal dialog(this);
     
    402402    }
    403403
    404     /* Don't show the inaccessible warning if the user tries to open VM settings: */
    405     m_fDoneInaccessibleWarningOnce = true;
     404    /* Don't show the inaccessible warning
     405     * if the user tries to open VM settings: */
     406    m_fWarningAboutInaccessibleMediumShown = true;
    406407
    407408    /* Create and execute corresponding VM settings dialog: */
     
    10011002}
    10021003
     1004void UISelectorWindow::showEvent(QShowEvent *pEvent)
     1005{
     1006    /* Call to base-class: */
     1007    QMainWindow::showEvent(pEvent);
     1008
     1009    /* Is polishing required? */
     1010    if (!m_fPolished)
     1011    {
     1012        /* Pass the show-event to polish-event: */
     1013        polishEvent(pEvent);
     1014        /* Mark as polished: */
     1015        m_fPolished = true;
     1016    }
     1017}
     1018
     1019void UISelectorWindow::polishEvent(QShowEvent*)
     1020{
     1021    /* Make sure user warned about inaccessible medium(s)
     1022     * even if enumeration had finished before selector window shown: */
     1023    QTimer::singleShot(0, this, SLOT(sltMediumEnumFinished()));
     1024}
     1025
    10031026void UISelectorWindow::closeEvent(QCloseEvent *pEvent)
    10041027{
     
    13791402{
    13801403    /* Medium enumeration connections: */
    1381     connect(&vboxGlobal(), SIGNAL(mediumEnumFinished(const VBoxMediaList &)), this, SLOT(sltMediumEnumFinished(const VBoxMediaList &)));
     1404    connect(&vboxGlobal(), SIGNAL(mediumEnumFinished(const VBoxMediaList &)), this, SLOT(sltMediumEnumFinished()));
    13821405
    13831406    /* Menu-bar connections: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h

    r44354 r45290  
    7070
    7171    /* Handler: Medium enumeration stuff: */
    72     void sltMediumEnumFinished(const VBoxMediaList &mediumList);
     72    void sltMediumEnumFinished();
    7373
    7474    /* Handler: Menubar/status stuff: */
     
    115115    /* Event handlers: */
    116116    bool event(QEvent *pEvent);
     117    void showEvent(QShowEvent *pEvent);
     118    void polishEvent(QShowEvent *pEvent);
    117119    void closeEvent(QCloseEvent *pEvent);
    118120#ifdef Q_WS_MAC
     
    157159    static bool isAtLeastOneItemStarted(const QList<UIVMItem*> &items);
    158160    static bool isAtLeastOneItemRunning(const QList<UIVMItem*> &items);
     161
     162    /* Variables: */
     163    bool m_fPolished : 1;
     164    bool m_fWarningAboutInaccessibleMediumShown : 1;
    159165
    160166    /* Central splitter window: */
     
    240246    /* Other variables: */
    241247    QRect m_normalGeo;
    242     bool m_fDoneInaccessibleWarningOnce : 1;
    243248};
    244249
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