- Timestamp:
- Apr 18, 2007 2:48:10 PM (18 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h
r2170 r2185 134 134 }; 135 135 136 class QIConstrainKeeper : public QObject137 {138 Q_OBJECT139 140 public:141 142 QIConstrainKeeper (QWidget*);143 144 private:145 146 bool eventFilter (QObject*, QEvent*);147 };148 149 136 // VBoxGlobal 150 137 //////////////////////////////////////////////////////////////////////////////// -
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 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r2178 r2185 470 470 471 471 #endif /* Q_WS_WIN */ 472 473 // QIConstrainKeeper474 ////////////////////////////////////////////////////////////////////////////////475 476 QIConstrainKeeper::QIConstrainKeeper (QWidget *aParent) : QObject (aParent)477 {478 aParent->setMinimumSize (aParent->size());479 aParent->installEventFilter (this);480 }481 482 bool QIConstrainKeeper::eventFilter (QObject *aObject, QEvent *aEvent)483 {484 if (aObject == parent() && aEvent->type() == QEvent::Resize)485 {486 QResizeEvent *ev = static_cast<QResizeEvent*> (aEvent);487 QSize oldSize = ev->oldSize();488 QSize newSize = ev->size();489 int maxWidth = newSize.width() > oldSize.width() ?490 newSize.width() : oldSize.width();491 int maxHeight = newSize.height() > oldSize.height() ?492 newSize.height() : oldSize.height();493 if (maxWidth > oldSize.width() || maxHeight > oldSize.height())494 ((QWidget*)parent())->setMinimumSize (maxWidth, maxHeight);495 }496 return QObject::eventFilter (aObject, aEvent);497 }498 472 499 473 // VBoxGlobal -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp
r2170 r2185 982 982 case QEvent::Show: 983 983 { 984 /// @todo improve 985 #if 0 984 986 /* Constrain StartVM button size */ 985 987 QObjectList *list = queryList ("QToolButton", … … 988 990 static_cast<QToolButton*> (list->first()) : 0; 989 991 if (actionButton) 990 new QIConstrainKeeper (actionButton); 992 new QIConstraintKeeper (actionButton); 993 #endif 991 994 break; 992 995 } -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui
r2175 r2185 2805 2805 <variable access="private">VBoxMediaComboBox *cbISOFloppy;</variable> 2806 2806 <variable access="private">VBoxUSBMenu *usbDevicesMenu;</variable> 2807 <variable access="private">Q Label *whatsThisLabel;</variable>2807 <variable access="private">QIRichLabel *whatsThisLabel;</variable> 2808 2808 <variable access="private">BootItemsList *tblBootOrder;</variable> 2809 2809 </variables> … … 2841 2841 <slot>cdMediaChanged()</slot> 2842 2842 <slot>fdMediaChanged()</slot> 2843 <slot>processAdjustSize()</slot> 2843 2844 <slot>updateInterfaces( QWidget* )</slot> 2844 2845 <slot>networkPageUpdate( QWidget* )</slot> -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui.h
r2175 r2185 404 404 whatsThisCandidate = NULL; 405 405 406 whatsThisLabel = new QLabel (this, "whatsThisLabel"); 407 whatsThisLabel->setTextFormat (Qt::RichText); 406 whatsThisLabel = new QIRichLabel (this, "whatsThisLabel"); 408 407 VBoxVMSettingsDlgLayout->addWidget (whatsThisLabel, 2, 1); 409 408 410 409 whatsThisLabel->setFocusPolicy (QWidget::NoFocus); 411 whatsThisLabel->setSizePolicy (QSizePolicy::Expanding, QSizePolicy:: Expanding);410 whatsThisLabel->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Fixed); 412 411 whatsThisLabel->setBackgroundMode (QLabel::PaletteMidlight); 413 412 whatsThisLabel->setFrameShape (QLabel::Box); … … 419 418 QLabel::AlignTop)); 420 419 421 whatsThisLabel->set MinimumHeight (whatsThisLabel->frameWidth() * 2 +420 whatsThisLabel->setFixedHeight (whatsThisLabel->frameWidth() * 2 + 422 421 6 /* seems that RichText adds some margin */ + 423 422 whatsThisLabel->fontMetrics().lineSpacing() * 3); … … 425 424 6 /* seems that RichText adds some margin */ + 426 425 whatsThisLabel->fontMetrics().width ('m') * 40); 426 /// @todo possibly, remove after QIConstraintKeeper is properly done 427 connect (whatsThisLabel, SIGNAL (textChanged()), this, SLOT (processAdjustSize())); 427 428 428 429 /* … … 799 800 VBoxGlobal::centerWidget (this, parentWidget()); 800 801 801 new QIConstrainKeeper (whatsThisLabel); 802 } 802 /// @todo improve 803 #if 0 804 new QIConstraintKeeper (whatsThisLabel); 805 #endif 806 } 807 808 /// @todo possibly, remove after QIConstraintKeeper is properly done 809 /// (should be at least possible to move this functionality into it) 810 void VBoxVMSettingsDlg::processAdjustSize() 811 { 812 int newHeight = minimumSize().height(); 813 int oldHeight = height(); 814 if (newHeight > oldHeight) 815 resize (minimumSize()); 816 } 803 817 804 818 void VBoxVMSettingsDlg::updateShortcuts()
Note:
See TracChangeset
for help on using the changeset viewer.