QWidget * PatternWallpaper::createConfigurationInterface(QWidget * parent) { QWidget * configWidget = new QWidget(parent); m_ui.setupUi(configWidget); m_ui.m_fgColor->setColor(m_fgColor); m_ui.m_bgColor->setColor(m_bgColor); m_model = new BackgroundListModel(this, configWidget); m_model->setWallpaperSize(targetSizeHint().toSize()); m_model->reload(); QTimer::singleShot(0, this, SLOT(setConfigurationInterfaceModel())); m_ui.m_pattern->setItemDelegate(new BackgroundDelegate(m_ui.m_pattern)); m_ui.m_pattern->setMinimumWidth((BackgroundDelegate::SCREENSHOT_SIZE + BackgroundDelegate::MARGIN * 2 + BackgroundDelegate::BLUR_INCREMENT) * 3 + m_ui.m_pattern->spacing() * 4 + QApplication::style()->pixelMetric(QStyle::PM_ScrollBarExtent) + QApplication::style()->pixelMetric(QStyle::PM_DefaultFrameWidth) * 2 + 7); m_ui.m_pattern->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); connect(m_ui.m_fgColor, SIGNAL(changed(QColor)), SLOT(widgetChanged())); connect(m_ui.m_bgColor, SIGNAL(changed(QColor)), SLOT(widgetChanged())); connect(this, SIGNAL(settingsChanged(bool)), parent, SLOT(settingsChanged(bool))); return configWidget; }
QWidget* Image::createConfigurationInterface(QWidget* parent) { m_configWidget = new QWidget(parent); connect(m_configWidget, SIGNAL(destroyed(QObject*)), this, SLOT(configWidgetDestroyed())); if (m_mode == "SingleImage") { m_uiImage.setupUi(m_configWidget); m_model = new BackgroundListModel(this, m_configWidget); m_model->setResizeMethod(resizeMethodHint()); m_model->setWallpaperSize(m_size); m_model->reload(m_usersWallpapers); QTimer::singleShot(0, this, SLOT(setConfigurationInterfaceModel())); m_uiImage.m_view->setItemDelegate(new BackgroundDelegate(m_uiImage.m_view)); //FIXME: setting the minimum width is rather ugly, but this gets us 3 columns of papers //which looks quite good as a default. the magic number 7 at the end of the calculation is //evidently making up for some other PM involved in the QListView that isn't being caught. //if a cleaner way can be found to achieve all this, that would be great m_uiImage.m_view->setMinimumWidth((BackgroundDelegate::SCREENSHOT_SIZE + BackgroundDelegate::MARGIN * 2 + BackgroundDelegate::BLUR_INCREMENT) * 3 + m_uiImage.m_view->spacing() * 4 + QApplication::style()->pixelMetric(QStyle::PM_ScrollBarExtent) + QApplication::style()->pixelMetric(QStyle::PM_DefaultFrameWidth) * 2 + 7); m_uiImage.m_view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); RemoveButtonManager *rmManager = new RemoveButtonManager(m_uiImage.m_view, &m_usersWallpapers); connect(rmManager, SIGNAL(removeClicked(QString)), this, SLOT(removeWallpaper(QString))); m_uiImage.m_pictureUrlButton->setIcon(KIcon("document-open")); connect(m_uiImage.m_pictureUrlButton, SIGNAL(clicked()), this, SLOT(showFileDialog())); m_uiImage.m_resizeMethod->addItem(i18n("Scaled & Cropped"), ScaledAndCroppedResize); m_uiImage.m_resizeMethod->addItem(i18n("Scaled"), ScaledResize); m_uiImage.m_resizeMethod->addItem(i18n("Scaled, keep proportions"), MaxpectResize); m_uiImage.m_resizeMethod->addItem(i18n("Centered"), CenteredResize); m_uiImage.m_resizeMethod->addItem(i18n("Tiled"), TiledResize); m_uiImage.m_resizeMethod->addItem(i18n("Center Tiled"), CenterTiledResize); for (int i = 0; i < m_uiImage.m_resizeMethod->count(); ++i) { if (resizeMethodHint() == m_uiImage.m_resizeMethod->itemData(i).value<int>()) { m_uiImage.m_resizeMethod->setCurrentIndex(i); break; } } connect(m_uiImage.m_resizeMethod, SIGNAL(currentIndexChanged(int)), this, SLOT(positioningChanged(int))); m_uiImage.m_color->setColor(m_color); //Color button is useless with some resize methods m_uiImage.m_color->setEnabled(resizeMethodHint() == MaxpectResize || resizeMethodHint() == CenteredResize); connect(m_uiImage.m_color, SIGNAL(changed(QColor)), this, SLOT(colorChanged(QColor))); m_uiImage.m_newStuff->setIcon(KIcon("get-hot-new-stuff")); connect(m_uiImage.m_newStuff, SIGNAL(clicked()), this, SLOT(getNewWallpaper())); connect(m_uiImage.m_color, SIGNAL(changed(QColor)), this, SLOT(modified())); connect(m_uiImage.m_resizeMethod, SIGNAL(currentIndexChanged(int)), this, SLOT(modified())); connect(m_uiImage.m_view, SIGNAL(clicked(QModelIndex)), this, SLOT(modified())); } else {