Changeset 79588 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jul 8, 2019 10:10:41 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 131885
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
r79555 r79588 67 67 68 68 const int iMessageTimeout = 3000; 69 /** Lock key position are used to identify respective keys. */69 /** Key position are used to identify respective keys. */ 70 70 const int iCapsLockPosition = 30; 71 71 const int iNumLockPosition = 90; 72 72 const int iScrollLockPosition = 125; 73 const int iLeftShiftPosition = 44; 74 const int iRightShiftPosition = 57; 75 const int iLeftCtrlPosition = 58; 76 const int iRightCtrlPosition = 64; 77 const int iAltPosition = 60; 78 const int iAltGrPosition = 62; 79 73 80 74 81 const QString strSubDirectorName("keyboardLayouts"); 75 82 76 enum UIKeyState77 { 78 UIKeyState_NotPressed,79 UIKeyState_Pressed,80 UIKeyState_Locked,81 UIKeyState_Max83 enum KeyState 84 { 85 KeyState_NotPressed, 86 KeyState_Pressed, 87 KeyState_Locked, 88 KeyState_Max 82 89 }; 83 90 84 enum UIKeyType85 { 86 /** Can be in UIKeyState_NotPressed and UIKeyState_Pressed states. */87 UIKeyType_Ordinary,88 /** e.g. CapsLock, NumLock. Can be only in UIKeyState_NotPressed, UIKeyState_Locked */89 UIKeyType_Lock,91 enum KeyType 92 { 93 /** Can be in KeyState_NotPressed and KeyState_Pressed states. */ 94 KeyType_Ordinary, 95 /** e.g. CapsLock, NumLock. Can be only in KeyState_NotPressed, KeyState_Locked */ 96 KeyType_Lock, 90 97 /** e.g. Shift Can be in all 3 states*/ 91 UIKeyType_Modifier,92 UIKeyType_Max98 KeyType_Modifier, 99 KeyType_Max 93 100 }; 94 101 … … 331 338 int position() const; 332 339 333 void setType( UIKeyType enmType);334 UIKeyType type() const;340 void setType(KeyType enmType); 341 KeyType type() const; 335 342 336 343 void setIsNumPadKey(bool fIsNumPadKey); … … 343 350 344 351 void setParentWidget(UISoftKeyboardWidget* pParent); 345 UIKeyState state() const;352 KeyState state() const; 346 353 QVector<LONG> scanCodeWithPrefix() const; 347 354 … … 367 374 /** Stores the key polygon in local coordinates. */ 368 375 QPolygon m_polygon; 369 UIKeyType m_enmType;370 UIKeyState m_enmState;376 KeyType m_enmType; 377 KeyState m_enmState; 371 378 /** Key width as it is read from the xml file. */ 372 379 int m_iWidth; … … 535 542 float layoutAspectRatio(); 536 543 537 bool showOSMenuKeys() ;544 bool showOSMenuKeys() const; 538 545 void setShowOSMenuKeys(bool fShow); 539 546 540 bool showNumPad() ;547 bool showNumPad() const; 541 548 void setShowNumPad(bool fShow); 542 549 … … 1387 1394 1388 1395 UISoftKeyboardKey::UISoftKeyboardKey() 1389 : m_enmType( UIKeyType_Ordinary)1390 , m_enmState( UIKeyState_NotPressed)1396 : m_enmType(KeyType_Ordinary) 1397 , m_enmState(KeyState_NotPressed) 1391 1398 , m_iWidth(0) 1392 1399 , m_iHeight(0) … … 1476 1483 } 1477 1484 1478 void UISoftKeyboardKey::setType( UIKeyType enmType)1485 void UISoftKeyboardKey::setType(KeyType enmType) 1479 1486 { 1480 1487 m_enmType = enmType; 1481 1488 } 1482 1489 1483 UIKeyType UISoftKeyboardKey::type() const1490 KeyType UISoftKeyboardKey::type() const 1484 1491 { 1485 1492 return m_enmType; … … 1513 1520 } 1514 1521 1515 UIKeyState UISoftKeyboardKey::state() const1522 KeyState UISoftKeyboardKey::state() const 1516 1523 { 1517 1524 return m_enmState; … … 1526 1533 { 1527 1534 /* Lock key states are controlled by the event signals we get from the guest OS. See updateLockKeyState function: */ 1528 if (m_enmType != UIKeyType_Lock)1535 if (m_enmType != KeyType_Lock) 1529 1536 updateState(false); 1530 1537 } … … 1533 1540 { 1534 1541 /* Lock key states are controlled by the event signals we get from the guest OS. See updateLockKeyState function: */ 1535 if (m_enmType != UIKeyType_Lock)1542 if (m_enmType != KeyType_Lock) 1536 1543 updateState(true); 1537 1544 } … … 1571 1578 void UISoftKeyboardKey::updateState(bool fPressed) 1572 1579 { 1573 UIKeyState enmPreviousState = state();1574 if (m_enmType == UIKeyType_Modifier)1580 KeyState enmPreviousState = state(); 1581 if (m_enmType == KeyType_Modifier) 1575 1582 { 1576 1583 if (fPressed) 1577 1584 { 1578 if (m_enmState == UIKeyState_NotPressed)1579 m_enmState = UIKeyState_Pressed;1580 else if(m_enmState == UIKeyState_Pressed)1581 m_enmState = UIKeyState_Locked;1585 if (m_enmState == KeyState_NotPressed) 1586 m_enmState = KeyState_Pressed; 1587 else if(m_enmState == KeyState_Pressed) 1588 m_enmState = KeyState_Locked; 1582 1589 else 1583 m_enmState = UIKeyState_NotPressed;1590 m_enmState = KeyState_NotPressed; 1584 1591 } 1585 1592 else 1586 1593 { 1587 if(m_enmState == UIKeyState_Pressed)1588 m_enmState = UIKeyState_NotPressed;1594 if(m_enmState == KeyState_Pressed) 1595 m_enmState = KeyState_NotPressed; 1589 1596 } 1590 1597 } 1591 else if (m_enmType == UIKeyType_Lock) 1592 { 1593 m_enmState = fPressed ? UIKeyState_Locked : UIKeyState_NotPressed; 1594 // if (fPressed) 1595 // { 1596 // if (m_enmState == UIKeyState_NotPressed) 1597 // m_enmState = UIKeyState_Locked; 1598 // else 1599 // m_enmState = UIKeyState_NotPressed; 1600 // } 1601 } 1602 else if (m_enmType == UIKeyType_Ordinary) 1603 { 1604 if (m_enmState == UIKeyState_NotPressed) 1605 m_enmState = UIKeyState_Pressed; 1598 else if (m_enmType == KeyType_Lock) 1599 { 1600 m_enmState = fPressed ? KeyState_Locked : KeyState_NotPressed; 1601 } 1602 else if (m_enmType == KeyType_Ordinary) 1603 { 1604 if (m_enmState == KeyState_NotPressed) 1605 m_enmState = KeyState_Pressed; 1606 1606 else 1607 m_enmState = UIKeyState_NotPressed;1607 m_enmState = KeyState_NotPressed; 1608 1608 } 1609 1609 if (enmPreviousState != state() && m_pParentWidget) … … 1613 1613 void UISoftKeyboardKey::updateLockState(bool fLocked) 1614 1614 { 1615 if (m_enmType != UIKeyType_Lock)1616 return; 1617 if (fLocked && m_enmState == UIKeyState_Locked)1618 return; 1619 if (!fLocked && m_enmState == UIKeyState_NotPressed)1615 if (m_enmType != KeyType_Lock) 1616 return; 1617 if (fLocked && m_enmState == KeyState_Locked) 1618 return; 1619 if (!fLocked && m_enmState == KeyState_NotPressed) 1620 1620 return; 1621 1621 updateState(fLocked); … … 1868 1868 keyGeometry.height() - 2 * iMargin); 1869 1869 1870 1871 1870 painter.drawText(textRect, Qt::AlignLeft | Qt::AlignTop, strTopleftString); 1872 1871 painter.drawText(textRect, Qt::AlignLeft | Qt::AlignBottom, strBottomleftString); 1873 1874 1872 painter.drawText(textRect, Qt::AlignRight | Qt::AlignTop, strShiftAltGrCaption); 1875 1873 painter.drawText(textRect, Qt::AlignRight | Qt::AlignBottom, strAltGrCaption); 1874 1876 1875 #endif 1877 1876 } … … 2071 2070 m_pCurrentKeyboardLayout->drawTextInRect(key.position(), key.keyGeometry(), painter); 2072 2071 2073 if (key.type() != UIKeyType_Ordinary)2072 if (key.type() != KeyType_Ordinary) 2074 2073 { 2075 2074 QColor ledColor; 2076 if (key.state() == UIKeyState_NotPressed)2075 if (key.state() == KeyState_NotPressed) 2077 2076 ledColor = color(KeyboardColorType_Font); 2078 else if (key.state() == UIKeyState_Pressed)2077 else if (key.state() == KeyState_Pressed) 2079 2078 ledColor = QColor(0, 191, 204); 2080 2079 else … … 2249 2248 } 2250 2249 2251 bool UISoftKeyboardWidget::showOSMenuKeys() 2250 bool UISoftKeyboardWidget::showOSMenuKeys() const 2252 2251 { 2253 2252 return m_fShowOSMenuKeys; … … 2262 2261 } 2263 2262 2264 bool UISoftKeyboardWidget::showNumPad() 2263 bool UISoftKeyboardWidget::showNumPad() const 2265 2264 { 2266 2265 return m_fShowNumPad; … … 2297 2296 void UISoftKeyboardWidget::updateLockKeyStates(bool fCapsLockState, bool fNumLockState, bool fScrollLockState) 2298 2297 { 2299 UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->physicalLayoutUuid()); 2300 if (!pPhysicalLayout) 2301 return; 2302 pPhysicalLayout->updateLockKeyStates(fCapsLockState, fNumLockState, fScrollLockState); 2298 for (int i = 0; i < m_physicalLayouts.size(); ++i) 2299 m_physicalLayouts[i].updateLockKeyStates(fCapsLockState, fNumLockState, fScrollLockState); 2303 2300 update(); 2304 2301 } … … 2428 2425 if (!pKey) 2429 2426 return; 2430 if (pKey->type() == UIKeyType_Ordinary)2427 if (pKey->type() == KeyType_Ordinary) 2431 2428 pKey->release(); 2432 2429 /* We only send the scan codes of Ordinary keys: */ 2433 if (pKey->type() == UIKeyType_Modifier)2430 if (pKey->type() == KeyType_Modifier) 2434 2431 return; 2435 2432 … … 2458 2455 pKey->press(); 2459 2456 2460 if (pKey->type() == UIKeyType_Modifier)2457 if (pKey->type() == KeyType_Modifier) 2461 2458 return; 2462 2459 … … 2481 2478 if (!pKey) 2482 2479 return; 2483 if (pKey->type() == UIKeyType_Modifier)2484 { 2485 if (pKey->state() == UIKeyState_NotPressed)2480 if (pKey->type() == KeyType_Modifier) 2481 { 2482 if (pKey->state() == KeyState_NotPressed) 2486 2483 m_pressedModifiers.removeOne(pKey); 2487 2484 else … … 2916 2913 QString strType = m_xmlReader.readElementText(); 2917 2914 if (strType == "modifier") 2918 key.setType( UIKeyType_Modifier);2915 key.setType(KeyType_Modifier); 2919 2916 else if (strType == "lock") 2920 key.setType( UIKeyType_Lock);2917 key.setType(KeyType_Lock); 2921 2918 } 2922 2919 else if (m_xmlReader.name() == "osmenukey") … … 3298 3295 QSpacerItem *pSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding); 3299 3296 if (pSpacer) 3300 pSettingsLayout->addItem(pSpacer, 5, 0);3297 pSettingsLayout->addItem(pSpacer, 6, 0); 3301 3298 3302 3299 setLayout(pSettingsLayout); … … 3646 3643 void UISoftKeyboard::configure() 3647 3644 { 3648 setWindowIcon(UIIconPool::iconSet Full(":/vm_show_logs_32px.png", ":/vm_show_logs_16px.png"));3645 setWindowIcon(UIIconPool::iconSet(":/keyboard_24px.png")); 3649 3646 if (m_pKeyboardWidget && m_pSettingsWidget) 3650 3647 { … … 3661 3658 updateLayoutSelectorList(); 3662 3659 if (m_pKeyboardWidget && m_pKeyboardWidget->currentLayout() && m_pLayoutSelector) 3660 { 3663 3661 m_pLayoutSelector->setCurrentLayout(m_pKeyboardWidget->currentLayout()->uid()); 3662 m_pLayoutSelector->setCurrentLayoutIsEditable(m_pKeyboardWidget->currentLayout()->editable()); 3663 } 3664 3664 } 3665 3665
Note:
See TracChangeset
for help on using the changeset viewer.