VirtualBox

Ignore:
Timestamp:
Sep 1, 2020 4:51:27 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9812: Global preferences: Prepare cascade cleanup for Update page; And a bit of minor fixes for radio-button stuff.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings/global
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsUpdate.cpp

    r85800 r85982  
    6969
    7070UIGlobalSettingsUpdate::UIGlobalSettingsUpdate()
    71     : m_pLastChosenRadio(0)
    72     , m_pCache(0)
    73     , m_pUpdateDateText(0)
    74     , m_pUpdateDateLabel(0)
    75     , m_pUpdatePeriodLabel(0)
    76     , m_pUpdateFilterLabel(0)
     71    : m_pCache(0)
    7772    , m_pCheckBoxUpdate(0)
    78     , m_pComboBoxUpdatePeriod(0)
     73    , m_pWidgetUpdateSettings(0)
     74    , m_pLabelUpdatePeriod(0)
     75    , m_pComboUpdatePeriod(0)
     76    , m_pLabelUpdateDate(0)
     77    , m_pFieldUpdateDate(0)
     78    , m_pLabelUpdateFilter(0)
     79    , m_pRadioUpdateFilterStable(0)
     80    , m_pRadioUpdateFilterEvery(0)
    7981    , m_pRadioUpdateFilterBetas(0)
    80     , m_pRadioUpdateFilterEvery(0)
    81     , m_pRadioUpdateFilterStable(0)
    82     , m_pContainerUpdate(0)
    8382{
    8483    /* Prepare: */
     
    126125    if (m_pCheckBoxUpdate->isChecked())
    127126    {
    128         m_pComboBoxUpdatePeriod->setCurrentIndex(oldUpdateData.m_periodIndex);
     127        m_pComboUpdatePeriod->setCurrentIndex(oldUpdateData.m_periodIndex);
    129128        if (oldUpdateData.m_branchIndex == VBoxUpdateData::BranchWithBetas)
    130129            m_pRadioUpdateFilterBetas->setChecked(true);
     
    134133            m_pRadioUpdateFilterStable->setChecked(true);
    135134    }
    136     m_pUpdateDateText->setText(oldUpdateData.m_strDate);
     135    m_pFieldUpdateDate->setText(oldUpdateData.m_strDate);
    137136    sltHandleUpdateToggle(oldUpdateData.m_fCheckEnabled);
    138137}
     
    167166    /* Configure navigation: */
    168167    setTabOrder(pWidget, m_pCheckBoxUpdate);
    169     setTabOrder(m_pCheckBoxUpdate, m_pComboBoxUpdatePeriod);
    170     setTabOrder(m_pComboBoxUpdatePeriod, m_pRadioUpdateFilterStable);
     168    setTabOrder(m_pCheckBoxUpdate, m_pComboUpdatePeriod);
     169    setTabOrder(m_pComboUpdatePeriod, m_pRadioUpdateFilterStable);
    171170    setTabOrder(m_pRadioUpdateFilterStable, m_pRadioUpdateFilterEvery);
    172171    setTabOrder(m_pRadioUpdateFilterEvery, m_pRadioUpdateFilterBetas);
     
    179178                                       "new VirtualBox version is available."));
    180179    m_pCheckBoxUpdate->setText(tr("&Check for Updates"));
    181     m_pUpdatePeriodLabel->setText(tr("&Once per:"));
    182     m_pComboBoxUpdatePeriod->setWhatsThis(tr("Selects how often the new version "
     180    m_pLabelUpdatePeriod->setText(tr("&Once per:"));
     181    m_pComboUpdatePeriod->setWhatsThis(tr("Selects how often the new version "
    183182                                             "check should be performed. Note that if you want to completely "
    184183                                             "disable this check, just clear the above check box."));
    185     m_pUpdateDateLabel->setText(tr("Next Check:"));
    186     m_pUpdateFilterLabel->setText(tr("Check for:"));
     184    m_pLabelUpdateDate->setText(tr("Next Check:"));
     185    m_pLabelUpdateFilter->setText(tr("Check for:"));
    187186    m_pRadioUpdateFilterStable->setWhatsThis(tr("<p>Choose this if you only wish to "
    188187                                                "be notified about stable updates to VirtualBox.</p>"));
     
    195194    m_pRadioUpdateFilterBetas->setText(tr("All New Releases and &Pre-Releases"));
    196195
    197     /* Retranslate m_pComboBoxUpdatePeriod combobox: */
    198     int iCurrenIndex = m_pComboBoxUpdatePeriod->currentIndex();
    199     m_pComboBoxUpdatePeriod->clear();
     196    /* Retranslate m_pComboUpdatePeriod combobox: */
     197    int iCurrenIndex = m_pComboUpdatePeriod->currentIndex();
     198    m_pComboUpdatePeriod->clear();
    200199    VBoxUpdateData::populate();
    201     m_pComboBoxUpdatePeriod->insertItems(0, VBoxUpdateData::list());
    202     m_pComboBoxUpdatePeriod->setCurrentIndex(iCurrenIndex == -1 ? 0 : iCurrenIndex);
     200    m_pComboUpdatePeriod->insertItems(0, VBoxUpdateData::list());
     201    m_pComboUpdatePeriod->setCurrentIndex(iCurrenIndex == -1 ? 0 : iCurrenIndex);
    203202}
    204203
     
    206205{
    207206    /* Update activity status: */
    208     m_pContainerUpdate->setEnabled(fEnabled);
     207    m_pWidgetUpdateSettings->setEnabled(fEnabled);
    209208
    210209    /* Update time of next check: */
    211210    sltHandleUpdatePeriodChange();
    212211
    213     /* Temporary remember branch type if was switched off: */
    214     if (!fEnabled)
    215     {
    216         m_pLastChosenRadio = m_pRadioUpdateFilterBetas->isChecked() ? m_pRadioUpdateFilterBetas :
    217                              m_pRadioUpdateFilterEvery->isChecked() ? m_pRadioUpdateFilterEvery : m_pRadioUpdateFilterStable;
    218     }
    219 
    220     /* Check/uncheck last selected radio depending on activity status: */
    221     if (m_pLastChosenRadio)
    222         m_pLastChosenRadio->setChecked(fEnabled);
     212    /* Choose stable branch if nothing chosen: */
     213    if (   fEnabled
     214        && !m_pRadioUpdateFilterStable->isChecked()
     215        && !m_pRadioUpdateFilterEvery->isChecked()
     216        && !m_pRadioUpdateFilterBetas->isChecked())
     217        m_pRadioUpdateFilterStable->setChecked(true);
    223218}
    224219
     
    226221{
    227222    const VBoxUpdateData data(periodType(), branchType());
    228     m_pUpdateDateText->setText(data.date());
     223    m_pFieldUpdateDate->setText(data.date());
    229224}
    230225
    231226void UIGlobalSettingsUpdate::prepare()
    232227{
    233     prepareWidgets();
    234 
    235228    /* Prepare cache: */
    236229    m_pCache = new UISettingsCacheGlobalUpdate;
    237230    AssertPtrReturnVoid(m_pCache);
    238231
    239     /* Layout/widgets created in the .ui file. */
    240     AssertPtrReturnVoid(m_pCheckBoxUpdate);
    241     AssertPtrReturnVoid(m_pComboBoxUpdatePeriod);
    242     {
    243         /* Configure widgets: */
    244         connect(m_pCheckBoxUpdate, &QCheckBox::toggled, this, &UIGlobalSettingsUpdate::sltHandleUpdateToggle);
    245         connect(m_pComboBoxUpdatePeriod, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated),
    246                 this, &UIGlobalSettingsUpdate::sltHandleUpdatePeriodChange);
    247     }
     232    /* Prepare everything: */
     233    prepareWidgets();
     234    prepareConnections();
    248235
    249236    /* Apply language settings: */
     
    253240void UIGlobalSettingsUpdate::prepareWidgets()
    254241{
    255     if (objectName().isEmpty())
    256         setObjectName(QStringLiteral("UIGlobalSettingsUpdate"));
    257     QGridLayout *pMainLayout = new QGridLayout(this);
    258     pMainLayout->setContentsMargins(0, 0, 0, 0);
    259     pMainLayout->setObjectName(QStringLiteral("gridLayout"));
    260     m_pCheckBoxUpdate = new QCheckBox();
    261     m_pCheckBoxUpdate->setObjectName(QStringLiteral("m_pCheckBoxUpdate"));
    262     pMainLayout->addWidget(m_pCheckBoxUpdate, 0, 0, 1, 2);
    263 
    264     QSpacerItem *pSpacerItem = new QSpacerItem(20, 0, QSizePolicy::Fixed, QSizePolicy::Minimum);
    265     pMainLayout->addItem(pSpacerItem, 1, 0, 1, 1);
    266 
    267     m_pContainerUpdate = new QWidget();
    268     m_pContainerUpdate->setObjectName(QStringLiteral("m_pContainerUpdate"));
    269     QGridLayout *pContainerLayoutUpdate = new QGridLayout(m_pContainerUpdate);
    270     pContainerLayoutUpdate->setContentsMargins(0, 0, 0, 0);
    271     pContainerLayoutUpdate->setObjectName(QStringLiteral("pContainerLayoutUpdate"));
    272     pContainerLayoutUpdate->setContentsMargins(0, 0, 0, 0);
    273     m_pUpdatePeriodLabel = new QLabel(m_pContainerUpdate);
    274     m_pUpdatePeriodLabel->setObjectName(QStringLiteral("m_pUpdatePeriodLabel"));
    275     m_pUpdatePeriodLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    276     pContainerLayoutUpdate->addWidget(m_pUpdatePeriodLabel, 0, 0, 1, 1);
    277 
    278     QHBoxLayout *pHBoxLayout = new QHBoxLayout();
    279     pHBoxLayout->setObjectName(QStringLiteral("pHBoxLayout"));
    280     m_pComboBoxUpdatePeriod = new QComboBox(m_pContainerUpdate);
    281     m_pComboBoxUpdatePeriod->setObjectName(QStringLiteral("m_pComboBoxUpdatePeriod"));
    282     QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    283     sizePolicy.setHorizontalStretch(0);
    284     sizePolicy.setVerticalStretch(0);
    285     sizePolicy.setHeightForWidth(m_pComboBoxUpdatePeriod->sizePolicy().hasHeightForWidth());
    286     m_pComboBoxUpdatePeriod->setSizePolicy(sizePolicy);
    287     pHBoxLayout->addWidget(m_pComboBoxUpdatePeriod);
    288 
    289     QSpacerItem *pSpacerItem1 = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
    290     pHBoxLayout->addItem(pSpacerItem1);
    291 
    292     pContainerLayoutUpdate->addLayout(pHBoxLayout, 0, 1, 1, 1);
    293 
    294     m_pUpdateDateLabel = new QLabel(m_pContainerUpdate);
    295     m_pUpdateDateLabel->setObjectName(QStringLiteral("m_pUpdateDateLabel"));
    296     m_pUpdateDateLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    297     pContainerLayoutUpdate->addWidget(m_pUpdateDateLabel, 1, 0, 1, 1);
    298 
    299     m_pUpdateDateText = new QLabel(m_pContainerUpdate);
    300     m_pUpdateDateText->setObjectName(QStringLiteral("m_pUpdateDateText"));
    301     pContainerLayoutUpdate->addWidget(m_pUpdateDateText, 1, 1, 1, 1);
    302 
    303     m_pUpdateFilterLabel = new QLabel(m_pContainerUpdate);
    304     m_pUpdateFilterLabel->setObjectName(QStringLiteral("m_pUpdateFilterLabel"));
    305     m_pUpdateFilterLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    306     pContainerLayoutUpdate->addWidget(m_pUpdateFilterLabel, 2, 0, 1, 1);
    307 
    308     m_pRadioUpdateFilterStable = new QRadioButton(m_pContainerUpdate);
    309     m_pRadioUpdateFilterStable->setObjectName(QStringLiteral("m_pRadioUpdateFilterStable"));
    310     pContainerLayoutUpdate->addWidget(m_pRadioUpdateFilterStable, 2, 1, 1, 1);
    311 
    312     m_pRadioUpdateFilterEvery = new QRadioButton(m_pContainerUpdate);
    313     m_pRadioUpdateFilterEvery->setObjectName(QStringLiteral("m_pRadioUpdateFilterEvery"));
    314     pContainerLayoutUpdate->addWidget(m_pRadioUpdateFilterEvery, 3, 1, 1, 1);
    315 
    316     m_pRadioUpdateFilterBetas = new QRadioButton(m_pContainerUpdate);
    317     m_pRadioUpdateFilterBetas->setObjectName(QStringLiteral("m_pRadioUpdateFilterBetas"));
    318     pContainerLayoutUpdate->addWidget(m_pRadioUpdateFilterBetas, 4, 1, 1, 1);
    319 
    320     pMainLayout->addWidget(m_pContainerUpdate, 1, 1, 1, 1);
    321 
    322     QSpacerItem *pSpacerItem2 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
    323     pMainLayout->addItem(pSpacerItem2, 2, 0, 1, 2);
    324 
    325     m_pUpdatePeriodLabel->setBuddy(m_pComboBoxUpdatePeriod);
     242    /* Prepare main layout: */
     243    QGridLayout *pLayoutMain = new QGridLayout(this);
     244    if (pLayoutMain)
     245    {
     246        pLayoutMain->setRowStretch(2, 1);
     247
     248        /* Prepare update check-box: */
     249        m_pCheckBoxUpdate = new QCheckBox(this);
     250        if (m_pCheckBoxUpdate)
     251            pLayoutMain->addWidget(m_pCheckBoxUpdate, 0, 0, 1, 2);
     252
     253        /* Prepare 20-px shifting spacer: */
     254        QSpacerItem *pSpacerItem = new QSpacerItem(20, 0, QSizePolicy::Fixed, QSizePolicy::Minimum);
     255        if (pSpacerItem)
     256            pLayoutMain->addItem(pSpacerItem, 1, 0);
     257
     258        /* Prepare update settings widget: */
     259        m_pWidgetUpdateSettings = new QWidget(this);
     260        if (m_pWidgetUpdateSettings)
     261        {
     262            /* Prepare update settings widget layout: */
     263            QGridLayout *pLayoutUpdateSettings = new QGridLayout(m_pWidgetUpdateSettings);
     264            if (pLayoutUpdateSettings)
     265            {
     266                pLayoutUpdateSettings->setContentsMargins(0, 0, 0, 0);
     267                pLayoutUpdateSettings->setColumnStretch(2, 1);
     268                pLayoutUpdateSettings->setRowStretch(5, 1);
     269
     270                /* Prepare update period label: */
     271                m_pLabelUpdatePeriod = new QLabel(m_pWidgetUpdateSettings);
     272                if (m_pLabelUpdatePeriod)
     273                {
     274                    m_pLabelUpdatePeriod->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     275                    pLayoutUpdateSettings->addWidget(m_pLabelUpdatePeriod, 0, 0);
     276                }
     277                /* Prepare update period combo: */
     278                m_pComboUpdatePeriod = new QComboBox(m_pWidgetUpdateSettings);
     279                if (m_pComboUpdatePeriod)
     280                {
     281                    if (m_pLabelUpdatePeriod)
     282                        m_pLabelUpdatePeriod->setBuddy(m_pComboUpdatePeriod);
     283                    m_pComboUpdatePeriod->setSizeAdjustPolicy(QComboBox::AdjustToContents);
     284                    m_pComboUpdatePeriod->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
     285
     286                    pLayoutUpdateSettings->addWidget(m_pComboUpdatePeriod, 0, 1);
     287                }
     288
     289                /* Prepare update date label: */
     290                m_pLabelUpdateDate = new QLabel(m_pWidgetUpdateSettings);
     291                if (m_pLabelUpdateDate)
     292                {
     293                    m_pLabelUpdateDate->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     294                    pLayoutUpdateSettings->addWidget(m_pLabelUpdateDate, 1, 0);
     295                }
     296                /* Prepare update date field: */
     297                m_pFieldUpdateDate = new QLabel(m_pWidgetUpdateSettings);
     298                if (m_pFieldUpdateDate)
     299                    pLayoutUpdateSettings->addWidget(m_pFieldUpdateDate, 1, 1);
     300
     301                /* Prepare update date label: */
     302                m_pLabelUpdateFilter = new QLabel(m_pWidgetUpdateSettings);
     303                if (m_pLabelUpdateFilter)
     304                {
     305                    m_pLabelUpdateFilter->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     306                    pLayoutUpdateSettings->addWidget(m_pLabelUpdateFilter, 2, 0);
     307                }
     308                /* Prepare 'stable' radio-button: */
     309                m_pRadioUpdateFilterStable = new QRadioButton(m_pWidgetUpdateSettings);
     310                if (m_pRadioUpdateFilterStable)
     311                    pLayoutUpdateSettings->addWidget(m_pRadioUpdateFilterStable, 2, 1);
     312                /* Prepare 'every' radio-button: */
     313                m_pRadioUpdateFilterEvery = new QRadioButton(m_pWidgetUpdateSettings);
     314                if (m_pRadioUpdateFilterEvery)
     315                    pLayoutUpdateSettings->addWidget(m_pRadioUpdateFilterEvery, 3, 1);
     316                /* Prepare 'betas' radio-button: */
     317                m_pRadioUpdateFilterBetas = new QRadioButton(m_pWidgetUpdateSettings);
     318                if (m_pRadioUpdateFilterBetas)
     319                    pLayoutUpdateSettings->addWidget(m_pRadioUpdateFilterBetas, 4, 1);
     320            }
     321
     322            pLayoutMain->addWidget(m_pWidgetUpdateSettings, 1, 1);
     323        }
     324    }
     325}
     326
     327void UIGlobalSettingsUpdate::prepareConnections()
     328{
     329    connect(m_pCheckBoxUpdate, &QCheckBox::toggled, this, &UIGlobalSettingsUpdate::sltHandleUpdateToggle);
     330    connect(m_pComboUpdatePeriod, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated),
     331            this, &UIGlobalSettingsUpdate::sltHandleUpdatePeriodChange);
    326332}
    327333
     
    336342{
    337343    const VBoxUpdateData::PeriodType result = m_pCheckBoxUpdate->isChecked() ?
    338         (VBoxUpdateData::PeriodType)m_pComboBoxUpdatePeriod->currentIndex() : VBoxUpdateData::PeriodNever;
     344        (VBoxUpdateData::PeriodType)m_pComboUpdatePeriod->currentIndex() : VBoxUpdateData::PeriodNever;
    339345    return result == VBoxUpdateData::PeriodUndefined ? VBoxUpdateData::Period1Day : result;
    340346}
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsUpdate.h

    r85800 r85982  
    8181    /** Prepares widgets. */
    8282    void prepareWidgets();
     83    /** Prepares connections. */
     84    void prepareConnections();
    8385    /** Cleanups all. */
    8486    void cleanup();
     
    9294    bool saveUpdateData();
    9395
    94     /** Holds the last checked button reference. */
    95     QRadioButton *m_pLastChosenRadio;
    96 
    9796    /** Holds the page data cache instance. */
    9897    UISettingsCacheGlobalUpdate *m_pCache;
     
    10099    /** @name Widgets
    101100     * @{ */
    102        QLabel *m_pUpdateDateText;
    103        QLabel *m_pUpdateDateLabel;
    104        QLabel *m_pUpdatePeriodLabel;
    105        QLabel *m_pUpdateFilterLabel;
    106        QCheckBox *m_pCheckBoxUpdate;
    107        QComboBox *m_pComboBoxUpdatePeriod;
    108        QRadioButton *m_pRadioUpdateFilterBetas;
    109        QRadioButton *m_pRadioUpdateFilterEvery;
    110        QRadioButton *m_pRadioUpdateFilterStable;
    111        QWidget *m_pContainerUpdate;
     101        QCheckBox *m_pCheckBoxUpdate;
     102        QWidget *m_pWidgetUpdateSettings;
     103        QLabel *m_pLabelUpdatePeriod;
     104        QComboBox *m_pComboUpdatePeriod;
     105        QLabel *m_pLabelUpdateDate;
     106        QLabel *m_pFieldUpdateDate;
     107        QLabel *m_pLabelUpdateFilter;
     108        QRadioButton *m_pRadioUpdateFilterStable;
     109        QRadioButton *m_pRadioUpdateFilterEvery;
     110        QRadioButton *m_pRadioUpdateFilterBetas;
    112111    /** @} */
    113112};
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