- Timestamp:
- May 22, 2019 2:24:22 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
r78661 r78663 19 19 #include <QApplication> 20 20 #include <QFile> 21 #include <QPainter> 22 #include <QStyle> 21 23 #include <QToolButton> 22 24 #include <QXmlStreamReader> … … 132 134 133 135 virtual void mousePressEvent(QMouseEvent *pEvent) /* override */; 136 virtual void paintEvent(QPaintEvent *pPaintEvent) /* override */; 134 137 135 138 private: … … 385 388 } 386 389 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 // } 390 void 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 } 400 417 401 418 void UISoftKeyboardKey::updateState(bool fPressed) … … 423 440 { 424 441 if (m_enmState == UIKeyState_NotPressed) 425 m_enmState = UIKeyState_ Pressed;442 m_enmState = UIKeyState_Locked; 426 443 else 427 444 m_enmState = UIKeyState_NotPressed; … … 442 459 443 460 if (m_enmState == UIKeyState_Pressed) 444 newColor = QColor(2 55, 0, 0);461 newColor = QColor(20, 255, 42); 445 462 else 446 newColor = QColor( 0, 255, 0);463 newColor = QColor(255, 7, 58); 447 464 448 465 setAutoFillBackground(true); 449 466 QPalette currentPalette = palette(); 450 467 currentPalette.setColor(QPalette::Button, newColor); 451 currentPalette.setColor(QPalette::ButtonText, newColor); 468 452 469 setPalette(currentPalette); 453 470 update();
Note:
See TracChangeset
for help on using the changeset viewer.