[prev in list] [next in list] [prev in thread] [next in thread]
List: kwrite-devel
Subject: Re: Changes to katedialogs.*
From: Anders Lund <anders.lund () lund ! tdcadsl ! dk>
Date: 2004-01-17 21:49:39
Message-ID: 200401172249.39453.anders.lund () lund ! tdcadsl ! dk
[Download RAW message or body]
On Saturday 17 January 2004 21:30, Anders Lund wrote:
> Hi cullmann, all
>
> I have spent time making it possible for kate to display the config pages
> for plugins in the config dialogs, but i got some conflicts when updating
> cvs - mostly, the katedocument is no longer provided to plugin config page.
>
> The enclosed patch shows will make katedialogs.h/cpp be my version, and
> requires the document pointer passed from katedocument.cpp.
>
> I have also written a plugin actually using the feature, namely a
> autobookmarker, which allows you to set bookmarks when a file is loaded,
> based on a regular experession.
>
> The plugin can be fetched at http://www.alweb.dk/autobookmarks-0.1.tar.bz2
>
> please taike a look
>
> -anders
Ooops -- forgot the patch..
It is attached here, but after discussing with cullmann at irc tonight, we
decided to wait for the next release with this.
-anders
--
Jabber: anders_lund@jabber.dk
GPG fingerprint: 4B50 66DE CF6E 35E3 4446 5DC1 CB23 1264 0F2C 0826
["katedialogs.diff" (text/x-diff)]
Index: part/katedialogs.cpp
===================================================================
RCS file: /home/kde/kdelibs/kate/part/katedialogs.cpp,v
retrieving revision 1.106
diff -u -b -r1.106 katedialogs.cpp
--- part/katedialogs.cpp 4 Jan 2004 22:51:31 -0000 1.106
+++ part/katedialogs.cpp 17 Jan 2004 19:57:15 -0000
@@ -117,6 +117,7 @@
#define HLDOWNLOADPATH "http://www.kde.org/apps/kate/hl/update.xml"
//END
+//BEGIN KateConfigPage
KateConfigPage::KateConfigPage ( QWidget *parent, const char *name )
: Kate::ConfigPage (parent, name)
, m_changed (false)
@@ -133,7 +134,9 @@
m_changed = true;
kdDebug (13000) << "TEST: something changed on the config page: " << this << endl;
}
+//END KateConfigPage
+//BEGIN SpellConfigPage
SpellConfigPage::SpellConfigPage( QWidget* parent )
: KateConfigPage( parent)
{
@@ -150,8 +153,11 @@
return;
// kspell
+ if ( ! changed() ) return;
+// m_changed = false;
cPage->writeGlobalSettings ();
}
+//END SpellConfigPage
//BEGIN IndentConfigTab
const int IndentConfigTab::flags[] = {KateDocument::cfAutoIndent, \
KateDocument::cfSpaceIndent, @@ -281,6 +287,7 @@
void IndentConfigTab::reload ()
{
+ //m_changed = false; // FIXME It seems not everything is reloaded??
if (KateDocumentConfig::global()->configFlags() & \
KateDocumentConfig::cfTabIndentsMode) m_tabs->setButton (2);
else if (KateDocumentConfig::global()->configFlags() & \
KateDocumentConfig::cfTabInsertsTab) @@ -345,12 +352,14 @@
KateDocumentConfig::global()->configEnd ();
}
+// FIXME reload *everything*
void SelectConfigTab::reload ()
{
if (KateDocumentConfig::global()->configFlags() & \
KateDocumentConfig::cfPersistent) m_tabs->setButton (1);
else
m_tabs->setButton (0);
+
}
//END SelectConfigTab
@@ -511,6 +520,7 @@
KateViewConfig::global()->configEnd ();
}
+// FIXME fill this in and use it
void EditConfigTab::reload ()
{
@@ -637,6 +647,7 @@
void ViewDefaultsConfig::reload ()
{
+
m_dynwrap->setChecked(KateViewConfig::global()->dynWordWrap());
m_dynwrapIndicatorsCombo->setCurrentItem( \
KateViewConfig::global()->dynWordWrapIndicators() ); \
m_dynwrapAlignLevel->setValue(KateViewConfig::global()->dynWordWrapAlignIndent()); @@ \
-896,10 +907,12 @@ //END
//BEGIN PluginConfigPage
-PluginConfigPage::PluginConfigPage (QWidget *parent) : KateConfigPage (parent, "")
+// FIXME -- *why* doesn't this one follow the usual apply() reload() scheme ?!?
+PluginConfigPage::PluginConfigPage (QWidget *parent, KateDocument *doc) : \
KateConfigPage (parent, "") {
// sizemanagment
QGridLayout *grid = new QGridLayout( this, 1, 1 );
+ grid->setSpacing( KDialog::spacingHint() );
listView = new KatePartPluginListView(this);
listView->addColumn(i18n("Name"));
@@ -909,14 +922,22 @@
for (uint i=0; i<KateFactory::self()->plugins().count(); i++)
{
- KatePartPluginListItem *item = new \
KatePartPluginListItem(KateDocumentConfig::global()->plugin(i), i, \
(KateFactory::self()->plugins())[i]->name(), listView);
- item->setText(0, (KateFactory::self()->plugins())[i]->name());
- item->setText(1, (KateFactory::self()->plugins())[i]->comment());
-
- m_items.append (item);
- }
-
- connect(listView, SIGNAL(stateChange(KatePartPluginListItem *, bool)), this, \
SLOT(slotChanged())); + KatePartPluginListItem *item = new \
KatePartPluginListItem(m_doc->s_plugins.at(i)->load, m_doc->s_plugins.at(i), \
listView); + item->setText(0, m_doc->s_plugins.at(i)->service->name());
+ item->setText(1, m_doc->s_plugins.at(i)->service->comment());
+ // load the plugin, so we can use its configure interface if defined.
+ if ( m_doc->s_plugins.at(i)->load )
+ m_doc->loadPlugin( item->info() );
+ }
+
+ // add "configure" button
+ m_btnConfigure = new QPushButton( i18n("&Configure..."), this, \
"button_configure"); + grid->addWidget( m_btnConfigure, 1, 0, Qt::AlignRight );
+
+ m_btnConfigure->setEnabled( false );
+ connect( listView, SIGNAL( currentChanged( QListViewItem*) ),
+ this, SLOT( slotCurrentChanged(QListViewItem*) ) );
+ connect( m_btnConfigure, SIGNAL( clicked() ), this, SLOT( slotConfigure() ) );
}
PluginConfigPage::~PluginConfigPage ()
@@ -925,16 +946,112 @@
void PluginConfigPage::apply ()
{
- // nothing changed, no need to apply stuff
- if (!changed())
+ if(b)
+ loadPlugin(item);
+ else
+ unloadPlugin(item);
+ slotCurrentChanged( (QListViewItem*)item );
+ emit changed();
+}
+
+void PluginConfigPage::slotCurrentChanged( QListViewItem *item )
+{
+ bool b( false );
+ if ( ((KatePartPluginListItem*)item)->isOn() )
+ {
+ if ( ((KatePartPluginListItem*)item)->info()->load )
+ {
+ kdDebug()<<"plugin ``"<<item->text(0)<<"'' is loaded: \
"<<((KatePartPluginListItem*)item)->info()->plugin<<endl; + \
KTextEditor::ConfigInterfaceExtension *cife = + \
KTextEditor::configInterfaceExtension( \
((KatePartPluginListItem*)item)->info()->plugin ); + if ( cife ) kdDebug()<<"-- \
configinterfaceextension found"<<endl; + if ( cife && cife->configPages() > 0 )
+ {
+ b = true;
+ }
+ }
+ }
+ m_btnConfigure->setEnabled( b );
+}
+
+void PluginConfigPage::slotConfigure()
+{
+ KatePartPluginListItem *item = (KatePartPluginListItem*)listView->currentItem();
+ KTextEditor::ConfigInterfaceExtension *cife =
+ KTextEditor::configInterfaceExtension( item->info()->plugin );
+
+ if ( ! cife )
return;
- KateDocumentConfig::global()->configStart ();
+ // If we have only one page, we use a simple dialog, else an icon list type
+ KDialogBase::DialogType dt =
+ cife->configPages() > 1 ?
+ KDialogBase::IconList :
+ KDialogBase::Plain;
+
+ KDialogBase *kd = new KDialogBase ( dt,
+ i18n("Configure %1").arg(item->info()->service->name()),
+ KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Help,
+ KDialogBase::Ok,
+ this );
- for (uint i=0; i < m_items.count(); i++)
- KateDocumentConfig::global()->setPlugin (m_items.at(i)->pluginIndex(), \
m_items.at(i)->isOn()); + //KWin::setIcons( kd->winId(), kapp->icon(), \
kapp->miniIcon() );
- KateDocumentConfig::global()->configEnd ();
+ QPtrList<KTextEditor::ConfigPage> editorPages;
+
+ for (uint i = 0; i < cife->configPages (); i++)
+ {
+ QWidget *page;
+ if ( dt == KDialogBase::IconList )
+ {
+ QStringList path;
+ path.clear();
+ path << cife->configPageName( i );
+ page = kd->addVBoxPage( path, cife->configPageFullName (i),
+ cife->configPagePixmap(i, KIcon::SizeMedium) );
+ }
+ else
+ {
+ page = kd->plainPage();
+ QVBoxLayout *_l = new QVBoxLayout( page );
+ _l->setAutoAdd( true );
+ }
+
+ editorPages.append( cife->configPage( i, page ) );
+ }
+
+ if (kd->exec())
+ {
+
+ for( uint i=0; i<editorPages.count(); i++ )
+ {
+ editorPages.at( i )->apply();
+ }
+
+ //writeConfig ();
+ }
+
+ delete kd;
+}
+
+void PluginConfigPage::loadPlugin( KatePartPluginListItem *item )
+{
+ item->info()->load = true;
+ for (uint z=0; z < KateFactory::self()->documents()->count(); z++)
+ KateFactory::self()->documents()->at(z)->loadAllEnabledPlugins ();
+
+ m_doc->loadPlugin( item->info() );
+ item->setOn(true);
+}
+
+void PluginConfigPage::unloadPlugin (KatePartPluginListItem *item)
+{
+ item->info()->load = false;
+ for (uint z=0; z < KateFactory::self()->documents()->count(); z++)
+ KateFactory::self()->documents()->at(z)->loadAllEnabledPlugins ();
+
+ m_doc->unloadPlugin( item->info() );
+ item->setOn(false);
}
//END
@@ -1031,6 +1148,7 @@
HlManager::self()->getKConfig()->sync ();
}
+// FIXME ?!
void HlConfigPage::reload ()
{
}
@@ -1241,6 +1359,7 @@
}
//END
+//BEGIN HlDownloadDialog
HlDownloadDialog::HlDownloadDialog(QWidget *parent, const char *name, bool modal)
:KDialogBase(KDialogBase::Swallow, i18n("Highlight Download"), User1|Cancel, \
User1, parent, name, modal,false,i18n("&Install")) {
@@ -1323,6 +1442,7 @@
// update Config !!
SyntaxDocument doc (true);
}
+//END HlDownloadDialog
//BEGIN GotoLineDialog
GotoLineDialog::GotoLineDialog(QWidget *parent, int line, int max)
Index: part/katedialogs.h
===================================================================
RCS file: /home/kde/kdelibs/kate/part/katedialogs.h,v
retrieving revision 1.55
diff -u -b -r1.55 katedialogs.h
--- part/katedialogs.h 4 Jan 2004 22:51:31 -0000 1.55
+++ part/katedialogs.h 17 Jan 2004 19:57:15 -0000
@@ -285,15 +285,42 @@
PluginConfigPage (QWidget *parent);
~PluginConfigPage ();
+<<<<<<< katedialogs.h
+ private:
+ KateDocument *m_doc;
+ QPushButton *m_btnConfigure;
+
+ private slots:
+ void stateChange(KatePartPluginListItem *, bool);
+ // Enable the "configure" button if the plugin is loaded,
+ // and has one or more plugin pages.
+ void slotCurrentChanged( QListViewItem * );
+ // Create a dialog witht the current plugin's configure
+ // page[s] if it is loaded, and has any..
+ void slotConfigure();
+
+ void loadPlugin (KatePartPluginListItem *);
+ void unloadPlugin (KatePartPluginListItem *);
+
+ signals:
+ void changed();
+
+=======
+>>>>>>> 1.55
public slots:
void apply ();
void reload () {};
void reset () {};
void defaults () {};
+<<<<<<< katedialogs.h
+ private:
+ KatePartPluginListView* listView;
+=======
private:
KatePartPluginListView *listView;
QPtrList<KatePartPluginListItem> m_items;
+>>>>>>> 1.55
};
/**
_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic