Changeset 7722 in vbox
- Timestamp:
- Apr 3, 2008 12:50:45 PM (17 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxDownloaderWgt.h
r7220 r7722 21 21 22 22 #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 28 29 class QStatusBar; 29 30 class QAction; 30 class Q 3ProgressBar;31 class QProgressBar; 31 32 class QToolButton; 32 33 class QThread; … … 88 89 void abortConnection(); 89 90 90 Q 3Url mUrl;91 QUrl mUrl; 91 92 QString mTarget; 92 93 QStatusBar *mStatusBar; 93 94 QAction *mAction; 94 Q 3ProgressBar *mProgressBar;95 QProgressBar *mProgressBar; 95 96 QToolButton *mCancelButton; 96 97 bool mIsChecking; -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxDownloaderWgt.cpp
r7220 r7722 22 22 #include "VBoxDownloaderWgt.h" 23 23 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> 34 31 35 32 /* These notifications are used to notify the GUI thread about different … … 60 57 ProcessDownloadEvent (const char *aData, ulong aSize) 61 58 : QEvent ((QEvent::Type) ProcessDownloadEventType) 62 , mData ( QByteArray().duplicate (aData, aSize)) {}59 , mData (aData, aSize) {} 63 60 64 61 QByteArray mData; … … 125 122 VBoxDownloaderWgt::VBoxDownloaderWgt (QStatusBar *aStatusBar, QAction *aAction, 126 123 const QString &aUrl, const QString &aTarget) 127 : QWidget ( 0, "VBoxDownloaderWgt")124 : QWidget () 128 125 , mUrl (aUrl), mTarget (aTarget) 129 126 , mStatusBar (aStatusBar), mAction (aAction) 130 127 , mProgressBar (0), mCancelButton (0) 131 128 , mIsChecking (true), mSuicide (false) 132 , mConn (new HConnect (mUrl.host() , 80))129 , mConn (new HConnect (mUrl.host().toAscii().constData(), 80)) 133 130 , mRequestThread (0) 134 131 , mDataStream (&mDataArray, QIODevice::WriteOnly) … … 137 134 /* Disable the associated action */ 138 135 mAction->setEnabled (false); 136 mTimeout->setSingleShot (true); 139 137 connect (mTimeout, SIGNAL (timeout()), 140 138 this, SLOT (processTimeout())); … … 143 141 setFixedHeight (16); 144 142 145 mProgressBar = new Q 3ProgressBar (this);143 mProgressBar = new QProgressBar (this); 146 144 mProgressBar->setFixedWidth (100); 147 mProgressBar->set PercentageVisible (true);148 mProgressBar->set Progress(0);145 mProgressBar->setFormat ("%p%"); 146 mProgressBar->setValue (0); 149 147 150 148 mCancelButton = new QToolButton (this); … … 154 152 this, SLOT (processAbort())); 155 153 156 Q3HBoxLayout *mainLayout = new Q3HBoxLayout (this); 154 QHBoxLayout *mainLayout = new QHBoxLayout (this); 155 mainLayout->setSpacing (0); 156 VBoxGlobal::setLayoutMargin (mainLayout, 0); 157 157 mainLayout->addWidget (mProgressBar); 158 158 mainLayout->addWidget (mCancelButton); 159 mainLayout->addItem (new QSpacerItem (0, 0, QSizePolicy::Expanding, 160 QSizePolicy::Fixed)); 159 mainLayout->addStretch (1); 161 160 162 161 /* Prepare the connection */ … … 164 163 165 164 languageChange(); 166 mStatusBar->addWidget (this );165 mStatusBar->addWidget (this, 1); 167 166 168 167 /* Try to get the required file for the information */ … … 174 173 mCancelButton->setText (tr ("Cancel")); 175 174 /// @todo the below title should be parametrized 176 QToolTip::add (mProgressBar,tr ("Downloading the VirtualBox Guest Additions "177 178 175 mProgressBar->setToolTip (tr ("Downloading the VirtualBox Guest Additions " 176 "CD image from <nobr><b>%1</b>...</nobr>") 177 .arg (mUrl.toString())); 179 178 /// @todo the below title should be parametrized 180 QToolTip::add (mCancelButton,tr ("Cancel the VirtualBox Guest "181 179 mCancelButton->setToolTip (tr ("Cancel the VirtualBox Guest " 180 "Additions CD image download")); 182 181 } 183 182 … … 230 229 ProcessDownloadEvent *e = static_cast<ProcessDownloadEvent*> (aEvent); 231 230 232 mTimeout->start (20000 , true);233 mProgressBar->set Progress (mProgressBar->progress() + e->mData.size());234 mDataStream.writeRaw Bytes(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()); 235 234 236 235 return true; … … 246 245 if (file.open (QIODevice::WriteOnly)) 247 246 { 248 file.write Block(mDataArray);247 file.write (mDataArray); 249 248 file.close(); 250 249 /// @todo the below action is not part of the generic … … 271 270 /// the title) 272 271 QString target = vboxGlobal().getExistingDirectory ( 273 QFileInfo (mTarget). dirPath(), this, "selectSaveDir",272 QFileInfo (mTarget).absolutePath(), this, "selectSaveDir", 274 273 tr ("Select folder to save Guest Additions image to"), true); 275 274 if (target.isNull()) 276 275 QTimer::singleShot (0, this, SLOT (suicide())); 277 276 else 278 mTarget = QDir (target).abs FilePath (QFileInfo (mTarget).fileName());277 mTarget = QDir (target).absoluteFilePath (QFileInfo (mTarget).fileName()); 279 278 } 280 279 … … 313 312 try 314 313 { 315 mConn->request ("GET", mPath );314 mConn->request ("GET", mPath.toAscii().constData()); 316 315 while (mConn->outstanding()) 317 316 { … … 338 337 mRequestThread = new Thread (this, mConn, mUrl.path(), &mMutex); 339 338 mRequestThread->start(); 340 mTimeout->start (20000 , true);339 mTimeout->start (20000); 341 340 } 342 341 … … 356 355 { 357 356 mIsChecking = false; 358 mProgressBar->set TotalSteps(aSize);357 mProgressBar->setMaximum (aSize); 359 358 getFile(); 360 359 }
Note:
See TracChangeset
for help on using the changeset viewer.