VirtualBox

Ignore:
Timestamp:
Feb 18, 2009 3:40:21 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
43037
Message:

FE/Qt4: 3627: Shorten error dialogs - plus/minus (expand/collapse) button handlers added.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/QIMessageBox.h

    r16802 r16913  
    5757public:
    5858
     59    enum ToggleType
     60    {
     61        Toggle = 0,
     62        CollapsOnly,
     63        ExpandOnly
     64    };
     65
    5966    QIArrowSplitter (QWidget *aParent = 0);
    6067
     
    6370public slots:
    6471
    65     void toggleWidget();
     72    void toggleWidget (ToggleType aType = Toggle);
    6673
    6774private:
     75
     76    bool eventFilter (QObject *aObject, QEvent *aEvent);
    6877
    6978    QVBoxLayout *mMainLayout;
  • trunk/src/VBox/Frontends/VirtualBox/src/QIMessageBox.cpp

    r16869 r16913  
    4646{
    4747    VBoxGlobal::setLayoutMargin (mMainLayout, 0);
     48    qApp->installEventFilter (this);
    4849}
    4950
     
    7475}
    7576
    76 void QIArrowSplitter::toggleWidget()
     77void QIArrowSplitter::toggleWidget (ToggleType aType)
    7778{
    7879    QToolButton *arrowButton = qobject_cast <QToolButton*> (sender());
     
    8586            QWidget *relatedWidget = mWidgetsList [mButtonsList.indexOf (itemButton)];
    8687            Assert (relatedWidget);
    87             relatedWidget->setVisible (!relatedWidget->isVisible());
    88             itemButton->setIcon (VBoxGlobal::iconSet (relatedWidget->isVisible() ?
    89                                  ":/arrow_down_10px.png" : ":/arrow_right_10px.png"));
     88            if ((relatedWidget->isVisible() && aType != ExpandOnly) ||
     89                (!relatedWidget->isVisible() && aType != CollapsOnly))
     90            {
     91                relatedWidget->setVisible (!relatedWidget->isVisible());
     92                itemButton->setIcon (VBoxGlobal::iconSet (relatedWidget->isVisible() ?
     93                                     ":/arrow_down_10px.png" : ":/arrow_right_10px.png"));
     94            }
    9095        }
    9196    }
     
    113118    window()->setFixedSize (window()->minimumSizeHint());
    114119#endif
     120}
     121
     122bool QIArrowSplitter::eventFilter (QObject *aObject, QEvent *aEvent)
     123{
     124    if (!aObject->isWidgetType())
     125        return QWidget::eventFilter (aObject, aEvent);
     126
     127    QWidget *widget = qobject_cast <QWidget*> (aObject);
     128    if (widget->window() != window())
     129        return QWidget::eventFilter (aObject, aEvent);
     130
     131    /* Process some keyboard events */
     132    if (aEvent->type() == QEvent::KeyPress)
     133    {
     134        QKeyEvent *kEvent = static_cast <QKeyEvent*> (aEvent);
     135        QToolButton *arrowButton = qobject_cast <QToolButton*> (QApplication::focusWidget());
     136        int slot = arrowButton ? mButtonsList.indexOf (arrowButton) : -1;
     137        switch (kEvent->key())
     138        {
     139            case Qt::Key_Plus:
     140            {
     141                if (slot != -1 && !mWidgetsList [slot]->isVisible())
     142                    arrowButton->animateClick();
     143                else
     144                    toggleWidget (ExpandOnly);
     145                break;
     146            }
     147            case Qt::Key_Minus:
     148            {
     149                if (slot != -1 && mWidgetsList [slot]->isVisible())
     150                    arrowButton->animateClick();
     151                else
     152                    toggleWidget (CollapsOnly);
     153                break;
     154            }
     155        }
     156    }
     157
     158    return QWidget::eventFilter (aObject, aEvent);
    115159}
    116160
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette