void UISettingsDialog::sltRevalidate(QIWidgetValidator *pValidator) { /* Get related settings page: */ UISettingsPage *pSettingsPage = qobject_cast<UISettingsPage*>(pValidator->widget()); AssertMsg(pSettingsPage, ("Validator should corresponds a page!\n")); /* Prepare empty warning & title: */ QString strWarning; QString strTitle = m_pSelector->itemTextByPage(pSettingsPage); /* Recorrelate page with others before revalidation: */ recorrelate(pSettingsPage); /* Revalidate the page: */ bool fValid = pSettingsPage->revalidate(strWarning, strTitle); /* Compose a message: */ strWarning = strWarning.isEmpty() ? QString() : tr("On the <b>%1</b> page, %2").arg(strTitle, strWarning); pValidator->setLastWarning(strWarning); fValid ? setWarning(strWarning) : setError(strWarning); /* Remember validation status: */ pValidator->setOtherValid(fValid); }
/* Set pages list: */ void setPageList(const UISettingsPageList &pageList) { for (int iPageIndex = 0; iPageIndex < pageList.size(); ++iPageIndex) { UISettingsPage *pPage = pageList[iPageIndex]; m_pages.insert(pPage->id(), pPage); } }
void UISettingsDialog::setDialogType(SettingsDialogType settingsDialogType) { m_dialogType = settingsDialogType; for (int iWidgetNumber = 0; iWidgetNumber < m_pStack->count(); ++iWidgetNumber) { UISettingsPage *pPage = static_cast<UISettingsPage*>(m_pStack->widget(iWidgetNumber)); pPage->setDialogType(dialogType()); } }
void UISettingsSerializer::run() { /* Initialize COM for other thread: */ COMBase::InitializeCOM(false); /* Mark all the pages initially as NOT processed: */ foreach (UISettingsPage *pPage, m_pages.values()) pPage->setProcessed(false); /* Iterate over the all left settings pages: */ UISettingsPageMap pages(m_pages); while (!pages.empty()) { /* Get required page pointer, protect map by mutex while getting pointer: */ UISettingsPage *pPage = m_iIdOfHighPriorityPage != -1 && pages.contains(m_iIdOfHighPriorityPage) ? pages.value(m_iIdOfHighPriorityPage) : *pages.begin(); /* Reset request of high priority: */ if (m_iIdOfHighPriorityPage != -1) m_iIdOfHighPriorityPage = -1; /* Process this page if its enabled: */ connect(pPage, SIGNAL(sigOperationProgressChange(ulong, QString, ulong, ulong)), this, SIGNAL(sigOperationProgressChange(ulong, QString, ulong, ulong))); connect(pPage, SIGNAL(sigOperationProgressError(QString)), this, SIGNAL(sigOperationProgressError(QString))); if (pPage->isEnabled()) { if (m_enmDirection == Load) pPage->loadToCacheFrom(m_data); if (m_enmDirection == Save) pPage->saveFromCacheTo(m_data); } /* Remember what page was processed: */ disconnect(pPage, SIGNAL(sigOperationProgressChange(ulong, QString, ulong, ulong)), this, SIGNAL(sigOperationProgressChange(ulong, QString, ulong, ulong))); disconnect(pPage, SIGNAL(sigOperationProgressError(QString)), this, SIGNAL(sigOperationProgressError(QString))); pPage->setProcessed(true); /* Remove processed page from our map: */ pages.remove(pPage->id()); /* Notify listeners about page was processed: */ emit sigNotifyAboutPageProcessed(pPage->id()); /* If serializer saves settings => wake up GUI thread: */ if (m_enmDirection == Save) m_condition.wakeAll(); /* Break further processing if page had failed: */ if (pPage->failed()) break; } /* Notify listeners about all pages were processed: */ emit sigNotifyAboutPagesProcessed(); /* If serializer saves settings => wake up GUI thread: */ if (m_enmDirection == Save) m_condition.wakeAll(); /* Deinitialize COM for other thread: */ COMBase::CleanupCOM(); }
void UISettingsSerializer::sltHandleProcessedPage(int iPageId) { /* Make sure such page present: */ AssertReturnVoid(m_pages.contains(iPageId)); /* Get the page being processed: */ UISettingsPage *pSettingsPage = m_pages.value(iPageId); /* If serializer loads settings: */ if (m_enmDirection == Load) { /* We should fetch internal page cache: */ pSettingsPage->setValidatorBlocked(true); pSettingsPage->getFromCache(); pSettingsPage->setValidatorBlocked(false); } /* Add processed page into corresponding map: */ m_pagesDone.insert(iPageId, pSettingsPage); /* Notify listeners about process reached n%: */ const int iValue = 100 * m_pagesDone.size() / m_pages.size(); emit sigNotifyAboutProcessProgressChanged(iValue); }