Changeset 85982 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Sep 1, 2020 4:51:27 PM (4 years ago)
- 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 69 69 70 70 UIGlobalSettingsUpdate::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) 77 72 , 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) 79 81 , m_pRadioUpdateFilterBetas(0) 80 , m_pRadioUpdateFilterEvery(0)81 , m_pRadioUpdateFilterStable(0)82 , m_pContainerUpdate(0)83 82 { 84 83 /* Prepare: */ … … 126 125 if (m_pCheckBoxUpdate->isChecked()) 127 126 { 128 m_pCombo BoxUpdatePeriod->setCurrentIndex(oldUpdateData.m_periodIndex);127 m_pComboUpdatePeriod->setCurrentIndex(oldUpdateData.m_periodIndex); 129 128 if (oldUpdateData.m_branchIndex == VBoxUpdateData::BranchWithBetas) 130 129 m_pRadioUpdateFilterBetas->setChecked(true); … … 134 133 m_pRadioUpdateFilterStable->setChecked(true); 135 134 } 136 m_p UpdateDateText->setText(oldUpdateData.m_strDate);135 m_pFieldUpdateDate->setText(oldUpdateData.m_strDate); 137 136 sltHandleUpdateToggle(oldUpdateData.m_fCheckEnabled); 138 137 } … … 167 166 /* Configure navigation: */ 168 167 setTabOrder(pWidget, m_pCheckBoxUpdate); 169 setTabOrder(m_pCheckBoxUpdate, m_pCombo BoxUpdatePeriod);170 setTabOrder(m_pCombo BoxUpdatePeriod, m_pRadioUpdateFilterStable);168 setTabOrder(m_pCheckBoxUpdate, m_pComboUpdatePeriod); 169 setTabOrder(m_pComboUpdatePeriod, m_pRadioUpdateFilterStable); 171 170 setTabOrder(m_pRadioUpdateFilterStable, m_pRadioUpdateFilterEvery); 172 171 setTabOrder(m_pRadioUpdateFilterEvery, m_pRadioUpdateFilterBetas); … … 179 178 "new VirtualBox version is available.")); 180 179 m_pCheckBoxUpdate->setText(tr("&Check for Updates")); 181 m_p UpdatePeriodLabel->setText(tr("&Once per:"));182 m_pCombo BoxUpdatePeriod->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 " 183 182 "check should be performed. Note that if you want to completely " 184 183 "disable this check, just clear the above check box.")); 185 m_p UpdateDateLabel->setText(tr("Next Check:"));186 m_p UpdateFilterLabel->setText(tr("Check for:"));184 m_pLabelUpdateDate->setText(tr("Next Check:")); 185 m_pLabelUpdateFilter->setText(tr("Check for:")); 187 186 m_pRadioUpdateFilterStable->setWhatsThis(tr("<p>Choose this if you only wish to " 188 187 "be notified about stable updates to VirtualBox.</p>")); … … 195 194 m_pRadioUpdateFilterBetas->setText(tr("All New Releases and &Pre-Releases")); 196 195 197 /* Retranslate m_pCombo BoxUpdatePeriod combobox: */198 int iCurrenIndex = m_pCombo BoxUpdatePeriod->currentIndex();199 m_pCombo BoxUpdatePeriod->clear();196 /* Retranslate m_pComboUpdatePeriod combobox: */ 197 int iCurrenIndex = m_pComboUpdatePeriod->currentIndex(); 198 m_pComboUpdatePeriod->clear(); 200 199 VBoxUpdateData::populate(); 201 m_pCombo BoxUpdatePeriod->insertItems(0, VBoxUpdateData::list());202 m_pCombo BoxUpdatePeriod->setCurrentIndex(iCurrenIndex == -1 ? 0 : iCurrenIndex);200 m_pComboUpdatePeriod->insertItems(0, VBoxUpdateData::list()); 201 m_pComboUpdatePeriod->setCurrentIndex(iCurrenIndex == -1 ? 0 : iCurrenIndex); 203 202 } 204 203 … … 206 205 { 207 206 /* Update activity status: */ 208 m_p ContainerUpdate->setEnabled(fEnabled);207 m_pWidgetUpdateSettings->setEnabled(fEnabled); 209 208 210 209 /* Update time of next check: */ 211 210 sltHandleUpdatePeriodChange(); 212 211 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); 223 218 } 224 219 … … 226 221 { 227 222 const VBoxUpdateData data(periodType(), branchType()); 228 m_p UpdateDateText->setText(data.date());223 m_pFieldUpdateDate->setText(data.date()); 229 224 } 230 225 231 226 void UIGlobalSettingsUpdate::prepare() 232 227 { 233 prepareWidgets();234 235 228 /* Prepare cache: */ 236 229 m_pCache = new UISettingsCacheGlobalUpdate; 237 230 AssertPtrReturnVoid(m_pCache); 238 231 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(); 248 235 249 236 /* Apply language settings: */ … … 253 240 void UIGlobalSettingsUpdate::prepareWidgets() 254 241 { 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 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); 326 332 } 327 333 … … 336 342 { 337 343 const VBoxUpdateData::PeriodType result = m_pCheckBoxUpdate->isChecked() ? 338 (VBoxUpdateData::PeriodType)m_pCombo BoxUpdatePeriod->currentIndex() : VBoxUpdateData::PeriodNever;344 (VBoxUpdateData::PeriodType)m_pComboUpdatePeriod->currentIndex() : VBoxUpdateData::PeriodNever; 339 345 return result == VBoxUpdateData::PeriodUndefined ? VBoxUpdateData::Period1Day : result; 340 346 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsUpdate.h
r85800 r85982 81 81 /** Prepares widgets. */ 82 82 void prepareWidgets(); 83 /** Prepares connections. */ 84 void prepareConnections(); 83 85 /** Cleanups all. */ 84 86 void cleanup(); … … 92 94 bool saveUpdateData(); 93 95 94 /** Holds the last checked button reference. */95 QRadioButton *m_pLastChosenRadio;96 97 96 /** Holds the page data cache instance. */ 98 97 UISettingsCacheGlobalUpdate *m_pCache; … … 100 99 /** @name Widgets 101 100 * @{ */ 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; 112 111 /** @} */ 113 112 };
Note:
See TracChangeset
for help on using the changeset viewer.