VirtualBox

Changeset 55263 in vbox


Ignore:
Timestamp:
Apr 15, 2015 5:41:04 AM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: Settings dialog: Own progress-dialog implementation.

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

Legend:

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

    r54954 r55263  
    2121/* Qt includes: */
    2222# include <QTimer>
     23# include <QLabel>
     24# include <QHBoxLayout>
     25# include <QVBoxLayout>
     26# include <QProgressBar>
    2327/* GUI includes: */
    2428# include "UISettingsSerializer.h"
    2529# include "UISettingsPage.h"
     30# include "UIIconPool.h"
    2631#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    2732
     
    171176UISettingsSerializerProgress::UISettingsSerializerProgress(QWidget *pParent, UISettingsSerializer::SerializationDirection direction,
    172177                                                           const QVariant &data, const UISettingsPageList &pages)
    173     : QIWithRetranslateUI<QProgressDialog>(pParent)
     178    : QIWithRetranslateUI<QIDialog>(pParent)
    174179    , m_direction(direction)
    175180    , m_data(data)
     
    189194
    190195    /* Call to base-class: */
    191     return QIWithRetranslateUI<QProgressDialog>::exec();
     196    return QIWithRetranslateUI<QIDialog>::exec();
    192197}
    193198
     
    202207    /* Configure self: */
    203208    setWindowModality(Qt::WindowModal);
    204     setMinimumDuration(0);
    205     setCancelButton(0);
     209    setWindowTitle(parentWidget()->windowTitle());
    206210    connect(this, SIGNAL(sigAskForProcessStart()),
    207211            this, SLOT(sltStartProcess()), Qt::QueuedConnection);
     
    218222    }
    219223
    220     /* Set maximum/minimum/current values: */
    221     setMaximum(m_pSerializer->pageCount() + 1);
    222     setMinimum(0);
    223     setValue(0);
     224    /* Create layout: */
     225    QVBoxLayout *pLayout = new QVBoxLayout(this);
     226    AssertPtrReturnVoid(pLayout);
     227    {
     228        /* Create top layout: */
     229        QHBoxLayout *pLayoutTop = new QHBoxLayout;
     230        AssertPtrReturnVoid(pLayoutTop);
     231        {
     232            /* Create pixmap label: */
     233            QLabel *pLabelPixmap = new QLabel;
     234            AssertPtrReturnVoid(pLabelPixmap);
     235            {
     236                /* Configure label: */
     237                const QIcon icon = UIIconPool::iconSet(":/progress_refresh_90px.png");
     238                pLabelPixmap->setPixmap(icon.pixmap(icon.availableSizes().first()));
     239                /* Add label into layout: */
     240                pLayoutTop->addWidget(pLabelPixmap);
     241            }
     242            /* Create progress layout: */
     243            QVBoxLayout *pLayoutProgress = new QVBoxLayout(this);
     244            AssertPtrReturnVoid(pLayoutProgress);
     245            {
     246                /* Create progress label: */
     247                m_pLabelProgress = new QLabel;
     248                AssertPtrReturnVoid(m_pLabelProgress);
     249                {
     250                    /* Add label into layout: */
     251                    pLayoutProgress->addWidget(m_pLabelProgress);
     252                }
     253                /* Create progress bar: */
     254                m_pBarProgress = new QProgressBar;
     255                AssertPtrReturnVoid(m_pBarProgress);
     256                {
     257                    /* Configure progress bar: */
     258                    m_pBarProgress->setMinimumWidth(200);
     259                    m_pBarProgress->setMaximum(m_pSerializer->pageCount() + 1);
     260                    m_pBarProgress->setMinimum(0);
     261                    m_pBarProgress->setValue(0);
     262                    connect(m_pBarProgress, SIGNAL(valueChanged(int)),
     263                            this, SLOT(sltProgressValueChanged(int)));
     264                    /* Add bar into layout: */
     265                    pLayoutProgress->addWidget(m_pBarProgress);
     266                }
     267                /* Add stretch: */
     268                pLayoutProgress->addStretch();
     269                /* Add layout into parent: */
     270                pLayoutTop->addLayout(pLayoutProgress);
     271            }
     272            /* Add layout into parent: */
     273            pLayout->addLayout(pLayoutTop);
     274        }
     275    }
    224276}
    225277
    226278void UISettingsSerializerProgress::retranslateUi()
    227279{
    228     /* Translate title: */
     280    /* Translate progress label: */
     281    AssertPtrReturnVoid(m_pLabelProgress);
    229282    switch (m_pSerializer->direction())
    230283    {
    231         case UISettingsSerializer::Load: setLabelText(tr("Loading Settings...")); break;
    232         case UISettingsSerializer::Save: setLabelText(tr("Saving Settings...")); break;
     284        case UISettingsSerializer::Load: m_pLabelProgress->setText(tr("Loading Settings...")); break;
     285        case UISettingsSerializer::Save: m_pLabelProgress->setText(tr("Saving Settings...")); break;
    233286    }
    234287}
     
    251304}
    252305
     306void UISettingsSerializerProgress::sltAdvanceProgressValue()
     307{
     308    /* Advance the serialize progress bar: */
     309    AssertPtrReturnVoid(m_pBarProgress);
     310    m_pBarProgress->setValue(m_pBarProgress->value() + 1);
     311}
     312
     313void UISettingsSerializerProgress::sltProgressValueChanged(int iValue)
     314{
     315    AssertPtrReturnVoid(m_pBarProgress);
     316    if (iValue == m_pBarProgress->maximum())
     317        hide();
     318}
     319
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSerializer.h

    r54954 r55263  
    2222#include <QVariant>
    2323#include <QWaitCondition>
    24 #include <QProgressDialog>
    2524#include <QMutex>
    2625#include <QList>
     
    2928/* GUI includes: */
    3029#include "QIWithRetranslateUI.h"
     30#include "QIDialog.h"
    3131
    3232/* Forward declarations: */
    3333class UISettingsPage;
     34class QProgressBar;
     35class QLabel;
    3436
    3537/* Type definitions: */
     
    125127};
    126128
    127 /** QProgressDialog reimplementation used to
     129/** QIDialog reimplementation used to
    128130  * reflect the settings serialization operation. */
    129 class UISettingsSerializerProgress : public QIWithRetranslateUI<QProgressDialog>
     131class UISettingsSerializerProgress : public QIWithRetranslateUI<QIDialog>
    130132{
    131133    Q_OBJECT;
     
    172174
    173175    /** Advances the current progress value. */
    174     void sltAdvanceProgressValue() { setValue(value() + 1); }
     176    void sltAdvanceProgressValue();
     177
     178    /** Handles the progress value change. */
     179    void sltProgressValueChanged(int iValue);
    175180
    176181private:
     
    186191    /** Holds the pointer to the thread loading/saving settings in async mode. */
    187192    UISettingsSerializer *m_pSerializer;
     193
     194    /** Holds the progress label. */
     195    QLabel *m_pLabelProgress;
     196    /** Holds the progress bar. */
     197    QProgressBar *m_pBarProgress;
    188198};
    189199
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