Esempio n. 1
0
void ViewManager::deleteView()
{
    QString text = i18n("<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>")
                   .arg(mActiveView->caption());
    QString caption = i18n("Confirm Delete");

    if(KMessageBox::warningContinueCancel(this, text, caption, KGuiItem(i18n("&Delete"), "editdelete")) == KMessageBox::Continue)
    {
        mViewNameList.remove(mActiveView->caption());

        // remove the view from the config file
        KConfig *config = mCore->config();
        config->deleteGroup(mActiveView->caption());

        mViewDict.remove(mActiveView->caption());
        mActiveView = 0;

        // we are in an invalid state now, but that should be fixed after
        // we emit the signal
        mActionSelectView->setItems(mViewNameList);
        if(mViewNameList.count() > 0)
        {
            mActionSelectView->setCurrentItem(0);
            setActiveView(mViewNameList[ 0 ]);
        }
        mActionDeleteView->setEnabled(mViewNameList.count() > 1);
    }
}
Esempio n. 2
0
/******************************************************************************
* Read the configuration file.
* Create the client list and open all calendar files.
*/
void ADConfigData::readConfig()
{
    kdDebug(5900) << "ADConfigData::readConfig()" << endl;
    ClientInfo::clear();
    KConfig *config = KGlobal::config();
    QStringList clients = config->groupList().grep(CLIENT_GROUP_SEARCH);
    for(QStringList::Iterator cl = clients.begin();  cl != clients.end();  ++cl)
    {
        // Read this client's configuration
        config->setGroup(*cl);
        QString client = *cl;
        client.remove(CLIENT_GROUP_SEARCH);
        QString  title       = config->readEntry(TITLE_KEY, client);   // read app title (default = app name)
        QCString dcopObject  = config->readEntry(DCOP_OBJECT_KEY).local8Bit();
        bool     startClient = config->readBoolEntry(START_CLIENT_KEY, false);
        QString  calendar    = config->readPathEntry(CALENDAR_KEY);

        // Verify the configuration
        bool ok = false;
        if(client.isEmpty()  ||  KStandardDirs::findExe(client).isNull())
            kdError(5900) << "ADConfigData::readConfig(): group '" << *cl << "' deleted (client app not found)\n";
        else if(calendar.isEmpty())
            kdError(5900) << "ADConfigData::readConfig(): no calendar specified for '" << client << "'\n";
        else if(dcopObject.isEmpty())
            kdError(5900) << "ADConfigData::readConfig(): no DCOP object specified for '" << client << "'\n";
        else
        {
            ADCalendar *cal = ADCalendar::getCalendar(calendar);
            if(cal)
                kdError(5900) << "ADConfigData::readConfig(): calendar registered by multiple clients: " << calendar << endl;
            else
                ok = true;
        }
        if(!ok)
        {
            config->deleteGroup(*cl, true);
            continue;
        }

        // Create the client and calendar objects
        new ClientInfo(client.local8Bit(), title, dcopObject, calendar, startClient);
        kdDebug(5900) << "ADConfigData::readConfig(): client " << client << " : calendar " << calendar << endl;
    }

    // Remove obsolete CheckInterval entry (if it exists)
    config->setGroup("General");
    config->deleteEntry("CheckInterval");

    // Save any updates
    config->sync();
}
Esempio n. 3
0
void ViewManager::addView()
{
    AddViewDialog dialog(&mViewFactoryDict, this);

    if(dialog.exec())
    {
        QString newName = dialog.viewName();
        QString type = dialog.viewType();

        // Check for name conflicts
        bool firstConflict = true;
        int numTries = 1;
        while(mViewNameList.contains(newName) > 0)
        {
            if(!firstConflict)
            {
                newName = newName.left(newName.length() - 4);
                firstConflict = false;
            }

            newName = QString("%1 <%2>").arg(newName).arg(numTries);
            numTries++;
        }

        // Add the new one to the list
        mViewNameList.append(newName);

        // write the view to the config file,
        KConfig *config = mCore->config();
        config->deleteGroup(newName);
        KConfigGroupSaver saver(config, newName);
        config->writeEntry("Type", type);

        // try to set the active view
        mActionSelectView->setItems(mViewNameList);
        mActionSelectView->setCurrentItem(mViewNameList.findIndex(newName));
        setActiveView(newName);

        editView();

        mActionDeleteView->setEnabled(mViewNameList.count() > 1);
    }
}
Esempio n. 4
0
void ToolConfig::removeTool()
{
    //KILE_DEBUG() << "==ToolConfig::removeTool()=====================" << endl;
    if ( KMessageBox::warningContinueCancel(this, i18n("Are you sure you want to remove the tool %1?").arg(m_current)) == KMessageBox::Continue )
    {
        KConfig *config = m_config;
        QStringList cfgs = KileTool::configNames(m_current, config);
        for ( uint i = 0; i < cfgs.count(); ++i)
        {
            config->deleteGroup(KileTool::groupFor(m_current, cfgs[i]));
        }
        config->setGroup("Tools");
        config->deleteEntry(m_current);
        int index = m_configWidget->m_lstbTools->currentItem()-1;
        if ( index < 0 ) index=0;
        QString tool = m_configWidget->m_lstbTools->text(index);
        m_configWidget->m_lstbTools->blockSignals(true);
        updateToollist();
        m_configWidget->m_lstbTools->setCurrentItem(index);
        switchTo(tool, false);
        m_configWidget->m_lstbTools->blockSignals(false);
    }
}
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. 6
0
/******************************************************************************
* Remove a client application's details from the config file.
*/
void ADConfigData::removeClient(const QCString &appName)
{
    KConfig *config = KGlobal::config();
    config->deleteGroup(CLIENT_GROUP + QString::fromLocal8Bit(appName));
    config->sync();
}
Esempio n. 7
0
void TopLevel::config()
{
  if (!confdlg) {
    confdlg = new KDialogBase(KDialogBase::Plain, i18n("Configure Tea Cooker"),
                              KDialogBase::Ok|KDialogBase::Cancel|KDialogBase::Help,
                              KDialogBase::Ok, this, "config", true);
    QWidget *page = confdlg->plainPage();
    // FIXME: enforce sensible initial/default size of dialog
    // FIXME: modal is ok, but can avoid always-on-top?

    QBoxLayout *top_box = new QVBoxLayout(page, 0, 8);    // whole config-stuff
    QBoxLayout *box = new QHBoxLayout(top_box);           // list + properties

    /* left side - tea list and list-modifying buttons */
    QBoxLayout *leftside = new QVBoxLayout(box);
    QGroupBox *listgroup = new QGroupBox(2, Vertical, i18n("Tea List"), page);
    leftside->addWidget(listgroup, 0, 0);

    listbox = new QListView(listgroup, "listBox");
    listbox->addColumn(i18n("Name"));
    listbox->header()->setClickEnabled(false, listbox->header()->count()-1);
    listbox->addColumn(i18n("Time"));
    listbox->header()->setClickEnabled(false, listbox->header()->count()-1);
    listbox->setSorting(-1);
    connect(listbox, SIGNAL(selectionChanged()), SLOT(listBoxItemSelected()));

    // now buttons for editing the tea-list
    QWidget *listgroup_widget = new QWidget(listgroup);
    QBoxLayout *hbox = new QHBoxLayout(listgroup_widget);
    hbox->setSpacing(4);
    btn_new = new QPushButton(QString::null, listgroup_widget);
    QToolTip::add(btn_new, i18n("New"));
    btn_new->setPixmap(SmallIcon("filenew"));
    btn_new->setMinimumSize(btn_new->sizeHint() * 1.2);
    connect(btn_new, SIGNAL(clicked()), SLOT(newButtonClicked()));
    hbox->addWidget(btn_new);

    btn_del = new QPushButton(QString::null, listgroup_widget);
    QToolTip::add(btn_del, i18n("Delete"));
    btn_del->setIconSet(SmallIconSet("editdelete"));
    btn_del->setMinimumSize(btn_new->sizeHint() * 1.2);
    connect(btn_del, SIGNAL(clicked()), SLOT(delButtonClicked()));
    hbox->addWidget(btn_del);

    btn_up = new QPushButton(QString::null, listgroup_widget);
    QToolTip::add(btn_up, i18n("Up"));
    btn_up->setIconSet(SmallIconSet("up"));
    btn_up->setMinimumSize(btn_up->sizeHint() * 1.2);
    connect(btn_up, SIGNAL(clicked()), SLOT(upButtonClicked()));
    hbox->addWidget(btn_up);

    btn_down = new QPushButton(QString::null, listgroup_widget);
    QToolTip::add(btn_down, i18n("Down"));
    btn_down->setIconSet(SmallIconSet("down"));
    btn_down->setMinimumSize(btn_down->sizeHint() * 1.2);
    connect(btn_down, SIGNAL(clicked()), SLOT(downButtonClicked()));
    hbox->addWidget(btn_down);

    hbox->addStretch(10);

    /* right side - tea properties */
    QBoxLayout *rightside = new QVBoxLayout(box);
    editgroup = new QGroupBox(2, Vertical, i18n("Tea Properties"), page);
    rightside->addWidget(editgroup, 0, 0);
    QHBox *propbox = new QHBox(editgroup);

    // FIXME: - must enforce correct vertical alignment of each label-editor pair
    //          (better use one HBox for each label-editor pair?)
    QVBox *propleft = new QVBox(propbox);
    QVBox *propright = new QVBox(propbox);
    nameEdit = new QLineEdit(propright);
    nameEdit->setFixedHeight(nameEdit->sizeHint().height());
    nameEdit->setAlignment(QLineEdit::AlignLeft);
    QLabel *l = new QLabel(nameEdit, i18n("Name:"), propleft);
    l->setFixedSize(l->sizeHint());
    connect(nameEdit, SIGNAL(textChanged(const QString&)), SLOT(nameEditTextChanged(const QString&)) );

    timeEdit = new TimeEdit(propright);
    timeEdit->setFixedHeight(timeEdit->sizeHint().height());
    l = new QLabel(timeEdit, i18n("Tea time:"), propleft);
    l->setFixedSize(l->sizeHint());
    connect(timeEdit, SIGNAL(valueChanged(int)), SLOT(spinBoxValueChanged(int)));

    /* bottom - timeout actions */
    QGroupBox *actiongroup = new QGroupBox(4, Vertical, i18n("Action"), page);
    top_box->addWidget(actiongroup, 0, 0);

    QWidget *actionconf_widget = new QWidget(actiongroup);
    QBoxLayout *actionconf_hbox = new QHBoxLayout(actionconf_widget);
    btn_conf = new QPushButton(i18n("Configure Events..."), actionconf_widget);
    actionconf_hbox->addWidget(btn_conf);
    connect(btn_conf, SIGNAL(clicked()), SLOT(confButtonClicked()));
    actionconf_hbox->addStretch(10);

    eventEnable = new QCheckBox(i18n("Event"), actiongroup);
    popupEnable = new QCheckBox(i18n("Popup"), actiongroup);
    eventEnable->setFixedHeight(eventEnable->sizeHint().height());
    popupEnable->setFixedHeight(popupEnable->sizeHint().height());

    QHBox *actionbox = new QHBox(actiongroup);
    actionEnable = new QCheckBox(actionbox);
//    FIXME: add text to this line:
//    QLabel *actionLabel = new QLabel(i18n("Execute: "), actiongroup);
    actionEdit = new QLineEdit(actionbox);
    actionEdit->setFixedHeight(actionEdit->sizeHint().height());
    QToolTip::add(actionEdit, i18n("Enter command here; '%t' will be replaced with name of steeping tea"));
    connect(actionEnable, SIGNAL(toggled(bool)), SLOT(actionEnableToggled(bool)));
    rightside->addStretch();

    // single checkbox
    visEnable = new QCheckBox(i18n("Visualize progress in icon tray"), page);
    top_box->addWidget(visEnable, 0, 0);


    // let listbox claim all remaining vertical space
    top_box->setStretchFactor(box, 10);

    connect(confdlg, SIGNAL(helpClicked()), SLOT(help()));
  }

  // now add all defined teas (and their times) to the listview
  // this is done backwards because QListViewItems are inserted at the top
  listbox->clear();
  for (int i=teas.count()-1; i>=0; i--) {
    TeaListItem *item = new TeaListItem(listbox);
    item->setName(teas[i].name);
    item->setTime(teas[i].time);
    if ((unsigned int)i == current_selected)
      current_item = item;
  }

  // select first entry in listbox; if no entries present then disable right side
  if (listempty) {
    enable_controls();
    disable_properties();
    nameEdit->setText("");
    timeEdit->setValue(1);
  } else {
    listbox->setSelected(listbox->firstChild(), true);
  }

  // -------------------------

  eventEnable->setChecked(useNotify);
  popupEnable->setChecked(usePopup);
  actionEnable->setChecked(useAction);
  actionEdit->setText(action);
  actionEdit->setEnabled(useAction);
  visEnable->setChecked(useTrayVis);

  if (confdlg->exec() == QDialog::Accepted)
  {
    // activate new settings
    useNotify = eventEnable->isChecked();
    usePopup = popupEnable->isChecked();
    useAction = actionEnable->isChecked();
    action = actionEdit->text();
    useTrayVis = visEnable->isChecked();

    teas.clear();

    // Copy over teas and times from the QListView
    int i = 0;
    teas.clear();
    teas.resize(listbox->childCount());
    for (QListViewItemIterator it(listbox); it.current() != 0; ++it) {
      teas[i].name = static_cast<TeaListItem *>(it.current())->name();
      teas[i].time = static_cast<TeaListItem *>(it.current())->time();
      if (it.current() == current_item)
        current_selected = i;
      i++;
    }

    listempty = (teas.count() == 0);

    rebuildTeaMenus();

    // and store to config
    KConfig *config = kapp->config();
    // remove old-style entries from default-group (if present)
    if (config->hasKey("UserTea"))
      config->deleteEntry("UserTea");

    config->setGroup("General");
    config->writeEntry("Beep", useNotify);
    config->writeEntry("Popup", usePopup);
    config->writeEntry("UseAction", useAction);
    config->writeEntry("Action", action);
    config->writeEntry("Tea", current_selected);
    config->writeEntry("UseTrayVis", useTrayVis);
    // first get rid of all previous tea-entries from config, then write anew
    config->deleteGroup("Teas", true);          // deep remove of whole group
    config->setGroup("Teas");
    config->writeEntry("Number", teas.count());
    QString key;
    int index = 1;
    for (QValueVector<tea_struct>::ConstIterator it = teas.begin(); it != teas.end(); ++it) {
      key.sprintf("Tea%d Name", index);
      config->writeEntry(key, it->name);
      key.sprintf("Tea%d Time", index);
      config->writeEntry(key, it->time);
      index++;
    }

    config->sync();
  }
}