static void themes(const QString &theme, QStringList &iconThemes) { if (iconThemes.contains(theme)) { return; } QString lower=theme.toLower(); iconThemes << theme; if (lower!=theme) { iconThemes << lower; } QStringList paths=QIcon::themeSearchPaths(); QString key("Inherits="); foreach (const QString &p, paths) { QString index(p+"/"+theme+"/index.theme"); QFile f(index); if (f.open(QIODevice::ReadOnly|QIODevice::Text)) { while (!f.atEnd()) { QString line=QString::fromUtf8(f.readLine()).trimmed().simplified(); if (line.startsWith(key)) { QStringList inherited=line.mid(key.length()).split(",", QString::SkipEmptyParts); foreach (const QString &i, inherited) { themes(i, iconThemes); } return; } }
int main(int argc, char ** argv) { bool CLIdone = false; for(int i=1; i<argc; i++){ //skip the first arg (app binary) if(QString(argv[i]) == "--reset-monitors"){ RRSettings::ApplyPrevious(); CLIdone = true; break; } } if(CLIdone){ return 0; } LTHEME::LoadCustomEnvSettings(); LSingleApplication a(argc, argv, "lumina-xconfig"); //loads translations inside constructor if( !a.isPrimaryProcess()){ return 0; } //qDebug() << "Loaded QApplication"; a.setApplicationName("Lumina Screen Configuration"); LuminaThemeEngine themes(&a); //Start the UI MainUI w; QObject::connect(&a, SIGNAL(InputsAvailable(QStringList)), &w, SLOT(slotSingleInstance()) ); QObject::connect(&themes, SIGNAL(updateIcons()), &w, SLOT(loadIcons()) ); w.show(); int retCode = a.exec(); return retCode; }
void ThemesDlg::saveUserAddedThemes() { KStandardDirs ksd; QStringList t = themes(); QStringList dirs = ksd.findDirs("data", QString(kapp->objectName()) + "/themes"); QStringList::Iterator it = t.begin(); bool remove; while (it != t.end()) { remove = false; QStringList::Iterator jtend(dirs.end()); for (QStringList::Iterator jt = dirs.begin(); jt != jtend; ++jt) { if (QString(QFileInfo(*it).dir().path() + '/') == *jt) { remove = true; break; } } if (remove) it = t.erase(it); else ++it; } SuperKarambaSettings::setUserAddedThemes(t); SuperKarambaSettings::self()->writeConfig(); }
int CThemes::Show() { std::string file_name = ""; CMenuWidget themes(menue_title, menue_icon, width); themes.setPreselected(selected); //intros themes.addIntroItems(menue_title != LOCALE_COLORTHEMEMENU_HEAD2 ? LOCALE_COLORTHEMEMENU_HEAD2 : NONEXISTANT_LOCALE); //set default theme themes.addItem(new CMenuForwarder(LOCALE_COLORTHEMEMENU_NEUTRINO_THEME, true, NULL, this, "theme_neutrino", CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED)); readThemes(themes); CStringInputSMS nameInput(LOCALE_COLORTHEMEMENU_NAME, &file_name, 30, false, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789- "); CMenuForwarder *m1 = new CMenuForwarder(LOCALE_COLORTHEMEMENU_SAVE, true , NULL, &nameInput); // Don't show SAVE if UserDir does'nt exist if ( access(USERDIR, F_OK) != 0 ) { // check for existance // mkdir must be called for each subdir which does not exist // mkdir (USERDIR, S_IRUSR | S_IREAD | S_IWUSR | S_IWRITE | S_IXUSR | S_IEXEC) == 0) { if (system (((std::string)"mkdir -p " + USERDIR).c_str()) != 0) { printf("[neutrino theme] error creating %s\n", USERDIR); } } if (access(USERDIR, F_OK) == 0 ) { themes.addItem(GenericMenuSeparatorLine); themes.addItem(m1); } else { delete m1; printf("[neutrino theme] error accessing %s\n", USERDIR); } int res = themes.exec(NULL, ""); selected = themes.getSelected(); if (file_name.length() > 1) { saveFile((char*)((std::string)USERDIR + file_name + FILE_PREFIX).c_str()); } if (hasThemeChanged) { if (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_COLORTHEMEMENU_QUESTION, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, menue_icon.c_str()) != CMessageBox::mbrYes) rememberOldTheme( false ); else hasThemeChanged = false; } return res; }
SoundThemeManager::SoundThemeManager() : MyThemes(new Themes("sounds", "sound.conf")) { MyThemes->setPaths(config_file.readEntry("Sounds", "SoundPaths").split('&', QString::SkipEmptyParts)); QStringList soundThemes = themes()->themes(); QString soundTheme = config_file.readEntry("Sounds", "SoundTheme"); if (!soundThemes.isEmpty() && (soundTheme != "Custom") && !soundThemes.contains(soundTheme)) { soundTheme = "default"; config_file.writeEntry("Sounds", "SoundTheme", "default"); } if (soundTheme != "custom") applyTheme(soundTheme); }
int main(int argc, char ** argv) { QStringList in; for(int i=1; i<argc; i++){ //skip the first arg (app binary) QString path = argv[i]; if(path=="."){ //Insert the current working directory in << QDir::currentPath(); }else{ if(!path.startsWith("/")){ path.prepend(QDir::currentPath()+"/"); } in << path; } } if(in.isEmpty()){ in << QDir::homePath(); } #ifdef __FreeBSD__ QtSingleApplication a(argc, argv); if( a.isRunning() ){ return !(a.sendMessage(in.join("\n"))); } #else QApplication a(argc, argv); #endif a.setApplicationName("Insight File Manager"); LuminaThemeEngine themes(&a); //Load current Locale QTranslator translator; QLocale mylocale; QString langCode = mylocale.name(); if ( ! QFile::exists(LOS::LuminaShare()+"i18n/lumina-fm_" + langCode + ".qm" ) ) langCode.truncate(langCode.indexOf("_")); translator.load( QString("lumina-fm_") + langCode, LOS::LuminaShare()+"i18n/" ); a.installTranslator( &translator ); qDebug() << "Locale:" << langCode; //Load current encoding for this locale QTextCodec::setCodecForTr( QTextCodec::codecForLocale() ); //make sure to use the same codec qDebug() << "Locale Encoding:" << QTextCodec::codecForLocale()->name(); MainUI w; QObject::connect(&a, SIGNAL(messageReceived(const QString&)), &w, SLOT(slotSingleInstance(const QString&)) ); QObject::connect(&themes, SIGNAL(updateIcons()), &w, SLOT(setupIcons()) ); w.OpenDirs(in); w.show(); int retCode = a.exec(); return retCode; }
int main(int argc, char ** argv) { //qDebug() << "Create Single Application"; LSingleApplication a(argc, argv, "lumina-info"); //loads translations inside constructor if( !a.isPrimaryProcess()){ return 0; } //qDebug() << "Set Application Name"; a.setApplicationName("About Lumina-DE"); //qDebug() << "Load Theme Engine"; LuminaThemeEngine themes(&a); //qDebug() << "Start the UI"; //Start the UI MainUI w; QObject::connect(&a, SIGNAL(InputsAvailable(QStringList)), &w, SLOT(slotSingleInstance()) ); w.show(); int retCode = a.exec(); return retCode; }
int main(int argc, char *argv[]) { if(initialize_finddir() != 0) return -1; int result = options (argc, argv); if(result == OPTIONS_PREMATURE_END) return 0; else if(result == OPTIONS_ERROR) return -1; else if(result != 0) return -2; initialize(); translation(); themes(); create_conkyrc(); confinstall(); return 0; }
//#define DEBUG 0 int main(int argc, char ** argv) { qDebug() << "Starting lumina-wm..."; LTHEME::LoadCustomEnvSettings(); LSingleApplication a(argc, argv, "lumina-wm"); if(!a.isPrimaryProcess()){ return 0; } //Inputs forwarded on to the primary already LuminaThemeEngine themes(&a); //Setup the special settings prefix location QSettings::setPath(QSettings::NativeFormat, QSettings::UserScope, QDir::homePath()+"/.lumina"); //Setup the global structures LWM::SYSTEM = new LXCB(); if(argc>1 && QString::fromLocal8Bit(argv[1])=="testwin"){ //Simple override to test out the window class qDebug() << "Starting window test..."; QLabel dlg(0, Qt::Window | Qt::BypassWindowManagerHint); //this test should be ignored by the current WM dlg.setText("Sample Window"); dlg.setWindowTitle("Test"); dlg.setGeometry(100,100,200,100); dlg.setStyleSheet("background: rgba(255,255,255,100); color: black;"); dlg.show(); qDebug() << " - Loading window frame..."; LWindow win(dlg.winId()); //have it wrap around the dialog qDebug() << " - Show frame..."; win.windowChanged(LWM::Show); qDebug() << " - Start event loop..."; a.setQuitOnLastWindowClosed(true); return a.exec(); } WMSession w; w.start(); QObject::connect(&themes, SIGNAL(updateIcons()), &w, SLOT(reloadIcons()) ); QObject::connect(&a, SIGNAL(InputsAvailable(QStringList)), &w, SLOT(newInputsAvailable(QStringList)) ); int retCode = a.exec(); return retCode; }
int CThemes::Show() { dprintf(DEBUG_NORMAL, "CThemes::Show:\n"); std::string file_name = ""; CMenuWidget themes(LOCALE_COLORMENU_MENUCOLORS, NEUTRINO_ICON_SETTINGS, width); //set default theme themes.addItem(new CMenuForwarder(LOCALE_COLORTHEMEMENU_DEFAULT_THEME, true, NULL, this, "theme_default" )); readThemes(themes); CStringInputSMS nameInput(LOCALE_COLORTHEMEMENU_NAME, &file_name); CMenuForwarder * m1 = new CMenuForwarder(LOCALE_COLORTHEMEMENU_SAVE, true , NULL, &nameInput, NULL, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED); // Don't show SAVE if UserDir does'nt exist if ( access(USERDIR, F_OK) != 0 ) { // check for existance // mkdir must be called for each subdir which does not exist // mkdir (USERDIR, S_IRUSR | S_IREAD | S_IWUSR | S_IWRITE | S_IXUSR | S_IEXEC) == 0) { if (system (((std::string)"mkdir -p " + USERDIR).c_str()) != 0) { printf("[neutrino theme] error creating %s\n", USERDIR); } } if (access(USERDIR, F_OK) == 0 ) { themes.addItem(new CMenuSeparator(CMenuSeparator::LINE)); themes.addItem(m1); } else { delete m1; printf("[neutrino theme] error accessing %s\n", USERDIR); } int res = themes.exec(NULL, ""); if (file_name.length() > 1) { saveFile((char*)((std::string)USERDIR + file_name + FILE_PREFIX).c_str()); } if (hasThemeChanged) { if (MessageBox(LOCALE_MESSAGEBOX_INFO, LOCALE_COLORTHEMEMENU_QUESTION, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_SETTINGS) != CMessageBox::mbrYes) { rememberOldTheme( false ); } else { CNeutrinoApp::getInstance()->exec(NULL, "savesettings"); hasThemeChanged = false; } } return res; }
void ThemeChooser::Load(void) { SetBusyPopupMessage(tr("Loading Installed Themes")); QString MythVersion = MYTH_SOURCE_PATH; QStringList themesSeen; QDir themes(GetConfDir() + "/themes"); themes.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); themes.setSorting(QDir::Name | QDir::IgnoreCase); // FIXME: For now, treat git master the same as svn trunk if (MythVersion == "master") MythVersion = "trunk"; if (MythVersion != "trunk") { MythVersion = MYTH_BINARY_VERSION; // Example: 0.25.20101017-1 MythVersion.replace(QRegExp("\\.[0-9]{8,}.*"), ""); } m_infoList = themes.entryInfoList(); for( QFileInfoList::iterator it = m_infoList.begin(); it != m_infoList.end(); ++it ) { if (loadThemeInfo(*it)) { themesSeen << (*it).fileName(); m_themeStatuses[(*it).fileName()] = "default"; } } themes.setPath(GetThemesParentDir()); QFileInfoList sharedThemes = themes.entryInfoList(); for( QFileInfoList::iterator it = sharedThemes.begin(); it != sharedThemes.end(); ++it ) { if ((!themesSeen.contains((*it).fileName())) && (loadThemeInfo(*it))) { m_infoList << *it; themesSeen << (*it).fileName(); m_themeStatuses[(*it).fileName()] = "default"; } } QString remoteThemesFile = GetConfDir(); remoteThemesFile.append("/tmp/themes.zip"); QString themeSite = QString("%1/%2") .arg(gCoreContext->GetSetting("ThemeRepositoryURL", "http://themes.mythtv.org/themes/repository")).arg(MythVersion); int downloadFailures = gCoreContext->GetNumSetting("ThemeInfoDownloadFailures", 0); if (QFile::exists(remoteThemesFile)) { QFileInfo finfo(remoteThemesFile); if (finfo.lastModified() < mythCurrentDateTime().addSecs(-600)) { LOG(VB_GUI, LOG_INFO, LOC + QString("%1 is over 10 minutes old, forcing " "remote theme list download").arg(remoteThemesFile)); m_refreshDownloadableThemes = true; } } else if (downloadFailures < 2) // (and themes.zip does not exist) { LOG(VB_GUI, LOG_INFO, LOC + QString("%1 does not exist, forcing remote theme " "list download").arg(remoteThemesFile)); m_refreshDownloadableThemes = true; } if (m_refreshDownloadableThemes) { SetBusyPopupMessage(tr("Refreshing Downloadable Themes Information")); QString url = themeSite; url.append("/themes.zip"); QString destdir = GetMythUI()->GetThemeCacheDir(); destdir.append("/themechooser"); QString versiondir = QString("%1/%2").arg(destdir).arg(MythVersion); removeThemeDir(versiondir); QDir dir; dir.mkpath(destdir); bool result = GetMythDownloadManager()->download(url, remoteThemesFile); SetBusyPopupMessage(tr("Extracting Downloadable Themes Information")); if (!result || !extractZIP(remoteThemesFile, destdir)) { QFile::remove(remoteThemesFile); downloadFailures++; gCoreContext->SaveSetting("ThemeInfoDownloadFailures", downloadFailures); } } QDir remoteThemesDir(GetMythUI()->GetThemeCacheDir() .append("/themechooser/").append(MythVersion)); if ((QFile::exists(remoteThemesFile)) && (remoteThemesDir.exists())) { SetBusyPopupMessage(tr("Loading Downloadable Themes")); LOG(VB_GUI, LOG_INFO, LOC + QString("%1 and %2 exist, using cached remote themes list") .arg(remoteThemesFile).arg(remoteThemesDir.absolutePath())); QString themesPath = remoteThemesDir.absolutePath(); themes.setPath(themesPath); QFileInfoList downloadableThemes = themes.entryInfoList(); for( QFileInfoList::iterator it = downloadableThemes.begin(); it != downloadableThemes.end(); ++it ) { QString dirName = (*it).fileName(); QString themeName = dirName; QString remoteDir = themeSite; remoteDir.append("/").append(dirName); QString localDir = themes.absolutePath(); localDir.append("/").append(dirName); if (themesSeen.contains(dirName)) { ThemeInfo remoteTheme((*it).absoluteFilePath()); ThemeInfo *localTheme = m_themeNameInfos[dirName]; themeName = remoteTheme.GetName(); int rmtMaj = remoteTheme.GetMajorVersion(); int rmtMin = remoteTheme.GetMinorVersion(); int locMaj = localTheme->GetMajorVersion(); int locMin = localTheme->GetMinorVersion(); if ((rmtMaj > locMaj) || ((rmtMaj == locMaj) && (rmtMin > locMin))) { if (loadThemeInfo(*it)) { m_infoList << *it; m_themeStatuses[themeName] = "updateavailable"; QFileInfo finfo(remoteTheme.GetPreviewPath()); GetMythDownloadManager()->queueDownload( remoteDir.append("/").append(finfo.fileName()), localDir.append("/").append(finfo.fileName()), NULL); } } else if ((rmtMaj == locMaj) && (rmtMin == locMin)) { m_themeStatuses[themeName] = "uptodate"; } } else { ThemeInfo *remoteTheme = loadThemeInfo(*it); if (remoteTheme) { themeName = remoteTheme->GetName(); themesSeen << dirName; m_infoList << *it; m_themeStatuses[themeName] = "updateavailable"; QFileInfo finfo(remoteTheme->GetPreviewPath()); GetMythDownloadManager()->queueDownload( remoteDir.append("/").append(finfo.fileName()), localDir.append("/").append(finfo.fileName()), NULL); } } } } ResetBusyPopup(); qSort(m_infoList.begin(), m_infoList.end(), sortThemeNames); }