Esempio n. 1
0
bool Dialog::isPluginForKCMEnabled(KCModuleInfo *moduleinfo) const
{
    // if the user of this class requested to hide disabled modules
    // we check whether it should be enabled or not
    bool enabled = true;
    kdDebug(700) << "check whether the " << moduleinfo->moduleName() << " KCM should be shown" << endl;
    // for all parent components
    QStringList parentComponents = moduleinfo->service()->property("X-KDE-ParentComponents").toStringList();
    for(QStringList::ConstIterator pcit = parentComponents.begin(); pcit != parentComponents.end(); ++pcit)
    {
        // if the parentComponent is not registered ignore it
        if(d->registeredComponents.find(*pcit) == d->registeredComponents.end())
            continue;

        // we check if the parent component is a plugin
        if(!d->plugininfomap.contains(*pcit))
        {
            // if not the KCModule must be enabled
            enabled = true;
            // we're done for this KCModuleInfo
            break;
        }
        // if it is a plugin we check whether the plugin is enabled
        KPluginInfo *pinfo = d->plugininfomap[*pcit];
        pinfo->load();
        enabled = pinfo->isPluginEnabled();
        kdDebug(700) << "parent " << *pcit << " is " << (enabled ? "enabled" : "disabled") << endl;
        // if it is enabled we're done for this KCModuleInfo
        if(enabled)
            break;
    }
    return enabled;
}
Esempio n. 2
0
void KPluginSelectionWidget::load()
{
    // kdDebug( 702 ) << k_funcinfo << endl;

    for(QMap< QCheckListItem *, KPluginInfo * >::Iterator it = d->pluginInfoMap.begin(); it != d->pluginInfoMap.end(); ++it)
    {
        KPluginInfo *info = it.data();
        info->load(d->config);
        it.key()->setOn(info->isPluginEnabled());
        if(d->visible && info == d->currentplugininfo)
            d->currentchecked = info->isPluginEnabled();
    }

    for(QValueList< KCModuleProxy * >::Iterator it = d->modulelist.begin(); it != d->modulelist.end(); ++it)
        if((*it)->changed())
            (*it)->load();

    updateConfigPage();
    // TODO: update changed state
}
Esempio n. 3
0
void KPluginSelectionWidget::executed(QListViewItem *item)
{
    kdDebug(702) << k_funcinfo << endl;
    if(item == 0)
        return;

    // Why not a dynamic_cast? - Martijn
    // because this is what the Qt API suggests; and since gcc 3.x I don't
    // trust dynamic_cast anymore - mkretz
    if(item->rtti() != 1) // check for a QCheckListItem
        return;

    QCheckListItem *citem = static_cast< QCheckListItem * >(item);
    bool checked = citem->isOn();
    // kdDebug( 702 ) << "it's a " << ( checked ? "checked" : "unchecked" )
    //    << " QCheckListItem" << endl;

    KPluginInfo *info = d->pluginInfoMap[citem];
    Q_ASSERT(!info->isHidden());

    if(info->isPluginEnabled() != checked)
    {
        kdDebug(702) << "Item changed state, emitting changed()" << endl;

        if(!d->plugincheckedchanged[info])
        {
            ++d->changed;
            if(d->changed == 1)
                emit changed(true);
        }
        d->plugincheckedchanged[info] = true;

        checkDependencies(info);
    }
    else
    {
        if(d->plugincheckedchanged[info])
        {
            --d->changed;
            if(d->changed == 0)
                emit changed(false);
        }
        d->plugincheckedchanged[info] = false;
        // FIXME: plugins that depend on this plugin need to be disabled, too
    }

    updateConfigPage(info, checked);
}
Esempio n. 4
0
void MainWindow::saveProperties( KConfig *config )
{
  Core::saveProperties( config );

  QStringList activePlugins;

  KPluginInfo::List::Iterator it = mPluginInfos.begin();
  KPluginInfo::List::Iterator end = mPluginInfos.end();
  for ( ; it != end; ++it ) {
    KPluginInfo *info = *it;
    if ( info->isPluginEnabled() ) {
      Plugin *plugin = pluginFromInfo( info );
      if ( plugin ) {
        activePlugins.append( plugin->identifier() );
        plugin->saveProperties( config );
      }
    }
  }

  config->writeEntry( "ActivePlugins", activePlugins );
}