Changeset 26889 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Feb 28, 2010 2:57:36 PM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 1 added
- 8 edited
- 6 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r26823 r26889 225 225 VBOX_GUI_INC_DIRS += \ 226 226 ./src/runtime \ 227 ./src/runtime/normal 227 ./src/runtime/normal \ 228 ./src/runtime/fullscreen 228 229 endif 229 230 … … 372 373 src/runtime/normal/UIMachineLogicNormal.h \ 373 374 src/runtime/normal/UIMachineWindowNormal.h \ 374 src/runtime/normal/UIMachineViewNormal.h 375 src/runtime/normal/UIMachineViewNormal.h \ 376 src/runtime/fullscreen/UIMachineLogicFullscreen.h \ 377 src/runtime/fullscreen/UIMachineWindowFullscreen.h \ 378 src/runtime/fullscreen/UIMachineViewFullscreen.h 375 379 endif 376 380 … … 501 505 src/runtime/normal/UIMachineLogicNormal.cpp \ 502 506 src/runtime/normal/UIMachineWindowNormal.cpp \ 503 src/runtime/normal/UIMachineViewNormal.cpp 507 src/runtime/normal/UIMachineViewNormal.cpp \ 508 src/runtime/fullscreen/UIMachineLogicFullscreen.cpp \ 509 src/runtime/fullscreen/UIMachineWindowFullscreen.cpp \ 510 src/runtime/fullscreen/UIMachineViewFullscreen.cpp 504 511 endif 505 512 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r26868 r26889 395 395 else if (mGlobal.isVMConsoleProcess()) 396 396 { 397 #ifndef VBOX_WITH_NEW_RUNTIME_CORE 398 /* TODO_NEW_CORE */ 397 399 /* Check for the currently running machine */ 398 400 CMachine machine = mGlobal.consoleWnd().session().GetMachine(); … … 409 411 } 410 412 } 413 #endif /* VBOX_WITH_NEW_RUNTIME_CORE */ 411 414 } 412 415 #endif /* Q_WS_MAC */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r26868 r26889 45 45 #include "UIMachineLogic.h" 46 46 #include "UIMachineLogicNormal.h" 47 //#include "UIMachineLogicFullscreen.h"47 #include "UIMachineLogicFullscreen.h" 48 48 //#include "UIMachineLogicSeamless.h" 49 49 #include "UIMachineWindow.h" … … 352 352 break; 353 353 case UIVisualStateType_Fullscreen: 354 // logic = new UIMachineLogicFullscreen(pParent, pSession, pActionsPool); 355 logic = new UIMachineLogicNormal(pParent, pSession, pActionsPool); 354 logic = new UIMachineLogicFullscreen(pParent, pSession, pActionsPool); 356 355 break; 357 356 case UIVisualStateType_Seamless: -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r26878 r26889 43 43 #include "UIMachineView.h" 44 44 #include "UIMachineViewNormal.h" 45 #include "UIMachineViewFullscreen.h" 45 46 46 47 #ifdef Q_WS_PM … … 127 128 break; 128 129 case UIVisualStateType_Fullscreen: 129 view = new UIMachineView Normal( pMachineWindow130 , renderMode130 view = new UIMachineViewFullscreen( pMachineWindow 131 , renderMode 131 132 #ifdef VBOX_WITH_VIDEOHWACCEL 132 , bAccelerate2DVideo133 #endif 134 );133 , bAccelerate2DVideo 134 #endif 135 ); 135 136 break; 136 137 case UIVisualStateType_Seamless: … … 184 185 } 185 186 187 #include <QMainWindow> 186 188 UIMachineView::UIMachineView( UIMachineWindow *pMachineWindow 187 189 , VBoxDefs::RenderMode renderMode … … 190 192 #endif 191 193 ) 194 // TODO_NEW_CORE: really think of if this is right 195 // : QAbstractScrollArea(((QMainWindow*)pMachineWindow->machineWindow())->centralWidget()) 192 196 : QAbstractScrollArea(pMachineWindow->machineWindow()) 197 , m_desktopGeometryType(DesktopGeo_Invalid) 193 198 , m_pMachineWindow(pMachineWindow) 194 199 , m_mode(renderMode) … … 417 422 { 418 423 /* Prepare view frame: */ 419 //setFrameStyle(QFrame::NoFrame);424 setFrameStyle(QFrame::NoFrame); 420 425 421 426 /* Pressed keys: */ … … 514 519 initMappedX11Keyboard(QX11Info::display(), vboxGlobal().settings().publicProperty("GUI/RemapScancodes")); 515 520 #endif 521 522 /* Remember the desktop geometry and register for geometry 523 * change events for telling the guest about video modes we like: */ 524 QString desktopGeometry = vboxGlobal().settings().publicProperty("GUI/MaxGuestResolution"); 525 if ((desktopGeometry == QString::null) || (desktopGeometry == "auto")) 526 setDesktopGeometry(DesktopGeo_Automatic, 0, 0); 527 else if (desktopGeometry == "any") 528 setDesktopGeometry(DesktopGeo_Any, 0, 0); 529 else 530 { 531 int width = desktopGeometry.section(',', 0, 0).toInt(); 532 int height = desktopGeometry.section(',', 1, 1).toInt(); 533 setDesktopGeometry(DesktopGeo_Fixed, width, height); 534 } 516 535 } 517 536 … … 532 551 #endif 533 552 } 553 554 QSize UIMachineView::desktopGeometry() const 555 { 556 QSize geometry; 557 switch (m_desktopGeometryType) 558 { 559 case DesktopGeo_Fixed: 560 case DesktopGeo_Automatic: 561 geometry = QSize(qMax(m_desktopGeometry.width(), m_storedConsoleSize.width()), 562 qMax(m_desktopGeometry.height(), m_storedConsoleSize.height())); 563 break; 564 case DesktopGeo_Any: 565 geometry = QSize(0, 0); 566 break; 567 default: 568 AssertMsgFailed(("Bad geometry type %d!\n", m_desktopGeometryType)); 569 } 570 return geometry; 571 } 572 573 void UIMachineView::setDesktopGeometry(DesktopGeo geometry, int aWidth, int aHeight) 574 { 575 switch (geometry) 576 { 577 case DesktopGeo_Fixed: 578 m_desktopGeometryType = DesktopGeo_Fixed; 579 if (aWidth != 0 && aHeight != 0) 580 m_desktopGeometry = QSize(aWidth, aHeight); 581 else 582 m_desktopGeometry = QSize(0, 0); 583 storeConsoleSize(0, 0); 584 break; 585 case DesktopGeo_Automatic: 586 m_desktopGeometryType = DesktopGeo_Automatic; 587 m_desktopGeometry = QSize(0, 0); 588 storeConsoleSize(0, 0); 589 break; 590 case DesktopGeo_Any: 591 m_desktopGeometryType = DesktopGeo_Any; 592 m_desktopGeometry = QSize(0, 0); 593 break; 594 default: 595 AssertMsgFailed(("Invalid desktop geometry type %d\n", geometry)); 596 m_desktopGeometryType = DesktopGeo_Invalid; 597 } 598 } 599 600 void UIMachineView::calculateDesktopGeometry() 601 { 602 /* This method should not get called until we have initially set up the m_desktopGeometryType: */ 603 Assert((m_desktopGeometryType != DesktopGeo_Invalid)); 604 /* If we are not doing automatic geometry calculation then there is nothing to do: */ 605 if (DesktopGeo_Automatic == m_desktopGeometryType) 606 { 607 /* Available geometry of the desktop. If the desktop is a single 608 * screen, this will exclude space taken up by desktop taskbars 609 * and things, but this is unfortunately not true for the more 610 * complex case of a desktop spanning multiple screens: */ 611 QRect desktop = availableGeometry(); 612 /* The area taken up by the machine window on the desktop, 613 * including window frame, title and menu bar and whatnot: */ 614 QRect frame = machineWindowWrapper()->machineWindow()->frameGeometry(); 615 /* The area taken up by the machine view, so excluding all decorations: */ 616 QRect window = geometry(); 617 /* To work out how big we can make the console window while still 618 * fitting on the desktop, we calculate desktop - frame + window. 619 * This works because the difference between frame and window 620 * (or at least its width and height) is a constant. */ 621 m_desktopGeometry = QSize(desktop.width() - frame.width() + window.width(), 622 desktop.height() - frame.height() + window.height()); 623 } 624 } 625 626 void UIMachineView::storeConsoleSize(int iWidth, int iHeight) 627 { 628 m_storedConsoleSize = QSize(iWidth, iHeight); 629 } 630 534 631 535 632 void UIMachineView::cleanupCommon() -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
r26878 r26889 51 51 52 52 public: 53 54 /* Desktop geometry types: */ 55 enum DesktopGeo { DesktopGeo_Invalid = 0, DesktopGeo_Fixed, DesktopGeo_Automatic, DesktopGeo_Any }; 53 56 54 57 /* Factory function to create required view sub-child: */ … … 113 116 bool isFrameBufferResizeIgnored() const { return m_bIsFrameBufferResizeIgnored; } 114 117 const QPixmap& pauseShot() const { return m_pauseShot; } 115 virtual QSize desktopGeometry() const = 0; 118 void calculateDesktopGeometry(); 119 virtual QSize desktopGeometry() const; 120 void setDesktopGeometry(DesktopGeo geometry, int iWidth, int iHeight); 121 void storeConsoleSize(int iWidth, int iHeight); 116 122 117 123 /* Protected setters: */ … … 158 164 # endif 159 165 #endif 166 protected: 167 168 DesktopGeo m_desktopGeometryType; 169 QSize m_desktopGeometry; 170 QSize m_storedConsoleSize; 160 171 161 172 private: … … 205 216 void sendChangedKeyStates(); 206 217 218 virtual QRect availableGeometry() = 0; 219 207 220 static void dimImage(QImage &img); 208 221 … … 254 267 255 268 /* Friend classes: */ 269 friend class UIMachineWindowFullscreen; 256 270 friend class UIFrameBuffer; 257 271 friend class UIFrameBufferQImage; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp
r26882 r26889 38 38 #include "UIMachineView.h" 39 39 #include "UIMachineWindowNormal.h" 40 //#include "UIMachineWindowFullscreen.h"40 #include "UIMachineWindowFullscreen.h" 41 41 //#include "UIMachineWindowSeamless.h" 42 42 … … 50 50 break; 51 51 case UIVisualStateType_Fullscreen: 52 // window = new UIMachineWindowFullscreen(pMachineLogic); 53 window = new UIMachineWindowNormal(pMachineLogic); 52 window = new UIMachineWindowFullscreen(pMachineLogic); 54 53 break; 55 54 case UIVisualStateType_Seamless: … … 508 507 m_pLeftSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed); 509 508 m_pRightSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed); 509 510 510 m_pMachineViewContainer->addItem(m_pTopSpacer, 0, 1); 511 511 m_pMachineViewContainer->addItem(m_pBottomSpacer, 2, 1); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp
r26849 r26889 3 3 * 4 4 * VBox frontends: Qt GUI ("VirtualBox"): 5 * UIMachineLogic Normalclass implementation5 * UIMachineLogicFullscreen class implementation 6 6 */ 7 7 … … 24 24 /* Global includes */ 25 25 #include <QMenu> 26 #include <Q Timer>26 #include <QDesktopWidget> 27 27 28 28 /* Local includes */ … … 35 35 #include "UISession.h" 36 36 #include "UIActionsPool.h" 37 #include "UIMachineLogic Normal.h"37 #include "UIMachineLogicFullscreen.h" 38 38 #include "UIMachineWindow.h" 39 39 #include "UIMachineView.h" … … 41 41 #include "VBoxUtils.h" 42 42 43 UIMachineLogic Normal::UIMachineLogicNormal(QObject *pParent, UISession *pSession, UIActionsPool *pActionsPool)44 : UIMachineLogic(pParent, pSession, pActionsPool, UIVisualStateType_ Normal)43 UIMachineLogicFullscreen::UIMachineLogicFullscreen(QObject *pParent, UISession *pSession, UIActionsPool *pActionsPool) 44 : UIMachineLogic(pParent, pSession, pActionsPool, UIVisualStateType_Fullscreen) 45 45 { 46 46 /* Prepare console connections: */ … … 56 56 prepareRequiredFeatures(); 57 57 58 /* Prepare normalmachine window: */58 /* Prepare machine window: */ 59 59 prepareMachineWindow(); 60 60 … … 65 65 } 66 66 67 UIMachineLogic Normal::~UIMachineLogicNormal()68 { 69 /* Cleanup normalmachine window: */67 UIMachineLogicFullscreen::~UIMachineLogicFullscreen() 68 { 69 /* Cleanup machine window: */ 70 70 cleanupMachineWindow(); 71 71 } 72 72 73 void UIMachineLogic Normal::sltPrepareNetworkAdaptersMenu()73 void UIMachineLogicFullscreen::sltPrepareNetworkAdaptersMenu() 74 74 { 75 75 QMenu *menu = qobject_cast<QMenu*>(sender()); … … 79 79 } 80 80 81 void UIMachineLogic Normal::sltPrepareSharedFoldersMenu()81 void UIMachineLogicFullscreen::sltPrepareSharedFoldersMenu() 82 82 { 83 83 QMenu *menu = qobject_cast<QMenu*>(sender()); … … 87 87 } 88 88 89 void UIMachineLogic Normal::sltPrepareMouseIntegrationMenu()89 void UIMachineLogicFullscreen::sltPrepareMouseIntegrationMenu() 90 90 { 91 91 QMenu *menu = qobject_cast<QMenu*>(sender()); … … 95 95 } 96 96 97 void UIMachineLogic Normal::prepareActionConnections()97 void UIMachineLogicFullscreen::prepareActionConnections() 98 98 { 99 99 /* Base class connections: */ … … 109 109 } 110 110 111 void UIMachineLogicNormal::prepareMachineWindow() 111 void UIMachineLogicFullscreen::prepareRequiredFeatures() 112 { 113 // TODO_NEW_CORE 114 // if (session().GetConsole().isAutoresizeGuestActive()) 115 { 116 // QRect screen = QApplication::desktop()->screenGeometry(this); 117 // ULONG64 availBits = session().GetMachine().GetVRAMSize() /* vram */ 118 // * _1M /* mb to bytes */ 119 // * 8; /* to bits */ 120 // ULONG guestBpp = mConsole->console().GetDisplay().GetBitsPerPixel(); 121 // ULONG64 usedBits = (screen.width() /* display width */ 122 // * screen.height() /* display height */ 123 // * guestBpp 124 // + _1M * 8) /* current cache per screen - may be changed in future */ 125 // * session().GetMachine().GetMonitorCount() /**< @todo fix assumption that all screens have same resolution */ 126 // + 4096 * 8; /* adapter info */ 127 // if (availBits < usedBits) 128 // { 129 // int result = vboxProblem().cannotEnterFullscreenMode( 130 // screen.width(), screen.height(), guestBpp, 131 // (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M); 132 // if (result == QIMessageBox::Cancel) 133 // sltClose(); 134 // } 135 } 136 } 137 138 void UIMachineLogicFullscreen::prepareMachineWindow() 112 139 { 113 140 /* Do not prepare window if its ready: */ … … 213 240 } 214 241 215 void UIMachineLogic Normal::cleanupMachineWindow()242 void UIMachineLogicFullscreen::cleanupMachineWindow() 216 243 { 217 244 /* Do not cleanup machine window if it is not present: */ … … 219 246 return; 220 247 221 /* Cleanup normalmachine window: */248 /* Cleanup machine window: */ 222 249 UIMachineWindow::destroy(machineWindowWrapper()); 223 250 setMachineWindowWrapper(0); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.h
r26849 r26889 2 2 * 3 3 * VBox frontends: Qt GUI ("VirtualBox"): 4 * UIMachineLogic Normalclass declaration4 * UIMachineLogicFullscreen class declaration 5 5 */ 6 6 … … 21 21 */ 22 22 23 #ifndef __UIMachineLogic Normal_h__24 #define __UIMachineLogic Normal_h__23 #ifndef __UIMachineLogicFullscreen_h__ 24 #define __UIMachineLogicFullscreen_h__ 25 25 26 26 /* Local includes */ … … 30 30 class UIActionsPool; 31 31 32 class UIMachineLogic Normal: public UIMachineLogic32 class UIMachineLogicFullscreen : public UIMachineLogic 33 33 { 34 34 Q_OBJECT; … … 36 36 protected: 37 37 38 /* Normalmachine logic constructor/destructor: */39 UIMachineLogic Normal(QObject *pParent,40 UISession *pSession,41 UIActionsPool *pActionsPool);42 virtual ~UIMachineLogic Normal();38 /* Fullscreen machine logic constructor/destructor: */ 39 UIMachineLogicFullscreen(QObject *pParent, 40 UISession *pSession, 41 UIActionsPool *pActionsPool); 42 virtual ~UIMachineLogicFullscreen(); 43 43 44 44 private slots: … … 54 54 void prepareActionConnections(); 55 55 void prepareMachineWindow(); 56 void prepareRequiredFeatures(); 56 57 57 58 /* Cleanup helpers: */ … … 63 64 }; 64 65 65 #endif // __UIMachineLogic Normal_h__66 #endif // __UIMachineLogicFullscreen_h__ 66 67 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.cpp
r26849 r26889 3 3 * 4 4 * VBox frontends: Qt GUI ("VirtualBox"): 5 * UIMachineView Normalclass implementation5 * UIMachineViewFullscreen class implementation 6 6 */ 7 7 … … 25 25 #include <QApplication> 26 26 #include <QDesktopWidget> 27 #include <QMainWindow>28 27 #include <QMenuBar> 28 #include <QTimer> 29 29 30 30 /* Local includes */ … … 34 34 #include "UIMachineLogic.h" 35 35 #include "UIMachineWindow.h" 36 #include "UIMachineViewNormal.h" 37 38 UIMachineViewNormal::UIMachineViewNormal( UIMachineWindow *pMachineWindow 36 #include "UIFrameBuffer.h" 37 #include "UIMachineViewFullscreen.h" 38 #include "QIMainDialog.h" 39 40 UIMachineViewFullscreen::UIMachineViewFullscreen( UIMachineWindow *pMachineWindow 39 41 , VBoxDefs::RenderMode renderMode 40 42 #ifdef VBOX_WITH_VIDEOHWACCEL … … 48 50 #endif 49 51 ) 52 , m_bIsGuestAutoresizeEnabled(pMachineWindow->machineLogic()->actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize)->isChecked()) 53 , m_fShouldWeDoResize(false) 50 54 { 51 55 /* Prepare frame buffer: */ … … 71 75 } 72 76 73 UIMachineView Normal::~UIMachineViewNormal()77 UIMachineViewFullscreen::~UIMachineViewFullscreen() 74 78 { 75 79 /* Cleanup common things: */ … … 80 84 } 81 85 82 void UIMachineViewNormal::sltPerformGuestResize(const QSize & /* toSize */) 83 { 84 #if 0 // TODO: fix that logic! 85 if (isGuestSupportsGraphics() && m_bIsGuestAutoresizeEnabled) 86 { 86 void UIMachineViewFullscreen::sltAdditionsStateChanged() 87 { 88 /* Check if we should restrict minimum size: */ 89 maybeRestrictMinimumSize(); 90 } 91 92 void UIMachineViewFullscreen::sltPerformGuestResize(const QSize &toSize) 93 { 94 if (m_bIsGuestAutoresizeEnabled && uisession()->isGuestSupportsGraphics()) 95 { 96 /* Taking Main Dialog: */ 97 QIMainDialog *pMainDialog = machineWindowWrapper() && machineWindowWrapper()->machineWindow() ? 98 qobject_cast<QIMainDialog*>(machineWindowWrapper()->machineWindow()) : 0; 99 87 100 /* If this slot is invoked directly then use the passed size 88 101 * otherwise get the available size for the guest display. 89 102 * We assume here that the centralWidget() contains this view only 90 103 * and gives it all available space. */ 91 QSize sz(toSize.isValid() ? toSize : machineWindow()->centralWidget()->size()); 104 QSize newSize(toSize.isValid() ? toSize : pMainDialog ? pMainDialog->centralWidget()->size() : QSize()); 105 AssertMsg(newSize.isValid(), ("This size should be valid!\n")); 106 107 /* Subtracting frame in case we basing on machine view size: */ 92 108 if (!toSize.isValid()) 93 sz -= QSize(frameWidth() * 2, frameWidth() * 2); 94 /* Do not send out useless hints. */ 95 if ((sz.width() == mStoredConsoleSize.width()) && (sz.height() == mStoredConsoleSize.height())) 109 newSize -= QSize(frameWidth() * 2, frameWidth() * 2); 110 111 /* Do not send the same hints as we already have: */ 112 if ((newSize.width() == m_storedConsoleSize.width()) && (newSize.height() == m_storedConsoleSize.height())) 96 113 return; 114 97 115 /* We only actually send the hint if 98 116 * 1) the autoresize property is set to true and … … 102 120 * needed (e.g. the autoresize was just enabled and the console 103 121 * was resized while it was disabled). */ 104 if ( m_bIsGuestAutoresizeEnabled && (toSize.isValid() || mDoResize))122 if (toSize.isValid() || m_fShouldWeDoResize) 105 123 { 106 124 /* Remember the new size. */ 107 storeConsoleSize(sz.width(), sz.height()); 108 109 mConsole.GetDisplay().SetVideoModeHint(sz.width(), sz.height(), 0, 0); 125 m_storedConsoleSize = newSize; 126 127 /* Send new size-hint to the guest: */ 128 session().GetConsole().GetDisplay().SetVideoModeHint(newSize.width(), newSize.height(), 0, 0); 110 129 } 111 /* We have resized now... */ 112 mDoResize = false; 113 } 114 #endif 115 } 116 117 void UIMachineViewNormal::sltAdditionsStateChanged() 118 { 119 /* Base-class additions state-change-handler: */ 120 UIMachineView::sltAdditionsStateChanged(); 121 122 /* Enable/Disable guest auto-resizing depending on advanced graphics availablability: */ 123 setGuestAutoresizeEnabled(m_bIsGuestAutoresizeEnabled && uisession()->isGuestSupportsGraphics()); 124 } 125 126 void UIMachineViewNormal::prepareFilters() 127 { 128 /* Prepare base-class filters: */ 130 /* We had requested resize now, rejecting accident requests: */ 131 m_fShouldWeDoResize = false; 132 } 133 } 134 135 /* If the desktop geometry is set automatically, this will update it: */ 136 void UIMachineViewFullscreen::sltDesktopResized() 137 { 138 calculateDesktopGeometry(); 139 } 140 141 void UIMachineViewFullscreen::prepareCommon() 142 { 143 UIMachineView::prepareCommon(); 144 145 /* Maximum size of the screen */ 146 setMaximumSize(availableGeometry().size()); 147 /* Minimum size is ignored too */ 148 setMinimumSize(0, 0); 149 /* No scrollbars */ 150 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 151 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 152 } 153 154 void UIMachineViewFullscreen::prepareFilters() 155 { 156 /* Base-class filters: */ 129 157 UIMachineView::prepareFilters(); 130 158 131 159 /* Normal window filters: */ 132 qobject_cast<QMainWindow*>(machineWindowWrapper()->machineWindow())->menuBar()->installEventFilter(this); 133 } 134 135 void UIMachineViewNormal::setGuestAutoresizeEnabled(bool fEnabled) 160 qobject_cast<QIMainDialog*>(machineWindowWrapper()->machineWindow())->menuBar()->installEventFilter(this); 161 } 162 163 void UIMachineViewFullscreen::prepareConsoleConnections() 164 { 165 /* Base class connections: */ 166 UIMachineView::prepareConsoleConnections(); 167 168 /* Guest additions state-change updater: */ 169 connect(uisession(), SIGNAL(sigAdditionsStateChange()), this, SLOT(sltAdditionsStateChanged())); 170 } 171 172 void UIMachineViewFullscreen::loadMachineViewSettings() 173 { 174 /* Base class settings: */ 175 UIMachineView::loadMachineViewSettings(); 176 177 /* Global settings: */ 178 { 179 connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(sltDesktopResized())); 180 } 181 } 182 183 void UIMachineViewFullscreen::setGuestAutoresizeEnabled(bool fEnabled) 136 184 { 137 185 if (m_bIsGuestAutoresizeEnabled != fEnabled) … … 146 194 } 147 195 148 void UIMachineView Normal::normalizeGeometry(bool bAdjustPosition /* = false */)196 void UIMachineViewFullscreen::normalizeGeometry(bool bAdjustPosition /* = false */) 149 197 { 150 198 QWidget *pTopLevelWidget = window(); … … 194 242 } 195 243 196 void UIMachineViewNormal::maybeRestrictMinimumSize() 244 QRect UIMachineViewFullscreen::availableGeometry() 245 { 246 return QApplication::desktop()->screenGeometry(this); 247 } 248 249 void UIMachineViewFullscreen::maybeRestrictMinimumSize() 197 250 { 198 251 /* Sets the minimum size restriction depending on the auto-resize feature state and the current rendering mode. … … 209 262 } 210 263 264 bool UIMachineViewFullscreen::event(QEvent *pEvent) 265 { 266 switch (pEvent->type()) 267 { 268 case VBoxDefs::ResizeEventType: 269 { 270 /* Some situations require initial VGA Resize Request 271 * to be ignored at all, leaving previous framebuffer, 272 * machine view and machine window sizes preserved: */ 273 if (uisession()->isGuestResizeIgnored()) 274 return true; 275 276 bool oldIgnoreMainwndResize = isMachineWindowResizeIgnored(); 277 setMachineWindowResizeIgnored(true); 278 279 UIResizeEvent *pResizeEvent = static_cast<UIResizeEvent*>(pEvent); 280 281 /* Store the new size to prevent unwanted resize hints being sent back. */ 282 storeConsoleSize(pResizeEvent->width(), pResizeEvent->height()); 283 284 /* Unfortunately restoreOverrideCursor() is broken in Qt 4.4.0 if WA_PaintOnScreen widgets are present. 285 * This is the case on linux with SDL. As workaround we save/restore the arrow cursor manually. 286 * See http://trolltech.com/developer/task-tracker/index_html?id=206165&method=entry for details. 287 * Moreover the current cursor, which could be set by the guest, should be restored after resize: */ 288 QCursor cursor; 289 if (uisession()->isHidingHostPointer()) 290 cursor = QCursor(Qt::BlankCursor); 291 else 292 cursor = viewport()->cursor(); 293 frameBuffer()->resizeEvent(pResizeEvent); 294 viewport()->setCursor(cursor); 295 296 #ifdef Q_WS_MAC 297 // TODO_NEW_CORE 298 // mDockIconPreview->setOriginalSize(pResizeEvent->width(), pResizeEvent->height()); 299 #endif /* Q_WS_MAC */ 300 301 /* This event appears in case of guest video was changed for somehow even without video resolution change. 302 * In this last case the host VM window will not be resized according this event and the host mouse cursor 303 * which was unset to default here will not be hidden in capture state. So it is necessary to perform 304 * updateMouseClipping() for the guest resize event if the mouse cursor was captured: */ 305 if (uisession()->isMouseCaptured()) 306 updateMouseClipping(); 307 308 /* Apply maximum size restriction: */ 309 setMaximumSize(sizeHint()); 310 311 /* May be we have to restrict minimum size? */ 312 maybeRestrictMinimumSize(); 313 314 /* Resize the guest canvas: */ 315 if (!isFrameBufferResizeIgnored()) 316 resize(pResizeEvent->width(), pResizeEvent->height()); 317 updateSliders(); 318 319 /* Let our toplevel widget calculate its sizeHint properly. */ 320 #ifdef Q_WS_X11 321 /* We use processEvents rather than sendPostedEvents & set the time out value to max cause on X11 otherwise 322 * the layout isn't calculated correctly. Dosn't find the bug in Qt, but this could be triggered through 323 * the async nature of the X11 window event system. */ 324 QCoreApplication::processEvents(QEventLoop::AllEvents, INT_MAX); 325 #else /* Q_WS_X11 */ 326 QCoreApplication::sendPostedEvents(0, QEvent::LayoutRequest); 327 #endif /* Q_WS_X11 */ 328 329 if (!isFrameBufferResizeIgnored()) 330 normalizeGeometry(true /* adjustPosition */); 331 332 /* Report to the VM thread that we finished resizing */ 333 session().GetConsole().GetDisplay().ResizeCompleted(0); 334 335 setMachineWindowResizeIgnored(oldIgnoreMainwndResize); 336 337 /* Update geometry after entering fullscreen */ 338 updateGeometry(); 339 340 /* Make sure that all posted signals are processed: */ 341 qApp->processEvents(); 342 343 /* Emit a signal about guest was resized: */ 344 emit resizeHintDone(); 345 346 /* We also recalculate the desktop geometry if this is determined 347 * automatically. In fact, we only need this on the first resize, 348 * but it is done every time to keep the code simpler. */ 349 calculateDesktopGeometry(); 350 351 // TODO_NEW_CORE: try to understand this, cause this is bullshit in fullscreen 352 /* Enable frame-buffer resize watching: */ 353 // if (isFrameBufferResizeIgnored()) 354 // setFrameBufferResizeIgnored(false); 355 356 return true; 357 } 358 359 case QEvent::KeyPress: 360 case QEvent::KeyRelease: 361 { 362 QKeyEvent *pKeyEvent = static_cast<QKeyEvent*>(pEvent); 363 364 if (isHostKeyPressed() && pEvent->type() == QEvent::KeyPress) 365 { 366 if (pKeyEvent->key() == Qt::Key_Home) 367 { 368 /* In Qt4 it is not enough to just set the focus to menu-bar. 369 * So to get the menu-bar we have to send Qt::Key_Alt press/release events directly: */ 370 QKeyEvent e1(QEvent::KeyPress, Qt::Key_Alt, Qt::NoModifier); 371 QKeyEvent e2(QEvent::KeyRelease, Qt::Key_Alt, Qt::NoModifier); 372 QMenuBar *pMenuBar = machineWindowWrapper() && machineWindowWrapper()->machineWindow() ? 373 qobject_cast<QIMainDialog*>(machineWindowWrapper()->machineWindow())->menuBar() : 0; 374 QApplication::sendEvent(pMenuBar, &e1); 375 QApplication::sendEvent(pMenuBar, &e2); 376 } 377 else 378 pEvent->ignore(); 379 } 380 } 381 default: 382 break; 383 } 384 return UIMachineView::event(pEvent); 385 } 386 387 bool UIMachineViewFullscreen::eventFilter(QObject *pWatched, QEvent *pEvent) 388 { 389 /* Who are we watchin? */ 390 QIMainDialog *pMainDialog = machineWindowWrapper() && machineWindowWrapper()->machineWindow() ? 391 qobject_cast<QIMainDialog*>(machineWindowWrapper()->machineWindow()) : 0; 392 QMenuBar *pMenuBar = pMainDialog ? qobject_cast<QIMainDialog*>(pMainDialog)->menuBar() : 0; 393 394 if (pWatched != 0 && pWatched == pMainDialog) 395 { 396 switch (pEvent->type()) 397 { 398 case QEvent::Resize: 399 { 400 /* Set the "guest needs to resize" hint. 401 * This hint is acted upon when (and only when) the autoresize property is "true": */ 402 m_fShouldWeDoResize = uisession()->isGuestSupportsGraphics(); 403 if (!isMachineWindowResizeIgnored() && m_bIsGuestAutoresizeEnabled && uisession()->isGuestSupportsGraphics()) 404 QTimer::singleShot(300, this, SLOT(sltPerformGuestResize())); 405 break; 406 } 407 #if defined (Q_WS_WIN32) 408 # if defined (VBOX_GUI_USE_DDRAW) 409 case QEvent::Move: 410 { 411 /* Notification from our parent that it has moved. We need this in order 412 * to possibly adjust the direct screen blitting: */ 413 if (frameBuffer()) 414 frameBuffer()->moveEvent(static_cast<QMoveEvent*>(pEvent)); 415 break; 416 } 417 # endif 418 #endif /* defined (Q_WS_WIN32) */ 419 default: 420 break; 421 } 422 } 423 else if (pWatched != 0 && pWatched == pMenuBar) 424 { 425 /* Sometimes when we press ESC in the menu it brings the focus away (Qt bug?) 426 * causing no widget to have a focus, or holds the focus itself, instead of 427 * returning the focus to the console window. Here we fix this: */ 428 switch (pEvent->type()) 429 { 430 case QEvent::FocusOut: 431 { 432 if (qApp->focusWidget() == 0) 433 setFocus(); 434 break; 435 } 436 case QEvent::KeyPress: 437 { 438 QKeyEvent *pKeyEvent = static_cast<QKeyEvent*>(pEvent); 439 if (pKeyEvent->key() == Qt::Key_Escape && (pKeyEvent->modifiers() == Qt::NoModifier)) 440 if (pMenuBar->hasFocus()) 441 setFocus(); 442 break; 443 } 444 default: 445 break; 446 } 447 } 448 return UIMachineView::eventFilter(pWatched, pEvent); 449 } 450 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.h
r26849 r26889 2 2 * 3 3 * VBox frontends: Qt GUI ("VirtualBox"): 4 * UIMachineView Normalclass declaration4 * UIMachineViewFullscreen class declaration 5 5 */ 6 6 … … 21 21 */ 22 22 23 #ifndef ___UIMachineView Normal_h___24 #define ___UIMachineView Normal_h___23 #ifndef ___UIMachineViewFullscreen_h___ 24 #define ___UIMachineViewFullscreen_h___ 25 25 26 26 /* Local includes */ 27 27 #include "UIMachineView.h" 28 28 29 class UIMachineView Normal: public UIMachineView29 class UIMachineViewFullscreen : public UIMachineView 30 30 { 31 31 Q_OBJECT; 32 33 signals: 34 35 /* Utility signals: */ 36 void resizeHintDone(); 32 37 33 38 protected: 34 39 35 40 /* Normal machine view constructor/destructor: */ 36 UIMachineView Normal( UIMachineWindow *pMachineWindow41 UIMachineViewFullscreen( UIMachineWindow *pMachineWindow 37 42 , VBoxDefs::RenderMode renderMode 38 43 #ifdef VBOX_WITH_VIDEOHWACCEL … … 40 45 #endif 41 46 ); 42 virtual ~UIMachineView Normal();47 virtual ~UIMachineViewFullscreen(); 43 48 44 49 private slots: … … 50 55 void sltPerformGuestResize(const QSize &aSize = QSize()); 51 56 57 /* Watch dog for desktop resizes: */ 58 void sltDesktopResized(); 59 52 60 private: 53 61 54 62 /* Prepare routines: */ 63 void prepareCommon(); 55 64 void prepareFilters(); 65 void prepareConsoleConnections(); 66 void loadMachineViewSettings(); 56 67 57 68 /* Private setters: */ … … 60 71 /* Private helpers: */ 61 72 void normalizeGeometry(bool bAdjustPosition = false); 73 QRect availableGeometry(); 62 74 void maybeRestrictMinimumSize(); 75 76 bool event(QEvent *pEvent); 77 bool eventFilter(QObject *pWatched, QEvent *pEvent); 63 78 64 79 /* Private members: */ 65 80 bool m_bIsGuestAutoresizeEnabled : 1; 81 bool m_fShouldWeDoResize : 1; 66 82 67 83 /* Friend classes: */ … … 69 85 }; 70 86 71 #endif // !___UIMachineView Normal_h___87 #endif // !___UIMachineViewFullscreen_h___ 72 88 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp
r26849 r26889 3 3 * 4 4 * VBox frontends: Qt GUI ("VirtualBox"): 5 * UIMachineWindow Normalclass implementation5 * UIMachineWindowFullscreen class implementation 6 6 */ 7 7 … … 33 33 #include "UISession.h" 34 34 #include "UIActionsPool.h" 35 #include "UIIndicatorsPool.h"36 35 #include "UIMachineLogic.h" 37 36 #include "UIMachineView.h" 38 #include "UIMachineWindowNormal.h" 39 40 #include "QIStatusBar.h" 41 #include "QIStateIndicator.h" 42 #include "QIHotKeyEdit.h" 43 44 UIMachineWindowNormal::UIMachineWindowNormal(UIMachineLogic *pMachineLogic) 37 #include "UIMachineWindowFullscreen.h" 38 39 #ifdef Q_WS_MAC 40 # ifdef QT_MAC_USE_COCOA 41 # include <Carbon/Carbon.h> 42 # endif /* QT_MAC_USE_COCOA */ 43 #endif /* Q_WS_MAC */ 44 45 UIMachineWindowFullscreen::UIMachineWindowFullscreen(UIMachineLogic *pMachineLogic) 45 46 : QIWithRetranslateUI<QIMainDialog>(0) 46 47 , UIMachineWindow(pMachineLogic) 47 , m_pIndicatorsPool(new UIIndicatorsPool(pMachineLogic->uisession()->session(), this))48 , m_pIdleTimer(0)49 48 { 50 49 /* "This" is machine window: */ … … 60 59 prepareMenu(); 61 60 62 /* Prepare status bar: */63 prepareStatusBar();64 65 61 /* Prepare connections: */ 66 62 prepareConnections(); … … 69 65 retranslateUi(); 70 66 67 /* Prepare machine view container: */ 68 prepareMachineViewContainer(); 69 71 70 /* Prepare normal machine view: */ 72 71 prepareMachineView(); … … 79 78 80 79 /* Show window: */ 81 show();82 } 83 84 UIMachineWindow Normal::~UIMachineWindowNormal()80 // show(); 81 } 82 83 UIMachineWindowFullscreen::~UIMachineWindowFullscreen() 85 84 { 86 85 /* Save normal window settings: */ 87 86 saveWindowSettings(); 88 87 89 /* Cleanup status-bar: */90 cleanup StatusBar();91 } 92 93 void UIMachineWindow Normal::sltMachineStateChanged()88 /* Cleanup normal machine view: */ 89 cleanupMachineView(); 90 } 91 92 void UIMachineWindowFullscreen::sltMachineStateChanged() 94 93 { 95 94 UIMachineWindow::sltMachineStateChanged(); 96 95 } 97 96 98 void UIMachineWindow Normal::sltMediumChange(const CMediumAttachment &attachment)97 void UIMachineWindowFullscreen::sltMediumChange(const CMediumAttachment &attachment) 99 98 { 100 99 KDeviceType type = attachment.GetType(); … … 107 106 } 108 107 109 void UIMachineWindow Normal::sltUSBControllerChange()108 void UIMachineWindowFullscreen::sltUSBControllerChange() 110 109 { 111 110 updateAppearanceOf(UIVisualElement_USBStuff); 112 111 } 113 112 114 void UIMachineWindow Normal::sltUSBDeviceStateChange()113 void UIMachineWindowFullscreen::sltUSBDeviceStateChange() 115 114 { 116 115 updateAppearanceOf(UIVisualElement_USBStuff); 117 116 } 118 117 119 void UIMachineWindow Normal::sltNetworkAdapterChange()118 void UIMachineWindowFullscreen::sltNetworkAdapterChange() 120 119 { 121 120 updateAppearanceOf(UIVisualElement_NetworkStuff); 122 121 } 123 122 124 void UIMachineWindow Normal::sltSharedFolderChange()123 void UIMachineWindowFullscreen::sltSharedFolderChange() 125 124 { 126 125 updateAppearanceOf(UIVisualElement_SharedFolderStuff); 127 126 } 128 127 129 void UIMachineWindow Normal::sltTryClose()128 void UIMachineWindowFullscreen::sltTryClose() 130 129 { 131 130 UIMachineWindow::sltTryClose(); 132 131 } 133 132 134 void UIMachineWindowNormal::sltUpdateIndicators() 135 { 136 CConsole console = session().GetConsole(); 137 QIStateIndicator *pStateIndicator = 0; 138 139 pStateIndicator = indicatorsPool()->indicator(UIIndicatorIndex_HardDisks); 140 if (pStateIndicator->state() != KDeviceActivity_Null) 141 { 142 int state = console.GetDeviceActivity(KDeviceType_HardDisk); 143 if (pStateIndicator->state() != state) 144 pStateIndicator->setState(state); 145 } 146 pStateIndicator = indicatorsPool()->indicator(UIIndicatorIndex_OpticalDisks); 147 if (pStateIndicator->state() != KDeviceActivity_Null) 148 { 149 int state = console.GetDeviceActivity(KDeviceType_DVD); 150 if (pStateIndicator->state() != state) 151 pStateIndicator->setState(state); 152 } 153 pStateIndicator = indicatorsPool()->indicator(UIIndicatorIndex_USBDevices); 154 if (pStateIndicator->state() != KDeviceActivity_Null) 155 { 156 int state = console.GetDeviceActivity(KDeviceType_USB); 157 if (pStateIndicator->state() != state) 158 pStateIndicator->setState(state); 159 } 160 pStateIndicator = indicatorsPool()->indicator(UIIndicatorIndex_NetworkAdapters); 161 if (pStateIndicator->state() != KDeviceActivity_Null) 162 { 163 int state = console.GetDeviceActivity(KDeviceType_Network); 164 if (pStateIndicator->state() != state) 165 pStateIndicator->setState(state); 166 } 167 pStateIndicator = indicatorsPool()->indicator(UIIndicatorIndex_SharedFolders); 168 if (pStateIndicator->state() != KDeviceActivity_Null) 169 { 170 int state = console.GetDeviceActivity(KDeviceType_SharedFolder); 171 if (pStateIndicator->state() != state) 172 pStateIndicator->setState(state); 173 } 174 } 175 176 void UIMachineWindowNormal::sltShowIndicatorsContextMenu(QIStateIndicator *pIndicator, QContextMenuEvent *pEvent) 177 { 178 if (pIndicator == indicatorsPool()->indicator(UIIndicatorIndex_OpticalDisks)) 179 { 180 if (machineLogic()->actionsPool()->action(UIActionIndex_Menu_OpticalDevices)->isEnabled()) 181 machineLogic()->actionsPool()->action(UIActionIndex_Menu_OpticalDevices)->menu()->exec(pEvent->globalPos()); 182 } 183 else if (pIndicator == indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)) 184 { 185 if (machineLogic()->actionsPool()->action(UIActionIndex_Menu_USBDevices)->isEnabled()) 186 machineLogic()->actionsPool()->action(UIActionIndex_Menu_USBDevices)->menu()->exec(pEvent->globalPos()); 187 } 188 else if (pIndicator == indicatorsPool()->indicator(UIIndicatorIndex_NetworkAdapters)) 189 { 190 if (machineLogic()->actionsPool()->action(UIActionIndex_Menu_NetworkAdapters)->isEnabled()) 191 machineLogic()->actionsPool()->action(UIActionIndex_Menu_NetworkAdapters)->menu()->exec(pEvent->globalPos()); 192 } 193 else if (pIndicator == indicatorsPool()->indicator(UIIndicatorIndex_SharedFolders)) 194 { 195 if (machineLogic()->actionsPool()->action(UIActionIndex_Menu_SharedFolders)->isEnabled()) 196 machineLogic()->actionsPool()->action(UIActionIndex_Menu_SharedFolders)->menu()->exec(pEvent->globalPos()); 197 } 198 else if (pIndicator == indicatorsPool()->indicator(UIIndicatorIndex_Mouse)) 199 { 200 if (machineLogic()->actionsPool()->action(UIActionIndex_Menu_MouseIntegration)->isEnabled()) 201 machineLogic()->actionsPool()->action(UIActionIndex_Menu_MouseIntegration)->menu()->exec(pEvent->globalPos()); 202 } 203 } 204 205 void UIMachineWindowNormal::sltProcessGlobalSettingChange(const char * /* aPublicName */, const char * /* aName */) 206 { 207 m_pNameHostkey->setText(QIHotKeyEdit::keyName(vboxGlobal().settings().hostKey())); 208 } 209 210 void UIMachineWindowNormal::retranslateUi() 133 void UIMachineWindowFullscreen::sltProcessGlobalSettingChange(const char * /* aPublicName */, const char * /* aName */) 134 { 135 } 136 137 void UIMachineWindowFullscreen::retranslateUi() 211 138 { 212 139 /* Translate parent class: */ … … 219 146 // m_pDockEnablePreviewMonitor->setText(tr("Show Monitor Preview")); 220 147 #endif /* Q_WS_MAC */ 221 222 m_pNameHostkey->setToolTip( 223 tr("Shows the currently assigned Host key.<br>" 224 "This key, when pressed alone, toggles the keyboard and mouse " 225 "capture state. It can also be used in combination with other keys " 226 "to quickly perform actions from the main menu.")); 227 m_pNameHostkey->setText(QIHotKeyEdit::keyName(vboxGlobal().settings().hostKey())); 228 } 229 230 void UIMachineWindowNormal::updateAppearanceOf(int iElement) 148 } 149 150 void UIMachineWindowFullscreen::updateAppearanceOf(int iElement) 231 151 { 232 152 /* Update parent-class window: */ 233 153 UIMachineWindow::updateAppearanceOf(iElement); 234 235 /* Update that machine window: */ 236 if (iElement & UIVisualElement_HDStuff) 237 indicatorsPool()->indicator(UIIndicatorIndex_HardDisks)->updateAppearance(); 238 if (iElement & UIVisualElement_CDStuff) 239 indicatorsPool()->indicator(UIIndicatorIndex_OpticalDisks)->updateAppearance(); 240 if (iElement & UIVisualElement_USBStuff && 241 !indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->isHidden()) 242 indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->updateAppearance(); 243 if (iElement & UIVisualElement_NetworkStuff) 244 indicatorsPool()->indicator(UIIndicatorIndex_NetworkAdapters)->updateAppearance(); 245 if (iElement & UIVisualElement_SharedFolderStuff) 246 indicatorsPool()->indicator(UIIndicatorIndex_SharedFolders)->updateAppearance(); 247 if (iElement & UIVisualElement_VirtualizationStuff) 248 indicatorsPool()->indicator(UIIndicatorIndex_Virtualization)->updateAppearance(); 249 } 250 251 bool UIMachineWindowNormal::event(QEvent *pEvent) 252 { 154 } 155 156 bool UIMachineWindowFullscreen::event(QEvent *pEvent) 157 { 158 return QIWithRetranslateUI<QIMainDialog>::event(pEvent); 253 159 switch (pEvent->type()) 254 160 { … … 285 191 286 192 #ifdef Q_WS_X11 287 bool UIMachineWindow Normal::x11Event(XEvent *pEvent)193 bool UIMachineWindowFullscreen::x11Event(XEvent *pEvent) 288 194 { 289 195 /* Qt bug: when the console view grabs the keyboard, FocusIn, FocusOut, … … 306 212 #endif 307 213 308 void UIMachineWindow Normal::closeEvent(QCloseEvent *pEvent)214 void UIMachineWindowFullscreen::closeEvent(QCloseEvent *pEvent) 309 215 { 310 216 return UIMachineWindow::closeEvent(pEvent); 311 217 } 312 218 313 void UIMachineWindow Normal::prepareConsoleConnections()219 void UIMachineWindowFullscreen::prepareConsoleConnections() 314 220 { 315 221 /* Base-class connections: */ … … 337 243 } 338 244 339 void UIMachineWindow Normal::prepareMenu()245 void UIMachineWindowFullscreen::prepareMenu() 340 246 { 341 247 /* Machine submenu: */ … … 364 270 } 365 271 366 void UIMachineWindowNormal::prepareStatusBar() 367 { 368 /* Common setup: */ 369 setStatusBar(new QIStatusBar(this)); 370 QWidget *pIndicatorBox = new QWidget; 371 QHBoxLayout *pIndicatorBoxHLayout = new QHBoxLayout(pIndicatorBox); 372 VBoxGlobal::setLayoutMargin(pIndicatorBoxHLayout, 0); 373 pIndicatorBoxHLayout->setSpacing(5); 374 375 /* Hard Disks: */ 376 pIndicatorBoxHLayout->addWidget(indicatorsPool()->indicator(UIIndicatorIndex_HardDisks)); 377 378 /* Optical Disks: */ 379 QIStateIndicator *pLedOpticalDisks = indicatorsPool()->indicator(UIIndicatorIndex_OpticalDisks); 380 pIndicatorBoxHLayout->addWidget(pLedOpticalDisks); 381 connect(pLedOpticalDisks, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)), 382 this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*))); 383 384 /* USB Devices: */ 385 QIStateIndicator *pLedUSBDevices = indicatorsPool()->indicator(UIIndicatorIndex_USBDevices); 386 pIndicatorBoxHLayout->addWidget(pLedUSBDevices); 387 connect(pLedUSBDevices, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)), 388 this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*))); 389 390 /* Network Adapters: */ 391 QIStateIndicator *pLedNetworkAdapters = indicatorsPool()->indicator(UIIndicatorIndex_NetworkAdapters); 392 pIndicatorBoxHLayout->addWidget(pLedNetworkAdapters); 393 connect(pLedNetworkAdapters, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)), 394 this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*))); 395 396 /* Shared Folders: */ 397 QIStateIndicator *pLedSharedFolders = indicatorsPool()->indicator(UIIndicatorIndex_SharedFolders); 398 pIndicatorBoxHLayout->addWidget(pLedSharedFolders); 399 connect(pLedSharedFolders, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)), 400 this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*))); 401 402 /* Virtualization: */ 403 pIndicatorBoxHLayout->addWidget(indicatorsPool()->indicator(UIIndicatorIndex_Virtualization)); 404 405 /* Separator: */ 406 QFrame *pSeparator = new QFrame; 407 pSeparator->setFrameStyle(QFrame::VLine | QFrame::Sunken); 408 pIndicatorBoxHLayout->addWidget(pSeparator); 409 410 /* Mouse: */ 411 QIStateIndicator *pLedMouse = indicatorsPool()->indicator(UIIndicatorIndex_Mouse); 412 pIndicatorBoxHLayout->addWidget(pLedMouse); 413 connect(pLedMouse, SIGNAL(contextMenuRequested(QIStateIndicator*, QContextMenuEvent*)), 414 this, SLOT(sltShowIndicatorsContextMenu(QIStateIndicator*, QContextMenuEvent*))); 415 416 /* Host Key: */ 417 m_pCntHostkey = new QWidget; 418 QHBoxLayout *pHostkeyLedContainerLayout = new QHBoxLayout(m_pCntHostkey); 419 VBoxGlobal::setLayoutMargin(pHostkeyLedContainerLayout, 0); 420 pHostkeyLedContainerLayout->setSpacing(3); 421 pIndicatorBoxHLayout->addWidget(m_pCntHostkey); 422 pHostkeyLedContainerLayout->addWidget(indicatorsPool()->indicator(UIIndicatorIndex_Hostkey)); 423 m_pNameHostkey = new QLabel(QIHotKeyEdit::keyName(vboxGlobal().settings().hostKey())); 424 pHostkeyLedContainerLayout->addWidget(m_pNameHostkey); 425 426 /* Add to statusbar: */ 427 statusBar()->addPermanentWidget(pIndicatorBox, 0); 428 429 /* Create & start timer to update LEDs: */ 430 m_pIdleTimer = new QTimer(this); 431 connect(m_pIdleTimer, SIGNAL(timeout()), this, SLOT(sltUpdateIndicators())); 432 m_pIdleTimer->start(50); 433 434 #ifdef Q_WS_MAC 435 /* For the status bar on Cocoa: */ 436 setUnifiedTitleAndToolBarOnMac(true); 437 #endif 438 } 439 440 void UIMachineWindowNormal::prepareConnections() 272 void UIMachineWindowFullscreen::prepareConnections() 441 273 { 442 274 /* Setup global settings change updater: */ … … 445 277 } 446 278 447 void UIMachineWindow Normal::prepareMachineView()279 void UIMachineWindowFullscreen::prepareMachineView() 448 280 { 449 281 CMachine machine = session().GetMachine(); … … 453 285 bool bAccelerate2DVideo = machine.GetAccelerate2DVideoEnabled() && VBoxGlobal::isAcceleration2DVideoAvailable(); 454 286 #endif 287 288 /* Set central widget: */ 289 setCentralWidget(new QWidget(this)); 290 291 /* Set central widget layout: */ 292 centralWidget()->setLayout(m_pMachineViewContainer); 455 293 456 294 m_pMachineView = UIMachineView::create( this … … 461 299 , machineLogic()->visualStateType()); 462 300 463 setCentralWidget(m_pMachineView); 464 465 /* Setup machine view connections: */ 466 if (machineView()) 467 { 468 /* Keyboard state-change updater: */ 469 connect(machineView(), SIGNAL(keyboardStateChanged(int)), indicatorsPool()->indicator(UIIndicatorIndex_Hostkey), SLOT(setState(int))); 470 471 /* Mouse state-change updater: */ 472 connect(machineView(), SIGNAL(mouseStateChanged(int)), indicatorsPool()->indicator(UIIndicatorIndex_Mouse), SLOT(setState(int))); 473 474 /* Early initialize required connections: */ 475 indicatorsPool()->indicator(UIIndicatorIndex_Hostkey)->setState(machineView()->keyboardState()); 476 indicatorsPool()->indicator(UIIndicatorIndex_Mouse)->setState(machineView()->mouseState()); 477 } 478 } 479 480 void UIMachineWindowNormal::loadWindowSettings() 301 /* Add machine view into layout: */ 302 m_pMachineViewContainer->addWidget(m_pMachineView, 1, 1, Qt::AlignVCenter | Qt::AlignHCenter); 303 } 304 305 void UIMachineWindowFullscreen::loadWindowSettings() 481 306 { 482 307 /* Load normal window settings: */ 483 308 CMachine machine = session().GetMachine(); 484 309 485 /* Load extra-data settings: */ 486 { 487 QString strPositionSettings = machine.GetExtraData(VBoxDefs::GUI_LastWindowPosition); 488 489 bool ok = false, max = false; 490 int x = 0, y = 0, w = 0, h = 0; 491 x = strPositionSettings.section(',', 0, 0).toInt(&ok); 492 if (ok) 493 y = strPositionSettings.section(',', 1, 1).toInt(&ok); 494 if (ok) 495 w = strPositionSettings.section(',', 2, 2).toInt(&ok); 496 if (ok) 497 h = strPositionSettings.section(',', 3, 3).toInt(&ok); 498 if (ok) 499 max = strPositionSettings.section(',', 4, 4) == VBoxDefs::GUI_LastWindowPosition_Max; 500 501 QRect ar = ok ? QApplication::desktop()->availableGeometry(QPoint(x, y)) : 502 QApplication::desktop()->availableGeometry(machineWindow()); 503 504 if (ok /* if previous parameters were read correctly */) 310 /* Toggle console to manual resize mode. */ 311 m_pMachineView->setMachineWindowResizeIgnored(true); 312 m_pMachineView->setFrameBufferResizeIgnored(true); 313 314 /* The background has to go black */ 315 QPalette palette(centralWidget()->palette()); 316 palette.setColor(centralWidget()->backgroundRole(), Qt::black); 317 centralWidget()->setPalette (palette); 318 centralWidget()->setAutoFillBackground (true); 319 setAutoFillBackground (true); 320 321 /* We have to show the window early, or the position will be wrong on the 322 Mac */ 323 show(); 324 325 #ifdef Q_WS_MAC 326 # ifndef QT_MAC_USE_COCOA 327 /* setWindowState removes the window group connection somehow. So save it 328 * temporary. */ 329 WindowGroupRef g = GetWindowGroup(::darwinToNativeWindow(this)); 330 # endif /* !QT_MAC_USE_COCOA */ 331 /* Here we are going really fullscreen */ 332 setWindowState(windowState() ^ Qt::WindowFullScreen); 333 setPresentationModeEnabled(true); 334 335 # ifndef QT_MAC_USE_COCOA 336 /* Reassign the correct window group. */ 337 SetWindowGroup(::darwinToNativeWindow (this), g); 338 # endif /* !QT_MAC_USE_COCOA */ 339 #else /* Q_WS_MAC */ 340 setWindowState(windowState() ^ Qt::WindowFullScreen); 341 #endif/* !Q_WS_MAC */ 342 343 QRect r = geometry(); 344 /* Load global settings: */ 345 { 346 // VBoxGlobalSettings settings = vboxGlobal().settings(); 347 // menuBar()->setHidden(settings.isFeatureActive("noMenuBar")); 348 } 349 } 350 351 void UIMachineWindowFullscreen::saveWindowSettings() 352 { 353 CMachine machine = session().GetMachine(); 354 355 /* Save extra-data settings: */ 356 { 357 } 358 359 setPresentationModeEnabled(false); 360 } 361 362 void UIMachineWindowFullscreen::cleanupMachineView() 363 { 364 /* Do not cleanup machine view if it is not present: */ 365 if (!machineView()) 366 return; 367 368 UIMachineView::destroy(m_pMachineView); 369 m_pMachineView = 0; 370 } 371 372 #ifdef Q_WS_MAC 373 # ifdef QT_MAC_USE_COCOA 374 void UIMachineWindowFullscreen::setPresentationModeEnabled(bool fEnabled) 375 { 376 if (fEnabled) 377 { 378 /* First check if we are on the primary screen, only than the presentation mode have to be changed. */ 379 QDesktopWidget* pDesktop = QApplication::desktop(); 380 if (pDesktop->screenNumber(this) == pDesktop->primaryScreen()) 505 381 { 506 m_normalGeometry = QRect(x, y, w, h); 507 setGeometry(m_normalGeometry); 508 509 /* Normalize view to the optimal size */ 510 if (machineView()) 511 machineView()->normalizeGeometry(true /* adjust position? */); 512 513 /* Maximize if needed: */ 514 if (max) 515 setWindowState(windowState() | Qt::WindowMaximized); 382 QString testStr = vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_PresentationModeEnabled).toLower(); 383 /* Default to false if it is an empty value */ 384 if (testStr.isEmpty() || testStr == "false") 385 SetSystemUIMode(kUIModeAllHidden, 0); 386 else 387 SetSystemUIMode(kUIModeAllSuppressed, 0); 516 388 } 517 else 518 { 519 /* Normalize to the optimal size */ 520 if (machineView()) 521 machineView()->normalizeGeometry(true /* adjust position? */); 522 523 /* Move newly created window to the screen center: */ 524 m_normalGeometry = geometry(); 525 m_normalGeometry.moveCenter(ar.center()); 526 setGeometry(m_normalGeometry); 527 } 528 } 529 530 /* Load availability settings: */ 531 { 532 /* USB Stuff: */ 533 CUSBController usbController = machine.GetUSBController(); 534 if (usbController.isNull()) 535 { 536 /* Hide USB Menu: */ 537 indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->setHidden(true); 538 } 539 else 540 { 541 /* Toggle USB LED: */ 542 indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->setState( 543 usbController.GetEnabled() ? KDeviceActivity_Idle : KDeviceActivity_Null); 544 } 545 } 546 547 /* Load global settings: */ 548 { 549 VBoxGlobalSettings settings = vboxGlobal().settings(); 550 menuBar()->setHidden(settings.isFeatureActive("noMenuBar")); 551 statusBar()->setHidden(settings.isFeatureActive("noStatusBar")); 552 } 553 } 554 555 void UIMachineWindowNormal::saveWindowSettings() 556 { 557 CMachine machine = session().GetMachine(); 558 559 /* Save extra-data settings: */ 560 { 561 QString strWindowPosition = QString("%1,%2,%3,%4") 562 .arg(m_normalGeometry.x()).arg(m_normalGeometry.y()) 563 .arg(m_normalGeometry.width()).arg(m_normalGeometry.height()); 564 if (isMaximized()) 565 strWindowPosition += QString(",%1").arg(VBoxDefs::GUI_LastWindowPosition_Max); 566 machine.SetExtraData(VBoxDefs::GUI_LastWindowPosition, strWindowPosition); 567 } 568 } 569 570 void UIMachineWindowNormal::cleanupStatusBar() 571 { 572 /* Stop LED-update timer: */ 573 m_pIdleTimer->stop(); 574 m_pIdleTimer->disconnect(SIGNAL(timeout()), this, SLOT(sltUpdateIndicators())); 575 } 576 389 } 390 else 391 SetSystemUIMode(kUIModeNormal, 0); 392 } 393 # endif /* QT_MAC_USE_COCOA */ 394 #endif /* Q_WS_MAC */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.h
r26849 r26889 2 2 * 3 3 * VBox frontends: Qt GUI ("VirtualBox"): 4 * UIMachineWindow Normalclass declaration4 * UIMachineWindowFullscreen class declaration 5 5 */ 6 6 … … 21 21 */ 22 22 23 #ifndef __UIMachineWindow Normal_h__24 #define __UIMachineWindow Normal_h__23 #ifndef __UIMachineWindowFullscreen_h__ 24 #define __UIMachineWindowFullscreen_h__ 25 25 26 26 /* Global includes */ … … 38 38 /* Local forwards */ 39 39 class CMediumAttachment; 40 class UIIndicatorsPool;41 class QIStateIndicator;42 40 43 class UIMachineWindow Normal: public QIWithRetranslateUI<QIMainDialog>, public UIMachineWindow41 class UIMachineWindowFullscreen : public QIWithRetranslateUI<QIMainDialog>, public UIMachineWindow 44 42 { 45 43 Q_OBJECT; … … 48 46 49 47 /* Normal machine window constructor/destructor: */ 50 UIMachineWindow Normal(UIMachineLogic *pMachineLogic);51 virtual ~UIMachineWindow Normal();48 UIMachineWindowFullscreen(UIMachineLogic *pMachineLogic); 49 virtual ~UIMachineWindowFullscreen(); 52 50 53 51 private slots: … … 62 60 63 61 /* LED connections: */ 64 void sltUpdateIndicators();65 void sltShowIndicatorsContextMenu(QIStateIndicator *pIndicator, QContextMenuEvent *pEvent);66 62 void sltProcessGlobalSettingChange(const char *aPublicName, const char *aName); 67 63 … … 84 80 void closeEvent(QCloseEvent *pEvent); 85 81 86 /* Private getters: */87 UIIndicatorsPool* indicatorsPool() { return m_pIndicatorsPool; }88 89 82 /* Prepare helpers: */ 90 83 void prepareConsoleConnections(); 91 84 void prepareMenu(); 92 void prepareStatusBar();93 85 void prepareConnections(); 86 void prepareMachineView(); 94 87 void loadWindowSettings(); 95 void prepareMachineView();96 88 97 89 /* Cleanup helpers: */ 98 //void cleanupMachineView() {}99 90 void saveWindowSettings(); 91 void cleanupMachineView(); 100 92 //void cleanupConnections() {} 101 void cleanupStatusBar();102 93 //void cleanupMenu() {} 103 94 //void cleanupConsoleConnections() {} 104 95 105 /* Indicators pool: */ 106 UIIndicatorsPool *m_pIndicatorsPool; 107 /* Other QWidgets: */ 108 QWidget *m_pCntHostkey; 109 QLabel *m_pNameHostkey; 110 /* Other QObjects: */ 111 QTimer *m_pIdleTimer; 96 #ifdef Q_WS_MAC 97 # ifdef QT_MAC_USE_COCOA 98 void setPresentationModeEnabled(bool fEnabled); 99 # endif /* QT_MAC_USE_COCOA */ 100 #endif /* Q_WS_MAC */ 101 112 102 /* Other members: */ 113 103 QRect m_normalGeometry; … … 117 107 }; 118 108 119 #endif // __UIMachineWindow Normal_h__109 #endif // __UIMachineWindowFullscreen_h__ 120 110 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp
r26878 r26889 50 50 #endif 51 51 ) 52 , m_desktopGeometryType(DesktopGeo_Invalid)53 52 , m_bIsGuestAutoresizeEnabled(pMachineWindow->machineLogic()->actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize)->isChecked()) 54 53 , m_fShouldWeDoResize(false) … … 165 164 /* Global settings: */ 166 165 { 167 /* Remember the desktop geometry and register for geometry168 * change events for telling the guest about video modes we like: */169 QString desktopGeometry = vboxGlobal().settings().publicProperty("GUI/MaxGuestResolution");170 if ((desktopGeometry == QString::null) || (desktopGeometry == "auto"))171 setDesktopGeometry(DesktopGeo_Automatic, 0, 0);172 else if (desktopGeometry == "any")173 setDesktopGeometry(DesktopGeo_Any, 0, 0);174 else175 {176 int width = desktopGeometry.section(',', 0, 0).toInt();177 int height = desktopGeometry.section(',', 1, 1).toInt();178 setDesktopGeometry(DesktopGeo_Fixed, width, height);179 }180 166 connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(sltDesktopResized())); 181 167 } … … 193 179 sltPerformGuestResize(); 194 180 } 195 }196 197 QSize UIMachineViewNormal::desktopGeometry() const198 {199 QSize geometry;200 switch (m_desktopGeometryType)201 {202 case DesktopGeo_Fixed:203 case DesktopGeo_Automatic:204 geometry = QSize(qMax(m_desktopGeometry.width(), m_storedConsoleSize.width()),205 qMax(m_desktopGeometry.height(), m_storedConsoleSize.height()));206 break;207 case DesktopGeo_Any:208 geometry = QSize(0, 0);209 break;210 default:211 AssertMsgFailed(("Bad geometry type %d!\n", m_desktopGeometryType));212 }213 return geometry;214 181 } 215 182 … … 262 229 } 263 230 264 void UIMachineViewNormal::calculateDesktopGeometry()265 {266 /* This method should not get called until we have initially set up the m_desktopGeometryType: */267 Assert((m_desktopGeometryType != DesktopGeo_Invalid));268 /* If we are not doing automatic geometry calculation then there is nothing to do: */269 if (DesktopGeo_Automatic == m_desktopGeometryType)270 {271 /* Available geometry of the desktop. If the desktop is a single272 * screen, this will exclude space taken up by desktop taskbars273 * and things, but this is unfortunately not true for the more274 * complex case of a desktop spanning multiple screens: */275 QRect desktop = availableGeometry();276 /* The area taken up by the machine window on the desktop,277 * including window frame, title and menu bar and whatnot: */278 QRect frame = machineWindowWrapper()->machineWindow()->frameGeometry();279 /* The area taken up by the machine view, so excluding all decorations: */280 QRect window = geometry();281 /* To work out how big we can make the console window while still282 * fitting on the desktop, we calculate desktop - frame + window.283 * This works because the difference between frame and window284 * (or at least its width and height) is a constant. */285 m_desktopGeometry = QSize(desktop.width() - frame.width() + window.width(),286 desktop.height() - frame.height() + window.height());287 }288 }289 290 231 QRect UIMachineViewNormal::availableGeometry() 291 232 { 292 return machineWindowWrapper()->machineWindow()->isFullScreen() ? 293 QApplication::desktop()->screenGeometry(this) : 294 QApplication::desktop()->availableGeometry(this); 295 } 296 297 void UIMachineViewNormal::setDesktopGeometry(DesktopGeo geometry, int aWidth, int aHeight) 298 { 299 switch (geometry) 300 { 301 case DesktopGeo_Fixed: 302 m_desktopGeometryType = DesktopGeo_Fixed; 303 if (aWidth != 0 && aHeight != 0) 304 m_desktopGeometry = QSize(aWidth, aHeight); 305 else 306 m_desktopGeometry = QSize(0, 0); 307 storeConsoleSize(0, 0); 308 break; 309 case DesktopGeo_Automatic: 310 m_desktopGeometryType = DesktopGeo_Automatic; 311 m_desktopGeometry = QSize(0, 0); 312 storeConsoleSize(0, 0); 313 break; 314 case DesktopGeo_Any: 315 m_desktopGeometryType = DesktopGeo_Any; 316 m_desktopGeometry = QSize(0, 0); 317 break; 318 default: 319 AssertMsgFailed(("Invalid desktop geometry type %d\n", geometry)); 320 m_desktopGeometryType = DesktopGeo_Invalid; 321 } 322 } 323 324 void UIMachineViewNormal::storeConsoleSize(int iWidth, int iHeight) 325 { 326 m_storedConsoleSize = QSize(iWidth, iHeight); 233 return QApplication::desktop()->availableGeometry(this); 327 234 } 328 235 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.h
r26878 r26889 38 38 protected: 39 39 40 /* Desktop geometry types: */41 enum DesktopGeo { DesktopGeo_Invalid = 0, DesktopGeo_Fixed, DesktopGeo_Automatic, DesktopGeo_Any };42 43 40 /* Normal machine view constructor/destructor: */ 44 41 UIMachineViewNormal( UIMachineWindow *pMachineWindow … … 76 73 void setGuestAutoresizeEnabled(bool bEnabled); 77 74 78 /* Hidden getters: */79 QSize desktopGeometry() const;80 81 75 /* Private helpers: */ 82 76 void normalizeGeometry(bool fAdjustPosition); 83 void calculateDesktopGeometry();84 77 QRect availableGeometry(); 85 void setDesktopGeometry(DesktopGeo geometry, int iWidth, int iHeight);86 void storeConsoleSize(int iWidth, int iHeight);87 78 void maybeRestrictMinimumSize(); 88 79 … … 92 83 93 84 /* Private members: */ 94 DesktopGeo m_desktopGeometryType;95 QSize m_desktopGeometry;96 QSize m_storedConsoleSize;97 85 bool m_bIsGuestAutoresizeEnabled : 1; 98 86 bool m_fShouldWeDoResize : 1;
Note:
See TracChangeset
for help on using the changeset viewer.