Ejemplo n.º 1
0
Kate::PluginConfigPage* PluginKateKJSWrapper::configPage (uint id, 
                                  QWidget *w, const char */*name*/) {
	kdDebug()<<"PluginKateKJSWrapper::configPage"<<endl;

	if (id>=configPages()) return 0;
        KJS::Interpreter *js = m_part->interpreter();

	KJS::Object constr=getObj(js,m_configPageFactories,id);

	if (js->globalExec()->hadException()) {
		kdDebug()<<"PluginKateKJSWrapper::configPage: exit 1"<<endl;
		js->globalExec()->clearException();
		return 0;
  	}
	
	if (!constr.implementsConstruct()) {
		kdWarning()<<"config page factory has to be an object constructor"<<endl;
		return 0;
	}

	KateKJSWrapperConfigPage *p=new KateKJSWrapperConfigPage(constr,this,w);	
	return (Kate::PluginConfigPage*)p;
/*
  KateKJSWrapperConfigPage* p = new KateKJSWrapperConfigPage(this, w);
  //init
  connect( p, SIGNAL(configPageApplyRequest(KateKJSWrapperConfigPage*)), 
           this, SLOT(applyConfig(KateKJSWrapperConfigPage*)) );
  return (Kate::PluginConfigPage*);*/
}
Ejemplo n.º 2
0
void KateGlobal::configDialog(QWidget *parent)
{
    QPointer<KPageDialog> kd = new KPageDialog(parent);
    kd->setCaption( i18n("Configure") );
    kd->setButtons( KDialog::Ok | KDialog::Cancel | KDialog::Apply | KDialog::Help );
    kd->setFaceType( KPageDialog::List );
    kd->setHelp( QString(), KGlobal::mainComponent().componentName() );

    QList<KTextEditor::ConfigPage*> editorPages;

    for (int i = 0; i < configPages (); ++i)
    {
        const QString name = configPageName (i);

        QFrame *page = new QFrame();

        KPageWidgetItem *item = kd->addPage( page, name );
        item->setHeader( configPageFullName (i) );
        item->setIcon( configPageIcon(i) );

        QVBoxLayout *topLayout = new QVBoxLayout( page );
        topLayout->setMargin( 0 );

        KTextEditor::ConfigPage *cp = configPage(i, page);
        connect(kd, SIGNAL(applyClicked  ( )), cp, SLOT(apply()));
        topLayout->addWidget( cp);
        editorPages.append (cp);
    }

    if (kd->exec() && kd)
    {
        KateGlobalConfig::global()->configStart ();
        KateDocumentConfig::global()->configStart ();
        KateViewConfig::global()->configStart ();
        KateRendererConfig::global()->configStart ();

        for (int i=0; i < editorPages.count(); ++i)
        {
            editorPages.at(i)->apply();
        }

        KateGlobalConfig::global()->configEnd ();
        KateDocumentConfig::global()->configEnd ();
        KateViewConfig::global()->configEnd ();
        KateRendererConfig::global()->configEnd ();
    }

    delete kd;
}
Ejemplo n.º 3
0
QString PluginKateKJSWrapper::configPageFullName(uint id) const {
	if (id>=configPages()) return "";
        KJS::Interpreter *js = m_part->interpreter();

	KJS::Object constr=getObj(js,m_configPageFactories,id);

	KJS::Value o=constr.get(js->globalExec(),KJS::Identifier("fullName"));
	QString retVal( o.toString(js->globalExec()).qstring() );

	kdDebug()<<"=============================================================================================="<<endl;
	kdDebug()<<"PluginKateKJSWrapper::configPageFullName: "<<retVal<<endl;
	kdDebug()<<"=============================================================================================="<<endl;
	js->globalExec()->clearException();
	return retVal;
}