VirtualBox

Ignore:
Timestamp:
Mar 6, 2007 2:58:38 PM (18 years ago)
Author:
vboxsync
Message:

FE/Qt: Fixed a lot more regressions in the Selector window.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp

    r1271 r1274  
    211211    ~VBoxVMDescriptionPage() {}
    212212
    213     void setMachine (const CMachine &);
     213    void setMachineItem (VBoxVMListBoxItem *aItem);
    214214
    215215    void languageChange();
     216    void updateState();
    216217
    217218private slots:
    218219
    219220    void goToSettings();
    220     void sessionStateChanged (const VBoxSessionStateChangeEvent &aE);
    221     void machineStateChanged (const VBoxMachineStateChangeEvent &aE);
    222221
    223222private:
    224223
    225     QUuid mMachineId;
     224    VBoxVMListBoxItem *mItem;
    226225
    227226    VBoxSelectorWnd *mParent;
     
    233232VBoxVMDescriptionPage::VBoxVMDescriptionPage (VBoxSelectorWnd *aParent,
    234233                                              const char *aName)
    235     : QWidget (aParent, aName), mParent (aParent)
     234    : QWidget (aParent, aName)
     235    , mItem (NULL), mParent (aParent)
    236236    , mBtnEdit (0), mBrowser (0)
    237237{
     
    268268                                          QSizePolicy::Minimum));
    269269
    270     /* connect VirtualBox callback events */
    271     connect (&vboxGlobal(), SIGNAL (machineStateChanged (const VBoxMachineStateChangeEvent &)),
    272              this, SLOT (machineStateChanged (const VBoxSessionStateChangeEvent &)));
    273     connect (&vboxGlobal(), SIGNAL (sessionStateChanged (const VBoxSessionStateChangeEvent &)),
    274              this, SLOT (sessionStateChanged (const VBoxSessionStateChangeEvent &)));
    275 
    276270    /* apply language settings */
    277271    languageChange();
    278 }
    279 
    280 void VBoxVMDescriptionPage::setMachine (const CMachine &aMachine)
    281 {
    282     Assert (!aMachine.isNull());
    283 
    284     mMachineId = aMachine.GetId();
    285 
    286     QString text = aMachine.GetDescription();
    287 
    288     if (text.isEmpty())
    289         text = QString::null;
    290 
    291     if (!text.isNull())
     272
     273    updateState();
     274}
     275
     276/**
     277 * The machine list @a aItem is used to access cached machine data w/o making
     278 * unnecessary RPC calls.
     279 */
     280void VBoxVMDescriptionPage::setMachineItem (VBoxVMListBoxItem *aItem)
     281{
     282    mItem = aItem;
     283
     284    QString text = aItem ? aItem->machine().GetDescription() : QString::null;
     285
     286    if (!text.isEmpty())
    292287    {
    293288        mBrowser->setText (text);
     
    303298
    304299    /* check initial machine and session states */
    305     bool saved = aMachine.GetState() == CEnums::Saved;
    306     bool busy = aMachine.GetState() != CEnums::SessionClosed;
    307     mBtnEdit->setEnabled (!saved && !busy);
     300    updateState();
    308301}
    309302
     
    315308}
    316309
     310/**
     311 * Called by the parent from machineStateChanged() and sessionStateChanged()
     312 * signal handlers. We cannot connect to these signals ourselves because we
     313 * use the VBoxVMListBoxItem which needs to be properly updated by the parent
     314 * first.
     315 */
     316void VBoxVMDescriptionPage::updateState()
     317{
     318    /// @todo disabling the edit button for a saved VM will not be necessary
     319    /// when we implement the selective VM Settings dialog, where only fields
     320    /// that can be changed in the saved state, can be changed.
     321
     322    if (mItem)
     323    {
     324        bool saved = mItem->state() == CEnums::Saved;
     325        bool busy = mItem->sessionState() != CEnums::SessionClosed;
     326        mBtnEdit->setEnabled (!saved && !busy);
     327    }
     328    else
     329        mBtnEdit->setEnabled (false);
     330}
     331
    317332void VBoxVMDescriptionPage::goToSettings()
    318333{
    319334    mParent->vmSettings ("#general", 2);
    320 }
    321 
    322 void VBoxVMDescriptionPage::machineStateChanged (const VBoxMachineStateChangeEvent &aE)
    323 {
    324     /// @todo this slot will not be necessary when we implement the selective
    325     /// VM Settings dialog, where only fields that can be changed in the
    326     /// saved state, can be changed.
    327 
    328     if (aE.id != mMachineId)
    329         return; /* not interested in other machines */
    330 
    331     /* disable the edit button for a saved machine */
    332     bool saved = aE.state == CEnums::Saved;
    333     mBtnEdit->setEnabled (!saved);
    334 }
    335 
    336 void VBoxVMDescriptionPage::sessionStateChanged (const VBoxSessionStateChangeEvent &aE)
    337 {
    338     if (aE.id != mMachineId)
    339         return; /* not interested in other machines */
    340 
    341     /* whether another direct session is open or not */
    342     bool busy = aE.state != CEnums::SessionClosed;
    343     mBtnEdit->setEnabled (!busy);
    344335}
    345336
     
    453444    vmSnapshotsWgt = new VBoxSnapshotsWgt (NULL, "vmSnapshotsWgt");
    454445    vmTabWidget->addTab (vmSnapshotsWgt,
    455                          VBoxGlobal::iconSet ("take_snapshot_16px.png"),
     446                         VBoxGlobal::iconSet ("take_snapshot_16px.png",
     447                                              "take_snapshot_dis_16px.png"),
    456448                         QString::null);
    457449
     
    459451    vmDescriptionPage = new VBoxVMDescriptionPage (this, "vmDescriptionPage");
    460452    vmTabWidget->addTab (vmDescriptionPage,
    461                          VBoxGlobal::iconSet ("description_16px.png"),
     453                         VBoxGlobal::iconSet ("description_16px.png",
     454                                              "description_disabled_16px.png"),
    462455                         QString::null);
    463456
     
    10631056                                               bool aRefreshDescription)
    10641057{
    1065     if ( !vmListBox->selectedItem() && vmListBox->currentItem() >= 0 )
     1058    if (!vmListBox->selectedItem() && vmListBox->currentItem() >= 0)
    10661059    {
    10671060        /* selected always follows current */
    1068         vmListBox->setSelected( vmListBox->currentItem(), true );
    1069     }
     1061        vmListBox->setSelected (vmListBox->currentItem(), true);
     1062    }
     1063
    10701064    vmListBox->ensureCurrentVisible();
    10711065    VBoxVMListBoxItem *item = (VBoxVMListBoxItem *) vmListBox->selectedItem();
     
    10931087                name += QString (" (%1)").arg (count);
    10941088            vmTabWidget->changeTab (vmSnapshotsWgt, name);
    1095             /* refresh snapshots widget */
     1089            /* refresh the snapshots widget */
    10961090            vmSnapshotsWgt->setMachine (m);
     1091            /* ensure the tab is enabled */
     1092            vmTabWidget->setTabEnabled (vmSnapshotsWgt, true);
    10971093        }
    10981094        if (aRefreshDescription)
     
    11021098                tr ("D&escription") : tr ("D&escription *");
    11031099            vmTabWidget->changeTab (vmDescriptionPage, name);
    1104             /* refresh description widget */
    1105             vmDescriptionPage->setMachine (m);
     1100            /* refresh the description widget */
     1101            vmDescriptionPage->setMachineItem (item);
     1102            /* ensure the tab is enabled */
     1103            vmTabWidget->setTabEnabled (vmDescriptionPage, true);
    11061104        }
    11071105
     
    11381136    else
    11391137    {
     1138        /* Note that the machine becomes inaccessible (or if the last VM gets
     1139         * deleted), we have to update all fields, ignoring input
     1140         * arguments. */
     1141
    11401142        if (item)
    11411143        {
     
    11431145            vmDetailsView->setErrorText (
    11441146                VBoxProblemReporter::formatErrorInfo (item->accessError()));
    1145 
    11461147            vmRefreshAction->setEnabled (true);
    11471148        }
    11481149        else
    11491150        {
    1150             vmDetailsView->setEmpty();
     1151            /* default HTML support in Qt is terrible so just try to get
     1152             * something really simple */
     1153            vmDetailsView->setDetailsText
     1154                (tr ("<h3><img src=ico64x01.png align=right/>"
     1155                     "Welcome to VirtualBox!</h3>"
     1156                     "<p>The left part of this window is intended to display "
     1157                     "a list of all virtual machines existing on this computer. "
     1158                     "This list is now empty because you didn't create any virtual "
     1159                     "machine."
     1160                     "<p>In order to create a new virtual machine, press the "
     1161                     "<b>New</b> button in the main tool bar located "
     1162                     "at the top of the window."));
    11511163            vmRefreshAction->setEnabled (false);
    11521164        }
    11531165
    1154         vmDetailsView->setEnabled (true);
    1155 
    1156         /* empty and disable refresh snapshots widget */
     1166        /* empty and disable other tabs */
     1167
    11571168        vmSnapshotsWgt->setMachine (CMachine());
    1158         vmSnapshotsWgt->setEnabled (false);
     1169        vmTabWidget->changeTab (vmSnapshotsWgt, tr ("&Snapshots"));
     1170        vmTabWidget->setTabEnabled (vmSnapshotsWgt, false);
     1171
     1172        vmDescriptionPage->setMachineItem (NULL);
     1173        vmTabWidget->changeTab (vmDescriptionPage, tr ("D&escription"));
     1174        vmTabWidget->setTabEnabled (vmDescriptionPage, false);
    11591175
    11601176        /* disable modify actions */
    11611177        vmConfigAction->setEnabled (false);
    11621178        vmDeleteAction->setEnabled (item != NULL);
     1179        vmDiscardAction->setEnabled (false);
     1180
     1181        /* change the Start button text accordingly */
     1182        vmStartAction->setMenuText (tr ("S&tart"));
     1183        vmStartAction->setText (tr ("Start"));
     1184        vmStartAction->setAccel (QString::null);
     1185        vmStartAction->setStatusTip (
     1186            tr ("Start the selected virtual machine"));
    11631187        vmStartAction->setEnabled (false);
    1164         vmDiscardAction->setEnabled (false);
    11651188    }
    11661189}
     
    12091232    refreshVMItem (e.id,
    12101233                   false /* aDetails */,
    1211                    false /* aSnapshot */,
     1234                   false /* aSnapshots */,
    12121235                   false /* aDescription */);
     1236
     1237    /* simulate a state change signal */
     1238    vmDescriptionPage->updateState();
    12131239}
    12141240
     
    12171243    refreshVMItem (e.id,
    12181244                   true  /* aDetails */,
    1219                    false /* aSnapshot */,
     1245                   false /* aSnapshots */,
    12201246                   true  /* aDescription */);
    12211247}
     
    12491275    refreshVMItem (e.id,
    12501276                   true  /* aDetails */,
    1251                    false /* aSnapshot */,
     1277                   false /* aSnapshots */,
    12521278                   false /* aDescription */);
     1279
     1280    /* simulate a state change signal */
     1281    vmDescriptionPage->updateState();
    12531282}
    12541283
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