VirtualBox

Ignore:
Timestamp:
Jun 5, 2014 4:08:24 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: 6660: Advanced extra-data management framework: Integrate GUI_LastGuestSizeHint, GUI_LastGuestSizeHintWasFullscreen.

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  
    516516    switch (visualStateType)
    517517    {
    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;
    520520        default: AssertFailedReturn(QRect());
    521521    }
    522     /* Append with screen-index: */
    523     if (uScreenIndex)
    524         strKey += QString::number(uScreenIndex);
    525522
    526523    /* Load corresponding extra-data: */
     
    553550    switch (visualStateType)
    554551    {
    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;
    557554        default: AssertFailedReturn(false);
    558555    }
    559     /* Append with screen-index: */
    560     if (uScreenIndex)
    561         strKey += QString::number(uScreenIndex);
    562556
    563557    /* Load corresponding extra-data: */
     
    574568    switch (visualStateType)
    575569    {
    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;
    578572        default: AssertFailedReturnVoid();
    579573    }
    580     /* Append with screen-index: */
    581     if (uScreenIndex)
    582         strKey += QString::number(uScreenIndex);
    583574
    584575    /* Serialize passed values: */
     
    593584    /* Re-cache corresponding extra-data: */
    594585    setExtraDataStringList(strKey, data, strId);
     586}
     587
     588QSize 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
     612void 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
     626bool 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
     635void 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);
    595642}
    596643
     
    11401187}
    11411188
     1189/* static */
     1190QString UIExtraDataManager::extraDataKeyPerScreen(const QString &strBase, ulong uScreenIndex)
     1191{
     1192    return uScreenIndex ? strBase + QString::number(uScreenIndex) : strBase;
     1193}
     1194
    11421195#include "UIExtraDataManager.moc"
    11431196
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r51549 r51558  
    180180    /** Defines geometry for machine-window with @a uScreenIndex in @a visualStateType as @a geometry and @a fMaximized. */
    181181    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);
    182191
    183192    /** Returns whether this machine started for the first time. */
     
    301310    void setExtraDataStringList(const QString &strKey, const QStringList &strValue, const QString &strID = m_sstrGlobalID);
    302311
     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
    303316    /** Singleton Extra-data Manager instance. */
    304317    static UIExtraDataManager *m_pInstance;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r51510 r51558  
    189189                                                         uisession()->isScreenVisible(screenId()),
    190190                                                         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());
    195193}
    196194
     
    648646QSize UIMachineView::guestSizeHint()
    649647{
    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
     655void UIMachineView::storeGuestSizeHint(const QSize &size)
     656{
     657    /* Save guest-screen size-hint: */
     658    gEDataManager->setLastGuestSizeHint(m_uScreenId, size, vboxGlobal().managedVMUuid());
    691659}
    692660
     
    846814    return    visualStateType() == UIVisualStateType_Fullscreen
    847815           || visualStateType() == UIVisualStateType_Seamless;
    848 }
    849 
    850 QString UIMachineView::makeExtraDataKeyPerMonitor(QString base) const
    851 {
    852     return m_uScreenId == 0 ? QString("%1").arg(base)
    853                             : QString("%1%2").arg(base).arg(m_uScreenId);
    854816}
    855817
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r51493 r51558  
    175175    /** Store a guest size hint value to extra data, called on switching to
    176176     * fullscreen. */
    177     void storeGuestSizeHint(const QSize &sizeHint);
     177    void storeGuestSizeHint(const QSize &size);
    178178
    179179    /* Protected helpers: */
     
    200200    /** Is this a fullscreen-type view? */
    201201    bool isFullscreenOrSeamless() const;
    202     /** Return a string consisting of @a base with a suffix for the active
    203      * virtual monitor.  Used for storing monitor-specific extra data. */
    204     QString makeExtraDataKeyPerMonitor(QString base) const;
    205202
    206203    /* Cross-platforms event processors: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp

    r49177 r51558  
    3333#include "UIMachineWindow.h"
    3434#include "UIMachineViewNormal.h"
     35#include "UIExtraDataManager.h"
    3536#include "UIFrameBuffer.h"
    3637
     
    171172    if (m_bIsGuestAutoresizeEnabled && uisession()->isGuestSupportsGraphics())
    172173    {
    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()))
    181176        {
    182177            QSize hint = guestSizeHint();
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette