Esempio n. 1
0
void KoDocumentInfoAuthor::initParameters()
{
    KConfig* config = KoGlobal::kofficeConfig();
    if ( config->hasGroup( "Author" ) ) {
        KConfigGroupSaver cgs( config, "Author" );
        m_telephoneHome=config->readEntry( "telephone" );
        m_telephoneWork=config->readEntry( "telephone-work" );
        m_fax=config->readEntry( "fax" );
        m_country=config->readEntry( "country" );
        m_postalCode=config->readEntry( "postal-code" );
        m_city=config->readEntry( "city" );
        m_street=config->readEntry( "street" );
    }

  m_emailCfg = new KConfig( "emaildefaults", true );
  m_emailCfg->setGroup( "Defaults" );
  QString group = m_emailCfg->readEntry("Profile","Default");
  m_emailCfg->setGroup(QString("PROFILE_%1").arg(group));

  if ( m_fullName.isNull() ) // only if null. Empty means the user made it explicitly empty.
  {
    QString name = m_emailCfg->readEntry( "FullName" );
    if ( !name.isEmpty() )
      m_fullName = name;
  }
  if ( m_company.isNull() )
  {
    QString name = m_emailCfg->readEntry( "Organization" );
    if ( !name.isEmpty() )
      m_company = name;
  }
}
Esempio n. 2
0
void DockBarExtension::loadContainerConfig()
{
    KConfig *conf = config();
    conf->setGroup("General");
    QStringList applets = conf->readListEntry("Applets");

    QStringList fail_list;
    for(QStringList::Iterator it = applets.begin(); it != applets.end(); ++it)
    {
        if(!conf->hasGroup(*it))
            continue;
        conf->setGroup(*it);
        QString cmd = conf->readPathEntry("Command");
        QString resName = conf->readPathEntry("resName");
        QString resClass = conf->readEntry("resClass");
        if(cmd.isEmpty() || resName.isEmpty() || resClass.isEmpty())
            continue;

        DockContainer *c = new DockContainer(cmd, this, resName, resClass);
        addContainer(c);

        KProcess proc;
        proc << KShell::splitArgs(cmd);
        if(!proc.start(KProcess::DontCare))
        {
            fail_list.append(cmd);
            removeContainer(c);
        }
    }
    if(!fail_list.isEmpty())
        KMessageBox::queuedMessageBox(0, KMessageBox::Information,
                                      i18n("The following dockbar applets could not be started: %1").arg(fail_list.join(", ")),
                                      i18n("kicker: information"), 0);
    saveContainerConfig();
}
void ProtoeditorSettings::loadSites()
{
  KConfig* config = KGlobal::config();
  SiteSettings* site;
  int i = 0;
  while(config->hasGroup(QString("Site_%1").arg(i))) {
    site = new SiteSettings(QString::number(i));
    m_siteSettingsMap[site->name()] = site;
    i++;
  }
}
Esempio n. 4
0
PiwigoWindow::PiwigoWindow(DInfoInterface* const iface,
                           QWidget* const /*parent*/)
    : WSToolDialog(nullptr, QLatin1String("PiwigoSync Dialog")),
      d(new Private(this, iface))
{
    d->pPiwigo = new PiwigoSession();

    setWindowTitle( i18n("Piwigo Export") );
    setModal(false);

    // "Start Upload" button
    startButton()->setText( i18n("Start Upload") );
    startButton()->setEnabled(false);

    connect(startButton(), SIGNAL(clicked()),
            this, SLOT(slotAddPhoto()));

    // we need to let d->talker work..
    d->talker      = new PiwigoTalker(iface, d->widget);

    // setting progressDlg and its numeric hints
    d->progressDlg = new QProgressDialog(this);
    d->progressDlg->setModal(true);
    d->progressDlg->setAutoReset(true);
    d->progressDlg->setAutoClose(true);
    d->progressDlg->setMaximum(0);
    d->progressDlg->reset();

    d->pUploadList = new QStringList;

    // connect functions
    connectSignals();

    QPointer<PiwigoLoginDlg> configDlg;
    KConfig config;

    if (!config.hasGroup("Piwigo Settings") )
    {
        configDlg = new PiwigoLoginDlg(QApplication::activeWindow(),
                                       d->pPiwigo,
                                       i18n("Edit Piwigo Data") );

        if (configDlg->exec() != QDialog::Accepted)
        {
            delete configDlg;
        }
    }

    readSettings();
    slotDoLogin();
}
Esempio n. 5
0
// backward compatibility
void Settings::read_settings_v1(KConfig &cfg_P)
{
    int sections = cfg_P.readNumEntry("Num_Sections", 0);
    Action_data_group *menuentries = NULL;
    for(Action_data_group::Iterator it(actions->first_child()); *it; ++it)
    {
        Action_data_group *tmp = dynamic_cast< Action_data_group * >(*it);
        if(tmp == NULL)
            continue;
        if(tmp->system_group() == Action_data_group::SYSTEM_MENUENTRIES)
        {
            menuentries = tmp;
            break;
        }
    }
    for(int sect = 1; sect <= sections; ++sect)
    {
        QString group = QString("Section%1").arg(sect);
        if(!cfg_P.hasGroup(group))
            continue;
        cfg_P.setGroup(group);
        QString name = cfg_P.readEntry("Name");
        if(name.isNull())
            continue;
        QString shortcut = cfg_P.readEntry("Shortcut");
        if(shortcut.isNull())
            continue;
        QString run = cfg_P.readEntry("Run");
        if(run.isNull())
            continue;
        bool menuentry = cfg_P.readBoolEntry("MenuEntry", false);
        // CHECKME tohle pridavani az pak je trosku HACK
        if(menuentry)
        {
            if(menuentries == NULL)
            {
                menuentries =
                    new Action_data_group(actions, i18n(MENU_EDITOR_ENTRIES_GROUP_NAME), i18n("These entries were created using Menu Editor."), NULL,
                                          Action_data_group::SYSTEM_MENUENTRIES, true);
                menuentries->set_conditions(new Condition_list("", menuentries));
            }
            (void)new Menuentry_shortcut_action_data(menuentries, name, "", KShortcut(shortcut), run);
        }
        else
        {
            (void)new Command_url_shortcut_action_data(actions, name, "", KShortcut(shortcut), run);
        }
    }
}
Esempio n. 6
0
void CompMgrClient::fillWidgetSetting(const QString & name, bool overwrite)
{
    if(!m_compSetting.contains(name) || overwrite)
    {
        QString group("Composite_");
        group += name;
        windowCompositeSetting winsetting;
        KConfig * config = ScimKdeSettings::self()->config();
        if(config->hasGroup(group))
        {
            config->setGroup(group);
            winsetting.translucencyEnabled = config->readBoolEntry("EnableTranslucency", true);
            winsetting.translucency = config->readNumEntry("Translucency", 75);
        } else
        {
            //default value: EnableTranslucency is true
            winsetting.translucencyEnabled = true;
            winsetting.translucency = 75;
        }
        m_compSetting[name] = winsetting;
    }
}
Esempio n. 7
0
void ExportNotesJob::backupConfig()
{
    setProgressDialogLabel(i18n("Backing up config..."));

    const QString knotesStr(QStringLiteral("knotesrc"));
    const QString knotesrc = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QLatin1Char('/') + knotesStr;
    backupFile(knotesrc, Utils::configsPath(), knotesStr);

    const QString globalNoteSettingsStr(QStringLiteral("globalnotesettings"));
    const QString globalNoteSettingsrc = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QLatin1Char('/') + globalNoteSettingsStr;

    if (QFile(globalNoteSettingsrc).exists()) {
        KSharedConfigPtr globalnotesettingsrc = KSharedConfig::openConfig(globalNoteSettingsrc);

        QTemporaryFile tmp;
        tmp.open();

        KConfig *knoteConfig = globalnotesettingsrc->copyTo(tmp.fileName());
        const QString selectFolderNoteStr(QStringLiteral("SelectNoteFolder"));
        if (knoteConfig->hasGroup(selectFolderNoteStr)) {
            KConfigGroup selectFolderNoteGroup = knoteConfig->group(selectFolderNoteStr);

            const QString selectFolderNoteGroupStr(QStringLiteral("DefaultFolder"));
            Utils::convertCollectionIdsToRealPath(selectFolderNoteGroup, selectFolderNoteGroupStr);
        }
        knoteConfig->sync();
        backupFile(tmp.fileName(), Utils::configsPath(), globalNoteSettingsStr);
        delete knoteConfig;
    }
    backupUiRcFile(QStringLiteral("knotesappui.rc"), QStringLiteral("knotes"));
    backupUiRcFile(QStringLiteral("knotesui.rc"), QStringLiteral("knotes"));
    backupUiRcFile(QStringLiteral("knotes_part.rc"), QStringLiteral("knotes"));
    backupConfigFile(QStringLiteral("akonadi_notes_agent.notifyrc"));
    storeDirectory(QStringLiteral("/knotes/print/theme/"));
    Q_EMIT info(i18n("Config backup done."));
}
Esempio n. 8
0
void SlickerCardManager::loadCards()
{
 	kdDebug(155004) << ("SlickerCardManager::loadCards()\n");
 	KConfig *config = kapp->config();

	config->setGroup("General");
 	QStringList ids = config->readListEntry("Cards");

 	for (QStringList::Iterator it = ids.begin(); it != ids.end(); ++it)
 	{
 		kdDebug(155004) << "found card: " << *it << endl;
		QString groupName = QString("Card_").append(*it);
		
		if (!config->hasGroup(groupName)) continue;
		KConfigGroup group(config,groupName);

 		CardDesk::Card *card = createCard(group.readEntry("AppletDesktopFile"), group.readEntry("AppletConfigFile"), &group);

		if (!card) continue;
		card->setCardId(*it);
		registerCard(card);

 	}
}
Esempio n. 9
0
void KateSessionManager::activateSession(KateSession::Ptr session, bool closeLast, bool saveLast, bool loadNew)
{
    // don't reload.
    // ### comparing the pointers directly is b0rk3d :(
    if(!session->sessionName().isEmpty() && session->sessionName() == m_activeSession->sessionName())
        return;
    // try to close last session
    if(closeLast)
    {
        if(KateApp::self()->activeMainWindow())
        {
            if(!KateApp::self()->activeMainWindow()->queryClose_internal())
                return;
        }
    }

    // save last session or not?
    if(saveLast)
        saveActiveSession(true);

    // really close last
    if(closeLast)
    {
        KateDocManager::self()->closeAllDocuments();
    }

    // set the new session
    m_activeSession = session;

    if(loadNew)
    {
        // open the new session
        Kate::Document::setOpenErrorDialogsActivated(false);

        KConfig *sc = activeSession()->configRead();

        if(sc)
            KateApp::self()->documentManager()->restoreDocumentList(sc);

        // if we have no session config object, try to load the default
        // (anonymous/unnamed sessions)
        if(!sc)
            sc = new KSimpleConfig(sessionsDir() + "/default.katesession");

        // window config
        if(sc)
        {
            KConfig *c = KateApp::self()->config();
            c->setGroup("General");

            if(c->readBoolEntry("Restore Window Configuration", true))
            {
                // a new, named session, read settings of the default session.
                if(!sc->hasGroup("Open MainWindows"))
                    sc = new KSimpleConfig(sessionsDir() + "/default.katesession");

                sc->setGroup("Open MainWindows");
                unsigned int wCount = sc->readUnsignedNumEntry("Count", 1);

                for(unsigned int i = 0; i < wCount; ++i)
                {
                    if(i >= KateApp::self()->mainWindows())
                    {
                        KateApp::self()->newMainWindow(sc, QString("MainWindow%1").arg(i));
                    }
                    else
                    {
                        sc->setGroup(QString("MainWindow%1").arg(i));
                        KateApp::self()->mainWindow(i)->readProperties(sc);
                    }
                }

                if(wCount > 0)
                {
                    while(wCount < KateApp::self()->mainWindows())
                    {
                        KateMainWindow *w = KateApp::self()->mainWindow(KateApp::self()->mainWindows() - 1);
                        KateApp::self()->removeMainWindow(w);
                        delete w;
                    }
                }
            }
        }

        Kate::Document::setOpenErrorDialogsActivated(true);
    }
}
void KopeteApplication::slotLoadPlugins()
{
	// we have to load the address book early, because calling this enters the Qt event loop when there are remote resources.
	// The plugin manager is written with the assumption that Kopete will not reenter the event loop during plugin load,
	// otherwise lots of things break as plugins are loaded, then contacts are added to incompletely initialised MCLVIs
	Kopete::KABCPersistence::self()->addressBook();

	//Create the command handler (looks silly)
	Kopete::CommandHandler::commandHandler();

	//Create the view manager
	KopeteViewManager::viewManager();

	Kopete::AccountManager::self()->load();
	Kopete::ContactList::self()->load();

	KConfig *config = KGlobal::config();

	// Parse command-line arguments
	KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

	bool showConfigDialog = false;

	config->setGroup( "Plugins" );

	/* FIXME: This is crap, if something purged that groups but your accounts
	 * are still working kopete will load the necessary plugins but still show the
	 * stupid accounts dialog (of course empty at that time because account data
	 * gets loaded later on). [mETz - 29.05.2004]
	 */
	if ( !config->hasGroup( "Plugins" ) )
		showConfigDialog = true;

	// Listen to arguments
	/*
	// TODO: conflicts with emoticon installer and the general meaning
	// of %U in kopete.desktop
	if ( args->count() > 0 )
	{
		showConfigDialog = false;
		for ( int i = 0; i < args->count(); i++ )
			Kopete::PluginManager::self()->setPluginEnabled( args->arg( i ), true );
	}
	*/

	// Prevent plugins from loading? (--disable=foo,bar)
	QStringList disableArgs = QStringList::split( ',', args->getOption( "disable" ) );
	for ( QStringList::ConstIterator it = disableArgs.begin(); it != disableArgs.end(); ++it )
	{
		showConfigDialog = false;
		Kopete::PluginManager::self()->setPluginEnabled( *it, false );
	}

	// Load some plugins exclusively? (--load-plugins=foo,bar)
	if ( args->isSet( "load-plugins" ) )
	{
		config->deleteGroup( "Plugins", true );
		showConfigDialog = false;
		QStringList plugins = QStringList::split( ',', args->getOption( "load-plugins" ) );
		for ( QStringList::ConstIterator it = plugins.begin(); it != plugins.end(); ++it )
			Kopete::PluginManager::self()->setPluginEnabled( *it, true );
	}

	config->sync();

	// Disable plugins altogether? (--noplugins)
	if ( !args->isSet( "plugins" ) )
	{
		// If anybody reenables this I'll get a sword and make a nice chop-suy out
		// of your body :P [mETz - 29.05.2004]
		// This screws up kopeterc because there is no way to get the Plugins group back!
		//config->deleteGroup( "Plugins", true );

		showConfigDialog = false;
		// pretend all plugins were loaded :)
		QTimer::singleShot(0, this, SLOT( slotAllPluginsLoaded() ));
	}
	else
	{
		Kopete::PluginManager::self()->loadAllPlugins();
	}

	connect( Kopete::PluginManager::self(), SIGNAL( allPluginsLoaded() ),
		this, SLOT( slotAllPluginsLoaded() ));

	if( showConfigDialog )
	{
		// No plugins specified. Show the config dialog.
		// FIXME: Although it's a bit stupid it is theoretically possible that a user
		//        explicitly configured Kopete to not load plugins on startup. In this
		//        case we don't want this dialog. We need some other config setting
		//        like a bool hasRunKopeteBefore or so to trigger the loading of the
		//        wizard. Maybe using the last run version number is more useful even
		//        as it also allows for other features. - Martijn
		// FIXME: Possibly we need to influence the showConfigDialog bool based on the
		//        command line arguments processed below. But how exactly? - Martijn
		// NB: the command line args are completely broken atm.  
		// I don't want to fix them for 3.5 as plugin loading will change for KDE4.	- Will
		AddAccountWizard *m_addwizard = new AddAccountWizard( Kopete::UI::Global::mainWidget(), "addAccountWizard", true, true );
		m_addwizard->exec();
		Kopete::AccountManager::self()->save();
	}
}
Esempio n. 11
0
void KNotify::notify(const QString &event, const QString &fromApp, const QString &text, QString sound, QString file, int present, int level,
                     int winId, int eventId)
{
    // kdDebug() << "event=" << event << " fromApp=" << fromApp << " text=" << text << " sound=" << sound <<
    //    " file=" << file << " present=" << present << " level=" << level <<  " winId=" << winId << " eventId=" << eventId << endl;
    if(d->inStartup)
    {
        d->startupEvents += "(" + event + ":" + fromApp + ")";
    }

    QString commandline;
    KConfig *eventsFile = NULL;
    KConfig *configFile = NULL;

    // check for valid events
    if(!event.isEmpty())
    {

        // get config file
        if(d->events.contains(fromApp))
        {
            eventsFile = d->events[fromApp];
        }
        else
        {
            eventsFile = new KConfig(locate("data", fromApp + "/eventsrc"), true, false);
            d->events.insert(fromApp, eventsFile);
        }
        if(d->configs.contains(fromApp))
        {
            configFile = d->configs[fromApp];
        }
        else
        {
            configFile = new KConfig(fromApp + ".eventsrc", true, false);
            d->configs.insert(fromApp, configFile);
        }

        if(!eventsFile->hasGroup(event) && isGlobal(event))
        {
            eventsFile = d->globalEvents;
            configFile = d->globalConfig;
        }

        eventsFile->setGroup(event);
        configFile->setGroup(event);

        // get event presentation
        if(present == -1)
            present = configFile->readNumEntry("presentation", -1);
        if(present == -1)
            present = eventsFile->readNumEntry("default_presentation", 0);

        // get sound file name
        if(present & KNotifyClient::Sound)
        {
            QString theSound = configFile->readPathEntry("soundfile");
            if(theSound.isEmpty())
                theSound = eventsFile->readPathEntry("default_sound");
            if(!theSound.isEmpty())
                sound = theSound;
        }

        // get log file name
        if(present & KNotifyClient::Logfile)
        {
            QString theFile = configFile->readPathEntry("logfile");
            if(theFile.isEmpty())
                theFile = eventsFile->readPathEntry("default_logfile");
            if(!theFile.isEmpty())
                file = theFile;
        }

        // get default event level
        if(present & KNotifyClient::Messagebox)
            level = eventsFile->readNumEntry("level", 0);

        // get command line
        if(present & KNotifyClient::Execute)
        {
            commandline = configFile->readPathEntry("commandline");
            if(commandline.isEmpty())
                commandline = eventsFile->readPathEntry("default_commandline");
        }
    }

    // emit event
    if(present & KNotifyClient::Sound) // && QFile(sound).isReadable()
        notifyBySound(sound, fromApp, eventId);

    if(present & KNotifyClient::Execute)
        notifyByExecute(commandline, event, fromApp, text, winId, eventId);

    if(present & KNotifyClient::Logfile) // && QFile(file).isWritable()
        notifyByLogfile(text, file);

    if(present & KNotifyClient::Stderr)
        notifyByStderr(text);

    if(present & KNotifyClient::Taskbar)
        notifyByTaskbar(checkWinId(fromApp, winId));

    if(present & KNotifyClient::PassivePopup)
        notifyByPassivePopup(text, fromApp, eventsFile, checkWinId(fromApp, winId));
    else if(present & KNotifyClient::Messagebox)
        notifyByMessagebox(text, level, checkWinId(fromApp, winId));

    QByteArray qbd;
    QDataStream ds(qbd, IO_WriteOnly);
    ds << event << fromApp << text << sound << file << present << level << winId << eventId;
    emitDCOPSignal("notifySignal(QString,QString,QString,QString,QString,int,int,int,int)", qbd);
}
Esempio n. 12
0
void KCMStyle::loadStyle( KConfig& config )
{
	cbStyle->clear();

	// Create a dictionary of WidgetStyle to Name and Desc. mappings,
	// as well as the config page info
	styleEntries.clear();
	styleEntries.setAutoDelete(true);

	QString strWidgetStyle;
	QStringList list = KGlobal::dirs()->findAllResources("themes", "*.themerc", true, true);
	for (QStringList::iterator it = list.begin(); it != list.end(); ++it)
	{
		KSimpleConfig config( *it, true );
		if ( !(config.hasGroup("KDE") && config.hasGroup("Misc")) )
			continue;

		config.setGroup("KDE");

		strWidgetStyle = config.readEntry("WidgetStyle");
		if (strWidgetStyle.isNull())
			continue;

		// We have a widgetstyle, so lets read the i18n entries for it...
		StyleEntry* entry = new StyleEntry;
		config.setGroup("Misc");
		entry->name = config.readEntry("Name");
		entry->desc = config.readEntry("Comment", i18n("No description available."));
		entry->configPage = config.readEntry("ConfigPage", QString::null);

		// Check if this style should be shown
		config.setGroup("Desktop Entry");
		entry->hidden = config.readBoolEntry("Hidden", false);

		// Insert the entry into our dictionary.
		styleEntries.insert(strWidgetStyle.lower(), entry);
	}

	// Obtain all style names
	QStringList allStyles = QStyleFactory::keys();

	// Get translated names, remove all hidden style entries.
	QStringList styles;
	StyleEntry* entry;
	for (QStringList::iterator it = allStyles.begin(); it != allStyles.end(); it++)
	{
		QString id = (*it).lower();
		// Find the entry.
		if ( (entry = styleEntries.find(id)) != 0 )
		{
			// Do not add hidden entries
			if (entry->hidden)
				continue;

			styles += entry->name;

			nameToStyleKey[entry->name] = id;
		}
		else
		{
			styles += (*it); //Fall back to the key (but in original case)
			nameToStyleKey[*it] = id;
		}
	}

	// Sort the style list, and add it to the combobox
	styles.sort();
	cbStyle->insertStringList( styles );

	// Find out which style is currently being used
	config.setGroup( "General" );
	QString defaultStyle = KStyle::defaultStyle();
	QString cfgStyle = config.readEntry( "widgetStyle", defaultStyle );

	// Select the current style
	// Do not use cbStyle->listBox() as this may be NULL for some styles when
	// they use QPopupMenus for the drop-down list!

	// ##### Since Trolltech likes to seemingly copy & paste code,
	// QStringList::findItem() doesn't have a Qt::StringComparisonMode field.
	// We roll our own (yuck)
	cfgStyle = cfgStyle.lower();
	int item = 0;
	for( int i = 0; i < cbStyle->count(); i++ )
	{
		QString id = nameToStyleKey[cbStyle->text(i)];
		item = i;
		if ( id == cfgStyle )	// ExactMatch
			break;
		else if ( id.contains( cfgStyle ) )
			break;
		else if ( id.contains( QApplication::style().className() ) )
			break;
		item = 0;
	}
	cbStyle->setCurrentItem( item );

	m_bStyleDirty = false;

	switchStyle( currentStyle() );	// make resets visible
}