VirtualBox

Changeset 8369 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 24, 2008 4:11:40 PM (17 years ago)
Author:
vboxsync
Message:

FE/Qt4: QIMessageBox changes:

  • QIMessageBox uses QIDialog: So all warnings/errors/... are sheets on Mac OS X now.
  • use QDialogButtonBox for the bottom buttons
  • replaced some deprecated window flags
Location:
trunk/src/VBox/Frontends/VirtualBox4
Files:
2 edited

Legend:

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

    r8170 r8369  
    66
    77/*
    8  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     8 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2424#define __QIMessageBox_h__
    2525
     26#include "QIDialog.h"
     27
    2628/* Qt includes */
    27 #include <QDialog>
    2829#include <QMessageBox>
    2930#include <QCheckBox>
     
    3435class QPushButton;
    3536class QSpacerItem;
     37class QDialogButtonBox;
    3638
    37 class QIMessageBox : public QDialog
     39class QIMessageBox : public QIDialog
    3840{
    3941    Q_OBJECT
     
    6466    QIMessageBox (const QString &aCaption, const QString &aText,
    6567                  Icon aIcon, int aButton0, int aButton1 = 0, int aButton2 = 0,
    66                   QWidget *aParent = 0, const char *aName = 0, bool aModal = TRUE,
    67                   Qt::WFlags aFlags = Qt::WStyle_DialogBorder);
     68                  QWidget *aParent = 0, const char *aName = 0, bool aModal = TRUE);
    6869
    6970    QString buttonText (int aButton) const;
     
    108109    QTextEdit *mDetailsText;
    109110    QSpacerItem *mSpacer;
     111    QDialogButtonBox *mButtonBox;
    110112};
    111113
  • trunk/src/VBox/Frontends/VirtualBox4/src/QIMessageBox.cpp

    r8170 r8369  
    66
    77/*
    8  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     8 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3131#include <QPushButton>
    3232#include <QLabel>
     33#include <QDialogButtonBox>
    3334
    3435/** @class QIMessageBox
     
    4041
    4142/**
    42  *  This constructor is equivalent to
    43  *  QMessageBox::QMessageBox (const QString &, const QString &, Icon,
    44  *      int, int, int, QWidget *, const char *, bool, WFlags).
    4543 *  See QMessageBox for details.
    4644 */
    4745QIMessageBox::QIMessageBox (const QString &aCaption, const QString &aText,
    4846                            Icon aIcon, int aButton0, int aButton1, int aButton2,
    49                             QWidget *aParent, const char *aName, bool aModal,
    50                             Qt::WFlags aFlags)
    51     : QDialog (aParent, aName, aModal,
    52                aFlags | Qt::WStyle_Customize | Qt::WStyle_NormalBorder |
    53                         Qt::WStyle_Title | Qt::WStyle_SysMenu)
     47                            QWidget *aParent, const char *aName, bool aModal)
     48    : QIDialog (aParent,
     49                Qt::Window | Qt::Sheet |
     50                Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
    5451{
    5552    setWindowTitle (aCaption);
     53    /* Necessary to later find some of the message boxes */
     54    setObjectName (aName);
     55    setModal (aModal);
    5656
    5757    mButton0 = aButton0;
     
    123123    layout->addItem (mSpacer);
    124124
    125     QHBoxLayout *buttonsHLayout = new QHBoxLayout();
    126     buttonsHLayout->setSpacing (5);
    127     layout->addLayout (buttonsHLayout);
     125    mButtonBox = new QDialogButtonBox;
     126    mButtonBox->setCenterButtons (true);
     127    layout->addWidget (mButtonBox);
    128128
    129129    mButtonEsc = 0;
     
    131131    mButton0PB = createButton (aButton0);
    132132    if (mButton0PB)
    133     {
    134         buttonsHLayout->addWidget (mButton0PB);
    135133        connect (mButton0PB, SIGNAL (clicked()), SLOT (done0()));
    136     }
    137134    mButton1PB = createButton (aButton1);
    138135    if (mButton1PB)
    139     {
    140         buttonsHLayout->addWidget (mButton1PB);
    141136        connect (mButton1PB, SIGNAL (clicked()), SLOT (done1()));
    142     }
    143137    mButton2PB = createButton (aButton2);
    144138    if (mButton2PB)
    145     {
    146         buttonsHLayout->addWidget (mButton2PB);
    147139        connect (mButton2PB, SIGNAL (clicked()), SLOT (done2()));
    148     }
    149 
    150     buttonsHLayout->setAlignment (Qt::AlignHCenter);
    151140
    152141    /* this call is a must -- it initializes mFlagCB and mSpacer */
    153142    setDetailsShown (false);
     143
     144    /* Set fixed size */
     145    setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
    154146}
    155147
     
    241233
    242234    QString text;
     235    QDialogButtonBox::ButtonRole role;
    243236    switch (aButton & ButtonMask)
    244237    {
    245         case Ok:        text = tr ("OK"); break;
    246         case Yes:       text = tr ("Yes"); break;
    247         case No:        text = tr ("No"); break;
    248         case Cancel:    text = tr ("Cancel"); break;
    249         case Ignore:    text = tr ("Ignore"); break;
     238        case Ok:        text = tr ("OK"); role = QDialogButtonBox::AcceptRole; break;
     239        case Yes:       text = tr ("Yes"); role = QDialogButtonBox::YesRole; break;
     240        case No:        text = tr ("No"); role = QDialogButtonBox::NoRole; break;
     241        case Cancel:    text = tr ("Cancel"); role = QDialogButtonBox::RejectRole; break;
     242        case Ignore:    text = tr ("Ignore"); role = QDialogButtonBox::AcceptRole; break;
    250243        default:
    251244            AssertMsgFailed (("Type %d is not implemented", aButton));
     
    253246    }
    254247
    255     QPushButton *b = new QPushButton (text);
     248    QPushButton *b = mButtonBox->addButton (text, role);
    256249
    257250    if (aButton & Default)
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