Beispiel #1
0
void LookConfig::reloadThemes(const boost::optional<ThemeInfo::StyleInfo> configuredStyle) {
	const ThemeMap themes = Themes::getThemes();
	
	int selectedThemeEntry = 0;
	
	qcbTheme->clear();
	qcbTheme->addItem(tr("None"));
	for (ThemeMap::const_iterator theme = themes.begin();
	     theme != themes.end();
	     ++theme) {
		
		for (ThemeInfo::StylesMap::const_iterator styleit = theme->styles.begin();
		     styleit != theme->styles.end();
		     ++styleit) {
			
			if (configuredStyle
			     && configuredStyle->themeName == styleit->themeName
			     && configuredStyle->name == styleit->name) {
				selectedThemeEntry = qcbTheme->count();
			}
			
			qcbTheme->addItem(theme->name + QLatin1String(" - ") + styleit->name, QVariant::fromValue(*styleit));
		}
	}
	
	qcbTheme->setCurrentIndex(selectedThemeEntry);
}
Beispiel #2
0
boost::optional<ThemeInfo::StyleInfo> Themes::getConfiguredStyle(const Settings &settings) {
	if (settings.themeName.isEmpty() && settings.themeStyleName.isEmpty()) {
			return boost::none;
	}

	const ThemeMap themes = getThemes();
	ThemeMap::const_iterator themeIt = themes.find(settings.themeName);
	if (themeIt == themes.end()) {
		qWarning() << "Could not find configured theme" << settings.themeName;
		return boost::none;
	}
	
	ThemeInfo::StylesMap::const_iterator styleIt = themeIt->styles.find(settings.themeStyleName);
	if (styleIt == themeIt->styles.end()) {
		qWarning() << "Configured theme" << settings.themeName << "does not have configured style" << settings.themeStyleName;
		return boost::none;
	}
	
	return *styleIt;
}