void QtStyleManager::GetIconThemes(IconThemeList& iconThemes) const { iconThemes.clear(); iconThemes.push_back(IconTheme(QString( "<<default>>" ))); QStringList iconSearchPaths = QIcon::themeSearchPaths(); for(QStringList::Iterator pathIt = iconSearchPaths.begin(); pathIt != iconSearchPaths.end(); ++pathIt) { QDirIterator dirIt(*pathIt); while (dirIt.hasNext()) { QString current = dirIt.next(); QFileInfo info = dirIt.fileInfo(); if (info.isDir() && info.isReadable()) { QFileInfo themeFile( info.filePath() + QString("/index.theme") ); if( themeFile.exists() && themeFile.isFile() && themeFile.isReadable() ) { QString fileName = info.fileName(); iconThemes.push_back( IconTheme(fileName) ); } } } } }
KBlocksScene::KBlocksScene(GameLogicInterface *p, int capacity) { mpGameLogic = p; mGameStarted = false; mSnapshotMode = false; mTopGameLevel = 0; mGroupCount = 0; mMaxCapacity = capacity; mSceneGamesPerLine = 4; mGameAnimEnabled = true; mWaitForAllUpdate = false; maGroupList = new KBlocksItemGroup*[capacity](); maGameScoreList = new KBlocksScore*[capacity](); maGameReadySignal = new bool[capacity](); QString themeFile(Settings::theme()); mpGrafx = new KBlocksGraphics(themeFile); mpSnd = new KBlocksSound(themeFile); int width = (capacity >= mSceneGamesPerLine) ? mSceneGamesPerLine : (capacity % mSceneGamesPerLine); int height = (int)(capacity / (mSceneGamesPerLine + 1)) + 1; setSceneRect(0, 0, mpGrafx->m_View_Size_Width * width, mpGrafx->m_View_Size_Height * height); setItemIndexMethod(NoIndex); mUpdateInterval = 50; mUpdateTimer.setInterval(mUpdateInterval); connect(&mUpdateTimer, &QTimer::timeout, this, &KBlocksScene::updateGame); mUpdateTimer.stop(); }
void KNThemeManager::loadThemeFiles(const QString &themeDirPath) { //Clear the previous theme list. m_themeList.clear(); //Add the default theme as the first item in the list. addTheme("Default", "://configure/default.json", QPixmap()); //The structure of a theme directory. /* Theme * |-<Theme Name> * | |-<Theme Name>.json * | |-<Theme Name>.png */ //Check the folder exist. If no, return. QDir themeFolder(themeDirPath); if(!themeFolder.exists()) { return; } //Get all the folder in the theme folder. QFileInfoList folderList=themeFolder.entryInfoList(); for(QFileInfoList::const_iterator i=folderList.constBegin(); i!=folderList.constEnd(); ++i) { QString themeName=(*i).fileName(); //Ignore if the current info is not folder, dot(.) and dot-dot(..). if(!(*i).isDir() || themeName=="." || themeName=="..") { continue; } //Get the theme file and the preview image. QFileInfo themeFile((*i).absoluteFilePath()+"/"+themeName+".json"), previewFile((*i).absoluteFilePath()+"/"+themeName+".png"); if(themeFile.exists()) { //Check the preview image. QPixmap previewImage; if(previewFile.exists()) { previewImage.load(previewFile.absoluteFilePath()); if(previewImage.isNull()) { //! FIXME: Set the preview to no image. ; } } else { //! FIXME: Set the preview to no image. ; } //Add the new theme addTheme(themeName, themeFile.absoluteFilePath(), previewImage); } } }
void SettingsWidget::onThemeChanged(int i) { // Apply and save the theme QFile themeFile(ui.cb_themes->itemData(i).toString()); if (themeFile.open(QFile::ReadOnly)) { qApp->setStyleSheet(themeFile.readAll()); _mainWidget->_theme = ui.cb_themes->itemText(i); themeFile.close(); return; } else { QMessageBox msgBox(QMessageBox::Critical, "Error", "Could not open theme file."); msgBox.exec(); } }
void KNThemeManager::loadTheme(const QString &themeFilePath) { QFile themeFile(themeFilePath); //Check the theme file exist or not. Open the file as ReadOnly mode. if(!themeFile.exists() || !themeFile.open(QIODevice::ReadOnly)) { return; } //Read the data and close the file. QJsonObject themeData=QJsonDocument::fromJson(themeFile.readAll()).object(); themeFile.close(); //Generate the temporary palette map and name hash list. //We don't write it to palette list to avoid the bad file. QHash<QString, QPalette> paletteList; //Parse the theme data. QStringList paletteNames=themeData.keys(); for(QStringList::iterator i=paletteNames.begin(); i!=paletteNames.end(); ++i) { //Check whether we have loaded this name before. if(paletteList.contains(*i)) { continue; } //Parse the data. parsePalette(*i, &themeData, paletteList); } //Check the new map is available or not. if(!paletteList.isEmpty()) { //Save the palette map. m_paletteList=paletteList; //Update all the widget's palette in the widget list. for(QLinkedList<QWidget *>::iterator i=m_widgetList.begin(); i!=m_widgetList.end(); ++i) { (*i)->setPalette(getPalette((*i)->objectName())); } //Emit the theme change signal. emit themeChange(); } }
// Windows only: attempts to get colour for UX theme page background wxColour wxNotebook::GetThemeBackgroundColour() const { #if wxUSE_UXTHEME if (wxUxThemeEngine::Get()) { wxUxThemeHandle hTheme((wxNotebook*) this, L"TAB"); if (hTheme) { // This is total guesswork. // See PlatformSDK\Include\Tmschema.h for values. // JACS: can also use 9 (TABP_PANE) COLORREF themeColor; bool success = (S_OK == wxUxThemeEngine::Get()->GetThemeColor( hTheme, 10 /* TABP_BODY */, 1 /* NORMAL */, 3821 /* FILLCOLORHINT */, &themeColor)); if (!success) return GetBackgroundColour(); /* [DS] Workaround for WindowBlinds: Some themes return a near black theme color using FILLCOLORHINT, this makes notebook pages have an ugly black background and makes text (usually black) unreadable. Retry again with FILLCOLOR. This workaround potentially breaks appearance of some themes, but in practice it already fixes some themes. */ if (themeColor == 1) { wxUxThemeEngine::Get()->GetThemeColor( hTheme, 10 /* TABP_BODY */, 1 /* NORMAL */, 3802 /* FILLCOLOR */, &themeColor); } wxColour colour = wxRGBToColour(themeColor); // Under Vista, the tab background colour is reported incorrectly. // So for the default theme at least, hard-code the colour to something // that will blend in. static int s_AeroStatus = -1; if (s_AeroStatus == -1) { WCHAR szwThemeFile[1024]; WCHAR szwThemeColor[256]; if (S_OK == wxUxThemeEngine::Get()->GetCurrentThemeName(szwThemeFile, 1024, szwThemeColor, 256, NULL, 0)) { wxString themeFile(szwThemeFile), themeColor(szwThemeColor); if (themeFile.Find(wxT("Aero")) != -1 && themeColor == wxT("NormalColor")) s_AeroStatus = 1; else s_AeroStatus = 0; } else s_AeroStatus = 0; } if (s_AeroStatus == 1) colour = wxColour(255, 255, 255); return colour; } } #endif // wxUSE_UXTHEME return GetBackgroundColour(); }