VirtualBox

Changeset 9296 in vbox


Ignore:
Timestamp:
Jun 2, 2008 12:58:24 PM (16 years ago)
Author:
vboxsync
Message:

FE/Qt4: Readded the progress bar to the VDM. QIDialogButtonBox can now display
an extra item in the empty space.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox4/include/QIDialogButtonBox.h

    r9056 r9296  
    2929#include <QDialogButtonBox>
    3030
     31class QBoxLayout;
     32
    3133class QIDialogButtonBox: public QIWithRetranslateUI<QDialogButtonBox>
    3234{
     
    4143    void setStandardButtons (StandardButtons aButtons);
    4244
     45    void addExtraWidget (QWidget *aWidget);
     46    void addExtraLayout (QLayout *aLayout);
     47
    4348protected:
     49
     50    QBoxLayout *boxLayout() const;
     51    int findEmptySpace (QBoxLayout *aLayout) const;
    4452
    4553    void retranslateUi();
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxDiskImageManagerDlg.h

    r9257 r9296  
    3434class VBoxToolBar;
    3535class InfoPaneLabel;
     36class VBoxProgressBar;
    3637
    3738class VBoxDiskImageManagerDlg : public QIWithRetranslateUI2<QIMainDialog>,
     
    138139    bool mDoSelect;
    139140    static VBoxDiskImageManagerDlg *mModelessDialog;
     141    VBoxProgressBar  *mProgressBar;
    140142
    141143    /* Type if we are in the select modus */
  • trunk/src/VBox/Frontends/VirtualBox4/src/QIDialogButtonBox.cpp

    r9056 r9296  
    2323#include "QIDialogButtonBox.h"
    2424
     25#include <iprt/assert.h>
     26
    2527/* Qt includes */
    2628#include <QPushButton>
    2729#include <QEvent>
     30#include <QBoxLayout>
    2831
    2932QIDialogButtonBox::QIDialogButtonBox (StandardButtons aButtons, Qt::Orientation aOrientation, QWidget *aParent)
     
    5659}
    5760
     61void QIDialogButtonBox::addExtraWidget (QWidget* aWidget)
     62{
     63    QBoxLayout *layout = boxLayout();
     64    int index = findEmptySpace (layout);
     65    layout->insertWidget (index + 1, aWidget);
     66    layout->insertStretch(index + 2);
     67}
     68
     69void QIDialogButtonBox::addExtraLayout (QLayout* aLayout)
     70{
     71    QBoxLayout *layout = boxLayout();
     72    int index = findEmptySpace (layout);
     73    layout->insertLayout (index + 1, aLayout);
     74    layout->insertStretch(index + 2);
     75}
     76
     77QBoxLayout *QIDialogButtonBox::boxLayout() const
     78{
     79  QBoxLayout *boxlayout = qobject_cast<QBoxLayout*> (layout());
     80  AssertMsg (VALID_PTR (boxlayout), ("Layout of the QDialogButtonBox isn't a box layout."));
     81  return boxlayout;
     82}
     83
     84int QIDialogButtonBox::findEmptySpace (QBoxLayout *aLayout) const
     85{
     86  /* Search for the first occurrence of QSpacerItem and return the index.
     87   * Please note that this is Qt internal, so it may change at any time. */
     88  int i=0;
     89  for (; i < aLayout->count(); ++i)
     90  {
     91      QLayoutItem *item = aLayout->itemAt(i);
     92      if (QSpacerItem *sitem = item->spacerItem())
     93          break;
     94  }
     95  return i;
     96}
     97
    5898void QIDialogButtonBox::retranslateUi()
    5999{
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxDiskImageManagerDlg.cpp

    r9287 r9296  
    3535#include <QPushButton>
    3636#include <QUrl>
     37#include <QProgressBar>
    3738
    3839class AddVDMUrlsEvent: public QEvent
     
    204205    /* Private member vars */
    205206    QLabel *mLabel;
     207};
     208
     209class VBoxProgressBar: public QWidget
     210{
     211public:
     212
     213    VBoxProgressBar (QWidget *aParent)
     214        : QWidget (aParent)
     215    {
     216        QHBoxLayout *layout = new QHBoxLayout (this);
     217        VBoxGlobal::setLayoutMargin (layout, 0);
     218        mText = new QLabel ();
     219        layout->addWidget (mText);
     220        mProgressBar = new QProgressBar;
     221        /* The text is provided by our own label */
     222        mProgressBar->setTextVisible (false);
     223        layout->addWidget (mProgressBar);
     224    }
     225
     226public slots:
     227
     228    void setText (const QString& aText) { mText->setText (aText); }
     229    void setValue (int aValue) { mProgressBar->setValue (aValue); }
     230    void setMinimum (int aValue) { mProgressBar->setMinimum (aValue); }
     231    void setMaximum (int aValue) { mProgressBar->setMaximum (aValue); }
     232    void setRange (int aMin, int aMax) { mProgressBar->setRange (aMin, aMax); }
     233
     234    QLabel *label() const { return mText; }
     235    QProgressBar *progressBar() const { return mProgressBar; }
     236
     237private:
     238
     239    /* Private member vars */
     240    QLabel       *mText;
     241    QProgressBar *mProgressBar;
    206242};
    207243
     
    388424    createInfoString (mFdsPane2, mFdsContainer, 1, 0);
    389425
    390     /* enumeration progressbar creation */
    391 //    mProgressText = new QLabel (centralWidget());
    392 //    mProgressText->setHidden (true);
    393 #warning port me
    394 //    buttonLayout->insertWidget (2, mProgressText);
    395 //    mProgressBar = new Q3ProgressBar (centralWidget());
    396 //    mProgressBar->setHidden (true);
    397 //    mProgressBar->setFrameShadow (Q3Frame::Sunken);
    398 //    mProgressBar->setFrameShape  (Q3Frame::Panel);
    399 //    mProgressBar->setPercentageVisible (false);
    400 //    mProgressBar->setMaximumWidth (100);
    401 #warning port me
    402 //    buttonLayout->insertWidget (3, mProgressBar);
     426    /* Enumeration progressbar creation */
     427    mProgressBar = new VBoxProgressBar (this);
     428    /* Add to the dialog button box */
     429    mButtonBox->addExtraWidget (mProgressBar);
     430    /* Default is invisible */
     431    mProgressBar->setVisible (false);
    403432
    404433    /* Connects for the button box */
     
    473502        {
    474503            mediaAdded (*it);
    475 //            if ((*it).status != VBoxMedia::Unknown)
    476 //                mProgressBar->setProgress (++ index);
     504            if ((*it).status != VBoxMedia::Unknown)
     505            {
     506                mProgressBar->setValue (++ index);
     507                qApp->processEvents();
     508            }
    477509        }
    478510
     
    807839    mFdsPane2->label()->setText (QString ("<nobr>%1:</nobr>").arg (tr ("Attached to")));
    808840
    809 //    mProgressText->setText (tr ("Checking accessibility"));
    810 //
     841    mProgressBar->setText (tr ("Checking accessibility"));
     842#ifdef Q_WS_MAC
     843    /* Make sure that the widgets aren't jumping around while the progress bar
     844     * get visible. */
     845    mProgressBar->adjustSize();
     846    int h = mProgressBar->height();
     847    mButtonBox->setMinimumHeight (h + 12);
     848#endif
     849
    811850    if (mHdsTree->model()->rowCount() || mCdsTree->model()->rowCount() || mFdsTree->model()->rowCount())
    812851        refreshAll();
     
    10341073    mediaUpdated (aMedia);
    10351074    Assert (aMedia.status != VBoxMedia::Unknown);
    1036 //    if (aMedia.status != VBoxMedia::Unknown)
    1037 //        mProgressBar->setProgress (aIndex + 1);
     1075    if (aMedia.status != VBoxMedia::Unknown)
     1076    {
     1077        mProgressBar->setValue (aIndex + 1);
     1078        qApp->processEvents();
     1079    }
    10381080}
    10391081
    10401082void VBoxDiskImageManagerDlg::mediaEnumFinished (const VBoxMediaList &/* aList */)
    10411083{
    1042 //    mProgressBar->setHidden (true);
    1043 //    mProgressText->setHidden (true);
     1084    mProgressBar->setVisible (false);
    10441085
    10451086    mRefreshAction->setEnabled (true);
     
    19231964
    19241965    /* Prepare progressbar */
    1925 //    if (mProgressBar)
    1926 //    {
    1927 //        mProgressBar->setProgress (0, aTotal);
    1928 //        mProgressBar->setHidden (false);
    1929 //        mProgressText->setHidden (false);
    1930 //    }
     1966    if (mProgressBar)
     1967    {
     1968        mProgressBar->setMaximum (aTotal);
     1969        mProgressBar->setValue (0);
     1970        mProgressBar->setVisible (true);
     1971    }
    19311972
    19321973    mRefreshAction->setEnabled (false);
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