Changeset 55655 in vbox
- Timestamp:
- May 5, 2015 11:08:12 AM (9 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings
- Files:
-
- 4 edited
-
UISettingsDialog.cpp (modified) (9 diffs)
-
UISettingsDialog.h (modified) (4 diffs)
-
UISettingsSerializer.cpp (modified) (5 diffs)
-
UISettingsSerializer.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.cpp
r55515 r55655 65 65 /* Loading/saving stuff: */ 66 66 , m_pSerializeProcess(0) 67 , m_pSerializeProgress(0)68 67 , m_fLoaded(false) 69 68 , m_fSaved(false) … … 123 122 /* Prepare process-bar: */ 124 123 m_pProcessBar = new QProgressBar; 124 m_pProcessBar->setMaximum(100); 125 m_pProcessBar->setMinimum(0); 125 126 126 127 /* Prepare warning-pane: */ … … 157 158 m_pSerializeProcess = 0; 158 159 } 159 if (serializeProgress())160 {161 delete m_pSerializeProgress;162 m_pSerializeProgress = 0;163 }164 160 165 161 /* Recall popup-pane if any: */ … … 223 219 m_pSerializeProcess = 0; 224 220 } 225 if (serializeProgress())226 {227 delete m_pSerializeProgress;228 m_pSerializeProgress = 0;229 }230 221 231 222 /* Mark as loaded: */ … … 241 232 m_pSerializeProcess = 0; 242 233 } 243 if (serializeProgress())244 {245 delete m_pSerializeProgress;246 m_pSerializeProgress = 0;247 }248 234 249 235 /* Mark as saved: */ … … 257 243 } 258 244 259 void UISettingsDialog::sltHandleP ageProcessed()260 { 261 m_pProcessBar->setValue( m_pProcessBar->value() + 1);245 void UISettingsDialog::sltHandleProcessProgressChange(int iValue) 246 { 247 m_pProcessBar->setValue(iValue); 262 248 if (m_pProcessBar->value() == m_pProcessBar->maximum()) 263 249 { … … 281 267 /* Configure settings loader: */ 282 268 connect(m_pSerializeProcess, SIGNAL(sigNotifyAboutProcessStarted()), this, SLOT(sltHandleProcessStarted())); 283 connect(m_pSerializeProcess, SIGNAL(sigNotifyAboutP agePostprocessed(int)), this, SLOT(sltHandlePageProcessed()));269 connect(m_pSerializeProcess, SIGNAL(sigNotifyAboutProcessProgressChanged(int)), this, SLOT(sltHandleProcessProgressChange(int))); 284 270 connect(m_pSerializeProcess, SIGNAL(sigNotifyAboutProcessFinished()), this, SLOT(sltMarkLoaded())); 271 285 272 /* Raise current page priority: */ 286 273 m_pSerializeProcess->raisePriorityOfPage(m_pSelector->currentId()); 274 287 275 /* Start settings loader: */ 288 276 m_pSerializeProcess->start(); 289 } 290 291 /* Upload data finally: */292 data = m_pSerializeProcess->data();277 278 /* Upload data finally: */ 279 data = m_pSerializeProcess->data(); 280 } 293 281 } 294 282 … … 298 286 m_fSaved = false; 299 287 300 /* Create settings saver: */ 301 QWidget *pDlgParent = windowManager().realParentWindow(window()); 302 m_pSerializeProgress = new UISettingsSerializerProgress(pDlgParent, UISettingsSerializer::Save, 303 data, m_pSelector->settingPages()); 304 AssertPtrReturnVoid(m_pSerializeProgress); 305 { 306 /* Make setting saver the temporary parent for all the sub-dialogs: */ 307 windowManager().registerNewParent(m_pSerializeProgress, pDlgParent); 308 /* Start settings saver: */ 309 m_pSerializeProgress->exec(); 310 } 311 312 /* Upload data finally: */ 313 data = m_pSerializeProgress->data(); 288 /* Create the 'settings saver': */ 289 QPointer<UISettingsSerializerProgress> pDlgSerializeProgress = 290 new UISettingsSerializerProgress(this, UISettingsSerializer::Save, 291 data, m_pSelector->settingPages()); 292 AssertPtrReturnVoid(static_cast<UISettingsSerializerProgress*>(pDlgSerializeProgress)); 293 { 294 /* Make the 'settings saver' temporary parent for all sub-dialogs: */ 295 windowManager().registerNewParent(pDlgSerializeProgress, windowManager().realParentWindow(this)); 296 297 /* Execute the 'settings saver': */ 298 pDlgSerializeProgress->exec(); 299 300 /* Any modal dialog can be destroyed in own event-loop 301 * as a part of application termination procedure.. 302 * We have to check if the dialog still valid. */ 303 if (pDlgSerializeProgress) 304 { 305 /* Upload 'settings saver' data: */ 306 data = pDlgSerializeProgress->data(); 307 308 /* Delete the 'settings saver': */ 309 delete pDlgSerializeProgress; 310 } 311 } 314 312 } 315 313 … … 364 362 /* Add stack-widget page if created: */ 365 363 m_pages[cId] = m_pStack->addWidget(pPage); 366 /* Update process-bar: */367 m_pProcessBar->setMinimum(0);368 m_pProcessBar->setMaximum(m_pStack->count());369 364 } 370 365 /* Assign validator if necessary: */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.h
r55513 r55655 34 34 class UISettingsPage; 35 35 class UISettingsSerializer; 36 class UISettingsSerializerProgress;37 36 38 37 /* Using declarations: */ … … 68 67 /* Handlers for process bar: */ 69 68 void sltHandleProcessStarted(); 70 void sltHandleP ageProcessed();69 void sltHandleProcessProgressChange(int iValue); 71 70 72 71 protected: … … 74 73 /** Returns the serialize process instance. */ 75 74 UISettingsSerializer* serializeProcess() const { return m_pSerializeProcess; } 76 /** Returns the serialize progress instance. */77 UISettingsSerializerProgress* serializeProgress() const { return m_pSerializeProgress; }78 75 79 76 /** Loads the @a data. */ … … 146 143 /** Holds the serialize process instance. */ 147 144 UISettingsSerializer *m_pSerializeProcess; 148 /** Holds the serialize progress instance. */149 UISettingsSerializerProgress *m_pSerializeProgress;150 145 151 146 /* Loading/saving stuff: */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSerializer.cpp
r55305 r55655 89 89 void UISettingsSerializer::sltHandleProcessedPage(int iPageId) 90 90 { 91 /* Make sure such page present: */ 92 AssertReturnVoid(m_pages.contains(iPageId)); 93 94 /* Get the page being processed: */ 95 UISettingsPage *pSettingsPage = m_pages.value(iPageId); 96 91 97 /* If serializer loads settings: */ 92 98 if (m_direction == Load) 93 99 { 94 /* If such page present: */95 if (m_pages.contains(iPageId))96 {97 /* We should fetch internal page cache: */98 UISettingsPage *pSettingsPage = m_pages[iPageId];99 pSettingsPage->setValidatorBlocked(true); 100 pSettingsPage->getFromCache();101 pSettingsPage->setValidatorBlocked(false);102 } 103 }104 /* Notify listeners about page postprocessed: */105 emit sigNotifyAboutP agePostprocessed(iPageId);100 /* We should fetch internal page cache: */ 101 pSettingsPage->setValidatorBlocked(true); 102 pSettingsPage->getFromCache(); 103 pSettingsPage->setValidatorBlocked(false); 104 } 105 106 /* Add processed page into corresponding map: */ 107 m_pagesDone.insert(iPageId, pSettingsPage); 108 109 /* Notify listeners about process reached n%: */ 110 const int iValue = 100 * m_pagesDone.size() / m_pages.size(); 111 emit sigNotifyAboutProcessProgressChanged(iValue); 106 112 } 107 113 … … 122 128 pPage->revalidate(); 123 129 } 124 /* Notify listeners about pages postprocessed: */ 125 emit sigNotifyAboutPagesPostprocessed(); 130 131 /* Notify listeners about process reached 100%: */ 132 emit sigNotifyAboutProcessProgressChanged(100); 126 133 } 127 134 … … 232 239 { 233 240 /* Install progress handler: */ 234 connect(m_pSerializer, SIGNAL(sigNotifyAboutPagePostprocessed(int)), 235 this, SLOT(sltAdvanceProgressValue())); 236 connect(m_pSerializer, SIGNAL(sigNotifyAboutPagesPostprocessed()), 237 this, SLOT(sltAdvanceProgressValue())); 241 connect(m_pSerializer, SIGNAL(sigNotifyAboutProcessProgressChanged(int)), 242 this, SLOT(sltHandleProcessProgressChange(int))); 238 243 connect(m_pSerializer, SIGNAL(sigOperationProgressChange(ulong, QString, ulong, ulong)), 239 244 this, SLOT(sltHandleOperationProgressChange(ulong, QString, ulong, ulong))); … … 286 291 /* Configure progress bar: */ 287 292 m_pBarOperationProgress->setMinimumWidth(300); 288 m_pBarOperationProgress->setMaximum( m_pSerializer->pageCount() + 1);293 m_pBarOperationProgress->setMaximum(100); 289 294 m_pBarOperationProgress->setMinimum(0); 290 295 m_pBarOperationProgress->setValue(0); 291 connect(m_pBarOperationProgress, SIGNAL(valueChanged(int)),292 this, SLOT(sltProgressValueChanged(int)));293 296 /* Add bar into layout: */ 294 297 pLayoutProgress->addWidget(m_pBarOperationProgress); … … 356 359 } 357 360 358 void UISettingsSerializerProgress::slt AdvanceProgressValue()359 { 360 /* Advance the operation progress bar: */361 void UISettingsSerializerProgress::sltHandleProcessProgressChange(int iValue) 362 { 363 /* Update the operation progress-bar with incoming value: */ 361 364 AssertPtrReturnVoid(m_pBarOperationProgress); 362 m_pBarOperationProgress->setValue(m_pBarOperationProgress->value() + 1); 363 } 364 365 void UISettingsSerializerProgress::sltProgressValueChanged(int iValue) 366 { 365 m_pBarOperationProgress->setValue(iValue); 367 366 /* Hide the progress-dialog upon reaching the 100% progress: */ 368 AssertPtrReturnVoid(m_pBarOperationProgress);369 367 if (iValue == m_pBarOperationProgress->maximum()) 370 368 hide(); -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSerializer.h
r55401 r55655 49 49 signals: 50 50 51 /** Notifies GUI threadabout process has been started. */51 /** Notifies listeners about process has been started. */ 52 52 void sigNotifyAboutProcessStarted(); 53 /** Notifies listeners about process reached @a iValue. */ 54 void sigNotifyAboutProcessProgressChanged(int iValue); 55 /** Notifies listeners about process has been finished. */ 56 void sigNotifyAboutProcessFinished(); 53 57 54 58 /** Notifies GUI thread about some page was processed. */ … … 56 60 /** Notifies GUI thread about all pages were processed. */ 57 61 void sigNotifyAboutPagesProcessed(); 58 59 /** Notifies listeners about some page was post-processed. */60 void sigNotifyAboutPagePostprocessed(int iPageId);61 /** Notifies listeners about all pages were post-processed. */62 void sigNotifyAboutPagesPostprocessed();63 64 /** Notifies listeners about process has been finished. */65 void sigNotifyAboutProcessFinished();66 62 67 63 /** Notifies listeners about particular operation progress change. … … 130 126 /** Holds the page(s) to load/save the data to/from. */ 131 127 UISettingsPageMap m_pages; 128 /** Holds the page(s) to load/save the data to/from for which that task was done. */ 129 UISettingsPageMap m_pagesDone; 132 130 133 131 /** Holds whether the save was complete. */ … … 187 185 void sltStartProcess(); 188 186 189 /** Advances the current progress value. */ 190 void sltAdvanceProgressValue(); 191 192 /** Handles the progress value change. */ 193 void sltProgressValueChanged(int iValue); 187 /** Handles process progress change to @a iValue. */ 188 void sltHandleProcessProgressChange(int iValue); 194 189 195 190 /** Handles particular operation progress change.
Note:
See TracChangeset
for help on using the changeset viewer.

