- Timestamp:
- Nov 4, 2008 4:01:42 PM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxSelectorWnd.h
r13580 r13790 33 33 /* Qt includes */ 34 34 #include <QMainWindow> 35 #ifdef VBOX_GUI_WITH_SYSTRAY 36 #include <QSystemTrayIcon> 37 #endif 38 #include <QUuid> 35 39 36 40 class VBoxSnapshotsWgt; … … 66 70 67 71 void fileMediaMgr(); 72 VBoxVMItem* getSelectedItem(); 73 #ifdef VBOX_GUI_WITH_SYSTRAY 74 void iconActivated(QSystemTrayIcon::ActivationReason aReason); 75 void showWindow(); 76 #endif 68 77 void fileSettings(); 69 78 void fileExit(); … … 71 80 void vmNew(); 72 81 void vmSettings (const QString &aCategory = QString::null, 73 const QString &aControl = QString::null); 74 void vmDelete(); 75 void vmStart(); 76 void vmDiscard(); 77 void vmPause (bool); 78 void vmRefresh(); 79 void vmShowLogs(); 82 const QString &aControl = QString::null, 83 const QUuid& = ""); 84 void vmDelete(const QUuid& = ""); 85 void vmStart (const QUuid& = ""); 86 void vmDiscard(const QUuid& = ""); 87 void vmPause (bool, const QUuid& = ""); 88 void vmRefresh(const QUuid& = ""); 89 void vmShowLogs(const QUuid& = ""); 80 90 91 #ifdef VBOX_GUI_WITH_SYSTRAY 92 void refreshSysTray(); 93 #endif 81 94 void refreshVMList(); 82 95 void refreshVMItem (const QUuid &aID, bool aDetails, … … 129 142 QAction *fileExitAction; 130 143 QAction *vmNewAction; 144 #ifdef VBOX_GUI_WITH_SYSTRAY 145 QAction *trayShowWindowAction; 146 QAction *trayExitAction; 147 #endif 131 148 QAction *vmConfigAction; 132 149 QAction *vmDeleteAction; … … 138 155 139 156 VBoxHelpActions mHelpActions; 157 158 #ifdef VBOX_GUI_WITH_SYSTRAY 159 /* The systray icon */ 160 QSystemTrayIcon *trayIcon; 161 QMenu *trayIconMenu; 162 #endif 140 163 141 164 /* The vm list view/model */ -
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxVMListView.h
r9729 r13790 31 31 #include <QDateTime> 32 32 33 class VBoxVMItem 34 { 35 public: 36 VBoxVMItem (const CMachine &aM); 33 class VBoxVMItem : public QObject 34 { 35 Q_OBJECT; 36 37 public: 38 39 enum Action 40 { 41 Config = 0, 42 Delete, 43 Start, 44 Discard, 45 Pause, 46 Refresh, 47 ShowLogs 48 }; 49 50 public: 51 52 VBoxVMItem (const CMachine &aM, QObject* pParent); 37 53 virtual ~VBoxVMItem(); 38 54 … … 42 58 QIcon osIcon() const { return mAccessible ? vboxGlobal().vmGuestOSTypeIcon (mOSTypeId) :QPixmap (":/os_unknown.png"); } 43 59 QUuid id() const { return mId; } 44 60 45 61 QString sessionStateName() const; 46 62 QIcon sessionStateIcon() const { return mAccessible ? vboxGlobal().toIcon (mState) : QPixmap (":/state_aborted_16px.png"); } … … 49 65 ULONG snapshotCount() const { return mSnapshotCount; } 50 66 67 QAction* vmActionConfig() const { return vmConfigAction; } 68 QAction* vmActionDelete() const { return vmDeleteAction; } 69 QAction* vmActionStart() const { return vmStartAction; } 70 QAction* vmActionDiscard() const { return vmDiscardAction; } 71 QAction* vmActionPause() const { return vmPauseAction; } 72 QAction* vmActionRefresh() const { return vmRefreshAction; } 73 QAction* vmActionShowLogs() const { return vmShowLogsAction; } 74 51 75 QString toolTipText() const; 52 76 53 77 bool accessible() const { return mAccessible; } 78 bool running() const { return (sessionState() != KSessionState_Closed); } 54 79 const CVirtualBoxErrorInfo &accessError() const { return mAccessError; } 55 80 KMachineState state() const { return mState; } … … 60 85 bool canSwitchTo() const; 61 86 bool switchTo(); 87 88 void updateActions(); 62 89 63 90 private: 64 91 65 92 /* Private member vars */ 93 QObject* mParent; 66 94 CMachine mMachine; 95 96 QAction *vmConfigAction; 97 QAction *vmDeleteAction; 98 QAction *vmStartAction; 99 QAction *vmDiscardAction; 100 QAction *vmPauseAction; 101 QAction *vmRefreshAction; 102 QAction *vmShowLogsAction; 67 103 68 104 /* Cached machine data (to minimize server requests) */ … … 82 118 83 119 ULONG mPid; 120 121 private slots: 122 123 void vmSettings(); 124 void vmDelete(); 125 void vmStart(); 126 void vmDiscard(); 127 void vmPause(bool aPause); 128 void vmRefresh(); 129 void vmShowLogs(); 84 130 }; 85 131 … … 111 157 112 158 VBoxVMItem *itemById (const QUuid &aId) const; 159 VBoxVMItem *itemByRow (int aRow) const; 113 160 QModelIndex indexById (const QUuid &aId) const; 114 161 … … 163 210 void mousePressEvent (QMouseEvent *aEvent); 164 211 bool selectCurrent(); 165 }; 212 }; 166 213 167 214 class VBoxVMItemPainter: public QIItemDelegate … … 181 228 inline QIcon::Mode iconMode (QStyle::State aState) const 182 229 { 183 if (!(aState & QStyle::State_Enabled)) 230 if (!(aState & QStyle::State_Enabled)) 184 231 return QIcon::Disabled; 185 if (aState & QStyle::State_Selected) 232 if (aState & QStyle::State_Selected) 186 233 return QIcon::Selected; 187 234 return QIcon::Normal; -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxSelectorWnd.cpp
r13669 r13790 412 412 fileExitAction->setMenuRole (QAction::QuitRole); 413 413 fileExitAction->setIcon (VBoxGlobal::iconSet (":/exit_16px.png")); 414 415 #ifdef VBOX_GUI_WITH_SYSTRAY 416 trayShowWindowAction = new QAction (this); 417 trayShowWindowAction->setIcon (VBoxGlobal::iconSet (":/VirtualBox_16px.png")); 418 trayShowWindowAction->setText (tr ("Sun xVM VirtualBox")); 419 420 trayExitAction = new QAction (this); 421 trayExitAction->setMenuRole (QAction::QuitRole); 422 trayExitAction->setIcon (VBoxGlobal::iconSet (":/exit_16px.png")); 423 #endif 414 424 415 425 vmNewAction = new QAction (this); … … 456 466 mHelpActions.setup (this); 457 467 458 /* Subwidgets */ 468 #ifdef VBOX_GUI_WITH_SYSTRAY 469 if (QSystemTrayIcon::isSystemTrayAvailable()) 470 { 471 /* tray menu */ 472 trayIconMenu = new QMenu(this); 473 474 /* tray icon */ 475 trayIcon = new QSystemTrayIcon (this); 476 trayIcon->setIcon(QIcon (":/VirtualBox_16px.png")); 477 trayIcon->setContextMenu (trayIconMenu); 478 479 connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), 480 this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); 481 } 482 #endif 459 483 460 484 /* Central widget @ horizontal layout */ … … 640 664 connect (fileExitAction, SIGNAL (triggered()), this, SLOT (fileExit())); 641 665 connect (vmNewAction, SIGNAL (triggered()), this, SLOT (vmNew())); 666 642 667 connect (vmConfigAction, SIGNAL (triggered()), this, SLOT (vmSettings())); 643 668 connect (vmDeleteAction, SIGNAL (triggered()), this, SLOT (vmDelete())); … … 647 672 connect (vmRefreshAction, SIGNAL (triggered()), this, SLOT (vmRefresh())); 648 673 connect (vmShowLogsAction, SIGNAL (triggered()), this, SLOT (vmShowLogs())); 674 675 #ifdef VBOX_GUI_WITH_SYSTRAY 676 connect (trayShowWindowAction, SIGNAL (triggered()), this, SLOT(showWindow())); 677 #endif 649 678 650 679 connect (mVMListView, SIGNAL (currentChanged()), … … 699 728 /* Save vm selector position */ 700 729 { 701 VBoxVMItem *item = mVMListView->selectedItem();730 VBoxVMItem *item = getSelectedItem(); 702 731 QString curVMId = item ? 703 732 QString (item->id()) : … … 712 741 // Public slots 713 742 ///////////////////////////////////////////////////////////////////////////// 743 744 #ifdef VBOX_GUI_WITH_SYSTRAY 745 void VBoxSelectorWnd::iconActivated(QSystemTrayIcon::ActivationReason aReason) 746 { 747 switch (aReason) 748 { 749 750 case QSystemTrayIcon::Context: 751 752 refreshSysTray(); 753 break; 754 755 case QSystemTrayIcon::Trigger: 756 break; 757 758 case QSystemTrayIcon::DoubleClick: 759 760 showWindow(); 761 break; 762 763 case QSystemTrayIcon::MiddleClick: 764 break; 765 766 default: 767 break; 768 } 769 } 770 #endif 771 772 VBoxVMItem* VBoxSelectorWnd::getSelectedItem() 773 { 774 VBoxVMItem* pItem = NULL; 775 776 if (NULL == pItem) 777 pItem = mVMListView->selectedItem(); 778 779 /* pItem can be NULL here, so don't assert. */ 780 return pItem; 781 } 782 783 #ifdef VBOX_GUI_WITH_SYSTRAY 784 void VBoxSelectorWnd::showWindow() 785 { 786 showNormal(); 787 setFocus(); 788 } 789 #endif 714 790 715 791 void VBoxSelectorWnd::fileMediaMgr() … … 769 845 * Opens the VM settings dialog. 770 846 */ 771 void VBoxSelectorWnd::vmSettings (const QString &aCategory, const QString &aControl )847 void VBoxSelectorWnd::vmSettings (const QString &aCategory, const QString &aControl, const QUuid& a_Uuid) 772 848 { 773 849 if (!aCategory.isEmpty() && aCategory [0] != '#') … … 778 854 } 779 855 780 VBoxVMItem *item = mVMListView->selectedItem(); 856 VBoxVMItem *item = mVMModel->itemById (a_Uuid); 857 if (NULL == item) 858 item = getSelectedItem(); 781 859 782 860 AssertMsgReturnVoid (item, ("Item must be always selected here")); … … 819 897 } 820 898 821 void VBoxSelectorWnd::vmDelete() 822 { 823 VBoxVMItem *item = mVMListView->selectedItem(); 899 void VBoxSelectorWnd::vmDelete(const QUuid& a_Uuid) 900 { 901 VBoxVMItem *item = mVMModel->itemById (a_Uuid); 902 if (NULL == item) 903 item = getSelectedItem(); 824 904 825 905 AssertMsgReturnVoid (item, ("Item must be always selected here")); … … 879 959 } 880 960 881 void VBoxSelectorWnd::vmStart() 882 { 961 void VBoxSelectorWnd::vmStart(const QUuid& a_Uuid) 962 { 963 VBoxVMItem *item = mVMModel->itemById (a_Uuid); 964 if (NULL == item) 965 item = getSelectedItem(); 966 967 AssertMsgReturn (item, ("Item must be always selected here"), (void) 0); 968 883 969 /* we always get here when mVMListView emits the activated() signal, 884 970 * so we must explicitly check if the action is enabled or not. */ 885 if (! vmStartAction->isEnabled())971 if (!item->vmActionStart()->isEnabled()) 886 972 return; 887 888 VBoxVMItem *item = mVMListView->selectedItem();889 890 AssertMsg (item, ("Item must be always selected here"));891 973 892 974 #if defined (VBOX_GUI_SEPARATE_VM_PROCESS) … … 956 1038 } 957 1039 958 void VBoxSelectorWnd::vmDiscard() 959 { 960 VBoxVMItem *item = mVMListView->selectedItem(); 1040 void VBoxSelectorWnd::vmDiscard(const QUuid& a_Uuid) 1041 { 1042 VBoxVMItem *item = mVMModel->itemById (a_Uuid); 1043 if (NULL == item) 1044 item = getSelectedItem(); 961 1045 962 1046 AssertMsgReturn (item, ("Item must be always selected here"), (void) 0); … … 990 1074 } 991 1075 992 void VBoxSelectorWnd::vmPause (bool aPause) 993 { 994 VBoxVMItem *item = mVMListView->selectedItem(); 1076 void VBoxSelectorWnd::vmPause (bool aPause, const QUuid& a_Uuid) 1077 { 1078 VBoxVMItem *item = mVMModel->itemById (a_Uuid); 1079 if (NULL == item) 1080 item = getSelectedItem(); 995 1081 996 1082 AssertMsgReturn (item, ("Item must be always selected here"), (void) 0); … … 1021 1107 } 1022 1108 1023 void VBoxSelectorWnd::vmRefresh() 1024 { 1025 VBoxVMItem *item = mVMListView->selectedItem(); 1109 void VBoxSelectorWnd::vmRefresh(const QUuid& a_Uuid) 1110 { 1111 VBoxVMItem *item = mVMModel->itemById (a_Uuid); 1112 if (NULL == item) 1113 item = getSelectedItem(); 1026 1114 1027 1115 AssertMsgReturn (item, ("Item must be always selected here"), (void) 0); … … 1033 1121 } 1034 1122 1035 void VBoxSelectorWnd::vmShowLogs() 1036 { 1037 VBoxVMItem *item = mVMListView->selectedItem(); 1123 void VBoxSelectorWnd::vmShowLogs(const QUuid& a_Uuid) 1124 { 1125 VBoxVMItem *item = mVMModel->itemById (a_Uuid); 1126 if (NULL == item) 1127 item = getSelectedItem(); 1128 1038 1129 CMachine machine = item->machine(); 1039 1130 VBoxVMLogViewer::createLogViewer (this, machine); 1040 1131 } 1132 1133 #ifdef VBOX_GUI_WITH_SYSTRAY 1134 void VBoxSelectorWnd::refreshSysTray() 1135 { 1136 if (false == QSystemTrayIcon::isSystemTrayAvailable()) 1137 return; 1138 1139 Assert(trayIcon); 1140 Assert(trayIconMenu); 1141 1142 trayIcon->setVisible (true); 1143 trayIconMenu->clear(); 1144 trayIconMenu->addAction (trayExitAction); 1145 trayIconMenu->addSeparator(); 1146 1147 VBoxVMItem* pItem = NULL; 1148 QMenu* pSubMenu = NULL; 1149 for (int i = 0; i < mVMModel->rowCount(); i++) 1150 { 1151 pItem = mVMModel->itemByRow(i); 1152 Assert(pItem); 1153 1154 pSubMenu = new QMenu (pItem->name()); 1155 Assert(pSubMenu); 1156 pSubMenu->setIcon (pItem->osIcon()); 1157 if(pItem->accessible()) 1158 { 1159 pSubMenu->addAction (pItem->vmActionConfig()); 1160 pSubMenu->addAction (pItem->vmActionDelete()); 1161 pSubMenu->addSeparator(); 1162 pSubMenu->addAction (pItem->vmActionStart()); 1163 pSubMenu->addAction (pItem->vmActionDiscard()); 1164 if (pItem->running()) 1165 { 1166 pSubMenu->addSeparator(); 1167 pSubMenu->addAction (pItem->vmActionPause()); 1168 } 1169 pSubMenu->addSeparator(); 1170 pSubMenu->addAction (pItem->vmActionShowLogs()); 1171 } 1172 else 1173 { 1174 pSubMenu->addAction (pItem->vmActionDelete()); 1175 pSubMenu->addAction (pItem->vmActionRefresh()); 1176 } 1177 1178 trayIconMenu->addMenu (pSubMenu); 1179 } 1180 1181 trayIconMenu->addSeparator(); 1182 trayIconMenu->addAction (fileExitAction); 1183 1184 trayIconMenu->setVisible (true); 1185 } 1186 #endif 1041 1187 1042 1188 void VBoxSelectorWnd::refreshVMList() … … 1046 1192 for (CMachineVector::ConstIterator m = vec.begin(); 1047 1193 m != vec.end(); ++ m) 1048 mVMModel->addItem (new VBoxVMItem (*m ));1194 mVMModel->addItem (new VBoxVMItem (*m, this)); 1049 1195 mVMModel->sort(); 1050 1196 1051 1197 vmListViewCurrentChanged(); 1198 1199 #ifdef VBOX_GUI_WITH_SYSTRAY 1200 refreshSysTray(); 1201 #endif 1052 1202 } 1053 1203 … … 1247 1397 1248 1398 void VBoxSelectorWnd::vmListViewCurrentChanged (bool aRefreshDetails, 1249 bool aRefreshSnapshots,1250 bool aRefreshDescription)1251 { 1252 VBoxVMItem *item = mVMListView->selectedItem();1399 bool aRefreshSnapshots, 1400 bool aRefreshDescription) 1401 { 1402 VBoxVMItem *item = getSelectedItem(); 1253 1403 1254 1404 if (item && item->accessible()) … … 1479 1629 if (!m.isNull()) 1480 1630 { 1481 mVMModel->addItem (new VBoxVMItem (m ));1631 mVMModel->addItem (new VBoxVMItem (m, this)); 1482 1632 mVMModel->sort(); 1483 1633 /* Make sure the description, ... pages are properly updated. -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMListView.cpp
r12058 r13790 23 23 #include "VBoxVMListView.h" 24 24 #include "VBoxProblemReporter.h" 25 #include "VBoxSelectorWnd.h" 25 26 26 27 /* Qt includes */ … … 134 135 #endif 135 136 136 VBoxVMItem::VBoxVMItem (const CMachine &aM) 137 : mMachine (aM) 138 { 137 VBoxVMItem::VBoxVMItem (const CMachine &aM, QObject* pParent) 138 : mMachine (aM), mParent(pParent) 139 { 140 vmConfigAction = new QAction (this); 141 vmConfigAction->setIcon (VBoxGlobal::iconSetFull ( 142 QSize (32, 32), QSize (16, 16), 143 ":/vm_settings_32px.png", ":/settings_16px.png", 144 ":/vm_settings_disabled_32px.png", ":/settings_dis_16px.png")); 145 vmDeleteAction = new QAction (this); 146 vmDeleteAction->setIcon (VBoxGlobal::iconSetFull ( 147 QSize (32, 32), QSize (16, 16), 148 ":/vm_delete_32px.png", ":/delete_16px.png", 149 ":/vm_delete_disabled_32px.png", ":/delete_dis_16px.png")); 150 vmStartAction = new QAction (this); 151 vmStartAction->setIcon (VBoxGlobal::iconSetFull ( 152 QSize (32, 32), QSize (16, 16), 153 ":/vm_start_32px.png", ":/start_16px.png", 154 ":/vm_start_disabled_32px.png", ":/start_dis_16px.png")); 155 vmDiscardAction = new QAction (this); 156 vmDiscardAction->setIcon (VBoxGlobal::iconSetFull ( 157 QSize (32, 32), QSize (16, 16), 158 ":/vm_discard_32px.png", ":/discard_16px.png", 159 ":/vm_discard_disabled_32px.png", ":/discard_dis_16px.png")); 160 vmPauseAction = new QAction (this); 161 vmPauseAction->setCheckable (true); 162 vmPauseAction->setIcon (VBoxGlobal::iconSetFull ( 163 QSize (32, 32), QSize (16, 16), 164 ":/vm_pause_32px.png", ":/pause_16px.png", 165 ":/vm_pause_disabled_32px.png", ":/pause_disabled_16px.png")); 166 vmRefreshAction = new QAction (this); 167 vmRefreshAction->setIcon (VBoxGlobal::iconSetFull ( 168 QSize (32, 32), QSize (16, 16), 169 ":/refresh_32px.png", ":/refresh_16px.png", 170 ":/refresh_disabled_32px.png", ":/refresh_disabled_16px.png")); 171 vmShowLogsAction = new QAction (this); 172 vmShowLogsAction->setIcon (VBoxGlobal::iconSetFull ( 173 QSize (32, 32), QSize (16, 16), 174 ":/vm_show_logs_32px.png", ":/show_logs_16px.png", 175 ":/vm_show_logs_disabled_32px.png", ":/show_logs_disabled_16px.png")); 176 139 177 recache(); 178 179 connect (vmConfigAction, SIGNAL (triggered()), this, SLOT (vmSettings())); 180 connect (vmDeleteAction, SIGNAL (triggered()), this, SLOT (vmDelete())); 181 connect (vmStartAction, SIGNAL (triggered()), this, SLOT (vmStart())); 182 connect (vmDiscardAction, SIGNAL (triggered()), this, SLOT (vmDiscard())); 183 connect (vmPauseAction, SIGNAL (toggled (bool)), this, SLOT (vmPause (bool))); 184 connect (vmRefreshAction, SIGNAL (triggered()), this, SLOT (vmRefresh())); 185 connect (vmShowLogsAction, SIGNAL (triggered()), this, SLOT (vmShowLogs())); 186 187 updateActions(); 140 188 } 141 189 … … 150 198 { 151 199 return mAccessible ? vboxGlobal().toString (mState) : VBoxVMListView::tr ("Inaccessible"); 200 } 201 202 void VBoxVMItem::vmSettings() 203 { 204 VBoxSelectorWnd* pWnd = qobject_cast<VBoxSelectorWnd*>(mParent); 205 Assert (pWnd); 206 emit pWnd->vmSettings(NULL, NULL, mId); 207 } 208 209 void VBoxVMItem::vmDelete() 210 { 211 VBoxSelectorWnd* pWnd = qobject_cast<VBoxSelectorWnd*>(mParent); 212 Assert (pWnd); 213 emit pWnd->vmDelete(mId); 214 } 215 216 void VBoxVMItem::vmStart() 217 { 218 VBoxSelectorWnd* pWnd = qobject_cast<VBoxSelectorWnd*>(mParent); 219 Assert (pWnd); 220 emit pWnd->vmStart(mId); 221 } 222 223 void VBoxVMItem::vmDiscard() 224 { 225 VBoxSelectorWnd* pWnd = qobject_cast<VBoxSelectorWnd*>(mParent); 226 Assert (pWnd); 227 emit pWnd->vmDiscard(mId); 228 } 229 230 void VBoxVMItem::vmPause(bool aPause) 231 { 232 VBoxSelectorWnd* pWnd = qobject_cast<VBoxSelectorWnd*>(mParent); 233 Assert (pWnd); 234 emit pWnd->vmPause(aPause, mId); 235 } 236 237 void VBoxVMItem::vmRefresh() 238 { 239 VBoxSelectorWnd* pWnd = qobject_cast<VBoxSelectorWnd*>(mParent); 240 Assert (pWnd); 241 emit pWnd->vmRefresh(mId); 242 } 243 244 void VBoxVMItem::vmShowLogs() 245 { 246 VBoxSelectorWnd* pWnd = qobject_cast<VBoxSelectorWnd*>(mParent); 247 Assert (pWnd); 248 emit pWnd->vmShowLogs(mId); 152 249 } 153 250 … … 199 296 { 200 297 QString name = mMachine.GetName(); 298 setObjectName(name); 201 299 CSnapshot snp = mMachine.GetCurrentSnapshot(); 202 300 mSnapshotName = snp.isNull() ? QString::null : snp.GetName(); … … 385 483 } 386 484 485 void VBoxVMItem::updateActions() 486 { 487 if (accessible()) 488 { 489 CMachine m = machine(); 490 491 KMachineState s = state(); 492 bool run = running(); 493 bool modifyEnabled = !run && s != KMachineState_Saved; 494 495 /* enable/disable modify actions */ 496 vmConfigAction->setEnabled (modifyEnabled); 497 vmDeleteAction->setEnabled (modifyEnabled); 498 vmDiscardAction->setEnabled (s == KMachineState_Saved && !run); 499 vmPauseAction->setEnabled (s == KMachineState_Running || 500 s == KMachineState_Paused); 501 502 /* change the Start button text accordingly */ 503 if (s >= KMachineState_Running) 504 { 505 vmStartAction->setText (tr ("S&how")); 506 vmStartAction->setStatusTip ( 507 tr ("Switch to the window of the selected virtual machine")); 508 509 vmStartAction->setEnabled (canSwitchTo()); 510 } 511 else 512 { 513 vmStartAction->setText (tr ("S&tart")); 514 vmStartAction->setStatusTip ( 515 tr ("Start the selected virtual machine")); 516 517 vmStartAction->setEnabled (!run); 518 } 519 520 /* change the Pause/Resume button text accordingly */ 521 if (s == KMachineState_Paused) 522 { 523 vmPauseAction->setText (tr ("R&esume")); 524 vmPauseAction->setStatusTip ( 525 tr ("Resume the execution of the virtual machine")); 526 vmPauseAction->blockSignals (true); 527 vmPauseAction->setChecked (true); 528 vmPauseAction->blockSignals (false); 529 } 530 else 531 { 532 vmPauseAction->setText (tr ("&Pause")); 533 vmPauseAction->setStatusTip ( 534 tr ("Suspend the execution of the virtual machine")); 535 vmPauseAction->blockSignals (true); 536 vmPauseAction->setChecked (false); 537 vmPauseAction->blockSignals (false); 538 } 539 540 /* disable Refresh for accessible machines */ 541 vmRefreshAction->setEnabled (false); 542 543 /* enable the show log item for the selected vm */ 544 vmShowLogsAction->setEnabled (true); 545 } 546 else 547 { 548 vmRefreshAction->setEnabled (true); 549 550 /* disable modify actions */ 551 vmConfigAction->setEnabled (false); 552 vmDeleteAction->setEnabled (true); 553 vmDiscardAction->setEnabled (false); 554 vmPauseAction->setEnabled (false); 555 556 /* change the Start button text accordingly */ 557 vmStartAction->setText (tr ("S&tart")); 558 vmStartAction->setStatusTip ( 559 tr ("Start the selected virtual machine")); 560 vmStartAction->setEnabled (false); 561 562 /* disable the show log item for the selected vm */ 563 vmShowLogsAction->setEnabled (false); 564 } 565 566 vmConfigAction->setText (tr ("&Settings...")); 567 vmConfigAction->setStatusTip (tr ("Configure the selected virtual machine")); 568 569 vmDeleteAction->setText (tr ("&Delete")); 570 vmDeleteAction->setStatusTip (tr ("Delete the selected virtual machine")); 571 572 vmDiscardAction->setText (tr ("D&iscard")); 573 vmDiscardAction->setStatusTip ( 574 tr ("Discard the saved state of the selected virtual machine")); 575 576 vmRefreshAction->setText (tr ("&Refresh")); 577 vmRefreshAction->setStatusTip ( 578 tr ("Refresh the accessibility state of the selected virtual machine")); 579 580 vmShowLogsAction->setText (tr ("Show &Log...")); 581 vmShowLogsAction->setIconText (tr ("Log", "icon text")); 582 vmShowLogsAction->setStatusTip ( 583 tr ("Show the log files of the selected virtual machine")); 584 } 585 387 586 /* VBoxVMModel class */ 388 587 … … 421 620 { 422 621 Assert (aItem); 622 aItem->updateActions(); 423 623 if (aItem->recache()) 424 624 sort(); … … 455 655 return item; 456 656 return NULL; 657 } 658 659 VBoxVMItem *VBoxVMModel::itemByRow (int aRow) const 660 { 661 return mVMItemList.at (aRow); 457 662 } 458 663
Note:
See TracChangeset
for help on using the changeset viewer.