Beispiel #1
0
static QString findFileName(const QString* tmpl,bool universal, const QString &profile) {
	QString myFile, filename;
	KStandardDirs *dirs = KGlobal::dirs();
	QString tmp = *tmpl;

	if (universal) {
		dirs->saveLocation("data", "konqsidebartng/kicker_entries/", true);
		tmp.prepend("/konqsidebartng/kicker_entries/");
	} else {
		dirs->saveLocation("data", "konqsidebartng/" + profile + "/entries/", true);
		tmp.prepend("/konqsidebartng/" + profile + "/entries/");
	}
	filename = tmp.arg("");
	myFile = locateLocal("data", filename);

	if (QFile::exists(myFile)) {
		for (ulong l = 0; l < ULONG_MAX; l++) {
			filename = tmp.arg(l);
			myFile = locateLocal("data", filename);
			if (!QFile::exists(myFile)) {
				break;
			} else {
				myFile = QString::null;
			}
		}
	}

	return myFile;
}
Beispiel #2
0
//scan the correct picture dir and get all the pics instead of loading with each filename
void KardView::loadPixmaps()
{
    QStringList picsList;
    KStandardDirs *dirs = KGlobal::dirs();
    QStringList themesFiles = dirs->findAllResources("data", "kard/pics/"+theme+"/*.png");
    themesFiles.sort();
    int i=0;
    if (!themesFiles.isEmpty()) {
        for (QStringList::Iterator it = themesFiles.begin(); it != themesFiles.end(); ++it ) {
            QFile f( *it);
            QString picture = f.fileName();
            picsList+=picture;
            px[i].load(KStandardDirs::locate("data", picture));
            if (theme == "opposites") {
                if (i%2 ==0) 
                    opp_numarr[i] = i;
                else 
                    opp_numarr[i] = i-1;
                i++;
            }
            else {
                px[i+1] = px[i];
                i=i+2;
            }
        }
        //TODO else tell no files had been found
    }
}
Beispiel #3
0
/*!
    \fn KmlExport::getConfig()
 */
int KmlExport::getConfig()
{
    KConfig config("kipirc");
    KConfigGroup group   = config.group("KMLExport Settings");

    m_localTarget        = group.readEntry("localTarget", true);
    m_optimize_googlemap = group.readEntry("optimize_googlemap", false);
    m_iconSize           = group.readEntry("iconSize", 33);
    //    googlemapSize    = group.readNumEntry("googlemapSize");
    m_size               = group.readEntry("size", 320);

    // UrlDestDir have to have the trailing
    m_baseDestDir        = group.readEntry("baseDestDir", QString("/tmp/"));
    m_UrlDestDir         = group.readEntry("UrlDestDir", QString("http://www.example.com/"));
    m_KMLFileName        = group.readEntry("KMLFileName", QString("kmldocument"));
    m_altitudeMode       = group.readEntry("Altitude Mode", 0);

    m_GPXtracks          = group.readEntry("UseGPXTracks", false);
    m_GPXFile            = group.readEntry("GPXFile", QString());
    m_TimeZone           = group.readEntry("Time Zone", 12);
    m_LineWidth          = group.readEntry("Line Width", 4);
    m_GPXColor           = group.readEntry("Track Color", "#17eeee" );
    m_GPXOpacity         = group.readEntry("Track Opacity", 64 );
    m_GPXAltitudeMode    = group.readEntry("GPX Altitude Mode", 0);

    KStandardDirs dir;
    m_tempDestDir        = dir.saveLocation("tmp", "kipi-kmlrexportplugin-" + QString::number(getpid()) + '/');
    m_imageDir           = "images/";
    m_googlemapSize      = 32;
    return 1;
}
Beispiel #4
0
/**
 * There might be a "better" way of doing this, but I don't know it,
 * but I do know that this does work. :)  Feel free to improve the loading system,
 * there isn't much code anyway.
 */
void AudioCDEncoder::findAllPlugins(KIO::SlaveBase *slave, QList<AudioCDEncoder *>&encoders)
{
    QString foundEncoders;

		KStandardDirs standardDirs;
    QStringList dirs = standardDirs.findDirs("module", QLatin1String( "" ));
    for (QStringList::const_iterator it = dirs.constBegin(); it != dirs.constEnd(); ++it) {
        QDir dir(*it);
        if (!dir.exists()) {
            kDebug(7117) << "Directory given by KStandardDirs: " << dir.path() << " doesn't exists!";
            continue;
        }

        dir.setFilter(QDir::Files | QDir::Hidden);
        const QFileInfoList files = dir.entryInfoList();
        for (int i = 0; i < files.count(); ++i) {
            QFileInfo fi(files.at(i));
            if (0 < fi.fileName().count(QRegExp( QLatin1String( "^libaudiocd_encoder_.*.so$" )))) {
                QString fileName = (fi.fileName().mid(0, fi.fileName().indexOf(QLatin1Char( '.' ))));
                if (foundEncoders.contains(fileName)) {
                    kDebug(7117) << "Warning, encoder has been found twice!";
                    continue;
                }
                foundEncoders.append(fileName);
                KLibrary::void_function_ptr function = loadPlugin(fileName);
                if (function) {
                    void (*functionPointer) (KIO::SlaveBase *, QList<AudioCDEncoder*>&) =
                            (void (*)(KIO::SlaveBase *slave, QList<AudioCDEncoder *>&encoders)) function;
                    functionPointer(slave, encoders);
                }
            }
        }
    }
}
Beispiel #5
0
void KFFWin_Flightplan::getFlightplanList( QStringList & list )
{
	KStandardDirs stddirs;
	QString dirname;
	QDir dir;

	dirname = stddirs.saveLocation( "data" );
	dir.cd( dirname );

	if ( !dir.exists( "kfreeflight" ) )
	{
		dir.mkdir( "kfreeflight" );
	}

	dir.cd( "kfreeflight" );

	if ( !dir.exists( "flightplans" ) )
	{
		dir.mkdir( "flightplans" );
	}

	dir.cd( "flightplans" );

	list = dir.entryList( QDir::Files, QDir::Name );

}
Beispiel #6
0
void DocMetaInfo::scanMetaInfo( bool force )
{
  if ( mLoaded && !force ) return;

  mLanguages = KGlobal::locale()->languagesTwoAlpha();

  kdDebug( 1400 ) << "LANGS: " << mLanguages.join( " " ) << endl;

  QStringList::ConstIterator it;
  for( it = mLanguages.begin(); it != mLanguages.end(); ++it ) {
    mLanguageNames.insert( *it, languageName( *it ) );
  }

  KConfig config( "khelpcenterrc" );
  config.setGroup( "General" );
  QStringList metaInfos = config.readListEntry( "MetaInfoDirs" );

  if ( metaInfos.isEmpty() ) {
    KStandardDirs* kstd = KGlobal::dirs();
    kstd->addResourceType( "data", "share/apps/khelpcenter" );
    metaInfos = kstd->findDirs( "data", "plugins" );
  }
  for( it = metaInfos.begin(); it != metaInfos.end(); it++) {
    kdDebug() << "DocMetaInfo::scanMetaInfo(): scanning " << *it << endl;
    scanMetaInfoDir( *it, &mRootEntry );
  }

  mLoaded = true;
}
Beispiel #7
0
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();
}
Beispiel #8
0
/*
 * This creates a Tab OCR
 */
void KOCRBase::ocrIntro( )
{
    m_ocrPage = addVBoxPage( i18n("OCR") );

    // Caption - Label and image
    /* labelstring */
    (void) new QLabel( i18n("<b>Starting Optical Character Recognition with %1</b><p>").
                       arg( ocrEngineName() ), m_ocrPage );
    // Find the kadmos logo and display if available
    KStandardDirs stdDir;
    QString logo = stdDir.findResource( "data", "kooka/pics/" + ocrEngineLogo() );

    kdDebug(28000)<< "Reading logo " << logo << endl;
    QPixmap pix;
    QWidget *pa = m_ocrPage;

    if( pix.load( logo ))
    {
        QHBox *hb_cap = new QHBox( m_ocrPage );
        hb_cap->setSpacing( KDialog::spacingHint());

        QLabel *imgLab = new QLabel( hb_cap );
        imgLab->setAlignment( Qt::AlignHCenter | Qt::AlignTop  );
        imgLab->setPixmap( pix );
        pa = hb_cap;
    }

    (void) new KActiveLabel( ocrEngineDesc(), pa );
}
/**
 * There might be a "better" way of doing this, but I don't know it,
 * but I do know that this does work. :)  Feel free to improve the loading system,
 * there isn't much code anyway.
 */
void AudioCDEncoder::findAllPlugins(KIO::SlaveBase *slave, QPtrList<AudioCDEncoder> &encoders){
    QString foundEncoders;

    KStandardDirs standardDirs;
    QStringList dirs = standardDirs.findDirs("module", "");
    for (QStringList::Iterator it = dirs.begin(); it != dirs.end(); ++it) {
        QDir dir(*it);
        if (!dir.exists()) {
            kdDebug(7117) << "Directory given by KStandardDirs: " << dir.path() << " doesn't exists!" << endl;
            continue;
        }
        dir.setFilter(QDir::Files | QDir::Hidden);
  
        QStringList list = dir.entryList( "libaudiocd_encoder_*.so");
        kdDebug() << "list " << list << endl;
        for (QStringList::ConstIterator it2 = list.begin(); it2 != list.end(); ++it2) 
        {
            QString fileName = *it2;
            kdDebug() << fileName << endl;
            if (foundEncoders.contains(fileName)) {
                kdDebug(7117) << "Warning, encoder has been found twice!" << endl; 
                continue;
            }
            foundEncoders.append(fileName);
            fileName = fileName.mid(0, fileName.find('.'));
            void *function = loadPlugin(fileName);
            if(function){
                void (*functionPointer)(KIO::SlaveBase *, QPtrList<AudioCDEncoder> &) = (void (*)(KIO::SlaveBase *slave, QPtrList<AudioCDEncoder> &encoders)) function;
                functionPointer(slave, encoders);
            }
        } 
    }
}
Beispiel #10
0
void Rad::load()
{
	if (loaded)
		return;

	KStandardDirs *dirs = KGlobal::dirs();
	QString radkfile = dirs->findResource("data", "kiten/radkfile");
	if (radkfile.isNull())
	{
		KMessageBox::error(0, i18n("Kanji radical information file not installed, so radical searching cannot be used."));
		return;
	}

	QFile f(radkfile);

	if (!f.open(IO_ReadOnly))
	{
		KMessageBox::error(0, i18n("Kanji radical information could not be loaded, so radical searching cannot be used."));
	}

	QTextStream t(&f);
	t.setCodec(QTextCodec::codecForName("eucJP"));
	Radical cur;
	while (!t.eof())
	{
		QString s = t.readLine();

		QChar first = s.at(0);
		if (first == '#') // comment!
		{
			// nothing
		}
		else if (first == '$') // header
		{
			// save previous one
			if( !cur.kanji().isNull() )
				list.append(cur);

			//first entry is trim(last 4 chars).. <rad><space><strokes>
			unsigned int strokes = s.right(2).toUInt();
			QString radical = QString(s.at(2));
			cur = Radical(radical, strokes);
		}
		else // continuation
		{
			cur.addKanji(s);
		}
	}

	// we gotta append the last one!!
	// this nagged jasonkb for a bit wondering why fue wasn't showing up ;)
	list.append(cur);

	f.close();

	loaded = true;
}
void KSimPackageFileWidget::defaultPressed()
{
	KStandardDirs dirs;
	QStringList libList;

	m_files->setFileList(libList);   // Empty list!!!

	libList = dirs.findDirs(QString::fromLatin1("lib"),QString::fromLatin1("ksimus"));
	
	m_directories->setFileList(libList);
}
Beispiel #12
0
KRomajiEdit::KRomajiEdit(QWidget *parent, const char *name)
	: KLineEdit(parent, name)
{
	kana = "unset";

	KStandardDirs *dirs = KGlobal::dirs();
	QString romkana = dirs->findResource("data", "kiten/romkana.cnv");
	if (romkana.isNull())
	{
		KMessageBox::error(0, i18n("Romaji information file not installed, so Romaji conversion cannot be used."));
		return;
	}

	QFile f(romkana);
	
	if (!f.open(IO_ReadOnly))
	{
		KMessageBox::error(0, i18n("Romaji information could not be loaded, so Romaji conversion cannot be used."));
	}

	QTextStream t(&f);
	t.setCodec(QTextCodec::codecForName("eucJP"));
	while (!t.eof())
	{
		QString s = t.readLine();

		QChar first = s.at(0);
		if (first == '#') // comment!
		{
			// nothing
		}
		else if (first == '$') // header
		{
			if (kana == "unset")
				kana = "hiragana";
			else
				kana = "katakana";
		}
		else // body
		{
			QStringList things(QStringList::split(QChar(' '), s));
			QString thekana(things.first());
			QString romaji(*things.at(1));

			if (kana == "hiragana")
				hiragana[romaji] = thekana;
			else if (kana == "katakana")
				katakana[romaji] = thekana;
		}
	}
	f.close();

	kana = "english";
}
Beispiel #13
0
void addBackEnd::aboutToShowAddMenu()
{
	if (!menu)
		return;
	KStandardDirs *dirs = KGlobal::dirs();
	QStringList list = dirs->findAllResources("data","konqsidebartng/add/*.desktop",true,true);
	libNames.setAutoDelete(true);
	libNames.resize(0);
	libParam.setAutoDelete(true);
	libParam.resize(0);
	menu->clear();
	int i = 0;

	for (QStringList::Iterator it = list.begin(); it != list.end(); ++it, i++ )
	{
		KDesktopFile *confFile;

		confFile = new KDesktopFile(*it, true);
		if (! confFile->tryExec()) {
			delete confFile;
			i--;
			continue;
		}
		if (m_universal) {
			if (confFile->readEntry("X-KDE-KonqSidebarUniversal").upper()!="TRUE") {
				delete confFile;
				i--;
				continue;
			}
		} else {
			if (confFile->readEntry("X-KDE-KonqSidebarBrowser").upper()=="FALSE") {
				delete confFile;
				i--;
				continue;
			}
		}
		QString icon = confFile->readIcon();
		if (!icon.isEmpty())
		{
			menu->insertItem(SmallIcon(icon),
					 confFile->readEntry("Name"), i);
		} else {
			menu->insertItem(confFile->readEntry("Name"), i);
		}
		libNames.resize(libNames.size()+1);
		libNames.insert(libNames.count(), new QString(confFile->readEntry("X-KDE-KonqSidebarAddModule")));
		libParam.resize(libParam.size()+1);
		libParam.insert(libParam.count(), new QString(confFile->readEntry("X-KDE-KonqSidebarAddParam")));
		delete confFile;
	}
        menu->insertSeparator();
        menu->insertItem(i18n("Rollback to System Default"), i);
}
void ProjectSelectionPage::itemChanged( const QModelIndex& current, const QModelIndex& )
{
    KStandardDirs* dirs = m_templatesModel->plugin()->componentData().dirs();
    QString picPath = dirs->findResource("apptemplate_previews", m_templatesModel->data( current, Qt::UserRole+2 ).toString() );
    if( picPath.isEmpty() ) 
    {
        picPath = dirs->findResource("apptemplate_previews", "default-kdevelop.png");
    }
    ui->preview->setPixmap( QPixmap( picPath ) );
    ui->description->setText( m_templatesModel->data( current ).toString() );
    validateData();
}
Beispiel #15
0
QString ArchiveMan::xmlBaseDir() const
{
    KStandardDirs stdDirs;
    QString outputDir = KraftSettings::self()->pdfOutputDir();
    if ( outputDir.isEmpty() ) {
        outputDir = stdDirs.saveLocation( "data", "kraft/archiveXml", true );
    }

    if ( ! outputDir.endsWith( "/" ) ) outputDir += "/";

    return outputDir;
}
Beispiel #16
0
bool Workspace::saveWorkSheet( WorkSheet *sheet )
{
  if ( !sheet ) {
    KMessageBox::sorry( this, i18n( "You do not have a tab that could be saved." ) );
    return false;
  }

  KStandardDirs* kstd = KGlobal::dirs();
  QString fileName = kstd->saveLocation( "data", "ksysguard") + sheet->fileName();

  if ( !sheet->save( fileName ) ) {
    return false;
  }
  return true;
}
Beispiel #17
0
void addBackEnd::doRollBack()
{
	if (KMessageBox::warningContinueCancel(m_parent, i18n("<qt>This removes all your entries from the sidebar and adds the system default ones.<BR><B>This procedure is irreversible</B><BR>Do you want to proceed?</qt>"))==KMessageBox::Continue)
	{
		KStandardDirs *dirs = KGlobal::dirs();
		QString loc=dirs->saveLocation("data","konqsidebartng/" + m_currentProfile + "/",true);
		QDir dir(loc);
		QStringList dirEntries = dir.entryList( QDir::Dirs | QDir::NoSymLinks );
		dirEntries.remove(".");
		dirEntries.remove("..");
		for ( QStringList::Iterator it = dirEntries.begin(); it != dirEntries.end(); ++it ) {
			if ((*it)!="add")
				 KIO::NetAccess::del(KURL( loc+(*it) ), m_parent);
		}
		emit initialCopyNeeded();
	}
}
void TrafficGraph::drawBackground(QPainter *p, int w, int h)
{
  p->fillRect(0,0,w, h, mBackgroundColor);

  if(mSvgFilename.isEmpty())
    return; //nothing to draw, return

  QSvgRenderer *svgRenderer;
  if(!sSvgRenderer.contains(mSvgFilename)) {
    KStandardDirs* kstd = KGlobal::dirs();
    QString file = kstd->findResource( "data", "ksysguard/" + mSvgFilename);

    svgRenderer =  new QSvgRenderer(file, this);
    sSvgRenderer.insert(mSvgFilename, svgRenderer);
  } else
    svgRenderer = sSvgRenderer[mSvgFilename];
  svgRenderer->render(p);
}
void KPrHtmlExportDialog::loadTemplatesList()
{
    KStandardDirs std;
    QStringList dirs = std.findDirs("data", "stage/templates/exportHTML/templates");
    for (QStringList::ConstIterator path=dirs.constBegin(); path!=dirs.constEnd(); ++path) {
        QDir dir(*path);
        dir.setFilter(QDir::Files);
        QStringList entries = dir.entryList();
        for (QStringList::ConstIterator entry=entries.constBegin(); entry!=entries.constEnd(); ++entry) {
            if (*entry != "." && *entry != "..") {
                QString name = *entry;
                if(name.endsWith(QLatin1String(".zip"), Qt::CaseInsensitive)){
                    name.chop(4);
                }
                ui.kcombobox->addItem(name, QVariant(QString(*path + *entry)));
            }
        }
    }
    ui.kcombobox->insertSeparator(ui.kcombobox->count());
}
Beispiel #20
0
void Sidebar_Widget::addWebSideBar(const KURL& url, const QString& /*name*/) {
	//kdDebug() << "Web sidebar entry to be added: " << url.url()
	//	<< " [" << name << "]" << endl;

	// Look for existing ones with this URL
	KStandardDirs *dirs = KGlobal::dirs();
	QString list;
	dirs->saveLocation("data", m_relPath, true);
	list = locateLocal("data", m_relPath);

	// Go through list to see which ones exist.  Check them for the URL
	QStringList files = QDir(list).entryList("websidebarplugin*.desktop");
	for (QStringList::Iterator it = files.begin(); it != files.end(); ++it){
		KSimpleConfig scf(list + *it, false);
		scf.setGroup("Desktop Entry");
		if (scf.readPathEntry("URL", QString::null) == url.url()) {
			// We already have this one!
			KMessageBox::information(this,
					i18n("This entry already exists."));
			return;
		}
	}

	QString tmpl = "websidebarplugin%1.desktop";
	QString myFile = findFileName(&tmpl,m_universalMode,m_currentProfile);

	if (!myFile.isEmpty()) {
		KSimpleConfig scf(myFile, false);
		scf.setGroup("Desktop Entry");
		scf.writeEntry("Type", "Link");
		scf.writePathEntry("URL", url.url());
		scf.writeEntry("Icon", "netscape");
		scf.writeEntry("Name", i18n("Web SideBar Plugin"));
		scf.writeEntry("Open", "true");
		scf.writeEntry("X-KDE-KonqSidebarModule", "konqsidebar_web");
		scf.sync();

		QTimer::singleShot(0,this,SLOT(updateButtons()));
	}
}
/**
 * set the defaults from a config file
 */
void CodeGenerationPolicy::setDefaults(bool emitUpdateSignal)
{
    blockSignals(true); // we need to do this because otherwise most of these
    // settors below will each send the modifiedCodeContent() signal
    // needlessly (we can just make one call at the end).

    setCodeVerboseSectionComments(UmbrelloSettings::forceDoc());
    setCodeVerboseDocumentComments(UmbrelloSettings::forceSections());
    setLineEndingType(UmbrelloSettings::lineEndingType());
    setIndentationType(UmbrelloSettings::indentationType());
    setIndentationAmount(UmbrelloSettings::indentationAmount());
    setAutoGenerateConstructors(UmbrelloSettings::autoGenEmptyConstructors());
    setAttributeAccessorScope(UmbrelloSettings::defaultAttributeAccessorScope());
    setAssociationFieldScope(UmbrelloSettings::defaultAssocFieldScope());
    setCommentStyle(UmbrelloSettings::commentStyle());

    calculateIndentation();

    QString path = UmbrelloSettings::outputDirectory();
    if (path.isEmpty())
        path = QDir::homePath() + QLatin1String("/uml-generated-code/");
    setOutputDirectory (QDir (path));

    path = UmbrelloSettings::headingsDirectory();
    if (path.isEmpty()) {
        KStandardDirs stddirs;
        path =  stddirs.findDirs("data", QLatin1String("umbrello/headings")).first();
    }
    setHeadingFileDir (path);

    setIncludeHeadings(UmbrelloSettings::includeHeadings());
    setOverwritePolicy(UmbrelloSettings::overwritePolicy());
    setModifyPolicy(UmbrelloSettings::modnamePolicy());

    blockSignals(false); // "as you were citizen"

    if (emitUpdateSignal)
        emit modifiedCodeContent();
}
Beispiel #22
0
QString Workspace::makeNameForNewSheet() const
{
  /* Find a name of the form "Sheet %d" that is not yet used by any
   * of the existing worksheets. */
  int i = 1;
  bool found = false;
  QString sheetName;
  KStandardDirs* kstd = KGlobal::dirs();
  do {
    sheetName = i18n( "Sheet %1" ,  i++ );
    //Check we don't have any existing files with this name
    found = !(kstd->findResource( "data", "ksysguard/" + sheetName + ".sgrd").isEmpty());

    //Check if we have any sheets with the same tab name or file name
    for(int i = 0; !found && i < mSheetList.size(); i++)
      if ( tabText(indexOf(mSheetList.at(i))) == sheetName  || QString(sheetName+".sgrd") == mSheetList.at(i)->fileName())
        found = true;

  } while ( found );

  return sheetName;
}
void DesktopThemeDetails::removeTheme()
{
    bool removeTheme = true;
    KConfigGroup cfg = KConfigGroup(KSharedConfig::openConfig("plasmarc"), "Theme");
    QString activeTheme = cfg.readEntry("name", "default");
    const QString theme = m_theme->currentIndex().data(ThemeModel::PackageNameRole).toString();
    const QString themeName = m_theme->currentIndex().data(Qt::DisplayRole).toString();


    if (m_themeCustomized) {
        if(KMessageBox::questionYesNo(this, i18n("Theme items have been changed.  Do you still wish remove the \"%1\" theme?", themeName), i18n("Remove Desktop Theme")) == KMessageBox::No) {
            removeTheme = false;
        }
    } else {
        if (theme == "default") {
            KMessageBox::information(this, i18n("Removal of the default desktop theme is not allowed."), i18n("Remove Desktop Theme"));
            removeTheme = false;
        } else {
            if(KMessageBox::questionYesNo(this, i18n("Are you sure you wish remove the \"%1\" theme?", themeName), i18n("Remove Desktop Theme")) == KMessageBox::No) {
                removeTheme = false;
            }
        }

    }
    KStandardDirs dirs;
    if (removeTheme) {
        if (theme == activeTheme) {
            setDesktopTheme("default");
            activeTheme = "default";
        }
        if (QDir(dirs.locateLocal("data", "desktoptheme/" + theme, false)).exists()) {
            KIO::DeleteJob *deleteTheme = KIO::del(QUrl::fromLocalFile(dirs.locateLocal("data", "desktoptheme/" + theme, false)), KIO::HideProgressInfo);
            KIO::NetAccess::synchronousRun(deleteTheme, this);
        }
    }
    m_themeModel->reload();
    reloadConfig();
    m_theme->setCurrentIndex(m_themeModel->indexOf(activeTheme));
}
/**
 * Executes the script using the "sh" shell.
 * @param	sCscopePath		If given, overrides the automatic check for Cscope's
 *							path
 * @param	sCtagsPath		If given, overrides the automatic check for Ctags'
 *							path
 * @param	sDotPath		If given, overrides the automatic check for Dot's
 *							path
 * @param	bCscopeOptsOnly	Only verify cscope's path and options
 * @return	true if successful, false otherwise
 */
bool ConfigFrontend::run(const QString& sCscopePath, 
	const QString& sCtagsPath, const QString& sDotPath,
	bool bCscopeOptsOnly)
{
	QStringList slArgs;
	KStandardDirs sd;
	QString sScript;

	// Execute using the user's shell
	setUseShell();

	// Find the configuration script
	sScript = sd.findResource("data", "kscope/kscope_config");
	if (sScript.isEmpty())
		return false;

	// Set command line arguments
	slArgs << QString("sh") << sScript;

	// Initialise environment
	setEnv("CSCOPE_PATH", sCscopePath);
	if (bCscopeOptsOnly){
		slArgs << QString("-co");
	} else {
		setEnv("CTAGS_PATH", sCtagsPath);
		setEnv("DOT_PATH", sDotPath);
	}

	// Parser initialisation
	m_delim = Newline;
	m_nNextResult = CscopePath;

	if (!Frontend::run("sh", QStringList(slArgs)))
		return false;

	emit test(CscopePath);
	return true;
}
Beispiel #25
0
void Workspace::readProperties( const KConfigGroup& cfg )
{
  QStringList selectedSheets = cfg.readPathEntry( "SelectedSheets", QStringList() );

  if ( selectedSheets.isEmpty() ) {
   /* If SelectedSheets config entry is not there, then it's
    * probably the first time the user has started KSysGuard. We
    * then "restore" a special default configuration. */
    selectedSheets << "ProcessTable.sgrd";
    selectedSheets << "SystemLoad2.sgrd";
  } else if(selectedSheets[0] != "ProcessTable.sgrd") {
    //We need to make sure that this is really is the process table on the first tab. No GUI way of changing this, but should make sure anyway.
    //Plus this migrates users from the kde3 setup
    selectedSheets.removeAll("ProcessTable.sgrd");
    selectedSheets.prepend( "ProcessTable.sgrd");
  }

  int oldSystemLoad = selectedSheets.indexOf("SystemLoad.sgrd");
  if(oldSystemLoad != -1) {
    selectedSheets.replace(oldSystemLoad, "SystemLoad2.sgrd");
  }

  KStandardDirs* kstd = KGlobal::dirs();
  QString filename;
  for ( QStringList::Iterator it = selectedSheets.begin(); it != selectedSheets.end(); ++it ) {
    filename = kstd->findResource( "data", "ksysguard/" + *it);
    if(!filename.isEmpty()) {
      restoreWorkSheet( filename, false);
    }
  }

  int idx = cfg.readEntry( "currentSheet", 0 );
  if (idx < 0 || idx > count() - 1) {
    idx = 0;
  }
  setCurrentIndex(idx);
}
Beispiel #26
0
int main(int argc, char **argv)
{
    KAboutData about("kapptemplate", 0, ki18n("KAppTemplate"), version, ki18n(description),
                     KAboutData::License_GPL, ki18n("(C) 2008 Anne-Marie Mahfouf"),KLocalizedString(), 0, "*****@*****.**");
    about.addAuthor( ki18n("Anne-Marie Mahfouf"), KLocalizedString(), "annma AT kde DOT org");
    about.addAuthor( ki18n("Sean Wilson"), ki18n("Icons from Oxygen Team icons"), "suseux AT googlemail DOT com");
    
    KCmdLineArgs::init(argc, argv, &about);

    KCmdLineOptions options;
    KCmdLineArgs::addCmdLineOptions(options);
    KApplication app;

    KStandardDirs* dirs = KGlobal::dirs();
    dirs->addResourceType( "apptemplates", "data", "kdevappwizard/templates/" );
    dirs->addResourceType( "apptemplate_descriptions", "data", "kdevappwizard/template_descriptions/" );
    dirs->addResourceType( "apptemplate_previews", "data", "kdevappwizard/template_previews/" );

    KAppTemplate appTemplate(0);
    appTemplate.show();


    return app.exec();
} 
Beispiel #27
0
bool KDesktopFile::isAuthorizedDesktopFile(const QString &path)
{
    if(!kapp || kapp->authorize("run_desktop_files"))
        return true;

    if(path.isEmpty())
        return false; // Empty paths are not ok.

    if(QDir::isRelativePath(path))
        return true; // Relative paths are ok.

    KStandardDirs *dirs = KGlobal::dirs();
    if(QDir::isRelativePath(dirs->relativeLocation("apps", path)))
        return true;
    if(QDir::isRelativePath(dirs->relativeLocation("xdgdata-apps", path)))
        return true;
    if(QDir::isRelativePath(dirs->relativeLocation("services", path)))
        return true;
    if(dirs->relativeLocation("data", path).startsWith("kdesktop/Desktop"))
        return true;

    kdWarning() << "Access to '" << path << "' denied because of 'run_desktop_files' restriction." << endl;
    return false;
}
void DesktopThemeDetails::clearCustomized(const QString& themeRoot) {
    KStandardDirs dirs;

    if ((isCustomized(themeRoot))) {
        // Remove both possible unnamed customized directories
        if (QDir(dirs.locateLocal("data", "desktoptheme/.customized", false)).exists()) {
            KIO::DeleteJob *clearCustom = KIO::del(QUrl::fromLocalFile(dirs.locateLocal("data", "desktoptheme/.customized", false)), KIO::HideProgressInfo);
            KIO::NetAccess::synchronousRun(clearCustom, this);
        }
        if (QDir(dirs.locateLocal("data", "desktoptheme/.customized1", false)).exists()) {
            KIO::DeleteJob *clearCustom1 = KIO::del(QUrl::fromLocalFile(dirs.locateLocal("data", "desktoptheme/.customized1", false)), KIO::HideProgressInfo);
            KIO::NetAccess::synchronousRun(clearCustom1, this);
        }
    } else {
        if (QDir(dirs.locateLocal("data", "desktoptheme/" + themeRoot, false)).exists()) {
            KIO::DeleteJob *clearCustom = KIO::del(QUrl::fromLocalFile(dirs.locateLocal("data", "desktoptheme/" + themeRoot, false)), KIO::HideProgressInfo);
            KIO::NetAccess::synchronousRun(clearCustom, this);
        }
    }
}
Beispiel #29
0
bool ThumbView::readSettings()
{
   KConfig *cfg = KGlobal::config();
   cfg->setGroup( THUMB_GROUP );
   bool dirty = false;

   QColor color;
   color = cfg->readColorEntry( MARGIN_COLOR1, &(colorGroup().base()));
   if( color != m_marginColor1 )
   {
      dirty = true;
      m_marginColor1 = color;
   }

   color = cfg->readColorEntry( MARGIN_COLOR2, &(colorGroup().foreground()));
   if( color != m_marginColor2 )
   {
      dirty = true;
      m_marginColor2 = color;
   }

   int value;
   bool sizeDirty = false;
   value = cfg->readNumEntry( THUMB_MARGIN, 5 );
   if( value != m_thumbMargin )
   {
      sizeDirty = true;
      m_thumbMargin = value;
   }

   value = cfg->readNumEntry( PIXMAP_WIDTH, 100 );
   if( value != m_pixWidth || m_pixWidth == 0 )
   {
      sizeDirty  = true;
      m_pixWidth = value;
   }

   value = cfg->readNumEntry( PIXMAP_HEIGHT, 120 );
   if( value != m_pixHeight || m_pixHeight == 0 )
   {
      sizeDirty  = true;
      m_pixHeight = value;
   }

   if( sizeDirty )
   {
      int gX = 2*m_thumbMargin+m_pixWidth+10;
      int gY = 2*m_thumbMargin+m_pixHeight+10;
      m_iconView->setGridX(gX);
      m_iconView->setGridY(gY);
      kdDebug(28000) << "Setting Grid " << gX << " - " << gY << endl;
   }

   KStandardDirs stdDir;
   QString newBgImg = cfg->readEntry( BG_WALLPAPER, stdDir.findResource( "data", STD_TILE_IMG ) );

   if( m_bgImg != newBgImg )
   {
      m_bgImg = newBgImg;
      slSetBackGround();
   }

   return (sizeDirty || dirty);
}
Beispiel #30
0
	QDBusReply<QDBusObjectPath> rep=s.DomainBrowserNew(-1, -1, "", (d->m_type==Browsing) ? 
	    AVAHI_DOMAIN_BROWSER_BROWSE : AVAHI_DOMAIN_BROWSER_REGISTER,0);
	
	if (!rep.isValid()) return;
	org::freedesktop::Avahi::DomainBrowser *b=new org::freedesktop::Avahi::DomainBrowser("org.freedesktop.Avahi",rep.value().path(),
	    QDBusConnection::systemBus());
	connect(b,SIGNAL(ItemNew(int,int,QString,uint)),d, SLOT(gotNewDomain(int,int,QString,uint)));
	connect(b,SIGNAL(ItemRemove(int,int,QString,uint)),d, SLOT(gotRemoveDomain(int,int,QString,uint)));
	d->m_browser=b;
	if (d->m_type==Browsing) {	
    	    QString domains_evar=qgetenv("AVAHI_BROWSE_DOMAINS");
	    if (!domains_evar.isEmpty()) {
		QStringList edomains=domains_evar.split(':');
		Q_FOREACH(const QString &s, edomains) d->gotNewDomain(-1,-1,s,0);
	    }
	    KStandardDirs dirs;
	    //FIXME: watch this file and restart browser if it changes
	    QFile domains_cfg(dirs.localxdgconfdir()+"/avahi/browse-domains");
	    if (domains_cfg.open(QIODevice::ReadOnly | QIODevice::Text)) 
		while (!domains_cfg.atEnd()) d->gotNewDomain(-1,-1,QString::fromUtf8(domains_cfg.readLine().data()).trimmed(),0);
	    
	}
	    	    
}

void DomainBrowserPrivate::gotNewDomain(int,int,const QString& domain,uint)
{
	QString decoded=DNSToDomain(domain);
	if (m_domains.contains(decoded)) return;
	m_domains+=decoded;
	emit m_parent->domainAdded(decoded);