/** * Update mInfo */ void Wizard::accept() { d->mInfo->mCollectionList=d->mCollectionSelector->selectedImageCollections(); Theme::Ptr theme = static_cast<ThemeListBoxItem*>(d->mThemePage->mThemeList->currentItem())->mTheme; QString themeInternalName = theme->internalName(); d->mInfo->setTheme(themeInternalName); Theme::ParameterList parameterList = theme->parameterList(); Theme::ParameterList::ConstIterator it = parameterList.constBegin(), end = parameterList.constEnd(); for (; it!=end; ++it) { AbstractThemeParameter* themeParameter = *it; QByteArray parameterInternalName = themeParameter->internalName(); QWidget* widget = d->mThemeParameterWidgetFromName[parameterInternalName]; QString value = themeParameter->valueFromWidget(widget); d->mInfo->setThemeParameterValue( themeInternalName, parameterInternalName, value); } d->mConfigManager->updateSettings(); KAssistantDialog::accept(); }
Theme::Ptr Theme::findByInternalName(const QString& internalName) { const Theme::List& lst=getList(); Theme::List::ConstIterator it=lst.constBegin(), end=lst.constEnd(); for (; it!=end; ++it) { Theme::Ptr theme = *it; if (theme->internalName() == internalName) { return theme; } } return Theme::Ptr(0); }
void initThemePage() { KListWidget* listWidget = mThemePage->mThemeList; Theme::List list=Theme::getList(); Theme::List::ConstIterator it=list.constBegin(), end=list.constEnd(); for (; it!=end; ++it) { Theme::Ptr theme = *it; ThemeListBoxItem* item = new ThemeListBoxItem(listWidget, theme); if ( theme->internalName()==mInfo->theme() ) { listWidget->setCurrentItem(item); } } }
ThemeListBoxItem(QListWidget* const list, Theme::Ptr theme) : QListWidgetItem(theme->name(), list), mTheme(theme) { }
void fillThemeParametersPage(Theme::Ptr theme) { // Create a new content page delete mThemeParametersPage->content; QWidget* content = new QWidget; mThemeParametersPage->content = content; mThemeParametersPage->scrollArea->setWidget(mThemeParametersPage->content); mThemeParameterWidgetFromName.clear(); // Create layout. We need to recreate it every time, to get rid of // spacers QGridLayout* layout = new QGridLayout(content); layout->setContentsMargins(QMargins()); layout->setSpacing(QApplication::style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing)); // Create widgets Theme::ParameterList parameterList = theme->parameterList(); QString themeInternalName = theme->internalName(); Theme::ParameterList::ConstIterator it = parameterList.constBegin(), end = parameterList.constEnd(); for (; it!=end; ++it) { AbstractThemeParameter* themeParameter = *it; QByteArray internalName = themeParameter->internalName(); QString value = mInfo->getThemeParameterValue( themeInternalName, internalName, themeParameter->defaultValue()); QString name = themeParameter->name(); name = i18nc("'%1' is a label for a theme parameter", "%1:", name); QLabel* label = new QLabel(name, content); label->setAlignment(Qt::AlignRight | Qt::AlignVCenter); QWidget* widget = themeParameter->createWidget(content, value); label->setBuddy(widget); int row = layout->rowCount(); layout->addWidget(label, row, 0); if (widget->sizePolicy().expandingDirections() & Qt::Horizontal) { // Widget wants full width layout->addWidget(widget, row, 1, 1, 2); } else { // Widget doesn't like to be stretched, add a spacer next to it layout->addWidget(widget, row, 1); QSpacerItem* spacer = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum); layout->addItem(spacer, row, 2); } mThemeParameterWidgetFromName[internalName] = widget; } // Add spacer at the end, so that widgets aren't spread on the whole // parent height QSpacerItem* spacer = new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding); layout->addItem(spacer, layout->rowCount(), 0); }