VirtualBox

Changeset 73841 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Aug 22, 2018 5:13:17 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9085. Implementing a togglable for the machine UI to send host key combo press/release scan codes.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r72030 r73841  
    513513        RuntimeMenuInputActionType_Mouse              = RT_BIT(8),
    514514        RuntimeMenuInputActionType_MouseIntegration   = RT_BIT(9),
     515        RuntimeMenuInputActionType_TypeHostKeyCombo   = RT_BIT(10),
    515516        RuntimeMenuInputActionType_All                = 0xFFFF
    516517    };
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolRuntime.cpp

    r73791 r73841  
    18131813        setName(QApplication::translate("UIActionPool", "&Insert %1", "that means send the %1 key sequence to the virtual machine").arg("Alt Print Screen"));
    18141814        setStatusTip(QApplication::translate("UIActionPool", "Send the %1 sequence to the virtual machine").arg("Alt Print Screen"));
     1815    }
     1816};
     1817
     1818/** Toggle action extension, used as 'Perform Host Key Combo press/release' action class. */
     1819class UIActionToggleRuntimePerformTypeHostKeyCombo : public UIActionToggle
     1820{
     1821    Q_OBJECT;
     1822
     1823public:
     1824
     1825    /** Constructs action passing @a pParent to the base-class. */
     1826    UIActionToggleRuntimePerformTypeHostKeyCombo(UIActionPool *pParent)
     1827        : UIActionToggle
     1828          (pParent,
     1829           ":/vm_pause_on_16px.png", ":/vm_pause_16px.png",
     1830           ":/vm_pause_on_disabled_16px.png", ":/vm_pause_disabled_16px.png",
     1831           true)
     1832    {}
     1833
     1834protected:
     1835
     1836    /** Returns action extra-data ID. */
     1837    virtual int extraDataID() const /* override */
     1838    {
     1839        return UIExtraDataMetaDefs::RuntimeMenuInputActionType_TypeHostKeyCombo;
     1840    }
     1841    /** Returns action extra-data key. */
     1842    virtual QString extraDataKey() const /* override */
     1843    {
     1844        return gpConverter->toInternalString(UIExtraDataMetaDefs::RuntimeMenuInputActionType_TypeHostKeyCombo);
     1845    }
     1846    /** Returns whether action is allowed. */
     1847    virtual bool isAllowed() const /* override */
     1848    {
     1849        return actionPool()->toRuntime()->isAllowedInMenuInput(UIExtraDataMetaDefs::RuntimeMenuInputActionType_TypeHostKeyCombo);
     1850    }
     1851
     1852    /** Returns shortcut extra-data ID. */
     1853    virtual QString shortcutExtraDataID() const /* override */
     1854    {
     1855        return QString("TypeHostKeyCode");
     1856    }
     1857
     1858    /** Returns default shortcut. */
     1859    virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
     1860    {
     1861#ifdef VBOX_WS_MAC
     1862        return QKeySequence("Insert");
     1863#else
     1864        return QKeySequence("Insert");
     1865#endif
     1866    }
     1867
     1868    /** Handles translation event. */
     1869    virtual void retranslateUi() /* override */
     1870    {
     1871        setName(QApplication::translate("UIActionPool", "&Insert %1", "that means send the %1 key sequence to the virtual machine").arg("Home Key Combo"));
     1872        setStatusTip(QApplication::translate("UIActionPool", "Send the %1 sequence to the virtual machine").arg("Home Key Combo"));
    18151873    }
    18161874};
     
    32123270    m_pool[UIActionIndexRT_M_Input_M_Keyboard_S_TypePrintScreen] = new UIActionSimpleRuntimePerformTypePrintScreen(this);
    32133271    m_pool[UIActionIndexRT_M_Input_M_Keyboard_S_TypeAltPrintScreen] = new UIActionSimpleRuntimePerformTypeAltPrintScreen(this);
     3272    m_pool[UIActionIndexRT_M_Input_M_Keyboard_T_TypeHostKeyCombo] = new UIActionToggleRuntimePerformTypeHostKeyCombo(this);
    32143273    m_pool[UIActionIndexRT_M_Input_M_Mouse] = new UIActionMenuRuntimeMouse(this);
    32153274    m_pool[UIActionIndexRT_M_Input_M_Mouse_T_Integration] = new UIActionToggleRuntimeMouseIntegration(this);
     
    39754034    /* 'Type Alt Print Screen' action: */
    39764035    fSeparator = addAction(pMenu, action(UIActionIndexRT_M_Input_M_Keyboard_S_TypeAltPrintScreen)) || fSeparator;
     4036    fSeparator = addAction(pMenu, action(UIActionIndexRT_M_Input_M_Keyboard_T_TypeHostKeyCombo)) || fSeparator;
    39774037
    39784038    /* Mark menu as valid: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolRuntime.h

    r73384 r73841  
    9191    UIActionIndexRT_M_Input_M_Keyboard_S_TypePrintScreen,
    9292    UIActionIndexRT_M_Input_M_Keyboard_S_TypeAltPrintScreen,
     93    UIActionIndexRT_M_Input_M_Keyboard_T_TypeHostKeyCombo,
    9394    UIActionIndexRT_M_Input_M_Mouse,
    9495    UIActionIndexRT_M_Input_M_Mouse_T_Integration,
     
    327328
    328329#endif /* !___UIActionPoolRuntime_h___ */
    329 
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r73694 r73841  
    4141#  include "UIDownloaderAdditions.h"
    4242# endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
     43# include "UIHostComboEditor.h"
    4344# include "UIIconPool.h"
    4445# include "UIKeyboardHandler.h"
     
    10301031    m_pRunningActions->addAction(actionPool()->action(UIActionIndexRT_M_Input_M_Keyboard_S_TypePrintScreen));
    10311032    m_pRunningActions->addAction(actionPool()->action(UIActionIndexRT_M_Input_M_Keyboard_S_TypeAltPrintScreen));
     1033    m_pRunningActions->addAction(actionPool()->action(UIActionIndexRT_M_Input_M_Keyboard_T_TypeHostKeyCombo));
    10321034
    10331035    /* Move actions into running-n-paused actions group: */
     
    11491151    connect(actionPool()->action(UIActionIndexRT_M_Input_M_Keyboard_S_TypeAltPrintScreen), SIGNAL(triggered()),
    11501152            this, SLOT(sltTypeAltPrintScreen()));
     1153    connect(actionPool()->action(UIActionIndexRT_M_Input_M_Keyboard_T_TypeHostKeyCombo), SIGNAL(toggled(bool)),
     1154            this, SLOT(sltTypeHostKeyComboPressRelease(bool)));
    11511155    connect(actionPool()->action(UIActionIndexRT_M_Input_M_Mouse_T_Integration), SIGNAL(toggled(bool)),
    11521156            this, SLOT(sltToggleMouseIntegration(bool)));
     
    16771681}
    16781682
     1683void UIMachineLogic::sltTypeHostKeyComboPressRelease(bool actionToggle)
     1684{
     1685    QList<unsigned> shortCodes = UIHostCombo::modifiersToScanCodes(gEDataManager->hostKeyCombination());
     1686    QVector <LONG> codes;
     1687    foreach (unsigned idxCode, shortCodes)
     1688    {
     1689        /* Check if we need to include extend code for this key: */
     1690        if (idxCode & 0x100)
     1691            codes << 0xE0;
     1692        if (actionToggle)
     1693        {
     1694            /* Add the press code: */
     1695             codes << (idxCode & 0x7F);
     1696        }
     1697        else
     1698        {
     1699            /* Add the release code: */
     1700            codes << ((idxCode & 0x7F) | 0x80);
     1701        }
     1702    }
     1703
     1704    keyboard().PutScancodes(codes);
     1705    AssertWrapperOk(keyboard());
     1706}
     1707
    16791708void UIMachineLogic::sltTakeSnapshot()
    16801709{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r70831 r73841  
    269269    void sltTypePrintScreen();
    270270    void sltTypeAltPrintScreen();
     271    void sltTypeHostKeyComboPressRelease(bool);
    271272    void sltTakeSnapshot();
    272273    void sltShowInformationDialog();
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