VirtualBox

Changeset 35862 in vbox


Ignore:
Timestamp:
Feb 7, 2011 8:57:38 AM (14 years ago)
Author:
vboxsync
Message:

FE/Qt: 5245: GUI support for complex host-key combinations: Erase-button restored, shortcut set to Backspace and Delete keys.

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  
    1818 */
    1919
     20/* Global includes */
     21#include <QShortcut>
     22
    2023/* Local includes */
    2124#include "UIGlobalSettingsInput.h"
     
    2730    /* Apply UI decorations: */
    2831    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()));
    2937
    3038    /* Apply language settings: */
     
    8492{
    8593    setTabOrder(pWidget, m_pHostKeyEditor);
    86     setTabOrder(m_pHostKeyEditor, m_pEnableAutoGrabCheckbox);
     94    setTabOrder(m_pHostKeyEditor, m_pResetHostCombinationButton);
     95    setTabOrder(m_pResetHostCombinationButton, m_pEnableAutoGrabCheckbox);
    8796}
    8897
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.ui

    r35730 r35862  
    6666    </widget>
    6767   </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">
    6982    <widget class="QCheckBox" name="m_pEnableAutoGrabCheckbox">
    7083     <property name="whatsThis">
     
    7689    </widget>
    7790   </item>
    78    <item row="2" column="0" colspan="3">
     91   <item row="2" column="0" colspan="4">
    7992    <spacer>
    8093     <property name="orientation">
     
    103116  </customwidget>
    104117 </customwidgets>
    105  <resources>
    106   <include location="../VirtualBox1.qrc"/>
    107  </resources>
     118 <resources/>
    108119 <connections>
    109120  <connection>
    110    <sender>m_pResetHostKeyButton</sender>
     121   <sender>m_pResetHostCombinationButton</sender>
    111122   <signal>clicked(bool)</signal>
    112123   <receiver>m_pHostKeyEditor</receiver>
    113    <slot>clear()</slot>
     124   <slot>sltClear()</slot>
    114125   <hints>
    115126    <hint type="sourcelabel">
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHotKeyEditor.cpp

    r35821 r35862  
    390390}
    391391
     392void UIHotKeyEditor::sltClear()
     393{
     394    m_shownKeys.clear();
     395    updateText();
     396}
     397
    392398#ifdef Q_WS_WIN
    393399bool UIHotKeyEditor::winEvent(MSG *pMsg, long* /* pResult */)
     
    496502#endif /* Q_WS_MAC */
    497503
     504void 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
     514void 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
     524void 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
     538void 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
    498561bool UIHotKeyEditor::processKeyEvent(int iKeyCode, bool fKeyPress)
    499562{
     
    549612}
    550613
    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 
    623614void UIHotKeyEditor::updateText()
    624615{
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHotKeyEditor.h

    r35797 r35862  
    6363    QSize minimumSizeHint() const;
    6464
     65public slots:
     66
     67    void sltClear();
     68
    6569protected:
    6670
     
    7680#endif /* Q_WS_MAC */
    7781
    78     bool processKeyEvent(int iKeyCode, bool fKeyPress);
    79 
    80     void keyPressEvent(QKeyEvent *pEvent);
    8182    void focusInEvent(QFocusEvent *pEvent);
    8283    void focusOutEvent(QFocusEvent *pEvent);
     
    8990private:
    9091
     92    bool processKeyEvent(int iKeyCode, bool fKeyPress);
    9193    void updateText();
    9294
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