VirtualBox

Ignore:
Timestamp:
Sep 15, 2020 4:14:08 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9827: Global properties / Update page: Heavy rework, replacing widgets with corresponding editor classes, reworking radio-button group stuff and performing overall cleanup.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
5 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r86124 r86128  
    848848        src/settings/editors/UIScaleFactorEditor.h \
    849849        src/settings/editors/UIShortcutConfigurationEditor.h \
     850        src/settings/editors/UIUpdateSettingsEditor.h \
    850851        src/settings/editors/UIVideoMemoryEditor.h \
    851852        src/settings/editors/UIVirtualCPUEditor.h \
     
    13651366        src/settings/editors/UIScaleFactorEditor.cpp \
    13661367        src/settings/editors/UIShortcutConfigurationEditor.cpp \
     1368        src/settings/editors/UIUpdateSettingsEditor.cpp \
    13671369        src/settings/editors/UIVideoMemoryEditor.cpp \
    13681370        src/settings/editors/UIVirtualCPUEditor.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateDefs.cpp

    r84319 r86128  
    8080}
    8181
     82VBoxUpdateData::VBoxUpdateData(const VBoxUpdateData &another)
     83    : m_strData(another.data())
     84    , m_enmPeriodIndex(another.periodIndex())
     85    , m_date(another.internalDate())
     86    , m_enmBranchIndex(another.branchIndex())
     87    , m_version(another.version())
     88{
     89}
     90
    8291bool VBoxUpdateData::isNoNeedToCheck() const
    8392{
     
    117126{
    118127    return isNoNeedToCheck() ? QCoreApplication::translate("UIUpdateManager", "Never") : m_date.toString(Qt::LocaleDate);
     128}
     129
     130QDate VBoxUpdateData::internalDate() const
     131{
     132    return m_date;
    119133}
    120134
     
    143157}
    144158
     159bool VBoxUpdateData::isEqual(const VBoxUpdateData &another) const
     160{
     161    return    true
     162           && (m_strData == another.data())
     163           && (m_enmPeriodIndex == another.periodIndex())
     164           && (m_date == another.internalDate())
     165           && (m_enmBranchIndex == another.branchIndex())
     166           && (m_version == another.version())
     167              ;
     168}
     169
     170bool VBoxUpdateData::operator==(const VBoxUpdateData &another) const
     171{
     172    return isEqual(another);
     173}
     174
     175bool VBoxUpdateData::operator!=(const VBoxUpdateData &another) const
     176{
     177    return !isEqual(another);
     178}
     179
    145180void VBoxUpdateData::decode()
    146181{
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateDefs.h

    r82968 r86128  
    8080
    8181    /** Constructs update description on the basis of passed @a strData. */
    82     VBoxUpdateData(const QString &strData);
     82    VBoxUpdateData(const QString &strData = QString());
    8383    /** Constructs update description on the basis of passed @a enmPeriodIndex and @a enmBranchIndex. */
    8484    VBoxUpdateData(PeriodType enmPeriodIndex, BranchType enmBranchIndex);
     85    /** Constructs update description on the basis of @a another one. */
     86    VBoxUpdateData(const VBoxUpdateData &another);
    8587
    8688    /** Returns whether there is no need to check. */
     
    9496    /** Returns update date. */
    9597    QString date() const;
     98    /** Returns internal update date. */
     99    QDate internalDate() const;
    96100    /** Returns branch index. */
    97101    BranchType branchIndex() const;
     
    100104    /** Returns version. */
    101105    UIVersion version() const;
     106
     107    /** Returns whether this item equals to @a another one. */
     108    bool isEqual(const VBoxUpdateData &another) const;
     109    /** Returns whether this item equals to @a another one. */
     110    bool operator==(const VBoxUpdateData &another) const;
     111    /** Returns whether this item isn't equal to @a another one. */
     112    bool operator!=(const VBoxUpdateData &another) const;
    102113
    103114private:
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIUpdateSettingsEditor.cpp

    r86125 r86128  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIGlobalSettingsUpdate class implementation.
     3 * VBox Qt GUI - UIUpdateSettingsEditor class implementation.
    44 */
    55
     
    1717
    1818/* Qt includes: */
     19#include <QButtonGroup>
    1920#include <QCheckBox>
    2021#include <QComboBox>
     
    2425
    2526/* GUI includes: */
    26 #include "UIGlobalSettingsUpdate.h"
    27 #include "UIExtraDataManager.h"
    28 #include "UIMessageCenter.h"
    29 #include "UICommon.h"
    30 
    31 
    32 /** Global settings: Update page data structure. */
    33 struct UIDataSettingsGlobalUpdate
    34 {
    35     /** Constructs data. */
    36     UIDataSettingsGlobalUpdate()
    37         : m_fCheckEnabled(false)
    38         , m_periodIndex(VBoxUpdateData::PeriodUndefined)
    39         , m_branchIndex(VBoxUpdateData::BranchStable)
    40         , m_strDate(QString())
    41     {}
    42 
    43     /** Returns whether the @a other passed data is equal to this one. */
    44     bool equal(const UIDataSettingsGlobalUpdate &other) const
    45     {
    46         return true
    47                && (m_fCheckEnabled == other.m_fCheckEnabled)
    48                && (m_periodIndex == other.m_periodIndex)
    49                && (m_branchIndex == other.m_branchIndex)
    50                && (m_strDate == other.m_strDate)
    51                ;
    52     }
    53 
    54     /** Returns whether the @a other passed data is equal to this one. */
    55     bool operator==(const UIDataSettingsGlobalUpdate &other) const { return equal(other); }
    56     /** Returns whether the @a other passed data is different from this one. */
    57     bool operator!=(const UIDataSettingsGlobalUpdate &other) const { return !equal(other); }
    58 
    59     /** Holds whether the update check is enabled. */
    60     bool m_fCheckEnabled;
    61     /** Holds the update check period. */
    62     VBoxUpdateData::PeriodType m_periodIndex;
    63     /** Holds the update branch type. */
    64     VBoxUpdateData::BranchType m_branchIndex;
    65     /** Holds the next update date. */
    66     QString m_strDate;
    67 };
    68 
    69 
    70 UIGlobalSettingsUpdate::UIGlobalSettingsUpdate()
    71     : m_pCache(0)
    72     , m_pCheckBoxUpdate(0)
     27#include "UIUpdateSettingsEditor.h"
     28
     29
     30UIUpdateSettingsEditor::UIUpdateSettingsEditor(QWidget *pParent /* = 0 */)
     31    : QIWithRetranslateUI<QWidget>(pParent)
     32    , m_pCheckBox(0)
    7333    , m_pWidgetUpdateSettings(0)
    7434    , m_pLabelUpdatePeriod(0)
     
    7737    , m_pFieldUpdateDate(0)
    7838    , m_pLabelUpdateFilter(0)
    79     , m_pRadioUpdateFilterStable(0)
    80     , m_pRadioUpdateFilterEvery(0)
    81     , m_pRadioUpdateFilterBetas(0)
    82 {
    83     /* Prepare: */
     39    , m_pRadioButtonGroup(0)
     40{
    8441    prepare();
    8542}
    8643
    87 UIGlobalSettingsUpdate::~UIGlobalSettingsUpdate()
    88 {
    89     /* Cleanup: */
    90     cleanup();
    91 }
    92 
    93 void UIGlobalSettingsUpdate::loadToCacheFrom(QVariant &data)
    94 {
    95     /* Fetch data to properties: */
    96     UISettingsPageGlobal::fetchData(data);
    97 
    98     /* Clear cache initially: */
    99     m_pCache->clear();
    100 
    101     /* Prepare old update data: */
    102     UIDataSettingsGlobalUpdate oldUpdateData;
    103 
    104     /* Gather old update data: */
    105     const VBoxUpdateData updateData(gEDataManager->applicationUpdateData());
    106     oldUpdateData.m_fCheckEnabled = !updateData.isNoNeedToCheck();
    107     oldUpdateData.m_periodIndex = updateData.periodIndex();
    108     oldUpdateData.m_branchIndex = updateData.branchIndex();
    109     oldUpdateData.m_strDate = updateData.date();
    110 
    111     /* Cache old update data: */
    112     m_pCache->cacheInitialData(oldUpdateData);
    113 
    114     /* Upload properties to data: */
    115     UISettingsPageGlobal::uploadData(data);
    116 }
    117 
    118 void UIGlobalSettingsUpdate::getFromCache()
    119 {
    120     /* Get old update data from the cache: */
    121     const UIDataSettingsGlobalUpdate &oldUpdateData = m_pCache->base();
    122 
    123     /* Load old update data from the cache: */
    124     m_pCheckBoxUpdate->setChecked(oldUpdateData.m_fCheckEnabled);
    125     if (m_pCheckBoxUpdate->isChecked())
    126     {
    127         m_pComboUpdatePeriod->setCurrentIndex(oldUpdateData.m_periodIndex);
    128         if (oldUpdateData.m_branchIndex == VBoxUpdateData::BranchWithBetas)
    129             m_pRadioUpdateFilterBetas->setChecked(true);
    130         else if (oldUpdateData.m_branchIndex == VBoxUpdateData::BranchAllRelease)
    131             m_pRadioUpdateFilterEvery->setChecked(true);
    132         else
    133             m_pRadioUpdateFilterStable->setChecked(true);
    134     }
    135     m_pFieldUpdateDate->setText(oldUpdateData.m_strDate);
    136     sltHandleUpdateToggle(oldUpdateData.m_fCheckEnabled);
    137 }
    138 
    139 void UIGlobalSettingsUpdate::putToCache()
    140 {
    141     /* Prepare new update data: */
    142     UIDataSettingsGlobalUpdate newUpdateData = m_pCache->base();
    143 
    144     /* Gather new update data: */
    145     newUpdateData.m_periodIndex = periodType();
    146     newUpdateData.m_branchIndex = branchType();
    147 
    148     /* Cache new update data: */
    149     m_pCache->cacheCurrentData(newUpdateData);
    150 }
    151 
    152 void UIGlobalSettingsUpdate::saveFromCacheTo(QVariant &data)
    153 {
    154     /* Fetch data to properties: */
    155     UISettingsPageGlobal::fetchData(data);
    156 
    157     /* Update update data and failing state: */
    158     setFailed(!saveUpdateData());
    159 
    160     /* Upload properties to data: */
    161     UISettingsPageGlobal::uploadData(data);
    162 }
    163 
    164 void UIGlobalSettingsUpdate::setOrderAfter(QWidget *pWidget)
    165 {
    166     /* Configure navigation: */
    167     setTabOrder(pWidget, m_pCheckBoxUpdate);
    168     setTabOrder(m_pCheckBoxUpdate, m_pComboUpdatePeriod);
    169     setTabOrder(m_pComboUpdatePeriod, m_pRadioUpdateFilterStable);
    170     setTabOrder(m_pRadioUpdateFilterStable, m_pRadioUpdateFilterEvery);
    171     setTabOrder(m_pRadioUpdateFilterEvery, m_pRadioUpdateFilterBetas);
    172 }
    173 
    174 void UIGlobalSettingsUpdate::retranslateUi()
    175 {
    176     m_pCheckBoxUpdate->setWhatsThis(tr("When checked, the application will "
    177                                        "periodically connect to the VirtualBox website and check whether a "
    178                                        "new VirtualBox version is available."));
    179     m_pCheckBoxUpdate->setText(tr("&Check for Updates"));
    180     m_pLabelUpdatePeriod->setText(tr("&Once per:"));
    181     m_pComboUpdatePeriod->setWhatsThis(tr("Selects how often the new version "
    182                                              "check should be performed. Note that if you want to completely "
    183                                              "disable this check, just clear the above check box."));
    184     m_pLabelUpdateDate->setText(tr("Next Check:"));
    185     m_pLabelUpdateFilter->setText(tr("Check for:"));
    186     m_pRadioUpdateFilterStable->setWhatsThis(tr("<p>Choose this if you only wish to "
    187                                                 "be notified about stable updates to VirtualBox.</p>"));
    188     m_pRadioUpdateFilterStable->setText(tr("&Stable Release Versions"));
    189     m_pRadioUpdateFilterEvery->setWhatsThis(tr("<p>Choose this if you wish to be "
    190                                                "notified about all new VirtualBox releases.</p>"));
    191     m_pRadioUpdateFilterEvery->setText(tr("&All New Releases"));
    192     m_pRadioUpdateFilterBetas->setWhatsThis(tr("<p>Choose this to be notified about "
    193                                                "all new VirtualBox releases and pre-release versions of VirtualBox.</p>"));
    194     m_pRadioUpdateFilterBetas->setText(tr("All New Releases and &Pre-Releases"));
    195 
    196     /* Retranslate m_pComboUpdatePeriod combobox: */
    197     int iCurrenIndex = m_pComboUpdatePeriod->currentIndex();
    198     m_pComboUpdatePeriod->clear();
    199     VBoxUpdateData::populate();
    200     m_pComboUpdatePeriod->insertItems(0, VBoxUpdateData::list());
    201     m_pComboUpdatePeriod->setCurrentIndex(iCurrenIndex == -1 ? 0 : iCurrenIndex);
    202 }
    203 
    204 void UIGlobalSettingsUpdate::sltHandleUpdateToggle(bool fEnabled)
     44void UIUpdateSettingsEditor::setValue(const VBoxUpdateData &guiValue)
     45{
     46    /* Update value if changed: */
     47    if (m_guiValue != guiValue)
     48    {
     49        /* Update value itself: */
     50        m_guiValue = guiValue;
     51
     52        /* Update check-box if present: */
     53        if (m_pCheckBox)
     54        {
     55            m_pCheckBox->setChecked(!m_guiValue.isNoNeedToCheck());
     56
     57            if (m_pCheckBox->isChecked())
     58            {
     59                /* Update period combo if present: */
     60                if (m_pComboUpdatePeriod)
     61                    m_pComboUpdatePeriod->setCurrentIndex(m_guiValue.periodIndex());
     62
     63                /* Update branch radio-buttons if present: */
     64                if (m_mapRadioButtons.value(m_guiValue.branchIndex()))
     65                    m_mapRadioButtons.value(m_guiValue.branchIndex())->setChecked(true);
     66            }
     67
     68            /* Update other related widgets: */
     69            sltHandleUpdateToggle(m_pCheckBox->isChecked());
     70        }
     71    }
     72}
     73
     74VBoxUpdateData UIUpdateSettingsEditor::value() const
     75{
     76    return m_pCheckBox ? VBoxUpdateData(periodType(), branchType()) : m_guiValue;
     77}
     78
     79void UIUpdateSettingsEditor::retranslateUi()
     80{
     81    /* Translate check-box: */
     82    if (m_pCheckBox)
     83    {
     84        m_pCheckBox->setWhatsThis(tr("When checked, the application will periodically connect to the VirtualBox "
     85                                     "website and check whether a new VirtualBox version is available."));
     86        m_pCheckBox->setText(tr("&Check for Updates"));
     87    }
     88
     89    /* Translate period widgets: */
     90    if (m_pLabelUpdatePeriod)
     91        m_pLabelUpdatePeriod->setText(tr("&Once per:"));
     92    if (m_pComboUpdatePeriod)
     93    {
     94        m_pComboUpdatePeriod->setWhatsThis(tr("Selects how often the new version check should be performed. Note that if you want "
     95                                              "to completely disable this check, just clear the above check box."));
     96        const int iCurrenIndex = m_pComboUpdatePeriod->currentIndex();
     97        m_pComboUpdatePeriod->clear();
     98        VBoxUpdateData::populate();
     99        m_pComboUpdatePeriod->insertItems(0, VBoxUpdateData::list());
     100        m_pComboUpdatePeriod->setCurrentIndex(iCurrenIndex == -1 ? 0 : iCurrenIndex);
     101    }
     102    if (m_pLabelUpdateDate)
     103        m_pLabelUpdateDate->setText(tr("Next Check:"));
     104    if (m_pLabelUpdateFilter)
     105        m_pLabelUpdateFilter->setText(tr("Check for:"));
     106
     107    /* Translate branch widgets: */
     108    if (m_mapRadioButtons.value(VBoxUpdateData::BranchStable))
     109    {
     110        m_mapRadioButtons.value(VBoxUpdateData::BranchStable)->setWhatsThis(tr("<p>Choose this if you only wish to be notified "
     111                                                                               "about stable updates to VirtualBox.</p>"));
     112        m_mapRadioButtons.value(VBoxUpdateData::BranchStable)->setText(tr("&Stable Release Versions"));
     113    }
     114    if (m_mapRadioButtons.value(VBoxUpdateData::BranchAllRelease))
     115    {
     116        m_mapRadioButtons.value(VBoxUpdateData::BranchAllRelease)->setWhatsThis(tr("<p>Choose this if you wish to be notified "
     117                                                                                   "about all new VirtualBox releases.</p>"));
     118        m_mapRadioButtons.value(VBoxUpdateData::BranchAllRelease)->setText(tr("&All New Releases"));
     119    }
     120    if (m_mapRadioButtons.value(VBoxUpdateData::BranchWithBetas))
     121    {
     122        m_mapRadioButtons.value(VBoxUpdateData::BranchWithBetas)->setWhatsThis(tr("<p>Choose this to be notified about all new "
     123                                                                                  "VirtualBox releases and pre-release versions "
     124                                                                                  "of VirtualBox.</p>"));
     125        m_mapRadioButtons.value(VBoxUpdateData::BranchWithBetas)->setText(tr("All New Releases and &Pre-Releases"));
     126    }
     127}
     128
     129void UIUpdateSettingsEditor::sltHandleUpdateToggle(bool fEnabled)
    205130{
    206131    /* Update activity status: */
    207     m_pWidgetUpdateSettings->setEnabled(fEnabled);
     132    if (m_pWidgetUpdateSettings)
     133        m_pWidgetUpdateSettings->setEnabled(fEnabled);
    208134
    209135    /* Update time of next check: */
    210136    sltHandleUpdatePeriodChange();
    211137
    212     /* Choose stable branch if nothing chosen: */
     138    /* Choose stable branch if update enabled but branch isn't chosen: */
    213139    if (   fEnabled
    214         && !m_pRadioUpdateFilterStable->isChecked()
    215         && !m_pRadioUpdateFilterEvery->isChecked()
    216         && !m_pRadioUpdateFilterBetas->isChecked())
    217         m_pRadioUpdateFilterStable->setChecked(true);
    218 }
    219 
    220 void UIGlobalSettingsUpdate::sltHandleUpdatePeriodChange()
    221 {
    222     const VBoxUpdateData data(periodType(), branchType());
    223     m_pFieldUpdateDate->setText(data.date());
    224 }
    225 
    226 void UIGlobalSettingsUpdate::prepare()
    227 {
    228     /* Prepare cache: */
    229     m_pCache = new UISettingsCacheGlobalUpdate;
    230     AssertPtrReturnVoid(m_pCache);
    231 
     140        && m_pRadioButtonGroup
     141        && !m_pRadioButtonGroup->checkedButton()
     142        && m_mapRadioButtons.value(VBoxUpdateData::BranchStable))
     143        m_mapRadioButtons.value(VBoxUpdateData::BranchStable)->setChecked(true);
     144}
     145
     146void UIUpdateSettingsEditor::sltHandleUpdatePeriodChange()
     147{
     148    if (m_pFieldUpdateDate)
     149        m_pFieldUpdateDate->setText(VBoxUpdateData(periodType(), branchType()).date());
     150}
     151
     152void UIUpdateSettingsEditor::prepare()
     153{
    232154    /* Prepare everything: */
    233155    prepareWidgets();
     
    238160}
    239161
    240 void UIGlobalSettingsUpdate::prepareWidgets()
     162void UIUpdateSettingsEditor::prepareWidgets()
    241163{
    242164    /* Prepare main layout: */
     
    244166    if (pLayoutMain)
    245167    {
     168        pLayoutMain->setContentsMargins(0, 0, 0, 0);
    246169        pLayoutMain->setRowStretch(2, 1);
    247170
    248171        /* Prepare update check-box: */
    249         m_pCheckBoxUpdate = new QCheckBox(this);
    250         if (m_pCheckBoxUpdate)
    251             pLayoutMain->addWidget(m_pCheckBoxUpdate, 0, 0, 1, 2);
     172        m_pCheckBox = new QCheckBox(this);
     173        if (m_pCheckBox)
     174            pLayoutMain->addWidget(m_pCheckBox, 0, 0, 1, 2);
    252175
    253176        /* Prepare 20-px shifting spacer: */
     
    306229                    pLayoutUpdateSettings->addWidget(m_pLabelUpdateFilter, 2, 0);
    307230                }
    308                 /* Prepare 'update to stable' radio-button: */
    309                 m_pRadioUpdateFilterStable = new QRadioButton(m_pWidgetUpdateSettings);
    310                 if (m_pRadioUpdateFilterStable)
    311                     pLayoutUpdateSettings->addWidget(m_pRadioUpdateFilterStable, 2, 1);
    312                 /* Prepare 'update to every' radio-button: */
    313                 m_pRadioUpdateFilterEvery = new QRadioButton(m_pWidgetUpdateSettings);
    314                 if (m_pRadioUpdateFilterEvery)
    315                     pLayoutUpdateSettings->addWidget(m_pRadioUpdateFilterEvery, 3, 1);
    316                 /* Prepare 'update to betas' radio-button: */
    317                 m_pRadioUpdateFilterBetas = new QRadioButton(m_pWidgetUpdateSettings);
    318                 if (m_pRadioUpdateFilterBetas)
    319                     pLayoutUpdateSettings->addWidget(m_pRadioUpdateFilterBetas, 4, 1);
     231                /* Prepare radio-button group: */
     232                m_pRadioButtonGroup = new QButtonGroup(m_pWidgetUpdateSettings);
     233                if (m_pRadioButtonGroup)
     234                {
     235                    /* Prepare 'update to "stable"' radio-button: */
     236                    m_mapRadioButtons[VBoxUpdateData::BranchStable] = new QRadioButton(m_pWidgetUpdateSettings);
     237                    if (m_mapRadioButtons.value(VBoxUpdateData::BranchStable))
     238                    {
     239                        m_pRadioButtonGroup->addButton(m_mapRadioButtons.value(VBoxUpdateData::BranchStable));
     240                        pLayoutUpdateSettings->addWidget(m_mapRadioButtons.value(VBoxUpdateData::BranchStable), 2, 1);
     241                    }
     242                    /* Prepare 'update to "all release"' radio-button: */
     243                    m_mapRadioButtons[VBoxUpdateData::BranchAllRelease] = new QRadioButton(m_pWidgetUpdateSettings);
     244                    if (m_mapRadioButtons.value(VBoxUpdateData::BranchAllRelease))
     245                    {
     246                        m_pRadioButtonGroup->addButton(m_mapRadioButtons.value(VBoxUpdateData::BranchAllRelease));
     247                        pLayoutUpdateSettings->addWidget(m_mapRadioButtons.value(VBoxUpdateData::BranchAllRelease), 3, 1);
     248                    }
     249                    /* Prepare 'update to "with betas"' radio-button: */
     250                    m_mapRadioButtons[VBoxUpdateData::BranchWithBetas] = new QRadioButton(m_pWidgetUpdateSettings);
     251                    if (m_mapRadioButtons.value(VBoxUpdateData::BranchWithBetas))
     252                    {
     253                        m_pRadioButtonGroup->addButton(m_mapRadioButtons.value(VBoxUpdateData::BranchWithBetas));
     254                        pLayoutUpdateSettings->addWidget(m_mapRadioButtons.value(VBoxUpdateData::BranchWithBetas), 4, 1);
     255                    }
     256                }
    320257            }
    321258
     
    325262}
    326263
    327 void 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);
    332 }
    333 
    334 void UIGlobalSettingsUpdate::cleanup()
    335 {
    336     /* Cleanup cache: */
    337     delete m_pCache;
    338     m_pCache = 0;
    339 }
    340 
    341 VBoxUpdateData::PeriodType UIGlobalSettingsUpdate::periodType() const
    342 {
    343     const VBoxUpdateData::PeriodType result = m_pCheckBoxUpdate->isChecked() ?
    344         (VBoxUpdateData::PeriodType)m_pComboUpdatePeriod->currentIndex() : VBoxUpdateData::PeriodNever;
    345     return result == VBoxUpdateData::PeriodUndefined ? VBoxUpdateData::Period1Day : result;
    346 }
    347 
    348 VBoxUpdateData::BranchType UIGlobalSettingsUpdate::branchType() const
    349 {
    350     if (m_pRadioUpdateFilterBetas->isChecked())
    351         return VBoxUpdateData::BranchWithBetas;
    352     else if (m_pRadioUpdateFilterEvery->isChecked())
    353         return VBoxUpdateData::BranchAllRelease;
    354     else
    355         return VBoxUpdateData::BranchStable;
    356 }
    357 
    358 bool UIGlobalSettingsUpdate::saveUpdateData()
    359 {
    360     /* Prepare result: */
    361     bool fSuccess = true;
    362     /* Save update settings from the cache: */
    363     if (fSuccess && m_pCache->wasChanged())
    364     {
    365         /* Get old update data from the cache: */
    366         //const UIDataSettingsGlobalUpdate &oldUpdateData = m_pCache->base();
    367         /* Get new update data from the cache: */
    368         const UIDataSettingsGlobalUpdate &newUpdateData = m_pCache->data();
    369 
    370         /* Save new update data from the cache: */
    371         const VBoxUpdateData newData(newUpdateData.m_periodIndex, newUpdateData.m_branchIndex);
    372         gEDataManager->setApplicationUpdateData(newData.data());
    373     }
    374     /* Return result: */
    375     return fSuccess;
    376 }
     264void UIUpdateSettingsEditor::prepareConnections()
     265{
     266    if (m_pCheckBox)
     267        connect(m_pCheckBox, &QCheckBox::toggled, this, &UIUpdateSettingsEditor::sltHandleUpdateToggle);
     268    if (m_pComboUpdatePeriod)
     269        connect(m_pComboUpdatePeriod, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated),
     270                this, &UIUpdateSettingsEditor::sltHandleUpdatePeriodChange);
     271}
     272
     273VBoxUpdateData::PeriodType UIUpdateSettingsEditor::periodType() const
     274{
     275    const VBoxUpdateData::PeriodType enmResult = m_pCheckBox && m_pCheckBox->isChecked() && m_pComboUpdatePeriod
     276                                               ? (VBoxUpdateData::PeriodType)m_pComboUpdatePeriod->currentIndex()
     277                                               : VBoxUpdateData::PeriodNever;
     278    return enmResult == VBoxUpdateData::PeriodUndefined ? VBoxUpdateData::Period1Day : enmResult;
     279}
     280
     281VBoxUpdateData::BranchType UIUpdateSettingsEditor::branchType() const
     282{
     283    QAbstractButton *pCheckedButton = m_pRadioButtonGroup ? m_pRadioButtonGroup->checkedButton() : 0;
     284    return pCheckedButton ? m_mapRadioButtons.key(pCheckedButton, VBoxUpdateData::BranchStable) : VBoxUpdateData::BranchStable;
     285}
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIUpdateSettingsEditor.h

    r86125 r86128  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIGlobalSettingsUpdate class declaration.
     3 * VBox Qt GUI - UIUpdateSettingsEditor class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_settings_global_UIGlobalSettingsUpdate_h
    19 #define FEQT_INCLUDED_SRC_settings_global_UIGlobalSettingsUpdate_h
     18#ifndef FEQT_INCLUDED_SRC_settings_editors_UIUpdateSettingsEditor_h
     19#define FEQT_INCLUDED_SRC_settings_editors_UIUpdateSettingsEditor_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
    2222#endif
    2323
     24/* Qt includes: */
     25#include <QMap>
     26
    2427/* GUI includes: */
    25 #include "UISettingsPage.h"
     28#include "QIWithRetranslateUI.h"
    2629#include "UIUpdateDefs.h"
    2730
    2831/* Forward declarations: */
     32class QAbstractButton;
     33class QButtonGroup;
    2934class QCheckBox;
    3035class QComboBox;
    3136class QLabel;
    32 class QRadioButton;
    33 struct UIDataSettingsGlobalUpdate;
    34 typedef UISettingsCache<UIDataSettingsGlobalUpdate> UISettingsCacheGlobalUpdate;
    3537
    36 /** Global settings: Update page. */
    37 class SHARED_LIBRARY_STUFF UIGlobalSettingsUpdate : public UISettingsPageGlobal
     38/** QWidget subclass used as a global update settings editor. */
     39class SHARED_LIBRARY_STUFF UIUpdateSettingsEditor : public QIWithRetranslateUI<QWidget>
    3840{
    3941    Q_OBJECT;
     
    4143public:
    4244
    43     /** Constructs Update settings page. */
    44     UIGlobalSettingsUpdate();
    45     /** Destructs Update settings page. */
    46     ~UIGlobalSettingsUpdate();
     45    /** Constructs global update settings editor passing @a pParent to the base-class. */
     46    UIUpdateSettingsEditor(QWidget *pParent = 0);
     47
     48    /** Defines editor @a guiValue. */
     49    void setValue(const VBoxUpdateData &guiValue);
     50    /** Returns editor value. */
     51    VBoxUpdateData value() const;
     52
     53    /** Returns period type. */
     54    VBoxUpdateData::PeriodType periodType() const;
     55    /** Returns branch type. */
     56    VBoxUpdateData::BranchType branchType() const;
    4757
    4858protected:
    49 
    50     /** Loads settings from external object(s) packed inside @a data to cache.
    51       * @note  This task WILL be performed in other than the GUI thread, no widget interactions! */
    52     virtual void loadToCacheFrom(QVariant &data) /* override */;
    53     /** Loads data from cache to corresponding widgets.
    54       * @note  This task WILL be performed in the GUI thread only, all widget interactions here! */
    55     virtual void getFromCache() /* override */;
    56 
    57     /** Saves data from corresponding widgets to cache.
    58       * @note  This task WILL be performed in the GUI thread only, all widget interactions here! */
    59     virtual void putToCache() /* override */;
    60     /** Saves settings from cache to external object(s) packed inside @a data.
    61       * @note  This task WILL be performed in other than the GUI thread, no widget interactions! */
    62     virtual void saveFromCacheTo(QVariant &data) /* overrride */;
    63 
    64     /** Defines TAB order for passed @a pWidget. */
    65     virtual void setOrderAfter(QWidget *pWidget) /* override */;
    6659
    6760    /** Handles translation event. */
     
    8376    /** Prepares connections. */
    8477    void prepareConnections();
    85     /** Cleanups all. */
    86     void cleanup();
    8778
    88     /** Returns period type. */
    89     VBoxUpdateData::PeriodType periodType() const;
    90     /** Returns branch type. */
    91     VBoxUpdateData::BranchType branchType() const;
    92 
    93     /** Saves existing update data from the cache. */
    94     bool saveUpdateData();
    95 
    96     /** Holds the page data cache instance. */
    97     UISettingsCacheGlobalUpdate *m_pCache;
     79    /** Holds the value to be set. */
     80    VBoxUpdateData  m_guiValue;
    9881
    9982    /** @name Widgets
    10083     * @{ */
    10184        /** Holds the update check-box instance. */
    102         QCheckBox    *m_pCheckBoxUpdate;
     85        QCheckBox    *m_pCheckBox;
    10386        /** Holds the update settings widget instance. */
    10487        QWidget      *m_pWidgetUpdateSettings;
     
    11396        /** Holds the update filter label instance. */
    11497        QLabel       *m_pLabelUpdateFilter;
    115         /** Holds the 'update to stable' radio-button instance. */
    116         QRadioButton *m_pRadioUpdateFilterStable;
    117         /** Holds the 'update to every' radio-button instance. */
    118         QRadioButton *m_pRadioUpdateFilterEvery;
    119         /** Holds the 'update to betas' radio-button instance. */
    120         QRadioButton *m_pRadioUpdateFilterBetas;
     98
     99        /** Holds the radio button group instance. */
     100        QButtonGroup                                       *m_pRadioButtonGroup;
     101        /** Holds the radio button map instance. */
     102        QMap<VBoxUpdateData::BranchType, QAbstractButton*>  m_mapRadioButtons;
    121103    /** @} */
    122104};
    123105
    124 #endif /* !FEQT_INCLUDED_SRC_settings_global_UIGlobalSettingsUpdate_h */
     106#endif /* !FEQT_INCLUDED_SRC_settings_editors_UIUpdateSettingsEditor_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsUpdate.cpp

    r86020 r86128  
    1717
    1818/* Qt includes: */
    19 #include <QCheckBox>
    20 #include <QComboBox>
    21 #include <QGridLayout>
    22 #include <QLabel>
    23 #include <QRadioButton>
     19#include <QVBoxLayout>
    2420
    2521/* GUI includes: */
     22#include "UIExtraDataManager.h"
    2623#include "UIGlobalSettingsUpdate.h"
    27 #include "UIExtraDataManager.h"
    28 #include "UIMessageCenter.h"
    29 #include "UICommon.h"
     24#include "UIUpdateSettingsEditor.h"
    3025
    3126
     
    3530    /** Constructs data. */
    3631    UIDataSettingsGlobalUpdate()
    37         : m_fCheckEnabled(false)
    38         , m_periodIndex(VBoxUpdateData::PeriodUndefined)
    39         , m_branchIndex(VBoxUpdateData::BranchStable)
    40         , m_strDate(QString())
     32        : m_guiUpdateData(VBoxUpdateData())
    4133    {}
    4234
     
    4436    bool equal(const UIDataSettingsGlobalUpdate &other) const
    4537    {
    46         return true
    47                && (m_fCheckEnabled == other.m_fCheckEnabled)
    48                && (m_periodIndex == other.m_periodIndex)
    49                && (m_branchIndex == other.m_branchIndex)
    50                && (m_strDate == other.m_strDate)
    51                ;
     38        return    true
     39               && (m_guiUpdateData == other.m_guiUpdateData)
     40                  ;
    5241    }
    5342
     
    5746    bool operator!=(const UIDataSettingsGlobalUpdate &other) const { return !equal(other); }
    5847
    59     /** Holds whether the update check is enabled. */
    60     bool m_fCheckEnabled;
    61     /** Holds the update check period. */
    62     VBoxUpdateData::PeriodType m_periodIndex;
    63     /** Holds the update branch type. */
    64     VBoxUpdateData::BranchType m_branchIndex;
    65     /** Holds the next update date. */
    66     QString m_strDate;
     48    /** Holds VBox update data. */
     49    VBoxUpdateData  m_guiUpdateData;
    6750};
    6851
     
    7053UIGlobalSettingsUpdate::UIGlobalSettingsUpdate()
    7154    : m_pCache(0)
    72     , m_pCheckBoxUpdate(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)
    81     , m_pRadioUpdateFilterBetas(0)
     55    , m_pEditorUpdateSettings(0)
    8256{
    83     /* Prepare: */
    8457    prepare();
    8558}
     
    8760UIGlobalSettingsUpdate::~UIGlobalSettingsUpdate()
    8861{
    89     /* Cleanup: */
    9062    cleanup();
    9163}
     
    9971    m_pCache->clear();
    10072
    101     /* Prepare old update data: */
    102     UIDataSettingsGlobalUpdate oldUpdateData;
    103 
    104     /* Gather old update data: */
    105     const VBoxUpdateData updateData(gEDataManager->applicationUpdateData());
    106     oldUpdateData.m_fCheckEnabled = !updateData.isNoNeedToCheck();
    107     oldUpdateData.m_periodIndex = updateData.periodIndex();
    108     oldUpdateData.m_branchIndex = updateData.branchIndex();
    109     oldUpdateData.m_strDate = updateData.date();
    110 
    111     /* Cache old update data: */
    112     m_pCache->cacheInitialData(oldUpdateData);
     73    /* Cache old data: */
     74    UIDataSettingsGlobalUpdate oldData;
     75    oldData.m_guiUpdateData = gEDataManager->applicationUpdateData();
     76    m_pCache->cacheInitialData(oldData);
    11377
    11478    /* Upload properties to data: */
     
    11882void UIGlobalSettingsUpdate::getFromCache()
    11983{
    120     /* Get old update data from the cache: */
    121     const UIDataSettingsGlobalUpdate &oldUpdateData = m_pCache->base();
    122 
    123     /* Load old update data from the cache: */
    124     m_pCheckBoxUpdate->setChecked(oldUpdateData.m_fCheckEnabled);
    125     if (m_pCheckBoxUpdate->isChecked())
    126     {
    127         m_pComboUpdatePeriod->setCurrentIndex(oldUpdateData.m_periodIndex);
    128         if (oldUpdateData.m_branchIndex == VBoxUpdateData::BranchWithBetas)
    129             m_pRadioUpdateFilterBetas->setChecked(true);
    130         else if (oldUpdateData.m_branchIndex == VBoxUpdateData::BranchAllRelease)
    131             m_pRadioUpdateFilterEvery->setChecked(true);
    132         else
    133             m_pRadioUpdateFilterStable->setChecked(true);
    134     }
    135     m_pFieldUpdateDate->setText(oldUpdateData.m_strDate);
    136     sltHandleUpdateToggle(oldUpdateData.m_fCheckEnabled);
     84    /* Load old data from cache: */
     85    const UIDataSettingsGlobalUpdate &oldData = m_pCache->base();
     86    m_pEditorUpdateSettings->setValue(oldData.m_guiUpdateData);
    13787}
    13888
    13989void UIGlobalSettingsUpdate::putToCache()
    14090{
    141     /* Prepare new update data: */
    142     UIDataSettingsGlobalUpdate newUpdateData = m_pCache->base();
     91    /* Prepare new data: */
     92    UIDataSettingsGlobalUpdate newData = m_pCache->base();
    14393
    144     /* Gather new update data: */
    145     newUpdateData.m_periodIndex = periodType();
    146     newUpdateData.m_branchIndex = branchType();
    147 
    148     /* Cache new update data: */
    149     m_pCache->cacheCurrentData(newUpdateData);
     94    /* Cache new data: */
     95    newData.m_guiUpdateData = m_pEditorUpdateSettings->value();
     96    m_pCache->cacheCurrentData(newData);
    15097}
    15198
     
    155102    UISettingsPageGlobal::fetchData(data);
    156103
    157     /* Update update data and failing state: */
    158     setFailed(!saveUpdateData());
     104    /* Update data and failing state: */
     105    setFailed(!saveData());
    159106
    160107    /* Upload properties to data: */
     
    162109}
    163110
    164 void UIGlobalSettingsUpdate::setOrderAfter(QWidget *pWidget)
    165 {
    166     /* Configure navigation: */
    167     setTabOrder(pWidget, m_pCheckBoxUpdate);
    168     setTabOrder(m_pCheckBoxUpdate, m_pComboUpdatePeriod);
    169     setTabOrder(m_pComboUpdatePeriod, m_pRadioUpdateFilterStable);
    170     setTabOrder(m_pRadioUpdateFilterStable, m_pRadioUpdateFilterEvery);
    171     setTabOrder(m_pRadioUpdateFilterEvery, m_pRadioUpdateFilterBetas);
    172 }
    173 
    174111void UIGlobalSettingsUpdate::retranslateUi()
    175112{
    176     m_pCheckBoxUpdate->setWhatsThis(tr("When checked, the application will "
    177                                        "periodically connect to the VirtualBox website and check whether a "
    178                                        "new VirtualBox version is available."));
    179     m_pCheckBoxUpdate->setText(tr("&Check for Updates"));
    180     m_pLabelUpdatePeriod->setText(tr("&Once per:"));
    181     m_pComboUpdatePeriod->setWhatsThis(tr("Selects how often the new version "
    182                                              "check should be performed. Note that if you want to completely "
    183                                              "disable this check, just clear the above check box."));
    184     m_pLabelUpdateDate->setText(tr("Next Check:"));
    185     m_pLabelUpdateFilter->setText(tr("Check for:"));
    186     m_pRadioUpdateFilterStable->setWhatsThis(tr("<p>Choose this if you only wish to "
    187                                                 "be notified about stable updates to VirtualBox.</p>"));
    188     m_pRadioUpdateFilterStable->setText(tr("&Stable Release Versions"));
    189     m_pRadioUpdateFilterEvery->setWhatsThis(tr("<p>Choose this if you wish to be "
    190                                                "notified about all new VirtualBox releases.</p>"));
    191     m_pRadioUpdateFilterEvery->setText(tr("&All New Releases"));
    192     m_pRadioUpdateFilterBetas->setWhatsThis(tr("<p>Choose this to be notified about "
    193                                                "all new VirtualBox releases and pre-release versions of VirtualBox.</p>"));
    194     m_pRadioUpdateFilterBetas->setText(tr("All New Releases and &Pre-Releases"));
    195 
    196     /* Retranslate m_pComboUpdatePeriod combobox: */
    197     int iCurrenIndex = m_pComboUpdatePeriod->currentIndex();
    198     m_pComboUpdatePeriod->clear();
    199     VBoxUpdateData::populate();
    200     m_pComboUpdatePeriod->insertItems(0, VBoxUpdateData::list());
    201     m_pComboUpdatePeriod->setCurrentIndex(iCurrenIndex == -1 ? 0 : iCurrenIndex);
    202 }
    203 
    204 void UIGlobalSettingsUpdate::sltHandleUpdateToggle(bool fEnabled)
    205 {
    206     /* Update activity status: */
    207     m_pWidgetUpdateSettings->setEnabled(fEnabled);
    208 
    209     /* Update time of next check: */
    210     sltHandleUpdatePeriodChange();
    211 
    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);
    218 }
    219 
    220 void UIGlobalSettingsUpdate::sltHandleUpdatePeriodChange()
    221 {
    222     const VBoxUpdateData data(periodType(), branchType());
    223     m_pFieldUpdateDate->setText(data.date());
    224113}
    225114
     
    232121    /* Prepare everything: */
    233122    prepareWidgets();
    234     prepareConnections();
    235123
    236124    /* Apply language settings: */
     
    241129{
    242130    /* Prepare main layout: */
    243     QGridLayout *pLayoutMain = new QGridLayout(this);
     131    QVBoxLayout *pLayoutMain = new QVBoxLayout(this);
    244132    if (pLayoutMain)
    245133    {
    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 'update to stable' radio-button: */
    309                 m_pRadioUpdateFilterStable = new QRadioButton(m_pWidgetUpdateSettings);
    310                 if (m_pRadioUpdateFilterStable)
    311                     pLayoutUpdateSettings->addWidget(m_pRadioUpdateFilterStable, 2, 1);
    312                 /* Prepare 'update to every' radio-button: */
    313                 m_pRadioUpdateFilterEvery = new QRadioButton(m_pWidgetUpdateSettings);
    314                 if (m_pRadioUpdateFilterEvery)
    315                     pLayoutUpdateSettings->addWidget(m_pRadioUpdateFilterEvery, 3, 1);
    316                 /* Prepare 'update to 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         }
     134        /* Prepare update settings editor: */
     135        m_pEditorUpdateSettings = new UIUpdateSettingsEditor(this);
     136        if (m_pEditorUpdateSettings)
     137            pLayoutMain->addWidget(m_pEditorUpdateSettings);
    324138    }
    325 }
    326 
    327 void 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);
    332139}
    333140
     
    339146}
    340147
    341 VBoxUpdateData::PeriodType UIGlobalSettingsUpdate::periodType() const
    342 {
    343     const VBoxUpdateData::PeriodType result = m_pCheckBoxUpdate->isChecked() ?
    344         (VBoxUpdateData::PeriodType)m_pComboUpdatePeriod->currentIndex() : VBoxUpdateData::PeriodNever;
    345     return result == VBoxUpdateData::PeriodUndefined ? VBoxUpdateData::Period1Day : result;
    346 }
    347 
    348 VBoxUpdateData::BranchType UIGlobalSettingsUpdate::branchType() const
    349 {
    350     if (m_pRadioUpdateFilterBetas->isChecked())
    351         return VBoxUpdateData::BranchWithBetas;
    352     else if (m_pRadioUpdateFilterEvery->isChecked())
    353         return VBoxUpdateData::BranchAllRelease;
    354     else
    355         return VBoxUpdateData::BranchStable;
    356 }
    357 
    358 bool UIGlobalSettingsUpdate::saveUpdateData()
     148bool UIGlobalSettingsUpdate::saveData()
    359149{
    360150    /* Prepare result: */
    361151    bool fSuccess = true;
    362     /* Save update settings from the cache: */
     152    /* Save update settings from cache: */
    363153    if (fSuccess && m_pCache->wasChanged())
    364154    {
    365         /* Get old update data from the cache: */
    366         //const UIDataSettingsGlobalUpdate &oldUpdateData = m_pCache->base();
    367         /* Get new update data from the cache: */
    368         const UIDataSettingsGlobalUpdate &newUpdateData = m_pCache->data();
     155        /* Get old data from cache: */
     156        const UIDataSettingsGlobalUpdate &oldData = m_pCache->base();
     157        /* Get new data from cache: */
     158        const UIDataSettingsGlobalUpdate &newData = m_pCache->data();
    369159
    370         /* Save new update data from the cache: */
    371         const VBoxUpdateData newData(newUpdateData.m_periodIndex, newUpdateData.m_branchIndex);
    372         gEDataManager->setApplicationUpdateData(newData.data());
     160        /* Save new data from cache: */
     161        if (   fSuccess
     162            && newData != oldData)
     163            gEDataManager->setApplicationUpdateData(newData.m_guiUpdateData.data());
    373164    }
    374165    /* Return result: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsUpdate.h

    r86095 r86128  
    2727
    2828/* Forward declarations: */
    29 class QCheckBox;
    30 class QComboBox;
    31 class QLabel;
    32 class QRadioButton;
     29class UIUpdateSettingsEditor;
    3330struct UIDataSettingsGlobalUpdate;
    3431typedef UISettingsCache<UIDataSettingsGlobalUpdate> UISettingsCacheGlobalUpdate;
     
    4138public:
    4239
    43     /** Constructs Update settings page. */
     40    /** Constructs settings page. */
    4441    UIGlobalSettingsUpdate();
    45     /** Destructs Update settings page. */
    46     ~UIGlobalSettingsUpdate();
     42    /** Destructs settings page. */
     43    virtual ~UIGlobalSettingsUpdate() /* override */;
    4744
    4845protected:
     
    6259    virtual void saveFromCacheTo(QVariant &data) /* overrride */;
    6360
    64     /** Defines TAB order for passed @a pWidget. */
    65     virtual void setOrderAfter(QWidget *pWidget) /* override */;
    66 
    6761    /** Handles translation event. */
    6862    virtual void retranslateUi() /* override */;
    69 
    70 private slots:
    71 
    72     /** Handles whether update is @a fEnabled. */
    73     void sltHandleUpdateToggle(bool fEnabled);
    74     /** Handles update period change. */
    75     void sltHandleUpdatePeriodChange();
    7663
    7764private:
     
    8168    /** Prepares widgets. */
    8269    void prepareWidgets();
    83     /** Prepares connections. */
    84     void prepareConnections();
    8570    /** Cleanups all. */
    8671    void cleanup();
    8772
    88     /** Returns period type. */
    89     VBoxUpdateData::PeriodType periodType() const;
    90     /** Returns branch type. */
    91     VBoxUpdateData::BranchType branchType() const;
    92 
    93     /** Saves existing update data from the cache. */
    94     bool saveUpdateData();
     73    /** Saves existing data from cache. */
     74    bool saveData();
    9575
    9676    /** Holds the page data cache instance. */
     
    9979    /** @name Widgets
    10080     * @{ */
    101         /** Holds the update check-box instance. */
    102         QCheckBox    *m_pCheckBoxUpdate;
    103         /** Holds the update settings widget instance. */
    104         QWidget      *m_pWidgetUpdateSettings;
    105         /** Holds the update period label instance. */
    106         QLabel       *m_pLabelUpdatePeriod;
    107         /** Holds the update period combo instance. */
    108         QComboBox    *m_pComboUpdatePeriod;
    109         /** Holds the update date label instance. */
    110         QLabel       *m_pLabelUpdateDate;
    111         /** Holds the update date field instance. */
    112         QLabel       *m_pFieldUpdateDate;
    113         /** Holds the update filter label instance. */
    114         QLabel       *m_pLabelUpdateFilter;
    115         /** Holds the 'update to stable' radio-button instance. */
    116         QRadioButton *m_pRadioUpdateFilterStable;
    117         /** Holds the 'update to every' radio-button instance. */
    118         QRadioButton *m_pRadioUpdateFilterEvery;
    119         /** Holds the 'update to betas' radio-button instance. */
    120         QRadioButton *m_pRadioUpdateFilterBetas;
     81        /** Holds the update settings editor instance. */
     82        UIUpdateSettingsEditor *m_pEditorUpdateSettings;
    12183    /** @} */
    12284};
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