[55282] | 1 | /* $Id: UISettingsSerializer.cpp 104313 2024-04-12 13:10:30Z vboxsync $ */
|
---|
[55281] | 2 | /** @file
|
---|
[54886] | 3 | * VBox Qt GUI - UISettingsSerializer class implementation.
|
---|
[25177] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
[25177] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
| 25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
[25177] | 26 | */
|
---|
| 27 |
|
---|
[41587] | 28 | /* Qt includes: */
|
---|
[104313] | 29 | #include <QCloseEvent>
|
---|
[76606] | 30 | #include <QHBoxLayout>
|
---|
| 31 | #include <QLabel>
|
---|
| 32 | #include <QProgressBar>
|
---|
| 33 | #include <QTimer>
|
---|
| 34 | #include <QVBoxLayout>
|
---|
[72106] | 35 |
|
---|
[41587] | 36 | /* GUI includes: */
|
---|
[76606] | 37 | #include "QILabel.h"
|
---|
| 38 | #include "UIIconPool.h"
|
---|
| 39 | #include "UIMessageCenter.h"
|
---|
| 40 | #include "UISettingsPage.h"
|
---|
| 41 | #include "UISettingsSerializer.h"
|
---|
[104313] | 42 | #include "UITranslationEventListener.h"
|
---|
[72106] | 43 |
|
---|
[52730] | 44 |
|
---|
[72105] | 45 | /*********************************************************************************************************************************
|
---|
| 46 | * Class UISettingsSerializer implementation. *
|
---|
| 47 | *********************************************************************************************************************************/
|
---|
| 48 |
|
---|
| 49 | UISettingsSerializer::UISettingsSerializer(QObject *pParent, SerializationDirection enmDirection,
|
---|
[54886] | 50 | const QVariant &data, const UISettingsPageList &pages)
|
---|
| 51 | : QThread(pParent)
|
---|
[72105] | 52 | , m_enmDirection(enmDirection)
|
---|
[54886] | 53 | , m_data(data)
|
---|
[72105] | 54 | , m_fSavingComplete(m_enmDirection == Load)
|
---|
[54886] | 55 | , m_iIdOfHighPriorityPage(-1)
|
---|
[25177] | 56 | {
|
---|
[54886] | 57 | /* Copy the page(s) from incoming list to our map: */
|
---|
[54928] | 58 | foreach (UISettingsPage *pPage, pages)
|
---|
[54886] | 59 | m_pages.insert(pPage->id(), pPage);
|
---|
[25177] | 60 |
|
---|
[54923] | 61 | /* Handling internal signals, they are also redirected in their handlers: */
|
---|
[80666] | 62 | connect(this, &UISettingsSerializer::sigNotifyAboutPageProcessed, this, &UISettingsSerializer::sltHandleProcessedPage, Qt::QueuedConnection);
|
---|
| 63 | connect(this, &UISettingsSerializer::sigNotifyAboutPagesProcessed, this, &UISettingsSerializer::sltHandleProcessedPages, Qt::QueuedConnection);
|
---|
[54923] | 64 |
|
---|
| 65 | /* Redirecting unhandled internal signals: */
|
---|
[80666] | 66 | connect(this, &UISettingsSerializer::finished, this, &UISettingsSerializer::sigNotifyAboutProcessFinished, Qt::QueuedConnection);
|
---|
[25177] | 67 | }
|
---|
| 68 |
|
---|
[54886] | 69 | UISettingsSerializer::~UISettingsSerializer()
|
---|
[41042] | 70 | {
|
---|
[54886] | 71 | /* If serializer is being destructed by it's parent,
|
---|
| 72 | * thread could still be running, we have to wait
|
---|
| 73 | * for it to be finished! */
|
---|
| 74 | if (isRunning())
|
---|
| 75 | wait();
|
---|
[25177] | 76 | }
|
---|
| 77 |
|
---|
[54886] | 78 | void UISettingsSerializer::raisePriorityOfPage(int iPageId)
|
---|
[25177] | 79 | {
|
---|
[54886] | 80 | /* If that page is present and was not processed already =>
|
---|
| 81 | * we should remember which page should be processed next: */
|
---|
| 82 | if (m_pages.contains(iPageId) && !(m_pages[iPageId]->processed()))
|
---|
| 83 | m_iIdOfHighPriorityPage = iPageId;
|
---|
[25177] | 84 | }
|
---|
| 85 |
|
---|
[54886] | 86 | void UISettingsSerializer::start(Priority priority /* = InheritPriority */)
|
---|
[25177] | 87 | {
|
---|
[54886] | 88 | /* Notify listeners about we are starting: */
|
---|
| 89 | emit sigNotifyAboutProcessStarted();
|
---|
[25177] | 90 |
|
---|
[54886] | 91 | /* If serializer saves settings: */
|
---|
[72105] | 92 | if (m_enmDirection == Save)
|
---|
[25177] | 93 | {
|
---|
[54886] | 94 | /* We should update internal page cache first: */
|
---|
| 95 | foreach (UISettingsPage *pPage, m_pages.values())
|
---|
| 96 | pPage->putToCache();
|
---|
[25177] | 97 | }
|
---|
| 98 |
|
---|
[54886] | 99 | /* Start async serializing thread: */
|
---|
| 100 | QThread::start(priority);
|
---|
[25177] | 101 | }
|
---|
| 102 |
|
---|
[54886] | 103 | void UISettingsSerializer::sltHandleProcessedPage(int iPageId)
|
---|
[41042] | 104 | {
|
---|
[55655] | 105 | /* Make sure such page present: */
|
---|
| 106 | AssertReturnVoid(m_pages.contains(iPageId));
|
---|
| 107 |
|
---|
| 108 | /* Get the page being processed: */
|
---|
| 109 | UISettingsPage *pSettingsPage = m_pages.value(iPageId);
|
---|
| 110 |
|
---|
[54886] | 111 | /* If serializer loads settings: */
|
---|
[72105] | 112 | if (m_enmDirection == Load)
|
---|
[34735] | 113 | {
|
---|
[55655] | 114 | /* We should fetch internal page cache: */
|
---|
| 115 | pSettingsPage->setValidatorBlocked(true);
|
---|
| 116 | pSettingsPage->getFromCache();
|
---|
| 117 | pSettingsPage->setValidatorBlocked(false);
|
---|
[34735] | 118 | }
|
---|
[55655] | 119 |
|
---|
| 120 | /* Add processed page into corresponding map: */
|
---|
| 121 | m_pagesDone.insert(iPageId, pSettingsPage);
|
---|
| 122 |
|
---|
| 123 | /* Notify listeners about process reached n%: */
|
---|
| 124 | const int iValue = 100 * m_pagesDone.size() / m_pages.size();
|
---|
| 125 | emit sigNotifyAboutProcessProgressChanged(iValue);
|
---|
[25177] | 126 | }
|
---|
| 127 |
|
---|
[54886] | 128 | void UISettingsSerializer::sltHandleProcessedPages()
|
---|
[25177] | 129 | {
|
---|
[54886] | 130 | /* If serializer saves settings: */
|
---|
[72105] | 131 | if (m_enmDirection == Save)
|
---|
[25177] | 132 | {
|
---|
[54886] | 133 | /* We should flag GUI thread to unlock itself: */
|
---|
| 134 | if (!m_fSavingComplete)
|
---|
| 135 | m_fSavingComplete = true;
|
---|
[47559] | 136 | }
|
---|
[54886] | 137 | /* If serializer loads settings: */
|
---|
| 138 | else
|
---|
[37109] | 139 | {
|
---|
[54886] | 140 | /* We have to do initial validation finally: */
|
---|
| 141 | foreach (UISettingsPage *pPage, m_pages.values())
|
---|
| 142 | pPage->revalidate();
|
---|
[37109] | 143 | }
|
---|
[55655] | 144 |
|
---|
| 145 | /* Notify listeners about process reached 100%: */
|
---|
| 146 | emit sigNotifyAboutProcessProgressChanged(100);
|
---|
[37109] | 147 | }
|
---|
| 148 |
|
---|
[54886] | 149 | void UISettingsSerializer::run()
|
---|
[37109] | 150 | {
|
---|
[54886] | 151 | /* Initialize COM for other thread: */
|
---|
| 152 | COMBase::InitializeCOM(false);
|
---|
[37109] | 153 |
|
---|
[54886] | 154 | /* Mark all the pages initially as NOT processed: */
|
---|
| 155 | foreach (UISettingsPage *pPage, m_pages.values())
|
---|
| 156 | pPage->setProcessed(false);
|
---|
[37109] | 157 |
|
---|
[54886] | 158 | /* Iterate over the all left settings pages: */
|
---|
| 159 | UISettingsPageMap pages(m_pages);
|
---|
| 160 | while (!pages.empty())
|
---|
[25177] | 161 | {
|
---|
[54886] | 162 | /* Get required page pointer, protect map by mutex while getting pointer: */
|
---|
| 163 | UISettingsPage *pPage = m_iIdOfHighPriorityPage != -1 && pages.contains(m_iIdOfHighPriorityPage) ?
|
---|
| 164 | pages.value(m_iIdOfHighPriorityPage) : *pages.begin();
|
---|
| 165 | /* Reset request of high priority: */
|
---|
| 166 | if (m_iIdOfHighPriorityPage != -1)
|
---|
| 167 | m_iIdOfHighPriorityPage = -1;
|
---|
| 168 | /* Process this page if its enabled: */
|
---|
[80666] | 169 | connect(pPage, &UISettingsPage::sigOperationProgressChange,
|
---|
| 170 | this, &UISettingsSerializer::sigOperationProgressChange);
|
---|
| 171 | connect(pPage, &UISettingsPage::sigOperationProgressError,
|
---|
| 172 | this, &UISettingsSerializer::sigOperationProgressError);
|
---|
[54886] | 173 | if (pPage->isEnabled())
|
---|
[25177] | 174 | {
|
---|
[72105] | 175 | if (m_enmDirection == Load)
|
---|
[54886] | 176 | pPage->loadToCacheFrom(m_data);
|
---|
[72105] | 177 | if (m_enmDirection == Save)
|
---|
[54886] | 178 | pPage->saveFromCacheTo(m_data);
|
---|
[32667] | 179 | }
|
---|
[54886] | 180 | /* Remember what page was processed: */
|
---|
[80666] | 181 | disconnect(pPage, &UISettingsPage::sigOperationProgressChange,
|
---|
| 182 | this, &UISettingsSerializer::sigOperationProgressChange);
|
---|
| 183 | disconnect(pPage, &UISettingsPage::sigOperationProgressError,
|
---|
| 184 | this, &UISettingsSerializer::sigOperationProgressError);
|
---|
[54886] | 185 | pPage->setProcessed(true);
|
---|
| 186 | /* Remove processed page from our map: */
|
---|
| 187 | pages.remove(pPage->id());
|
---|
| 188 | /* Notify listeners about page was processed: */
|
---|
| 189 | emit sigNotifyAboutPageProcessed(pPage->id());
|
---|
| 190 | /* If serializer saves settings => wake up GUI thread: */
|
---|
[72105] | 191 | if (m_enmDirection == Save)
|
---|
[54886] | 192 | m_condition.wakeAll();
|
---|
| 193 | /* Break further processing if page had failed: */
|
---|
| 194 | if (pPage->failed())
|
---|
[25177] | 195 | break;
|
---|
| 196 | }
|
---|
[54886] | 197 | /* Notify listeners about all pages were processed: */
|
---|
| 198 | emit sigNotifyAboutPagesProcessed();
|
---|
| 199 | /* If serializer saves settings => wake up GUI thread: */
|
---|
[72105] | 200 | if (m_enmDirection == Save)
|
---|
[54886] | 201 | m_condition.wakeAll();
|
---|
[25177] | 202 |
|
---|
[54886] | 203 | /* Deinitialize COM for other thread: */
|
---|
| 204 | COMBase::CleanupCOM();
|
---|
[37143] | 205 | }
|
---|
| 206 |
|
---|
[55279] | 207 |
|
---|
[72105] | 208 | /*********************************************************************************************************************************
|
---|
| 209 | * Class UISettingsSerializerProgress implementation. *
|
---|
| 210 | *********************************************************************************************************************************/
|
---|
| 211 |
|
---|
| 212 | QString UISettingsSerializerProgress::s_strProgressDescriptionTemplate = QString("<compact elipsis=\"middle\">%1 (%2/%3)</compact>");
|
---|
| 213 |
|
---|
[72106] | 214 | UISettingsSerializerProgress::UISettingsSerializerProgress(QWidget *pParent,
|
---|
| 215 | UISettingsSerializer::SerializationDirection enmDirection,
|
---|
| 216 | const QVariant &data,
|
---|
| 217 | const UISettingsPageList &pages)
|
---|
[104313] | 218 | : QIDialog(pParent)
|
---|
[72105] | 219 | , m_enmDirection(enmDirection)
|
---|
[54928] | 220 | , m_data(data)
|
---|
| 221 | , m_pages(pages)
|
---|
[54936] | 222 | , m_pSerializer(0)
|
---|
[55276] | 223 | , m_pLabelOperationProgress(0)
|
---|
| 224 | , m_pBarOperationProgress(0)
|
---|
[55279] | 225 | , m_pLabelSubOperationProgress(0)
|
---|
| 226 | , m_pBarSubOperationProgress(0)
|
---|
[65600] | 227 | , m_fClean(true)
|
---|
[54928] | 228 | {
|
---|
| 229 | /* Prepare: */
|
---|
| 230 | prepare();
|
---|
| 231 | /* Translate: */
|
---|
[104313] | 232 | sltRetranslateUI();
|
---|
| 233 | connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
|
---|
| 234 | this, &UISettingsSerializerProgress::sltRetranslateUI);
|
---|
[54928] | 235 | }
|
---|
| 236 |
|
---|
| 237 | int UISettingsSerializerProgress::exec()
|
---|
| 238 | {
|
---|
[54952] | 239 | /* Ask for process start: */
|
---|
| 240 | emit sigAskForProcessStart();
|
---|
[54928] | 241 |
|
---|
| 242 | /* Call to base-class: */
|
---|
[104313] | 243 | return QIDialog::exec();
|
---|
[54928] | 244 | }
|
---|
| 245 |
|
---|
[72105] | 246 | QVariant &UISettingsSerializerProgress::data()
|
---|
[54928] | 247 | {
|
---|
| 248 | AssertPtrReturn(m_pSerializer, m_data);
|
---|
| 249 | return m_pSerializer->data();
|
---|
| 250 | }
|
---|
| 251 |
|
---|
| 252 | void UISettingsSerializerProgress::prepare()
|
---|
| 253 | {
|
---|
[54936] | 254 | /* Configure self: */
|
---|
| 255 | setWindowModality(Qt::WindowModal);
|
---|
[55263] | 256 | setWindowTitle(parentWidget()->windowTitle());
|
---|
[80666] | 257 | connect(this, &UISettingsSerializerProgress::sigAskForProcessStart,
|
---|
| 258 | this, &UISettingsSerializerProgress::sltStartProcess, Qt::QueuedConnection);
|
---|
[54936] | 259 |
|
---|
[54928] | 260 | /* Create serializer: */
|
---|
[72105] | 261 | m_pSerializer = new UISettingsSerializer(this, m_enmDirection, m_data, m_pages);
|
---|
[54928] | 262 | AssertPtrReturnVoid(m_pSerializer);
|
---|
| 263 | {
|
---|
| 264 | /* Install progress handler: */
|
---|
[80666] | 265 | connect(m_pSerializer, &UISettingsSerializer::sigNotifyAboutProcessProgressChanged,
|
---|
| 266 | this, &UISettingsSerializerProgress::sltHandleProcessProgressChange);
|
---|
| 267 | connect(m_pSerializer, &UISettingsSerializer::sigOperationProgressChange,
|
---|
| 268 | this, &UISettingsSerializerProgress::sltHandleOperationProgressChange);
|
---|
| 269 | connect(m_pSerializer, &UISettingsSerializer::sigOperationProgressError,
|
---|
| 270 | this, &UISettingsSerializerProgress::sltHandleOperationProgressError);
|
---|
[54928] | 271 | }
|
---|
| 272 |
|
---|
[55263] | 273 | /* Create layout: */
|
---|
| 274 | QVBoxLayout *pLayout = new QVBoxLayout(this);
|
---|
| 275 | AssertPtrReturnVoid(pLayout);
|
---|
| 276 | {
|
---|
| 277 | /* Create top layout: */
|
---|
| 278 | QHBoxLayout *pLayoutTop = new QHBoxLayout;
|
---|
| 279 | AssertPtrReturnVoid(pLayoutTop);
|
---|
| 280 | {
|
---|
[55276] | 281 | /* Create pixmap layout: */
|
---|
| 282 | QVBoxLayout *pLayoutPixmap = new QVBoxLayout;
|
---|
| 283 | AssertPtrReturnVoid(pLayoutPixmap);
|
---|
[55263] | 284 | {
|
---|
[55276] | 285 | /* Create pixmap label: */
|
---|
| 286 | QLabel *pLabelPixmap = new QLabel;
|
---|
| 287 | AssertPtrReturnVoid(pLabelPixmap);
|
---|
| 288 | {
|
---|
| 289 | /* Configure label: */
|
---|
| 290 | const QIcon icon = UIIconPool::iconSet(":/progress_settings_90px.png");
|
---|
[71006] | 291 | pLabelPixmap->setPixmap(icon.pixmap(icon.availableSizes().value(0, QSize(90, 90))));
|
---|
[55276] | 292 | /* Add label into layout: */
|
---|
| 293 | pLayoutPixmap->addWidget(pLabelPixmap);
|
---|
| 294 | }
|
---|
| 295 | /* Add stretch: */
|
---|
| 296 | pLayoutPixmap->addStretch();
|
---|
| 297 | /* Add layout into parent: */
|
---|
| 298 | pLayoutTop->addLayout(pLayoutPixmap);
|
---|
[55263] | 299 | }
|
---|
| 300 | /* Create progress layout: */
|
---|
[55276] | 301 | QVBoxLayout *pLayoutProgress = new QVBoxLayout;
|
---|
[55263] | 302 | AssertPtrReturnVoid(pLayoutProgress);
|
---|
| 303 | {
|
---|
[55276] | 304 | /* Create operation progress label: */
|
---|
| 305 | m_pLabelOperationProgress = new QLabel;
|
---|
| 306 | AssertPtrReturnVoid(m_pLabelOperationProgress);
|
---|
[55263] | 307 | {
|
---|
| 308 | /* Add label into layout: */
|
---|
[55276] | 309 | pLayoutProgress->addWidget(m_pLabelOperationProgress);
|
---|
[55263] | 310 | }
|
---|
[55276] | 311 | /* Create operation progress bar: */
|
---|
| 312 | m_pBarOperationProgress = new QProgressBar;
|
---|
| 313 | AssertPtrReturnVoid(m_pBarOperationProgress);
|
---|
[55263] | 314 | {
|
---|
| 315 | /* Configure progress bar: */
|
---|
[55276] | 316 | m_pBarOperationProgress->setMinimumWidth(300);
|
---|
[55655] | 317 | m_pBarOperationProgress->setMaximum(100);
|
---|
[55276] | 318 | m_pBarOperationProgress->setMinimum(0);
|
---|
| 319 | m_pBarOperationProgress->setValue(0);
|
---|
[55263] | 320 | /* Add bar into layout: */
|
---|
[55276] | 321 | pLayoutProgress->addWidget(m_pBarOperationProgress);
|
---|
[55263] | 322 | }
|
---|
[55279] | 323 | /* Create sub-operation progress label: */
|
---|
| 324 | m_pLabelSubOperationProgress = new QILabel;
|
---|
| 325 | AssertPtrReturnVoid(m_pLabelSubOperationProgress);
|
---|
| 326 | {
|
---|
| 327 | /* Configure label: */
|
---|
| 328 | m_pLabelSubOperationProgress->hide();
|
---|
| 329 | m_pLabelSubOperationProgress->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed));
|
---|
| 330 | /* Add label into layout: */
|
---|
| 331 | pLayoutProgress->addWidget(m_pLabelSubOperationProgress);
|
---|
| 332 | }
|
---|
| 333 | /* Create sub-operation progress bar: */
|
---|
| 334 | m_pBarSubOperationProgress = new QProgressBar;
|
---|
| 335 | AssertPtrReturnVoid(m_pBarSubOperationProgress);
|
---|
| 336 | {
|
---|
| 337 | /* Configure progress bar: */
|
---|
| 338 | m_pBarSubOperationProgress->hide();
|
---|
| 339 | m_pBarSubOperationProgress->setMinimumWidth(300);
|
---|
| 340 | m_pBarSubOperationProgress->setMaximum(100);
|
---|
| 341 | m_pBarSubOperationProgress->setMinimum(0);
|
---|
| 342 | m_pBarSubOperationProgress->setValue(0);
|
---|
| 343 | /* Add bar into layout: */
|
---|
| 344 | pLayoutProgress->addWidget(m_pBarSubOperationProgress);
|
---|
| 345 | }
|
---|
[55263] | 346 | /* Add stretch: */
|
---|
| 347 | pLayoutProgress->addStretch();
|
---|
| 348 | /* Add layout into parent: */
|
---|
| 349 | pLayoutTop->addLayout(pLayoutProgress);
|
---|
| 350 | }
|
---|
| 351 | /* Add layout into parent: */
|
---|
| 352 | pLayout->addLayout(pLayoutTop);
|
---|
| 353 | }
|
---|
| 354 | }
|
---|
[54928] | 355 | }
|
---|
| 356 |
|
---|
[104313] | 357 | void UISettingsSerializerProgress::sltRetranslateUI()
|
---|
[54928] | 358 | {
|
---|
[55276] | 359 | /* Translate operation progress label: */
|
---|
| 360 | AssertPtrReturnVoid(m_pLabelOperationProgress);
|
---|
[54928] | 361 | switch (m_pSerializer->direction())
|
---|
| 362 | {
|
---|
[55276] | 363 | case UISettingsSerializer::Load: m_pLabelOperationProgress->setText(tr("Loading Settings...")); break;
|
---|
| 364 | case UISettingsSerializer::Save: m_pLabelOperationProgress->setText(tr("Saving Settings...")); break;
|
---|
[54928] | 365 | }
|
---|
| 366 | }
|
---|
| 367 |
|
---|
[54954] | 368 | void UISettingsSerializerProgress::closeEvent(QCloseEvent *pEvent)
|
---|
| 369 | {
|
---|
| 370 | /* No need to close the dialog: */
|
---|
| 371 | pEvent->ignore();
|
---|
| 372 | }
|
---|
| 373 |
|
---|
| 374 | void UISettingsSerializerProgress::reject()
|
---|
| 375 | {
|
---|
| 376 | /* No need to reject the dialog. */
|
---|
| 377 | }
|
---|
| 378 |
|
---|
[54952] | 379 | void UISettingsSerializerProgress::sltStartProcess()
|
---|
| 380 | {
|
---|
| 381 | /* Start the serializer: */
|
---|
| 382 | m_pSerializer->start();
|
---|
| 383 | }
|
---|
| 384 |
|
---|
[55655] | 385 | void UISettingsSerializerProgress::sltHandleProcessProgressChange(int iValue)
|
---|
[55263] | 386 | {
|
---|
[55655] | 387 | /* Update the operation progress-bar with incoming value: */
|
---|
[55276] | 388 | AssertPtrReturnVoid(m_pBarOperationProgress);
|
---|
[55655] | 389 | m_pBarOperationProgress->setValue(iValue);
|
---|
[55279] | 390 | /* Hide the progress-dialog upon reaching the 100% progress: */
|
---|
[55276] | 391 | if (iValue == m_pBarOperationProgress->maximum())
|
---|
[55263] | 392 | hide();
|
---|
| 393 | }
|
---|
| 394 |
|
---|
[55279] | 395 | void UISettingsSerializerProgress::sltHandleOperationProgressChange(ulong iOperations, QString strOperation,
|
---|
| 396 | ulong iOperation, ulong iPercent)
|
---|
| 397 | {
|
---|
| 398 | /* Update the sub-operation progress label and bar: */
|
---|
| 399 | AssertPtrReturnVoid(m_pLabelSubOperationProgress);
|
---|
| 400 | AssertPtrReturnVoid(m_pBarSubOperationProgress);
|
---|
| 401 | m_pLabelSubOperationProgress->show();
|
---|
| 402 | m_pBarSubOperationProgress->show();
|
---|
[72105] | 403 | m_pLabelSubOperationProgress->setText(s_strProgressDescriptionTemplate.arg(strOperation).arg(iOperation).arg(iOperations));
|
---|
[55279] | 404 | m_pBarSubOperationProgress->setValue(iPercent);
|
---|
| 405 | }
|
---|
| 406 |
|
---|
[55305] | 407 | void UISettingsSerializerProgress::sltHandleOperationProgressError(QString strErrorInfo)
|
---|
| 408 | {
|
---|
[65600] | 409 | /* Mark the serialization process dirty: */
|
---|
| 410 | m_fClean = false;
|
---|
| 411 |
|
---|
[55305] | 412 | /* Show the error message: */
|
---|
| 413 | msgCenter().cannotSaveSettings(strErrorInfo, this);
|
---|
| 414 | }
|
---|