Changeset 16913 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Feb 18, 2009 3:40:21 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 43037
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/QIMessageBox.h
r16802 r16913 57 57 public: 58 58 59 enum ToggleType 60 { 61 Toggle = 0, 62 CollapsOnly, 63 ExpandOnly 64 }; 65 59 66 QIArrowSplitter (QWidget *aParent = 0); 60 67 … … 63 70 public slots: 64 71 65 void toggleWidget ();72 void toggleWidget (ToggleType aType = Toggle); 66 73 67 74 private: 75 76 bool eventFilter (QObject *aObject, QEvent *aEvent); 68 77 69 78 QVBoxLayout *mMainLayout; -
trunk/src/VBox/Frontends/VirtualBox/src/QIMessageBox.cpp
r16869 r16913 46 46 { 47 47 VBoxGlobal::setLayoutMargin (mMainLayout, 0); 48 qApp->installEventFilter (this); 48 49 } 49 50 … … 74 75 } 75 76 76 void QIArrowSplitter::toggleWidget ()77 void QIArrowSplitter::toggleWidget (ToggleType aType) 77 78 { 78 79 QToolButton *arrowButton = qobject_cast <QToolButton*> (sender()); … … 85 86 QWidget *relatedWidget = mWidgetsList [mButtonsList.indexOf (itemButton)]; 86 87 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 } 90 95 } 91 96 } … … 113 118 window()->setFixedSize (window()->minimumSizeHint()); 114 119 #endif 120 } 121 122 bool 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); 115 159 } 116 160
Note:
See TracChangeset
for help on using the changeset viewer.