VirtualBox

Changeset 7722 in vbox


Ignore:
Timestamp:
Apr 3, 2008 12:50:45 PM (17 years ago)
Author:
vboxsync
Message:

FE/Qt4: Ported this one also.

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

Legend:

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

    r7220 r7722  
    2121
    2222#include "HappyHttp.h"
    23 #include "qwidget.h"
    24 #include "q3url.h"
    25 #include "qmutex.h"
    26 //Added by qt3to4:
    27 #include <QEvent>
     23
     24/* Qt includes */
     25#include <QWidget>
     26#include <QUrl>
     27#include <QMutex>
     28
    2829class QStatusBar;
    2930class QAction;
    30 class Q3ProgressBar;
     31class QProgressBar;
    3132class QToolButton;
    3233class QThread;
     
    8889    void abortConnection();
    8990
    90     Q3Url mUrl;
     91    QUrl mUrl;
    9192    QString mTarget;
    9293    QStatusBar *mStatusBar;
    9394    QAction *mAction;
    94     Q3ProgressBar *mProgressBar;
     95    QProgressBar *mProgressBar;
    9596    QToolButton *mCancelButton;
    9697    bool mIsChecking;
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxDownloaderWgt.cpp

    r7220 r7722  
    2222#include "VBoxDownloaderWgt.h"
    2323
    24 #include "qaction.h"
    25 #include "q3progressbar.h"
    26 #include "qtoolbutton.h"
    27 #include "qlayout.h"
    28 #include "qstatusbar.h"
    29 #include "qdir.h"
    30 #include "qtimer.h"
    31 //Added by qt3to4:
    32 #include <Q3HBoxLayout>
    33 #include <QEvent>
     24/* Qt includes */
     25#include <QProgressBar>
     26#include <QHBoxLayout>
     27#include <QTimer>
     28#include <QToolButton>
     29#include <QStatusBar>
     30#include <QDir>
    3431
    3532/* These notifications are used to notify the GUI thread about different
     
    6057    ProcessDownloadEvent (const char *aData, ulong aSize)
    6158        : QEvent ((QEvent::Type) ProcessDownloadEventType)
    62         , mData (QByteArray().duplicate (aData, aSize)) {}
     59        , mData (aData, aSize) {}
    6360
    6461    QByteArray mData;
     
    125122VBoxDownloaderWgt::VBoxDownloaderWgt (QStatusBar *aStatusBar, QAction *aAction,
    126123                                      const QString &aUrl, const QString &aTarget)
    127     : QWidget (0, "VBoxDownloaderWgt")
     124    : QWidget ()
    128125    , mUrl (aUrl), mTarget (aTarget)
    129126    , mStatusBar (aStatusBar), mAction (aAction)
    130127    , mProgressBar (0), mCancelButton (0)
    131128    , mIsChecking (true), mSuicide (false)
    132     , mConn (new HConnect (mUrl.host(), 80))
     129    , mConn (new HConnect (mUrl.host().toAscii().constData(), 80))
    133130    , mRequestThread (0)
    134131    , mDataStream (&mDataArray, QIODevice::WriteOnly)
     
    137134    /* Disable the associated action */
    138135    mAction->setEnabled (false);
     136    mTimeout->setSingleShot (true);
    139137    connect (mTimeout, SIGNAL (timeout()),
    140138             this, SLOT (processTimeout()));
     
    143141    setFixedHeight (16);
    144142
    145     mProgressBar = new Q3ProgressBar (this);
     143    mProgressBar = new QProgressBar (this);
    146144    mProgressBar->setFixedWidth (100);
    147     mProgressBar->setPercentageVisible (true);
    148     mProgressBar->setProgress (0);
     145    mProgressBar->setFormat ("%p%");
     146    mProgressBar->setValue (0);
    149147
    150148    mCancelButton = new QToolButton (this);
     
    154152             this, SLOT (processAbort()));
    155153
    156     Q3HBoxLayout *mainLayout = new Q3HBoxLayout (this);
     154    QHBoxLayout *mainLayout = new QHBoxLayout (this);
     155    mainLayout->setSpacing (0);
     156    VBoxGlobal::setLayoutMargin (mainLayout, 0);
    157157    mainLayout->addWidget (mProgressBar);
    158158    mainLayout->addWidget (mCancelButton);
    159     mainLayout->addItem (new QSpacerItem (0, 0, QSizePolicy::Expanding,
    160                                                 QSizePolicy::Fixed));
     159    mainLayout->addStretch (1);
    161160
    162161    /* Prepare the connection */
     
    164163
    165164    languageChange();
    166     mStatusBar->addWidget (this);
     165    mStatusBar->addWidget (this, 1);
    167166
    168167    /* Try to get the required file for the information */
     
    174173    mCancelButton->setText (tr ("Cancel"));
    175174    /// @todo the below title should be parametrized
    176     QToolTip::add (mProgressBar, tr ("Downloading the VirtualBox Guest Additions "
    177                                      "CD image from <nobr><b>%1</b>...</nobr>")
    178                                  .arg (mUrl.toString()));
     175    mProgressBar->setToolTip (tr ("Downloading the VirtualBox Guest Additions "
     176                                  "CD image from <nobr><b>%1</b>...</nobr>")
     177                              .arg (mUrl.toString()));
    179178    /// @todo the below title should be parametrized
    180     QToolTip::add (mCancelButton, tr ("Cancel the VirtualBox Guest "
    181                                       "Additions CD image download"));
     179    mCancelButton->setToolTip (tr ("Cancel the VirtualBox Guest "
     180                                   "Additions CD image download"));
    182181}
    183182
     
    230229            ProcessDownloadEvent *e = static_cast<ProcessDownloadEvent*> (aEvent);
    231230
    232             mTimeout->start (20000, true);
    233             mProgressBar->setProgress (mProgressBar->progress() + e->mData.size());
    234             mDataStream.writeRawBytes (e->mData.data(), e->mData.size());
     231            mTimeout->start (20000);
     232            mProgressBar->setValue (mProgressBar->value() + e->mData.size());
     233            mDataStream.writeRawData (e->mData.data(), e->mData.size());
    235234
    236235            return true;
     
    246245                if (file.open (QIODevice::WriteOnly))
    247246                {
    248                     file.writeBlock (mDataArray);
     247                    file.write (mDataArray);
    249248                    file.close();
    250249                    /// @todo the below action is not part of the generic
     
    271270                /// the title)
    272271                QString target = vboxGlobal().getExistingDirectory (
    273                     QFileInfo (mTarget).dirPath(), this, "selectSaveDir",
     272                    QFileInfo (mTarget).absolutePath(), this, "selectSaveDir",
    274273                    tr ("Select folder to save Guest Additions image to"), true);
    275274                if (target.isNull())
    276275                    QTimer::singleShot (0, this, SLOT (suicide()));
    277276                else
    278                     mTarget = QDir (target).absFilePath (QFileInfo (mTarget).fileName());
     277                    mTarget = QDir (target).absoluteFilePath (QFileInfo (mTarget).fileName());
    279278            }
    280279
     
    313312            try
    314313            {
    315                 mConn->request ("GET", mPath);
     314                mConn->request ("GET", mPath.toAscii().constData());
    316315                while (mConn->outstanding())
    317316                {
     
    338337        mRequestThread = new Thread (this, mConn, mUrl.path(), &mMutex);
    339338    mRequestThread->start();
    340     mTimeout->start (20000, true);
     339    mTimeout->start (20000);
    341340}
    342341
     
    356355    {
    357356        mIsChecking = false;
    358         mProgressBar->setTotalSteps (aSize);
     357        mProgressBar->setMaximum (aSize);
    359358        getFile();
    360359    }
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