VirtualBox

Changeset 45432 in vbox


Ignore:
Timestamp:
Apr 9, 2013 1:03:52 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
84863
Message:

FE/Qt: Moving main-app window provider functions into Modal-window manager.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIFileDialog.cpp

    r45377 r45432  
    267267            QString result;
    268268
    269             QWidget *topParent = mwManager().realParentWindow(mParent ? mParent : msgCenter().mainWindowShown());
     269            QWidget *topParent = windowManager().realParentWindow(mParent ? mParent : msgCenter().mainWindowShown());
    270270            QString title = mCaption.isNull() ? tr ("Select a directory") : mCaption;
    271271
     
    468468            QString title = mCaption.isNull() ? tr ("Select a file") : mCaption;
    469469
    470             QWidget *topParent = mwManager().realParentWindow(mParent ? mParent : msgCenter().mainWindowShown());
     470            QWidget *topParent = windowManager().realParentWindow(mParent ? mParent : msgCenter().mainWindowShown());
    471471            QString winFilters = winFilter (mFilters);
    472472            AssertCompile (sizeof (TCHAR) == sizeof (QChar));
     
    717717            QString title = mCaption.isNull() ? tr ("Select a file") : mCaption;
    718718
    719             QWidget *topParent = mwManager().realParentWindow(mParent ? mParent : msgCenter().mainWindowShown());
     719            QWidget *topParent = windowManager().realParentWindow(mParent ? mParent : msgCenter().mainWindowShown());
    720720            QString winFilters = winFilter (mFilters);
    721721            AssertCompile (sizeof (TCHAR) == sizeof (QChar));
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r45427 r45432  
    243243
    244244    /* Create message-box: */
    245     QWidget *pBoxParent = mwManager().realParentWindow(pParent);
     245    QWidget *pBoxParent = windowManager().realParentWindow(pParent);
    246246    QPointer<QIMessageBox> pBox = new QIMessageBox(strTitle, strMessage, icon,
    247247                                                   iButton1, iButton2, iButton3, pBoxParent);
    248     mwManager().registerNewParent(pBox, pBoxParent);
     248    windowManager().registerNewParent(pBox, pBoxParent);
    249249
    250250    /* Load option: */
     
    293293
    294294    /* Create progress-dialog: */
    295     QWidget *pDlgParent = mwManager().realParentWindow(pParent ? pParent : mainWindowShown());
     295    QWidget *pDlgParent = windowManager().realParentWindow(pParent ? pParent : windowManager().mainWindowShown());
    296296    QPointer<UIProgressDialog> pProgressDlg = new UIProgressDialog(progress, strTitle, pPixmap, cMinDuration, pDlgParent);
    297     mwManager().registerNewParent(pProgressDlg, pDlgParent);
     297    windowManager().registerNewParent(pProgressDlg, pDlgParent);
    298298
    299299    /* Run the dialog with the 350 ms refresh interval. */
     
    312312
    313313    return true;
    314 }
    315 
    316 QWidget* UIMessageCenter::mainWindowShown() const
    317 {
    318     /* It may happen that this method is called during VBoxGlobal
    319      * initialization or even after it failed (for example, to show some error message).
    320      * Return no main window in this case: */
    321     if (!vboxGlobal().isValid())
    322         return 0;
    323 
    324     /* For VM console process: */
    325     if (vboxGlobal().isVMConsoleProcess())
    326     {
    327         /* It will be currently active machine-window if visible: */
    328         if (vboxGlobal().activeMachineWindow()->isVisible())
    329             return vboxGlobal().activeMachineWindow();
    330     }
    331     /* Otherwise: */
    332     else
    333     {
    334         /* It will be the selector window if visible: */
    335         if (vboxGlobal().selectorWnd().isVisible())
    336             return &vboxGlobal().selectorWnd();
    337     }
    338 
    339     /* Nothing by default: */
    340     return 0;
    341 }
    342 
    343 QWidget* UIMessageCenter::networkManagerOrMainWindowShown() const
    344 {
    345     return gNetworkManager->window()->isVisible() ? gNetworkManager->window() : mainWindowShown();
    346314}
    347315
     
    19891957bool UIMessageCenter::confirmCancelingAllNetworkRequests() const
    19901958{
    1991     return questionBinary(networkManagerOrMainWindowShown(), MessageType_Question,
     1959    return questionBinary(windowManager().networkManagerOrMainWindowShown(), MessageType_Question,
    19921960                          tr("Do you wish to cancel all current network operations?"));
    19931961}
     
    19951963void UIMessageCenter::showUpdateSuccess(const QString &strVersion, const QString &strLink) const
    19961964{
    1997     alert(networkManagerOrMainWindowShown(), MessageType_Info,
     1965    alert(windowManager().networkManagerOrMainWindowShown(), MessageType_Info,
    19981966          tr("<p>A new version of VirtualBox has been released! Version <b>%1</b> is available "
    19991967             "at <a href=\"http://www.virtualbox.org/\">virtualbox.org</a>.</p>"
     
    20051973void UIMessageCenter::showUpdateNotFound() const
    20061974{
    2007     alert(networkManagerOrMainWindowShown(), MessageType_Info,
     1975    alert(windowManager().networkManagerOrMainWindowShown(), MessageType_Info,
    20081976          tr("You are already running the most recent version of VirtualBox."));
    20091977}
     
    20111979void UIMessageCenter::askUserToDownloadExtensionPack(const QString &strExtPackName, const QString &strExtPackVersion, const QString &strVBoxVersion) const
    20121980{
    2013     alert(networkManagerOrMainWindowShown(), MessageType_Info,
     1981    alert(windowManager().networkManagerOrMainWindowShown(), MessageType_Info,
    20141982          tr("<p>You have version %1 of the <b><nobr>%2</nobr></b> installed.</p>"
    20151983             "<p>You should download and install version %3 of this extension pack from Oracle!</p>")
     
    20281996bool UIMessageCenter::confirmDownloadGuestAdditions(const QString &strUrl, qulonglong uSize) const
    20291997{
    2030     return questionBinary(networkManagerOrMainWindowShown(), MessageType_Question,
     1998    return questionBinary(windowManager().networkManagerOrMainWindowShown(), MessageType_Question,
    20311999                          tr("<p>Are you sure you want to download the <b>VirtualBox Guest Additions</b> CD image "
    20322000                             "from <nobr><a href=\"%1\">%1</a></nobr> (size %2 bytes)?</p>")
     
    20382006void UIMessageCenter::cannotSaveGuestAdditions(const QString &strURL, const QString &strTarget) const
    20392007{
    2040     alert(networkManagerOrMainWindowShown(), MessageType_Error,
     2008    alert(windowManager().networkManagerOrMainWindowShown(), MessageType_Error,
    20412009          tr("<p>The <b>VirtualBox Guest Additions</b> CD image has been successfully downloaded "
    20422010             "from <nobr><a href=\"%1\">%1</a></nobr> "
     
    20482016bool UIMessageCenter::proposeMountGuestAdditions(const QString &strUrl, const QString &strSrc) const
    20492017{
    2050     return questionBinary(networkManagerOrMainWindowShown(), MessageType_Question,
     2018    return questionBinary(windowManager().networkManagerOrMainWindowShown(), MessageType_Question,
    20512019                          tr("<p>The <b>VirtualBox Guest Additions</b> CD image has been successfully downloaded "
    20522020                             "from <nobr><a href=\"%1\">%1</a></nobr> "
     
    20872055bool UIMessageCenter::confirmDownloadUserManual(const QString &strURL, qulonglong uSize) const
    20882056{
    2089     return questionBinary(networkManagerOrMainWindowShown(), MessageType_Question,
     2057    return questionBinary(windowManager().networkManagerOrMainWindowShown(), MessageType_Question,
    20902058                          tr("<p>Are you sure you want to download the <b>VirtualBox User Manual</b> "
    20912059                             "from <nobr><a href=\"%1\">%1</a></nobr> (size %2 bytes)?</p>")
     
    20972065void UIMessageCenter::cannotSaveUserManual(const QString &strURL, const QString &strTarget) const
    20982066{
    2099     alert(networkManagerOrMainWindowShown(), MessageType_Error,
     2067    alert(windowManager().networkManagerOrMainWindowShown(), MessageType_Error,
    21002068          tr("<p>The VirtualBox User Manual has been successfully downloaded "
    21012069             "from <nobr><a href=\"%1\">%1</a></nobr> "
     
    21072075void UIMessageCenter::warnAboutUserManualDownloaded(const QString &strURL, const QString &strTarget) const
    21082076{
    2109     alert(networkManagerOrMainWindowShown(), MessageType_Warning,
     2077    alert(windowManager().networkManagerOrMainWindowShown(), MessageType_Warning,
    21102078          tr("<p>The VirtualBox User Manual has been successfully downloaded "
    21112079             "from <nobr><a href=\"%1\">%1</a></nobr> "
     
    21162084bool UIMessageCenter::warAboutOutdatedExtensionPack(const QString &strExtPackName, const QString &strExtPackVersion) const
    21172085{
    2118     return questionBinary(networkManagerOrMainWindowShown(), MessageType_Question,
     2086    return questionBinary(windowManager().networkManagerOrMainWindowShown(), MessageType_Question,
    21192087                          tr("<p>You have an old version (%1) of the <b><nobr>%2</nobr></b> installed.</p>"
    21202088                             "<p>Do you wish to download latest one from the Internet?</p>")
     
    21262094bool UIMessageCenter::confirmDownloadExtensionPack(const QString &strExtPackName, const QString &strURL, qulonglong uSize) const
    21272095{
    2128     return questionBinary(networkManagerOrMainWindowShown(), MessageType_Question,
     2096    return questionBinary(windowManager().networkManagerOrMainWindowShown(), MessageType_Question,
    21292097                          tr("<p>Are you sure you want to download the <b><nobr>%1</nobr></b> "
    21302098                             "from <nobr><a href=\"%2\">%2</a></nobr> (size %3 bytes)?</p>")
     
    21362104void UIMessageCenter::cannotSaveExtensionPack(const QString &strExtPackName, const QString &strFrom, const QString &strTo) const
    21372105{
    2138     alert(networkManagerOrMainWindowShown(), MessageType_Error,
     2106    alert(windowManager().networkManagerOrMainWindowShown(), MessageType_Error,
    21392107          tr("<p>The <b><nobr>%1</nobr></b> has been successfully downloaded "
    21402108             "from <nobr><a href=\"%2\">%2</a></nobr> "
     
    21462114bool UIMessageCenter::proposeInstallExtentionPack(const QString &strExtPackName, const QString &strFrom, const QString &strTo) const
    21472115{
    2148     return questionBinary(networkManagerOrMainWindowShown(), MessageType_Question,
     2116    return questionBinary(windowManager().networkManagerOrMainWindowShown(), MessageType_Question,
    21492117                          tr("<p>The <b><nobr>%1</nobr></b> has been successfully downloaded "
    21502118                             "from <nobr><a href=\"%2\">%2</a></nobr> "
     
    24692437    AssertWrapperOk(vbox);
    24702438
    2471     (new VBoxAboutDlg(mainWindowShown(), strFullVersion))->show();
     2439    (new VBoxAboutDlg(windowManager().mainWindowShown(), strFullVersion))->show();
    24722440}
    24732441
     
    27552723
    27562724    /* Create message-box: */
    2757     QWidget *pMessageBoxParent = mwManager().realParentWindow(pParent ? pParent : mainWindowShown());
     2725    QWidget *pMessageBoxParent = windowManager().realParentWindow(pParent ? pParent : windowManager().mainWindowShown());
    27582726    QPointer<QIMessageBox> pMessageBox = new QIMessageBox(title, strMessage, icon,
    27592727                                                          iButton1, iButton2, iButton3,
    27602728                                                          pMessageBoxParent);
    2761     mwManager().registerNewParent(pMessageBox, pMessageBoxParent);
     2729    windowManager().registerNewParent(pMessageBox, pMessageBoxParent);
    27622730
    27632731    /* Prepare auto-confirmation check-box: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r45427 r45432  
    151151                                 const QString &strImage = "", QWidget *pParent = 0,
    152152                                 int cMinDuration = 2000);
    153 
    154     /* API: Main window stuff: */
    155     QWidget* mainWindowShown() const;
    156     QWidget* networkManagerOrMainWindowShown() const;
    157153
    158154    /* API: Main (startup) warnings: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIModalWindowManager.cpp

    r45183 r45432  
    2020/* GUI includes: */
    2121#include "UIModalWindowManager.h"
     22#include "UINetworkManagerDialog.h"
     23#include "UINetworkManager.h"
     24#include "UISelectorWindow.h"
     25#include "VBoxGlobal.h"
    2226
    2327/* Other VBox includes: */
     
    6266    if (m_spInstance == this)
    6367        m_spInstance = 0;
     68}
     69
     70QWidget* UIModalWindowManager::mainWindowShown() const
     71{
     72    /* Later this function will be independent of VBoxGlobal at all,
     73     * but for now VBoxGlobal creates all the main application windows,
     74     * so we should honor this fact.
     75     *
     76     * It may happen that this method is called during VBoxGlobal
     77     * initialization or even after it had failed (for example, to show some message).
     78     * Return NULL pointer in this case: */
     79    if (!vboxGlobal().isValid())
     80        return 0;
     81
     82    /* For VM console process: */
     83    if (vboxGlobal().isVMConsoleProcess())
     84    {
     85        /* It will be currently active machine-window if visible: */
     86        if (vboxGlobal().activeMachineWindow()->isVisible())
     87            return vboxGlobal().activeMachineWindow();
     88    }
     89    /* Otherwise: */
     90    else
     91    {
     92        /* It will be the selector window if visible: */
     93        if (vboxGlobal().selectorWnd().isVisible())
     94            return &vboxGlobal().selectorWnd();
     95    }
     96
     97    /* Nothing by default: */
     98    return 0;
     99}
     100
     101QWidget* UIModalWindowManager::networkManagerOrMainWindowShown() const
     102{
     103    /* It may happen that this method is called before network-manager initialization
     104     * or when the network-manager is hidden, return main application window in this case: */
     105    return gNetworkManager && gNetworkManager->window()->isVisible() ? gNetworkManager->window() : mainWindowShown();
    64106}
    65107
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIModalWindowManager.h

    r45429 r45432  
    4646    void registerNewParent(QWidget *pWindow, QWidget *pParentWindow = 0);
    4747
     48    /* API: Main application window stuff: */
     49    QWidget* mainWindowShown() const;
     50    QWidget* networkManagerOrMainWindowShown() const;
     51
    4852private slots:
    4953
     
    6670    /* Static API: Instance stuff: */
    6771    static UIModalWindowManager* instance();
    68     friend UIModalWindowManager& mwManager();
     72    friend UIModalWindowManager& windowManager();
    6973};
    7074
    7175/* Shortcut to the static UIModalWindowManager::instance() method: */
    72 inline UIModalWindowManager& mwManager() { return *(UIModalWindowManager::instance()); }
     76inline UIModalWindowManager& windowManager() { return *(UIModalWindowManager::instance()); }
    7377
    7478#endif /* !__UIModalWindowManager_h__ */
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UIDownloaderAdditions.cpp

    r45371 r45432  
    2828#include "VBoxGlobal.h"
    2929#include "UIMessageCenter.h"
     30#include "UIModalWindowManager.h"
    3031
    3132/* static */
     
    103104        /* Ask the user for another location for the additions-image file: */
    104105        QString strTarget = QIFileDialog::getExistingDirectory(QFileInfo(target()).absolutePath(),
    105                                                                msgCenter().networkManagerOrMainWindowShown(),
     106                                                               windowManager().networkManagerOrMainWindowShown(),
    106107                                                               tr("Select folder to save Guest Additions image to"), true);
    107108
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UIDownloaderExtensionPack.cpp

    r45342 r45432  
    2929#include "VBoxGlobal.h"
    3030#include "UIMessageCenter.h"
     31#include "UIModalWindowManager.h"
    3132
    3233/* static */
     
    120121        /* Ask the user for another location for the extension-pack file: */
    121122        QString strTarget = QIFileDialog::getExistingDirectory(QFileInfo(target()).absolutePath(),
    122                                                                msgCenter().networkManagerOrMainWindowShown(),
     123                                                               windowManager().networkManagerOrMainWindowShown(),
    123124                                                               tr("Select folder to save %1 to").arg(GUI_ExtPackName), true);
    124125
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UIDownloaderUserManual.cpp

    r45342 r45432  
    2828#include "VBoxGlobal.h"
    2929#include "UIMessageCenter.h"
     30#include "UIModalWindowManager.h"
    3031
    3132/* static */
     
    107108        /* Ask the user for another location for the user-manual file: */
    108109        QString strTarget = QIFileDialog::getExistingDirectory(QFileInfo(target()).absolutePath(),
    109                                                                msgCenter().networkManagerOrMainWindowShown(),
     110                                                               windowManager().networkManagerOrMainWindowShown(),
    110111                                                               tr("Select folder to save User Manual to"), true);
    111112
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkManagerDialog.cpp

    r45377 r45432  
    3434#include "VBoxGlobal.h"
    3535#include "UIMessageCenter.h"
     36#include "UIModalWindowManager.h"
    3637#include "QIDialogButtonBox.h"
    3738
     
    168169
    169170    /* Center according current main application window: */
    170     vboxGlobal().centerWidget(this, msgCenter().mainWindowShown(), false);
     171    vboxGlobal().centerWidget(this, windowManager().mainWindowShown(), false);
    171172
    172173    /* Pass event to the base-class: */
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateManager.cpp

    r45371 r45432  
    3232#include "VBoxGlobal.h"
    3333#include "UIMessageCenter.h"
     34#include "UIModalWindowManager.h"
    3435#include "VBoxUtils.h"
    3536#include "UIDownloaderExtensionPack.h"
     
    443444        /* Warn the user about extension pack was downloaded and saved, propose to install it: */
    444445        if (msgCenter().proposeInstallExtentionPack(GUI_ExtPackName, strSource, QDir::toNativeSeparators(strTarget)))
    445             UIGlobalSettingsExtension::doInstallation(strTarget, strDigest, msgCenter().networkManagerOrMainWindowShown(), NULL);
     446            UIGlobalSettingsExtension::doInstallation(strTarget, strDigest, windowManager().networkManagerOrMainWindowShown(), NULL);
    446447    }
    447448};
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r45424 r45432  
    999999
    10001000    /* Create take-snapshot dialog: */
    1001     QWidget *pDlgParent = mwManager().realParentWindow(activeMachineWindow());
     1001    QWidget *pDlgParent = windowManager().realParentWindow(activeMachineWindow());
    10021002    QPointer<VBoxTakeSnapshotDlg> pDlg = new VBoxTakeSnapshotDlg(pDlgParent, machine);
    1003     mwManager().registerNewParent(pDlg, pDlgParent);
     1003    windowManager().registerNewParent(pDlg, pDlgParent);
    10041004
    10051005    /* Assign corresponding icon: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r45377 r45432  
    273273
    274274    /* Prepare close-dialog: */
    275     QWidget *pParentDlg = mwManager().realParentWindow(this);
     275    QWidget *pParentDlg = windowManager().realParentWindow(this);
    276276    QPointer<UIVMCloseDialog> pCloseDlg = new UIVMCloseDialog(pParentDlg, machineCopy, session());
    277     mwManager().registerNewParent(pCloseDlg, pParentDlg);
     277    windowManager().registerNewParent(pCloseDlg, pParentDlg);
    278278
    279279    /* Makes sure the dialog is valid: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.cpp

    r45371 r45432  
    814814        {
    815815            /* Create take-snapshot dialog: */
    816             QWidget *pDlgParent = mwManager().realParentWindow(this);
     816            QWidget *pDlgParent = windowManager().realParentWindow(this);
    817817            QPointer<VBoxTakeSnapshotDlg> pDlg = new VBoxTakeSnapshotDlg(pDlgParent, mMachine);
    818             mwManager().registerNewParent(pDlg, pDlgParent);
     818            windowManager().registerNewParent(pDlg, pDlgParent);
    819819
    820820            /* Assign corresponding icon: */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIProgressDialog.cpp

    r45335 r45432  
    193193     * modal dialog prevents our event-loop from
    194194     * being exit overlapping 'this'. */
    195     if (m_fEnded && !isHidden() && mwManager().isWindowOnTheTopOfTheModalWindowStack(this))
     195    if (m_fEnded && !isHidden() && windowManager().isWindowOnTheTopOfTheModalWindowStack(this))
    196196    {
    197197        hide();
     
    204204    {
    205205        /* Is this progress-dialog a top-level modal-dialog now? */
    206         if (mwManager().isWindowOnTheTopOfTheModalWindowStack(this))
     206        if (windowManager().isWindowOnTheTopOfTheModalWindowStack(this))
    207207        {
    208208            /* Progress finished: */
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