VirtualBox

Changeset 69004 in vbox


Ignore:
Timestamp:
Oct 6, 2017 2:22:50 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8674: A bit of rework for UIProgressDialog (part 4): Reworking progress-dialog close routine, to be reused.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/widgets
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIProgressDialog.cpp

    r69000 r69004  
    2929
    3030/* GUI includes: */
    31 # include "UIProgressDialog.h"
    32 # include "UIErrorString.h"
    33 # include "UISpecialControls.h"
    34 # include "UIModalWindowManager.h"
    3531# include "QIDialogButtonBox.h"
    3632# include "QILabel.h"
     33# include "UIErrorString.h"
     34# include "UIModalWindowManager.h"
     35# include "UIProgressDialog.h"
     36# include "UISpecialControls.h"
    3737# include "VBoxGlobal.h"
    3838# ifdef VBOX_WS_MAC
     
    4545#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    4646
     47
     48/*********************************************************************************************************************************
     49*   Class UIProgressDialog implementation.                                                                                       *
     50*********************************************************************************************************************************/
    4751
    4852const char *UIProgressDialog::m_spcszOpDescTpl = "%1 ... (%2/%3)";
     
    400404}
    401405
     406void UIProgressDialog::closeProgressDialog()
     407{
     408    /* If window is on the top of the stack: */
     409    if (windowManager().isWindowOnTheTopOfTheModalWindowStack(this))
     410    {
     411        /* Progress completed? */
     412        if (m_comProgress.isOk())
     413            done(Accepted);
     414        /* Or aborted? */
     415        else
     416            done(Rejected);
     417
     418        /* Mark progress-dialog finished: */
     419        m_fEnded = true;
     420    }
     421}
     422
    402423void UIProgressDialog::handleTimerEvent()
    403424{
    404     /* We should hide progress-dialog
    405      * if it was already finalized but not yet closed.
    406      * This could happens in case of some other
    407      * modal dialog prevents our event-loop from
    408      * being exit overlapping 'this'. */
    409     if (m_fEnded && !isHidden() && windowManager().isWindowOnTheTopOfTheModalWindowStack(this))
    410     {
    411         hide();
     425    /* If progress-dialog is ended: */
     426    if (m_fEnded)
     427    {
     428        // WORKAROUND:
     429        // We should hide progress-dialog if it was already ended but not yet closed.  This could happen
     430        // in case if some other modal dialog prevents our event-loop from being exit overlapping 'this'.
     431        /* If window is on the top of the stack and still shown: */
     432        if (!isHidden() && windowManager().isWindowOnTheTopOfTheModalWindowStack(this))
     433            hide();
     434
    412435        return;
    413436    }
    414     else if (m_fEnded)
    415         return;
    416 
    417     if (!m_fEnded && (!m_comProgress.isOk() || m_comProgress.GetCompleted()))
    418     {
    419         /* Is this progress-dialog a top-level modal-dialog now? */
    420         if (windowManager().isWindowOnTheTopOfTheModalWindowStack(this))
    421         {
    422             /* Progress finished: */
    423             if (m_comProgress.isOk())
    424             {
    425                 m_pProgressBar->setValue(100);
    426                 done(Accepted);
    427             }
    428             /* Progress is not valid: */
    429             else
    430                 done(Rejected);
    431 
    432             /* Request to exit loop: */
    433             m_fEnded = true;
    434             return;
    435         }
    436 
    437         /* Else we should wait until all the subsequent
    438          * top-level modal-dialog(s) will be dismissed: */
    439         return;
     437
     438    /* If progress-dialog is not yet ended but progress is aborted or completed: */
     439    if (!m_comProgress.isOk() || m_comProgress.GetCompleted())
     440    {
     441        /* Set progress to 100%: */
     442        m_pProgressBar->setValue(100);
     443
     444        /* Try to close the dialog: */
     445        return closeProgressDialog();
    440446    }
    441447
     
    445451}
    446452
     453
     454/*********************************************************************************************************************************
     455*   Class UIProgress implementation.                                                                                             *
     456*********************************************************************************************************************************/
    447457
    448458UIProgress::UIProgress(CProgress &progress, QObject *pParent /* = 0 */)
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIProgressDialog.h

    r69000 r69004  
    2424
    2525/* Forward declarations: */
     26class QLabel;
    2627class QProgressBar;
    27 class QLabel;
    2828class QILabel;
    2929class UIMiniCancelButton;
     
    104104    /** Updates progress-dialog percentage. */
    105105    void updateProgressPercentage(int iPercent = -1);
     106
     107    /** Closes progress dialog (if possible). */
     108    void closeProgressDialog();
    106109
    107110    /** Performes timer event handling. */
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