Changeset 51558 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jun 5, 2014 4:08:24 PM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp
r51549 r51558 516 516 switch (visualStateType) 517 517 { 518 case UIVisualStateType_Normal: strKey = GUI_LastNormalWindowPosition; break;519 case UIVisualStateType_Scale: strKey = GUI_LastScaleWindowPosition; break;518 case UIVisualStateType_Normal: strKey = extraDataKeyPerScreen(GUI_LastNormalWindowPosition, uScreenIndex); break; 519 case UIVisualStateType_Scale: strKey = extraDataKeyPerScreen(GUI_LastScaleWindowPosition, uScreenIndex); break; 520 520 default: AssertFailedReturn(QRect()); 521 521 } 522 /* Append with screen-index: */523 if (uScreenIndex)524 strKey += QString::number(uScreenIndex);525 522 526 523 /* Load corresponding extra-data: */ … … 553 550 switch (visualStateType) 554 551 { 555 case UIVisualStateType_Normal: strKey = GUI_LastNormalWindowPosition; break;556 case UIVisualStateType_Scale: strKey = GUI_LastScaleWindowPosition; break;552 case UIVisualStateType_Normal: strKey = extraDataKeyPerScreen(GUI_LastNormalWindowPosition, uScreenIndex); break; 553 case UIVisualStateType_Scale: strKey = extraDataKeyPerScreen(GUI_LastScaleWindowPosition, uScreenIndex); break; 557 554 default: AssertFailedReturn(false); 558 555 } 559 /* Append with screen-index: */560 if (uScreenIndex)561 strKey += QString::number(uScreenIndex);562 556 563 557 /* Load corresponding extra-data: */ … … 574 568 switch (visualStateType) 575 569 { 576 case UIVisualStateType_Normal: strKey = GUI_LastNormalWindowPosition; break;577 case UIVisualStateType_Scale: strKey = GUI_LastScaleWindowPosition; break;570 case UIVisualStateType_Normal: strKey = extraDataKeyPerScreen(GUI_LastNormalWindowPosition, uScreenIndex); break; 571 case UIVisualStateType_Scale: strKey = extraDataKeyPerScreen(GUI_LastScaleWindowPosition, uScreenIndex); break; 578 572 default: AssertFailedReturnVoid(); 579 573 } 580 /* Append with screen-index: */581 if (uScreenIndex)582 strKey += QString::number(uScreenIndex);583 574 584 575 /* Serialize passed values: */ … … 593 584 /* Re-cache corresponding extra-data: */ 594 585 setExtraDataStringList(strKey, data, strId); 586 } 587 588 QSize UIExtraDataManager::lastGuestSizeHint(ulong uScreenIndex, const QString &strId) const 589 { 590 /* Choose corresponding key: */ 591 QString strKey = extraDataKeyPerScreen(GUI_LastGuestSizeHint, uScreenIndex); 592 593 /* Load corresponding extra-data: */ 594 const QStringList data = extraDataStringList(strKey, strId); 595 596 /* Parse loaded data: */ 597 int iW = 0, iH = 0; 598 bool fOk = data.size() == 2; 599 do 600 { 601 if (!fOk) break; 602 iW = data[0].toInt(&fOk); 603 if (!fOk) break; 604 iH = data[1].toInt(&fOk); 605 } 606 while (0); 607 608 /* Return size (loaded or invalid): */ 609 return fOk ? QSize(iW, iH) : QSize(); 610 } 611 612 void UIExtraDataManager::setLastGuestSizeHint(ulong uScreenIndex, const QSize &size, const QString &strId) 613 { 614 /* Choose corresponding key: */ 615 QString strKey = extraDataKeyPerScreen(GUI_LastGuestSizeHint, uScreenIndex); 616 617 /* Serialize passed values: */ 618 QStringList data; 619 data << QString::number(size.width()); 620 data << QString::number(size.height()); 621 622 /* Re-cache corresponding extra-data: */ 623 setExtraDataStringList(strKey, data, strId); 624 } 625 626 bool UIExtraDataManager::wasLastGuestSizeHintForFullScreen(ulong uScreenIndex, const QString &strId) const 627 { 628 /* Choose corresponding key: */ 629 const QString strKey = extraDataKeyPerScreen(GUI_LastGuestSizeHintWasFullscreen, uScreenIndex); 630 631 /* True only if was stated directly: */ 632 return isFeatureAllowed(strKey, strId); 633 } 634 635 void UIExtraDataManager::markLastGuestSizeHintAsFullScreen(ulong uScreenIndex, bool fWas, const QString &strId) 636 { 637 /* Choose corresponding key: */ 638 const QString strKey = extraDataKeyPerScreen(GUI_LastGuestSizeHintWasFullscreen, uScreenIndex); 639 640 /* State directly only if was true: */ 641 return setExtraDataString(strKey, toFeatureAllowed(fWas), strId); 595 642 } 596 643 … … 1140 1187 } 1141 1188 1189 /* static */ 1190 QString UIExtraDataManager::extraDataKeyPerScreen(const QString &strBase, ulong uScreenIndex) 1191 { 1192 return uScreenIndex ? strBase + QString::number(uScreenIndex) : strBase; 1193 } 1194 1142 1195 #include "UIExtraDataManager.moc" 1143 1196 -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h
r51549 r51558 180 180 /** Defines geometry for machine-window with @a uScreenIndex in @a visualStateType as @a geometry and @a fMaximized. */ 181 181 void setMachineWindowGeometry(UIVisualStateType visualStateType, ulong uScreenIndex, const QRect &geometry, bool fMaximized, const QString &strId); 182 183 /** Returns last guest-screen size-hint for screen with @a uScreenIndex. */ 184 QSize lastGuestSizeHint(ulong uScreenIndex, const QString &strId) const; 185 /** Defines last guest-screen size-hint for screen with @a uScreenIndex as @a size. */ 186 void setLastGuestSizeHint(ulong uScreenIndex, const QSize &size, const QString &strId); 187 /** Returns whether guest size hint was for full or seamless screen with @a uScreenIndex. */ 188 bool wasLastGuestSizeHintForFullScreen(ulong uScreenIndex, const QString &strId) const; 189 /** Defines whether guest size hint @a fWas for full or seamless screen with @a uScreenIndex. */ 190 void markLastGuestSizeHintAsFullScreen(ulong uScreenIndex, bool fWas, const QString &strId); 182 191 183 192 /** Returns whether this machine started for the first time. */ … … 301 310 void setExtraDataStringList(const QString &strKey, const QStringList &strValue, const QString &strID = m_sstrGlobalID); 302 311 312 /** Return a string consisting of @a strBase with a suffix for the passed screen. 313 * Used for storing per-screen extra-data. */ 314 static QString extraDataKeyPerScreen(const QString &strBase, ulong uScreenIndex); 315 303 316 /** Singleton Extra-data Manager instance. */ 304 317 static UIExtraDataManager *m_pInstance; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r51510 r51558 189 189 uisession()->isScreenVisible(screenId()), 190 190 false, 0, 0, newSize.width(), newSize.height(), 0); 191 /* And track whether we have had a "normal" resize since the last 192 * fullscreen resize hint was sent: */ 193 QString strKey = makeExtraDataKeyPerMonitor(GUI_LastGuestSizeHintWasFullscreen); 194 machine.SetExtraData(strKey, isFullscreenOrSeamless() ? "true" : ""); 191 /* And track whether we have a "normal" or "fullscreen"/"seamless" size-hint sent: */ 192 gEDataManager->markLastGuestSizeHintAsFullScreen(m_uScreenId, isFullscreenOrSeamless(), vboxGlobal().managedVMUuid()); 195 193 } 196 194 … … 648 646 QSize UIMachineView::guestSizeHint() 649 647 { 650 /* Result: */ 651 QSize sizeHint; 652 653 /* Get current machine: */ 654 CMachine machine = session().GetMachine(); 655 656 /* Load machine view hint: */ 657 QString strKey = makeExtraDataKeyPerMonitor(GUI_LastGuestSizeHint); 658 QString strValue = machine.GetExtraData(strKey); 659 660 bool ok = true; 661 int width = 0, height = 0; 662 if (ok) 663 width = strValue.section(',', 0, 0).toInt(&ok); 664 if (ok) 665 height = strValue.section(',', 1, 1).toInt(&ok); 666 667 if (ok /* If previous parameters were read correctly! */) 668 { 669 /* Compose guest size hint from loaded values: */ 670 sizeHint = QSize(width, height); 671 } 672 else 673 { 674 /* Compose guest size hint from default attributes: */ 675 sizeHint = QSize(800, 600); 676 } 677 678 /* Return result: */ 679 return sizeHint; 680 } 681 682 void UIMachineView::storeGuestSizeHint(const QSize &sizeHint) 683 { 684 /* Get current machine: */ 685 CMachine machine = session().GetMachine(); 686 687 /* Save machine view hint: */ 688 QString strKey = makeExtraDataKeyPerMonitor(GUI_LastGuestSizeHint); 689 QString strValue = QString("%1,%2").arg(sizeHint.width()).arg(sizeHint.height()); 690 machine.SetExtraData(strKey, strValue); 648 /* Load guest-screen size-hint: */ 649 QSize size = gEDataManager->lastGuestSizeHint(m_uScreenId, vboxGlobal().managedVMUuid()); 650 651 /* Return loaded or default: */ 652 return size.isValid() ? size : QSize(800, 600); 653 } 654 655 void UIMachineView::storeGuestSizeHint(const QSize &size) 656 { 657 /* Save guest-screen size-hint: */ 658 gEDataManager->setLastGuestSizeHint(m_uScreenId, size, vboxGlobal().managedVMUuid()); 691 659 } 692 660 … … 846 814 return visualStateType() == UIVisualStateType_Fullscreen 847 815 || visualStateType() == UIVisualStateType_Seamless; 848 }849 850 QString UIMachineView::makeExtraDataKeyPerMonitor(QString base) const851 {852 return m_uScreenId == 0 ? QString("%1").arg(base)853 : QString("%1%2").arg(base).arg(m_uScreenId);854 816 } 855 817 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
r51493 r51558 175 175 /** Store a guest size hint value to extra data, called on switching to 176 176 * fullscreen. */ 177 void storeGuestSizeHint(const QSize &size Hint);177 void storeGuestSizeHint(const QSize &size); 178 178 179 179 /* Protected helpers: */ … … 200 200 /** Is this a fullscreen-type view? */ 201 201 bool isFullscreenOrSeamless() const; 202 /** Return a string consisting of @a base with a suffix for the active203 * virtual monitor. Used for storing monitor-specific extra data. */204 QString makeExtraDataKeyPerMonitor(QString base) const;205 202 206 203 /* Cross-platforms event processors: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp
r49177 r51558 33 33 #include "UIMachineWindow.h" 34 34 #include "UIMachineViewNormal.h" 35 #include "UIExtraDataManager.h" 35 36 #include "UIFrameBuffer.h" 36 37 … … 171 172 if (m_bIsGuestAutoresizeEnabled && uisession()->isGuestSupportsGraphics()) 172 173 { 173 /* Get the current machine: */ 174 CMachine machine = session().GetMachine(); 175 176 /* We send a guest size hint if needed to reverse a transition 177 * to fullscreen or seamless. */ 178 QString strKey = makeExtraDataKeyPerMonitor(GUI_LastGuestSizeHintWasFullscreen); 179 QString strHintSent = machine.GetExtraData(strKey); 180 if (!strHintSent.isEmpty()) 174 /* Send guest-screen size-hint if needed to reverse a transition to fullscreen or seamless: */ 175 if (gEDataManager->wasLastGuestSizeHintForFullScreen(m_uScreenId, vboxGlobal().managedVMUuid())) 181 176 { 182 177 QSize hint = guestSizeHint();
Note:
See TracChangeset
for help on using the changeset viewer.