Style::Style(QWidget *parent, const char* name) : StyleDlg(parent, name) { // Common Pardus settings for all themes KConfig *config = new KConfig("kdeglobals"); config->setGroup("KDE"); config->writeEntry("ShowIconsOnPushButtons", true); config->writeEntry("EffectAnimateCombo", true); config->sync(); delete config; // add kaptan themes into resouce pool KGlobal::dirs()->addResourceType("themes", KStandardDirs::kde_default("data") + "kaptan/themes/"); QStringList themes = KGlobal::dirs()->findAllResources("themes", "*.xml", true /*recursive*/); themes.sort(); for (QStringList::const_iterator it = themes.begin(); it != themes.end(); ++it) styleBox->insertItem(QFileInfo(*it).baseName()); connect(styleButton, SIGNAL(clicked()), this, SLOT(testStyle())); connect(styleBox, SIGNAL(activated(int)), this, SLOT(styleSelected(int))); connect(checkKickoff, SIGNAL(clicked()), this, SLOT(kickoffSelected())); styleBox->setCurrentItem(0); emit(styleSelected(0)); }
QString KoGenStyles::insert(const KoGenStyle& style, const QString& baseName, InsertionFlags flags) { // if it is a default style it has to be saved differently if (style.isDefaultStyle()) { // we can have only one default style per type Q_ASSERT(!d->defaultStyles.contains(style.type())); // default style is only possible for style:style in office:style types Q_ASSERT(style.type() == KoGenStyle::TextStyle || style.type() == KoGenStyle::ParagraphStyle || style.type() == KoGenStyle::SectionStyle || style.type() == KoGenStyle::RubyStyle || style.type() == KoGenStyle::TableStyle || style.type() == KoGenStyle::TableColumnStyle || style.type() == KoGenStyle::TableRowStyle || style.type() == KoGenStyle::TableCellStyle || style.type() == KoGenStyle::GraphicStyle || style.type() == KoGenStyle::PresentationStyle || style.type() == KoGenStyle::DrawingPageStyle || style.type() == KoGenStyle::ChartStyle); d->defaultStyles.insert(style.type(), style); // default styles don't have a name return QString(); } if (flags & AllowDuplicates) { StyleMap::iterator it = d->insertStyle(style, baseName, flags); return it.value(); } StyleMap::iterator it = d->styleMap.find(style); if (it == d->styleMap.end()) { // Not found, try if this style is in fact equal to its parent (the find above // wouldn't have found it, due to m_parentName being set). if (!style.parentName().isEmpty()) { KoGenStyle testStyle(style); const KoGenStyle* parentStyle = this->style(style.parentName(), style.familyName()); // ## linear search if (!parentStyle) { kDebug(30003) << "baseName=" << baseName << "parent style" << style.parentName() << "not found in collection"; } else { // TODO remove if (testStyle.m_familyName != parentStyle->m_familyName) { kWarning(30003) << "baseName=" << baseName << "family=" << testStyle.m_familyName << "parent style" << style.parentName() << "has a different family:" << parentStyle->m_familyName; } testStyle.m_parentName = parentStyle->m_parentName; // Exclude the type from the comparison. It's ok for an auto style // to have a user style as parent; they can still be identical testStyle.m_type = parentStyle->m_type; // Also it's ok to not have the display name of the parent style // in the auto style QMap<QString, QString>::const_iterator it = parentStyle->m_attributes.find("style:display-name"); if (it != parentStyle->m_attributes.end()) testStyle.addAttribute("style:display-name", *it); if (*parentStyle == testStyle) return style.parentName(); } } it = d->insertStyle(style, baseName, flags); } return it.value(); }