VirtualBox

Changeset 3943 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 31, 2007 2:42:32 PM (18 years ago)
Author:
vboxsync
Message:

2142: GUI should download Additions:

  1. QIMessageBox was changed to use QIRichLabel instead of QLabel for the text displaying purposes.
  2. QIRichLabel was updated to allow user to copy the link contained in the label text through the context menu.
  3. All the Additions Downloader’s messages were updated according the described requirements (including the new one messages and the protocol http:// displaying before the image path).
  4. The progress bar is now appears just after the code decides it is necessary to download additions.
  5. Some minor bug-fixes ( bonus :) ).
Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/QIMessageBox.h

    r3894 r3943  
    3030#include <qtextedit.h>
    3131
     32class QIRichLabel;
    3233class QLabel;
    3334class QPushButton;
     
    4748        Warning = QMessageBox::Warning,
    4849        Critical = QMessageBox::Critical,
    49                 Question = QMessageBox::Question
     50        Question = QMessageBox::Question
    5051    };
    5152
     
    9394
    9495    int mButton0, mButton1, mButton2, mButtonEsc;
    95     QLabel *mIconLabel, *mTextLabel;
     96    QLabel *mIconLabel;
     97    QIRichLabel *mTextLabel;
    9698    QPushButton *mButton0PB, *mButton1PB, *mButton2PB;
    9799    QVBox *mMessageVBox;
  • trunk/src/VBox/Frontends/VirtualBox/include/QIRichLabel.h

    r2981 r3943  
    125125   QMovie     *lmovie;
    126126   QPopupMenu *popupMenu;
     127   QString     popupBuffer;
    127128   QWidget    *lbuddy;
    128129   ushort      align;
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h

    r3936 r3943  
    195195                                   const QString &, const QString &);
    196196
     197    int cannotFindGuestAdditions (const QString &aSrc1, const QString &aSrc2);
    197198    void cannotDownloadGuestAdditions (const QString &aURL,
    198199                                       const QString &aReason);
    199     int confirmDownloadAdditions (const QString &aSrc1, const QString &aSrc2,
    200                                   const QString &aURL, ulong aSize);
     200    int confirmDownloadAdditions (const QString &aURL, ulong aSize);
     201    int confirmMountAdditions (const QString &aURL, const QString &aSrc);
    201202    void warnAboutTooOldAdditions (QWidget *, const QString &, const QString &);
    202203    void warnAboutOldAdditions (QWidget *, const QString &, const QString &);
  • trunk/src/VBox/Frontends/VirtualBox/src/QIMessageBox.cpp

    r3898 r3943  
    2323#include "QIMessageBox.h"
    2424#include "VBoxDefs.h"
     25#include "QIRichLabel.h"
    2526
    2627#include <qpixmap.h>
     
    8081    mMessageVBox->setSpacing (10);
    8182
    82     mTextLabel = new QLabel (aText, mMessageVBox);
     83    mTextLabel = new QIRichLabel (aText, mMessageVBox);
    8384    mTextLabel->setAlignment (AlignAuto | AlignTop | ExpandTabs | WordBreak);
    8485    mTextLabel->setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Fixed, true);
  • trunk/src/VBox/Frontends/VirtualBox/src/QIRichLabel.cpp

    r2981 r3943  
    397397
    398398    QString link = doc->anchorAt (aEvent->pos());
    399     if (!link.isEmpty()) /* Mouse clicked on the link */
     399    /* Check for mouse left button clicked on the link */
     400    if (!link.isEmpty() && aEvent->button() == LeftButton)
    400401        emit clickedOnLink (link);
    401402}
     
    484485void QIRichLabel::contextMenuEvent (QContextMenuEvent *aEvent)
    485486{
    486    if (hasFocus())
    487       popupMenu->popup(aEvent->globalPos());
     487    popupBuffer = doc->anchorAt (aEvent->pos());
     488    if (hasFocus() || !popupBuffer.isEmpty())
     489        popupMenu->popup (aEvent->globalPos());
    488490}
    489491
     
    491493void QIRichLabel::putToClipBoard()
    492494{
    493    QClipboard *appClipboard = QApplication::clipboard();
    494    QString toClipBoard = ltext;
    495    toClipBoard.remove (QRegExp ("<[^>]*>"));
    496    appClipboard->setText (toClipBoard);
     495    QString toClipBoard = ltext;
     496
     497    if (popupBuffer.isEmpty())
     498        toClipBoard.remove (QRegExp ("<[^>]*>"));
     499    else
     500        toClipBoard = popupBuffer;
     501
     502    QApplication::clipboard()->setText (toClipBoard);
    497503}
    498504
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp

    r3936 r3943  
    212212public:
    213213
    214     VBoxGADownloader (QStatusBar *aStatusBar, QAction *aAction,
    215                       const QString &aSrc1, const QString &aSrc2)
     214    VBoxGADownloader (QStatusBar *aStatusBar, QAction *aAction)
    216215        : QWidget (0, "VBoxGADownloader")
    217216        , mStatusBar (aStatusBar)
    218         , mSrc1 (aSrc1), mSrc2 (aSrc2)
     217        , mProtocol ("http://")
    219218        , mHost (QString::null), mPath (QString::null), mFile (QString::null)
    220219        , mHttp (0), mIsChecking (true)
     
    226225
    227226        /* Drawing itself */
     227        setFixedHeight (16);
     228
    228229        mProgressBar = new QProgressBar (this);
    229230        mProgressBar->setFixedWidth (100);
     
    240241
    241242        languageChange();
     243        mStatusBar->addWidget (this);
    242244
    243245        /* Select the product version */
     
    315317        else if (!aError && !mIsChecking)
    316318        {
     319            mHttp->abort();
    317320            /* Serialize the incoming buffer into the .iso image. */
    318321            QString path = QDir (QDir::home()).absFilePath (mFile);
     
    322325                file.writeBlock (mHttp->readAll());
    323326                file.close();
    324                 vboxGlobal().consoleWnd().installGuestAdditionsFrom (path);
     327                int rc = vboxProblem().confirmMountAdditions (mProtocol + mHost +
     328                                  mPath + mFile, QDir::convertSeparators (path));
     329                if (rc == QIMessageBox::Yes)
     330                    vboxGlobal().consoleWnd().installGuestAdditionsFrom (path);
    325331                QTimer::singleShot (0, this, SLOT (suicide()));
    326332            }
     
    365371        /* Ask user about GA image downloading */
    366372        int rc = vboxProblem().
    367             confirmDownloadAdditions (mSrc1, mSrc2,
    368                                       mHost + mPath + mFile, aSize);
     373            confirmDownloadAdditions (mProtocol + mHost + mPath + mFile, aSize);
    369374        if (rc == QIMessageBox::Yes)
    370375        {
    371             mStatusBar->addWidget (this);
    372             setFixedHeight (16);
    373376            mIsChecking = false;
    374377            mHttp->get (mPath + mFile);
     
    383386    void abortDownload (const QString &aReason)
    384387    {
    385         vboxProblem().cannotDownloadGuestAdditions (mHost + mPath + mFile,
    386                                                     aReason);
     388        vboxProblem().cannotDownloadGuestAdditions (mProtocol + mHost +
     389                                                    mPath + mFile, aReason);
    387390        /* Allows all the queued signals to be processed before quit. */
    388391        QTimer::singleShot (0, this, SLOT (suicide()));
     
    390393
    391394    QStatusBar *mStatusBar;
    392     QString mSrc1;
    393     QString mSrc2;
     395    QString mProtocol;
    394396    QString mHost;
    395397    QString mPath;
     
    25202522        installGuestAdditionsFrom (src2);
    25212523    else
    2522         new VBoxGADownloader (statusBar(), devicesInstallGuestToolsAction,
    2523                               src1, src2);
     2524    {
     2525        int rc = vboxProblem().cannotFindGuestAdditions (
     2526            QDir::convertSeparators (src1), QDir::convertSeparators (src2));
     2527        if (rc == QIMessageBox::Yes)
     2528            new VBoxGADownloader (statusBar(), devicesInstallGuestToolsAction);
     2529    }
    25242530}
    25252531
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp

    r3936 r3943  
    12541254}
    12551255
     1256int VBoxProblemReporter::cannotFindGuestAdditions (const QString &aSrc1,
     1257                                                   const QString &aSrc2)
     1258{
     1259    return message (&vboxGlobal().consoleWnd(), Question,
     1260                    tr ("<p>Failed to find the VirtualBox Guest Additions "
     1261                        "CD image <nobr><b>%1</b></nobr> or "
     1262                        "<nobr><b>%2</b>.</nobr></p><p>Do you want to "
     1263                        "download this image from the Internet?</p>")
     1264                        .arg (aSrc1).arg (aSrc2),
     1265                    0, /* autoConfirmId */
     1266                    QIMessageBox::Yes | QIMessageBox::Default,
     1267                    QIMessageBox::No | QIMessageBox::Escape);
     1268}
     1269
    12561270void VBoxProblemReporter::cannotDownloadGuestAdditions (const QString &aURL,
    12571271                                                        const QString &aReason)
    12581272{
    1259     QString msg = tr ("<p>Failed to download the VirtualBox Guest "
    1260         "Additions CD image from <nobr><b>%1</b>.</nobr></p>").arg (aURL);
    1261     msg += QString ("<p>%1</p>").arg (aReason);
    1262     message (&vboxGlobal().consoleWnd(), Error, msg);
    1263 }
    1264 
    1265 int VBoxProblemReporter::confirmDownloadAdditions (const QString &aSrc1,
    1266                                                    const QString &aSrc2,
    1267                                                    const QString &aURL,
     1273    message (&vboxGlobal().consoleWnd(), Error,
     1274             tr ("<p>Failed to download the VirtualBox Guest Additions CD "
     1275                 "image from <nobr><a href=\"%1\">%2</a>.</nobr></p><p>%3</p>")
     1276                 .arg (aURL).arg (aURL).arg (aReason));
     1277}
     1278
     1279int VBoxProblemReporter::confirmDownloadAdditions (const QString &aURL,
    12681280                                                   ulong aSize)
    12691281{
    1270     QString msg = tr ("<p>Failed to find the VirtualBox Guest Additions CD image "
    1271                       "<nobr><b>%1</b></nobr> or "
    1272                       "<nobr><b>%2</b></nobr></p>").arg (aSrc1).arg (aSrc2);
    1273     msg += tr ("<p>Do you want to download this image from "
    1274                "<nobr><b>%1</b></nobr> (%2 bytes)?</p>").arg (aURL).arg (aSize);
    1275 
    1276     return message (&vboxGlobal().consoleWnd(), Question, msg,
     1282    return message (&vboxGlobal().consoleWnd(), Question,
     1283                    tr ("<p>Are you sure you want to download the VirtualBox "
     1284                        "Guest Additions CD image from "
     1285                        "<nobr><a href=\"%1\">%2</a></nobr> "
     1286                        "(size %3 bytes)?</p>").arg (aURL).arg (aURL).arg (aSize),
     1287                    0, /* autoConfirmId */
     1288                    QIMessageBox::Yes | QIMessageBox::Default,
     1289                    QIMessageBox::No | QIMessageBox::Escape);
     1290}
     1291
     1292int VBoxProblemReporter::confirmMountAdditions (const QString &aURL,
     1293                                                const QString &aSrc)
     1294{
     1295    return message (&vboxGlobal().consoleWnd(), Question,
     1296                    tr ("<p>The VirtualBox Guest Additions CD image was "
     1297                        "successfully downloaded from "
     1298                        "<nobr><a href=\"%1\">%2</a></nobr> "
     1299                        "and saved locally as <nobr><b>%3</b>.</nobr></p>"
     1300                        "<p>Do you want to register this CD image and mount it "
     1301                        "on the virtual CD/DVD drive?</p>")
     1302                        .arg (aURL).arg (aURL).arg (aSrc),
    12771303                    0, /* autoConfirmId */
    12781304                    QIMessageBox::Yes | QIMessageBox::Default,
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