VirtualBox

Changeset 16802 in vbox for trunk/src


Ignore:
Timestamp:
Feb 16, 2009 6:04:09 PM (16 years ago)
Author:
vboxsync
Message:

FE/Qt4: 3627: Shorten error dialogs. First approved variant done.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/VirtualBox.qrc

    r16743 r16802  
    319319    <file alias="monitor.png">images/monitor.png</file>
    320320    <file alias="monitor_glossy.png">images/monitor_glossy.png</file>
     321    <file alias="arrow_right_10px.png">images/arrow_right_10px.png</file>
     322    <file alias="arrow_left_10px.png">images/arrow_left_10px.png</file>
     323    <file alias="arrow_up_10px.png">images/arrow_up_10px.png</file>
     324    <file alias="arrow_down_10px.png">images/arrow_down_10px.png</file>
    321325    <file alias="name_16px.png">images/name_16px.png</file>
    322326    <file alias="os_type_16px.png">images/os_type_16px.png</file>
  • trunk/src/VBox/Frontends/VirtualBox/include/QIMessageBox.h

    r14440 r16802  
    2424#define __QIMessageBox_h__
    2525
     26/* VBox includes */
    2627#include "QIDialog.h"
    2728
     
    3132#include <QTextEdit>
    3233
     34/* VBox forwards */
     35class QIArrowSplitter;
     36class QIDialogButtonBox;
    3337class QILabel;
     38
     39/* Qt forwards */
     40class QCloseEvent;
    3441class QLabel;
    3542class QPushButton;
    3643class QSpacerItem;
    37 class QCloseEvent;
     44class QToolButton;
     45class QVBoxLayout;
    3846
    39 class QIDialogButtonBox;
     47/** @class QIArrowSplitter
     48 *
     49 *  The QIArrowSplitter class is a folding widget placeholder.
     50 *  It is declared here until moved into separate file in case
     51 *  of it will be used somewhere except problem-reporter dialog.
     52 */
     53class QIArrowSplitter : public QWidget
     54{
     55    Q_OBJECT;
    4056
     57public:
     58
     59    QIArrowSplitter (QWidget *aParent = 0);
     60
     61    void addWidget (const QString &aName, QWidget *aWidget);
     62
     63public slots:
     64
     65    void toggleWidget();
     66
     67private:
     68
     69    QVBoxLayout *mMainLayout;
     70    QList <QToolButton*> mButtonsList;
     71    QList <QWidget*> mWidgetsList;
     72};
     73
     74/** @class QIMessageBox
     75 *
     76 *  The QIMessageBox class is a message box similar to QMessageBox.
     77 *  It partly implements the QMessageBox interface and adds some enhanced
     78 *  functionality.
     79 */
    4180class QIMessageBox : public QIDialog
    4281{
    43     Q_OBJECT
     82    Q_OBJECT;
    4483
    4584public:
     
    92131
    93132    void closeEvent (QCloseEvent *e);
     133    void showEvent (QShowEvent *e);
    94134
    95135private slots:
     
    109149    QCheckBox *mFlagCB, *mFlagCB_Main, *mFlagCB_Details;
    110150    QWidget *mDetailsVBox;
     151    QIArrowSplitter *mDetailsSplitter;
    111152    QTextEdit *mDetailsText;
    112153    QSpacerItem *mSpacer;
    113154    QIDialogButtonBox *mButtonBox;
    114155    bool mWasDone : 1;
     156    bool mWasPolished : 1;
    115157};
    116158
  • trunk/src/VBox/Frontends/VirtualBox/src/QIMessageBox.cpp

    r15887 r16802  
    2121 */
    2222
     23/* VBox includes */
    2324#include "VBoxDefs.h"
    2425#include "VBoxGlobal.h"
    25 
    2626#include "QIMessageBox.h"
    2727#include "QILabel.h"
     
    3333/* Qt includes */
    3434#include <QHBoxLayout>
     35#include <QLabel>
    3536#include <QPushButton>
    36 #include <QLabel>
     37#include <QToolButton>
     38
     39/** @class QIArrowSplitter
     40 *
     41 *  The QIArrowSplitter class is a folding widget placeholder.
     42 */
     43QIArrowSplitter::QIArrowSplitter (QWidget *aParent)
     44    : QWidget (aParent)
     45    , mMainLayout (new QVBoxLayout (this))
     46{
     47    VBoxGlobal::setLayoutMargin (mMainLayout, 0);
     48}
     49
     50void QIArrowSplitter::addWidget (const QString &aName, QWidget *aWidget)
     51{
     52    /* Creating arrow tool-button */
     53    QToolButton *arrowButton = new QToolButton();
     54    connect (arrowButton, SIGNAL (clicked (bool)), this, SLOT (toggleWidget()));
     55    arrowButton->setIcon (VBoxGlobal::iconSet (":/arrow_right_10px.png"));
     56    arrowButton->setFocusPolicy (Qt::StrongFocus);
     57    arrowButton->setAutoRaise (true);
     58    arrowButton->setFixedSize (14, 16);
     59    mButtonsList.append (arrowButton);
     60
     61    /* Creating description label */
     62    QLabel *descriptionLabel = new QLabel (aName);
     63    descriptionLabel->setBuddy (arrowButton);
     64
     65    mWidgetsList.append (aWidget);
     66
     67    QHBoxLayout *lineLayout = new QHBoxLayout();
     68    lineLayout->addWidget (arrowButton);
     69    lineLayout->addWidget (descriptionLabel);
     70
     71    mMainLayout->insertWidget (0, aWidget);
     72    mMainLayout->insertLayout (0, lineLayout);
     73}
     74
     75void QIArrowSplitter::toggleWidget()
     76{
     77    QToolButton *arrowButton = qobject_cast <QToolButton*> (sender());
     78
     79    /* Toggle all or the specified arrow & related widget */
     80    foreach (QToolButton *itemButton, mButtonsList)
     81    {
     82        if ((itemButton == arrowButton) || (!arrowButton))
     83        {
     84            QWidget *relatedWidget = mWidgetsList [mButtonsList.indexOf (itemButton)];
     85            Assert (relatedWidget);
     86            relatedWidget->setVisible (!relatedWidget->isVisible());
     87            itemButton->setIcon (VBoxGlobal::iconSet (relatedWidget->isVisible() ?
     88                                 ":/arrow_down_10px.png" : ":/arrow_right_10px.png"));
     89        }
     90    }
     91
     92    /* Update full layout system of message window */
     93    QList <QLayout*> layouts = findChildren <QLayout*> ();
     94    foreach (QLayout *item, layouts)
     95    {
     96        item->update();
     97        item->activate();
     98    }
     99
     100    /* Update main layout of message window at last */
     101    window()->layout()->update();
     102    window()->layout()->activate();
     103
     104    /* Now resize window to minimum possible size */
     105    window()->resize (window()->minimumSizeHint());
     106    qApp->processEvents();
     107    window()->setFixedSize (window()->size());
     108}
    37109
    38110/** @class QIMessageBox
     
    51123    : QIDialog (aParent)
    52124    , mWasDone (false)
     125    , mWasPolished (false)
    53126{
    54127#ifdef Q_WS_MAC
     
    99172    hLayout->addLayout (messageVBoxLayout);
    100173
    101     mTextLabel = new QILabel (aText, NULL);
     174    mTextLabel = new QILabel (aText);
    102175    mTextLabel->setAlignment (Qt::AlignLeft | Qt::AlignTop);
    103176    mTextLabel->setWordWrap (true);
    104     QSizePolicy sp (QSizePolicy::Minimum, QSizePolicy::Minimum);
     177    QSizePolicy sp (QSizePolicy::Preferred, QSizePolicy::Preferred);
    105178    sp.setHeightForWidth (true);
    106179    mTextLabel->setSizePolicy (sp);
    107     mTextLabel->adjustSize();
    108     mTextLabel->setMinimumWidth (mTextLabel->sizeHint().width());
    109180    messageVBoxLayout->addWidget (mTextLabel);
    110181
     
    116187    layout->addWidget (mDetailsVBox);
    117188
    118     QVBoxLayout* detailsVBoxLayout = new QVBoxLayout(mDetailsVBox);
     189    QVBoxLayout* detailsVBoxLayout = new QVBoxLayout (mDetailsVBox);
    119190    VBoxGlobal::setLayoutMargin (detailsVBoxLayout, 0);
    120191    detailsVBoxLayout->setSpacing (10);
     192
     193    mDetailsSplitter = new QIArrowSplitter();
     194    detailsVBoxLayout->addWidget (mDetailsSplitter);
    121195
    122196    mDetailsText = new QTextEdit();
     
    130204    mDetailsText->setSizePolicy (QSizePolicy::Expanding,
    131205                                 QSizePolicy::MinimumExpanding);
    132     detailsVBoxLayout->addWidget (mDetailsText);
     206    mDetailsSplitter->addWidget (tr ("&Details:"), mDetailsText);
    133207
    134208    mFlagCB_Details = new QCheckBox();
     
    157231    /* this call is a must -- it initializes mFlagCB and mSpacer */
    158232    setDetailsShown (false);
    159 
    160     /* Set fixed size */
    161     setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
    162233}
    163234
     
    379450}
    380451
     452void QIMessageBox::showEvent (QShowEvent *e)
     453{
     454    if (!mWasPolished)
     455    {
     456        /* Polishing sub-widgets */
     457        resize (minimumSizeHint());
     458        qApp->processEvents();
     459        mTextLabel->setMinimumWidth (mTextLabel->width());
     460        mTextLabel->updateSizeHint();
     461        mDetailsSplitter->toggleWidget();
     462        mWasPolished = true;
     463    }
     464
     465    QIDialog::showEvent (e);
     466}
     467
    381468void QIMessageBox::reject()
    382469{
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