VirtualBox

Changeset 78663 in vbox for trunk/src


Ignore:
Timestamp:
May 22, 2019 2:24:22 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6143. Adding a small led like indicator to modifiers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp

    r78661 r78663  
    1919#include <QApplication>
    2020#include <QFile>
     21#include <QPainter>
     22#include <QStyle>
    2123#include <QToolButton>
    2224#include <QXmlStreamReader>
     
    132134
    133135    virtual void mousePressEvent(QMouseEvent *pEvent) /* override */;
     136    virtual void paintEvent(QPaintEvent *pPaintEvent) /* override */;
    134137
    135138private:
     
    385388}
    386389
    387 // void UISoftKeyboardKey::mouseReleaseEvent(QMouseEvent *pEvent)
    388 // {
    389 //     if (m_enmType == UIKeyType_SingleState)
    390 //     {
    391 //         QToolButton::mouseReleaseEvent(pEvent);
    392 //         setState(UIKeyState_NotPressed)
    393 //     }
    394 //     else
    395 //     {
    396 //         pEvent->accept();
    397 //     }
    398 
    399 // }
     390void UISoftKeyboardKey::paintEvent(QPaintEvent *pEvent)
     391{
     392    QToolButton::paintEvent(pEvent);
     393
     394    if (m_enmType == UIKeyType_SingleState)
     395        return;
     396
     397
     398    QPainter painter(this);
     399    painter.setRenderHint(QPainter::Antialiasing, true);
     400
     401    painter.setPen(QPen(QColor(50, 50, 50), 0.2f));
     402    if (m_enmState == UIKeyState_NotPressed)
     403        painter.setBrush(QColor(100, 100, 100));
     404    else if (m_enmState == UIKeyState_Pressed)
     405        painter.setBrush(QColor(20, 255, 42));
     406    else
     407        painter.setBrush(QColor(255, 7, 58));
     408
     409    int unitSize = qApp->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
     410
     411    float fRadius = 1.1 * unitSize;
     412    float fSpace = unitSize;
     413    QRectF rectangle(fSpace, fSpace, fRadius, fRadius);
     414
     415    painter.drawEllipse(rectangle);
     416}
    400417
    401418void UISoftKeyboardKey::updateState(bool fPressed)
     
    423440        {
    424441            if (m_enmState == UIKeyState_NotPressed)
    425                  m_enmState = UIKeyState_Pressed;
     442                 m_enmState = UIKeyState_Locked;
    426443            else
    427444                m_enmState = UIKeyState_NotPressed;
     
    442459
    443460     if (m_enmState == UIKeyState_Pressed)
    444          newColor = QColor(255, 0, 0);
     461         newColor = QColor(20, 255, 42);
    445462     else
    446          newColor = QColor(0, 255, 0);
     463         newColor = QColor(255, 7, 58);
    447464
    448465     setAutoFillBackground(true);
    449466     QPalette currentPalette = palette();
    450467     currentPalette.setColor(QPalette::Button, newColor);
    451      currentPalette.setColor(QPalette::ButtonText, newColor);
     468
    452469     setPalette(currentPalette);
    453470     update();
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