void GuiGameList::updateTheme() { if(!mTheme) return; mTheme->readXML( getThemeFile() ); mList->setSelectorColor(mTheme->getColor("selector")); mList->setSelectedTextColor(mTheme->getColor("selected")); mList->setScrollSound(mTheme->getSound("menuScroll")); //fonts mList->setFont(mTheme->getListFont()); if(mDetailed) { mList->setCentered(mTheme->getBool("listCentered")); mList->setOffsetX(mTheme->getFloat("listOffsetX") * Renderer::getScreenWidth()); mList->setTextOffsetX(mTheme->getFloat("listTextOffsetX") * Renderer::getScreenWidth()); mScreenshot->setOffsetX(mTheme->getFloat("gameImageOffsetX") * Renderer::getScreenWidth()); mScreenshot->setOffsetY(mTheme->getFloat("gameImageOffsetY") * Renderer::getScreenHeight()); mScreenshot->setOrigin(mTheme->getFloat("gameImageOriginX"), mTheme->getFloat("gameImageOriginY")); mScreenshot->setResize(mTheme->getFloat("gameImageWidth"), mTheme->getFloat("gameImageHeight"), false); } }
QString VConfigManager::getCodeBlockCssStyleUrl() const { Q_ASSERT(!m_themes.isEmpty()); Q_ASSERT(!m_codeBlockCssStyles.isEmpty()); if (m_codeBlockCssStyle.isEmpty()) { // Use theme's style. const_cast<VConfigManager *>(this)->m_codeBlockCssStyle = VPalette::themeCodeBlockCssStyle(getThemeFile()); } QString cssPath; auto it = m_codeBlockCssStyles.find(m_codeBlockCssStyle); if (it != m_codeBlockCssStyles.end()) { cssPath = it.value(); } if (cssPath.startsWith(":")) { cssPath = "qrc" + cssPath; } else { QUrl cssUrl = QUrl::fromLocalFile(cssPath); cssPath = cssUrl.toString(); } qDebug() << "use code block css style file" << cssPath; return cssPath; }
/********************************************************** * ThemeEngine class *********************************************************/ ThemeEngine::ThemeEngine(Common::String id, GraphicsMode mode) : _system(0), _vectorRenderer(0), _buffering(false), _bytesPerPixel(0), _graphicsMode(kGfxDisabled), _font(0), _initOk(false), _themeOk(false), _enabled(false), _cursor(0) { _system = g_system; _parser = new ThemeParser(this); _themeEval = new GUI::ThemeEval(); _useCursor = false; for (int i = 0; i < kDrawDataMAX; ++i) { _widgets[i] = 0; } for (int i = 0; i < kTextDataMAX; ++i) { _texts[i] = 0; } for (int i = 0; i < kTextColorMAX; ++i) { _textColors[i] = 0; } // We currently allow two different ways of theme selection in our config file: // 1) Via full path // 2) Via a basename, which will need to be translated into a full path // This function assures we have a correct path to pass to the ThemeEngine // constructor. _themeFile = getThemeFile(id); // We will use getThemeId to retrive the theme id from the given filename // here, since the user could have passed a fixed filename as 'id'. _themeId = getThemeId(_themeFile); _graphicsMode = mode; _themeArchive = 0; _initOk = false; }
QString VConfigManager::getEditorStyleFile() const { Q_ASSERT(!m_themes.isEmpty()); Q_ASSERT(!m_editorStyles.isEmpty()); if (m_editorStyle.isEmpty()) { // Use theme's style. const_cast<VConfigManager *>(this)->m_editorStyle = VPalette::themeEditorStyle(getThemeFile()); } auto it = m_editorStyles.find(m_editorStyle); if (it != m_editorStyles.end()) { return it.value(); } return QString(); }