VirtualBox

Changeset 3893 in vbox for trunk/src


Ignore:
Timestamp:
Jul 26, 2007 9:04:13 PM (17 years ago)
Author:
vboxsync
Message:

backed out 23271 to fix the tinderboxes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/QIMessageBox.cpp

    r3892 r3893  
    4545 *  See QMessageBox for details.
    4646 */
    47 QIMessageBox::QIMessageBox (const QString &aCaption, const QString &aText,
    48                             Icon aIcon, int aButton0, int aButton1, int aButton2,
    49                             QWidget *aParent, const char *aName, bool aModal,
    50                             WFlags aFlags)
    51     : QDialog (aParent, aName, aModal,
    52                aFlags | WStyle_Customize | WStyle_NormalBorder |
    53                         WStyle_Title | WStyle_SysMenu)
    54 {
    55     setCaption (aCaption);
    56 
    57     mButton0 = aButton0;
    58     mButton1 = aButton1;
    59     mButton2 = aButton2;
     47QIMessageBox::QIMessageBox (
     48    const QString &caption, const QString &text,
     49    Icon icon, int button0, int button1, int button2,
     50    QWidget *parent, const char *name, bool modal,
     51    WFlags f
     52) :
     53    QDialog (
     54        parent, name, modal,
     55        f | WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu
     56    )
     57{
     58    setCaption (caption);
     59
     60    b0 = button0;
     61    b1 = button1;
     62    b2 = button2;
    6063
    6164    QVBoxLayout *layout = new QVBoxLayout (this);
     
    7174    layout->addWidget (main);
    7275
    73     mIconLabel = new QLabel (main);
    74     mIconLabel->setPixmap (QMessageBox::standardIcon ((QMessageBox::Icon) aIcon));
    75     mIconLabel->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Minimum);
    76     mIconLabel->setAlignment (AlignHCenter | AlignTop);
    77 
    78     mMessageVBox = new QVBox (main);
    79     mMessageVBox->setMargin (0);
    80     mMessageVBox->setSpacing (10);
    81 
    82     mTextLabel = new QLabel (aText, mMessageVBox);
    83     mTextLabel->setAlignment (AlignAuto | AlignTop | ExpandTabs | WordBreak);
    84     mTextLabel->setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Fixed, true);
    85 
    86     mFlagCB_Main = new QCheckBox (mMessageVBox);
    87 
    88     mDetailsVBox = new QVBox (this);
    89     mDetailsVBox->setMargin (0);
    90     mDetailsVBox->setSpacing (10);
    91     layout->addWidget (mDetailsVBox);
    92 
    93     mDetailsText = new QTextEdit (mDetailsVBox);
     76    licon = new QLabel (main);
     77    licon->setPixmap (QMessageBox::standardIcon ((QMessageBox::Icon) icon));
     78    licon->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Minimum);
     79    licon->setAlignment (AlignHCenter | AlignTop);
     80
     81    message = new QVBox (main);
     82    message->setMargin (0);
     83    message->setSpacing (10);
     84
     85    ltext = new QLabel (text, message);
     86    ltext->setAlignment (AlignAuto | AlignTop | ExpandTabs | WordBreak);
     87    ltext->setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Fixed, true);
     88
     89    dbox = new QVBox (this);
     90    dbox->setMargin (0);
     91    dbox->setSpacing (10);
     92    layout->addWidget (dbox);
     93
     94    dtext = new QTextEdit (dbox);
    9495    {
    9596        /* calculate the minimum size dynamically, approx. for 40 chars and
    9697         * 6 lines */
    97         QFontMetrics fm = mDetailsText->fontMetrics();
    98         mDetailsText->setMinimumSize (40 * fm.width ('m'), fm.lineSpacing() * 6);
    99     }
    100     mDetailsText->setReadOnly (true);
    101     mDetailsText->setWrapPolicy (QTextEdit::AtWordOrDocumentBoundary);
    102     mDetailsText->setSizePolicy (QSizePolicy::Expanding,
    103                                  QSizePolicy::MinimumExpanding);
    104 
    105     mFlagCB_Details = new QCheckBox (mDetailsVBox);
    106 
    107     mSpacer = new QSpacerItem (0, 0);
    108     layout->addItem (mSpacer);
     98        QFontMetrics fm = dtext->fontMetrics();
     99        dtext->setMinimumSize (40 * fm.width ('m'), fm.lineSpacing() * 6);
     100    }
     101    dtext->setReadOnly (true);
     102    dtext->setWrapPolicy (QTextEdit::AtWordOrDocumentBoundary);
     103    dtext->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
     104
     105    /* cbflag has no parent initially, setDetailsShown() will do that */
     106    cbflag = new QCheckBox (0);
     107    cbflag->hide();
     108
     109    spacer = new QSpacerItem (0, 0);
     110    layout->addItem (spacer);
    109111
    110112    QHBoxLayout *buttons = new QHBoxLayout (new QWidget (this));
     
    113115    buttons->setSpacing (5);
    114116
    115     mButtonEsc = 0;
    116 
    117     mButton0PB = createButton (buttons->mainWidget(), aButton0);
    118     if (mButton0PB)
    119         connect (mButton0PB, SIGNAL (clicked()), SLOT (done0()));
    120     mButton1PB = createButton (buttons->mainWidget(), aButton1);
    121     if (mButton1PB)
    122         connect (mButton1PB, SIGNAL (clicked()), SLOT (done1()));
    123     mButton2PB = createButton (buttons->mainWidget(), aButton2);
    124     if (mButton2PB)
    125         connect (mButton2PB, SIGNAL (clicked()), SLOT (done2()));
    126 
     117    bescape = 0;
     118
     119    pb0 = createButton (buttons->mainWidget(), button0);
     120    if (pb0) connect (pb0, SIGNAL( clicked() ), SLOT( done0() ));
     121    pb1 = createButton (buttons->mainWidget(), button1);
     122    if (pb1) connect (pb1, SIGNAL( clicked() ), SLOT( done1() ));
     123    pb2 = createButton (buttons->mainWidget(), button2);
     124    if (pb2) connect (pb2, SIGNAL( clicked() ), SLOT( done2() ));
    127125    buttons->setAlignment (AlignHCenter);
    128126
    129     /* this call is a must -- it initializes mFlagCB and mSpacer */
    130127    setDetailsShown (false);
    131128}
     
    144141 *  will hide the flag. By default, the flag is hidden.
    145142 */
    146 void QIMessageBox::setFlagText (const QString &aText)
    147 {
    148     if (aText.isNull())
    149     {
    150         mFlagCB->hide();
    151     }
    152     else
    153     {
    154         mFlagCB->setText (aText);
    155         mFlagCB->show();
    156         mFlagCB->setFocus();
     143void QIMessageBox::setFlagText (const QString &text)
     144{
     145    if (text.isNull()) {
     146        cbflag->hide();
     147    } else {
     148        cbflag->setText (text);
     149        cbflag->show();
     150        cbflag->setFocus();
    157151    }
    158152}
     
    175169 */
    176170
    177 QPushButton *QIMessageBox::createButton (QWidget *aParent, int aButton)
    178 {
    179     if (aButton == 0)
     171QPushButton *QIMessageBox::createButton (QWidget *parent, int button)
     172{
     173    if (button == 0)
    180174        return 0;
    181175
    182176    QString text;
    183     switch (aButton & ButtonMask)
     177    switch (button & ButtonMask)
    184178    {
    185179        case Ok:        text = tr ("OK"); break;
     
    189183        case Ignore:    text = tr ("Ignore"); break;
    190184        default:
    191             AssertMsgFailed (("Type %d is not implemented", aButton));
    192             return NULL;
    193     }
    194 
    195     QPushButton *b = new QPushButton (text, aParent);
    196 
    197     if (aButton & Default)
     185            AssertMsgFailed (("QIMessageBox::createButton(): type %d is not implemented",
     186                              button));
     187            return 0;
     188    }
     189
     190    QPushButton *b = new QPushButton (text, parent);
     191
     192    if (button & Default)
    198193    {
    199194        b->setDefault (true);
     
    201196    }
    202197    else
    203     if (aButton & Escape)
    204         mButtonEsc = aButton & ButtonMask;
     198    if (button & Escape)
     199        bescape = button & ButtonMask;
    205200
    206201    return b;
     
    222217 *  @see #setDetailsShown()
    223218 */
    224 void QIMessageBox::setDetailsText (const QString &aText)
    225 {
    226     mDetailsText->setText (aText);
     219void QIMessageBox::setDetailsText (const QString &text)
     220{
     221    dtext->setText (text);
    227222}
    228223
     
    243238 *  @see #setDetailsText()
    244239 */
    245 void QIMessageBox::setDetailsShown (bool aShown)
    246 {
    247     if (aShown)
    248     {
    249         mFlagCB_Details->setShown (mFlagCB->isShown());
    250         mFlagCB_Details->setChecked (mFlagCB->isChecked());
    251         mFlagCB_Main->setShown (false);
    252         mFlagCB = mFlagCB_Details;
    253         mSpacer->changeSize (0, 0, QSizePolicy::Minimum, QSizePolicy::Minimum);
    254     }
    255 
    256     mDetailsVBox->setShown (aShown);
    257 
    258     if (!aShown)
    259     {
    260         mFlagCB_Main->setShown (mFlagCB_Details->isShown());
    261         mFlagCB_Main->setChecked (mFlagCB_Details->isChecked());
    262         mFlagCB = mFlagCB_Main;
    263         mSpacer->changeSize (0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
    264     }
    265 }
    266 
     240void QIMessageBox::setDetailsShown (bool shown)
     241{
     242
     243    bool cbflagShown = cbflag->isShown();
     244
     245    if (shown)
     246    {
     247        cbflag->reparent (dbox, QPoint());
     248        cbflag->setShown (cbflagShown);
     249        spacer->changeSize (0, 0, QSizePolicy::Minimum, QSizePolicy::Minimum);
     250    }
     251
     252    dbox->setShown (shown);
     253
     254    if (!shown)
     255    {
     256        cbflag->reparent (message, QPoint(), cbflagShown);
     257        cbflag->setShown (cbflagShown);
     258        spacer->changeSize (0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
     259    }
     260}
     261
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