VirtualBox

Changeset 2170 in vbox for trunk


Ignore:
Timestamp:
Apr 18, 2007 1:09:20 PM (18 years ago)
Author:
vboxsync
Message:

1934: Never decrease size in the layout:

  1. Created the proposed QIConstrainKeeper for using it for individual child widgets with dynamic contents.
  2. QIConstrainKeeper used for the horizontal size of the Start/Show button, to have it's minimum size fixed at it's maximum value.
Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
5 edited

Legend:

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

    r2044 r2170  
    134134};
    135135
     136class QIConstrainKeeper : public QObject
     137{
     138    Q_OBJECT
     139
     140public:
     141
     142    QIConstrainKeeper (QWidget*);
     143
     144private:
     145
     146    bool eventFilter (QObject*, QEvent*);
     147};
     148
    136149// VBoxGlobal
    137150////////////////////////////////////////////////////////////////////////////////
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r2158 r2170  
    470470
    471471#endif /* Q_WS_WIN */
     472
     473// QIConstrainKeeper
     474////////////////////////////////////////////////////////////////////////////////
     475
     476QIConstrainKeeper::QIConstrainKeeper (QWidget *aParent) : QObject (aParent)
     477{
     478    aParent->setMinimumSize (aParent->size());
     479    aParent->installEventFilter (this);
     480}
     481
     482bool 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}
    472498
    473499// VBoxGlobal
     
    19451971    else
    19461972        loadOk = false;
    1947    
     1973
    19481974    if (loadOk)
    19491975        sLoadedLangId = selectedLangId;
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp

    r2139 r2170  
    980980            break;
    981981        }
     982        case QEvent::Show:
     983        {
     984            /* Constrain StartVM button size */
     985            QObjectList *list = queryList ("QToolButton",
     986                QString (vmStartAction->name()) + "_action_button");
     987            QToolButton *actionButton = list->first() ?
     988                static_cast<QToolButton*> (list->first()) : 0;
     989            if (actionButton)
     990                new QIConstrainKeeper (actionButton);
     991            break;
     992        }
    982993
    983994        default:
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui

    r1925 r2170  
    28412841    <slot>cdMediaChanged()</slot>
    28422842    <slot>fdMediaChanged()</slot>
    2843     <slot>processAdjustSize()</slot>
    28442843    <slot>updateInterfaces( QWidget* )</slot>
    28452844    <slot>networkPageUpdate( QWidget* )</slot>
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui.h

    r2154 r2170  
    424424                                     6 /* seems that RichText adds some margin */ +
    425425                                     whatsThisLabel->fontMetrics().width ('m') * 40);
    426     connect (whatsThisLabel, SIGNAL (textChanged()), this, SLOT (processAdjustSize()));
    427426
    428427    /*
     
    799798    VBoxGlobal::centerWidget (this, parentWidget());
    800799}
    801 
    802 void VBoxVMSettingsDlg::processAdjustSize()
    803 {
    804     int newHeight = minimumSize().height();
    805     int oldHeight = height();
    806     if (newHeight > oldHeight)
    807         resize (minimumSize());
    808 }
    809 
    810800
    811801void VBoxVMSettingsDlg::updateShortcuts()
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