PreviewConfigurationWidget::PreviewConfigurationWidgetPrivate::PreviewConfigurationWidgetPrivate(QGroupBox *g) : m_core(0), m_defaultStyle(PreviewConfigurationWidget::tr("Default")), m_parent(g), m_firstUserSkinIndex(0), m_browseSkinIndex(0), m_lastSkinIndex(0) { m_ui.setupUi(g); // styles m_ui.m_styleCombo->setEditable(false); QStringList styleItems(m_defaultStyle); styleItems += QStyleFactory::keys(); m_ui.m_styleCombo->addItems(styleItems); // sheet m_ui.m_appStyleSheetLineEdit->setTextPropertyValidationMode(qdesigner_internal::ValidationStyleSheet); m_ui.m_appStyleSheetClearButton->setIcon(qdesigner_internal::createIconSet(QString::fromUtf8("resetproperty.png"))); QObject::connect(m_ui.m_appStyleSheetClearButton, SIGNAL(clicked()), m_ui.m_appStyleSheetLineEdit, SLOT(clear())); m_ui.m_skinRemoveButton->setIcon(qdesigner_internal::createIconSet(QString::fromUtf8("editdelete.png"))); // skins: find default skins (resources) m_ui.m_skinRemoveButton->setEnabled(false); Skins skins = defaultSkins(); skins.push_front(SkinNamePath(PreviewConfigurationWidget::tr("None"), QString())); const Skins::const_iterator scend = skins.constEnd(); for (Skins::const_iterator it = skins.constBegin(); it != scend; ++it) m_ui.m_skinCombo->addItem (it->first, QVariant(it->second)); m_browseSkinIndex = m_firstUserSkinIndex = skins.size(); m_ui.m_skinCombo->addItem (PreviewConfigurationWidget::tr("Browse..."), QString()); m_ui.m_skinCombo->setMaxVisibleItems (qMax(15, 2 * m_browseSkinIndex)); m_ui.m_skinCombo->setEditable(false); }
// find default skins (resources) static const Skins &defaultSkins() { static Skins rc; if (rc.empty()) { const QString skinPath = QLatin1String(skinResourcePathC); QString pattern = QLatin1String("*."); pattern += QLatin1String(skinExtensionC); const QDir dir(skinPath, pattern); const QFileInfoList list = dir.entryInfoList(QDir::Dirs|QDir::NoDotAndDotDot, QDir::Name); if (list.empty()) return rc; const QFileInfoList::const_iterator lcend = list.constEnd(); for (QFileInfoList::const_iterator it = list.constBegin(); it != lcend; ++it) rc.push_back(SkinNamePath(it->baseName(), it->filePath())); } return rc; }
// find default skins (resources) static const Skins &defaultSkins() { static Skins rc; if (rc.empty()) { #ifdef DEFAULT_SKINS_FROM_RESOURCE const QString skinPath = QLatin1String(skinResourcePathC); #else QString skinPath = QLibraryInfo::location(QLibraryInfo::PrefixPath); skinPath += QDir::separator(); skinPath += QLatin1String("tools"); skinPath += QDir::separator(); skinPath += QLatin1String("qvfb"); #endif QString pattern = QLatin1String("*."); pattern += QLatin1String(skinExtensionC); const QDir dir(skinPath, pattern); const QFileInfoList list = dir.entryInfoList(); if (list.empty()) return rc; const QFileInfoList::const_iterator lcend = list.constEnd(); for (QFileInfoList::const_iterator it = list.constBegin(); it != lcend; ++it) rc.push_back(SkinNamePath(it->baseName(), it->filePath())); } return rc; }