VirtualBox

Changeset 2801 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
May 23, 2007 12:53:00 PM (18 years ago)
Author:
vboxsync
Message:

1750: Add CDROM configuration to "Create VM" wizard:

CD/DVD Boot source selection Dialog implemented.

  1. This dialog shows only during each VM first time started.
  2. It allows to temporarily attach host CD/DVD drive into VM drive to load from it.
  3. It allows to temporarily attach CD/DVD image file into VM drive to load from it.
  4. User can invoke VDM Dialog (CD/DVD Filtered) from this dialog.
Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r2529 r2801  
    5252VirtualBox_SDKS.linux = LIBSDL
    5353
    54 ifeq ($(BUILD_TARGET),darwin) 
     54ifeq ($(BUILD_TARGET),darwin)
    5555# For the launch trick we need different inode numbers.
    5656VirtualBox_INST = $(INST_BIN)VirtualBox $(INST_BIN)VirtualBoxVM
     
    8383
    8484# Sources containing local definitions of classes that use the Q_OBJECT macro
    85 VirtualBox_QT_MOCSRCS = src/VBoxSelectorWnd.cpp
     85VirtualBox_QT_MOCSRCS = src/VBoxSelectorWnd.cpp \
     86                                                src/VBoxConsoleWnd.cpp
    8687ifneq ($(BUILD_TARGET),win)
    8788VirtualBox_QT_MOCSRCS += src/COMDefs.cpp
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h

    r2764 r2801  
    283283    QColor erase_color;
    284284
     285    bool mIsFirstTimeStarted : 1;
     286
    285287#ifdef VBOX_WITH_DEBUGGER_GUI
    286288    // Debugger GUI
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp

    r2764 r2801  
    3333#include "VBoxSharedFoldersSettings.h"
    3434#include "VBoxUtils.h"
     35#include "VBoxMediaComboBox.h"
    3536#include "QIStateIndicator.h"
    3637#include "QIStatusBar.h"
     
    4950#include <qdir.h>
    5051#include <qpushbutton.h>
     52#include <qtoolbutton.h>
    5153
    5254#include <qeventloop.h>
     
    188190
    189191    QString mTip;
     192};
     193
     194/**
     195 *  Bootable CD/DVD ISO Selection Dialog class.
     196 *  Allows user to select temporarily mounted image or host drive
     197 *  to load the system from.
     198 */
     199class BootDVDDialog : public QDialog
     200{
     201    Q_OBJECT
     202
     203public:
     204
     205    BootDVDDialog (QWidget *aParent, CMachine &aMachine)
     206        : QDialog (aParent, "BootDVDDialog", true /* modal */)
     207        , mMachine (aMachine)
     208        , mGrpBox (0)
     209        , mRbHost (0), mRbImage (0)
     210        , mCbHost (0), mCbImage (0)
     211        , mTbVDM (0), mPbOk (0)
     212    {
     213        /* Setup Dialog's title */
     214        setCaption (tr ("Select Boot Source"));
     215        setIcon (QPixmap::fromMimeSource ("select_file_16px.png"));
     216
     217        /* Setup main group-box */
     218        mGrpBox = new QButtonGroup (this, "mGrpBox");
     219        mGrpBox->setCheckable (true);
     220        mGrpBox->setChecked (false);
     221        mGrpBox->setColumnLayout (0, Qt::Vertical);
     222        mGrpBox->setTitle (tr ("&Mount CD/DVD Drive"));
     223        mGrpBox->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Fixed);
     224        connect (mGrpBox, SIGNAL (toggled (bool)), this, SLOT (grpBoxToggled (bool)));
     225
     226        /* Setup group box widgets */
     227        mRbHost = new QRadioButton (tr ("Host CD/DVD &Drive"), mGrpBox, "mRbHost");
     228        connect (mRbHost,  SIGNAL (clicked()), this, SLOT (rbClicked()));
     229        mCbHost = new QComboBox (mGrpBox, "mCbHost");
     230        CHostDVDDriveCollection coll = vboxGlobal().virtualBox().GetHost().GetDVDDrives();
     231        mHostDVDs.resize (coll.GetCount());
     232        int id = 0;
     233        CHostDVDDriveEnumerator en = coll.Enumerate();
     234        while (en.HasMore())
     235        {
     236            CHostDVDDrive hostDVD = en.GetNext();
     237            mCbHost->insertItem (hostDVD.GetName(), id);
     238            mHostDVDs [id] = hostDVD;
     239            ++ id;
     240        }
     241
     242        mRbImage = new QRadioButton (tr ("&ISO Image File"), mGrpBox, "mRbImage");
     243        connect (mRbImage, SIGNAL (clicked()), this, SLOT (rbClicked()));
     244        mCbImage = new VBoxMediaComboBox (mGrpBox, "sel", VBoxDefs::CD);
     245        if (!vboxGlobal().isMediaEnumerationStarted())
     246            vboxGlobal().startEnumeratingMedia();
     247        else
     248            mCbImage->refresh();
     249        mTbVDM = new QToolButton (mGrpBox, "mTbVDM");
     250        mTbVDM->setIconSet (VBoxGlobal::iconSet ("select_file_16px.png",
     251                                                 "select_file_dis_16px.png"));
     252        mTbVDM->setFocusPolicy (QWidget::TabFocus);
     253        connect (mTbVDM, SIGNAL (clicked()), this, SLOT (vdmOpen()));
     254
     255        /* Setup group box layout */
     256        QGridLayout *grbLayout = new QGridLayout (mGrpBox->layout(), 2, 3, 10, "grbLayout");
     257        grbLayout->addWidget (mRbHost, 0, 0);
     258        grbLayout->addWidget (mCbHost, 0, 1);
     259        grbLayout->addWidget (mRbImage, 1, 0);
     260        grbLayout->addWidget (mCbImage, 1, 1);
     261        grbLayout->addWidget (mTbVDM, 1, 2);
     262
     263        /* Setup dialog buttons */
     264        mPbOk = new QPushButton (tr ("OK"), this, "mPbOk");
     265        QSpacerItem *spacer = new QSpacerItem (0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
     266        QPushButton *pbCancel = new QPushButton (tr ("Cancel"), this, "pbCancel");
     267        connect (mPbOk, SIGNAL (clicked()), this, SLOT (accept()));
     268        connect (pbCancel, SIGNAL (clicked()), this, SLOT (reject()));
     269
     270        /* Setup main layout */
     271        QVBoxLayout *mainLayout = new QVBoxLayout (this, 10, 10, "mainLayout");
     272        mainLayout->addWidget (mGrpBox);
     273        QSpacerItem *btSpacer =
     274            new QSpacerItem (0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
     275        mainLayout->addItem (btSpacer);
     276
     277        /* Setup buttons layout */
     278        QHBoxLayout *buttonLayout = new QHBoxLayout (mainLayout, 10, "buttonLayout");
     279        buttonLayout->addWidget (mPbOk);
     280        buttonLayout->addItem (spacer);
     281        buttonLayout->addWidget (pbCancel);
     282    }
     283
     284private slots:
     285
     286    void grpBoxToggled (bool aOn)
     287    {
     288        if (aOn)
     289            mRbHost->animateClick();
     290        else
     291        {
     292            mRbHost->setChecked (false);
     293            mRbImage->setChecked (false);
     294            validate();
     295        }
     296    }
     297
     298    void rbClicked()
     299    {
     300        mCbHost->setEnabled (sender() == mRbHost);
     301        mCbImage->setEnabled (sender() == mRbImage);
     302        mTbVDM->setEnabled (sender() == mRbImage);
     303        validate();
     304    }
     305
     306    void vdmOpen()
     307    {
     308        VBoxDiskImageManagerDlg vdm (this, "VBoxDiskImageManagerDlg",
     309                                     WType_Dialog | WShowModal);
     310                QUuid machineId = mMachine.GetId();
     311        vdm.setup (VBoxDefs::CD, true, &machineId);
     312        if (vdm.exec() == VBoxDiskImageManagerDlg::Accepted)
     313            mCbImage->setCurrentItem (vdm.getSelectedUuid());
     314    }
     315
     316    void accept()
     317    {
     318        if (mGrpBox->isChecked() && mRbHost->isChecked())
     319        {
     320            CHostDVDDrive hostDrive = mHostDVDs [mCbHost->currentItem()];
     321            if (!hostDrive.isNull())
     322            {
     323                CDVDDrive virtualDrive = mMachine.GetDVDDrive();
     324                virtualDrive.CaptureHostDrive (hostDrive);
     325            }
     326        }
     327        else if (mGrpBox->isChecked() && mRbImage->isChecked())
     328        {
     329            CDVDDrive virtualDrive = mMachine.GetDVDDrive();
     330            virtualDrive.MountImage (mCbImage->getId());
     331        }
     332
     333        QDialog::accept();
     334    }
     335
     336private:
     337
     338    void validate()
     339    {
     340        bool valid =
     341            !mGrpBox->isChecked() ||
     342            (mGrpBox->isChecked() && mRbHost->isChecked()
     343             && !mCbHost->currentText().isEmpty()) ||
     344            (mGrpBox->isChecked() && mRbImage->isChecked()
     345             && !mCbImage->currentText().isEmpty());
     346        mPbOk->setEnabled (valid);
     347    }
     348
     349    CMachine mMachine;
     350    QButtonGroup *mGrpBox;
     351    QRadioButton *mRbHost, *mRbImage;
     352    QComboBox *mCbHost;
     353    VBoxMediaComboBox *mCbImage;
     354    QToolButton *mTbVDM;
     355    QPushButton *mPbOk;
     356    QValueVector <CHostDVDDrive> mHostDVDs;
    190357};
    191358
     
    225392    , was_max (false)
    226393    , console_style (0)
     394    , mIsFirstTimeStarted (true)
    227395#ifdef VBOX_WITH_DEBUGGER_GUI
    228396    , dbg_gui (NULL)
     
    675843static const char *GUI_Fullscreen = "GUI/Fullscreen";
    676844static const char *GUI_AutoresizeGuest = "GUI/AutoresizeGuest";
     845static const char *GUI_FirstRun = "GUI/FirstRun";
    677846
    678847/**
     
    726895        if (str != "off")
    727896            vmAutoresizeGuestAction->setOn (true);
     897
     898        str = cmachine.GetExtraData (GUI_FirstRun);
     899        if (str == "no")
     900            mIsFirstTimeStarted = false;
    728901
    729902        str = cmachine.GetExtraData (GUI_LastWindowPosition);
     
    8921065    CConsole cconsole = console->console();
    8931066
     1067    if (mIsFirstTimeStarted)
     1068    {
     1069        BootDVDDialog dlg (this, cmachine);
     1070        dlg.exec();
     1071    }
     1072
    8941073    /* start the VM */
    8951074    CProgress progress = cconsole.PowerUp();
     
    9931172        machine.SetExtraData (GUI_AutoresizeGuest,
    9941173                              vmAutoresizeGuestAction->isOn() ? "on" : "off");
     1174        machine.SetExtraData (GUI_FirstRun, "no");
    9951175    }
    9961176
     
    27172897}
    27182898
     2899#include "VBoxConsoleWnd.moc"
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