VirtualBox

Changeset 9674 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jun 13, 2008 8:48:50 AM (17 years ago)
Author:
vboxsync
Message:

FE/Qt4: Use QIDialogButtonBox and fixed a bug for the warning label.

Location:
trunk/src/VBox/Frontends/VirtualBox4
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxVMSettingsDlg.h

    r9654 r9674  
    2929class QIWidgetValidator;
    3030class VBoxMediaComboBox;
     31class VBoxWarnIconLabel;
     32
    3133class QTimer;
    3234class QWidgetStack;
     
    9395    CMachine mMachine;
    9496    QString  mWarnString;
     97    VBoxWarnIconLabel *mWarnIconLabel;
    9598
    9699    /* Flags */
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsDlg.cpp

    r9654 r9674  
    101101
    102102
     103class VBoxWarnIconLabel: public QWidget
     104{
     105public:
     106    VBoxWarnIconLabel (QWidget *aParent = NULL)
     107      : QWidget (aParent)
     108    {
     109        QHBoxLayout *layout = new QHBoxLayout (this);
     110        VBoxGlobal::setLayoutMargin (layout, 0);
     111        layout->addWidget (&mIcon);
     112        layout->addWidget (&mLabel);
     113    }
     114    void setWarningPixmap (const QPixmap& aPixmap) { mIcon.setPixmap (aPixmap); }
     115    void setWarningText (const QString& aText) { mLabel.setText (aText); }
     116
     117private:
     118    QLabel mIcon;
     119    QLabel mLabel;
     120};
     121
    103122VBoxVMSettingsDlg::VBoxVMSettingsDlg (QWidget *aParent,
    104123                                      const QString &aCategory,
     
    114133    Ui::VBoxVMSettingsDlg::setupUi (this);
    115134
     135    mWarnIconLabel = new VBoxWarnIconLabel();
     136    mWarnIconLabel->setWarningText (tr ("Invalid settings detected"));
     137    mButtonBox->button (QDialogButtonBox::Ok)->setWhatsThis (tr ("Accepts (saves) changes and closes the dialog."));
     138    mButtonBox->button (QDialogButtonBox::Cancel)->setWhatsThis (tr ("Cancels changes and closes the dialog."));
     139    mButtonBox->button (QDialogButtonBox::Help)->setWhatsThis (tr ("Displays the dialog help."));
     140
    116141    /* Setup warning icon */
    117142    QIcon icon = vboxGlobal().standardIcon (QStyle::SP_MessageBoxWarning, this);
    118143    if (!icon.isNull())
    119         mLbWarnIcon->setPixmap (icon.pixmap (16, 16));
     144        mWarnIconLabel->setWarningPixmap (icon.pixmap (16, 16));
     145
     146    mButtonBox->addExtraWidget (mWarnIconLabel);
    120147
    121148    /* Page title font is derived from the system font */
     
    144171    /* Common connections */
    145172
    146     connect (mBtnOk, SIGNAL (clicked()), this, SLOT (accept()));
    147     connect (mBtnCancel, SIGNAL (clicked()), this, SLOT (reject()));
    148     connect (mBtnHelp, SIGNAL (clicked()), &vboxProblem(), SLOT (showHelpHelpDialog()));
     173    connect (mButtonBox, SIGNAL (accepted()), this, SLOT (accept()));
     174    connect (mButtonBox, SIGNAL (rejected()), this, SLOT (reject()));
     175    connect (mButtonBox, SIGNAL (helpRequested()), &vboxProblem(), SLOT (showHelpHelpDialog()));
    149176    connect (mTwSelector, SIGNAL (currentItemChanged (QTreeWidgetItem*, QTreeWidgetItem*)),
    150177             this, SLOT (settingsGroupChanged (QTreeWidgetItem *, QTreeWidgetItem*)));
     
    364391    {
    365392        mValid = newValid;
    366         mBtnOk->setEnabled (mValid);
    367         mLbWarnText->setHidden (mValid);
    368         mLbWarnIcon->setHidden (mValid);
     393        mButtonBox->button (QDialogButtonBox::Ok)->setEnabled (mValid);
     394        mWarnIconLabel->setVisible (!mValid);
    369395    }
    370396}
  • trunk/src/VBox/Frontends/VirtualBox4/ui/VBoxVMSettingsDlg.ui

    r9654 r9674  
    348348   </item>
    349349   <item row="3" column="0" colspan="2" >
    350     <layout class="QHBoxLayout" >
    351      <item>
    352       <widget class="QPushButton" name="mBtnHelp" >
    353        <property name="whatsThis" >
    354         <string>Displays the dialog help.</string>
    355        </property>
    356        <property name="text" >
    357         <string>Help</string>
    358        </property>
    359        <property name="shortcut" >
    360         <string>F1</string>
    361        </property>
    362       </widget>
    363      </item>
    364      <item>
    365       <spacer>
    366        <property name="orientation" >
    367         <enum>Qt::Horizontal</enum>
    368        </property>
    369        <property name="sizeHint" >
    370         <size>
    371          <width>40</width>
    372          <height>20</height>
    373         </size>
    374        </property>
    375       </spacer>
    376      </item>
    377      <item>
    378       <widget class="QLabel" name="mLbWarnIcon" >
    379        <property name="maximumSize" >
    380         <size>
    381          <width>16</width>
    382          <height>16</height>
    383         </size>
    384        </property>
    385       </widget>
    386      </item>
    387      <item>
    388       <widget class="QLabel" name="mLbWarnText" >
    389        <property name="text" >
    390         <string>Invalid settings detected</string>
    391        </property>
    392       </widget>
    393      </item>
    394      <item>
    395       <spacer>
    396        <property name="orientation" >
    397         <enum>Qt::Horizontal</enum>
    398        </property>
    399        <property name="sizeHint" >
    400         <size>
    401          <width>40</width>
    402          <height>20</height>
    403         </size>
    404        </property>
    405       </spacer>
    406      </item>
    407      <item>
    408       <widget class="QPushButton" name="mBtnOk" >
    409        <property name="whatsThis" >
    410         <string>Accepts (saves) changes and closes the dialog.</string>
    411        </property>
    412        <property name="text" >
    413         <string>&amp;Ok</string>
    414        </property>
    415        <property name="default" >
    416         <bool>true</bool>
    417        </property>
    418       </widget>
    419      </item>
    420      <item>
    421       <widget class="QPushButton" name="mBtnCancel" >
    422        <property name="whatsThis" >
    423         <string>Cancels changes and closes the dialog.</string>
    424        </property>
    425        <property name="text" >
    426         <string>Cancel</string>
    427        </property>
    428       </widget>
    429      </item>
    430     </layout>
     350    <widget class="QIDialogButtonBox" name="mButtonBox" >
     351     <property name="standardButtons" >
     352      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
     353     </property>
     354    </widget>
    431355   </item>
    432356  </layout>
    433357 </widget>
     358 <customwidgets>
     359  <customwidget>
     360   <class>QIDialogButtonBox</class>
     361   <extends>QDialogButtonBox</extends>
     362   <header>QIDialogButtonBox.h</header>
     363  </customwidget>
     364 </customwidgets>
    434365 <resources>
    435366  <include location="../VirtualBox.qrc" />
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