- Timestamp:
- Oct 13, 2009 1:12:05 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 53443
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h
r23562 r23723 6 6 7 7 /* 8 * Copyright (C) 2006-200 7Sun Microsystems, Inc.8 * Copyright (C) 2006-2009 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 24 24 #define __VBoxConsoleWnd_h__ 25 25 26 /* Global includes */ 27 #include <QColor> 28 #include <QDialog> 29 #include <QMainWindow> 30 #include <QMap> 31 #include <QMenu> 32 #include <QPointer> 33 34 /* Local includes */ 26 35 #include "COMDefs.h" 27 28 36 #include "QIWithRetranslateUI.h" 29 30 37 #include "VBoxProblemReporter.h" 31 38 #include "VBoxHelpActions.h" 32 33 /* Qt includes */34 #include <QMainWindow>35 #include <QMap>36 #include <QColor>37 #include <QDialog>38 #include <QMenu>39 #include <QPointer>40 39 41 40 #ifdef VBOX_WITH_DEBUGGER_GUI … … 49 48 #endif 50 49 50 /* Global forwards */ 51 51 class QAction; 52 52 class QActionGroup; … … 54 54 class QSpacerItem; 55 55 56 /* Local forwards */ 57 class QIMenu; 58 class QIStateIndicator; 59 class VBoxChangeDockIconUpdateEvent; 56 60 class VBoxConsoleView; 57 class QIStateIndicator;58 61 class VBoxMiniToolBar; 62 class VBoxSwitchMenu; 59 63 class VBoxUSBMenu; 60 class VBoxSwitchMenu; 61 62 class VBoxChangeDockIconUpdateEvent; 63 64 class VBoxMiniToolBar; 65 66 /* We want to make the first action highlighted but not 67 * selected, but Qt makes the both or neither one of this, 68 * so, just move the focus to the next eligible object, 69 * which will be the first menu action. This little 70 * subclass made only for that purpose. */ 71 class QIMenu : public QMenu 64 65 class VBoxConsoleWnd : public QIWithRetranslateUI2 <QMainWindow> 72 66 { 73 67 Q_OBJECT; … … 75 69 public: 76 70 77 QIMenu (QWidget *aParent) : QMenu (aParent) {} 78 79 void selectFirstAction() { QMenu::focusNextChild(); } 80 }; 81 82 class VBoxConsoleWnd : public QIWithRetranslateUI2<QMainWindow> 83 { 84 Q_OBJECT; 85 86 public: 87 88 VBoxConsoleWnd (VBoxConsoleWnd **aSelf, 89 QWidget* aParent = 0, 90 Qt::WindowFlags aFlags = Qt::Window); 71 VBoxConsoleWnd (VBoxConsoleWnd **aSelf, QWidget* aParent = 0, Qt::WindowFlags aFlags = Qt::Window); 91 72 virtual ~VBoxConsoleWnd(); 92 93 bool openView (const CSession &session);94 95 void refreshView();96 73 97 74 bool isWindowMaximized() const … … 101 78 * maximize the window. This situation has to be considered when 102 79 * checking for maximized or fullscreen mode. */ 103 return ! (isTrueSeamless()) && QMainWindow::isMaximized();80 return !isTrueSeamless() && QMainWindow::isMaximized(); 104 81 #else /* Q_WS_MAC */ 105 82 return QMainWindow::isMaximized(); … … 117 94 #endif /* Q_WS_MAC */ 118 95 } 119 120 96 bool isTrueFullscreen() const { return mIsFullscreen; } 121 122 97 bool isTrueSeamless() const { return mIsSeamless; } 123 98 99 KMachineState machineState() const { return mMachineState; } 100 101 bool openView (const CSession &aSession); 102 124 103 void setMouseIntegrationLocked (bool aDisabled); 125 104 … … 129 108 130 109 void setMask (const QRegion &aRegion); 131 132 110 void clearMask(); 133 111 134 KMachineState machineState() const { return machine_state; }135 136 public slots:137 138 void changeDockIconUpdate (const VBoxChangeDockIconUpdateEvent &e);139 140 112 signals: 141 113 … … 144 116 protected: 145 117 146 // events 147 bool event (QEvent *e); 148 void closeEvent (QCloseEvent *e); 149 #if defined(Q_WS_X11) 150 bool x11Event (XEvent *event); 118 bool event (QEvent *aEvent); 119 void closeEvent (QCloseEvent *aEvent); 120 #ifdef Q_WS_X11 121 bool x11Event (XEvent *aEvent); 151 122 #endif 152 123 153 124 void retranslateUi(); 154 125 155 #ifdef VBOX_WITH_DEBUGGER_GUI 156 bool dbgCreated(); 157 void dbgDestroy(); 158 void dbgAdjustRelativePos(); 159 #endif 160 161 protected slots: 162 163 void closeView(); 126 private slots: 127 128 void finalizeOpenView(); 129 void tryClose(); 130 131 void vmFullscreen (bool aOn); 132 void vmSeamless (bool aOn); 133 void vmAutoresizeGuest (bool aOn); 134 void vmAdjustWindow(); 135 void vmDisableMouseIntegration (bool aOff); 136 void vmTypeCAD(); 137 #ifdef Q_WS_X11 138 void vmTypeCABS(); 139 #endif 140 void vmTakeSnapshot(); 141 void vmShowInfoDialog(); 142 void vmReset(); 143 void vmPause (bool aOn); 144 void vmACPIShutdown(); 145 void vmClose(); 146 147 void devicesSwitchVrdp (bool aOn); 148 void devicesOpenStorageDialog(); 149 void devicesOpenNetworkDialog(); 150 void devicesOpenSFDialog(); 151 void devicesInstallGuestAdditions(); 152 153 void prepareStorageMenu(); 154 void prepareNetworkMenu(); 155 void prepareSFMenu(); 156 157 void switchUSB (QAction *aAction); 158 159 void showIndicatorContextMenu (QIStateIndicator *aInd, QContextMenuEvent *aEvent); 160 161 void updateDeviceLights(); 162 void updateMachineState (KMachineState aState); 163 void updateMouseState (int aState); 164 void updateAdditionsState (const QString &aVersion, bool aActive, 165 bool aSeamlessSupported, bool aGraphicsSupported); 166 void updateNetworkAdaptersState(); 167 void updateUsbState(); 168 void updateMediaDriveState (VBoxDefs::MediumType aType); 169 void updateSharedFoldersState(); 170 171 void onExitFullscreen(); 172 void unlockActionsSwitch(); 173 174 void mtExitMode(); 175 void mtCloseVM(); 176 void mtMaskUpdate(); 177 178 void changeDockIconUpdate (const VBoxChangeDockIconUpdateEvent &aEvent); 179 void processGlobalSettingChange (const char *aPublicName, const char *aName); 180 181 #ifdef VBOX_WITH_DEBUGGER_GUI 182 void dbgPrepareDebugMenu(); 183 void dbgShowStatistics(); 184 void dbgShowCommandLine(); 185 void dbgLoggingToggled (bool aBool); 186 #endif 164 187 165 188 private: … … 167 190 enum /* Stuff */ 168 191 { 169 FloppyStuff= 0x01,192 HardDiskStuff = 0x01, 170 193 DVDStuff = 0x02, 171 HardDiskStuff= 0x04,194 FloppyStuff = 0x04, 172 195 PauseAction = 0x08, 173 196 NetworkStuff = 0x10, … … 181 204 }; 182 205 183 void updateAppearanceOf (int element);184 185 bool toggleFullscreenMode (bool, bool);186 187 206 void checkRequiredFeatures(); 188 189 private slots:190 191 void finalizeOpenView();192 193 207 void activateUICustomizations(); 194 208 195 void vmFullscreen (bool on); 196 void vmSeamless (bool on); 197 void vmAutoresizeGuest (bool on); 198 void vmAdjustWindow(); 199 200 void vmTypeCAD(); 201 void vmTypeCABS(); 202 void vmReset(); 203 void vmPause(bool); 204 void vmACPIShutdown(); 205 void vmClose(); 206 void vmTakeSnapshot(); 207 void vmShowInfoDialog(); 208 void vmDisableMouseIntegr (bool); 209 210 void devicesMountFloppyImage(); 211 void devicesUnmountFloppy(); 212 void devicesMountDVDImage(); 213 void devicesUnmountDVD(); 214 void devicesSwitchVrdp (bool); 215 void devicesOpenNetworkDialog(); 216 void devicesOpenSFDialog(); 217 void devicesInstallGuestAdditions(); 218 219 void prepareFloppyMenu(); 220 void prepareDVDMenu(); 221 void prepareNetworkMenu(); 222 void prepareSFMenu(); 223 224 void captureFloppy (QAction *aAction); 225 void captureDVD (QAction *aAction); 226 void switchUSB (QAction *aAction); 227 228 void statusTipChanged (const QString &); 229 void clearStatusBar(); 230 231 void showIndicatorContextMenu (QIStateIndicator *ind, QContextMenuEvent *e); 232 233 void updateDeviceLights(); 234 void updateMachineState (KMachineState state); 235 void updateMouseState (int state); 236 void updateAdditionsState (const QString&, bool, bool, bool); 237 void updateNetworkAdaptersState(); 238 void updateUsbState(); 239 void updateMediaDriveState (VBoxDefs::MediumType aType); 240 void updateSharedFoldersState(); 241 242 void tryClose(); 243 244 void processGlobalSettingChange (const char *publicName, const char *name); 245 246 void dbgPrepareDebugMenu(); 247 void dbgShowStatistics(); 248 void dbgShowCommandLine(); 249 void dbgLoggingToggled(bool aBool); 250 251 void onExitFullscreen(); 252 void unlockActionsSwitch(); 253 209 void updateAppearanceOf (int aElement); 210 211 bool toggleFullscreenMode (bool aOn, bool aSeamless); 254 212 void switchToFullscreen (bool aOn, bool aSeamless); 255 213 void setViewInSeamlessMode (const QRect &aTargetRect); 256 214 257 void mtExitMode(); 258 void mtCloseVM(); 259 void mtMaskUpdate(); 260 261 private: 262 263 /** Popup version of the main menu */ 215 void closeView(); 216 217 #ifdef VBOX_WITH_DEBUGGER_GUI 218 bool dbgCreated(); 219 void dbgDestroy(); 220 void dbgAdjustRelativePos(); 221 #endif 222 223 /* COM Variables */ 224 CSession mSession; 225 226 /* Machine State */ 227 KMachineState mMachineState; 228 229 /* Window Variables */ 230 QString mCaptionPrefix; 231 int mConsoleStyle; 232 233 /* Menu items */ 264 234 QIMenu *mMainMenu; 235 QMenu *mVMMenu; 236 QMenu *mVMMenuMini; 237 QMenu *mDevicesMenu; 238 QMenu *mDevicesStorageMenu; 239 QMenu *mDevicesNetworkMenu; 240 QMenu *mDevicesSFMenu; 241 VBoxUSBMenu *mDevicesUSBMenu; 242 VBoxSwitchMenu *mVmDisMouseIntegrMenu; 243 #if 0 /* todo: allow to setup */ 244 VBoxSwitchMenu *mDevicesVRDPMenu; 245 VBoxSwitchMenu *mVmAutoresizeMenu; 246 #endif 247 #ifdef VBOX_WITH_DEBUGGER_GUI 248 QMenu *mDbgMenu; 249 #endif 250 QMenu *mHelpMenu; 265 251 266 252 QActionGroup *mRunningActions; … … 272 258 QAction *mVmAutoresizeGuestAction; 273 259 QAction *mVmAdjustWindowAction; 260 QAction *mVmDisableMouseIntegrAction; 274 261 QAction *mVmTypeCADAction; 275 #if defined(Q_WS_X11)262 #ifdef Q_WS_X11 276 263 QAction *mVmTypeCABSAction; 277 264 #endif 265 QAction *mVmTakeSnapshotAction; 266 QAction *mVmShowInformationDlgAction; 278 267 QAction *mVmResetAction; 279 268 QAction *mVmPauseAction; 280 269 QAction *mVmACPIShutdownAction; 281 270 QAction *mVmCloseAction; 282 QAction *mVmTakeSnapshotAction;283 QAction *mVmDisableMouseIntegrAction;284 QAction *mVmShowInformationDlgAction;285 271 286 272 /* Devices actions */ 287 QAction *mDevicesMountFloppyImageAction; 288 QAction *mDevicesUnmountFloppyAction; 289 QAction *mDevicesMountDVDImageAction; 290 QAction *mDevicesUnmountDVDAction; 291 QAction *mDevicesSwitchVrdpAction; 273 QAction *mDevicesStorageDialogAction; 292 274 QAction *mDevicesNetworkDialogAction; 293 275 QAction *mDevicesSFDialogAction; 276 QAction *mDevicesSwitchVrdpSeparator; 277 QAction *mDevicesSwitchVrdpAction; 294 278 QAction *mDevicesInstallGuestToolsAction; 295 279 … … 304 288 VBoxHelpActions mHelpActions; 305 289 306 /* Machine popup menus */ 307 VBoxSwitchMenu *mVmAutoresizeMenu; 308 VBoxSwitchMenu *mVmDisMouseIntegrMenu; 309 310 /* Devices popup menus */ 311 bool mWaitForStatusBarChange : 1; 312 bool mStatusBarChangedInside : 1; 313 314 QAction *mDevicesUSBMenuSeparator; 315 QAction *mDevicesVRDPMenuSeparator; 316 QAction *mDevicesSFMenuSeparator; 317 318 QMenu *mVMMenu; 319 QMenu *mMiniVMMenu; 320 QMenu *mDevicesMenu; 321 QMenu *mDevicesMountFloppyMenu; 322 QMenu *mDevicesMountDVDMenu; 323 QMenu *mDevicesSFMenu; 324 QMenu *mDevicesNetworkMenu; 325 VBoxUSBMenu *mDevicesUSBMenu; 326 /* VBoxSwitchMenu *mDevicesVRDPMenu; */ 327 #ifdef VBOX_WITH_DEBUGGER_GUI 328 // Debugger popup menu 329 QMenu *mDbgMenu; 330 #endif 331 QMenu *mHelpMenu; 332 290 /* Widgets */ 291 VBoxConsoleView *mConsole; 292 VBoxMiniToolBar *mMiniToolBar; 293 #ifdef VBOX_WITH_DEBUGGER_GUI 294 /** The handle to the debugger gui. */ 295 PDBGGUI mDbgGui; 296 /** The virtual method table for the debugger GUI. */ 297 PCDBGGUIVT mDbgGuiVT; 298 #endif 299 300 /* Timer to update LEDs */ 301 QTimer *mIdleTimer; 302 303 /* LEDs */ 304 QIStateIndicator *mHDLed; 305 QIStateIndicator *mCDLed; 306 #if 0 /* todo: allow to setup */ 307 QIStateIndicator *mFDLed; 308 #endif 309 QIStateIndicator *mNetLed; 310 QIStateIndicator *mUSBLed; 311 QIStateIndicator *mSFLed; 312 QIStateIndicator *mVirtLed; 313 QIStateIndicator *mMouseLed; 314 QIStateIndicator *mHostkeyLed; 315 QWidget *mHostkeyLedContainer; 316 QLabel *mHostkeyName; 317 #if 0 /* todo: allow to setup */ 318 QIStateIndicator *mVrdpLed; 319 QIStateIndicator *mAutoresizeLed; 320 #endif 321 322 /* Normal Mode */ 323 QRect mNormalGeo; 324 325 /* Fullscreen/Seamless Mode */ 326 QList < QPointer <QWidget> > mHiddenChildren; 333 327 QSpacerItem *mShiftingSpacerLeft; 334 328 QSpacerItem *mShiftingSpacerTop; 335 329 QSpacerItem *mShiftingSpacerRight; 336 330 QSpacerItem *mShiftingSpacerBottom; 331 QPalette mErasePalette; 332 QSize mPrevMinSize; 337 333 QSize mMaskShift; 338 339 CSession csession; 340 341 // widgets 342 VBoxConsoleView *console; 343 QIStateIndicator *hd_light, *cd_light, *fd_light, *net_light, *usb_light, *sf_light; 344 QIStateIndicator *mVirtLed; 345 QIStateIndicator *mouse_state, *hostkey_state; 346 QIStateIndicator *autoresize_state; 347 QIStateIndicator *vrdp_state; 348 QWidget *hostkey_hbox; 349 QLabel *hostkey_name; 350 351 QTimer *idle_timer; 352 KMachineState machine_state; 353 QString caption_prefix; 354 355 bool no_auto_close : 1; 356 357 QMap <QAction *, CMedium> hostDVDMap; 358 QMap <QAction *, CMedium> hostFloppyMap; 359 360 QRect mNormalGeo; 361 QSize prev_min_size; 362 334 QRegion mStrictedRegion; 363 335 #ifdef Q_WS_WIN 364 336 QRegion mPrevRegion; 365 337 #endif 366 367 338 #ifdef Q_WS_MAC 368 QRegion mCurrRegion;339 //QRegion mCurrRegion; 369 340 # ifndef QT_MAC_USE_COCOA 370 EventHandlerRef mDarwinRegionEventHandlerRef;341 //EventHandlerRef mDarwinRegionEventHandlerRef; 371 342 # endif 372 #endif 373 374 // variables for dealing with true fullscreen 375 QRegion mStrictedRegion; 343 /* For seamless maximizing */ 344 QRect mNormalGeometry; 345 Qt::WindowFlags mSavedFlags; 346 /* For the fade effect if the the window goes fullscreen */ 347 CGDisplayFadeReservationToken mFadeToken; 348 #endif 349 350 /* Different bool flags */ 351 bool mIsOpenViewFinished : 1; 352 bool mIsFirstTimeStarted : 1; 353 bool mIsAutoSaveMedia : 1; 354 bool mNoAutoClose : 1; 376 355 bool mIsFullscreen : 1; 377 356 bool mIsSeamless : 1; … … 379 358 bool mIsGraphicsSupported : 1; 380 359 bool mIsWaitingModeResize : 1; 381 bool was_max : 1; 382 QList < QPointer <QWidget> > mHiddenChildren; 383 int console_style; 384 QPalette mErasePalette; 385 386 bool mIsOpenViewFinished : 1; 387 bool mIsFirstTimeStarted : 1; 388 bool mIsAutoSaveMedia : 1; 389 390 #ifdef VBOX_WITH_DEBUGGER_GUI 391 /** The handle to the debugger gui. */ 392 PDBGGUI mDbgGui; 393 /** The virtual method table for the debugger GUI. */ 394 PCDBGGUIVT mDbgGuiVT; 395 #endif 396 397 #ifdef Q_WS_MAC 398 /* For seamless maximizing */ 399 QRect mNormalGeometry; 400 Qt::WindowFlags mSavedFlags; 401 /* For the fade effect if the the window goes fullscreen */ 402 CGDisplayFadeReservationToken mFadeToken; 403 #endif 404 405 VBoxMiniToolBar *mMiniToolBar; 360 bool mWasMax : 1; 406 361 }; 407 362 363 /* We want to make the first action highlighted but not 364 * selected, but Qt makes the both or neither one of this, 365 * so, just move the focus to the next eligible object, 366 * which will be the first menu action. This little 367 * subclass made only for that purpose. */ 368 class QIMenu : public QMenu 369 { 370 Q_OBJECT; 371 372 public: 373 374 QIMenu (QWidget *aParent) : QMenu (aParent) {} 375 376 void selectFirstAction() { QMenu::focusNextChild(); } 377 }; 378 408 379 class VBoxSettingsPage; 380 class VBoxStorageDialog : public QIWithRetranslateUI <QDialog> 381 { 382 Q_OBJECT; 383 384 public: 385 386 VBoxStorageDialog (QWidget *aParent, CSession &aSession); 387 388 protected: 389 390 void retranslateUi(); 391 392 protected slots: 393 394 virtual void accept(); 395 396 protected: 397 398 void showEvent (QShowEvent *aEvent); 399 400 private: 401 402 VBoxSettingsPage *mSettings; 403 CSession &mSession; 404 }; 405 409 406 class VBoxNetworkDialog : public QIWithRetranslateUI <QDialog> 410 407 { -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxVMSettingsHD.h
r23580 r23723 504 504 public: 505 505 506 StorageDelegate (QObject *aParent );506 StorageDelegate (QObject *aParent, bool aDisableStaticControls); 507 507 508 508 private: 509 509 510 510 void paint (QPainter *aPainter, const QStyleOptionViewItem &aOption, const QModelIndex &aIndex) const; 511 512 bool mDisableStaticControls; 511 513 }; 512 514 … … 522 524 public: 523 525 524 VBoxVMSettingsHD ();526 VBoxVMSettingsHD (bool aDisableStaticControls = false); 525 527 526 528 signals: … … 608 610 bool mIsLoadingInProgress; 609 611 bool mIsPolished; 612 bool mDisableStaticControls; 610 613 }; 611 614 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r23562 r23723 21 21 */ 22 22 23 /* VBox includes */ 23 /* Global includes */ 24 #include <QActionGroup> 25 #include <QDesktopWidget> 26 #include <QDir> 27 #include <QFileInfo> 28 #include <QMenuBar> 29 #include <QProgressBar> 30 #include <QTimer> 31 32 #ifdef Q_WS_X11 33 # include <QX11Info> 34 #endif 35 #ifdef Q_WS_MAC 36 # include <QPainter> 37 #endif 38 39 /* Local includes */ 40 #include "QIFileDialog.h" 41 #include "QIHotKeyEdit.h" 42 #include "QIHttp.h" 43 #include "QIStateIndicator.h" 44 #include "QIStatusBar.h" 24 45 #include "VBoxConsoleWnd.h" 25 46 #include "VBoxConsoleView.h" … … 32 53 #include "VBoxTakeSnapshotDlg.h" 33 54 #include "VBoxVMFirstRunWzd.h" 55 #include "VBoxVMSettingsHD.h" 34 56 #include "VBoxVMSettingsNetwork.h" 35 57 #include "VBoxVMSettingsSF.h" 36 58 #include "VBoxVMInformationDlg.h" 37 #include "QIFileDialog.h" 38 #include "QIHotKeyEdit.h" 39 #include "QIHttp.h" 40 #include "QIStateIndicator.h" 41 #include "QIStatusBar.h" 42 43 /* Qt includes */ 44 #include <QActionGroup> 45 #include <QDesktopWidget> 46 #include <QDir> 47 #include <QFileInfo> 48 #include <QMenuBar> 49 #include <QProgressBar> 50 #include <QTimer> 59 51 60 #ifdef Q_WS_X11 52 # include <QX11Info> 53 #endif 54 55 #include <VBox/VMMDev.h> /** @todo @bugref{4084} */ 56 57 #if defined(Q_WS_X11) 58 #include <X11/Xlib.h> 59 #include <XKeyboard.h> 60 #endif 61 61 # include <X11/Xlib.h> 62 # include <XKeyboard.h> 63 #endif 62 64 #ifdef Q_WS_MAC 63 65 # include "VBoxUtils.h" 64 66 # include "VBoxIChatTheaterWrapper.h" 65 67 # include <ApplicationServices/ApplicationServices.h> 66 /* Qt includes */ 67 # include <QPainter> 68 #endif 69 68 #endif 70 69 #ifdef VBOX_WITH_DEBUGGER_GUI 71 70 # include <VBox/err.h> … … 73 72 #endif 74 73 74 #include <VBox/VMMDev.h> /** @todo @bugref{4084} */ 75 75 #include <iprt/buildconfig.h> 76 76 #include <iprt/param.h> 77 77 #include <iprt/path.h> 78 79 /* Global forwards */ 80 extern void qt_set_sequence_auto_mnemonic (bool on); 78 81 79 82 /** class StatusTipEvent … … 94 97 QString mTip; 95 98 }; 96 97 #ifdef RT_OS_DARWIN98 class Q3Http;99 class Q3HttpResponseHeader;100 #endif101 99 102 100 class VBoxAdditionsDownloader : public VBoxDownloaderWgt … … 215 213 * recursion in VBoxGlobal::consoleWnd()) 216 214 */ 217 VBoxConsoleWnd:: 218 VBoxConsoleWnd (VBoxConsoleWnd **aSelf, QWidget* aParent, 219 Qt::WindowFlags aFlags /* = Qt::Window */) 220 : QIWithRetranslateUI2<QMainWindow> (aParent, aFlags) 215 VBoxConsoleWnd::VBoxConsoleWnd (VBoxConsoleWnd **aSelf, QWidget* aParent, Qt::WindowFlags aFlags /* = Qt::Window */) 216 : QIWithRetranslateUI2 <QMainWindow> (aParent, aFlags) 217 /* Machine State */ 218 , mMachineState (KMachineState_Null) 219 /* Window Variables */ 220 , mConsoleStyle (0) 221 /* Menu Items */ 221 222 , mMainMenu (0) 223 , mVMMenu (0) 224 , mVMMenuMini (0) 225 , mDevicesMenu (0) 226 , mDevicesStorageMenu (0) 227 , mDevicesNetworkMenu (0) 228 , mDevicesSFMenu (0) 229 , mDevicesUSBMenu (0) 230 , mVmDisMouseIntegrMenu (0) 231 #if 0 /* TODO: Allow to setup status-bar! */ 232 , mDevicesVRDPMenu (0) 233 , mVmAutoresizeMenu (0) 234 #endif 222 235 #ifdef VBOX_WITH_DEBUGGER_GUI 223 , mDbgStatisticsAction (NULL) 224 , mDbgCommandLineAction (NULL) 225 , mDbgLoggingAction (NULL) 226 , mDbgMenu (NULL) 227 #endif 228 , console (0) 229 , machine_state (KMachineState_Null) 230 , no_auto_close (false) 236 , mDbgMenu (0) 237 #endif 238 , mHelpMenu (0) 239 /* Action Groups */ 240 , mRunningActions (0) 241 , mRunningOrPausedActions (0) 242 /* Machine Menu Actions */ 243 , mVmFullscreenAction (0) 244 , mVmSeamlessAction (0) 245 , mVmAutoresizeGuestAction (0) 246 , mVmAdjustWindowAction (0) 247 , mVmDisableMouseIntegrAction (0) 248 , mVmTypeCADAction (0) 249 #ifdef Q_WS_X11 250 , mVmTypeCABSAction (0) 251 #endif 252 , mVmTakeSnapshotAction (0) 253 , mVmShowInformationDlgAction (0) 254 , mVmResetAction (0) 255 , mVmPauseAction (0) 256 , mVmACPIShutdownAction (0) 257 , mVmCloseAction (0) 258 /* Device Menu Actions */ 259 , mDevicesStorageDialogAction (0) 260 , mDevicesNetworkDialogAction (0) 261 , mDevicesSFDialogAction (0) 262 , mDevicesSwitchVrdpSeparator (0) 263 , mDevicesSwitchVrdpAction (0) 264 , mDevicesInstallGuestToolsAction (0) 265 #ifdef VBOX_WITH_DEBUGGER_GUI 266 /* Debug Menu Actions */ 267 , mDbgStatisticsAction (0) 268 , mDbgCommandLineAction (0) 269 , mDbgLoggingAction (0) 270 #endif 271 /* Widgets */ 272 , mConsole (0) 273 , mMiniToolBar (0) 274 #ifdef VBOX_WITH_DEBUGGER_GUI 275 , mDbgGui (0) 276 , mDbgGuiVT (0) 277 #endif 278 /* LED Update Timer */ 279 , mIdleTimer (new QTimer (this)) 280 /* LEDs */ 281 , mHDLed (0) 282 , mCDLed (0) 283 #if 0 /* TODO: Allow to setup status-bar! */ 284 , mFDLed (0) 285 #endif 286 , mNetLed (0) 287 , mUSBLed (0) 288 , mSFLed (0) 289 , mVirtLed (0) 290 , mMouseLed (0) 291 , mHostkeyLed (0) 292 , mHostkeyLedContainer (0) 293 , mHostkeyName (0) 294 #if 0 /* TODO: Allow to setup status-bar! */ 295 , mVrdpLed (0) 296 , mAutoresizeLed (0) 297 #endif 298 , mIsOpenViewFinished (false) 299 , mIsFirstTimeStarted (false) 300 , mIsAutoSaveMedia (true) 301 , mNoAutoClose (false) 231 302 , mIsFullscreen (false) 232 303 , mIsSeamless (false) … … 234 305 , mIsGraphicsSupported (false) 235 306 , mIsWaitingModeResize (false) 236 , was_max (false) 237 , console_style (0) 238 , mIsOpenViewFinished (false) 239 , mIsFirstTimeStarted (false) 240 , mIsAutoSaveMedia (true) 241 #ifdef VBOX_WITH_DEBUGGER_GUI 242 , mDbgGui (NULL) 243 , mDbgGuiVT (NULL) 244 #endif 307 , mWasMax (false) 245 308 { 246 309 if (aSelf) 247 310 *aSelf = this; 248 311 249 idle_timer = new QTimer (this); 312 /* Enumerate mediums to work with cached data */ 313 vboxGlobal().startEnumeratingMedia(); 250 314 251 315 #if !(defined (Q_WS_WIN) || defined (Q_WS_MAC)) … … 256 320 #endif 257 321 258 /* ensure status bar is created */322 /* Ensure status bar is created */ 259 323 setStatusBar (new QIStatusBar (this)); 260 324 261 ///// Actions /////////////////////////////////////////////////////////// 262 263 /* a group for all actions that are enabled only when the VM is running. 325 /* A group for all actions that are enabled only when the VM is running. 264 326 * Note that only actions whose enabled state depends exclusively on the 265 327 * execution state of the VM are added to this group. */ … … 267 329 mRunningActions->setExclusive (false); 268 330 269 /* agroup for all actions that are enabled when the VM is running or331 /* A group for all actions that are enabled when the VM is running or 270 332 * paused. Note that only actions whose enabled state depends exclusively 271 333 * on the execution state of the VM are added to this group. */ … … 274 336 275 337 /* VM menu actions */ 276 277 338 mVmFullscreenAction = new QAction (this); 278 mVmFullscreenAction->setIcon ( 279 VBoxGlobal::iconSetOnOff ( 280 ":/fullscreen_on_16px.png", ":/fullscreen_16px.png", 281 ":/fullscreen_on_disabled_16px.png", ":/fullscreen_disabled_16px.png")); 339 mVmFullscreenAction->setIcon (VBoxGlobal::iconSetOnOff ( 340 ":/fullscreen_on_16px.png", ":/fullscreen_16px.png", 341 ":/fullscreen_on_disabled_16px.png", ":/fullscreen_disabled_16px.png")); 282 342 mVmFullscreenAction->setCheckable (true); 283 343 284 344 mVmSeamlessAction = new QAction (this); 285 mVmSeamlessAction->setIcon ( 286 VBoxGlobal::iconSetOnOff ( 287 ":/seamless_on_16px.png", ":/seamless_16px.png", 288 ":/seamless_on_disabled_16px.png", ":/seamless_disabled_16px.png")); 345 mVmSeamlessAction->setIcon (VBoxGlobal::iconSetOnOff ( 346 ":/seamless_on_16px.png", ":/seamless_16px.png", 347 ":/seamless_on_disabled_16px.png", ":/seamless_disabled_16px.png")); 289 348 mVmSeamlessAction->setCheckable (true); 290 349 291 350 mVmAutoresizeGuestAction = new QAction (mRunningActions); 292 mVmAutoresizeGuestAction->setIcon ( 293 VBoxGlobal::iconSetOnOff ( 294 ":/auto_resize_on_on_16px.png", ":/auto_resize_on_16px.png", 295 ":/auto_resize_on_on_disabled_16px.png", ":/auto_resize_on_disabled_16px.png")); 351 mVmAutoresizeGuestAction->setIcon (VBoxGlobal::iconSetOnOff ( 352 ":/auto_resize_on_on_16px.png", ":/auto_resize_on_16px.png", 353 ":/auto_resize_on_on_disabled_16px.png", ":/auto_resize_on_disabled_16px.png")); 296 354 mVmAutoresizeGuestAction->setCheckable (true); 297 355 mVmAutoresizeGuestAction->setEnabled (false); 298 356 299 357 mVmAdjustWindowAction = new QAction (this); 300 mVmAdjustWindowAction->setIcon ( 301 VBoxGlobal::iconSet (":/adjust_win_size_16px.png", 302 ":/adjust_win_size_disabled_16px.png")); 358 mVmAdjustWindowAction->setIcon (VBoxGlobal::iconSet ( 359 ":/adjust_win_size_16px.png", ":/adjust_win_size_disabled_16px.png")); 360 361 mVmDisableMouseIntegrAction = new QAction (this); 362 mVmDisableMouseIntegrAction->setIcon (VBoxGlobal::iconSetOnOff ( 363 ":/mouse_can_seamless_on_16px.png", ":/mouse_can_seamless_16px.png", 364 ":/mouse_can_seamless_on_disabled_16px.png", ":/mouse_can_seamless_disabled_16px.png")); 365 mVmDisableMouseIntegrAction->setCheckable (true); 303 366 304 367 mVmTypeCADAction = new QAction (mRunningActions); 305 mVmTypeCADAction->setIcon (VBoxGlobal::iconSet ( ":/hostkey_16px.png",306 368 mVmTypeCADAction->setIcon (VBoxGlobal::iconSet ( 369 ":/hostkey_16px.png", ":/hostkey_disabled_16px.png")); 307 370 308 371 #if defined(Q_WS_X11) 309 372 mVmTypeCABSAction = new QAction (mRunningActions); 310 mVmTypeCABSAction->setIcon (VBoxGlobal::iconSet (":/hostkey_16px.png", 311 ":/hostkey_disabled_16px.png")); 312 #endif 373 mVmTypeCABSAction->setIcon (VBoxGlobal::iconSet ( 374 ":/hostkey_16px.png", ":/hostkey_disabled_16px.png")); 375 #endif 376 377 mVmTakeSnapshotAction = new QAction (mRunningOrPausedActions); 378 mVmTakeSnapshotAction->setIcon (VBoxGlobal::iconSet ( 379 ":/take_snapshot_16px.png", ":/take_snapshot_dis_16px.png")); 380 381 mVmShowInformationDlgAction = new QAction (this); 382 mVmShowInformationDlgAction->setIcon (VBoxGlobal::iconSet ( 383 ":/session_info_16px.png", ":/session_info_disabled_16px.png")); 313 384 314 385 mVmResetAction = new QAction (mRunningActions); 315 mVmResetAction->setIcon (VBoxGlobal::iconSet ( ":/reset_16px.png",316 386 mVmResetAction->setIcon (VBoxGlobal::iconSet ( 387 ":/reset_16px.png", ":/reset_disabled_16px.png")); 317 388 318 389 mVmPauseAction = new QAction (this); 319 mVmPauseAction->setIcon ( 320 /* checkbox over the pause icon doesn't look nice */ 321 #if 0 322 VBoxGlobal::iconSetOnOff ( 323 ":/pause_on_16px.png", ":/pause_16px.png", 324 ":/pause_on_disabled_16px.png", ":/pause_disabled_16px.png")); 325 #else 326 VBoxGlobal::iconSet (":/pause_16px.png", ":/pause_disabled_16px.png")); 327 #endif 390 mVmPauseAction->setIcon (VBoxGlobal::iconSet ( 391 ":/pause_16px.png", ":/pause_disabled_16px.png")); 328 392 mVmPauseAction->setCheckable (true); 329 393 330 394 mVmACPIShutdownAction = new QAction (mRunningActions); 331 mVmACPIShutdownAction->setIcon ( 332 VBoxGlobal::iconSet (":/acpi_16px.png", ":/acpi_disabled_16px.png"));395 mVmACPIShutdownAction->setIcon (VBoxGlobal::iconSet ( 396 ":/acpi_16px.png", ":/acpi_disabled_16px.png")); 333 397 334 398 mVmCloseAction = new QAction (this); … … 336 400 mVmCloseAction->setIcon (VBoxGlobal::iconSet (":/exit_16px.png")); 337 401 338 mVmTakeSnapshotAction = new QAction (mRunningOrPausedActions);339 mVmTakeSnapshotAction->setIcon (VBoxGlobal::iconSet (340 ":/take_snapshot_16px.png", ":/take_snapshot_dis_16px.png"));341 342 mVmShowInformationDlgAction = new QAction (this);343 mVmShowInformationDlgAction->setIcon (VBoxGlobal::iconSet (344 ":/session_info_16px.png", ":/session_info_disabled_16px.png"));345 346 mVmDisableMouseIntegrAction = new QAction (this);347 mVmDisableMouseIntegrAction->setIcon (348 VBoxGlobal::iconSetOnOff (349 ":/mouse_can_seamless_on_16px.png", ":/mouse_can_seamless_16px.png",350 ":/mouse_can_seamless_on_disabled_16px.png", ":/mouse_can_seamless_disabled_16px.png"));351 mVmDisableMouseIntegrAction->setCheckable (true);352 353 402 /* Devices menu actions */ 354 355 mDevicesMountFloppyImageAction = new QAction (mRunningOrPausedActions); 356 357 mDevicesUnmountFloppyAction = new QAction (this); 358 mDevicesUnmountFloppyAction->setIcon ( 359 VBoxGlobal::iconSet (":/fd_unmount_16px.png", 360 ":/fd_unmount_dis_16px.png")); 361 362 mDevicesMountDVDImageAction = new QAction (mRunningOrPausedActions); 363 364 mDevicesUnmountDVDAction = new QAction (this); 365 mDevicesUnmountDVDAction->setIcon ( 366 VBoxGlobal::iconSet (":/cd_unmount_16px.png", 367 ":/cd_unmount_dis_16px.png")); 403 mDevicesStorageDialogAction = new QAction (mRunningOrPausedActions); 404 mDevicesStorageDialogAction->setIcon (VBoxGlobal::iconSet ( 405 ":/attachment_16px.png", ":/attachment_disabled_16px.png")); 368 406 369 407 mDevicesNetworkDialogAction = new QAction (mRunningOrPausedActions); 370 mDevicesNetworkDialogAction->setIcon ( 371 VBoxGlobal::iconSet (":/nw_16px.png", 372 ":/nw_disabled_16px.png")); 408 mDevicesNetworkDialogAction->setIcon (VBoxGlobal::iconSet ( 409 ":/nw_16px.png", ":/nw_disabled_16px.png")); 373 410 374 411 mDevicesSFDialogAction = new QAction (mRunningOrPausedActions); 375 mDevicesSFDialogAction->setIcon ( 376 VBoxGlobal::iconSet (":/shared_folder_16px.png", 377 ":/shared_folder_disabled_16px.png")); 412 mDevicesSFDialogAction->setIcon (VBoxGlobal::iconSet ( 413 ":/shared_folder_16px.png", ":/shared_folder_disabled_16px.png")); 378 414 379 415 mDevicesSwitchVrdpAction = new QAction (mRunningOrPausedActions); 380 mDevicesSwitchVrdpAction->setIcon ( 381 VBoxGlobal::iconSetOnOff ( 382 ":/vrdp_on_16px.png", ":/vrdp_16px.png", 383 ":/vrdp_on_disabled_16px.png", ":/vrdp_disabled_16px.png")); 416 mDevicesSwitchVrdpAction->setIcon (VBoxGlobal::iconSetOnOff ( 417 ":/vrdp_on_16px.png", ":/vrdp_16px.png", 418 ":/vrdp_on_disabled_16px.png", ":/vrdp_disabled_16px.png")); 384 419 mDevicesSwitchVrdpAction->setCheckable (true); 385 420 386 421 mDevicesInstallGuestToolsAction = new QAction (mRunningActions); 387 mDevicesInstallGuestToolsAction->setIcon ( 388 VBoxGlobal::iconSet (":/guesttools_16px.png", 389 ":/guesttools_disabled_16px.png")); 422 mDevicesInstallGuestToolsAction->setIcon (VBoxGlobal::iconSet ( 423 ":/guesttools_16px.png", ":/guesttools_disabled_16px.png")); 390 424 391 425 #ifdef VBOX_WITH_DEBUGGER_GUI 426 /* Debug menu actions */ 392 427 if (vboxGlobal().isDebuggerEnabled()) 393 428 { … … 404 439 else 405 440 { 406 mDbgStatisticsAction = NULL;407 mDbgCommandLineAction = NULL;408 mDbgLoggingAction = NULL;441 mDbgStatisticsAction = 0; 442 mDbgCommandLineAction = 0; 443 mDbgLoggingAction = 0; 409 444 } 410 445 #endif 411 446 412 447 /* Help menu actions */ 413 414 448 mHelpActions.setup (this); 415 449 416 ///// Menubar /////////////////////////////////////////////////////////// 417 450 /* Menu Items */ 418 451 mMainMenu = new QIMenu (this); 419 mDevicesNetworkMenu = new QMenu(this); 420 mDevicesSFMenu = new QMenu(this); 452 mDevicesStorageMenu = new QMenu (this); 453 mDevicesNetworkMenu = new QMenu (this); 454 mDevicesSFMenu = new QMenu (this); 421 455 422 456 /* Machine submenu */ 423 424 457 mVMMenu = menuBar()->addMenu (QString::null); 425 458 mMainMenu->addMenu (mVMMenu); 426 427 /* dynamic & status line popup menus*/459 mVmDisMouseIntegrMenu = new VBoxSwitchMenu (mVMMenu, mVmDisableMouseIntegrAction, true); 460 #if 0 /* TODO: Allow to setup status-bar! */ 428 461 mVmAutoresizeMenu = new VBoxSwitchMenu (mVMMenu, mVmAutoresizeGuestAction); 429 mVmDisMouseIntegrMenu = new VBoxSwitchMenu (mVMMenu, mVmDisableMouseIntegrAction, 430 true /* inverted toggle state */); 462 #endif 431 463 432 464 mVMMenu->addAction (mVmFullscreenAction); … … 438 470 mVMMenu->addSeparator(); 439 471 mVMMenu->addAction (mVmTypeCADAction); 440 #if defined(Q_WS_X11)472 #ifdef Q_WS_X11 441 473 mVMMenu->addAction (mVmTypeCABSAction); 442 474 #endif … … 455 487 456 488 /* Devices submenu */ 457 458 489 mDevicesMenu = menuBar()->addMenu (QString::null); 459 490 mMainMenu->addMenu (mDevicesMenu); 460 491 461 /* dynamic & statusline popup menus */ 462 463 mDevicesMountDVDMenu = mDevicesMenu->addMenu (VBoxGlobal::iconSet (":/cd_16px.png", ":/cd_disabled_16px.png"), QString::null); 464 mDevicesMenu->addAction (mDevicesUnmountDVDAction); 492 mDevicesUSBMenu = new VBoxUSBMenu (mDevicesMenu); 493 mDevicesUSBMenu->setIcon (VBoxGlobal::iconSet ( 494 ":/usb_16px.png", ":/usb_disabled_16px.png")); 495 496 mDevicesMenu->addAction (mDevicesStorageDialogAction); 497 mDevicesMenu->addAction (mDevicesNetworkDialogAction); 498 mDevicesMenu->addAction (mDevicesSFDialogAction); 499 mDevicesMenu->addMenu (mDevicesUSBMenu); 500 501 #if 0 /* TODO: Allow to setup status-bar! */ 502 mDevicesVRDPMenu = new VBoxSwitchMenu (mDevicesMenu, mDevicesSwitchVrdpAction); 503 #endif 504 mDevicesSwitchVrdpSeparator = mDevicesMenu->addSeparator(); 505 mDevicesMenu->addAction (mDevicesSwitchVrdpAction); 506 465 507 mDevicesMenu->addSeparator(); 466 467 mDevicesMountFloppyMenu = mDevicesMenu->addMenu (VBoxGlobal::iconSet (":/fd_16px.png", ":/fd_disabled_16px.png"), QString::null);468 mDevicesMenu->addAction (mDevicesUnmountFloppyAction);469 mDevicesMenu->addSeparator();470 471 mDevicesMenu->addAction (mDevicesNetworkDialogAction);472 mDevicesMenu->addSeparator();473 474 mDevicesUSBMenu = new VBoxUSBMenu (mDevicesMenu);475 mDevicesMenu->addMenu (mDevicesUSBMenu);476 mDevicesUSBMenu->setIcon (VBoxGlobal::iconSet (":/usb_16px.png", ":/usb_disabled_16px.png"));477 mDevicesUSBMenuSeparator = mDevicesMenu->addSeparator();478 479 mDevicesMenu->addAction (mDevicesSFDialogAction);480 mDevicesSFMenuSeparator = mDevicesMenu->addSeparator();481 482 /* Currently not needed cause there is no state icon in the statusbar */483 /* mDevicesVRDPMenu = new VBoxSwitchMenu (mDevicesMenu, mDevicesSwitchVrdpAction); */484 mDevicesMenu->addAction (mDevicesSwitchVrdpAction);485 mDevicesVRDPMenuSeparator = mDevicesMenu->addSeparator();486 487 508 mDevicesMenu->addAction (mDevicesInstallGuestToolsAction); 488 509 489 /* reset the "context menu" flag */ 490 mDevicesMountFloppyMenu->menuAction()->setData (false); 491 mDevicesMountDVDMenu->menuAction()->setData (false); 510 /* Reset the "context menu" flag */ 492 511 mDevicesUSBMenu->menuAction()->setData (false); 493 512 494 513 #ifdef VBOX_WITH_DEBUGGER_GUI 495 /* Debug popupmenu */514 /* Debug submenu */ 496 515 if (vboxGlobal().isDebuggerEnabled()) 497 516 { … … 503 522 } 504 523 else 505 mDbgMenu = NULL;524 mDbgMenu = 0; 506 525 #endif 507 526 508 527 /* Help submenu */ 509 510 528 mHelpMenu = menuBar()->addMenu (QString::null); 511 529 mMainMenu->addMenu (mHelpMenu); 512 513 530 mHelpActions.addTo (mHelpMenu); 514 531 515 /* Machine submenu for mini 516 m MiniVMMenu= new QMenu (this);517 m MiniVMMenu->addAction (mVmTypeCADAction);532 /* Machine submenu for mini-toolbar */ 533 mVMMenuMini = new QMenu (this); 534 mVMMenuMini->addAction (mVmTypeCADAction); 518 535 #ifdef Q_WS_X11 519 mMiniVMMenu->addAction (mVmTypeCABSAction); 520 #endif 521 mMiniVMMenu->addSeparator(); 522 mMiniVMMenu->addAction (mVmTakeSnapshotAction); 523 mMiniVMMenu->addSeparator(); 524 mMiniVMMenu->addAction (mVmShowInformationDlgAction); 525 mMiniVMMenu->addSeparator(); 526 mMiniVMMenu->addAction (mVmResetAction); 527 mMiniVMMenu->addAction (mVmPauseAction); 528 mMiniVMMenu->addAction (mVmACPIShutdownAction); 529 530 ///// Status bar //////////////////////////////////////////////////////// 531 532 QWidget *indicatorBox = new QWidget (); 536 mVMMenuMini->addAction (mVmTypeCABSAction); 537 #endif 538 mVMMenuMini->addSeparator(); 539 mVMMenuMini->addAction (mVmTakeSnapshotAction); 540 mVMMenuMini->addSeparator(); 541 mVMMenuMini->addAction (mVmShowInformationDlgAction); 542 mVMMenuMini->addSeparator(); 543 mVMMenuMini->addAction (mVmResetAction); 544 mVMMenuMini->addAction (mVmPauseAction); 545 mVMMenuMini->addAction (mVmACPIShutdownAction); 546 547 /* Status bar */ 548 QWidget *indicatorBox = new QWidget; 533 549 QHBoxLayout *indicatorBoxHLayout = new QHBoxLayout (indicatorBox); 534 550 VBoxGlobal::setLayoutMargin (indicatorBoxHLayout, 0); 535 551 indicatorBoxHLayout->setSpacing (5); 552 536 553 /* i/o devices */ 537 hd_light = new QIStateIndicator (KDeviceActivity_Idle); 538 hd_light->setStateIcon (KDeviceActivity_Idle, QPixmap (":/hd_16px.png")); 539 hd_light->setStateIcon (KDeviceActivity_Reading, QPixmap (":/hd_read_16px.png")); 540 hd_light->setStateIcon (KDeviceActivity_Writing, QPixmap (":/hd_write_16px.png")); 541 hd_light->setStateIcon (KDeviceActivity_Null, QPixmap (":/hd_disabled_16px.png")); 542 indicatorBoxHLayout->addWidget (hd_light); 543 cd_light = new QIStateIndicator (KDeviceActivity_Idle); 544 cd_light->setStateIcon (KDeviceActivity_Idle, QPixmap (":/cd_16px.png")); 545 cd_light->setStateIcon (KDeviceActivity_Reading, QPixmap (":/cd_read_16px.png")); 546 cd_light->setStateIcon (KDeviceActivity_Writing, QPixmap (":/cd_write_16px.png")); 547 cd_light->setStateIcon (KDeviceActivity_Null, QPixmap (":/cd_disabled_16px.png")); 548 indicatorBoxHLayout->addWidget (cd_light); 549 fd_light = new QIStateIndicator (KDeviceActivity_Idle); 550 fd_light->setStateIcon (KDeviceActivity_Idle, QPixmap (":/fd_16px.png")); 551 fd_light->setStateIcon (KDeviceActivity_Reading, QPixmap (":/fd_read_16px.png")); 552 fd_light->setStateIcon (KDeviceActivity_Writing, QPixmap (":/fd_write_16px.png")); 553 fd_light->setStateIcon (KDeviceActivity_Null, QPixmap (":/fd_disabled_16px.png")); 554 fd_light->hide(); /* This LED hidden due to little importance (defect #3630) */ 555 indicatorBoxHLayout->addWidget (fd_light); 556 net_light = new QIStateIndicator (KDeviceActivity_Idle); 557 net_light->setStateIcon (KDeviceActivity_Idle, QPixmap (":/nw_16px.png")); 558 net_light->setStateIcon (KDeviceActivity_Reading, QPixmap (":/nw_read_16px.png")); 559 net_light->setStateIcon (KDeviceActivity_Writing, QPixmap (":/nw_write_16px.png")); 560 net_light->setStateIcon (KDeviceActivity_Null, QPixmap (":/nw_disabled_16px.png")); 561 indicatorBoxHLayout->addWidget (net_light); 562 usb_light = new QIStateIndicator (KDeviceActivity_Idle); 563 usb_light->setStateIcon (KDeviceActivity_Idle, QPixmap (":/usb_16px.png")); 564 usb_light->setStateIcon (KDeviceActivity_Reading, QPixmap (":/usb_read_16px.png")); 565 usb_light->setStateIcon (KDeviceActivity_Writing, QPixmap (":/usb_write_16px.png")); 566 usb_light->setStateIcon (KDeviceActivity_Null, QPixmap (":/usb_disabled_16px.png")); 567 indicatorBoxHLayout->addWidget (usb_light); 568 sf_light = new QIStateIndicator (KDeviceActivity_Idle); 569 sf_light->setStateIcon (KDeviceActivity_Idle, QPixmap (":/shared_folder_16px.png")); 570 sf_light->setStateIcon (KDeviceActivity_Reading, QPixmap (":/shared_folder_read_16px.png")); 571 sf_light->setStateIcon (KDeviceActivity_Writing, QPixmap (":/shared_folder_write_16px.png")); 572 sf_light->setStateIcon (KDeviceActivity_Null, QPixmap (":/shared_folder_disabled_16px.png")); 573 indicatorBoxHLayout->addWidget (sf_light); 554 mHDLed = new QIStateIndicator (KDeviceActivity_Idle); 555 mHDLed->setStateIcon (KDeviceActivity_Idle, QPixmap (":/hd_16px.png")); 556 mHDLed->setStateIcon (KDeviceActivity_Reading, QPixmap (":/hd_read_16px.png")); 557 mHDLed->setStateIcon (KDeviceActivity_Writing, QPixmap (":/hd_write_16px.png")); 558 mHDLed->setStateIcon (KDeviceActivity_Null, QPixmap (":/hd_disabled_16px.png")); 559 indicatorBoxHLayout->addWidget (mHDLed); 560 mCDLed = new QIStateIndicator (KDeviceActivity_Idle); 561 mCDLed->setStateIcon (KDeviceActivity_Idle, QPixmap (":/cd_16px.png")); 562 mCDLed->setStateIcon (KDeviceActivity_Reading, QPixmap (":/cd_read_16px.png")); 563 mCDLed->setStateIcon (KDeviceActivity_Writing, QPixmap (":/cd_write_16px.png")); 564 mCDLed->setStateIcon (KDeviceActivity_Null, QPixmap (":/cd_disabled_16px.png")); 565 indicatorBoxHLayout->addWidget (mCDLed); 566 #if 0 /* TODO: Allow to setup status-bar! */ 567 mFDLed = new QIStateIndicator (KDeviceActivity_Idle); 568 mFDLed->setStateIcon (KDeviceActivity_Idle, QPixmap (":/fd_16px.png")); 569 mFDLed->setStateIcon (KDeviceActivity_Reading, QPixmap (":/fd_read_16px.png")); 570 mFDLed->setStateIcon (KDeviceActivity_Writing, QPixmap (":/fd_write_16px.png")); 571 mFDLed->setStateIcon (KDeviceActivity_Null, QPixmap (":/fd_disabled_16px.png")); 572 indicatorBoxHLayout->addWidget (mFDLed); 573 #endif 574 mNetLed = new QIStateIndicator (KDeviceActivity_Idle); 575 mNetLed->setStateIcon (KDeviceActivity_Idle, QPixmap (":/nw_16px.png")); 576 mNetLed->setStateIcon (KDeviceActivity_Reading, QPixmap (":/nw_read_16px.png")); 577 mNetLed->setStateIcon (KDeviceActivity_Writing, QPixmap (":/nw_write_16px.png")); 578 mNetLed->setStateIcon (KDeviceActivity_Null, QPixmap (":/nw_disabled_16px.png")); 579 indicatorBoxHLayout->addWidget (mNetLed); 580 mUSBLed = new QIStateIndicator (KDeviceActivity_Idle); 581 mUSBLed->setStateIcon (KDeviceActivity_Idle, QPixmap (":/usb_16px.png")); 582 mUSBLed->setStateIcon (KDeviceActivity_Reading, QPixmap (":/usb_read_16px.png")); 583 mUSBLed->setStateIcon (KDeviceActivity_Writing, QPixmap (":/usb_write_16px.png")); 584 mUSBLed->setStateIcon (KDeviceActivity_Null, QPixmap (":/usb_disabled_16px.png")); 585 indicatorBoxHLayout->addWidget (mUSBLed); 586 mSFLed = new QIStateIndicator (KDeviceActivity_Idle); 587 mSFLed->setStateIcon (KDeviceActivity_Idle, QPixmap (":/shared_folder_16px.png")); 588 mSFLed->setStateIcon (KDeviceActivity_Reading, QPixmap (":/shared_folder_read_16px.png")); 589 mSFLed->setStateIcon (KDeviceActivity_Writing, QPixmap (":/shared_folder_write_16px.png")); 590 mSFLed->setStateIcon (KDeviceActivity_Null, QPixmap (":/shared_folder_disabled_16px.png")); 591 indicatorBoxHLayout->addWidget (mSFLed); 574 592 575 593 /* virtualization */ … … 583 601 indicatorBoxHLayout->addWidget (separator); 584 602 585 #if 0 // do not show these indicators, information overload586 /* vrdp state */587 vrdp_state = new QIStateIndicator (0, indicatorBox, "vrdp_state", Qt::WNoAutoErase);588 vrdp_state->setStateIcon (0, QPixmap (":/vrdp_disabled_16px.png"));589 vrdp_state->setStateIcon (1, QPixmap (":/vrdp_16px.png"));590 /* auto resize state */591 autoresize_state = new QIStateIndicator (1, indicatorBox, "autoresize_state", Qt::WNoAutoErase);592 autoresize_state->setStateIcon (0, QPixmap (":/auto_resize_off_disabled_16px.png"));593 autoresize_state->setStateIcon (1, QPixmap (":/auto_resize_off_16px.png"));594 autoresize_state->setStateIcon (2, QPixmap (":/auto_resize_on_disabled_16px.png"));595 autoresize_state->setStateIcon (3, QPixmap (":/auto_resize_on_16px.png"));596 #endif597 598 603 /* mouse */ 599 mouse_state = new QIStateIndicator (0); 600 mouse_state->setStateIcon (0, QPixmap (":/mouse_disabled_16px.png")); 601 mouse_state->setStateIcon (1, QPixmap (":/mouse_16px.png")); 602 mouse_state->setStateIcon (2, QPixmap (":/mouse_seamless_16px.png")); 603 mouse_state->setStateIcon (3, QPixmap (":/mouse_can_seamless_16px.png")); 604 mouse_state->setStateIcon (4, QPixmap (":/mouse_can_seamless_uncaptured_16px.png")); 605 indicatorBoxHLayout->addWidget (mouse_state); 604 mMouseLed = new QIStateIndicator (0); 605 mMouseLed->setStateIcon (0, QPixmap (":/mouse_disabled_16px.png")); 606 mMouseLed->setStateIcon (1, QPixmap (":/mouse_16px.png")); 607 mMouseLed->setStateIcon (2, QPixmap (":/mouse_seamless_16px.png")); 608 mMouseLed->setStateIcon (3, QPixmap (":/mouse_can_seamless_16px.png")); 609 mMouseLed->setStateIcon (4, QPixmap (":/mouse_can_seamless_uncaptured_16px.png")); 610 indicatorBoxHLayout->addWidget (mMouseLed); 611 606 612 /* host key */ 607 hostkey_hbox = new QWidget(); 608 QHBoxLayout *hostkeyHBoxLayout = new QHBoxLayout (hostkey_hbox); 609 VBoxGlobal::setLayoutMargin (hostkeyHBoxLayout, 0); 610 hostkeyHBoxLayout->setSpacing (3); 611 indicatorBoxHLayout->addWidget (hostkey_hbox); 612 613 hostkey_state = new QIStateIndicator (0); 614 hostkey_state->setStateIcon (0, QPixmap (":/hostkey_16px.png")); 615 hostkey_state->setStateIcon (1, QPixmap (":/hostkey_captured_16px.png")); 616 hostkey_state->setStateIcon (2, QPixmap (":/hostkey_pressed_16px.png")); 617 hostkey_state->setStateIcon (3, QPixmap (":/hostkey_captured_pressed_16px.png")); 618 hostkeyHBoxLayout->addWidget (hostkey_state); 619 hostkey_name = new QLabel (QIHotKeyEdit::keyName (vboxGlobal().settings().hostKey())); 620 hostkeyHBoxLayout->addWidget (hostkey_name); 613 mHostkeyLedContainer = new QWidget; 614 QHBoxLayout *hostkeyLEDContainerLayout = new QHBoxLayout (mHostkeyLedContainer); 615 VBoxGlobal::setLayoutMargin (hostkeyLEDContainerLayout, 0); 616 hostkeyLEDContainerLayout->setSpacing (3); 617 indicatorBoxHLayout->addWidget (mHostkeyLedContainer); 618 619 mHostkeyLed = new QIStateIndicator (0); 620 mHostkeyLed->setStateIcon (0, QPixmap (":/hostkey_16px.png")); 621 mHostkeyLed->setStateIcon (1, QPixmap (":/hostkey_captured_16px.png")); 622 mHostkeyLed->setStateIcon (2, QPixmap (":/hostkey_pressed_16px.png")); 623 mHostkeyLed->setStateIcon (3, QPixmap (":/hostkey_captured_pressed_16px.png")); 624 hostkeyLEDContainerLayout->addWidget (mHostkeyLed); 625 mHostkeyName = new QLabel (QIHotKeyEdit::keyName (vboxGlobal().settings().hostKey())); 626 hostkeyLEDContainerLayout->addWidget (mHostkeyName); 627 628 #if 0 /* TODO: Allow to setup status-bar! */ 629 /* VRDP Led */ 630 mVrdpLed = new QIStateIndicator (0, indicatorBox, "mVrdpLed", Qt::WNoAutoErase); 631 mVrdpLed->setStateIcon (0, QPixmap (":/vrdp_disabled_16px.png")); 632 mVrdpLed->setStateIcon (1, QPixmap (":/vrdp_16px.png")); 633 /* Auto-Resize LED */ 634 mAutoresizeLed = new QIStateIndicator (1, indicatorBox, "mAutoresizeLed", Qt::WNoAutoErase); 635 mAutoresizeLed->setStateIcon (0, QPixmap (":/auto_resize_off_disabled_16px.png")); 636 mAutoresizeLed->setStateIcon (1, QPixmap (":/auto_resize_off_16px.png")); 637 mAutoresizeLed->setStateIcon (2, QPixmap (":/auto_resize_on_disabled_16px.png")); 638 mAutoresizeLed->setStateIcon (3, QPixmap (":/auto_resize_on_16px.png")); 639 #endif 640 621 641 /* add to statusbar */ 622 642 statusBar()->addPermanentWidget (indicatorBox, 0); 623 643 624 ///////////////////////////////////////////////////////////////////////// 625 644 /* Retranslate UI */ 626 645 retranslateUi(); 627 646 628 setWindowTitle (caption_prefix); 629 630 ///// Connections /////////////////////////////////////////////////////// 631 632 connect (mVmFullscreenAction, SIGNAL (toggled (bool)), 633 this, SLOT (vmFullscreen (bool))); 634 connect (mVmSeamlessAction, SIGNAL (toggled (bool)), 635 this, SLOT (vmSeamless (bool))); 636 connect (mVmAutoresizeGuestAction, SIGNAL (toggled (bool)), 637 this, SLOT (vmAutoresizeGuest (bool))); 638 connect (mVmAdjustWindowAction, SIGNAL (triggered()), 639 this, SLOT (vmAdjustWindow())); 640 641 connect (mVmTypeCADAction, SIGNAL(triggered()), this, SLOT(vmTypeCAD())); 642 #if defined(Q_WS_X11) 643 connect (mVmTypeCABSAction, SIGNAL(triggered()), this, SLOT(vmTypeCABS())); 644 #endif 645 connect (mVmResetAction, SIGNAL(triggered()), this, SLOT (vmReset())); 646 connect (mVmPauseAction, SIGNAL(toggled (bool)), this, SLOT (vmPause (bool))); 647 setWindowTitle (mCaptionPrefix); 648 649 /* Connections */ 650 connect (mVmFullscreenAction, SIGNAL (toggled (bool)), this, SLOT (vmFullscreen (bool))); 651 connect (mVmSeamlessAction, SIGNAL (toggled (bool)), this, SLOT (vmSeamless (bool))); 652 connect (mVmAutoresizeGuestAction, SIGNAL (toggled (bool)), this, SLOT (vmAutoresizeGuest (bool))); 653 connect (mVmAdjustWindowAction, SIGNAL (triggered()), this, SLOT (vmAdjustWindow())); 654 connect (mVmDisableMouseIntegrAction, SIGNAL (toggled (bool)), this, SLOT (vmDisableMouseIntegration (bool))); 655 connect (mVmTypeCADAction, SIGNAL (triggered()), this, SLOT (vmTypeCAD())); 656 #ifdef Q_WS_X11 657 connect (mVmTypeCABSAction, SIGNAL (triggered()), this, SLOT (vmTypeCABS())); 658 #endif 659 connect (mVmTakeSnapshotAction, SIGNAL (triggered()), this, SLOT (vmTakeSnapshot())); 660 connect (mVmShowInformationDlgAction, SIGNAL (triggered()), this, SLOT (vmShowInfoDialog())); 661 connect (mVmResetAction, SIGNAL (triggered()), this, SLOT (vmReset())); 662 connect (mVmPauseAction, SIGNAL (toggled (bool)), this, SLOT (vmPause (bool))); 647 663 connect (mVmACPIShutdownAction, SIGNAL (triggered()), this, SLOT (vmACPIShutdown())); 648 connect (mVmCloseAction, SIGNAL(triggered()), this, SLOT (vmClose())); 649 650 connect (mVmTakeSnapshotAction, SIGNAL(triggered()), this, SLOT(vmTakeSnapshot())); 651 connect (mVmShowInformationDlgAction, SIGNAL(triggered()), this, SLOT (vmShowInfoDialog())); 652 653 connect (mVmDisableMouseIntegrAction, SIGNAL(toggled (bool)), this, SLOT(vmDisableMouseIntegr (bool))); 654 655 connect (mDevicesMountFloppyImageAction, SIGNAL(triggered()), this, SLOT(devicesMountFloppyImage())); 656 connect (mDevicesUnmountFloppyAction, SIGNAL(triggered()), this, SLOT(devicesUnmountFloppy())); 657 connect (mDevicesMountDVDImageAction, SIGNAL(triggered()), this, SLOT(devicesMountDVDImage())); 658 connect (mDevicesUnmountDVDAction, SIGNAL(triggered()), this, SLOT(devicesUnmountDVD())); 659 connect (mDevicesSwitchVrdpAction, SIGNAL(toggled (bool)), this, SLOT(devicesSwitchVrdp (bool))); 660 connect (mDevicesNetworkDialogAction, SIGNAL(triggered()), this, SLOT(devicesOpenNetworkDialog())); 661 connect (mDevicesSFDialogAction, SIGNAL(triggered()), this, SLOT(devicesOpenSFDialog())); 662 connect (mDevicesInstallGuestToolsAction, SIGNAL(triggered()), this, SLOT(devicesInstallGuestAdditions())); 663 664 665 connect (mDevicesMountFloppyMenu, SIGNAL(aboutToShow()), this, SLOT(prepareFloppyMenu())); 666 connect (mDevicesMountDVDMenu, SIGNAL(aboutToShow()), this, SLOT(prepareDVDMenu())); 667 connect (mDevicesNetworkMenu, SIGNAL(aboutToShow()), this, SLOT(prepareNetworkMenu())); 668 connect (mDevicesSFMenu, SIGNAL(aboutToShow()), this, SLOT(prepareSFMenu())); 669 670 connect (statusBar(), SIGNAL(messageChanged (const QString &)), this, SLOT(statusTipChanged (const QString &))); 671 672 connect (mDevicesMountFloppyMenu, SIGNAL(triggered(QAction *)), this, SLOT(captureFloppy(QAction *))); 673 connect (mDevicesMountDVDMenu, SIGNAL(triggered(QAction *)), this, SLOT(captureDVD(QAction *))); 674 connect (mDevicesUSBMenu, SIGNAL(triggered(QAction *)), this, SLOT(switchUSB(QAction *))); 675 676 /* Cleanup the status bar tip when a menu with dynamic items is 677 * hidden. This is necessary for context menus in the first place but also 678 * for normal menus (because Qt will not do it on pressing ESC if the menu 679 * is constructed of dynamic items only) */ 680 connect (mDevicesMountFloppyMenu, SIGNAL (aboutToHide()), 681 statusBar(), SLOT (clearMessage())); 682 connect (mDevicesMountDVDMenu, SIGNAL (aboutToHide()), 683 statusBar(), SLOT (clearMessage())); 684 685 connect (fd_light, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)), 664 connect (mVmCloseAction, SIGNAL (triggered()), this, SLOT (vmClose())); 665 666 connect (mDevicesStorageMenu, SIGNAL (aboutToShow()), this, SLOT (prepareStorageMenu())); 667 connect (mDevicesNetworkMenu, SIGNAL (aboutToShow()), this, SLOT (prepareNetworkMenu())); 668 connect (mDevicesSFMenu, SIGNAL (aboutToShow()), this, SLOT (prepareSFMenu())); 669 connect (mDevicesUSBMenu, SIGNAL(triggered (QAction *)), this, SLOT(switchUSB (QAction *))); 670 671 connect (mDevicesStorageDialogAction, SIGNAL (triggered()), this, SLOT (devicesOpenStorageDialog())); 672 connect (mDevicesNetworkDialogAction, SIGNAL (triggered()), this, SLOT (devicesOpenNetworkDialog())); 673 connect (mDevicesSFDialogAction, SIGNAL (triggered()), this, SLOT (devicesOpenSFDialog())); 674 connect (mDevicesSwitchVrdpAction, SIGNAL (toggled (bool)), this, SLOT (devicesSwitchVrdp (bool))); 675 connect (mDevicesInstallGuestToolsAction, SIGNAL (triggered()), this, SLOT (devicesInstallGuestAdditions())); 676 677 connect (mHDLed, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)), 686 678 this, SLOT (showIndicatorContextMenu (QIStateIndicator *, QContextMenuEvent *))); 687 connect ( cd_light, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)),679 connect (mCDLed, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)), 688 680 this, SLOT (showIndicatorContextMenu (QIStateIndicator *, QContextMenuEvent *))); 689 connect (usb_light, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)), 681 #if 0 /* TODO: Allow to setup status-bar! */ 682 connect (mFDLed, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)), 690 683 this, SLOT (showIndicatorContextMenu (QIStateIndicator *, QContextMenuEvent *))); 691 connect (sf_light, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)), 684 #endif 685 connect (mNetLed, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)), 692 686 this, SLOT (showIndicatorContextMenu (QIStateIndicator *, QContextMenuEvent *))); 693 connect ( net_light, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)),687 connect (mUSBLed, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)), 694 688 this, SLOT (showIndicatorContextMenu (QIStateIndicator *, QContextMenuEvent *))); 695 696 #if 0 697 connect (vrdp_state, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)), 689 connect (mSFLed, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)), 698 690 this, SLOT (showIndicatorContextMenu (QIStateIndicator *, QContextMenuEvent *))); 699 connect ( autoresize_state, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)),691 connect (mMouseLed, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)), 700 692 this, SLOT (showIndicatorContextMenu (QIStateIndicator *, QContextMenuEvent *))); 701 # endif702 connect (m ouse_state, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)),693 #if 0 /* TODO: Allow to setup status-bar! */ 694 connect (mVrdpLed, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)), 703 695 this, SLOT (showIndicatorContextMenu (QIStateIndicator *, QContextMenuEvent *))); 704 705 /* watch global settings changes */ 696 connect (mAutoresizeLed, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)), 697 this, SLOT (showIndicatorContextMenu (QIStateIndicator *, QContextMenuEvent *))); 698 #endif 699 700 /* Watch global settings changes */ 706 701 connect (&vboxGlobal().settings(), SIGNAL (propertyChanged (const char *, const char *)), 707 702 this, SLOT (processGlobalSettingChange (const char *, const char *))); … … 725 720 /* For the status bar on Cocoa */ 726 721 setUnifiedTitleAndToolBarOnMac (true); 727 728 722 # ifdef VBOX_WITH_ICHAT_THEATER 729 //int setAttr[] = { kHIWindowBitDoesNotShowBadgeInDock, 0 };730 // HIWindowChangeAttributes (window, setAttr, NULL);723 // int setAttr[] = { kHIWindowBitDoesNotShowBadgeInDock, 0 }; 724 // HIWindowChangeAttributes (window, setAttr, 0); 731 725 initSharedAVManager(); 732 726 # endif 733 727 #endif 728 734 729 mMaskShift.scale (0, 0, Qt::IgnoreAspectRatio); 735 730 } … … 740 735 741 736 #ifdef VBOX_WITH_DEBUGGER_GUI 742 /* destroy the debugger gui */743 737 dbgDestroy(); 744 738 #endif 745 739 } 746 747 //748 // Public members749 /////////////////////////////////////////////////////////////////////////////750 740 751 741 /** … … 754 744 * Used by VBoxGlobal::startMachine(), should not be called directly. 755 745 */ 756 bool VBoxConsoleWnd::openView (const CSession & session)746 bool VBoxConsoleWnd::openView (const CSession &aSession) 757 747 { 758 748 LogFlowFuncEnter(); 759 749 760 if ( console)750 if (mConsole) 761 751 { 762 752 LogFlowFunc (("Already opened\n")); … … 772 762 #endif /* Q_WS_MAC */ 773 763 774 csession = session;764 mSession = aSession; 775 765 776 766 if (!centralWidget()) 777 767 { 778 768 setCentralWidget (new QWidget (this)); 779 QGridLayout *pMainLayout = new QGridLayout (centralWidget());769 QGridLayout *pMainLayout = new QGridLayout (centralWidget()); 780 770 VBoxGlobal::setLayoutMargin (pMainLayout, 0); 781 771 pMainLayout->setSpacing (0); 782 772 783 mShiftingSpacerLeft = new QSpacerItem (0, 0, 784 QSizePolicy::Fixed, 785 QSizePolicy::Fixed); 786 mShiftingSpacerTop = new QSpacerItem (0, 0, 787 QSizePolicy::Fixed, 788 QSizePolicy::Fixed); 789 mShiftingSpacerRight = new QSpacerItem (0, 0, 790 QSizePolicy::Fixed, 791 QSizePolicy::Fixed); 792 mShiftingSpacerBottom = new QSpacerItem (0, 0, 793 QSizePolicy::Fixed, 794 QSizePolicy::Fixed); 773 mShiftingSpacerLeft = new QSpacerItem (0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed); 774 mShiftingSpacerTop = new QSpacerItem (0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed); 775 mShiftingSpacerRight = new QSpacerItem (0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed); 776 mShiftingSpacerBottom = new QSpacerItem (0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed); 795 777 pMainLayout->addItem (mShiftingSpacerTop, 0, 0, 1, -1); 796 778 pMainLayout->addItem (mShiftingSpacerLeft, 1, 0); … … 801 783 mVmPauseAction->setChecked (false); 802 784 803 VBoxDefs::RenderMode mode = vboxGlobal().vmRenderMode(); 804 805 CConsole cconsole = csession.GetConsole(); 806 AssertWrapperOk (csession); 807 808 CMachine cmachine = csession.GetMachine(); 785 CConsole console = mSession.GetConsole(); 786 AssertWrapperOk (mSession); 787 788 CMachine machine = mSession.GetMachine(); 809 789 810 790 #ifdef VBOX_WITH_VIDEOHWACCEL 811 791 /* Need to force the QGL framebuffer in case 2D Video Acceleration is supported & enabled */ 812 bool bAccelerate2DVideo = cmachine.GetAccelerate2DVideoEnabled() && VBoxGlobal::isAcceleration2DVideoAvailable();813 #endif 814 815 console = new VBoxConsoleView (this, cconsole, mode,792 bool bAccelerate2DVideo = machine.GetAccelerate2DVideoEnabled() && VBoxGlobal::isAcceleration2DVideoAvailable(); 793 #endif 794 795 mConsole = new VBoxConsoleView (this, console, vboxGlobal().vmRenderMode(), 816 796 #ifdef VBOX_WITH_VIDEOHWACCEL 817 bAccelerate2DVideo,818 #endif 819 centralWidget());820 static_cast <QGridLayout*> (centralWidget()->layout())->addWidget (console, 1, 1, Qt::AlignVCenter | Qt::AlignHCenter);797 bAccelerate2DVideo, 798 #endif 799 centralWidget()); 800 qobject_cast <QGridLayout*> (centralWidget()->layout())->addWidget (mConsole, 1, 1, Qt::AlignVCenter | Qt::AlignHCenter); 821 801 822 802 /* Mini toolbar */ 823 bool isActive = !( cmachine.GetExtraData (VBoxDefs::GUI_ShowMiniToolBar) == "no");824 bool isAtTop = ( cmachine.GetExtraData (VBoxDefs::GUI_MiniToolBarAlignment) == "top");825 bool isAutoHide = !( cmachine.GetExtraData (VBoxDefs::GUI_MiniToolBarAutoHide) == "off");826 QList <QMenu*> menus (QList <QMenu*> () << mMiniVMMenu<< mDevicesMenu);803 bool isActive = !(machine.GetExtraData (VBoxDefs::GUI_ShowMiniToolBar) == "no"); 804 bool isAtTop = (machine.GetExtraData (VBoxDefs::GUI_MiniToolBarAlignment) == "top"); 805 bool isAutoHide = !(machine.GetExtraData (VBoxDefs::GUI_MiniToolBarAutoHide) == "off"); 806 QList <QMenu*> menus (QList <QMenu*>() << mVMMenuMini << mDevicesMenu); 827 807 mMiniToolBar = new VBoxMiniToolBar (centralWidget(), isAtTop ? VBoxMiniToolBar::AlignTop : VBoxMiniToolBar::AlignBottom, 828 808 isActive, isAutoHide); … … 838 818 /* Not on Mac OS X. The dock icon is handled below. */ 839 819 #ifndef Q_WS_MAC 840 setWindowIcon (vboxGlobal().vmGuestOSTypeIcon ( cmachine.GetOSTypeId()));820 setWindowIcon (vboxGlobal().vmGuestOSTypeIcon (machine.GetOSTypeId())); 841 821 #endif 842 822 843 823 /* Restore the position of the window and some options */ 844 824 { 845 QString str = cmachine.GetExtraData (VBoxDefs::GUI_LastWindowPosition);825 QString str = machine.GetExtraData (VBoxDefs::GUI_LastWindowPosition); 846 826 847 827 bool ok = false, max = false; … … 866 846 867 847 /* Normalize to the optimal size */ 868 console->normalizeGeometry (true /* adjustPosition */);848 mConsole->normalizeGeometry (true /* adjustPosition */); 869 849 870 850 if (max) … … 872 852 /* Maximize if needed */ 873 853 setWindowState (windowState() | Qt::WindowMaximized); 874 was_max = max;854 mWasMax = max; 875 855 } 876 856 } … … 878 858 { 879 859 /* Normalize to the optimal size */ 880 console->normalizeGeometry (true /* adjustPosition */);860 mConsole->normalizeGeometry (true /* adjustPosition */); 881 861 882 862 /* Move newly created window to the screen center. */ … … 892 872 893 873 mVmSeamlessAction->setEnabled (false); 894 str = cmachine.GetExtraData (VBoxDefs::GUI_Seamless);874 str = machine.GetExtraData (VBoxDefs::GUI_Seamless); 895 875 if (str == "on") 896 876 mVmSeamlessAction->setChecked (true); 897 877 898 str = cmachine.GetExtraData (VBoxDefs::GUI_AutoresizeGuest);878 str = machine.GetExtraData (VBoxDefs::GUI_AutoresizeGuest); 899 879 if (str != "off") 900 880 mVmAutoresizeGuestAction->setChecked (true); 901 881 902 str = cmachine.GetExtraData (VBoxDefs::GUI_FirstRun);882 str = machine.GetExtraData (VBoxDefs::GUI_FirstRun); 903 883 if (str == "yes") 904 884 mIsFirstTimeStarted = true; 905 885 else if (!str.isEmpty()) 906 cmachine.SetExtraData (VBoxDefs::GUI_FirstRun, QString::null);907 908 str = cmachine.GetExtraData (VBoxDefs::GUI_SaveMountedAtRuntime);886 machine.SetExtraData (VBoxDefs::GUI_FirstRun, QString::null); 887 888 str = machine.GetExtraData (VBoxDefs::GUI_SaveMountedAtRuntime); 909 889 if (str == "no") 910 890 mIsAutoSaveMedia = false; 911 891 912 892 /* Check if one of extended modes to be activated on loading */ 913 QString fsMode = cmachine.GetExtraData (VBoxDefs::GUI_Fullscreen);914 QString slMode = cmachine.GetExtraData (VBoxDefs::GUI_Seamless);893 QString fsMode = machine.GetExtraData (VBoxDefs::GUI_Fullscreen); 894 QString slMode = machine.GetExtraData (VBoxDefs::GUI_Seamless); 915 895 bool extendedMode = fsMode == "on" || slMode == "on"; 916 896 … … 918 898 * console resize event which will come from VGA Device on loading. */ 919 899 if (extendedMode) 920 console->requestToResize (QSize (w, h - menuBar()->height() - statusBar()->height()));900 mConsole->requestToResize (QSize (w, h - menuBar()->height() - statusBar()->height())); 921 901 } 922 902 923 903 /* initialize usb stuff */ 924 CUSBController usbctl = cmachine.GetUSBController();904 CUSBController usbctl = machine.GetUSBController(); 925 905 if (usbctl.isNull()) 926 906 { 927 907 /* hide usb_menu & usb_separator & usb_status_led */ 928 908 mDevicesUSBMenu->setVisible (false); 929 mDevicesUSBMenuSeparator->setVisible (false); 930 usb_light->setHidden (true); 909 mUSBLed->setHidden (true); 931 910 } 932 911 else … … 934 913 bool isUSBEnabled = usbctl.GetEnabled(); 935 914 mDevicesUSBMenu->setEnabled (isUSBEnabled); 936 mDevicesUSBMenu->setConsole (cconsole); 937 usb_light->setState (isUSBEnabled ? KDeviceActivity_Idle 938 : KDeviceActivity_Null); 915 mDevicesUSBMenu->setConsole (console); 916 mUSBLed->setState (isUSBEnabled ? KDeviceActivity_Idle : KDeviceActivity_Null); 939 917 } 940 918 941 919 /* initialize vrdp stuff */ 942 CVRDPServer vrdpsrv = cmachine.GetVRDPServer();920 CVRDPServer vrdpsrv = machine.GetVRDPServer(); 943 921 if (vrdpsrv.isNull()) 944 922 { 945 923 /* hide vrdp_menu_action & vrdp_separator & vrdp_status_icon */ 946 924 mDevicesSwitchVrdpAction->setVisible (false); 947 mDevices VRDPMenuSeparator->setVisible (false);948 #if 0 949 vrdp_state->setHidden (true);925 mDevicesSwitchVrdpSeparator->setVisible (false); 926 #if 0 /* TODO: Allow to setup status-bar! */ 927 mVrdpLed->setHidden (true); 950 928 #endif 951 929 } 952 930 953 931 /* start an idle timer that will update device lighths */ 954 connect (idle_timer, SIGNAL (timeout()), SLOT (updateDeviceLights())); 955 idle_timer->start (50); 956 957 connect (console, SIGNAL (mouseStateChanged (int)), 958 this, SLOT (updateMouseState (int))); 959 connect (console, SIGNAL (keyboardStateChanged (int)), 960 hostkey_state, SLOT (setState (int))); 961 connect (console, SIGNAL (machineStateChanged (KMachineState)), 962 this, SLOT (updateMachineState (KMachineState))); 963 connect (console, SIGNAL (additionsStateChanged (const QString&, bool, bool, bool)), 932 connect (mIdleTimer, SIGNAL (timeout()), SLOT (updateDeviceLights())); 933 mIdleTimer->start (50); 934 935 connect (mConsole, SIGNAL (mouseStateChanged (int)), this, SLOT (updateMouseState (int))); 936 connect (mConsole, SIGNAL (keyboardStateChanged (int)), mHostkeyLed, SLOT (setState (int))); 937 connect (mConsole, SIGNAL (machineStateChanged (KMachineState)), this, SLOT (updateMachineState (KMachineState))); 938 connect (mConsole, SIGNAL (additionsStateChanged (const QString&, bool, bool, bool)), 964 939 this, SLOT (updateAdditionsState (const QString &, bool, bool, bool))); 965 connect ( console, SIGNAL (mediaDriveChanged (VBoxDefs::MediumType)),940 connect (mConsole, SIGNAL (mediaDriveChanged (VBoxDefs::MediumType)), 966 941 this, SLOT (updateMediaDriveState (VBoxDefs::MediumType))); 967 connect (console, SIGNAL (usbStateChange()), 968 this, SLOT (updateUsbState())); 969 connect (console, SIGNAL (networkStateChange()), 970 this, SLOT (updateNetworkAdaptersState())); 971 connect (console, SIGNAL (sharedFoldersChanged()), 972 this, SLOT (updateSharedFoldersState())); 942 connect (mConsole, SIGNAL (usbStateChange()), this, SLOT (updateUsbState())); 943 connect (mConsole, SIGNAL (networkStateChange()), this, SLOT (updateNetworkAdaptersState())); 944 connect (mConsole, SIGNAL (sharedFoldersChanged()), this, SLOT (updateSharedFoldersState())); 973 945 974 946 #ifdef Q_WS_MAC … … 976 948 /* Default to true if it is an empty value */ 977 949 bool f = (testStr.isEmpty() || testStr == "true"); 978 console->setDockIconEnabled (f);979 console->updateDockOverlay();980 #endif 981 982 /* set the correct initial m achine_state value */983 m achine_state = cconsole.GetState();984 985 console->normalizeGeometry (false /* adjustPosition */);950 mConsole->setDockIconEnabled (f); 951 mConsole->updateDockOverlay(); 952 #endif 953 954 /* set the correct initial mMachineState value */ 955 mMachineState = console.GetState(); 956 957 mConsole->normalizeGeometry (false /* adjustPosition */); 986 958 987 959 updateAppearanceOf (AllStuff); … … 1004 976 } 1005 977 1006 void VBoxConsoleWnd::activateUICustomizations()1007 {1008 VBoxGlobalSettings settings = vboxGlobal().settings();1009 /* Process known keys */1010 menuBar()->setHidden (settings.isFeatureActive ("noMenuBar"));1011 statusBar()->setHidden (settings.isFeatureActive ("noStatusBar"));1012 }1013 1014 void VBoxConsoleWnd::finalizeOpenView()1015 {1016 LogFlowFuncEnter();1017 1018 /* Notify the console scroll-view about the console-window is opened. */1019 console->onViewOpened();1020 1021 bool saved = machine_state == KMachineState_Saved;1022 1023 CMachine cmachine = csession.GetMachine();1024 CConsole cconsole = console->console();1025 1026 if (mIsFirstTimeStarted)1027 {1028 VBoxVMFirstRunWzd wzd (cmachine, this);1029 wzd.exec();1030 1031 /* Remove GUI_FirstRun extra data key from the machine settings1032 * file after showing the wizard once. */1033 cmachine.SetExtraData (VBoxDefs::GUI_FirstRun, QString::null);1034 }1035 1036 /* start the VM */1037 CProgress progress = vboxGlobal().isStartPausedEnabled()1038 || vboxGlobal().isDebuggerAutoShowEnabled()1039 ? cconsole.PowerUpPaused()1040 : cconsole.PowerUp();1041 1042 /* check for an immediate failure */1043 if (!cconsole.isOk())1044 {1045 vboxProblem().cannotStartMachine (cconsole);1046 /* close this window (this will call closeView()) */1047 close();1048 1049 LogFlowFunc (("Error starting VM\n"));1050 LogFlowFuncLeave();1051 return;1052 }1053 1054 console->attach();1055 1056 /* Disable auto closure because we want to have a chance to show the1057 * error dialog on startup failure */1058 no_auto_close = true;1059 1060 /* show the "VM starting / restoring" progress dialog */1061 1062 if (saved)1063 vboxProblem().showModalProgressDialog (progress, cmachine.GetName(),1064 this, 0);1065 else1066 vboxProblem().showModalProgressDialog (progress, cmachine.GetName(),1067 this);1068 1069 if (progress.GetResultCode() != 0)1070 {1071 vboxProblem().cannotStartMachine (progress);1072 /* close this window (this will call closeView()) */1073 close();1074 1075 LogFlowFunc (("Error starting VM\n"));1076 LogFlowFuncLeave();1077 return;1078 }1079 1080 no_auto_close = false;1081 1082 /* Check if we missed a really quick termination after successful1083 * startup, and process it if we did. */1084 if (machine_state < KMachineState_Running)1085 {1086 close();1087 LogFlowFuncLeave();1088 return;1089 }1090 1091 /* Currently the machine is started and the guest API could be used...1092 * Checking if the fullscreen mode should be activated */1093 QString str = cmachine.GetExtraData (VBoxDefs::GUI_Fullscreen);1094 if (str == "on")1095 mVmFullscreenAction->setChecked (true);1096 1097 /* If seamless mode should be enabled then check if it is enabled1098 * currently and re-enable it if seamless is supported */1099 if ( mVmSeamlessAction->isChecked()1100 && mIsSeamlessSupported1101 && mIsGraphicsSupported)1102 toggleFullscreenMode (true, true);1103 #ifdef VBOX_WITH_DEBUGGER_GUI1104 /* Open the debugger in "full screen" mode requested by the user. */1105 else if (vboxGlobal().isDebuggerAutoShowEnabled())1106 {1107 /* console in upper left corner of the desktop. */1108 QRect rct(0, 0, 0, 0);1109 QDesktopWidget *desktop = QApplication::desktop();1110 if (desktop)1111 rct = desktop->availableGeometry(pos());1112 move (QPoint (rct.x(), rct.y()));1113 1114 if (vboxGlobal().isDebuggerAutoShowStatisticsEnabled())1115 dbgShowStatistics();1116 if (vboxGlobal().isDebuggerAutoShowCommandLineEnabled())1117 dbgShowCommandLine();1118 1119 if (!vboxGlobal().isStartPausedEnabled())1120 console->pause (false);1121 }1122 #endif1123 1124 mIsOpenViewFinished = true;1125 LogFlowFuncLeave();1126 1127 #ifdef VBOX_WITH_UPDATE_REQUEST1128 vboxGlobal().showUpdateDialog (false /* aForce */);1129 #endif1130 1131 /* Finally check the status of required features. */1132 checkRequiredFeatures();1133 1134 /* Re-request all the static values finally after1135 * view is really opened and attached. */1136 updateAppearanceOf (VirtualizationStuff);1137 }1138 1139 /**1140 * Closes the console view opened by openView().1141 * Does nothing if no console view was opened.1142 */1143 void VBoxConsoleWnd::closeView()1144 {1145 LogFlowFuncEnter();1146 1147 if (!console)1148 {1149 LogFlow (("Already closed!\n"));1150 LogFlowFuncLeave();1151 return;1152 }1153 1154 console->detach();1155 centralWidget()->layout()->removeWidget (console);1156 delete console;1157 console = 0;1158 csession.Close();1159 csession.detach();1160 1161 LogFlowFuncLeave();1162 }1163 1164 /**1165 * Refreshes the console view by readressing this call to1166 * VBoxConsoleView::refresh(). Does nothing if the console view doesn't1167 * exist (i.e., as before openView() or after stopView()).1168 */1169 void VBoxConsoleWnd::refreshView()1170 {1171 if ( console ) {1172 console->refresh();1173 }1174 }1175 1176 /**1177 * This slot is called just after leaving the fullscreen/seamless mode,1178 * when the console was resized to previous size.1179 */1180 void VBoxConsoleWnd::onExitFullscreen()1181 {1182 console->setIgnoreMainwndResize (false);1183 }1184 1185 void VBoxConsoleWnd::unlockActionsSwitch()1186 {1187 if (mIsSeamless)1188 mVmSeamlessAction->setEnabled (true);1189 else if (mIsFullscreen)1190 mVmFullscreenAction->setEnabled (true);1191 else1192 {1193 mVmSeamlessAction->setEnabled (mIsSeamlessSupported && mIsGraphicsSupported);1194 mVmFullscreenAction->setEnabled (true);1195 }1196 1197 #ifdef Q_WS_MAC1198 if (!mIsSeamless)1199 {1200 /* Fade back to the normal gamma */1201 CGDisplayFade (mFadeToken, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, false);1202 CGReleaseDisplayFadeReservation (mFadeToken);1203 }1204 console->setMouseCoalescingEnabled (true);1205 #endif1206 }1207 1208 978 void VBoxConsoleWnd::setMouseIntegrationLocked (bool aDisabled) 1209 979 { … … 1242 1012 } 1243 1013 1244 // 1245 // Protected Members 1246 ///////////////////////////////////////////////////////////////////////////// 1247 1248 bool VBoxConsoleWnd::event (QEvent *e) 1249 { 1250 switch (e->type()) 1014 void VBoxConsoleWnd::installGuestAdditionsFrom (const QString &aSource) 1015 { 1016 CVirtualBox vbox = vboxGlobal().virtualBox(); 1017 QString uuid; 1018 1019 CMedium image = vbox.FindDVDImage (aSource); 1020 if (image.isNull()) 1021 { 1022 image = vbox.OpenDVDImage (aSource, uuid); 1023 if (vbox.isOk()) 1024 uuid = image.GetId(); 1025 } 1026 else 1027 uuid = image.GetId(); 1028 1029 if (!vbox.isOk()) 1030 return vboxProblem().cannotOpenMedium (this, vbox, 1031 VBoxDefs::MediumType_DVD, aSource); 1032 1033 Assert (!uuid.isNull()); 1034 CMachine m = mSession.GetMachine(); 1035 1036 QString ctrName; 1037 LONG ctrPort = -1, ctrDevice = -1; 1038 /* Searching for the first suitable slot */ 1039 { 1040 CStorageControllerVector controllers = m.GetStorageControllers(); 1041 int i = 0; 1042 while (i < controllers.size() && ctrName.isNull()) 1043 { 1044 CStorageController controller = controllers [i]; 1045 CMediumAttachmentVector attachments = m.GetMediumAttachmentsOfController (controller.GetName()); 1046 int j = 0; 1047 while (j < attachments.size() && ctrName.isNull()) 1048 { 1049 CMediumAttachment attachment = attachments [j]; 1050 if (attachment.GetDevice() == KDeviceType_DVD) 1051 { 1052 ctrName = controller.GetName(); 1053 ctrPort = attachment.GetPort(); 1054 ctrDevice = attachment.GetDevice(); 1055 } 1056 ++ j; 1057 } 1058 ++ i; 1059 } 1060 } 1061 1062 if (!ctrName.isNull()) 1063 { 1064 m.MountMedium (ctrName, ctrPort, ctrDevice, uuid); 1065 AssertWrapperOk (m); 1066 if (m.isOk()) 1067 { 1068 if (mIsAutoSaveMedia) 1069 { 1070 m.SaveSettings(); 1071 if (!m.isOk()) 1072 vboxProblem().cannotSaveMachineSettings (m); 1073 } 1074 } 1075 } 1076 else 1077 { 1078 /* TODO: Make warning about DVD is missing! */ 1079 } 1080 } 1081 1082 void VBoxConsoleWnd::setMask (const QRegion &aRegion) 1083 { 1084 QRegion region = aRegion; 1085 1086 /* The global mask shift cause of toolbars and such things. */ 1087 region.translate (mMaskShift.width(), mMaskShift.height()); 1088 1089 /* Including mini toolbar area */ 1090 QRegion toolBarRegion (mMiniToolBar->mask()); 1091 toolBarRegion.translate (mMiniToolBar->mapToGlobal (toolBarRegion.boundingRect().topLeft()) - QPoint (1, 0)); 1092 region += toolBarRegion; 1093 1094 /* Restrict the drawing to the available space on the screen. 1095 * (The &operator is better than the previous used -operator, 1096 * because this excludes space around the real screen also. 1097 * This is necessary for the mac.) */ 1098 region &= mStrictedRegion; 1099 1100 #ifdef Q_WS_WIN 1101 QRegion difference = mPrevRegion.subtract (region); 1102 1103 /* Region offset calculation */ 1104 int fleft = 0, ftop = 0; 1105 1106 /* Visible region calculation */ 1107 HRGN newReg = CreateRectRgn (0, 0, 0, 0); 1108 CombineRgn (newReg, region.handle(), 0, RGN_COPY); 1109 OffsetRgn (newReg, fleft, ftop); 1110 1111 /* Invisible region calculation */ 1112 HRGN diffReg = CreateRectRgn (0, 0, 0, 0); 1113 CombineRgn (diffReg, difference.handle(), 0, RGN_COPY); 1114 OffsetRgn (diffReg, fleft, ftop); 1115 1116 /* Set the current visible region and clean the previous */ 1117 SetWindowRgn (winId(), newReg, FALSE); 1118 RedrawWindow (0, 0, diffReg, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); 1119 RedrawWindow (mConsole->viewport()->winId(), 0, 0, RDW_INVALIDATE); 1120 1121 mPrevRegion = region; 1122 #elif defined (Q_WS_MAC) 1123 # if defined (VBOX_GUI_USE_QUARTZ2D) 1124 if (vboxGlobal().vmRenderMode() == VBoxDefs::Quartz2DMode) 1125 { 1126 /* If we are using the Quartz2D backend we have to trigger 1127 * an repaint only. All the magic clipping stuff is done 1128 * in the paint engine. */ 1129 ::darwinWindowInvalidateShape (mConsole->viewport()); 1130 } 1131 else 1132 # endif 1133 { 1134 /* This is necessary to avoid the flicker by an mask update. 1135 * See http://lists.apple.com/archives/Carbon-development/2001/Apr/msg01651.html 1136 * for the hint. 1137 * There *must* be a better solution. */ 1138 if (!region.isEmpty()) 1139 region |= QRect (0, 0, 1, 1); 1140 // /* Save the current region for later processing in the darwin event handler. */ 1141 // mCurrRegion = region; 1142 // /* We repaint the screen before the ReshapeCustomWindow command. Unfortunately 1143 // * this command flushes a copy of the backbuffer to the screen after the new 1144 // * mask is set. This leads into a missplaced drawing of the content. Currently 1145 // * no alternative to this and also this is not 100% perfect. */ 1146 // repaint(); 1147 // qApp->processEvents(); 1148 // /* Now force the reshaping of the window. This is definitly necessary. */ 1149 // ReshapeCustomWindow (reinterpret_cast <WindowPtr> (winId())); 1150 QMainWindow::setMask (region); 1151 // HIWindowInvalidateShadow (::darwinToWindowRef (mConsole->viewport())); 1152 } 1153 #else 1154 QMainWindow::setMask (region); 1155 #endif 1156 } 1157 1158 void VBoxConsoleWnd::clearMask() 1159 { 1160 #ifdef Q_WS_WIN 1161 SetWindowRgn (winId(), 0, TRUE); 1162 #else 1163 QMainWindow::clearMask(); 1164 #endif 1165 } 1166 1167 bool VBoxConsoleWnd::event (QEvent *aEvent) 1168 { 1169 switch (aEvent->type()) 1251 1170 { 1252 1171 /* By handling every Resize and Move we keep track of the normal … … 1256 1175 case QEvent::Resize: 1257 1176 { 1258 QResizeEvent *re = (QResizeEvent *) e;1177 QResizeEvent *re = (QResizeEvent *) aEvent; 1259 1178 1260 1179 if (!mIsWaitingModeResize && !isWindowMaximized() && … … 1301 1220 case StatusTipEvent::Type: 1302 1221 { 1303 StatusTipEvent *ev = (StatusTipEvent*) e;1222 StatusTipEvent *ev = (StatusTipEvent*) aEvent; 1304 1223 statusBar()->showMessage (ev->mTip); 1305 1224 break; … … 1309 1228 } 1310 1229 1311 return QMainWindow::event ( e);1312 } 1313 1314 void VBoxConsoleWnd::closeEvent (QCloseEvent * e)1230 return QMainWindow::event (aEvent); 1231 } 1232 1233 void VBoxConsoleWnd::closeEvent (QCloseEvent *aEvent) 1315 1234 { 1316 1235 LogFlowFuncEnter(); … … 1321 1240 static const char *kDiscardCurState = "discardCurState"; 1322 1241 1323 if (! console)1324 { 1325 e->accept();1242 if (!mConsole) 1243 { 1244 aEvent->accept(); 1326 1245 LogFlowFunc (("Console already destroyed!")); 1327 1246 LogFlowFuncLeave(); … … 1329 1248 } 1330 1249 1331 if (machine_state > KMachineState_Paused && 1332 machine_state != KMachineState_Stuck) 1333 { 1334 /* 1335 * The machine is in some temporary state like Saving or Stopping. 1336 * Ignore the close event. When it is Stopping, it will be soon closed 1337 * anyway from updateMachineState(). In all other cases, an appropriate 1338 * progress dialog will be shown within a few seconds. 1339 */ 1340 e->ignore(); 1250 if (mMachineState > KMachineState_Paused && mMachineState != KMachineState_Stuck) 1251 { 1252 /* The machine is in some temporary state like Saving or Stopping. 1253 * Ignore the close event. When it is Stopping, it will be soon closed anyway from updateMachineState(). 1254 * In all other cases, an appropriate progress dialog will be shown within a few seconds. */ 1255 aEvent->ignore(); 1256 } 1257 else if (mMachineState < KMachineState_Running) 1258 { 1259 /* The machine has been already powered off or saved or aborted -- close the window immediately. */ 1260 aEvent->accept(); 1341 1261 } 1342 1262 else 1343 if (machine_state < KMachineState_Running) 1344 { 1345 /* 1346 * the machine has been already powered off or saved or aborted -- 1347 * close the window immediately 1348 */ 1349 e->accept(); 1350 } 1351 else 1352 { 1353 /* start with ignore the close event */ 1354 e->ignore(); 1355 1356 bool isACPIEnabled = csession.GetConsole().GetGuestEnteredACPIMode(); 1263 { 1264 /* Start with ignore the close event */ 1265 aEvent->ignore(); 1266 1267 bool isACPIEnabled = mSession.GetConsole().GetGuestEnteredACPIMode(); 1357 1268 1358 1269 bool success = true; 1359 1270 1360 bool wasPaused = machine_state == KMachineState_Paused || 1361 machine_state == KMachineState_Stuck; 1271 bool wasPaused = mMachineState == KMachineState_Paused || mMachineState == KMachineState_Stuck; 1362 1272 if (!wasPaused) 1363 1273 { 1364 1274 /* Suspend the VM and ignore the close event if failed to do so. 1365 1275 * pause() will show the error message to the user. */ 1366 success = console->pause (true);1276 success = mConsole->pause (true); 1367 1277 } 1368 1278 … … 1371 1281 success = false; 1372 1282 1373 CMachine cmachine = csession.GetMachine();1283 CMachine machine = mSession.GetMachine(); 1374 1284 VBoxCloseVMDlg dlg (this); 1375 QString typeId = cmachine.GetOSTypeId();1285 QString typeId = machine.GetOSTypeId(); 1376 1286 dlg.pmIcon->setPixmap (vboxGlobal().vmGuestOSTypeIcon (typeId)); 1377 1287 1378 /* make the Discard checkbox invisible if there are no snapshots */1379 dlg.mCbDiscardCurState->setVisible ( cmachine.GetSnapshotCount() > 0);1380 1381 if (m achine_state != KMachineState_Stuck)1288 /* Make the Discard checkbox invisible if there are no snapshots */ 1289 dlg.mCbDiscardCurState->setVisible (machine.GetSnapshotCount() > 0); 1290 1291 if (mMachineState != KMachineState_Stuck) 1382 1292 { 1383 /* read the last user's choice for the given VM */ 1384 QStringList lastAction = 1385 cmachine.GetExtraData (VBoxDefs::GUI_LastCloseAction).split (','); 1386 AssertWrapperOk (cmachine); 1293 /* Read the last user's choice for the given VM */ 1294 QStringList lastAction = machine.GetExtraData (VBoxDefs::GUI_LastCloseAction).split (','); 1295 AssertWrapperOk (machine); 1387 1296 if (lastAction [0] == kSave) 1388 1297 { … … 1396 1305 dlg.mRbPowerOff->setFocus(); 1397 1306 } 1398 else /* the default is ACPI Shutdown */1307 else /* The default is ACPI Shutdown */ 1399 1308 { 1400 1309 dlg.mRbShutdown->setChecked (true); 1401 1310 dlg.mRbShutdown->setFocus(); 1402 1311 } 1403 dlg.mCbDiscardCurState->setChecked (lastAction.count() > 1 && 1404 lastAction [1] == kDiscardCurState); 1312 dlg.mCbDiscardCurState->setChecked (lastAction.count() > 1 && lastAction [1] == kDiscardCurState); 1405 1313 } 1406 1314 else 1407 1315 { 1408 /* The stuck VM can only be powered off; disable anything 1409 * else and choose PowerOff */ 1316 /* The stuck VM can only be powered off; disable anything else and choose PowerOff */ 1410 1317 dlg.mRbSave->setEnabled (false); 1411 1318 dlg.mRbShutdown->setEnabled (false); … … 1417 1324 if (dlg.exec() == QDialog::Accepted) 1418 1325 { 1419 /* Disable auto closure because we want to have a chance to show the1420 * error dialog on save state / power off failure. */1421 no_auto_close = true;1422 1423 CConsole c console = console->console();1326 /* Disable auto closure because we want to have a chance to show 1327 * the error dialog on save state / power off failure. */ 1328 mNoAutoClose = true; 1329 1330 CConsole console = mConsole->console(); 1424 1331 1425 1332 if (dlg.mRbSave->isChecked()) 1426 1333 { 1427 CProgress progress = c console.SaveState();1428 1429 if (c console.isOk())1334 CProgress progress = console.SaveState(); 1335 1336 if (console.isOk()) 1430 1337 { 1431 /* show the "VM saving" progress dialog */ 1432 vboxProblem() 1433 .showModalProgressDialog (progress, cmachine.GetName(), 1434 this, 0); 1338 /* Show the "VM saving" progress dialog */ 1339 vboxProblem().showModalProgressDialog (progress, machine.GetName(), this, 0); 1435 1340 if (progress.GetResultCode() != 0) 1436 1341 vboxProblem().cannotSaveMachineState (progress); … … 1439 1344 } 1440 1345 else 1441 vboxProblem().cannotSaveMachineState (c console);1346 vboxProblem().cannotSaveMachineState (console); 1442 1347 } 1443 else 1444 if (dlg.mRbShutdown->isChecked()) 1348 else if (dlg.mRbShutdown->isChecked()) 1445 1349 { 1446 /* unpause the VM to let it grab the ACPI shutdown event */1447 console->pause (false);1448 /* prevent the subsequent unpause request */1350 /* Unpause the VM to let it grab the ACPI shutdown event */ 1351 mConsole->pause (false); 1352 /* Prevent the subsequent unpause request */ 1449 1353 wasPaused = true; 1450 /* signal ACPI shutdown (if there is no ACPI device, the1354 /* Signal ACPI shutdown (if there is no ACPI device, the 1451 1355 * operation will fail) */ 1452 c console.PowerButton();1453 wasShutdown = c console.isOk();1356 console.PowerButton(); 1357 wasShutdown = console.isOk(); 1454 1358 if (!wasShutdown) 1455 vboxProblem().cannotACPIShutdownMachine (c console);1456 /* success is always false because we never accept the close1359 vboxProblem().cannotACPIShutdownMachine (console); 1360 /* Success is always false because we never accept the close 1457 1361 * window action when doing ACPI shutdown */ 1458 1362 success = false; 1459 1363 } 1460 else 1461 if (dlg.mRbPowerOff->isChecked()) 1364 else if (dlg.mRbPowerOff->isChecked()) 1462 1365 { 1463 CProgress progress = c console.PowerDown();1464 1465 if (c console.isOk())1366 CProgress progress = console.PowerDown(); 1367 1368 if (console.isOk()) 1466 1369 { 1467 /* show the power down progress dialog */ 1468 vboxProblem() 1469 .showModalProgressDialog (progress, cmachine.GetName(), 1470 this, 0); 1370 /* Show the power down progress dialog */ 1371 vboxProblem().showModalProgressDialog (progress, machine.GetName(), this, 0); 1471 1372 if (progress.GetResultCode() != 0) 1472 1373 vboxProblem().cannotStopMachine (progress); … … 1475 1376 } 1476 1377 else 1477 vboxProblem().cannotStopMachine (c console);1378 vboxProblem().cannotStopMachine (console); 1478 1379 1479 1380 if (success) … … 1483 1384 * will closed anyway */ 1484 1385 1485 /* discard the current state if requested */ 1486 if (dlg.mCbDiscardCurState->isChecked() && 1487 dlg.mCbDiscardCurState->isVisibleTo (&dlg)) 1386 /* Discard the current state if requested */ 1387 if (dlg.mCbDiscardCurState->isChecked() && dlg.mCbDiscardCurState->isVisibleTo (&dlg)) 1488 1388 { 1489 CProgress progress = c console.DiscardCurrentState();1490 if (c console.isOk())1389 CProgress progress = console.DiscardCurrentState(); 1390 if (console.isOk()) 1491 1391 { 1492 /* show the progress dialog */ 1493 vboxProblem() 1494 .showModalProgressDialog (progress, 1495 cmachine.GetName(), 1496 this); 1392 /* Show the progress dialog */ 1393 vboxProblem().showModalProgressDialog (progress, machine.GetName(), this); 1497 1394 if (progress.GetResultCode() != 0) 1498 vboxProblem() 1499 .cannotDiscardCurrentState (progress); 1395 vboxProblem().cannotDiscardCurrentState (progress); 1500 1396 } 1501 1397 else 1502 vboxProblem().cannotDiscardCurrentState (c console);1398 vboxProblem().cannotDiscardCurrentState (console); 1503 1399 } 1504 1400 } … … 1507 1403 if (success) 1508 1404 { 1509 /* accept the close action on success */1510 e->accept();1405 /* Accept the close action on success */ 1406 aEvent->accept(); 1511 1407 } 1512 1408 1513 1409 if (success || wasShutdown) 1514 1410 { 1515 /* read the last user's choice for the given VM */ 1516 QStringList prevAction = 1517 cmachine.GetExtraData (VBoxDefs::GUI_LastCloseAction).split (','); 1518 /* memorize the last user's choice for the given VM */ 1411 /* Read the last user's choice for the given VM */ 1412 QStringList prevAction = machine.GetExtraData (VBoxDefs::GUI_LastCloseAction).split (','); 1413 /* Memorize the last user's choice for the given VM */ 1519 1414 QString lastAction = kPowerOff; 1520 1415 if (dlg.mRbSave->isChecked()) 1521 1416 lastAction = kSave; 1522 1417 else if (dlg.mRbShutdown->isChecked() || 1523 (dlg.mRbPowerOff->isChecked() && 1524 prevAction [0] == kShutdown && 1525 !isACPIEnabled)) 1418 (dlg.mRbPowerOff->isChecked() && prevAction [0] == kShutdown && !isACPIEnabled)) 1526 1419 lastAction = kShutdown; 1527 1420 else if (dlg.mRbPowerOff->isChecked()) … … 1531 1424 if (dlg.mCbDiscardCurState->isChecked()) 1532 1425 (lastAction += ",") += kDiscardCurState; 1533 cmachine.SetExtraData (VBoxDefs::GUI_LastCloseAction, lastAction);1534 AssertWrapperOk ( cmachine);1426 machine.SetExtraData (VBoxDefs::GUI_LastCloseAction, lastAction); 1427 AssertWrapperOk (machine); 1535 1428 } 1536 1429 } 1537 1430 } 1538 1431 1539 no_auto_close = false; 1540 1541 if (machine_state < KMachineState_Running) 1542 { 1543 /* 1544 * the machine has been stopped while showing the Close or the Pause 1545 * failure dialog -- accept the close event immediately 1546 */ 1547 e->accept(); 1432 mNoAutoClose = false; 1433 1434 if (mMachineState < KMachineState_Running) 1435 { 1436 /* The machine has been stopped while showing the Close or the Pause 1437 * failure dialog -- accept the close event immediately. */ 1438 aEvent->accept(); 1548 1439 } 1549 1440 else … … 1551 1442 if (!success) 1552 1443 { 1553 /* restore the running state if needed */1554 if (!wasPaused && m achine_state == KMachineState_Paused)1555 console->pause (false);1444 /* Restore the running state if needed */ 1445 if (!wasPaused && mMachineState == KMachineState_Paused) 1446 mConsole->pause (false); 1556 1447 } 1557 1448 } 1558 1449 } 1559 1450 1560 if ( e->isAccepted())1451 if (aEvent->isAccepted()) 1561 1452 { 1562 1453 #ifndef VBOX_GUI_SEPARATE_VM_PROCESS … … 1565 1456 1566 1457 /* Stop LED update timer */ 1567 idle_timer->stop();1568 idle_timer->disconnect (SIGNAL (timeout()), this, SLOT (updateDeviceLights()));1458 mIdleTimer->stop(); 1459 mIdleTimer->disconnect (SIGNAL (timeout()), this, SLOT (updateDeviceLights())); 1569 1460 1570 1461 /* Hide console window */ … … 1572 1463 1573 1464 /* Save the position of the window and some options */ 1574 CMachine machine = csession.GetMachine();1465 CMachine machine = mSession.GetMachine(); 1575 1466 QString winPos = QString ("%1,%2,%3,%4") 1576 1467 .arg (mNormalGeo.x()).arg (mNormalGeo.y()) 1577 1468 .arg (mNormalGeo.width()).arg (mNormalGeo.height()); 1578 if (isWindowMaximized() || (mIsFullscreen && was_max) 1579 || (mIsSeamless && was_max)) 1469 if (isWindowMaximized() || (mIsFullscreen && mWasMax) || (mIsSeamless && mWasMax)) 1580 1470 winPos += QString (",%1").arg (VBoxDefs::GUI_LastWindowPosition_Max); 1581 1471 … … 1603 1493 } 1604 1494 1605 LogFlowFunc (("accepted=%d\n", e->isAccepted()));1495 LogFlowFunc (("accepted=%d\n", aEvent->isAccepted())); 1606 1496 LogFlowFuncLeave(); 1607 1497 } 1608 1498 1609 #if defined(Q_WS_X11)1610 bool VBoxConsoleWnd::x11Event (XEvent * event)1611 { 1612 / /Qt bug: when the console view grabs the keyboard, FocusIn, FocusOut,1613 //WindowActivate and WindowDeactivate Qt events are not properly sent1614 //on top level window (i.e. this) deactivation. The fix is to substiute1615 //the mode in FocusOut X11 event structure to NotifyNormal to cause1616 // Qt to process it as desired.1617 if ( console && event->type == FocusOut)1618 { 1619 if ( event->xfocus.mode == NotifyWhileGrabbed &&1620 ( event->xfocus.detail == NotifyAncestor ||1621 event->xfocus.detail == NotifyInferior ||1622 event->xfocus.detail == NotifyNonlinear))1623 { 1624 event->xfocus.mode = NotifyNormal;1499 #ifdef Q_WS_X11 1500 bool VBoxConsoleWnd::x11Event (XEvent *aEvent) 1501 { 1502 /* Qt bug: when the console view grabs the keyboard, FocusIn, FocusOut, 1503 * WindowActivate and WindowDeactivate Qt events are not properly sent 1504 * on top level window (i.e. this) deactivation. The fix is to substiute 1505 * the mode in FocusOut X11 event structure to NotifyNormal to cause 1506 * Qt to process it as desired. */ 1507 if (mConsole && aEvent->type == FocusOut) 1508 { 1509 if (aEvent->xfocus.mode == NotifyWhileGrabbed && 1510 (aEvent->xfocus.detail == NotifyAncestor || 1511 aEvent->xfocus.detail == NotifyInferior || 1512 aEvent->xfocus.detail == NotifyNonlinear)) 1513 { 1514 aEvent->xfocus.mode = NotifyNormal; 1625 1515 } 1626 1516 } 1627 1517 return false; 1628 1518 } 1629 #endif1630 1631 #ifdef Q_WS_MAC1632 extern void qt_set_sequence_auto_mnemonic (bool on);1633 1519 #endif 1634 1520 … … 1640 1526 { 1641 1527 #ifdef VBOX_OSE 1642 caption_prefix = tr ("VirtualBox OSE");1528 mCaptionPrefix = tr ("VirtualBox OSE"); 1643 1529 #else 1644 caption_prefix = tr ("Sun VirtualBox");1530 mCaptionPrefix = tr ("Sun VirtualBox"); 1645 1531 #endif 1646 1532 1647 1533 #ifdef VBOX_BLEEDING_EDGE 1648 caption_prefix += tr (" EXPERIMENTAL build %1r%2 - %3").arg (RTBldCfgVersion()).arg (RTBldCfgRevisionStr()).arg (VBOX_BLEEDING_EDGE);1534 mCaptionPrefix += tr (" EXPERIMENTAL build %1r%2 - %3").arg (RTBldCfgVersion()).arg (RTBldCfgRevisionStr()).arg (VBOX_BLEEDING_EDGE); 1649 1535 #endif 1650 1536 /* … … 1661 1547 1662 1548 /* VM actions */ 1663 1664 1549 #ifdef Q_WS_MAC 1665 1550 qt_set_sequence_auto_mnemonic (false); 1666 1551 #endif 1667 1552 1553 mVmDisMouseIntegrMenu->setToolTip (tr ("Mouse Integration", "enable/disable...")); 1554 #if 0 /* TODO: Allow to setup status-bar! */ 1555 mVmAutoresizeMenu->setToolTip (tr ("Auto-resize Guest Display", "enable/disable...")); 1556 #endif 1557 1668 1558 mVmFullscreenAction->setText (VBoxGlobal::insertKeyToActionText (tr ("&Fullscreen Mode"), "F")); 1669 1559 mVmFullscreenAction->setStatusTip (tr ("Switch to fullscreen mode" )); … … 1672 1562 mVmSeamlessAction->setStatusTip (tr ("Switch to seamless desktop integration mode")); 1673 1563 1674 mVmDisMouseIntegrMenu->setToolTip (tr ("Mouse Integration", 1675 "enable/disable...")); 1676 mVmAutoresizeMenu->setToolTip (tr ("Auto-resize Guest Display", 1677 "enable/disable...")); 1678 mVmAutoresizeGuestAction->setText (VBoxGlobal::insertKeyToActionText (tr ("Auto-resize &Guest Display"), 1679 "G")); 1680 mVmAutoresizeGuestAction->setStatusTip ( 1681 tr ("Automatically resize the guest display when the window is resized " 1682 "(requires Guest Additions)")); 1564 mVmAutoresizeGuestAction->setText (VBoxGlobal::insertKeyToActionText (tr ("Auto-resize &Guest Display"), "G")); 1565 mVmAutoresizeGuestAction->setStatusTip (tr ("Automatically resize the guest display when the " 1566 "window is resized (requires Guest Additions)")); 1683 1567 1684 1568 mVmAdjustWindowAction->setText (VBoxGlobal::insertKeyToActionText (tr ("&Adjust Window Size"), "A")); 1685 mVmAdjustWindowAction->setStatusTip ( 1686 tr ("Adjust window size and position to best fit the guest display")); 1569 mVmAdjustWindowAction->setStatusTip (tr ("Adjust window size and position to best fit the guest display")); 1570 1571 /* mVmDisableMouseIntegrAction is set up in updateAppearanceOf() */ 1687 1572 1688 1573 mVmTypeCADAction->setText (VBoxGlobal::insertKeyToActionText (tr ("&Insert Ctrl-Alt-Del"), "Del")); 1689 mVmTypeCADAction->setStatusTip ( 1690 tr ("Send the Ctrl-Alt-Del sequence to the virtual machine")); 1574 mVmTypeCADAction->setStatusTip (tr ("Send the Ctrl-Alt-Del sequence to the virtual machine")); 1691 1575 1692 1576 #if defined(Q_WS_X11) 1693 mVmTypeCABSAction->setText (VBoxGlobal::insertKeyToActionText (tr ("&Insert Ctrl-Alt-Backspace"), 1694 "Backspace")); 1695 mVmTypeCABSAction->setStatusTip ( 1696 tr ("Send the Ctrl-Alt-Backspace sequence to the virtual machine")); 1697 #endif 1577 mVmTypeCABSAction->setText (VBoxGlobal::insertKeyToActionText (tr ("&Insert Ctrl-Alt-Backspace"), "Backspace")); 1578 mVmTypeCABSAction->setStatusTip (tr ("Send the Ctrl-Alt-Backspace sequence to the virtual machine")); 1579 #endif 1580 1581 mVmTakeSnapshotAction->setText (VBoxGlobal::insertKeyToActionText (tr ("Take &Snapshot..."), "S")); 1582 mVmTakeSnapshotAction->setStatusTip (tr ("Take a snapshot of the virtual machine")); 1583 1584 mVmShowInformationDlgAction->setText (VBoxGlobal::insertKeyToActionText (tr ("Session I&nformation Dialog"), "N")); 1585 mVmShowInformationDlgAction->setStatusTip (tr ("Show Session Information Dialog")); 1698 1586 1699 1587 mVmResetAction->setText (VBoxGlobal::insertKeyToActionText (tr ("&Reset"), "R")); … … 1708 1596 mVmACPIShutdownAction->setText (VBoxGlobal::insertKeyToActionText (tr ("ACPI S&hutdown"), "H")); 1709 1597 #endif /* !Q_WS_MAC */ 1710 mVmACPIShutdownAction->setStatusTip ( 1711 tr ("Send the ACPI Power Button press event to the virtual machine")); 1598 mVmACPIShutdownAction->setStatusTip (tr ("Send the ACPI Power Button press event to the virtual machine")); 1712 1599 1713 1600 mVmCloseAction->setText (VBoxGlobal::insertKeyToActionText (tr ("&Close..." ), "Q")); … … 1715 1602 mVmCloseAction->setMenuRole (QAction::QuitRole); 1716 1603 1717 mVmTakeSnapshotAction->setText (VBoxGlobal::insertKeyToActionText (tr ("Take &Snapshot..."), "S"));1718 mVmTakeSnapshotAction->setStatusTip (tr ("Take a snapshot of the virtual machine"));1719 1720 mVmShowInformationDlgAction->setText (VBoxGlobal::insertKeyToActionText (tr ("Session I&nformation Dialog"),1721 "N"));1722 mVmShowInformationDlgAction->setStatusTip (tr ("Show Session Information Dialog"));1723 1724 /* mVmDisableMouseIntegrAction is set up in updateAppearanceOf() */1725 1726 1604 /* Devices actions */ 1727 1728 mDevicesMountFloppyImageAction->setText (tr ("&Floppy Image...")); 1729 mDevicesMountFloppyImageAction->setStatusTip (tr ("Mount a floppy image file")); 1730 1731 mDevicesUnmountFloppyAction->setText (tr ("Unmount F&loppy")); 1732 mDevicesUnmountFloppyAction->setStatusTip ( 1733 tr ("Unmount the currently mounted floppy media")); 1734 1735 mDevicesMountDVDImageAction->setText (tr ("&CD/DVD-ROM Image...")); 1736 mDevicesMountDVDImageAction->setStatusTip ( 1737 tr ("Mount a CD/DVD-ROM image file")); 1738 1739 mDevicesUnmountDVDAction->setText (tr ("Unmount C&D/DVD-ROM")); 1740 mDevicesUnmountDVDAction->setStatusTip ( 1741 tr ("Unmount the currently mounted CD/DVD-ROM media")); 1742 1743 /* mDevicesVRDPMenu->setToolTip (tr ("Remote Desktop (RDP) Server", 1744 "enable/disable...")); */ 1605 mDevicesStorageDialogAction->setText (tr ("&Storage Devices...")); 1606 mDevicesStorageDialogAction->setStatusTip (tr ("Open the dialog to change settings of the storage devices")); 1607 1608 mDevicesNetworkDialogAction->setText (tr ("&Network Adapters...")); 1609 mDevicesNetworkDialogAction->setStatusTip (tr ("Open the dialog to change settings of the network adapters")); 1610 1611 mDevicesSFDialogAction->setText (tr ("&Shared Folders...")); 1612 mDevicesSFDialogAction->setStatusTip (tr ("Open the dialog to operate on shared folders")); 1613 1745 1614 mDevicesSwitchVrdpAction->setText (tr ("Remote Dis&play")); 1746 mDevicesSwitchVrdpAction->setStatusTip ( 1747 tr ("Enable or disable remote desktop (RDP) connections to this machine")); 1748 1749 mDevicesNetworkDialogAction->setText (tr ("&Network Adapters...")); 1750 mDevicesNetworkDialogAction->setStatusTip ( 1751 tr ("Open the dialog to change settings of the Network Adapters")); 1752 1753 mDevicesSFDialogAction->setText (tr ("&Shared Folders...")); 1754 mDevicesSFDialogAction->setStatusTip ( 1755 tr ("Open the dialog to operate on shared folders")); 1756 1757 mDevicesInstallGuestToolsAction->setText (VBoxGlobal::insertKeyToActionText (tr ("&Install Guest Additions..."), 1758 "D")); 1759 mDevicesInstallGuestToolsAction->setStatusTip ( 1760 tr ("Mount the Guest Additions installation image")); 1615 mDevicesSwitchVrdpAction->setStatusTip (tr ("Enable or disable remote desktop (RDP) connections to this machine")); 1616 #if 0 /* TODO: Allow to setup status-bar! */ 1617 mDevicesVRDPMenu->setToolTip (tr ("Remote Desktop (RDP) Server", "enable/disable...")); 1618 #endif 1619 1620 mDevicesInstallGuestToolsAction->setText (VBoxGlobal::insertKeyToActionText (tr ("&Install Guest Additions..."), "D")); 1621 mDevicesInstallGuestToolsAction->setStatusTip (tr ("Mount the Guest Additions installation image")); 1622 1623 mDevicesUSBMenu->setTitle (tr ("&USB Devices")); 1761 1624 1762 1625 #ifdef VBOX_WITH_DEBUGGER_GUI 1763 1626 /* Debug actions */ 1764 1765 1627 if (mDbgStatisticsAction) 1766 1628 mDbgStatisticsAction->setText (tr ("&Statistics...", "debug action")); … … 1772 1634 1773 1635 /* Help actions */ 1774 1775 1636 mHelpActions.retranslateUi(); 1776 1637 1777 /* Devices menu submenus */ 1778 1779 mDevicesMountFloppyMenu->setTitle (tr ("Mount &Floppy")); 1780 mDevicesMountDVDMenu->setTitle (tr ("Mount &CD/DVD-ROM")); 1781 mDevicesUSBMenu->setTitle (tr ("&USB Devices")); 1782 1783 /* main menu & seamless popup menu */ 1784 1638 /* Main menu & seamless popup menu */ 1785 1639 mVMMenu->setTitle (tr ("&Machine")); 1786 //mVMMenu->setIcon (VBoxGlobal::iconSet (":/machine_16px.png"));1787 1788 m MiniVMMenu->setTitle (tr ("&Machine"));1640 // mVMMenu->setIcon (VBoxGlobal::iconSet (":/machine_16px.png")); 1641 1642 mVMMenuMini->setTitle (tr ("&Machine")); 1789 1643 1790 1644 mDevicesMenu->setTitle (tr ("&Devices")); 1791 //mDevicesMenu->setIcon (VBoxGlobal::iconSet (":/settings_16px.png"));1645 // mDevicesMenu->setIcon (VBoxGlobal::iconSet (":/settings_16px.png")); 1792 1646 1793 1647 #ifdef VBOX_WITH_DEBUGGER_GUI … … 1796 1650 #endif 1797 1651 mHelpMenu->setTitle (tr ("&Help")); 1798 // mHelpMenu->setIcon (VBoxGlobal::iconSet (":/help_16px.png")); 1799 1800 /* status bar widgets */ 1801 1802 #if 0 1803 autoresize_state->setToolTip ( 1804 tr ("Indicates whether the guest display auto-resize function is On " 1805 "(<img src=:/auto_resize_on_16px.png/>) or Off (<img src=:/auto_resize_off_16px.png/>). " 1806 "Note that this function requires Guest Additions to be installed in the guest OS.")); 1807 #endif 1808 mouse_state->setToolTip ( 1652 // mHelpMenu->setIcon (VBoxGlobal::iconSet (":/help_16px.png")); 1653 1654 /* Status bar widgets */ 1655 mMouseLed->setToolTip ( 1809 1656 tr ("Indicates whether the host mouse pointer is captured by the guest OS:<br>" 1810 1657 "<nobr><img src=:/mouse_disabled_16px.png/> pointer is not captured</nobr><br>" … … 1814 1661 "<nobr><img src=:/mouse_can_seamless_uncaptured_16px.png/> MI is Off, pointer is not captured</nobr><br>" 1815 1662 "Note that the mouse integration feature requires Guest Additions to be installed in the guest OS.")); 1816 hostkey_state->setToolTip (1663 mHostkeyLed->setToolTip ( 1817 1664 tr ("Indicates whether the keyboard is captured by the guest OS " 1818 1665 "(<img src=:/hostkey_captured_16px.png/>) or not (<img src=:/hostkey_16px.png/>).")); 1819 hostkey_name->setToolTip (1666 mHostkeyName->setToolTip ( 1820 1667 tr ("Shows the currently assigned Host key.<br>" 1821 1668 "This key, when pressed alone, toggles the keyboard and mouse " 1822 1669 "capture state. It can also be used in combination with other keys " 1823 1670 "to quickly perform actions from the main menu.")); 1824 hostkey_name->setText (QIHotKeyEdit::keyName (vboxGlobal().settings().hostKey())); 1671 mHostkeyName->setText (QIHotKeyEdit::keyName (vboxGlobal().settings().hostKey())); 1672 1673 #if 0 /* TODO: Allow to setup status-bar! */ 1674 mAutoresizeLed->setToolTip ( 1675 tr ("Indicates whether the guest display auto-resize function is On " 1676 "(<img src=:/auto_resize_on_16px.png/>) or Off (<img src=:/auto_resize_off_16px.png/>). " 1677 "Note that this function requires Guest Additions to be installed in the guest OS.")); 1678 #endif 1825 1679 1826 1680 updateAppearanceOf (AllStuff); 1827 1681 } 1828 1682 1829 // 1830 // Private members 1831 ///////////////////////////////////////////////////////////////////////////// 1832 1833 void VBoxConsoleWnd::updateAppearanceOf (int element) 1834 { 1835 if (!console) return; 1836 1837 CMachine cmachine = csession.GetMachine(); 1838 CConsole cconsole = console->console(); 1839 1840 bool isRunningOrPaused = machine_state == KMachineState_Running || 1841 machine_state == KMachineState_Paused; 1842 1843 if (element & Caption) 1683 void VBoxConsoleWnd::finalizeOpenView() 1684 { 1685 LogFlowFuncEnter(); 1686 1687 /* Notify the console scroll-view about the console-window is opened. */ 1688 mConsole->onViewOpened(); 1689 1690 bool saved = mMachineState == KMachineState_Saved; 1691 1692 CMachine machine = mSession.GetMachine(); 1693 CConsole console = mConsole->console(); 1694 1695 if (mIsFirstTimeStarted) 1696 { 1697 VBoxVMFirstRunWzd wzd (machine, this); 1698 wzd.exec(); 1699 1700 /* Remove GUI_FirstRun extra data key from the machine settings 1701 * file after showing the wizard once. */ 1702 machine.SetExtraData (VBoxDefs::GUI_FirstRun, QString::null); 1703 } 1704 1705 /* Start the VM */ 1706 CProgress progress = vboxGlobal().isStartPausedEnabled() || vboxGlobal().isDebuggerAutoShowEnabled() ? 1707 console.PowerUpPaused() : console.PowerUp(); 1708 1709 /* Check for an immediate failure */ 1710 if (!console.isOk()) 1711 { 1712 vboxProblem().cannotStartMachine (console); 1713 /* close this window (this will call closeView()) */ 1714 close(); 1715 1716 LogFlowFunc (("Error starting VM\n")); 1717 LogFlowFuncLeave(); 1718 return; 1719 } 1720 1721 mConsole->attach(); 1722 1723 /* Disable auto closure because we want to have a chance to show the 1724 * error dialog on startup failure */ 1725 mNoAutoClose = true; 1726 1727 /* show the "VM starting / restoring" progress dialog */ 1728 1729 if (saved) 1730 vboxProblem().showModalProgressDialog (progress, machine.GetName(), this, 0); 1731 else 1732 vboxProblem().showModalProgressDialog (progress, machine.GetName(), this); 1733 1734 if (progress.GetResultCode() != 0) 1735 { 1736 vboxProblem().cannotStartMachine (progress); 1737 /* close this window (this will call closeView()) */ 1738 close(); 1739 1740 LogFlowFunc (("Error starting VM\n")); 1741 LogFlowFuncLeave(); 1742 return; 1743 } 1744 1745 mNoAutoClose = false; 1746 1747 /* Check if we missed a really quick termination after successful 1748 * startup, and process it if we did. */ 1749 if (mMachineState < KMachineState_Running) 1750 { 1751 close(); 1752 LogFlowFuncLeave(); 1753 return; 1754 } 1755 1756 /* Currently the machine is started and the guest API could be used... 1757 * Checking if the fullscreen mode should be activated */ 1758 QString str = machine.GetExtraData (VBoxDefs::GUI_Fullscreen); 1759 if (str == "on") 1760 mVmFullscreenAction->setChecked (true); 1761 1762 /* If seamless mode should be enabled then check if it is enabled 1763 * currently and re-enable it if seamless is supported */ 1764 if (mVmSeamlessAction->isChecked() && mIsSeamlessSupported && mIsGraphicsSupported) 1765 toggleFullscreenMode (true, true); 1766 #ifdef VBOX_WITH_DEBUGGER_GUI 1767 /* Open the debugger in "full screen" mode requested by the user. */ 1768 else if (vboxGlobal().isDebuggerAutoShowEnabled()) 1769 { 1770 /* console in upper left corner of the desktop. */ 1771 QRect rct (0, 0, 0, 0); 1772 QDesktopWidget *desktop = QApplication::desktop(); 1773 if (desktop) 1774 rct = desktop->availableGeometry(pos()); 1775 move (QPoint (rct.x(), rct.y())); 1776 1777 if (vboxGlobal().isDebuggerAutoShowStatisticsEnabled()) 1778 dbgShowStatistics(); 1779 if (vboxGlobal().isDebuggerAutoShowCommandLineEnabled()) 1780 dbgShowCommandLine(); 1781 1782 if (!vboxGlobal().isStartPausedEnabled()) 1783 mConsole->pause (false); 1784 } 1785 #endif 1786 1787 mIsOpenViewFinished = true; 1788 LogFlowFuncLeave(); 1789 1790 #ifdef VBOX_WITH_UPDATE_REQUEST 1791 vboxGlobal().showUpdateDialog (false /* aForce */); 1792 #endif 1793 1794 /* Finally check the status of required features. */ 1795 checkRequiredFeatures(); 1796 1797 /* Re-request all the static values finally after 1798 * view is really opened and attached. */ 1799 updateAppearanceOf (VirtualizationStuff); 1800 } 1801 1802 /** 1803 * Helper to safely close the main console window. 1804 * 1805 * This method ensures that close() will not be called if there is some 1806 * modal widget currently being executed, as it can cause uninitialization 1807 * at the point of code where it is not expected at all (example: 1808 * VBoxConsoleView::mouseEvent() calling 1809 * VBoxProblemReporter::confirmInputCapture()). Instead, an attempt to 1810 * close the current modal widget is done and tryClose() is rescheduled for 1811 * later execution using a single-shot zero timer. 1812 * 1813 * In particular, this method is used by updateMachineState() when the VM 1814 * goes offline, which can even happen if we are inside the modal event loop, 1815 * (for example, the VM has been externally powered off or the guest OS 1816 * has initiated a shutdown procedure). 1817 */ 1818 void VBoxConsoleWnd::tryClose() 1819 { 1820 /* First close any open modal & popup widgets. Use a single shot with 1821 * timeout 0 to allow the widgets to cleany close and test then again. If 1822 * all open widgets are closed destroy ourself. */ 1823 QWidget *widget = QApplication::activeModalWidget() ? 1824 QApplication::activeModalWidget() : 1825 QApplication::activePopupWidget() ? 1826 QApplication::activePopupWidget() : 0; 1827 if (widget) 1828 { 1829 widget->close(); 1830 QTimer::singleShot (0, this, SLOT (tryClose())); 1831 } 1832 else 1833 close(); 1834 } 1835 1836 void VBoxConsoleWnd::vmFullscreen (bool aOn) 1837 { 1838 bool ok = toggleFullscreenMode (aOn, false /* aSeamless */); 1839 if (!ok) 1840 { 1841 /* On failure, restore the previous button state */ 1842 mVmFullscreenAction->blockSignals (true); 1843 mVmFullscreenAction->setChecked (!aOn); 1844 mVmFullscreenAction->blockSignals (false); 1845 } 1846 } 1847 1848 void VBoxConsoleWnd::vmSeamless (bool aOn) 1849 { 1850 /* Check if it is possible to enter/leave seamless mode */ 1851 if ((mIsSeamlessSupported && mIsGraphicsSupported) || !aOn) 1852 { 1853 bool ok = toggleFullscreenMode (aOn, true /* aSeamless */); 1854 if (!ok) 1855 { 1856 /* On failure, restore the previous button state */ 1857 mVmSeamlessAction->blockSignals (true); 1858 mVmSeamlessAction->setChecked (!aOn); 1859 mVmSeamlessAction->blockSignals (false); 1860 } 1861 } 1862 } 1863 1864 void VBoxConsoleWnd::vmAutoresizeGuest (bool on) 1865 { 1866 if (!mConsole) 1867 return; 1868 1869 #if 0 /* TODO: Allow to setup status-bar! */ 1870 mAutoresizeLed->setState (on ? 3 : 1); 1871 #endif 1872 1873 mConsole->setAutoresizeGuest (on); 1874 } 1875 1876 void VBoxConsoleWnd::vmAdjustWindow() 1877 { 1878 if (mConsole) 1879 { 1880 if (isWindowMaximized()) 1881 showNormal(); 1882 mConsole->normalizeGeometry (true /* adjustPosition */); 1883 } 1884 } 1885 1886 void VBoxConsoleWnd::vmDisableMouseIntegration (bool aOff) 1887 { 1888 if (mConsole) 1889 { 1890 mConsole->setMouseIntegrationEnabled (!aOff); 1891 updateAppearanceOf (DisableMouseIntegrAction); 1892 } 1893 } 1894 1895 void VBoxConsoleWnd::vmTypeCAD() 1896 { 1897 if (mConsole) 1898 { 1899 CKeyboard keyboard = mConsole->console().GetKeyboard(); 1900 Assert (!keyboard.isNull()); 1901 keyboard.PutCAD(); 1902 AssertWrapperOk (keyboard); 1903 } 1904 } 1905 1906 #ifdef Q_WS_X11 1907 void VBoxConsoleWnd::vmTypeCABS() 1908 { 1909 if (mConsole) 1910 { 1911 CKeyboard keyboard = mConsole->console().GetKeyboard(); 1912 Assert (!keyboard.isNull()); 1913 static QVector <LONG> sSequence (6); 1914 sSequence[0] = 0x1d; // Ctrl down 1915 sSequence[1] = 0x38; // Alt down 1916 sSequence[2] = 0x0E; // Backspace down 1917 sSequence[3] = 0x8E; // Backspace up 1918 sSequence[4] = 0xb8; // Alt up 1919 sSequence[5] = 0x9d; // Ctrl up 1920 keyboard.PutScancodes (sSequence); 1921 AssertWrapperOk (keyboard); 1922 } 1923 } 1924 #endif 1925 1926 void VBoxConsoleWnd::vmTakeSnapshot() 1927 { 1928 AssertReturn (mConsole, (void) 0); 1929 1930 /* remember the paused state */ 1931 bool wasPaused = mMachineState == KMachineState_Paused; 1932 if (!wasPaused) 1933 { 1934 /* Suspend the VM and ignore the close event if failed to do so. 1935 * pause() will show the error message to the user. */ 1936 if (!mConsole->pause (true)) 1937 return; 1938 } 1939 1940 CMachine machine = mSession.GetMachine(); 1941 1942 VBoxTakeSnapshotDlg dlg (this); 1943 1944 QString typeId = machine.GetOSTypeId(); 1945 dlg.mLbIcon->setPixmap (vboxGlobal().vmGuestOSTypeIcon (typeId)); 1946 1947 /* search for the max available filter index */ 1948 int maxSnapShotIndex = 0; 1949 QString snapShotName = tr ("Snapshot %1"); 1950 QRegExp regExp (QString ("^") + snapShotName.arg ("([0-9]+)") + QString ("$")); 1951 CSnapshot index = machine.GetSnapshot (QString::null); 1952 while (!index.isNull()) 1953 { 1954 /* Check the current snapshot name */ 1955 QString name = index.GetName(); 1956 int pos = regExp.indexIn (name); 1957 if (pos != -1) 1958 maxSnapShotIndex = regExp.cap (1).toInt() > maxSnapShotIndex ? 1959 regExp.cap (1).toInt() : maxSnapShotIndex; 1960 /* Traversing to the next child */ 1961 CSnapshotVector c = index.GetChildren(); 1962 if (c.size() > 0) 1963 index = c [0]; 1964 else 1965 break; 1966 } 1967 dlg.mLeName->setText (snapShotName.arg (maxSnapShotIndex + 1)); 1968 1969 if (dlg.exec() == QDialog::Accepted) 1970 { 1971 CConsole console = mSession.GetConsole(); 1972 1973 CProgress progress = console.TakeSnapshot (dlg.mLeName->text().trimmed(), dlg.mTeDescription->toPlainText()); 1974 1975 if (console.isOk()) 1976 { 1977 /* Show the "Taking Snapshot" progress dialog */ 1978 vboxProblem().showModalProgressDialog (progress, machine.GetName(), this, 0); 1979 1980 if (progress.GetResultCode() != 0) 1981 vboxProblem().cannotTakeSnapshot (progress); 1982 } 1983 else 1984 vboxProblem().cannotTakeSnapshot (console); 1985 } 1986 1987 /* Restore the running state if needed */ 1988 if (!wasPaused) 1989 mConsole->pause (false); 1990 } 1991 1992 void VBoxConsoleWnd::vmShowInfoDialog() 1993 { 1994 VBoxVMInformationDlg::createInformationDlg (mSession, mConsole); 1995 } 1996 1997 void VBoxConsoleWnd::vmReset() 1998 { 1999 if (mConsole) 2000 { 2001 if (vboxProblem().confirmVMReset (this)) 2002 mConsole->console().Reset(); 2003 } 2004 } 2005 2006 void VBoxConsoleWnd::vmPause (bool aOn) 2007 { 2008 if (mConsole) 2009 { 2010 mConsole->pause (aOn); 2011 updateAppearanceOf (PauseAction); 2012 } 2013 } 2014 2015 void VBoxConsoleWnd::vmACPIShutdown() 2016 { 2017 if (!mSession.GetConsole().GetGuestEnteredACPIMode()) 2018 return vboxProblem().cannotSendACPIToMachine(); 2019 2020 if (mConsole) 2021 { 2022 CConsole console = mConsole->console(); 2023 console.PowerButton(); 2024 if (!console.isOk()) 2025 vboxProblem().cannotACPIShutdownMachine (console); 2026 } 2027 } 2028 2029 void VBoxConsoleWnd::vmClose() 2030 { 2031 if (mConsole) 2032 close(); 2033 } 2034 2035 void VBoxConsoleWnd::devicesSwitchVrdp (bool aOn) 2036 { 2037 if (!mConsole) return; 2038 2039 CVRDPServer vrdpServer = mSession.GetMachine().GetVRDPServer(); 2040 /* This method should not be executed if vrdpServer is null */ 2041 Assert (!vrdpServer.isNull()); 2042 2043 vrdpServer.SetEnabled (aOn); 2044 updateAppearanceOf (VRDPStuff); 2045 } 2046 2047 void VBoxConsoleWnd::devicesOpenStorageDialog() 2048 { 2049 if (!mConsole) return; 2050 2051 VBoxStorageDialog dlg (mConsole, mSession); 2052 dlg.exec(); 2053 } 2054 2055 void VBoxConsoleWnd::devicesOpenNetworkDialog() 2056 { 2057 if (!mConsole) return; 2058 2059 VBoxNetworkDialog dlg (mConsole, mSession); 2060 dlg.exec(); 2061 } 2062 2063 void VBoxConsoleWnd::devicesOpenSFDialog() 2064 { 2065 if (!mConsole) return; 2066 2067 VBoxSFDialog dlg (mConsole, mSession); 2068 dlg.exec(); 2069 } 2070 2071 void VBoxConsoleWnd::devicesInstallGuestAdditions() 2072 { 2073 char szAppPrivPath [RTPATH_MAX]; 2074 int rc = RTPathAppPrivateNoArch (szAppPrivPath, sizeof (szAppPrivPath)); 2075 AssertRC (rc); 2076 2077 QString src1 = QString (szAppPrivPath) + "/VBoxGuestAdditions.iso"; 2078 QString src2 = qApp->applicationDirPath() + "/additions/VBoxGuestAdditions.iso"; 2079 2080 /* Check the standard image locations */ 2081 if (QFile::exists (src1)) 2082 return installGuestAdditionsFrom (src1); 2083 else if (QFile::exists (src2)) 2084 return installGuestAdditionsFrom (src2); 2085 2086 /* Check for the already registered image */ 2087 CVirtualBox vbox = vboxGlobal().virtualBox(); 2088 QString name = QString ("VBoxGuestAdditions_%1.iso").arg (vbox.GetVersion().remove ("_OSE")); 2089 2090 CMediumVector vec = vbox.GetDVDImages(); 2091 for (CMediumVector::ConstIterator it = vec.begin(); it != vec.end(); ++ it) 2092 { 2093 QString path = it->GetLocation(); 2094 /* Compare the name part ignoring the file case */ 2095 QString fn = QFileInfo (path).fileName(); 2096 if (RTPathCompare (name.toUtf8().constData(), fn.toUtf8().constData()) == 0) 2097 return installGuestAdditionsFrom (path); 2098 } 2099 2100 /* Download the required image */ 2101 int result = vboxProblem().cannotFindGuestAdditions ( 2102 QDir::toNativeSeparators (src1), QDir::toNativeSeparators (src2)); 2103 if (result == QIMessageBox::Yes) 2104 { 2105 QString source = QString ("http://download.virtualbox.org/virtualbox/%1/") 2106 .arg (vbox.GetVersion().remove ("_OSE")) + name; 2107 QString target = QDir (vboxGlobal().virtualBox().GetHomeFolder()) 2108 .absoluteFilePath (name); 2109 2110 VBoxAdditionsDownloader *dl = 2111 new VBoxAdditionsDownloader (source, target, mDevicesInstallGuestToolsAction); 2112 statusBar()->addWidget (dl, 0); 2113 dl->start(); 2114 } 2115 } 2116 2117 void VBoxConsoleWnd::prepareStorageMenu() 2118 { 2119 mDevicesStorageMenu->clear(); 2120 mDevicesStorageMenu->addAction (mDevicesStorageDialogAction); 2121 } 2122 2123 void VBoxConsoleWnd::prepareNetworkMenu() 2124 { 2125 mDevicesNetworkMenu->clear(); 2126 mDevicesNetworkMenu->addAction (mDevicesNetworkDialogAction); 2127 } 2128 2129 void VBoxConsoleWnd::prepareSFMenu() 2130 { 2131 mDevicesSFMenu->clear(); 2132 mDevicesSFMenu->addAction (mDevicesSFDialogAction); 2133 } 2134 2135 /** 2136 * Attach/Detach selected USB Device. 2137 */ 2138 void VBoxConsoleWnd::switchUSB (QAction *aAction) 2139 { 2140 if (!mConsole) return; 2141 2142 CConsole console = mSession.GetConsole(); 2143 AssertWrapperOk (mSession); 2144 2145 CUSBDevice usb = mDevicesUSBMenu->getUSB (aAction); 2146 /* if null then some other item but a USB device is selected */ 2147 if (usb.isNull()) 2148 return; 2149 2150 if (!aAction->isChecked()) 2151 { 2152 console.DetachUSBDevice (usb.GetId()); 2153 if (!console.isOk()) 2154 { 2155 /// @todo (r=dmik) the dialog should be either modeless 2156 // or we have to pause the VM 2157 vboxProblem().cannotDetachUSBDevice (console, vboxGlobal().details (usb)); 2158 } 2159 } 2160 else 2161 { 2162 console.AttachUSBDevice (usb.GetId()); 2163 if (!console.isOk()) 2164 { 2165 /// @todo (r=dmik) the dialog should be either modeless 2166 // or we have to pause the VM 2167 vboxProblem().cannotAttachUSBDevice (console, vboxGlobal().details (usb)); 2168 } 2169 } 2170 } 2171 2172 void VBoxConsoleWnd::showIndicatorContextMenu (QIStateIndicator *aInd, QContextMenuEvent *aEvent) 2173 { 2174 if (aInd == mHDLed) 2175 { 2176 if (mDevicesStorageMenu->isEnabled()) 2177 { 2178 /* set "this is a context menu" flag */ 2179 mDevicesStorageMenu->menuAction()->setData (true); 2180 mDevicesStorageMenu->exec (aEvent->globalPos()); 2181 mDevicesStorageMenu->menuAction()->setData (false); 2182 } 2183 } 2184 else if (aInd == mCDLed) 2185 { 2186 if (mDevicesStorageMenu->isEnabled()) 2187 { 2188 /* set "this is a context menu" flag */ 2189 mDevicesStorageMenu->menuAction()->setData (true); 2190 mDevicesStorageMenu->exec (aEvent->globalPos()); 2191 mDevicesStorageMenu->menuAction()->setData (false); 2192 } 2193 } 2194 #if 0 /* TODO: Allow to setup status-bar! */ 2195 else if (aInd == mFDLed) 2196 { 2197 if (mDevicesStorageMenu->isEnabled()) 2198 { 2199 /* set "this is a context menu" flag */ 2200 mDevicesStorageMenu->menuAction()->setData (true); 2201 mDevicesStorageMenu->exec (aEvent->globalPos()); 2202 mDevicesStorageMenu->menuAction()->setData (false); 2203 } 2204 } 2205 #endif 2206 else if (aInd == mNetLed) 2207 { 2208 if (mDevicesNetworkMenu->isEnabled()) 2209 { 2210 mDevicesNetworkMenu->menuAction()->setData (true); 2211 mDevicesNetworkMenu->exec (aEvent->globalPos()); 2212 mDevicesNetworkMenu->menuAction()->setData (false); 2213 } 2214 } 2215 else if (aInd == mUSBLed) 2216 { 2217 if (mDevicesUSBMenu->isEnabled()) 2218 { 2219 /* set "this is a context menu" flag */ 2220 mDevicesUSBMenu->menuAction()->setData (true); 2221 mDevicesUSBMenu->exec (aEvent->globalPos()); 2222 mDevicesUSBMenu->menuAction()->setData (false); 2223 } 2224 } 2225 else if (aInd == mSFLed) 2226 { 2227 if (mDevicesSFMenu->isEnabled()) 2228 { 2229 mDevicesSFMenu->menuAction()->setData (true); 2230 mDevicesSFMenu->exec (aEvent->globalPos()); 2231 mDevicesSFMenu->menuAction()->setData (false); 2232 } 2233 } 2234 else if (aInd == mMouseLed) 2235 { 2236 mVmDisMouseIntegrMenu->exec (aEvent->globalPos()); 2237 } 2238 #if 0 /* TODO: Allow to setup status-bar! */ 2239 else if (aInd == mVrdpLed) 2240 { 2241 mDevicesVRDPMenu->exec (aEvent->globalPos()); 2242 } 2243 else if (aInd == mAutoresizeLed) 2244 { 2245 mVmAutoresizeMenu->exec (aEvent->globalPos()); 2246 } 2247 #endif 2248 } 2249 2250 void VBoxConsoleWnd::updateDeviceLights() 2251 { 2252 if (mConsole) 2253 { 2254 CConsole &console = mConsole->console(); 2255 int st; 2256 if (mHDLed->state() != KDeviceActivity_Null) 2257 { 2258 st = console.GetDeviceActivity (KDeviceType_HardDisk); 2259 if (mHDLed->state() != st) 2260 mHDLed->setState (st); 2261 } 2262 if (mCDLed->state() != KDeviceActivity_Null) 2263 { 2264 st = console.GetDeviceActivity (KDeviceType_DVD); 2265 if (mCDLed->state() != st) 2266 mCDLed->setState (st); 2267 } 2268 #if 0 /* TODO: Allow to setup status-bar! */ 2269 if (mFDLed->state() != KDeviceActivity_Null) 2270 { 2271 st = console.GetDeviceActivity (KDeviceType_Floppy); 2272 if (mFDLed->state() != st) 2273 mFDLed->setState (st); 2274 } 2275 #endif 2276 if (mNetLed->state() != KDeviceActivity_Null) 2277 { 2278 st = console.GetDeviceActivity (KDeviceType_Network); 2279 if (mNetLed->state() != st) 2280 mNetLed->setState (st); 2281 } 2282 if (mUSBLed->state() != KDeviceActivity_Null) 2283 { 2284 st = console.GetDeviceActivity (KDeviceType_USB); 2285 if (mUSBLed->state() != st) 2286 mUSBLed->setState (st); 2287 } 2288 if (mSFLed->state() != KDeviceActivity_Null) 2289 { 2290 st = console.GetDeviceActivity (KDeviceType_SharedFolder); 2291 if (mSFLed->state() != st) 2292 mSFLed->setState (st); 2293 } 2294 } 2295 } 2296 2297 void VBoxConsoleWnd::updateMachineState (KMachineState aState) 2298 { 2299 bool guruMeditation = false; 2300 2301 if (mConsole && mMachineState != aState) 2302 { 2303 if (aState >= KMachineState_Running) 2304 { 2305 switch (aState) 2306 { 2307 case KMachineState_Stuck: 2308 { 2309 guruMeditation = true; 2310 break; 2311 } 2312 case KMachineState_Paused: 2313 { 2314 if (!mVmPauseAction->isChecked()) 2315 mVmPauseAction->setChecked (true); 2316 break; 2317 } 2318 case KMachineState_Running: 2319 { 2320 if (mMachineState == KMachineState_Paused && mVmPauseAction->isChecked()) 2321 mVmPauseAction->setChecked (false); 2322 break; 2323 } 2324 #ifdef Q_WS_X11 2325 case KMachineState_Starting: 2326 { 2327 /* The keyboard handler may wish to do some release logging 2328 on startup. Tell it that the logger is now active. */ 2329 doXKeyboardLogging (QX11Info::display()); 2330 break; 2331 } 2332 #endif 2333 default: 2334 break; 2335 } 2336 } 2337 2338 bool isRunningOrPaused = aState == KMachineState_Running || aState == KMachineState_Paused; 2339 2340 /* Enable/Disable actions that are not managed by updateAppearanceOf() */ 2341 2342 mRunningActions->setEnabled (aState == KMachineState_Running); 2343 mRunningOrPausedActions->setEnabled (isRunningOrPaused); 2344 2345 mMachineState = aState; 2346 2347 updateAppearanceOf (Caption | 2348 HardDiskStuff | DVDStuff | FloppyStuff | 2349 NetworkStuff | USBStuff | VRDPStuff | 2350 PauseAction | DisableMouseIntegrAction); 2351 2352 if (aState < KMachineState_Running) 2353 { 2354 /* VM has been powered off or saved or aborted, no matter 2355 * internally or externally -- we must *safely* close the console 2356 * window unless auto closure is disabled. */ 2357 if (!mNoAutoClose) 2358 tryClose(); 2359 } 2360 } 2361 2362 if (guruMeditation) 2363 { 2364 CConsole console = mConsole->console(); 2365 QString logFolder = console.GetMachine().GetLogFolder(); 2366 2367 /* Take the screenshot for debugging purposes and save it */ 2368 QString fname = logFolder + "/VBox.png"; 2369 2370 CDisplay dsp = console.GetDisplay(); 2371 QImage shot = QImage (dsp.GetWidth(), dsp.GetHeight(), QImage::Format_RGB32); 2372 dsp.TakeScreenShot (shot.bits(), shot.width(), shot.height()); 2373 shot.save (QFile::encodeName (fname), "PNG"); 2374 2375 if (vboxProblem().remindAboutGuruMeditation (console, QDir::toNativeSeparators (logFolder))) 2376 { 2377 qApp->processEvents(); 2378 console.PowerDown(); 2379 if (!console.isOk()) 2380 vboxProblem().cannotStopMachine (console); 2381 } 2382 } 2383 2384 #ifdef Q_WS_MAC 2385 if (mConsole) 2386 mConsole->updateDockOverlay(); 2387 #endif 2388 } 2389 2390 void VBoxConsoleWnd::updateMouseState (int aState) 2391 { 2392 mVmDisableMouseIntegrAction->setEnabled (aState & VBoxConsoleView::MouseAbsolute); 2393 2394 if ((aState & VBoxConsoleView::MouseAbsoluteDisabled) && 2395 (aState & VBoxConsoleView::MouseAbsolute) && 2396 !(aState & VBoxConsoleView::MouseCaptured)) 2397 { 2398 mMouseLed->setState (4); 2399 } 2400 else 2401 { 2402 mMouseLed->setState (aState & (VBoxConsoleView::MouseAbsolute | VBoxConsoleView::MouseCaptured)); 2403 } 2404 } 2405 2406 void VBoxConsoleWnd::updateAdditionsState (const QString &aVersion, 2407 bool aActive, 2408 bool aSeamlessSupported, 2409 bool aGraphicsSupported) 2410 { 2411 mVmAutoresizeGuestAction->setEnabled (aActive && aGraphicsSupported); 2412 if ((mIsSeamlessSupported != aSeamlessSupported) || 2413 (mIsGraphicsSupported != aGraphicsSupported)) 2414 { 2415 mVmSeamlessAction->setEnabled (aSeamlessSupported && aGraphicsSupported); 2416 mIsSeamlessSupported = aSeamlessSupported; 2417 mIsGraphicsSupported = aGraphicsSupported; 2418 /* If seamless mode should be enabled then check if it is enabled 2419 * currently and re-enable it if open-view procedure is finished */ 2420 if (mVmSeamlessAction->isChecked() && mIsOpenViewFinished && aSeamlessSupported && aGraphicsSupported) 2421 toggleFullscreenMode (true, true); 2422 /* Disable auto-resizing if advanced graphics are not available */ 2423 mConsole->setAutoresizeGuest (mIsGraphicsSupported && mVmAutoresizeGuestAction->isChecked()); 2424 mVmAutoresizeGuestAction->setEnabled (mIsGraphicsSupported); 2425 } 2426 2427 /* Check the GA version only in case of additions are active */ 2428 if (!aActive) 2429 return; 2430 2431 /* Check the Guest Additions version and warn the user about possible 2432 * compatibility issues in case if the installed version is outdated. */ 2433 uint version = aVersion.toUInt(); 2434 QString versionStr = QString ("%1.%2") 2435 .arg (RT_HIWORD (version)).arg (RT_LOWORD (version)); 2436 QString expectedStr = QString ("%1.%2") 2437 .arg (VMMDEV_VERSION_MAJOR).arg (VMMDEV_VERSION_MINOR); /** @todo r=bird: This isn't want we want! We want the VirtualBox version of the additions, all three numbers. See @bugref{4084}.*/ 2438 2439 if (RT_HIWORD (version) < VMMDEV_VERSION_MAJOR) 2440 { 2441 vboxProblem().warnAboutTooOldAdditions (this, versionStr, expectedStr); 2442 } 2443 else if (RT_HIWORD (version) == VMMDEV_VERSION_MAJOR && 2444 RT_LOWORD (version) < VMMDEV_VERSION_MINOR) 2445 { 2446 vboxProblem().warnAboutOldAdditions (this, versionStr, expectedStr); 2447 } 2448 else if (version > VMMDEV_VERSION) 2449 { 2450 vboxProblem().warnAboutNewAdditions (this, versionStr, expectedStr); 2451 } 2452 } 2453 2454 void VBoxConsoleWnd::updateNetworkAdaptersState() 2455 { 2456 updateAppearanceOf (NetworkStuff); 2457 } 2458 2459 void VBoxConsoleWnd::updateUsbState() 2460 { 2461 updateAppearanceOf (USBStuff); 2462 } 2463 2464 void VBoxConsoleWnd::updateMediaDriveState (VBoxDefs::MediumType aType) 2465 { 2466 Assert (aType == VBoxDefs::MediumType_DVD || aType == VBoxDefs::MediumType_Floppy); 2467 updateAppearanceOf (aType == VBoxDefs::MediumType_DVD ? DVDStuff : 2468 aType == VBoxDefs::MediumType_Floppy ? FloppyStuff : 2469 AllStuff); 2470 } 2471 2472 void VBoxConsoleWnd::updateSharedFoldersState() 2473 { 2474 updateAppearanceOf (SharedFolderStuff); 2475 } 2476 2477 /** 2478 * This slot is called just after leaving the fullscreen/seamless mode, 2479 * when the console was resized to previous size. 2480 */ 2481 void VBoxConsoleWnd::onExitFullscreen() 2482 { 2483 mConsole->setIgnoreMainwndResize (false); 2484 } 2485 2486 void VBoxConsoleWnd::unlockActionsSwitch() 2487 { 2488 if (mIsSeamless) 2489 mVmSeamlessAction->setEnabled (true); 2490 else if (mIsFullscreen) 2491 mVmFullscreenAction->setEnabled (true); 2492 else 2493 { 2494 mVmSeamlessAction->setEnabled (mIsSeamlessSupported && mIsGraphicsSupported); 2495 mVmFullscreenAction->setEnabled (true); 2496 } 2497 2498 #ifdef Q_WS_MAC 2499 if (!mIsSeamless) 2500 { 2501 /* Fade back to the normal gamma */ 2502 CGDisplayFade (mFadeToken, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, false); 2503 CGReleaseDisplayFadeReservation (mFadeToken); 2504 } 2505 mConsole->setMouseCoalescingEnabled (true); 2506 #endif 2507 } 2508 2509 void VBoxConsoleWnd::mtExitMode() 2510 { 2511 if (mIsSeamless) 2512 mVmSeamlessAction->toggle(); 2513 else 2514 mVmFullscreenAction->toggle(); 2515 } 2516 2517 void VBoxConsoleWnd::mtCloseVM() 2518 { 2519 mVmCloseAction->trigger(); 2520 } 2521 2522 void VBoxConsoleWnd::mtMaskUpdate() 2523 { 2524 if (mIsSeamless) 2525 setMask (mConsole->lastVisibleRegion()); 2526 } 2527 2528 void VBoxConsoleWnd::changeDockIconUpdate (const VBoxChangeDockIconUpdateEvent &aEvent) 2529 { 2530 #ifdef Q_WS_MAC 2531 if (mConsole) 2532 { 2533 mConsole->setDockIconEnabled (aEvent.mChanged); 2534 mConsole->updateDockOverlay(); 2535 } 2536 #else 2537 Q_UNUSED (aEvent); 2538 #endif 2539 } 2540 2541 /** 2542 * Called (on non-UI thread!) when a global GUI setting changes. 2543 */ 2544 void VBoxConsoleWnd::processGlobalSettingChange (const char * /* aPublicName */, const char * /* aName */) 2545 { 2546 mHostkeyName->setText (QIHotKeyEdit::keyName (vboxGlobal().settings().hostKey())); 2547 } 2548 2549 /** 2550 * This function checks the status of required features and 2551 * makes a warning and/or some action if something necessary 2552 * is not in good condition. 2553 * Does nothing if no console view was opened. 2554 */ 2555 void VBoxConsoleWnd::checkRequiredFeatures() 2556 { 2557 if (!mConsole) return; 2558 2559 CConsole console = mConsole->console(); 2560 2561 /* Check if the virtualization feature is required. */ 2562 bool is64BitsGuest = vboxGlobal().virtualBox().GetGuestOSType ( 2563 console.GetGuest().GetOSTypeId()).GetIs64Bit(); 2564 bool fRecommendVirtEx = vboxGlobal().virtualBox().GetGuestOSType ( 2565 console.GetGuest().GetOSTypeId()).GetRecommendedVirtEx(); 2566 Assert(!is64BitsGuest || fRecommendVirtEx); 2567 bool isVirtEnabled = console.GetDebugger().GetHWVirtExEnabled(); 2568 if (fRecommendVirtEx && !isVirtEnabled) 2569 { 2570 bool ret; 2571 2572 vmPause (true); 2573 2574 if (is64BitsGuest) 2575 ret = vboxProblem().warnAboutVirtNotEnabled64BitsGuest(); 2576 else 2577 ret = vboxProblem().warnAboutVirtNotEnabledGuestRequired(); 2578 2579 if (ret == true) 2580 close(); 2581 else 2582 vmPause (false); 2583 } 2584 } 2585 2586 void VBoxConsoleWnd::activateUICustomizations() 2587 { 2588 VBoxGlobalSettings settings = vboxGlobal().settings(); 2589 /* Process known keys */ 2590 menuBar()->setHidden (settings.isFeatureActive ("noMenuBar")); 2591 statusBar()->setHidden (settings.isFeatureActive ("noStatusBar")); 2592 } 2593 2594 void VBoxConsoleWnd::updateAppearanceOf (int aElement) 2595 { 2596 if (!mConsole) return; 2597 2598 CMachine machine = mSession.GetMachine(); 2599 CConsole console = mConsole->console(); 2600 2601 bool isRunningOrPaused = mMachineState == KMachineState_Running || mMachineState == KMachineState_Paused; 2602 2603 if (aElement & Caption) 1844 2604 { 1845 2605 QString snapshotName; 1846 if ( cmachine.GetSnapshotCount() > 0)1847 { 1848 CSnapshot snapshot = cmachine.GetCurrentSnapshot();2606 if (machine.GetSnapshotCount() > 0) 2607 { 2608 CSnapshot snapshot = machine.GetCurrentSnapshot(); 1849 2609 snapshotName = " (" + snapshot.GetName() + ")"; 1850 2610 } 1851 setWindowTitle (cmachine.GetName() + snapshotName + 1852 " [" + vboxGlobal().toString (machine_state) + "] - " + 1853 caption_prefix); 1854 mMiniToolBar->setDisplayText (cmachine.GetName() + snapshotName); 1855 //#ifdef Q_WS_MAC 1856 // SetWindowTitleWithCFString (reinterpret_cast <WindowPtr> (this->winId()), CFSTR("sfds")); 1857 //SetWindowAlternateTitle 1858 //#endif 1859 } 1860 if (element & FloppyStuff) 1861 { 1862 mDevicesMountFloppyMenu->setEnabled (isRunningOrPaused); 1863 CMedium floppy = cmachine.GetMedium("Floppy Controller", 0, 0); 1864 bool mounted = !floppy.isNull(); 1865 mDevicesUnmountFloppyAction->setEnabled (isRunningOrPaused && mounted); 1866 fd_light->setState (mounted ? KDeviceActivity_Idle : KDeviceActivity_Null); 1867 QString tip = tr ("<qt><nobr>Indicates the activity of the floppy media:</nobr>" 1868 "%1</qt>", 1869 "Floppy tooltip"); 1870 #if 0 1871 /// @todo MEDIUM resurrect host dvd/floppy stuff deleted in r51247 1872 #endif 1873 QString name; 1874 if (mounted) 1875 name = tr ("<br><nobr><b>Image</b>: %1</nobr>", 1876 "Floppy tooltip") 1877 .arg (QDir::toNativeSeparators (floppy.GetLocation())); 1878 else 1879 name = tr ("<br><nobr><b>No media mounted</b></nobr>", 1880 "Floppy tooltip"); 1881 fd_light->setToolTip (tip.arg (name)); 1882 } 1883 if (element & DVDStuff) 1884 { 1885 mDevicesMountDVDMenu->setEnabled (isRunningOrPaused); 1886 CMedium dvd = cmachine.GetMedium("IDE Controller", 1, 0); 1887 bool mounted = !dvd.isNull(); 1888 mDevicesUnmountDVDAction->setEnabled (isRunningOrPaused && mounted); 1889 cd_light->setState (mounted ? KDeviceActivity_Idle : KDeviceActivity_Null); 1890 QString tip = tr ("<qt><nobr>Indicates the activity of the CD/DVD-ROM media:</nobr>" 1891 "%1</qt>", 1892 "DVD-ROM tooltip"); 1893 #if 0 1894 /// @todo MEDIUM resurrect host dvd/floppy stuff deleted in r51247 1895 #endif 1896 QString name; 1897 if (mounted) 1898 name = tr ("<br><nobr><b>Image</b>: %1</nobr>", 1899 "DVD-ROM tooltip") 1900 .arg (QDir::toNativeSeparators (dvd.GetLocation())); 1901 else 1902 name = tr ("<br><nobr><b>No media mounted</b></nobr>", 1903 "DVD-ROM tooltip"); 1904 cd_light->setToolTip (tip.arg (name)); 1905 } 1906 if (element & HardDiskStuff) 1907 { 1908 QString tip = tr ("<qt><nobr>Indicates the activity of virtual hard disks:</nobr>" 1909 "%1</qt>", 1910 "HDD tooltip"); 2611 setWindowTitle (machine.GetName() + snapshotName + 2612 " [" + vboxGlobal().toString (mMachineState) + "] - " + 2613 mCaptionPrefix); 2614 mMiniToolBar->setDisplayText (machine.GetName() + snapshotName); 2615 } 2616 if (aElement & HardDiskStuff) 2617 { 2618 QString tip = tr ("<p style='white-space:pre'><nobr>Indicates the activity " 2619 "of virtual hard disks:</nobr>%1</p>", "HDD tooltip"); 1911 2620 QString data; 1912 bool hasDisks = false; 1913 CMediumAttachmentVector vec = cmachine.GetMediumAttachments(); 1914 for (CMediumAttachmentVector::ConstIterator hda = vec.begin(); 1915 hda != vec.end(); ++ hda) 1916 { 1917 if (hda->GetType() != KDeviceType_HardDisk) 1918 continue; 1919 1920 CMedium hd = hda->GetMedium(); 1921 const QString ctlName = hda->GetController(); 1922 CStorageController ctl = cmachine.GetStorageControllerByName(ctlName); 1923 1924 data += QString ("<br><nobr><b>%1</b>: %2</nobr>") 1925 .arg (vboxGlobal().toString (StorageSlot (ctl.GetBus(), hda->GetPort(), hda->GetDevice()))) 1926 .arg (QDir::convertSeparators (hd.GetLocation())); 1927 hasDisks = true; 1928 } 1929 if (!hasDisks) 1930 data += tr ("<br><nobr><b>No hard disks attached</b></nobr>", 1931 "HDD tooltip"); 1932 hd_light->setToolTip (tip.arg (data)); 1933 hd_light->setState (hasDisks ? KDeviceActivity_Idle : KDeviceActivity_Null); 1934 } 1935 if (element & NetworkStuff) 1936 { 1937 ulong maxCount = vboxGlobal().virtualBox() 1938 .GetSystemProperties().GetNetworkAdapterCount(); 2621 bool attachmentsPresent = false; 2622 2623 CStorageControllerVector controllers = machine.GetStorageControllers(); 2624 foreach (const CStorageController &controller, controllers) 2625 { 2626 QString attData; 2627 CMediumAttachmentVector attachments = machine.GetMediumAttachmentsOfController (controller.GetName()); 2628 foreach (const CMediumAttachment &attachment, attachments) 2629 { 2630 if (attachment.GetType() != KDeviceType_HardDisk) 2631 continue; 2632 attData += QString ("<br> <nobr>%1: %2</nobr>") 2633 .arg (vboxGlobal().toString (StorageSlot (controller.GetBus(), attachment.GetPort(), attachment.GetDevice()))) 2634 .arg (vboxGlobal().findMedium (attachment.GetMedium().GetId()).location()); 2635 attachmentsPresent = true; 2636 } 2637 if (!attData.isNull()) 2638 data += QString ("<br><nobr><b>%1</b></nobr>").arg (controller.GetName()) + attData; 2639 } 2640 2641 if (!attachmentsPresent) 2642 data += tr ("<br><nobr><b>No hard disks attached</b></nobr>", "HDD tooltip"); 2643 2644 mHDLed->setToolTip (tip.arg (data)); 2645 mHDLed->setState (attachmentsPresent ? KDeviceActivity_Idle : KDeviceActivity_Null); 2646 } 2647 if (aElement & DVDStuff) 2648 { 2649 QString tip = tr ("<p style='white-space:pre'><nobr>Indicates the activity " 2650 "of the CD/DVD devices:</nobr>%1</p>", "CD/DVD tooltip"); 2651 QString data; 2652 bool attachmentsPresent = false; 2653 2654 CStorageControllerVector controllers = machine.GetStorageControllers(); 2655 foreach (const CStorageController &controller, controllers) 2656 { 2657 QString attData; 2658 CMediumAttachmentVector attachments = machine.GetMediumAttachmentsOfController (controller.GetName()); 2659 foreach (const CMediumAttachment &attachment, attachments) 2660 { 2661 if (attachment.GetType() != KDeviceType_DVD) 2662 continue; 2663 QString id (attachment.GetMedium().isNull() ? QString() : attachment.GetMedium().GetId()); 2664 VBoxMedium vboxMedium = vboxGlobal().findMedium (id); 2665 attData += QString ("<br> <nobr>%1: %2</nobr>") 2666 .arg (vboxGlobal().toString (StorageSlot (controller.GetBus(), attachment.GetPort(), attachment.GetDevice()))) 2667 .arg (vboxMedium.isNull() || vboxMedium.isHostDrive() ? vboxMedium.name() : vboxMedium.location()); 2668 attachmentsPresent = true; 2669 } 2670 if (!attData.isNull()) 2671 data += QString ("<br><nobr><b>%1</b></nobr>").arg (controller.GetName()) + attData; 2672 } 2673 2674 if (!attachmentsPresent) 2675 data += tr ("<br><nobr><b>No CD/DVD devices attached</b></nobr>", "CD/DVD tooltip"); 2676 2677 mCDLed->setToolTip (tip.arg (data)); 2678 mCDLed->setState (attachmentsPresent ? KDeviceActivity_Idle : KDeviceActivity_Null); 2679 } 2680 #if 0 /* TODO: Allow to setup status-bar! */ 2681 if (aElement & FloppyStuff) 2682 { 2683 QString tip = tr ("<p style='white-space:pre'><nobr>Indicates the activity " 2684 "of the floppy devices:</nobr>%1</p>", "FD tooltip"); 2685 QString data; 2686 bool attachmentsPresent = false; 2687 2688 CStorageControllerVector controllers = machine.GetStorageControllers(); 2689 foreach (const CStorageController &controller, controllers) 2690 { 2691 QString attData; 2692 CMediumAttachmentVector attachments = machine.GetMediumAttachmentsOfController (controller.GetName()); 2693 foreach (const CMediumAttachment &attachment, attachments) 2694 { 2695 if (attachment.GetType() != KDeviceType_Floppy) 2696 continue; 2697 QString id (attachment.GetMedium().isNull() ? QString() : attachment.GetMedium().GetId()); 2698 VBoxMedium vboxMedium = vboxGlobal().findMedium (id); 2699 attData += QString ("<br> <nobr>%1: %2</nobr>") 2700 .arg (vboxGlobal().toString (StorageSlot (controller.GetBus(), attachment.GetPort(), attachment.GetDevice()))) 2701 .arg (vboxMedium.isNull() || vboxMedium.isHostDrive() ? vboxMedium.name() : vboxMedium.location()); 2702 attachmentsPresent = true; 2703 } 2704 if (!attData.isNull()) 2705 data += QString ("<br><nobr><b>%1</b></nobr>").arg (controller.GetName()) + attData; 2706 } 2707 2708 if (!attachmentsPresent) 2709 data += tr ("<br><nobr><b>No floppy devices attached</b></nobr>", "FD tooltip"); 2710 2711 mFDLed->setToolTip (tip.arg (data)); 2712 mFDLed->setState (attachmentsPresent ? KDeviceActivity_Idle : KDeviceActivity_Null); 2713 } 2714 #endif 2715 if (aElement & NetworkStuff) 2716 { 2717 ulong maxCount = vboxGlobal().virtualBox().GetSystemProperties().GetNetworkAdapterCount(); 1939 2718 ulong count = 0; 1940 for (ulong slot = 0; slot < maxCount; slot++) 1941 if (cmachine.GetNetworkAdapter (slot).GetEnabled()) 1942 count++; 1943 net_light->setState (count > 0 ? KDeviceActivity_Idle 1944 : KDeviceActivity_Null); 2719 for (ulong slot = 0; slot < maxCount; ++ slot) 2720 if (machine.GetNetworkAdapter (slot).GetEnabled()) 2721 ++ count; 2722 mNetLed->setState (count > 0 ? KDeviceActivity_Idle : KDeviceActivity_Null); 1945 2723 1946 2724 mDevicesNetworkDialogAction->setEnabled (isRunningOrPaused && count > 0); 1947 2725 mDevicesNetworkMenu->setEnabled (isRunningOrPaused && count > 0); 1948 2726 1949 /* update tooltip */ 1950 QString ttip = tr ("<qt><nobr>Indicates the activity of the network " 1951 "interfaces:</nobr>" 1952 "%1</qt>", 1953 "Network adapters tooltip"); 2727 QString tip = tr ("<p style='white-space:pre'><nobr>Indicates the activity of the " 2728 "network interfaces:</nobr>%1</p>", "Network adapters tooltip"); 1954 2729 QString info; 1955 2730 1956 2731 for (ulong slot = 0; slot < maxCount; ++ slot) 1957 2732 { 1958 CNetworkAdapter adapter = cmachine.GetNetworkAdapter (slot);2733 CNetworkAdapter adapter = machine.GetNetworkAdapter (slot); 1959 2734 if (adapter.GetEnabled()) 1960 info += tr ("<br><nobr><b>Adapter %1 (%2)</b>: cable %3</nobr>", 1961 "Network adapters tooltip") 1962 .arg (slot+1) 2735 info += tr ("<br><nobr><b>Adapter %1 (%2)</b>: cable %3</nobr>", "Network adapters tooltip") 2736 .arg (slot + 1) 1963 2737 .arg (vboxGlobal().toString (adapter.GetAttachmentType())) 1964 2738 .arg (adapter.GetCableConnected() ? … … 1968 2742 1969 2743 if (info.isNull()) 1970 info = tr ("<br><nobr><b>All network adapters are disabled</b></nobr>", 1971 "Network adapters tooltip"); 1972 1973 net_light->setToolTip (ttip.arg (info)); 1974 } 1975 if (element & USBStuff) 1976 { 1977 if (!usb_light->isHidden()) 1978 { 1979 /* update tooltip */ 1980 QString ttip = tr ("<qt><nobr>Indicates the activity of the " 1981 "attached USB devices:</nobr>" 1982 "%1</qt>", 1983 "USB device tooltip"); 2744 info = tr ("<br><nobr><b>All network adapters are disabled</b></nobr>", "Network adapters tooltip"); 2745 2746 mNetLed->setToolTip (tip.arg (info)); 2747 } 2748 if (aElement & USBStuff) 2749 { 2750 if (!mUSBLed->isHidden()) 2751 { 2752 QString tip = tr ("<p style='white-space:pre'><nobr>Indicates the activity of " 2753 "the attached USB devices:</nobr>%1</p>", "USB device tooltip"); 1984 2754 QString info; 1985 2755 1986 CUSBController usbctl = cmachine.GetUSBController(); 1987 if ( !usbctl.isNull() 1988 && usbctl.GetEnabled()) 2756 CUSBController usbctl = machine.GetUSBController(); 2757 if (!usbctl.isNull() && usbctl.GetEnabled()) 1989 2758 { 1990 2759 mDevicesUSBMenu->setEnabled (isRunningOrPaused); 1991 2760 1992 CUSBDeviceVector devsvec = c console.GetUSBDevices();1993 for (int i = 0; i < devsvec.size(); ++ i)2761 CUSBDeviceVector devsvec = console.GetUSBDevices(); 2762 for (int i = 0; i < devsvec.size(); ++ i) 1994 2763 { 1995 CUSBDevice usb = devsvec[i]; 1996 info += QString ("<br><b><nobr>%1</nobr></b>") 1997 .arg (vboxGlobal().details (usb)); 2764 CUSBDevice usb = devsvec [i]; 2765 info += QString ("<br><b><nobr>%1</nobr></b>").arg (vboxGlobal().details (usb)); 1998 2766 } 1999 2767 if (info.isNull()) 2000 info = tr ("<br><nobr><b>No USB devices attached</b></nobr>", 2001 "USB device tooltip"); 2768 info = tr ("<br><nobr><b>No USB devices attached</b></nobr>", "USB device tooltip"); 2002 2769 } 2003 2770 else 2004 2771 { 2005 2772 mDevicesUSBMenu->setEnabled (false); 2006 2007 info = tr ("<br><nobr><b>USB Controller is disabled</b></nobr>", 2008 "USB device tooltip"); 2773 info = tr ("<br><nobr><b>USB Controller is disabled</b></nobr>", "USB device tooltip"); 2009 2774 } 2010 2775 2011 usb_light->setToolTip (ttip.arg (info));2012 } 2013 } 2014 if ( element & VRDPStuff)2015 { 2016 CVRDPServer vrdpsrv = csession.GetMachine().GetVRDPServer();2776 mUSBLed->setToolTip (tip.arg (info)); 2777 } 2778 } 2779 if (aElement & VRDPStuff) 2780 { 2781 CVRDPServer vrdpsrv = mSession.GetMachine().GetVRDPServer(); 2017 2782 if (!vrdpsrv.isNull()) 2018 2783 { … … 2020 2785 bool isVRDPEnabled = vrdpsrv.GetEnabled(); 2021 2786 mDevicesSwitchVrdpAction->setChecked (isVRDPEnabled); 2022 #if 0 2023 vrdp_state->setState (isVRDPEnabled ? 1 : 0); 2024 2025 /* compose status icon tooltip */ 2787 #if 0 /* TODO: Allow to setup status-bar! */ 2788 mVrdpLed->setState (isVRDPEnabled ? 1 : 0); 2789 2026 2790 QString tip = tr ("Indicates whether the Remote Display (VRDP Server) " 2027 2791 "is enabled (<img src=:/vrdp_16px.png/>) or not " 2028 "(<img src=:/vrdp_disabled_16px.png/>)." 2029 ); 2792 "(<img src=:/vrdp_disabled_16px.png/>)."); 2030 2793 if (vrdpsrv.GetEnabled()) 2031 2794 tip += tr ("<hr>VRDP Server is listening on port %1").arg (vrdpsrv.GetPort()); 2032 vrdp_state->setToolTip (tip); 2033 #endif 2034 } 2035 } 2036 if (element & SharedFolderStuff) 2037 { 2038 QString tip = tr ("<qt><nobr>Indicates the activity of shared folders:</nobr>" 2039 "%1</qt>", 2040 "Shared folders tooltip"); 2795 mVrdpLed->setToolTip (tip); 2796 #endif 2797 } 2798 } 2799 if (aElement & SharedFolderStuff) 2800 { 2801 QString tip = tr ("<p style='white-space:pre'><nobr>Indicates the activity of " 2802 "shared folders:</nobr>%1</p>", "Shared folders tooltip"); 2041 2803 2042 2804 QString data; … … 2045 2807 mDevicesSFMenu->setEnabled (true); 2046 2808 2047 /// @todo later: add global folders 2048 2049 /* permanent folders */ 2050 CSharedFolderVector psfvec = cmachine.GetSharedFolders(); 2051 2052 for (int i = 0; i < psfvec.size(); ++i) 2053 { 2054 CSharedFolder sf = psfvec[i]; 2809 /* Permanent folders */ 2810 CSharedFolderVector psfvec = machine.GetSharedFolders(); 2811 2812 for (int i = 0; i < psfvec.size(); ++ i) 2813 { 2814 CSharedFolder sf = psfvec [i]; 2055 2815 sfs.insert (sf.GetName(), sf.GetHostPath()); 2056 2816 } 2057 2817 2058 /* transient folders */2059 CSharedFolderVector tsfvec = c console.GetSharedFolders();2060 2061 for (int i = 0; i < tsfvec.size(); ++ i)2818 /* Transient folders */ 2819 CSharedFolderVector tsfvec = console.GetSharedFolders(); 2820 2821 for (int i = 0; i < tsfvec.size(); ++ i) 2062 2822 { 2063 2823 CSharedFolder sf = tsfvec[i]; … … 2065 2825 } 2066 2826 2067 for (QMap <QString, QString>::const_iterator it = sfs.constBegin(); 2068 it != sfs.constEnd(); ++ it) 2827 for (QMap <QString, QString>::const_iterator it = sfs.constBegin(); it != sfs.constEnd(); ++ it) 2069 2828 { 2070 2829 /* Select slashes depending on the OS type */ 2071 if (VBoxGlobal::isDOSType (cconsole.GetGuest().GetOSTypeId())) 2072 data += QString ("<br><nobr><b>\\\\vboxsvr\\%1 </b></nobr>" 2073 "<nobr>%2</nobr>") 2074 .arg (it.key(), it.value()); 2830 if (VBoxGlobal::isDOSType (console.GetGuest().GetOSTypeId())) 2831 data += QString ("<br><nobr><b>\\\\vboxsvr\\%1 </b></nobr><nobr>%2</nobr>") 2832 .arg (it.key(), it.value()); 2075 2833 else 2076 data += QString ("<br><nobr><b>%1 </b></nobr>" 2077 "<nobr>%2</nobr>") 2078 .arg (it.key(), it.value()); 2834 data += QString ("<br><nobr><b>%1 </b></nobr><nobr>%2</nobr>") 2835 .arg (it.key(), it.value()); 2079 2836 } 2080 2837 2081 2838 if (sfs.count() == 0) 2082 data = tr ("<br><nobr><b>No shared folders</b></nobr>", 2083 "Shared folders tooltip"); 2084 2085 sf_light->setToolTip (tip.arg (data)); 2086 } 2087 if (element & VirtualizationStuff) 2088 { 2089 bool virtEnabled = cconsole.GetDebugger().GetHWVirtExEnabled(); 2839 data = tr ("<br><nobr><b>No shared folders</b></nobr>", "Shared folders tooltip"); 2840 2841 mSFLed->setToolTip (tip.arg (data)); 2842 } 2843 if (aElement & VirtualizationStuff) 2844 { 2845 bool virtEnabled = console.GetDebugger().GetHWVirtExEnabled(); 2090 2846 QString virtualization = virtEnabled ? 2091 2847 VBoxGlobal::tr ("Enabled", "details report (VT-x/AMD-V)") : 2092 2848 VBoxGlobal::tr ("Disabled", "details report (VT-x/AMD-V)"); 2093 2849 2094 bool nestEnabled = c console.GetDebugger().GetHWVirtExNestedPagingEnabled();2850 bool nestEnabled = console.GetDebugger().GetHWVirtExNestedPagingEnabled(); 2095 2851 QString nestedPaging = nestEnabled ? 2096 2852 VBoxVMInformationDlg::tr ("Enabled", "nested paging") : … … 2105 2861 .arg (VBoxVMInformationDlg::tr ("Nested Paging"), nestedPaging)); 2106 2862 2107 int cpuCount = c console.GetMachine().GetCPUCount();2863 int cpuCount = console.GetMachine().GetCPUCount(); 2108 2864 if (cpuCount > 1) 2109 2865 tip += tr ("<br><nobr><b>%1:</b> %2</nobr>", "Virtualization Stuff LED") 2110 .arg (VBoxGlobal::tr ("Processor(s)", "details report")).arg (cpuCount);2866 .arg (VBoxGlobal::tr ("Processor(s)", "details report")).arg (cpuCount); 2111 2867 2112 2868 mVirtLed->setToolTip (tip); 2113 2869 mVirtLed->setState (virtEnabled); 2114 2870 } 2115 if ( element & PauseAction)2871 if (aElement & PauseAction) 2116 2872 { 2117 2873 if (!mVmPauseAction->isChecked()) 2118 2874 { 2119 2875 mVmPauseAction->setText (VBoxGlobal::insertKeyToActionText (tr ("&Pause"), "P")); 2120 mVmPauseAction->setStatusTip ( 2121 tr ("Suspend the execution of the virtual machine")); 2876 mVmPauseAction->setStatusTip (tr ("Suspend the execution of the virtual machine")); 2122 2877 } 2123 2878 else 2124 2879 { 2125 2880 mVmPauseAction->setText (VBoxGlobal::insertKeyToActionText (tr ("R&esume"), "P")); 2126 mVmPauseAction->setStatusTip ( 2127 tr ("Resume the execution of the virtual machine" ) ); 2881 mVmPauseAction->setStatusTip (tr ("Resume the execution of the virtual machine" ) ); 2128 2882 } 2129 2883 mVmPauseAction->setEnabled (isRunningOrPaused); 2130 2884 } 2131 if ( element & DisableMouseIntegrAction)2885 if (aElement & DisableMouseIntegrAction) 2132 2886 { 2133 2887 if (!mVmDisableMouseIntegrAction->isChecked()) 2134 2888 { 2135 mVmDisableMouseIntegrAction->setText (VBoxGlobal::insertKeyToActionText (tr ("Disable &Mouse Integration"), 2136 "I")); 2137 mVmDisableMouseIntegrAction->setStatusTip ( 2138 tr ("Temporarily disable host mouse pointer integration")); 2889 mVmDisableMouseIntegrAction->setText (VBoxGlobal::insertKeyToActionText (tr ("Disable &Mouse Integration"), "I")); 2890 mVmDisableMouseIntegrAction->setStatusTip (tr ("Temporarily disable host mouse pointer integration")); 2139 2891 } 2140 2892 else 2141 2893 { 2142 mVmDisableMouseIntegrAction->setText (VBoxGlobal::insertKeyToActionText (tr ("Enable &Mouse Integration"), 2143 "I")); 2144 mVmDisableMouseIntegrAction->setStatusTip ( 2145 tr ("Enable temporarily disabled host mouse pointer integration")); 2146 } 2147 if (machine_state == KMachineState_Running) 2148 mVmDisableMouseIntegrAction->setEnabled (console->isMouseAbsolute()); 2894 mVmDisableMouseIntegrAction->setText (VBoxGlobal::insertKeyToActionText (tr ("Enable &Mouse Integration"), "I")); 2895 mVmDisableMouseIntegrAction->setStatusTip (tr ("Enable temporarily disabled host mouse pointer integration")); 2896 } 2897 if (mMachineState == KMachineState_Running) 2898 mVmDisableMouseIntegrAction->setEnabled (mConsole->isMouseAbsolute()); 2149 2899 else 2150 2900 mVmDisableMouseIntegrAction->setEnabled (false); 2151 }2152 }2153 2154 /**2155 * This function checks the status of required features and2156 * makes a warning and/or some action if something necessary2157 * is not in good condition.2158 * Does nothing if no console view was opened.2159 */2160 void VBoxConsoleWnd::checkRequiredFeatures()2161 {2162 if (!console) return;2163 2164 CConsole cconsole = console->console();2165 2166 /* Check if the virtualization feature is required. */2167 bool is64BitsGuest = vboxGlobal().virtualBox().GetGuestOSType (2168 cconsole.GetGuest().GetOSTypeId()).GetIs64Bit();2169 bool fRecommendVirtEx = vboxGlobal().virtualBox().GetGuestOSType (2170 cconsole.GetGuest().GetOSTypeId()).GetRecommendedVirtEx();2171 Assert(!is64BitsGuest || fRecommendVirtEx);2172 bool isVirtEnabled = cconsole.GetDebugger().GetHWVirtExEnabled();2173 if (fRecommendVirtEx && !isVirtEnabled)2174 {2175 bool ret;2176 2177 vmPause (true);2178 2179 if (is64BitsGuest)2180 ret = vboxProblem().warnAboutVirtNotEnabled64BitsGuest();2181 else2182 ret = vboxProblem().warnAboutVirtNotEnabledGuestRequired();2183 2184 if (ret == true)2185 close();2186 else2187 vmPause (false);2188 2901 } 2189 2902 } … … 2200 2913 2201 2914 QSize initialSize = size(); 2202 if (aSeamless || console->isAutoresizeGuestActive())2915 if (aSeamless || mConsole->isAutoresizeGuestActive()) 2203 2916 { 2204 2917 QRect screen = aSeamless ? 2205 2918 QApplication::desktop()->availableGeometry (this) : 2206 2919 QApplication::desktop()->screenGeometry (this); 2207 ULONG64 availBits = csession.GetMachine().GetVRAMSize() /* vram */2920 ULONG64 availBits = mSession.GetMachine().GetVRAMSize() /* vram */ 2208 2921 * _1M /* mb to bytes */ 2209 2922 * 8; /* to bits */ 2210 ULONG guestBpp = console->console().GetDisplay().GetBitsPerPixel();2923 ULONG guestBpp = mConsole->console().GetDisplay().GetBitsPerPixel(); 2211 2924 ULONG64 usedBits = (screen.width() /* display width */ 2212 2925 * screen.height() /* display height */ 2213 2926 * guestBpp 2214 2927 + _1M * 8) /* current cache per screen - may be changed in future */ 2215 * csession.GetMachine().GetMonitorCount() /**< @todo fix assumption that all screens have same resolution */2928 * mSession.GetMachine().GetMonitorCount() /**< @todo fix assumption that all screens have same resolution */ 2216 2929 + 4096 * 8; /* adapter info */ 2217 2930 if (aOn && (availBits < usedBits)) … … 2235 2948 } 2236 2949 2237 AssertReturn ( console, false);2950 AssertReturn (mConsole, false); 2238 2951 AssertReturn ((mHiddenChildren.empty() == aOn), false); 2239 2952 AssertReturn ((aSeamless && mIsSeamless != aOn) || … … 2286 2999 mVmDisableMouseIntegrAction->setEnabled (!aOn); 2287 3000 2288 console->console().GetDisplay().SetSeamlessMode (aOn);3001 mConsole->console().GetDisplay().SetSeamlessMode (aOn); 2289 3002 mIsSeamless = aOn; 2290 3003 } … … 2308 3021 if (aOn) 2309 3022 { 2310 consoleSize = console->frameSize();2311 consoleSize -= QSize ( console->frameWidth() * 2, console->frameWidth() * 2);3023 consoleSize = mConsole->frameSize(); 3024 consoleSize -= QSize (mConsole->frameWidth() * 2, mConsole->frameWidth() * 2); 2312 3025 2313 3026 /* Toggle console to manual resize mode. */ 2314 console->setIgnoreMainwndResize (true);3027 mConsole->setIgnoreMainwndResize (true); 2315 3028 2316 3029 /* Memorize the maximized state. */ 2317 3030 QDesktopWidget *dtw = QApplication::desktop(); 2318 was_max = isWindowMaximized() &&3031 mWasMax = isWindowMaximized() && 2319 3032 dtw->availableGeometry().width() == frameSize().width() && 2320 3033 dtw->availableGeometry().height() == frameSize().height(); … … 2324 3037 * the exiting fullscreen. Required for correct scroll-view and 2325 3038 * guest display update in SDL mode. */ 2326 prev_min_size = console->minimumSize();2327 console->setMinimumSize (0, 0);3039 mPrevMinSize = mConsole->minimumSize(); 3040 mConsole->setMinimumSize (0, 0); 2328 3041 2329 3042 /* let the widget take the whole available desktop space */ … … 2363 3076 centralWidget()->setPalette (palette); 2364 3077 centralWidget()->setAutoFillBackground (!aSeamless); 2365 console_style = console->frameStyle();2366 console->setFrameStyle (QFrame::NoFrame);2367 console->setMaximumSize (scrGeo.size());2368 console->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);2369 console->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);3078 mConsoleStyle = mConsole->frameStyle(); 3079 mConsole->setFrameStyle (QFrame::NoFrame); 3080 mConsole->setMaximumSize (scrGeo.size()); 3081 mConsole->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff); 3082 mConsole->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff); 2370 3083 } 2371 3084 else … … 2380 3093 * fullscreen. Required for correct scroll-view and guest display 2381 3094 * update in SDL mode. */ 2382 console->setMinimumSize (prev_min_size);3095 mConsole->setMinimumSize (mPrevMinSize); 2383 3096 2384 3097 #ifdef Q_WS_MAC … … 2399 3112 centralWidget()->setPalette (mErasePalette); 2400 3113 centralWidget()->setAutoFillBackground (false); 2401 console->setFrameStyle (console_style);2402 console->setMaximumSize (console->sizeHint());2403 console->setHorizontalScrollBarPolicy (Qt::ScrollBarAsNeeded);2404 console->setVerticalScrollBarPolicy (Qt::ScrollBarAsNeeded);3114 mConsole->setFrameStyle (mConsoleStyle); 3115 mConsole->setMaximumSize (mConsole->sizeHint()); 3116 mConsole->setHorizontalScrollBarPolicy (Qt::ScrollBarAsNeeded); 3117 mConsole->setVerticalScrollBarPolicy (Qt::ScrollBarAsNeeded); 2405 3118 2406 3119 /* Show everything hidden when going fullscreen. */ … … 2443 3156 2444 3157 /* Send guest size hint */ 2445 console->toggleFSMode (consoleSize);3158 mConsole->toggleFSMode (consoleSize); 2446 3159 2447 3160 /* Process all console attributes changes and sub-widget hidings */ … … 2465 3178 } 2466 3179 2467 void VBoxConsoleWnd::changeDockIconUpdate (const VBoxChangeDockIconUpdateEvent &e)2468 {2469 #ifdef Q_WS_MAC2470 if (console)2471 {2472 console->setDockIconEnabled (e.mChanged);2473 console->updateDockOverlay();2474 }2475 #else2476 Q_UNUSED (e);2477 #endif2478 }2479 2480 //2481 // Private slots2482 /////////////////////////////////////////////////////////////////////////////2483 3180 void VBoxConsoleWnd::switchToFullscreen (bool aOn, bool aSeamless) 2484 3181 { … … 2556 3253 } 2557 3254 2558 void VBoxConsoleWnd::mtExitMode() 2559 { 2560 if (mIsSeamless) 2561 mVmSeamlessAction->toggle(); 2562 else 2563 mVmFullscreenAction->toggle(); 2564 } 2565 2566 void VBoxConsoleWnd::mtCloseVM() 2567 { 2568 mVmCloseAction->trigger(); 2569 } 2570 2571 void VBoxConsoleWnd::mtMaskUpdate() 2572 { 2573 if (mIsSeamless) 2574 setMask (console->lastVisibleRegion()); 2575 } 2576 2577 void VBoxConsoleWnd::vmFullscreen (bool aOn) 2578 { 2579 bool ok = toggleFullscreenMode (aOn, false /* aSeamless */); 2580 if (!ok) 2581 { 2582 /* on failure, restore the previous button state */ 2583 mVmFullscreenAction->blockSignals (true); 2584 mVmFullscreenAction->setChecked (!aOn); 2585 mVmFullscreenAction->blockSignals (false); 2586 } 2587 } 2588 2589 void VBoxConsoleWnd::vmSeamless (bool aOn) 2590 { 2591 /* check if it is possible to enter/leave seamless mode */ 2592 if ((mIsSeamlessSupported && mIsGraphicsSupported) || !aOn) 2593 { 2594 bool ok = toggleFullscreenMode (aOn, true /* aSeamless */); 2595 if (!ok) 2596 { 2597 /* on failure, restore the previous button state */ 2598 mVmSeamlessAction->blockSignals (true); 2599 mVmSeamlessAction->setChecked (!aOn); 2600 mVmSeamlessAction->blockSignals (false); 2601 } 2602 } 2603 } 2604 2605 void VBoxConsoleWnd::vmAutoresizeGuest (bool on) 2606 { 2607 if (!console) 3255 /** 3256 * Closes the console view opened by openView(). 3257 * Does nothing if no console view was opened. 3258 */ 3259 void VBoxConsoleWnd::closeView() 3260 { 3261 LogFlowFuncEnter(); 3262 3263 if (!mConsole) 3264 { 3265 LogFlow (("Already closed!\n")); 3266 LogFlowFuncLeave(); 2608 3267 return; 2609 2610 /* Currently, we use only "off" and "on" icons. Later, 2611 * we may want to use disabled versions of icons when no guest additions 2612 * are available (to indicate that this function is ineffective). */ 2613 #if 0 2614 autoresize_state->setState (on ? 3 : 1); 2615 #endif 2616 2617 console->setAutoresizeGuest (on); 2618 } 2619 2620 void VBoxConsoleWnd::vmAdjustWindow() 2621 { 2622 if (console) 2623 { 2624 if (isWindowMaximized()) 2625 showNormal(); 2626 console->normalizeGeometry (true /* adjustPosition */); 2627 } 2628 } 2629 2630 void VBoxConsoleWnd::vmTypeCAD() 2631 { 2632 if (console) 2633 { 2634 CKeyboard keyboard = console->console().GetKeyboard(); 2635 Assert (!keyboard.isNull()); 2636 keyboard.PutCAD(); 2637 AssertWrapperOk (keyboard); 2638 } 2639 } 2640 2641 void VBoxConsoleWnd::vmTypeCABS() 2642 { 2643 #if defined(Q_WS_X11) 2644 if (console) 2645 { 2646 CKeyboard keyboard = console->console().GetKeyboard(); 2647 Assert (!keyboard.isNull()); 2648 static QVector <LONG> sSequence (6); 2649 sSequence[0] = 0x1d; // Ctrl down 2650 sSequence[1] = 0x38; // Alt down 2651 sSequence[2] = 0x0E; // Backspace down 2652 sSequence[3] = 0x8E; // Backspace up 2653 sSequence[4] = 0xb8; // Alt up 2654 sSequence[5] = 0x9d; // Ctrl up 2655 keyboard.PutScancodes (sSequence); 2656 AssertWrapperOk (keyboard); 2657 } 2658 #else 2659 /* we have to define this slot anyway because MOC doesn't understand ifdefs */ 2660 #endif 2661 } 2662 2663 void VBoxConsoleWnd::vmReset() 2664 { 2665 if (console) 2666 { 2667 if (vboxProblem().confirmVMReset (this)) 2668 console->console().Reset(); 2669 } 2670 } 2671 2672 void VBoxConsoleWnd::vmPause (bool on) 2673 { 2674 if (console) 2675 { 2676 console->pause (on); 2677 updateAppearanceOf (PauseAction); 2678 } 2679 } 2680 2681 void VBoxConsoleWnd::vmACPIShutdown() 2682 { 2683 if (!csession.GetConsole().GetGuestEnteredACPIMode()) 2684 return vboxProblem().cannotSendACPIToMachine(); 2685 2686 if (console) 2687 { 2688 CConsole cconsole = console->console(); 2689 cconsole.PowerButton(); 2690 if (!cconsole.isOk()) 2691 vboxProblem().cannotACPIShutdownMachine (cconsole); 2692 } 2693 } 2694 2695 void VBoxConsoleWnd::vmClose() 2696 { 2697 if (console) 2698 { 2699 close(); 2700 } 2701 } 2702 2703 void VBoxConsoleWnd::vmTakeSnapshot() 2704 { 2705 AssertReturn (console, (void) 0); 2706 2707 /* remember the paused state */ 2708 bool wasPaused = machine_state == KMachineState_Paused; 2709 if (!wasPaused) 2710 { 2711 /* Suspend the VM and ignore the close event if failed to do so. 2712 * pause() will show the error message to the user. */ 2713 if (!console->pause (true)) 2714 return; 2715 } 2716 2717 CMachine cmachine = csession.GetMachine(); 2718 2719 VBoxTakeSnapshotDlg dlg (this); 2720 2721 QString typeId = cmachine.GetOSTypeId(); 2722 dlg.mLbIcon->setPixmap (vboxGlobal().vmGuestOSTypeIcon (typeId)); 2723 2724 /* search for the max available filter index */ 2725 int maxSnapShotIndex = 0; 2726 QString snapShotName = tr ("Snapshot %1"); 2727 QRegExp regExp (QString ("^") + snapShotName.arg ("([0-9]+)") + QString ("$")); 2728 CSnapshot index = cmachine.GetSnapshot (QString::null); 2729 while (!index.isNull()) 2730 { 2731 /* Check the current snapshot name */ 2732 QString name = index.GetName(); 2733 int pos = regExp.indexIn (name); 2734 if (pos != -1) 2735 maxSnapShotIndex = regExp.cap (1).toInt() > maxSnapShotIndex ? 2736 regExp.cap (1).toInt() : maxSnapShotIndex; 2737 /* Traversing to the next child */ 2738 CSnapshotVector c = index.GetChildren(); 2739 if (c.size() > 0) 2740 index = c[0]; 2741 else 2742 break; 2743 } 2744 dlg.mLeName->setText (snapShotName.arg (maxSnapShotIndex + 1)); 2745 2746 if (dlg.exec() == QDialog::Accepted) 2747 { 2748 CConsole cconsole = csession.GetConsole(); 2749 2750 CProgress progress = 2751 cconsole.TakeSnapshot (dlg.mLeName->text().trimmed(), 2752 dlg.mTeDescription->toPlainText()); 2753 2754 if (cconsole.isOk()) 2755 { 2756 /* show the "Taking Snapshot" progress dialog */ 2757 vboxProblem(). 2758 showModalProgressDialog (progress, cmachine.GetName(), this, 0); 2759 2760 if (progress.GetResultCode() != 0) 2761 vboxProblem().cannotTakeSnapshot (progress); 2762 } 2763 else 2764 vboxProblem().cannotTakeSnapshot (cconsole); 2765 } 2766 2767 /* restore the running state if needed */ 2768 if (!wasPaused) 2769 console->pause (false); 2770 } 2771 2772 void VBoxConsoleWnd::vmShowInfoDialog() 2773 { 2774 VBoxVMInformationDlg::createInformationDlg (csession, console); 2775 } 2776 2777 void VBoxConsoleWnd::vmDisableMouseIntegr (bool aOff) 2778 { 2779 if (console) 2780 { 2781 console->setMouseIntegrationEnabled (!aOff); 2782 updateAppearanceOf (DisableMouseIntegrAction); 2783 } 2784 } 2785 2786 void VBoxConsoleWnd::devicesMountFloppyImage() 2787 { 2788 if (!console) return; 2789 2790 VBoxMediaManagerDlg dlg (this); 2791 2792 dlg.setup (VBoxDefs::MediumType_Floppy, true /* aDoSelect */, 2793 true /* aRefresh */, csession.GetMachine()); 2794 2795 if (dlg.exec() == QDialog::Accepted) 2796 { 2797 CMachine m = csession.GetMachine(); 2798 2799 m.MountMedium ("Floppy Controller", 0, 0, dlg.selectedId()); 2800 2801 AssertWrapperOk (m); 2802 if (m.isOk()) 2803 { 2804 if (mIsAutoSaveMedia) 2805 { 2806 m.SaveSettings(); 2807 if (!m.isOk()) 2808 vboxProblem().cannotSaveMachineSettings (m); 2809 } 2810 } 2811 } 2812 } 2813 2814 void VBoxConsoleWnd::devicesUnmountFloppy() 2815 { 2816 if (!console) return; 2817 2818 CMachine m = csession.GetMachine(); 2819 m.MountMedium ("Floppy Controller", 0, 0, NULL); 2820 if (m.isOk()) 2821 { 2822 if (mIsAutoSaveMedia) 2823 { 2824 m.SaveSettings(); 2825 if (!m.isOk()) 2826 vboxProblem().cannotSaveMachineSettings (m); 2827 } 2828 } 2829 2830 if (!m.GetMedium ("Floppy Controller", 0, 0).isNull()) 2831 { 2832 /* Looks like Main make no force unmounting here 2833 * but IFloppyDrive::Unmount() is called synchronously. 2834 * Also Main performs rollback for this procedure if 2835 * it was failed by some reason - for example if the 2836 * guest OS locked IFloppyDrive preventing image from 2837 * unmounting - so no way to know the error was really 2838 * occured. Thats why we just checking the drive state 2839 * and warn a user about problem if present. */ 2840 vboxProblem().cannotEjectDrive(); 2841 } 2842 } 2843 2844 void VBoxConsoleWnd::devicesMountDVDImage() 2845 { 2846 if (!console) return; 2847 2848 VBoxMediaManagerDlg dlg (this); 2849 2850 dlg.setup (VBoxDefs::MediumType_DVD, true /* aDoSelect */, 2851 true /* aRefresh */, csession.GetMachine()); 2852 2853 if (dlg.exec() == QDialog::Accepted) 2854 { 2855 CMachine m = csession.GetMachine(); 2856 2857 m.MountMedium ("IDE Controller", 1, 0, dlg.selectedId()); 2858 2859 AssertWrapperOk (m); 2860 if (m.isOk()) 2861 { 2862 if (mIsAutoSaveMedia) 2863 { 2864 m.SaveSettings(); 2865 if (!m.isOk()) 2866 vboxProblem().cannotSaveMachineSettings (m); 2867 } 2868 } 2869 } 2870 } 2871 2872 2873 void VBoxConsoleWnd::devicesUnmountDVD() 2874 { 2875 if (!console) return; 2876 2877 CMachine m = csession.GetMachine(); 2878 m.MountMedium ("IDE Controller", 1, 0, NULL); 2879 AssertWrapperOk (m); 2880 if (m.isOk()) 2881 { 2882 if (mIsAutoSaveMedia) 2883 { 2884 m.SaveSettings(); 2885 if (!m.isOk()) 2886 vboxProblem().cannotSaveMachineSettings (m); 2887 } 2888 } 2889 2890 if (!m.GetMedium("IDE Controller", 1, 0).isNull()) 2891 { 2892 /* Looks like Main make no force unmounting here 2893 * but IDVDDrive::Unmount() is called synchronously. 2894 * Also Main performs rollback for this procedure if 2895 * it was failed by some reason - for example if the 2896 * guest OS locked IDVDDrive preventing image from 2897 * unmounting - so no way to know the error was really 2898 * occured. Thats why we just checking the drive state 2899 * and warn a user about problem if present. */ 2900 vboxProblem().cannotEjectDrive(); 2901 } 2902 } 2903 2904 void VBoxConsoleWnd::devicesSwitchVrdp (bool aOn) 2905 { 2906 if (!console) return; 2907 2908 CVRDPServer vrdpServer = csession.GetMachine().GetVRDPServer(); 2909 /* this method should not be executed if vrdpServer is null */ 2910 Assert (!vrdpServer.isNull()); 2911 2912 vrdpServer.SetEnabled (aOn); 2913 updateAppearanceOf (VRDPStuff); 2914 } 2915 2916 void VBoxConsoleWnd::devicesOpenNetworkDialog() 2917 { 2918 if (!console) return; 2919 2920 VBoxNetworkDialog dlg (console, csession); 2921 dlg.exec(); 2922 } 2923 2924 void VBoxConsoleWnd::devicesOpenSFDialog() 2925 { 2926 if (!console) return; 2927 2928 VBoxSFDialog dlg (console, csession); 2929 dlg.exec(); 2930 } 2931 2932 void VBoxConsoleWnd::devicesInstallGuestAdditions() 2933 { 2934 #if defined (DEBUG_dmik) /* subscribe yourself here if you care for this behavior. */ 2935 QString src1 = qApp->applicationDirPath() + "/../../release/bin/VBoxGuestAdditions.iso"; 2936 QString src2 = qApp->applicationDirPath() + "/../../release/bin/additions/VBoxGuestAdditions.iso"; 2937 #else 2938 char szAppPrivPath [RTPATH_MAX]; 2939 int rc = RTPathAppPrivateNoArch (szAppPrivPath, sizeof (szAppPrivPath)); 2940 AssertRC (rc); 2941 2942 QString src1 = QString (szAppPrivPath) + "/VBoxGuestAdditions.iso"; 2943 QString src2 = qApp->applicationDirPath() + "/additions/VBoxGuestAdditions.iso"; 2944 #endif 2945 2946 /* Check the standard image locations */ 2947 if (QFile::exists (src1)) 2948 return installGuestAdditionsFrom (src1); 2949 else if (QFile::exists (src2)) 2950 return installGuestAdditionsFrom (src2); 2951 2952 /* Check for the already registered image */ 2953 CVirtualBox vbox = vboxGlobal().virtualBox(); 2954 QString name = QString ("VBoxGuestAdditions_%1.iso") 2955 .arg (vbox.GetVersion().remove ("_OSE")); 2956 2957 CMediumVector vec = vbox.GetDVDImages(); 2958 for (CMediumVector::ConstIterator it = vec.begin(); 2959 it != vec.end(); ++ it) 2960 { 2961 QString path = it->GetLocation(); 2962 /* Compare the name part ignoring the file case */ 2963 QString fn = QFileInfo (path).fileName(); 2964 if (RTPathCompare (name.toUtf8().constData(), fn.toUtf8().constData()) == 0) 2965 return installGuestAdditionsFrom (path); 2966 } 2967 2968 /* Download the required image */ 2969 int result = vboxProblem().cannotFindGuestAdditions ( 2970 QDir::toNativeSeparators (src1), QDir::toNativeSeparators (src2)); 2971 if (result == QIMessageBox::Yes) 2972 { 2973 QString source = QString ("http://download.virtualbox.org/virtualbox/%1/") 2974 .arg (vbox.GetVersion().remove ("_OSE")) + name; 2975 QString target = QDir (vboxGlobal().virtualBox().GetHomeFolder()) 2976 .absoluteFilePath (name); 2977 2978 VBoxAdditionsDownloader *dl = 2979 new VBoxAdditionsDownloader (source, target, mDevicesInstallGuestToolsAction); 2980 statusBar()->addWidget (dl, 0); 2981 dl->start(); 2982 } 2983 } 2984 2985 void VBoxConsoleWnd::installGuestAdditionsFrom (const QString &aSource) 2986 { 2987 CVirtualBox vbox = vboxGlobal().virtualBox(); 2988 QString uuid; 2989 2990 CMedium image = vbox.FindDVDImage (aSource); 2991 if (image.isNull()) 2992 { 2993 image = vbox.OpenDVDImage (aSource, uuid); 2994 if (vbox.isOk()) 2995 uuid = image.GetId(); 2996 } 2997 else 2998 uuid = image.GetId(); 2999 3000 if (!vbox.isOk()) 3001 return vboxProblem().cannotOpenMedium (this, vbox, 3002 VBoxDefs::MediumType_DVD, aSource); 3003 3004 Assert (!uuid.isNull()); 3005 CMachine m = csession.GetMachine(); 3006 m.MountMedium ("IDE Controller", 1, 0, uuid); 3007 AssertWrapperOk (m); 3008 if (m.isOk()) 3009 { 3010 if (mIsAutoSaveMedia) 3011 { 3012 m.SaveSettings(); 3013 if (!m.isOk()) 3014 vboxProblem().cannotSaveMachineSettings (m); 3015 } 3016 } 3017 } 3018 3019 void VBoxConsoleWnd::setMask (const QRegion &aRegion) 3020 { 3021 QRegion region = aRegion; 3022 3023 /* The global mask shift cause of toolbars and such things. */ 3024 region.translate (mMaskShift.width(), mMaskShift.height()); 3025 3026 /* Including mini toolbar area */ 3027 QRegion toolBarRegion (mMiniToolBar->mask()); 3028 toolBarRegion.translate (mMiniToolBar->mapToGlobal (toolBarRegion.boundingRect().topLeft()) - QPoint (1, 0)); 3029 region += toolBarRegion; 3030 3031 /* Restrict the drawing to the available space on the screen. 3032 * (The &operator is better than the previous used -operator, 3033 * because this excludes space around the real screen also. 3034 * This is necessary for the mac.) */ 3035 region &= mStrictedRegion; 3036 3037 #ifdef Q_WS_WIN 3038 QRegion difference = mPrevRegion.subtract (region); 3039 3040 /* Region offset calculation */ 3041 int fleft = 0, ftop = 0; 3042 /* I think this isn't necessary anymore because the 4 shifting spacer. 3043 * Has to be verified. */ 3044 // if (isTopLevel()) 3045 // { 3046 // ftop = topData()->ftop; 3047 // fleft = topData()->fleft; 3048 // } 3049 3050 /* Visible region calculation */ 3051 HRGN newReg = CreateRectRgn (0, 0, 0, 0); 3052 CombineRgn (newReg, region.handle(), 0, RGN_COPY); 3053 OffsetRgn (newReg, fleft, ftop); 3054 3055 /* Invisible region calculation */ 3056 HRGN diffReg = CreateRectRgn (0, 0, 0, 0); 3057 CombineRgn (diffReg, difference.handle(), 0, RGN_COPY); 3058 OffsetRgn (diffReg, fleft, ftop); 3059 3060 /* Set the current visible region and clean the previous */ 3061 SetWindowRgn (winId(), newReg, FALSE); 3062 RedrawWindow (NULL, NULL, diffReg, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); 3063 RedrawWindow (console->viewport()->winId(), NULL, NULL, RDW_INVALIDATE); 3064 3065 mPrevRegion = region; 3066 #elif defined(Q_WS_MAC) 3067 # if defined(VBOX_GUI_USE_QUARTZ2D) 3068 if (vboxGlobal().vmRenderMode() == VBoxDefs::Quartz2DMode) 3069 { 3070 /* If we are using the Quartz2D backend we have to trigger 3071 * an repaint only. All the magic clipping stuff is done 3072 * in the paint engine. */ 3073 ::darwinWindowInvalidateShape (console->viewport()); 3074 } 3075 else 3076 # endif 3077 { 3078 /* This is necessary to avoid the flicker by an mask update. 3079 * See http://lists.apple.com/archives/Carbon-development/2001/Apr/msg01651.html 3080 * for the hint. 3081 * There *must* be a better solution. */ 3082 if (!region.isEmpty()) 3083 region |= QRect (0, 0, 1, 1); 3084 // /* Save the current region for later processing in the darwin event handler. */ 3085 // mCurrRegion = region; 3086 // /* We repaint the screen before the ReshapeCustomWindow command. Unfortunately 3087 // * this command flushes a copy of the backbuffer to the screen after the new 3088 // * mask is set. This leads into a missplaced drawing of the content. Currently 3089 // * no alternative to this and also this is not 100% perfect. */ 3090 // repaint(); 3091 // qApp->processEvents(); 3092 // /* Now force the reshaping of the window. This is definitly necessary. */ 3093 // ReshapeCustomWindow (reinterpret_cast <WindowPtr> (winId())); 3094 QMainWindow::setMask (region); 3095 // HIWindowInvalidateShadow (::darwinToWindowRef (console->viewport())); 3096 } 3097 #else 3098 QMainWindow::setMask (region); 3099 #endif 3100 } 3101 3102 void VBoxConsoleWnd::clearMask() 3103 { 3104 #ifdef Q_WS_WIN 3105 SetWindowRgn (winId(), 0, TRUE); 3106 #else 3107 QMainWindow::clearMask(); 3108 #endif 3109 } 3110 3111 /** 3112 * Prepares the "Mount Floppy..." menu by populating the existent host 3113 * floppies. 3114 */ 3115 void VBoxConsoleWnd::prepareFloppyMenu() 3116 { 3117 if (!console) return; 3118 3119 mDevicesMountFloppyMenu->clear(); 3120 3121 CMedium selected = csession.GetMachine().GetMedium("Floppy Controller", 0, 0); 3122 3123 hostFloppyMap.clear(); 3124 CMediumVector drvvec = 3125 vboxGlobal().virtualBox().GetHost().GetFloppyDrives(); 3126 for (int i = 0; i < drvvec.size(); ++i) 3127 { 3128 CMedium hostFloppy = drvvec[i]; 3129 /** @todo set icon */ 3130 QString drvName = hostFloppy.GetName(); 3131 QString description = hostFloppy.GetDescription(); 3132 QString fullName = description.isEmpty() ? 3133 drvName : 3134 QString ("%1 (%2)").arg (description, drvName); 3135 QAction *action = mDevicesMountFloppyMenu->addAction (tr ("Host Drive ") + fullName); 3136 action->setStatusTip (tr ("Mount the selected physical drive of the host PC", 3137 "Floppy tip")); 3138 hostFloppyMap [action] = hostFloppy; 3139 if (machine_state != KMachineState_Running && machine_state != KMachineState_Paused) 3140 action->setEnabled (false); 3141 else if (!selected.isNull()) 3142 if (!selected.GetName().compare (hostFloppy.GetName())) 3143 action->setEnabled (false); 3144 } 3145 3146 if (mDevicesMountFloppyMenu->actions().count() > 0) 3147 mDevicesMountFloppyMenu->addSeparator(); 3148 mDevicesMountFloppyMenu->addAction (mDevicesMountFloppyImageAction); 3149 3150 /* if shown as a context menu */ 3151 if(mDevicesMountFloppyMenu->menuAction()->data().toBool()) 3152 { 3153 mDevicesMountFloppyMenu->addSeparator(); 3154 mDevicesMountFloppyMenu->addAction (mDevicesUnmountFloppyAction); 3155 } 3156 } 3157 3158 /** 3159 * Prepares the "Capture DVD..." menu by populating the existent host 3160 * CD/DVD-ROM drives. 3161 */ 3162 void VBoxConsoleWnd::prepareDVDMenu() 3163 { 3164 if (!console) return; 3165 3166 mDevicesMountDVDMenu->clear(); 3167 3168 CMedium selected = csession.GetMachine().GetMedium("IDE Controller", 1, 0); 3169 3170 hostDVDMap.clear(); 3171 CMediumVector drvvec = 3172 vboxGlobal().virtualBox().GetHost().GetDVDDrives(); 3173 for (int i = 0; i < drvvec.size(); ++i) 3174 { 3175 CMedium hostDVD = drvvec[i]; 3176 /** @todo set icon */ 3177 QString drvName = hostDVD.GetName(); 3178 QString description = hostDVD.GetDescription(); 3179 QString fullName = description.isEmpty() ? 3180 drvName : 3181 QString ("%1 (%2)").arg (description, drvName); 3182 QAction *action = mDevicesMountDVDMenu->addAction ( 3183 tr ("Host Drive ") + fullName); 3184 action->setStatusTip (tr ("Mount the selected physical drive of the host PC", 3185 "CD/DVD tip")); 3186 hostDVDMap [action] = hostDVD; 3187 if (machine_state != KMachineState_Running && machine_state != KMachineState_Paused) 3188 action->setEnabled (false); 3189 else if (!selected.isNull()) 3190 if (!selected.GetName().compare (hostDVD.GetName())) 3191 action->setEnabled (false); 3192 } 3193 3194 if (mDevicesMountDVDMenu->actions().count() > 0) 3195 mDevicesMountDVDMenu->addSeparator(); 3196 mDevicesMountDVDMenu->addAction (mDevicesMountDVDImageAction); 3197 3198 /* if shown as a context menu */ 3199 if(mDevicesMountDVDMenu->menuAction()->data().toBool()) 3200 { 3201 mDevicesMountDVDMenu->addSeparator(); 3202 mDevicesMountDVDMenu->addAction (mDevicesUnmountDVDAction); 3203 } 3204 } 3205 3206 void VBoxConsoleWnd::prepareNetworkMenu() 3207 { 3208 mDevicesNetworkMenu->clear(); 3209 mDevicesNetworkMenu->addAction (mDevicesNetworkDialogAction); 3210 } 3211 3212 void VBoxConsoleWnd::prepareSFMenu() 3213 { 3214 mDevicesSFMenu->clear(); 3215 mDevicesSFMenu->addAction (mDevicesSFDialogAction); 3216 } 3217 3218 void VBoxConsoleWnd::statusTipChanged (const QString & /*aMes*/) 3219 { 3220 mStatusBarChangedInside = mWaitForStatusBarChange; 3221 mWaitForStatusBarChange = false; 3222 } 3223 3224 void VBoxConsoleWnd::clearStatusBar() 3225 { 3226 if (mStatusBarChangedInside) 3227 statusBar()->clearMessage(); 3228 } 3229 3230 /** 3231 * Captures a floppy device corresponding to a given menu action. 3232 */ 3233 void VBoxConsoleWnd::captureFloppy (QAction *aAction) 3234 { 3235 if (!console) return; 3236 3237 CMedium d = hostFloppyMap [aAction]; 3238 /* if null then some other item but host drive is selected */ 3239 if (d.isNull()) return; 3240 3241 CMachine m = csession.GetMachine(); 3242 m.MountMedium ("Floppy Controller", 0, 0, d.GetId()); 3243 AssertWrapperOk (m); 3244 3245 if (m.isOk()) 3246 { 3247 if (mIsAutoSaveMedia) 3248 { 3249 m.SaveSettings(); 3250 if (!m.isOk()) 3251 vboxProblem().cannotSaveMachineSettings (m); 3252 } 3253 } 3254 } 3255 3256 /** 3257 * Captures a CD/DVD-ROM device corresponding to a given menu action. 3258 */ 3259 void VBoxConsoleWnd::captureDVD (QAction *aAction) 3260 { 3261 if (!console) return; 3262 3263 CMedium d = hostDVDMap [aAction]; 3264 /* if null then some other item but host drive is selected */ 3265 if (d.isNull()) return; 3266 3267 CMachine m = csession.GetMachine(); 3268 m.MountMedium ("IDE Controller", 1, 0, d.GetId()); 3269 AssertWrapperOk (m); 3270 3271 if (m.isOk()) 3272 { 3273 if (mIsAutoSaveMedia) 3274 { 3275 m.SaveSettings(); 3276 if (!m.isOk()) 3277 vboxProblem().cannotSaveMachineSettings (m); 3278 } 3279 } 3280 } 3281 3282 /** 3283 * Attach/Detach selected USB Device. 3284 */ 3285 void VBoxConsoleWnd::switchUSB (QAction *aAction) 3286 { 3287 if (!console) return; 3288 3289 CConsole cconsole = csession.GetConsole(); 3290 AssertWrapperOk (csession); 3291 3292 CUSBDevice usb = mDevicesUSBMenu->getUSB (aAction); 3293 /* if null then some other item but a USB device is selected */ 3294 if (usb.isNull()) 3295 return; 3296 3297 if (!aAction->isChecked()) 3298 { 3299 cconsole.DetachUSBDevice (usb.GetId()); 3300 if (!cconsole.isOk()) 3301 { 3302 /// @todo (r=dmik) the dialog should be either modeless 3303 // or we have to pause the VM 3304 vboxProblem().cannotDetachUSBDevice (cconsole, 3305 vboxGlobal().details (usb)); 3306 } 3307 } 3308 else 3309 { 3310 cconsole.AttachUSBDevice (usb.GetId()); 3311 if (!cconsole.isOk()) 3312 { 3313 /// @todo (r=dmik) the dialog should be either modeless 3314 // or we have to pause the VM 3315 vboxProblem().cannotAttachUSBDevice (cconsole, 3316 vboxGlobal().details (usb)); 3317 } 3318 } 3319 } 3320 3321 void VBoxConsoleWnd::showIndicatorContextMenu (QIStateIndicator *ind, QContextMenuEvent *e) 3322 { 3323 if (ind == cd_light) 3324 { 3325 /* set "this is a context menu" flag */ 3326 mDevicesMountDVDMenu->menuAction()->setData (true); 3327 mDevicesMountDVDMenu->exec (e->globalPos()); 3328 mDevicesMountDVDMenu->menuAction()->setData (false); 3329 } 3330 else 3331 if (ind == fd_light) 3332 { 3333 /* set "this is a context menu" flag */ 3334 mDevicesMountFloppyMenu->menuAction()->setData (true); 3335 mDevicesMountFloppyMenu->exec (e->globalPos()); 3336 mDevicesMountFloppyMenu->menuAction()->setData (false); 3337 } 3338 else 3339 if (ind == usb_light) 3340 { 3341 if (mDevicesUSBMenu->isEnabled()) 3342 { 3343 /* set "this is a context menu" flag */ 3344 mDevicesUSBMenu->menuAction()->setData (true); 3345 mDevicesUSBMenu->exec (e->globalPos()); 3346 mDevicesUSBMenu->menuAction()->setData (false); 3347 } 3348 } 3349 else 3350 /* if (ind == vrdp_state) 3351 { 3352 mDevicesVRDPMenu->exec (e->globalPos()); 3353 } 3354 else */ 3355 if (ind == autoresize_state) 3356 { 3357 mVmAutoresizeMenu->exec (e->globalPos()); 3358 } 3359 else 3360 if (ind == mouse_state) 3361 { 3362 mVmDisMouseIntegrMenu->exec (e->globalPos()); 3363 } 3364 else 3365 if (ind == sf_light) 3366 { 3367 if (mDevicesSFMenu->isEnabled()) 3368 { 3369 mDevicesSFMenu->menuAction()->setData (true); 3370 mDevicesSFMenu->exec (e->globalPos()); 3371 mDevicesSFMenu->menuAction()->setData (false); 3372 } 3373 } 3374 else 3375 if (ind == net_light) 3376 { 3377 if (mDevicesNetworkMenu->isEnabled()) 3378 { 3379 mDevicesNetworkMenu->menuAction()->setData (true); 3380 mDevicesNetworkMenu->exec (e->globalPos()); 3381 mDevicesNetworkMenu->menuAction()->setData (false); 3382 } 3383 } 3384 } 3385 3386 void VBoxConsoleWnd::updateDeviceLights() 3387 { 3388 if (console) { 3389 CConsole &cconsole = console->console(); 3390 int st; 3391 if (hd_light->state() != KDeviceActivity_Null) { 3392 st = cconsole.GetDeviceActivity (KDeviceType_HardDisk); 3393 if (hd_light->state() != st) 3394 hd_light->setState (st); 3395 } 3396 if (cd_light->state() != KDeviceActivity_Null) { 3397 st = cconsole.GetDeviceActivity (KDeviceType_DVD); 3398 if (cd_light->state() != st) 3399 cd_light->setState (st); 3400 } 3401 if (fd_light->state() != KDeviceActivity_Null) { 3402 st = cconsole.GetDeviceActivity (KDeviceType_Floppy); 3403 if (fd_light->state() != st) 3404 fd_light->setState (st); 3405 } 3406 if (net_light->state() != KDeviceActivity_Null) { 3407 st = cconsole.GetDeviceActivity (KDeviceType_Network); 3408 if (net_light->state() != st) 3409 net_light->setState (st); 3410 } 3411 if (usb_light->state() != KDeviceActivity_Null) { 3412 st = cconsole.GetDeviceActivity (KDeviceType_USB); 3413 if (usb_light->state() != st) 3414 usb_light->setState (st); 3415 } 3416 if (sf_light->state() != KDeviceActivity_Null) { 3417 st = cconsole.GetDeviceActivity (KDeviceType_SharedFolder); 3418 if (sf_light->state() != st) 3419 sf_light->setState (st); 3420 } 3421 } 3422 } 3423 3424 void VBoxConsoleWnd::updateMachineState (KMachineState state) 3425 { 3426 bool guruMeditation = false; 3427 3428 if (console && machine_state != state) 3429 { 3430 if (state >= KMachineState_Running) 3431 { 3432 switch (state) 3433 { 3434 case KMachineState_Stuck: 3435 { 3436 guruMeditation = true; 3437 break; 3438 } 3439 case KMachineState_Paused: 3440 { 3441 if (!mVmPauseAction->isChecked()) 3442 mVmPauseAction->setChecked (true); 3443 break; 3444 } 3445 case KMachineState_Running: 3446 { 3447 if (machine_state == KMachineState_Paused && mVmPauseAction->isChecked()) 3448 mVmPauseAction->setChecked (false); 3449 break; 3450 } 3451 #ifdef Q_WS_X11 3452 case KMachineState_Starting: 3453 { 3454 /* The keyboard handler may wish to do some release logging 3455 on startup. Tell it that the logger is now active. */ 3456 doXKeyboardLogging(QX11Info::display()); 3457 break; 3458 } 3459 #endif 3460 default: 3461 break; 3462 } 3463 } 3464 3465 bool isRunningOrPaused = state == KMachineState_Running || 3466 state == KMachineState_Paused; 3467 3468 /* enable/disable actions that are not managed by 3469 * updateAppearanceOf() */ 3470 3471 mRunningActions->setEnabled (state == KMachineState_Running); 3472 mRunningOrPausedActions->setEnabled (isRunningOrPaused); 3473 3474 machine_state = state; 3475 3476 updateAppearanceOf (Caption | FloppyStuff | DVDStuff | NetworkStuff | 3477 USBStuff | VRDPStuff | PauseAction | 3478 DisableMouseIntegrAction); 3479 3480 if (state < KMachineState_Running) 3481 { 3482 /* 3483 * VM has been powered off or saved or aborted, no matter 3484 * internally or externally -- we must *safely* close the console 3485 * window unless auto closure is disabled. 3486 */ 3487 if (!no_auto_close) 3488 tryClose(); 3489 } 3490 } 3491 3492 if (guruMeditation) 3493 { 3494 CConsole cconsole = console->console(); 3495 QString logFolder = cconsole.GetMachine().GetLogFolder(); 3496 3497 /* Take the screenshot for debugging purposes and save it */ 3498 QString fname = logFolder + "/VBox.png"; 3499 3500 /// @todo for some reason, IDisplay::takeScreenShot() may not work 3501 /// properly on a VM which is Stuck -- investigate it. 3502 CDisplay dsp = cconsole.GetDisplay(); 3503 QImage shot = QImage (dsp.GetWidth(), dsp.GetHeight(), QImage::Format_RGB32); 3504 dsp.TakeScreenShot (shot.bits(), shot.width(), shot.height()); 3505 shot.save (QFile::encodeName (fname), "PNG"); 3506 3507 if (vboxProblem().remindAboutGuruMeditation ( 3508 cconsole, QDir::toNativeSeparators (logFolder))) 3509 { 3510 qApp->processEvents(); 3511 cconsole.PowerDown(); 3512 if (!cconsole.isOk()) 3513 vboxProblem().cannotStopMachine (cconsole); 3514 } 3515 } 3516 3517 #ifdef Q_WS_MAC 3518 if (console) 3519 console->updateDockOverlay(); 3520 #endif 3521 } 3522 3523 void VBoxConsoleWnd::updateMouseState (int state) 3524 { 3525 mVmDisableMouseIntegrAction->setEnabled (state & VBoxConsoleView::MouseAbsolute); 3526 3527 if ((state & VBoxConsoleView::MouseAbsoluteDisabled) && 3528 (state & VBoxConsoleView::MouseAbsolute) && 3529 !(state & VBoxConsoleView::MouseCaptured)) 3530 { 3531 mouse_state->setState (4); 3532 } 3533 else 3534 { 3535 mouse_state->setState (state & (VBoxConsoleView::MouseAbsolute | 3536 VBoxConsoleView::MouseCaptured)); 3537 } 3538 } 3539 3540 3541 void VBoxConsoleWnd::updateAdditionsState (const QString &aVersion, 3542 bool aActive, 3543 bool aSeamlessSupported, 3544 bool aGraphicsSupported) 3545 { 3546 mVmAutoresizeGuestAction->setEnabled (aActive && aGraphicsSupported); 3547 if ( (mIsSeamlessSupported != aSeamlessSupported) 3548 || (mIsGraphicsSupported != aGraphicsSupported)) 3549 { 3550 mVmSeamlessAction->setEnabled (aSeamlessSupported && aGraphicsSupported); 3551 mIsSeamlessSupported = aSeamlessSupported; 3552 mIsGraphicsSupported = aGraphicsSupported; 3553 /* If seamless mode should be enabled then check if it is enabled 3554 * currently and re-enable it if open-view procedure is finished */ 3555 if ( mVmSeamlessAction->isChecked() 3556 && mIsOpenViewFinished 3557 && aSeamlessSupported 3558 && aGraphicsSupported) 3559 toggleFullscreenMode (true, true); 3560 /* Disable auto-resizing if advanced graphics are not available */ 3561 console->setAutoresizeGuest ( mIsGraphicsSupported 3562 && mVmAutoresizeGuestAction->isChecked()); 3563 mVmAutoresizeGuestAction->setEnabled (mIsGraphicsSupported); 3564 } 3565 3566 /* Check the GA version only in case of additions are active */ 3567 if (!aActive) 3568 return; 3569 3570 /* Check the Guest Additions version and warn the user about possible 3571 * compatibility issues in case if the installed version is outdated. */ 3572 uint version = aVersion.toUInt(); 3573 QString versionStr = QString ("%1.%2") 3574 .arg (RT_HIWORD (version)).arg (RT_LOWORD (version)); 3575 QString expectedStr = QString ("%1.%2") 3576 .arg (VMMDEV_VERSION_MAJOR).arg (VMMDEV_VERSION_MINOR); /** @todo r=bird: This isn't want we want! We want the VirtualBox version of the additions, all three numbers. See @bugref{4084}.*/ 3577 3578 if (RT_HIWORD (version) < VMMDEV_VERSION_MAJOR) 3579 { 3580 vboxProblem().warnAboutTooOldAdditions (this, versionStr, expectedStr); 3581 } 3582 else if (RT_HIWORD (version) == VMMDEV_VERSION_MAJOR && 3583 RT_LOWORD (version) < VMMDEV_VERSION_MINOR) 3584 { 3585 vboxProblem().warnAboutOldAdditions (this, versionStr, expectedStr); 3586 } 3587 else if (version > VMMDEV_VERSION) 3588 { 3589 vboxProblem().warnAboutNewAdditions (this, versionStr, expectedStr); 3590 } 3591 } 3592 3593 void VBoxConsoleWnd::updateMediaDriveState (VBoxDefs::MediumType aType) 3594 { 3595 Assert (aType == VBoxDefs::MediumType_DVD || aType == VBoxDefs::MediumType_Floppy); 3596 updateAppearanceOf (aType == VBoxDefs::MediumType_DVD ? DVDStuff : 3597 aType == VBoxDefs::MediumType_Floppy ? FloppyStuff : 3598 AllStuff); 3599 } 3600 3601 void VBoxConsoleWnd::updateSharedFoldersState() 3602 { 3603 updateAppearanceOf (SharedFolderStuff); 3604 } 3605 3606 void VBoxConsoleWnd::updateUsbState() 3607 { 3608 updateAppearanceOf (USBStuff); 3609 } 3610 3611 void VBoxConsoleWnd::updateNetworkAdaptersState() 3612 { 3613 updateAppearanceOf (NetworkStuff); 3614 } 3615 3616 /** 3617 * Helper to safely close the main console window. 3618 * 3619 * This method ensures that close() will not be called if there is some 3620 * modal widget currently being executed, as it can cause uninitialization 3621 * at the point of code where it is not expected at all (example: 3622 * VBoxConsoleView::mouseEvent() calling 3623 * VBoxProblemReporter::confirmInputCapture()). Instead, an attempt to 3624 * close the current modal widget is done and tryClose() is rescheduled for 3625 * later execution using a single-shot zero timer. 3626 * 3627 * In particular, this method is used by updateMachineState() when the VM 3628 * goes offline, which can even happen if we are inside the modal event loop, 3629 * (for example, the VM has been externally powered off or the guest OS 3630 * has initiated a shutdown procedure). 3631 */ 3632 void VBoxConsoleWnd::tryClose() 3633 { 3634 /* First close any open modal & popup widgets. Use a single shot with 3635 * timeout 0 to allow the widgets to cleany close and test then again. If 3636 * all open widgets are closed destroy ourself. */ 3637 3638 /// #warning "port me": 3639 /// @todo (r=dsen) we have to test this on windows 3640 3641 QWidget *widget = QApplication::activeModalWidget() ? 3642 QApplication::activeModalWidget() : 3643 QApplication::activePopupWidget() ? 3644 QApplication::activePopupWidget() : 0; 3645 if (widget) 3646 { 3647 widget->close(); 3648 QTimer::singleShot (0, this, SLOT (tryClose())); 3649 } 3650 else 3651 close(); 3652 } 3653 3654 /** 3655 * Called (on non-UI thread!) when a global GUI setting changes. 3656 */ 3657 void VBoxConsoleWnd::processGlobalSettingChange (const char * /*publicName*/, 3658 const char * /*name*/) 3659 { 3660 hostkey_name->setText (QIHotKeyEdit::keyName (vboxGlobal().settings().hostKey())); 3661 } 3268 } 3269 3270 mConsole->detach(); 3271 centralWidget()->layout()->removeWidget (mConsole); 3272 delete mConsole; 3273 mConsole = 0; 3274 mSession.Close(); 3275 mSession.detach(); 3276 3277 LogFlowFuncLeave(); 3278 } 3279 3280 #ifdef VBOX_WITH_DEBUGGER_GUI 3662 3281 3663 3282 /** … … 3666 3285 void VBoxConsoleWnd::dbgPrepareDebugMenu() 3667 3286 { 3668 #ifdef VBOX_WITH_DEBUGGER_GUI3669 3287 /* The "Logging" item. */ 3670 3288 bool fEnabled = false; 3671 3289 bool fChecked = false; 3672 CConsole c console = csession.GetConsole();3673 if (c console.isOk())3674 { 3675 CMachineDebugger cdebugger = c console.GetDebugger();3676 if (c console.isOk())3290 CConsole console = mSession.GetConsole(); 3291 if (console.isOk()) 3292 { 3293 CMachineDebugger cdebugger = console.GetDebugger(); 3294 if (console.isOk()) 3677 3295 { 3678 3296 fEnabled = true; … … 3684 3302 if (fChecked != mDbgLoggingAction->isChecked()) 3685 3303 mDbgLoggingAction->setChecked (fChecked); 3686 #endif /* VBOX_WITH_DEBUGGER_GUI */3687 3304 } 3688 3305 … … 3692 3309 void VBoxConsoleWnd::dbgShowStatistics() 3693 3310 { 3694 #ifdef VBOX_WITH_DEBUGGER_GUI3695 3311 if (dbgCreated()) 3696 3312 mDbgGuiVT->pfnShowStatistics (mDbgGui); 3697 #endif3698 3313 } 3699 3314 … … 3703 3318 void VBoxConsoleWnd::dbgShowCommandLine() 3704 3319 { 3705 #ifdef VBOX_WITH_DEBUGGER_GUI3706 3320 if (dbgCreated()) 3707 3321 mDbgGuiVT->pfnShowCommandLine (mDbgGui); 3708 #endif3709 3322 } 3710 3323 … … 3712 3325 * Called when the Debug->Logging menu item is selected. 3713 3326 */ 3714 void VBoxConsoleWnd::dbgLoggingToggled (bool aState)3327 void VBoxConsoleWnd::dbgLoggingToggled (bool aState) 3715 3328 { 3716 3329 NOREF(aState); 3717 #ifdef VBOX_WITH_DEBUGGER_GUI 3718 CConsole cconsole = csession.GetConsole(); 3719 if (cconsole.isOk()) 3720 { 3721 CMachineDebugger cdebugger = cconsole.GetDebugger(); 3722 if (cconsole.isOk()) 3723 cdebugger.SetLogEnabled(aState); 3724 } 3725 #endif 3726 } 3727 3728 #ifdef VBOX_WITH_DEBUGGER_GUI 3330 CConsole console = mSession.GetConsole(); 3331 if (console.isOk()) 3332 { 3333 CMachineDebugger cdebugger = console.GetDebugger(); 3334 if (console.isOk()) 3335 cdebugger.SetLogEnabled (aState); 3336 } 3337 } 3729 3338 3730 3339 /** … … 3744 3353 3745 3354 PFNDBGGUICREATE pfnGuiCreate; 3746 int rc = RTLdrGetSymbol (hLdrMod, "DBGGuiCreate", (void **)&pfnGuiCreate);3355 int rc = RTLdrGetSymbol (hLdrMod, "DBGGuiCreate", (void**) &pfnGuiCreate); 3747 3356 if (RT_SUCCESS (rc)) 3748 3357 { 3749 ISession *pISession = csession.raw();3358 ISession *pISession = mSession.raw(); 3750 3359 rc = pfnGuiCreate (pISession, &mDbgGui, &mDbgGuiVT); 3751 3360 if (RT_SUCCESS (rc)) 3752 3361 { 3753 if ( DBGGUIVT_ARE_VERSIONS_COMPATIBLE (mDbgGuiVT->u32Version, DBGGUIVT_VERSION)3754 ||mDbgGuiVT->u32EndVersion == mDbgGuiVT->u32Version)3362 if (DBGGUIVT_ARE_VERSIONS_COMPATIBLE (mDbgGuiVT->u32Version, DBGGUIVT_VERSION) || 3363 mDbgGuiVT->u32EndVersion == mDbgGuiVT->u32Version) 3755 3364 { 3756 mDbgGuiVT->pfnSetParent (mDbgGui, (QWidget *)this);3757 mDbgGuiVT->pfnSetMenu (mDbgGui, (QMenu *)mDbgMenu);3365 mDbgGuiVT->pfnSetParent (mDbgGui, (QWidget*) this); 3366 mDbgGuiVT->pfnSetMenu (mDbgGui, (QMenu*) mDbgMenu); 3758 3367 dbgAdjustRelativePos(); 3759 3368 return true; … … 3769 3378 LogRel (("RTLdrGetSymbol(,\"DBGGuiCreate\",) -> %Rrc\n", rc)); 3770 3379 3771 mDbgGui = NULL;3772 mDbgGuiVT = NULL;3380 mDbgGui = 0; 3381 mDbgGuiVT = 0; 3773 3382 return false; 3774 3383 } … … 3782 3391 { 3783 3392 mDbgGuiVT->pfnDestroy (mDbgGui); 3784 mDbgGui = NULL;3785 mDbgGuiVT = NULL;3393 mDbgGui = 0; 3394 mDbgGuiVT = 0; 3786 3395 } 3787 3396 } … … 3800 3409 3801 3410 #endif /* VBOX_WITH_DEBUGGER_GUI */ 3411 3412 VBoxStorageDialog::VBoxStorageDialog (QWidget *aParent, CSession &aSession) 3413 : QIWithRetranslateUI <QDialog> (aParent) 3414 , mSettings (0) 3415 , mSession (aSession) 3416 { 3417 setModal (true); 3418 /* Setup Dialog's options */ 3419 setWindowIcon (QIcon (":/attachment_16px.png")); 3420 setSizeGripEnabled (true); 3421 3422 /* Setup main dialog's layout */ 3423 QVBoxLayout *mainLayout = new QVBoxLayout (this); 3424 VBoxGlobal::setLayoutMargin (mainLayout, 10); 3425 mainLayout->setSpacing (10); 3426 3427 /* Setup settings layout */ 3428 mSettings = new VBoxVMSettingsHD (true); 3429 VBoxGlobal::setLayoutMargin (mSettings->layout(), 0); 3430 mainLayout->addWidget (mSettings); 3431 mSettings->getFrom (aSession.GetMachine()); 3432 3433 /* Setup button's layout */ 3434 QIDialogButtonBox *buttonBox = new QIDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help); 3435 3436 connect (buttonBox, SIGNAL (helpRequested()), &vboxProblem(), SLOT (showHelpHelpDialog())); 3437 connect (buttonBox, SIGNAL (accepted()), this, SLOT (accept())); 3438 connect (buttonBox, SIGNAL (rejected()), this, SLOT (reject())); 3439 mainLayout->addWidget (buttonBox); 3440 3441 retranslateUi(); 3442 } 3443 3444 void VBoxStorageDialog::retranslateUi() 3445 { 3446 setWindowTitle (tr ("Storage Devices")); 3447 } 3448 3449 void VBoxStorageDialog::accept() 3450 { 3451 mSettings->putBackTo(); 3452 CMachine machine = mSession.GetMachine(); 3453 machine.SaveSettings(); 3454 if (!machine.isOk()) 3455 vboxProblem().cannotSaveMachineSettings (machine); 3456 QDialog::accept(); 3457 } 3458 3459 void VBoxStorageDialog::showEvent (QShowEvent *aEvent) 3460 { 3461 resize (450, 300); 3462 VBoxGlobal::centerWidget (this, parentWidget()); 3463 setMinimumWidth (400); 3464 QDialog::showEvent (aEvent); 3465 } 3802 3466 3803 3467 VBoxNetworkDialog::VBoxNetworkDialog (QWidget *aParent, CSession &aSession) -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsHD.cpp
r23585 r23723 1436 1436 1437 1437 /* Storage Delegate */ 1438 StorageDelegate::StorageDelegate (QObject *aParent )1438 StorageDelegate::StorageDelegate (QObject *aParent, bool aDisableStaticControls) 1439 1439 : QItemDelegate (aParent) 1440 , mDisableStaticControls (aDisableStaticControls) 1440 1441 { 1441 1442 } … … 1494 1495 1495 1496 /* Draw Controller Additions */ 1496 if ( model->data (aIndex, StorageModel::R_IsController).toBool() && state & QStyle::State_Selected)1497 if (!mDisableStaticControls && model->data (aIndex, StorageModel::R_IsController).toBool() && state & QStyle::State_Selected) 1497 1498 { 1498 1499 DeviceTypeList devicesList (model->data (aIndex, StorageModel::R_CtrDevices).value <DeviceTypeList>()); … … 1546 1547 * Used as HD Settings widget. 1547 1548 */ 1548 VBoxVMSettingsHD::VBoxVMSettingsHD ()1549 VBoxVMSettingsHD::VBoxVMSettingsHD (bool aDisableStaticControls /* = false */) 1549 1550 : mValidator (0) 1550 1551 , mIsPolished (false) 1552 , mDisableStaticControls (aDisableStaticControls) 1551 1553 { 1552 1554 /* Apply UI decorations */ … … 1607 1609 /* Storage Model/View */ 1608 1610 mStorageModel = new StorageModel (mTwStorageTree); 1609 StorageDelegate *storageDelegate = new StorageDelegate (mTwStorageTree );1611 StorageDelegate *storageDelegate = new StorageDelegate (mTwStorageTree, mDisableStaticControls); 1610 1612 mTwStorageTree->setMouseTracking (true); 1611 1613 mTwStorageTree->setContextMenuPolicy (Qt::CustomContextMenu); … … 1621 1623 mTbStorageBar->addAction (mAddCtrAction); 1622 1624 mTbStorageBar->addAction (mDelCtrAction); 1625 mTbStorageBar->setHidden (mDisableStaticControls); 1623 1626 1624 1627 #ifdef Q_WS_MAC … … 1733 1736 void VBoxVMSettingsHD::putBackTo() 1734 1737 { 1735 /* Remove currently present controllers & attachments */ 1736 CStorageControllerVector controllers = mMachine.GetStorageControllers(); 1737 foreach (const CStorageController &controller, controllers) 1738 { 1739 QString controllerName (controller.GetName()); 1740 CMediumAttachmentVector attachments = mMachine.GetMediumAttachmentsOfController (controllerName); 1741 foreach (const CMediumAttachment &attachment, attachments) 1742 mMachine.DetachDevice (controllerName, attachment.GetPort(), attachment.GetDevice()); 1743 mMachine.RemoveStorageController (controllerName); 1744 } 1745 1746 /* Save created controllers & attachments */ 1747 QModelIndex rootIndex = mStorageModel->root(); 1748 for (int i = 0; i < mStorageModel->rowCount (rootIndex); ++ i) 1749 { 1750 QModelIndex ctrIndex = rootIndex.child (i, 0); 1751 QString ctrName = mStorageModel->data (ctrIndex, StorageModel::R_CtrName).toString(); 1752 KStorageBus ctrBusType = mStorageModel->data (ctrIndex, StorageModel::R_CtrBusType).value <KStorageBus>(); 1753 KStorageControllerType ctrType = mStorageModel->data (ctrIndex, StorageModel::R_CtrType).value <KStorageControllerType>(); 1754 CStorageController ctr = mMachine.AddStorageController (ctrName, ctrBusType); 1755 ctr.SetControllerType (ctrType); 1756 for (int j = 0; j < mStorageModel->rowCount (ctrIndex); ++ j) 1757 { 1758 QModelIndex attIndex = ctrIndex.child (j, 0); 1759 StorageSlot attStorageSlot = mStorageModel->data (attIndex, StorageModel::R_AttSlot).value <StorageSlot>(); 1760 KDeviceType attDeviceType = mStorageModel->data (attIndex, StorageModel::R_AttDevice).value <KDeviceType>(); 1761 QString attMediumId = mStorageModel->data (attIndex, StorageModel::R_AttMediumId).toString(); 1762 mMachine.AttachDevice (ctrName, attStorageSlot.port, attStorageSlot.device, attDeviceType, attMediumId); 1763 CMediumAttachment attachment = mMachine.GetMediumAttachment (ctrName, attStorageSlot.port, attStorageSlot.device); 1764 attachment.SetPassthrough (mStorageModel->data (attIndex, StorageModel::R_AttIsHostDrive).toBool() && 1765 mStorageModel->data (attIndex, StorageModel::R_AttIsPassthrough).toBool()); 1738 if (mDisableStaticControls) 1739 { 1740 /* Just search for the currently present CD/DVD & Floppy devices to update */ 1741 QModelIndex rootIndex = mStorageModel->root(); 1742 for (int i = 0; i < mStorageModel->rowCount (rootIndex); ++ i) 1743 { 1744 QModelIndex ctrIndex = rootIndex.child (i, 0); 1745 QString ctrName = mStorageModel->data (ctrIndex, StorageModel::R_CtrName).toString(); 1746 for (int j = 0; j < mStorageModel->rowCount (ctrIndex); ++ j) 1747 { 1748 QModelIndex attIndex = ctrIndex.child (j, 0); 1749 KDeviceType attDeviceType = mStorageModel->data (attIndex, StorageModel::R_AttDevice).value <KDeviceType>(); 1750 if (attDeviceType != KDeviceType_DVD && attDeviceType != KDeviceType_Floppy) continue; 1751 StorageSlot attStorageSlot = mStorageModel->data (attIndex, StorageModel::R_AttSlot).value <StorageSlot>(); 1752 QString attMediumId = mStorageModel->data (attIndex, StorageModel::R_AttMediumId).toString(); 1753 const CMedium &medium = mMachine.GetMedium (ctrName, attStorageSlot.port, attStorageSlot.device); 1754 if ((medium.isNull() && !QUuid (attMediumId).isNull()) || 1755 (!medium.isNull() && medium.GetId() != attMediumId)) 1756 mMachine.MountMedium (ctrName, attStorageSlot.port, attStorageSlot.device, attMediumId); 1757 } 1758 } 1759 } 1760 else 1761 { 1762 /* Remove currently present controllers & attachments */ 1763 CStorageControllerVector controllers = mMachine.GetStorageControllers(); 1764 foreach (const CStorageController &controller, controllers) 1765 { 1766 QString controllerName (controller.GetName()); 1767 CMediumAttachmentVector attachments = mMachine.GetMediumAttachmentsOfController (controllerName); 1768 foreach (const CMediumAttachment &attachment, attachments) 1769 mMachine.DetachDevice (controllerName, attachment.GetPort(), attachment.GetDevice()); 1770 mMachine.RemoveStorageController (controllerName); 1771 } 1772 1773 /* Save created controllers & attachments */ 1774 QModelIndex rootIndex = mStorageModel->root(); 1775 for (int i = 0; i < mStorageModel->rowCount (rootIndex); ++ i) 1776 { 1777 QModelIndex ctrIndex = rootIndex.child (i, 0); 1778 QString ctrName = mStorageModel->data (ctrIndex, StorageModel::R_CtrName).toString(); 1779 KStorageBus ctrBusType = mStorageModel->data (ctrIndex, StorageModel::R_CtrBusType).value <KStorageBus>(); 1780 KStorageControllerType ctrType = mStorageModel->data (ctrIndex, StorageModel::R_CtrType).value <KStorageControllerType>(); 1781 CStorageController ctr = mMachine.AddStorageController (ctrName, ctrBusType); 1782 ctr.SetControllerType (ctrType); 1783 for (int j = 0; j < mStorageModel->rowCount (ctrIndex); ++ j) 1784 { 1785 QModelIndex attIndex = ctrIndex.child (j, 0); 1786 StorageSlot attStorageSlot = mStorageModel->data (attIndex, StorageModel::R_AttSlot).value <StorageSlot>(); 1787 KDeviceType attDeviceType = mStorageModel->data (attIndex, StorageModel::R_AttDevice).value <KDeviceType>(); 1788 QString attMediumId = mStorageModel->data (attIndex, StorageModel::R_AttMediumId).toString(); 1789 mMachine.AttachDevice (ctrName, attStorageSlot.port, attStorageSlot.device, attDeviceType, attMediumId); 1790 CMediumAttachment attachment = mMachine.GetMediumAttachment (ctrName, attStorageSlot.port, attStorageSlot.device); 1791 attachment.SetPassthrough (mStorageModel->data (attIndex, StorageModel::R_AttIsHostDrive).toBool() && 1792 mStorageModel->data (attIndex, StorageModel::R_AttIsPassthrough).toBool()); 1793 } 1766 1794 } 1767 1795 } … … 1891 1919 { 1892 1920 mStorageModel->setData (attIndex, attMediumId, StorageModel::R_AttMediumId); 1893 mValidator->revalidate();1921 if (mValidator) mValidator->revalidate(); 1894 1922 } 1895 1923 } … … 1910 1938 { 1911 1939 mStorageModel->setData (attIndex, firstAvailableId, StorageModel::R_AttMediumId); 1912 mValidator->revalidate();1940 if (mValidator) mValidator->revalidate(); 1913 1941 } 1914 1942 } … … 1953 1981 mStorageModel->delController (QUuid (mStorageModel->data (index, StorageModel::R_ItemId).toString())); 1954 1982 emit storageChanged(); 1955 mValidator->revalidate();1983 if (mValidator) mValidator->revalidate(); 1956 1984 } 1957 1985 … … 2002 2030 QUuid (mStorageModel->data (index, StorageModel::R_ItemId).toString())); 2003 2031 emit storageChanged(); 2004 mValidator->revalidate();2032 if (mValidator) mValidator->revalidate(); 2005 2033 } 2006 2034 … … 2023 2051 /* Getting Controller Name */ 2024 2052 mLeName->setText (mStorageModel->data (index, StorageModel::R_CtrName).toString()); 2053 mLbName->setEnabled (!mDisableStaticControls); 2054 mLeName->setEnabled (!mDisableStaticControls); 2025 2055 2026 2056 /* Getting Controller Sub type */ … … 2032 2062 int ctrPos = mCbType->findText (vboxGlobal().toString (type)); 2033 2063 mCbType->setCurrentIndex (ctrPos == -1 ? 0 : ctrPos); 2064 mLbType->setEnabled (!mDisableStaticControls); 2065 mCbType->setEnabled (!mDisableStaticControls); 2034 2066 2035 2067 /* Showing Controller Page */ … … 2047 2079 int attSlotPos = mCbSlot->findText (vboxGlobal().toString (slt)); 2048 2080 mCbSlot->setCurrentIndex (attSlotPos == -1 ? 0 : attSlotPos); 2081 mLbSlot->setEnabled (!mDisableStaticControls); 2082 mCbSlot->setEnabled (!mDisableStaticControls); 2049 2083 2050 2084 /* Getting Show Diffs state */ 2051 2085 bool isShowDiffs = mStorageModel->data (index, StorageModel::R_AttIsShowDiffs).toBool(); 2052 2086 mCbShowDiffs->setChecked (isShowDiffs); 2087 mCbShowDiffs->setEnabled (!mDisableStaticControls); 2053 2088 2054 2089 /* Getting Attachment Medium */ … … 2058 2093 case KDeviceType_HardDisk: 2059 2094 mLbVdi->setText (tr ("Hard &Disk:")); 2095 mLbVdi->setEnabled (!mDisableStaticControls); 2096 mCbVdi->setEnabled (!mDisableStaticControls); 2097 mTbVmm->setEnabled (!mDisableStaticControls); 2060 2098 break; 2061 2099 case KDeviceType_DVD: 2062 2100 mLbVdi->setText (tr ("&CD/DVD Device:")); 2101 mLbVdi->setEnabled (true); 2102 mCbVdi->setEnabled (true); 2103 mTbVmm->setEnabled (true); 2063 2104 break; 2064 2105 case KDeviceType_Floppy: 2065 2106 mLbVdi->setText (tr ("&Floppy Device:")); 2107 mLbVdi->setEnabled (true); 2108 mCbVdi->setEnabled (true); 2109 mTbVmm->setEnabled (true); 2066 2110 break; 2067 2111 default: … … 2075 2119 /* Getting Passthrough state */ 2076 2120 bool isHostDrive = mStorageModel->data (index, StorageModel::R_AttIsHostDrive).toBool(); 2077 mCbPassthrough->setEnabled ( isHostDrive);2121 mCbPassthrough->setEnabled (!mDisableStaticControls && isHostDrive); 2078 2122 mCbPassthrough->setChecked (isHostDrive && mStorageModel->data (index, StorageModel::R_AttIsPassthrough).toBool()); 2079 2123 … … 2098 2142 } 2099 2143 2100 mValidator->revalidate();2144 if (mValidator) mValidator->revalidate(); 2101 2145 2102 2146 mIsLoadingInProgress = false; … … 2168 2212 bool isAttachmentsPossible = mStorageModel->data (index, StorageModel::R_IsMoreAttachmentsPossible).toBool(); 2169 2213 2170 mAddCtrAction->setEnabled ( isIDEPossible || isSATAPossible || isSCSIPossible || isFloppyPossible);2171 mAddIDECtrAction->setEnabled ( isIDEPossible);2172 mAddSATACtrAction->setEnabled ( isSATAPossible);2173 mAddSCSICtrAction->setEnabled ( isSCSIPossible);2174 mAddFloppyCtrAction->setEnabled ( isFloppyPossible);2175 2176 mAddAttAction->setEnabled ( isController && isAttachmentsPossible);2177 mAddHDAttAction->setEnabled ( isController && isAttachmentsPossible);2178 mAddCDAttAction->setEnabled ( isController && isAttachmentsPossible);2179 mAddFDAttAction->setEnabled ( isController && isAttachmentsPossible);2180 2181 mDelCtrAction->setEnabled ( isController);2182 mDelAttAction->setEnabled ( isAttachment);2214 mAddCtrAction->setEnabled (!mDisableStaticControls && (isIDEPossible || isSATAPossible || isSCSIPossible || isFloppyPossible)); 2215 mAddIDECtrAction->setEnabled (!mDisableStaticControls && isIDEPossible); 2216 mAddSATACtrAction->setEnabled (!mDisableStaticControls && isSATAPossible); 2217 mAddSCSICtrAction->setEnabled (!mDisableStaticControls && isSCSIPossible); 2218 mAddFloppyCtrAction->setEnabled (!mDisableStaticControls && isFloppyPossible); 2219 2220 mAddAttAction->setEnabled (!mDisableStaticControls && isController && isAttachmentsPossible); 2221 mAddHDAttAction->setEnabled (!mDisableStaticControls && isController && isAttachmentsPossible); 2222 mAddCDAttAction->setEnabled (!mDisableStaticControls && isController && isAttachmentsPossible); 2223 mAddFDAttAction->setEnabled (!mDisableStaticControls && isController && isAttachmentsPossible); 2224 2225 mDelCtrAction->setEnabled (!mDisableStaticControls && isController); 2226 mDelAttAction->setEnabled (!mDisableStaticControls && isAttachment); 2183 2227 } 2184 2228 … … 2486 2530 mStorageModel->addAttachment (QUuid (mStorageModel->data (index, StorageModel::R_ItemId).toString()), aDevice); 2487 2531 emit storageChanged(); 2488 mValidator->revalidate();2532 if (mValidator) mValidator->revalidate(); 2489 2533 } 2490 2534
Note:
See TracChangeset
for help on using the changeset viewer.