Changeset 2185 in vbox for trunk/src/VBox/Frontends/VirtualBox/include/VBoxUtils.h
- Timestamp:
- Apr 18, 2007 2:48:10 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxUtils.h
r382 r2185 126 126 }; 127 127 128 /** 129 * Watches the given widget and makes sure the minimum widget size set by the layout 130 * manager does never get smaller than the previous minimum size set by the 131 * layout manager. This way, widgets with dynamic contents (i.e. text on some 132 * toggle buttons) will be able only to grow, never shrink, to avoid flicker 133 * during alternate contents updates (Pause -> Resume -> Pause -> ...). 134 * 135 * @todo not finished 136 */ 137 class QIConstraintKeeper : public QObject 138 { 139 Q_OBJECT 140 141 public: 142 143 QIConstraintKeeper (QWidget *aParent) : QObject (aParent) 144 { 145 aParent->setMinimumSize (aParent->size()); 146 aParent->installEventFilter (this); 147 } 148 149 private: 150 151 bool eventFilter (QObject *aObject, QEvent *aEvent) 152 { 153 if (aObject == parent() && aEvent->type() == QEvent::Resize) 154 { 155 QResizeEvent *ev = static_cast<QResizeEvent*> (aEvent); 156 QSize oldSize = ev->oldSize(); 157 QSize newSize = ev->size(); 158 int maxWidth = newSize.width() > oldSize.width() ? 159 newSize.width() : oldSize.width(); 160 int maxHeight = newSize.height() > oldSize.height() ? 161 newSize.height() : oldSize.height(); 162 if (maxWidth > oldSize.width() || maxHeight > oldSize.height()) 163 ((QWidget*)parent())->setMinimumSize (maxWidth, maxHeight); 164 } 165 return QObject::eventFilter (aObject, aEvent); 166 } 167 }; 168 128 169 #endif // __VBoxUtils_h__ 129 170
Note:
See TracChangeset
for help on using the changeset viewer.