Changeset 1274 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Mar 6, 2007 2:58:38 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp
r1271 r1274 211 211 ~VBoxVMDescriptionPage() {} 212 212 213 void setMachine (const CMachine &);213 void setMachineItem (VBoxVMListBoxItem *aItem); 214 214 215 215 void languageChange(); 216 void updateState(); 216 217 217 218 private slots: 218 219 219 220 void goToSettings(); 220 void sessionStateChanged (const VBoxSessionStateChangeEvent &aE);221 void machineStateChanged (const VBoxMachineStateChangeEvent &aE);222 221 223 222 private: 224 223 225 QUuid mMachineId;224 VBoxVMListBoxItem *mItem; 226 225 227 226 VBoxSelectorWnd *mParent; … … 233 232 VBoxVMDescriptionPage::VBoxVMDescriptionPage (VBoxSelectorWnd *aParent, 234 233 const char *aName) 235 : QWidget (aParent, aName), mParent (aParent) 234 : QWidget (aParent, aName) 235 , mItem (NULL), mParent (aParent) 236 236 , mBtnEdit (0), mBrowser (0) 237 237 { … … 268 268 QSizePolicy::Minimum)); 269 269 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 276 270 /* apply language settings */ 277 271 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 */ 280 void VBoxVMDescriptionPage::setMachineItem (VBoxVMListBoxItem *aItem) 281 { 282 mItem = aItem; 283 284 QString text = aItem ? aItem->machine().GetDescription() : QString::null; 285 286 if (!text.isEmpty()) 292 287 { 293 288 mBrowser->setText (text); … … 303 298 304 299 /* 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(); 308 301 } 309 302 … … 315 308 } 316 309 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 */ 316 void 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 317 332 void VBoxVMDescriptionPage::goToSettings() 318 333 { 319 334 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 selective325 /// VM Settings dialog, where only fields that can be changed in the326 /// 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);344 335 } 345 336 … … 453 444 vmSnapshotsWgt = new VBoxSnapshotsWgt (NULL, "vmSnapshotsWgt"); 454 445 vmTabWidget->addTab (vmSnapshotsWgt, 455 VBoxGlobal::iconSet ("take_snapshot_16px.png"), 446 VBoxGlobal::iconSet ("take_snapshot_16px.png", 447 "take_snapshot_dis_16px.png"), 456 448 QString::null); 457 449 … … 459 451 vmDescriptionPage = new VBoxVMDescriptionPage (this, "vmDescriptionPage"); 460 452 vmTabWidget->addTab (vmDescriptionPage, 461 VBoxGlobal::iconSet ("description_16px.png"), 453 VBoxGlobal::iconSet ("description_16px.png", 454 "description_disabled_16px.png"), 462 455 QString::null); 463 456 … … 1063 1056 bool aRefreshDescription) 1064 1057 { 1065 if ( !vmListBox->selectedItem() && vmListBox->currentItem() >= 0)1058 if (!vmListBox->selectedItem() && vmListBox->currentItem() >= 0) 1066 1059 { 1067 1060 /* selected always follows current */ 1068 vmListBox->setSelected( vmListBox->currentItem(), true ); 1069 } 1061 vmListBox->setSelected (vmListBox->currentItem(), true); 1062 } 1063 1070 1064 vmListBox->ensureCurrentVisible(); 1071 1065 VBoxVMListBoxItem *item = (VBoxVMListBoxItem *) vmListBox->selectedItem(); … … 1093 1087 name += QString (" (%1)").arg (count); 1094 1088 vmTabWidget->changeTab (vmSnapshotsWgt, name); 1095 /* refresh snapshots widget */1089 /* refresh the snapshots widget */ 1096 1090 vmSnapshotsWgt->setMachine (m); 1091 /* ensure the tab is enabled */ 1092 vmTabWidget->setTabEnabled (vmSnapshotsWgt, true); 1097 1093 } 1098 1094 if (aRefreshDescription) … … 1102 1098 tr ("D&escription") : tr ("D&escription *"); 1103 1099 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); 1106 1104 } 1107 1105 … … 1138 1136 else 1139 1137 { 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 1140 1142 if (item) 1141 1143 { … … 1143 1145 vmDetailsView->setErrorText ( 1144 1146 VBoxProblemReporter::formatErrorInfo (item->accessError())); 1145 1146 1147 vmRefreshAction->setEnabled (true); 1147 1148 } 1148 1149 else 1149 1150 { 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.")); 1151 1163 vmRefreshAction->setEnabled (false); 1152 1164 } 1153 1165 1154 vmDetailsView->setEnabled (true); 1155 1156 /* empty and disable refresh snapshots widget */ 1166 /* empty and disable other tabs */ 1167 1157 1168 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); 1159 1175 1160 1176 /* disable modify actions */ 1161 1177 vmConfigAction->setEnabled (false); 1162 1178 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")); 1163 1187 vmStartAction->setEnabled (false); 1164 vmDiscardAction->setEnabled (false);1165 1188 } 1166 1189 } … … 1209 1232 refreshVMItem (e.id, 1210 1233 false /* aDetails */, 1211 false /* aSnapshot */,1234 false /* aSnapshots */, 1212 1235 false /* aDescription */); 1236 1237 /* simulate a state change signal */ 1238 vmDescriptionPage->updateState(); 1213 1239 } 1214 1240 … … 1217 1243 refreshVMItem (e.id, 1218 1244 true /* aDetails */, 1219 false /* aSnapshot */,1245 false /* aSnapshots */, 1220 1246 true /* aDescription */); 1221 1247 } … … 1249 1275 refreshVMItem (e.id, 1250 1276 true /* aDetails */, 1251 false /* aSnapshot */,1277 false /* aSnapshots */, 1252 1278 false /* aDescription */); 1279 1280 /* simulate a state change signal */ 1281 vmDescriptionPage->updateState(); 1253 1282 } 1254 1283
Note:
See TracChangeset
for help on using the changeset viewer.