VirtualBox

Changeset 84022 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Apr 27, 2020 7:18:37 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9653: Rework QIDialogContainer to be able to add caption to progress-bar and embed that stuff to button-box directly.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/extensions
Files:
2 edited

Legend:

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

    r84016 r84022  
    1818/* Qt includes: */
    1919#include <QGridLayout>
     20#include <QLabel>
    2021#include <QProgressBar>
    2122#include <QPushButton>
     
    3031
    3132QIDialogContainer::QIDialogContainer(QWidget *pParent /* = 0 */, Qt::WindowFlags enmFlags /* = Qt::WindowFlags() */)
    32     : QDialog(pParent, enmFlags)
     33    : QIWithRetranslateUI2<QDialog>(pParent, enmFlags)
    3334    , m_pLayout(0)
    3435    , m_pWidget(0)
     36    , m_pProgressLabel(0)
    3537    , m_pProgressBar(0)
    3638    , m_pButtonBox(0)
     
    4951void QIDialogContainer::setProgressBarHidden(bool fHidden)
    5052{
     53    AssertPtrReturnVoid(m_pProgressLabel);
    5154    AssertPtrReturnVoid(m_pProgressBar);
     55    m_pProgressLabel->setHidden(fHidden);
    5256    m_pProgressBar->setHidden(fHidden);
    5357}
     
    6064}
    6165
     66void QIDialogContainer::retranslateUi()
     67{
     68    m_pProgressLabel->setText(tr("Loading"));
     69}
     70
    6271void QIDialogContainer::prepare()
    6372{
     
    6675    if (m_pLayout)
    6776    {
    68         /* Prepare horizontal layout: */
    69         QHBoxLayout *pHLayout = new QHBoxLayout;
    70         if (pHLayout)
     77        /* Prepare dialog button-box: */
     78        m_pButtonBox = new QIDialogButtonBox(this);
     79        if (m_pButtonBox)
    7180        {
    72             /* Prepare progress-bar: */
    73             m_pProgressBar = new QProgressBar(this);
    74             if (m_pProgressBar)
     81            m_pButtonBox->setStandardButtons(QDialogButtonBox::Ok);
     82            connect(m_pButtonBox, &QIDialogButtonBox::accepted,
     83                    this, &QDialog::accept);
     84            connect(m_pButtonBox, &QIDialogButtonBox::rejected,
     85                    this, &QDialog::reject);
     86
     87            /* Prepare progress-layout: */
     88            QHBoxLayout *pHLayout = new QHBoxLayout;
     89            if (pHLayout)
    7590            {
    76                 m_pProgressBar->setHidden(true);
    77                 m_pProgressBar->setMinimum(0);
    78                 m_pProgressBar->setMaximum(0);
     91                pHLayout->setContentsMargins(0, 0, 0, 0);
    7992
    80                 /* Add into layout: */
    81                 pHLayout->addWidget(m_pProgressBar);
    82             }
     93                /* Prepare progress-label: */
     94                m_pProgressLabel = new QLabel(this);
     95                if (m_pProgressLabel)
     96                {
     97                    m_pProgressLabel->setHidden(true);
    8398
    84             /* Prepare dialog button-box: */
    85             m_pButtonBox = new QIDialogButtonBox(this);
    86             if (m_pButtonBox)
    87             {
    88                 m_pButtonBox->setStandardButtons(QDialogButtonBox::Ok);
    89                 connect(m_pButtonBox, &QIDialogButtonBox::accepted,
    90                         this, &QDialog::accept);
    91                 connect(m_pButtonBox, &QIDialogButtonBox::rejected,
    92                         this, &QDialog::reject);
     99                    /* Add into layout: */
     100                    pHLayout->addWidget(m_pProgressLabel);
     101                }
     102                /* Prepare progress-bar: */
     103                m_pProgressBar = new QProgressBar(this);
     104                if (m_pProgressBar)
     105                {
     106                    m_pProgressBar->setHidden(true);
     107                    m_pProgressBar->setTextVisible(false);
     108                    m_pProgressBar->setMinimum(0);
     109                    m_pProgressBar->setMaximum(0);
    93110
    94                 /* Add into layout: */
    95                 pHLayout->addWidget(m_pButtonBox);
     111                    /* Add into layout: */
     112                    pHLayout->addWidget(m_pProgressBar);
     113                }
     114
     115                /* Add into button-box: */
     116                m_pButtonBox->addExtraLayout(pHLayout);
    96117            }
    97118
    98119            /* Add into layout: */
    99             m_pLayout->addLayout(pHLayout, 1, 0);
     120            m_pLayout->addWidget(m_pButtonBox, 1, 0);
    100121        }
    101122    }
     123
     124    /* Apply language settings: */
     125    retranslateUi();
    102126}
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIDialogContainer.h

    r84016 r84022  
    2626
    2727/* GUI includes: */
     28#include "QIWithRetranslateUI.h"
    2829#include "UILibraryDefs.h"
    2930
    3031/* Forward declarations: */
    3132class QGridLayout;
     33class QLabel;
    3234class QProgressBar;
    3335class QWidget;
     
    3638/** QDialog sub-class used as executable input container for passed widget.
    3739  * Should be used as popup or modal dialog wrapping functionality of the passed widget. */
    38 class SHARED_LIBRARY_STUFF QIDialogContainer : public QDialog
     40class SHARED_LIBRARY_STUFF QIDialogContainer : public QIWithRetranslateUI2<QDialog>
    3941{
    4042    Q_OBJECT;
     
    5961    void setOkButtonEnabled(bool fEnabled);
    6062
     63protected:
     64
     65    /** Handles translation event. */
     66    virtual void retranslateUi() /* override */;
     67
    6168private:
    6269
     
    6976    QWidget           *m_pWidget;
    7077    /** Holds the progress-bar instance. */
     78    QLabel            *m_pProgressLabel;
     79    /** Holds the progress-bar instance. */
    7180    QProgressBar      *m_pProgressBar;
    7281    /** Holds the button-box instance. */
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