VirtualBox

Changeset 105329 in vbox


Ignore:
Timestamp:
Jul 15, 2024 3:00:45 PM (5 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10672: Runtime UI: More wise and clear states processing for mouse pointer and corresponding indicator.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp

    r105326 r105329  
    11071107    Q_OBJECT;
    11081108
     1109    /** Possible indicator states. */
     1110    enum
     1111    {
     1112        State_NotCaptured         = 0, // 000 == !MouseCaptured
     1113        State_Captured            = 1, // 001 == MouseCaptured
     1114        State_AbsoluteNotCaptured = 2, // 010 == !MouseCaptured & MouseSupportsAbsolute
     1115        State_AbsoluteCaptured    = 3, // 011 == MouseCaptured & MouseSupportsAbsolute
     1116        State_Integrated          = 6, // 110 == MouseSupportsAbsolute & MouseIntegrated
     1117    };
     1118
    11091119public:
    11101120
     
    11141124    {
    11151125        /* Assign state-icons: */
    1116         setStateIcon(0, UIIconPool::iconSet(":/mouse_disabled_16px.png"));
    1117         setStateIcon(1, UIIconPool::iconSet(":/mouse_16px.png"));
    1118         setStateIcon(2, UIIconPool::iconSet(":/mouse_seamless_16px.png"));
    1119         setStateIcon(3, UIIconPool::iconSet(":/mouse_can_seamless_16px.png"));
    1120         setStateIcon(4, UIIconPool::iconSet(":/mouse_can_seamless_uncaptured_16px.png"));
    1121         /* Configure connection: */
    1122         connect(m_pMachine, &UIMachine::sigMouseStateChange,
    1123                 this, static_cast<void(UIIndicatorMouse::*)(int)>(&UIIndicatorMouse::setState)); // us to blame ..
     1126        setStateIcon(State_NotCaptured,         UIIconPool::iconSet(":/mouse_disabled_16px.png"));                // 000
     1127        setStateIcon(State_Captured,            UIIconPool::iconSet(":/mouse_16px.png"));                         // 001
     1128        setStateIcon(State_AbsoluteNotCaptured, UIIconPool::iconSet(":/mouse_can_seamless_uncaptured_16px.png")); // 010
     1129        setStateIcon(State_AbsoluteCaptured,    UIIconPool::iconSet(":/mouse_can_seamless_16px.png"));            // 011
     1130        setStateIcon(State_Integrated,          UIIconPool::iconSet(":/mouse_seamless_16px.png"));                // 110
     1131
     1132        /* Configure machine connection: */
     1133        connect(m_pMachine, &UIMachine::sigMouseStateChange, this, &UIIndicatorMouse::setState);
     1134
    11241135        /* Update & translate finally: */
    11251136        updateAppearance();
     
    11311142    virtual void updateAppearance() RT_OVERRIDE
    11321143    {
     1144        /* Retranslate finally: */
     1145        sltRetranslateUI();
     1146    }
     1147
     1148    /** Handles translation event. */
     1149    virtual void sltRetranslateUI() RT_OVERRIDE
     1150    {
     1151        /* Call to base-class: */
     1152        UISessionStateStatusBarIndicator::sltRetranslateUI();
     1153
     1154        /* Update tool-tip: */
    11331155        const QString strToolTip = tr("Indicates whether the host mouse pointer is "
    11341156                                      "captured by the guest OS:%1", "Mouse tooltip");
     
    11361158        strFullData += s_strTableRow3
    11371159            .arg(QString("<img src=:/mouse_disabled_16px.png/>"))
    1138             .arg(tr("pointer is not captured", "Mouse tooltip"));
     1160            .arg(tr("Pointer is not captured", "Mouse tooltip"));
    11391161        strFullData += s_strTableRow3
    11401162            .arg(QString("<img src=:/mouse_16px.png/>"))
    1141             .arg(tr("pointer is captured", "Mouse tooltip"));
     1163            .arg(tr("Pointer is captured", "Mouse tooltip"));
     1164        strFullData += s_strTableRow3
     1165            .arg(QString("<img src=:/mouse_can_seamless_uncaptured_16px.png/>"))
     1166            .arg(tr("Mouse integration is Off, pointer is not captured", "Mouse tooltip"));
     1167        strFullData += s_strTableRow3
     1168            .arg(QString("<img src=:/mouse_can_seamless_16px.png/>"))
     1169            .arg(tr("Mouse integration is Off, pointer is captured", "Mouse tooltip"));
    11421170        strFullData += s_strTableRow3
    11431171            .arg(QString("<img src=:/mouse_seamless_16px.png/>"))
    1144             .arg(tr("mouse integration (MI) is On", "Mouse tooltip"));
    1145         strFullData += s_strTableRow3
    1146             .arg(QString("<img src=:/mouse_can_seamless_16px.png/>"))
    1147             .arg(tr("MI is Off, pointer is captured", "Mouse tooltip"));
    1148         strFullData += s_strTableRow3
    1149             .arg(QString("<img src=:/mouse_can_seamless_uncaptured_16px.png/>"))
    1150             .arg(tr("MI is Off, pointer is not captured", "Mouse tooltip"));
     1172            .arg(tr("Mouse integration is On", "Mouse tooltip"));
    11511173        strFullData = s_strTable.arg(strFullData);
    11521174        strFullData += tr("Note that the mouse integration feature requires Guest "
    11531175                          "Additions to be installed in the guest OS.", "Mouse tooltip");
    1154 
    1155         /* Update tool-tip: */
    11561176        setToolTip(strToolTip.arg(strFullData));
    1157 
    1158         /* Retranslate finally: */
    1159         sltRetranslateUI();
    1160     }
    1161 
    1162     /** Handles translation event. */
    1163     virtual void sltRetranslateUI() RT_OVERRIDE
    1164     {
    1165         /* Call to base-class: */
    1166         UISessionStateStatusBarIndicator::sltRetranslateUI();
    11671177
    11681178        /* Append description with more info: */
     
    11701180        switch (state())
    11711181        {
    1172             case 0: strState = tr("pointer is not captured", "Mouse tooltip"); break;
    1173             case 1: strState = tr("pointer is captured", "Mouse tooltip"); break;
    1174             case 2: strState = tr("mouse integration (MI) is On", "Mouse tooltip"); break;
    1175             case 3: strState = tr("MI is Off, pointer is captured", "Mouse tooltip"); break;
    1176             case 4: strState = tr("MI is Off, pointer is not captured", "Mouse tooltip"); break;
    1177             default: break;
     1182            case State_NotCaptured:
     1183                strState = tr("Pointer is not captured", "Mouse tooltip"); break;
     1184            case State_Captured:
     1185                strState = tr("Pointer is captured", "Mouse tooltip"); break;
     1186            case State_AbsoluteNotCaptured:
     1187                strState = tr("Mouse integration is Off, pointer is not captured", "Mouse tooltip"); break;
     1188            case State_AbsoluteCaptured:
     1189                strState = tr("Mouse integration is Off, pointer is captured", "Mouse tooltip"); break;
     1190            case State_Integrated:
     1191                strState = tr("Mouse integration is On", "Mouse tooltip"); break;
     1192            default:
     1193                break;
    11781194        }
    11791195        if (!strState.isNull())
     
    11861202    void setState(int iState) RT_OVERRIDE
    11871203    {
    1188         if ((iState & UIMouseStateType_MouseAbsoluteDisabled) &&
    1189             (iState & UIMouseStateType_MouseAbsolute) &&
    1190             !(iState & UIMouseStateType_MouseCaptured))
    1191             QIStateStatusBarIndicator::setState(4);
    1192         else
    1193             QIStateStatusBarIndicator::setState(iState & (UIMouseStateType_MouseAbsolute | UIMouseStateType_MouseCaptured));
    1194         sltRetranslateUI();
     1204        /* Call to base-class: */
     1205        QIStateStatusBarIndicator::setState(iState);
     1206
     1207        /* Update everything: */
     1208        updateAppearance();
    11951209    }
    11961210};
     1211
    11971212
    11981213/** UISessionStateStatusBarIndicator extension for Runtime UI: Keyboard indicator. */
     
    12471262    }
    12481263};
     1264
    12491265
    12501266/** QITextStatusBarIndicator extension for Runtime UI: Keyboard-extension indicator. */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineDefs.h

    r103339 r105329  
    5858{
    5959    UIMouseStateType_MouseCaptured         = RT_BIT(0),
    60     UIMouseStateType_MouseAbsolute         = RT_BIT(1),
    61     UIMouseStateType_MouseAbsoluteDisabled = RT_BIT(2),
    62     UIMouseStateType_MouseNeedsHostCursor  = RT_BIT(3)
     60    UIMouseStateType_MouseSupportsAbsolute = RT_BIT(1),
     61    UIMouseStateType_MouseIntegrated       = RT_BIT(2)
    6362};
    6463
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp

    r104598 r105329  
    258258int UIMouseHandler::state() const
    259259{
    260     return uimachine()->machineState() == KMachineState_Null ? 0 :
    261            (uimachine()->isMouseCaptured() ? UIMouseStateType_MouseCaptured : 0) |
    262            (uimachine()->isMouseSupportsAbsolute() ? UIMouseStateType_MouseAbsolute : 0) |
    263            (uimachine()->isMouseIntegrated() ? 0 : UIMouseStateType_MouseAbsoluteDisabled);
     260    int iResult = 0;
     261    if (uimachine()->isMouseCaptured())
     262        iResult |= UIMouseStateType_MouseCaptured;
     263    if (uimachine()->isMouseSupportsAbsolute())
     264    {
     265        iResult |= UIMouseStateType_MouseSupportsAbsolute;
     266        if (uimachine()->isMouseIntegrated())
     267            iResult |= UIMouseStateType_MouseIntegrated;
     268    }
     269    return iResult;
    264270}
    265271
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