VirtualBox

Changeset 37106 in vbox


Ignore:
Timestamp:
May 16, 2011 2:50:12 PM (14 years ago)
Author:
vboxsync
Message:

FE/Qt: 4989: Lazy init VM settings dialog: Added a progress-bar reflecting the progress of settings-loading procedure.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.cpp

    r36589 r37106  
    1919
    2020/* Global includes */
     21#include <QProgressBar>
    2122#include <QPushButton>
    2223#include <QStackedWidget>
     
    5152    , m_dialogType(settingsDialogType)
    5253    , m_fPolished(false)
    53     /* Loading stuff: */
     54    /* Loading/saving stuff: */
    5455    , m_fProcessed(false)
     56    /* Status bar stuff: */
     57    , m_pStatusBar(new QStackedWidget(this))
     58    /* Process bar stuff: */
     59    , m_pProcessBar(new QProgressBar(this))
    5560    /* Error/Warning stuff: */
    5661    , m_fValid(true)
     
    104109    pStackLayout->addWidget(m_pStack);
    105110
     111    /* Status bar: */
     112    m_pStatusBar->addWidget(new QWidget);
     113    m_pButtonBox->addExtraWidget(m_pStatusBar);
     114
     115    /* Setup process bar stuff: */
     116    m_pStatusBar->addWidget(m_pProcessBar);
     117
    106118    /* Setup error & warning stuff: */
    107     m_pButtonBox->addExtraWidget(m_pWarningPane);
     119    m_pStatusBar->addWidget(m_pWarningPane);
    108120    m_errorIcon = UIIconPool::defaultIcon(UIIconPool::MessageBoxCriticalIcon, this).pixmap(16, 16);
    109121    m_warningIcon = UIIconPool::defaultIcon(UIIconPool::MessageBoxWarningIcon, this).pixmap(16, 16);
     
    197209}
    198210
     211void UISettingsDialog::sltHandleProcessStarted()
     212{
     213    m_pProcessBar->setValue(0);
     214    m_pStatusBar->setCurrentWidget(m_pProcessBar);
     215}
     216
     217void UISettingsDialog::sltHandlePageProcessed()
     218{
     219    m_pProcessBar->setValue(m_pProcessBar->value() + 1);
     220    if (m_pProcessBar->value() == m_pProcessBar->maximum())
     221    {
     222        if (!m_fValid || !m_fSilent)
     223            m_pStatusBar->setCurrentWidget(m_pWarningPane);
     224        else
     225            m_pStatusBar->setCurrentIndex(0);
     226    }
     227}
     228
    199229void UISettingsDialog::retranslateUi()
    200230{
     
    245275    if (m_fPolished)
    246276    {
    247         if (!m_strErrorString.isEmpty())
     277        if (!m_strErrorString.isEmpty() && m_pStatusBar->currentWidget() == m_pWarningPane)
    248278            m_pLbWhatsThis->setText(m_strErrorString);
    249279        else
     
    261291    if (m_fPolished)
    262292    {
    263         if (!m_strWarningString.isEmpty())
     293        if (!m_strWarningString.isEmpty() && m_pStatusBar->currentWidget() == m_pWarningPane)
    264294            m_pLbWhatsThis->setText(m_strWarningString);
    265295        else
     
    295325        m_pages[cId] = m_pStack->addWidget(pPage);
    296326#endif /* !Q_WS_MAC */
     327        /* Update process bar: */
     328        m_pProcessBar->setMinimum(0);
     329        m_pProcessBar->setMaximum(m_pStack->count());
    297330    }
    298331    if (pSettingsPage)
     
    334367
    335368        m_fValid = fNewValid;
     369        m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(m_fValid);
    336370        m_pWarningPane->setWarningPixmap(m_errorIcon);
    337371        m_pWarningPane->setWarningText(m_strErrorHint);
     
    339373        m_pWarningPane->setToolTip(m_strErrorString);
    340374#endif /* Q_WS_MAC */
    341         m_pWarningPane->setVisible(!m_fValid);
    342         m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(m_fValid);
     375        if (m_fValid && m_pStatusBar->currentWidget() == m_pWarningPane)
     376            m_pStatusBar->setCurrentIndex(0);
     377        else if (!m_fValid && m_pStatusBar->currentIndex() == 0)
     378            m_pStatusBar->setCurrentWidget(m_pWarningPane);
    343379
    344380        if (!m_fValid)
     
    375411        m_pWarningPane->setToolTip(m_strWarningString);
    376412#endif /* Q_WS_MAC */
    377         m_pWarningPane->setVisible(!m_fSilent);
     413        if (m_fSilent && m_pStatusBar->currentWidget() == m_pWarningPane)
     414            m_pStatusBar->setCurrentIndex(0);
     415        else if (!m_fSilent && m_pStatusBar->currentIndex() == 0)
     416            m_pStatusBar->setCurrentWidget(m_pWarningPane);
    378417    }
    379418}
     
    408447
    409448#ifndef Q_WS_MAC
    410     if (strWhatsThisText.isEmpty() && !m_strErrorString.isEmpty())
    411         strWhatsThisText = m_strErrorString;
    412     else if (strWhatsThisText.isEmpty() && !m_strWarningString.isEmpty())
    413         strWhatsThisText = m_strWarningString;
     449    if (m_pStatusBar->currentWidget() == m_pWarningPane)
     450    {
     451        if (strWhatsThisText.isEmpty() && !m_strErrorString.isEmpty())
     452            strWhatsThisText = m_strErrorString;
     453        else if (strWhatsThisText.isEmpty() && !m_strWarningString.isEmpty())
     454            strWhatsThisText = m_strWarningString;
     455    }
    414456    if (strWhatsThisText.isEmpty())
    415457        strWhatsThisText = whatsThis();
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.h

    r36592 r37106  
    2828/* Forward declarations: */
    2929class QIWidgetValidator;
     30class QProgressBar;
    3031class QStackedWidget;
    3132class QTimer;
     
    6263    /* Mark dialog as processed: */
    6364    virtual void sltMarkProcessed();
     65
     66    /* Handlers for process bar: */
     67    void sltHandleProcessStarted();
     68    void sltHandlePageProcessed();
    6469
    6570protected:
     
    116121    bool m_fPolished;
    117122
     123    /* Loading/saving stuff: */
     124    bool m_fProcessed;
     125
     126    /* Status bar widget: */
     127    QStackedWidget *m_pStatusBar;
     128
     129    /* Process bar widget: */
     130    QProgressBar *m_pProcessBar;
     131
    118132    /* Error & Warning stuff: */
    119     bool m_fProcessed;
    120133    bool m_fValid;
    121134    bool m_fSilent;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialogSpecific.cpp

    r37036 r37106  
    8686        , m_iIdOfHighPriorityPage(-1)
    8787    {
    88         /* Connecting thread signals: */
     88        /* Connecting this signals: */
    8989        connect(this, SIGNAL(sigNotifyAboutPageProcessed(int)), this, SLOT(sltHandleProcessedPage(int)), Qt::QueuedConnection);
    9090        connect(this, SIGNAL(sigNotifyAboutPagesProcessed()), this, SLOT(sltHandleProcessedPages()), Qt::QueuedConnection);
    9191        connect(this, SIGNAL(finished()), this, SLOT(sltDestroySerializer()), Qt::QueuedConnection);
     92        /* Connecting parent signals: */
     93        connect(this, SIGNAL(sigNotifyAboutProcessStarted()), parent(), SLOT(sltHandleProcessStarted()), Qt::QueuedConnection);
     94        connect(this, SIGNAL(sigNotifyAboutPageProcessed(int)), parent(), SLOT(sltHandlePageProcessed()), Qt::QueuedConnection);
    9295
    9396        /* Set instance: */
     
    153156signals:
    154157
     158    /* Signal to notify main GUI thread about process has been started: */
     159    void sigNotifyAboutProcessStarted();
     160
    155161    /* Signal to notify main GUI thread about some page was processed: */
    156162    void sigNotifyAboutPageProcessed(int iPageId);
     
    163169    void start(Priority priority = InheritPriority)
    164170    {
     171        /* Notify listeners a bout we are starting: */
     172        emit sigNotifyAboutProcessStarted();
    165173        /* If serializer saves settings: */
    166174        if (m_direction == UISettingsSerializeDirection_Save)
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/VBoxWarningPane.cpp

    r28800 r37106  
    77
    88/*
    9  * Copyright (C) 2009 Oracle Corporation
     9 * Copyright (C) 2009-2011 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3232    pLayout->addWidget(&m_icon);
    3333    pLayout->addWidget(&m_label);
    34     setVisible(false);
    3534}
    3635
    3736void VBoxWarningPane::setWarningPixmap(const QPixmap &imgPixmap)
    3837{
    39     m_icon.setPixmap (imgPixmap);
     38    m_icon.setPixmap(imgPixmap);
    4039}
    4140
    4241void VBoxWarningPane::setWarningText(const QString &strText)
    4342{
    44     m_label.setText (strText);
     43    m_label.setText(strText);
    4544}
    4645
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