Changeset 35862 in vbox
- Timestamp:
- Feb 7, 2011 8:57:38 AM (14 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.cpp
r35730 r35862 18 18 */ 19 19 20 /* Global includes */ 21 #include <QShortcut> 22 20 23 /* Local includes */ 21 24 #include "UIGlobalSettingsInput.h" … … 27 30 /* Apply UI decorations: */ 28 31 Ui::UIGlobalSettingsInput::setupUi(this); 32 33 /* Set the new shortcut for the eraze-host-combo button: */ 34 m_pResetHostCombinationButton->setShortcut(QKeySequence()); 35 new QShortcut(QKeySequence(Qt::Key_Delete), m_pResetHostCombinationButton, SLOT(animateClick())); 36 new QShortcut(QKeySequence(Qt::Key_Backspace), m_pResetHostCombinationButton, SLOT(animateClick())); 29 37 30 38 /* Apply language settings: */ … … 84 92 { 85 93 setTabOrder(pWidget, m_pHostKeyEditor); 86 setTabOrder(m_pHostKeyEditor, m_pEnableAutoGrabCheckbox); 94 setTabOrder(m_pHostKeyEditor, m_pResetHostCombinationButton); 95 setTabOrder(m_pResetHostCombinationButton, m_pEnableAutoGrabCheckbox); 87 96 } 88 97 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.ui
r35730 r35862 66 66 </widget> 67 67 </item> 68 <item row="1" column="2"> 68 <item row="0" column="3"> 69 <widget class="UIResetButton" name="m_pResetHostCombinationButton"> 70 <property name="focusPolicy"> 71 <enum>Qt::StrongFocus</enum> 72 </property> 73 <property name="toolTip"> 74 <string>Reset host combination</string> 75 </property> 76 <property name="whatsThis"> 77 <string>Resets the key combination used as the host combination in the VM window.</string> 78 </property> 79 </widget> 80 </item> 81 <item row="1" column="2" colspan="2"> 69 82 <widget class="QCheckBox" name="m_pEnableAutoGrabCheckbox"> 70 83 <property name="whatsThis"> … … 76 89 </widget> 77 90 </item> 78 <item row="2" column="0" colspan=" 3">91 <item row="2" column="0" colspan="4"> 79 92 <spacer> 80 93 <property name="orientation"> … … 103 116 </customwidget> 104 117 </customwidgets> 105 <resources> 106 <include location="../VirtualBox1.qrc"/> 107 </resources> 118 <resources/> 108 119 <connections> 109 120 <connection> 110 <sender>m_pResetHost KeyButton</sender>121 <sender>m_pResetHostCombinationButton</sender> 111 122 <signal>clicked(bool)</signal> 112 123 <receiver>m_pHostKeyEditor</receiver> 113 <slot> clear()</slot>124 <slot>sltClear()</slot> 114 125 <hints> 115 126 <hint type="sourcelabel"> -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHotKeyEditor.cpp
r35821 r35862 390 390 } 391 391 392 void UIHotKeyEditor::sltClear() 393 { 394 m_shownKeys.clear(); 395 updateText(); 396 } 397 392 398 #ifdef Q_WS_WIN 393 399 bool UIHotKeyEditor::winEvent(MSG *pMsg, long* /* pResult */) … … 496 502 #endif /* Q_WS_MAC */ 497 503 504 void UIHotKeyEditor::focusInEvent(QFocusEvent *pEvent) 505 { 506 QLabel::focusInEvent(pEvent); 507 508 QPalette p = palette(); 509 p.setColor(QPalette::Active, QPalette::Foreground, p.color(QPalette::Active, QPalette::HighlightedText)); 510 p.setColor(QPalette::Active, QPalette::Background, p.color(QPalette::Active, QPalette::Highlight)); 511 setPalette(p); 512 } 513 514 void UIHotKeyEditor::focusOutEvent(QFocusEvent *pEvent) 515 { 516 QLabel::focusOutEvent(pEvent); 517 518 QPalette p = palette(); 519 p.setColor(QPalette::Active, QPalette::Foreground, p.color(QPalette::Active, QPalette::Text)); 520 p.setColor(QPalette::Active, QPalette::Background, p.color(QPalette::Active, QPalette::Base)); 521 setPalette(p); 522 } 523 524 void UIHotKeyEditor::paintEvent(QPaintEvent *pEvent) 525 { 526 if (hasFocus()) 527 { 528 QStylePainter painter(this); 529 QStyleOptionFocusRect option; 530 option.initFrom(this); 531 option.backgroundColor = palette().color(QPalette::Background); 532 option.rect = contentsRect(); 533 painter.drawPrimitive(QStyle::PE_FrameFocusRect, option); 534 } 535 QLabel::paintEvent(pEvent); 536 } 537 538 void UIHotKeyEditor::sltReleasePendingKeys() 539 { 540 /* Stop the timer, we process all pending keys at once: */ 541 m_pReleaseTimer->stop(); 542 /* Something to do? */ 543 if (!m_releasedKeys.isEmpty()) 544 { 545 /* Remove every key: */ 546 QSetIterator<int> iterator(m_releasedKeys); 547 while (iterator.hasNext()) 548 { 549 int iKeyCode = iterator.next(); 550 m_pressedKeys.remove(iKeyCode); 551 m_shownKeys.remove(iKeyCode); 552 } 553 m_releasedKeys.clear(); 554 if (m_pressedKeys.isEmpty()) 555 m_fStartNewSequence = true; 556 } 557 /* Make sure the user see what happens: */ 558 updateText(); 559 } 560 498 561 bool UIHotKeyEditor::processKeyEvent(int iKeyCode, bool fKeyPress) 499 562 { … … 549 612 } 550 613 551 void UIHotKeyEditor::keyPressEvent(QKeyEvent *pEvent)552 {553 switch (pEvent->key())554 {555 case Qt::Key_Delete:556 case Qt::Key_Backspace:557 m_shownKeys.clear();558 updateText();559 break;560 default:561 QWidget::keyPressEvent(pEvent);562 break;563 }564 }565 566 void UIHotKeyEditor::focusInEvent(QFocusEvent *pEvent)567 {568 QLabel::focusInEvent(pEvent);569 570 QPalette p = palette();571 p.setColor(QPalette::Active, QPalette::Foreground, p.color(QPalette::Active, QPalette::HighlightedText));572 p.setColor(QPalette::Active, QPalette::Background, p.color(QPalette::Active, QPalette::Highlight));573 setPalette(p);574 }575 576 void UIHotKeyEditor::focusOutEvent(QFocusEvent *pEvent)577 {578 QLabel::focusOutEvent(pEvent);579 580 QPalette p = palette();581 p.setColor(QPalette::Active, QPalette::Foreground, p.color(QPalette::Active, QPalette::Text));582 p.setColor(QPalette::Active, QPalette::Background, p.color(QPalette::Active, QPalette::Base));583 setPalette(p);584 }585 586 void UIHotKeyEditor::paintEvent(QPaintEvent *pEvent)587 {588 if (hasFocus())589 {590 QStylePainter painter(this);591 QStyleOptionFocusRect option;592 option.initFrom(this);593 option.backgroundColor = palette().color(QPalette::Background);594 option.rect = contentsRect();595 painter.drawPrimitive(QStyle::PE_FrameFocusRect, option);596 }597 QLabel::paintEvent(pEvent);598 }599 600 void UIHotKeyEditor::sltReleasePendingKeys()601 {602 /* Stop the timer, we process all pending keys at once: */603 m_pReleaseTimer->stop();604 /* Something to do? */605 if (!m_releasedKeys.isEmpty())606 {607 /* Remove every key: */608 QSetIterator<int> iterator(m_releasedKeys);609 while (iterator.hasNext())610 {611 int iKeyCode = iterator.next();612 m_pressedKeys.remove(iKeyCode);613 m_shownKeys.remove(iKeyCode);614 }615 m_releasedKeys.clear();616 if (m_pressedKeys.isEmpty())617 m_fStartNewSequence = true;618 }619 /* Make sure the user see what happens: */620 updateText();621 }622 623 614 void UIHotKeyEditor::updateText() 624 615 { -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHotKeyEditor.h
r35797 r35862 63 63 QSize minimumSizeHint() const; 64 64 65 public slots: 66 67 void sltClear(); 68 65 69 protected: 66 70 … … 76 80 #endif /* Q_WS_MAC */ 77 81 78 bool processKeyEvent(int iKeyCode, bool fKeyPress);79 80 void keyPressEvent(QKeyEvent *pEvent);81 82 void focusInEvent(QFocusEvent *pEvent); 82 83 void focusOutEvent(QFocusEvent *pEvent); … … 89 90 private: 90 91 92 bool processKeyEvent(int iKeyCode, bool fKeyPress); 91 93 void updateText(); 92 94
Note:
See TracChangeset
for help on using the changeset viewer.