[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/soc-kdepim-scripting/kontact/src
From: Kun Xi <bookstack () gmail ! com>
Date: 2005-08-01 5:11:16
Message-ID: 1122873076.739750.6332.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 441930 by kunxi:
Kontact now uses updated KPIM::ScriptManager, works fine.
M +11 -50 mainwindow.cpp
M +4 -7 mainwindow.h
--- branches/work/soc-kdepim-scripting/kontact/src/mainwindow.cpp #441929:441930
@@ -76,7 +76,6 @@
#include <kjsembed/kjsembedpart.h>
#include <kdesktopfile.h>
-#include <qsignalmapper.h>
#include "kjsengine.h"
#include "scriptmanager.h"
@@ -113,6 +112,7 @@
setupScripts();
publishObjects();
+ setupAddons();
}
void MainWindow::initGUI()
@@ -198,10 +198,9 @@
delete p;
p = 0;
}
+ delete scriptManager;
+ scriptManager = 0;
- delete scriptMenu;
- scriptMenu = 0;
-
Prefs::self()->writeConfig();
}
@@ -339,8 +338,6 @@
actionCollection(), "help_tipofday" );
new KAction( i18n( "&Request Feature..." ), 0, this, SLOT( slotRequestFeature() ),
actionCollection(), "help_requestfeature" );
- // Add me if you want to populate the scripts in the menu.
- scriptMenu = new KActionMenu( i18n("&Add-on"), actionCollection(), "scripts");
}
bool MainWindow::isPluginLoaded( const KPluginInfo *info )
@@ -894,62 +891,26 @@
void MainWindow::setupScripts()
{
- // refered to kate/app/katemainwindow.cpp
+ scriptManager = new KPIM::ScriptManager( this, "script_man" );
+
QStringList scripts = KGlobal::dirs()->findAllResources("data", QString(kapp->name()) + \
"/scripts/*.desktop", false, true );
for (QStringList::Iterator it = scripts.begin(); it != scripts.end(); ++it ) {
- KPIM::ScriptManager::instance()->addScript( *it );
+ scriptManager->addScript( *it );
}
}
void MainWindow::publishObjects()
{
KPIM::KJSEngine::instance()->addObject(this, "Kontact");
- QPtrList<KAction> actions;
- QSignalMapper *addonMapper = new QSignalMapper( this );
- connect( addonMapper, SIGNAL( mapped( const QString& )), this, SLOT( runScript( const QString& )));
+}
+
+void MainWindow::setupAddons()
+{
+ QPtrList<KAction> actions = scriptManager->setupActions();
- QDictIterator<KPIM::ScriptInfo> it ( KPIM::ScriptManager::instance()->scripts());
- for(; it.current(); ++it )
- {
- KPIM::ScriptInfo* si = it.current();
- kdDebug() << "Loading Add-on: " << it.currentKey() << endl;
- if( si->loadOption == "Autoload" )
- KPIM::KJSEngine::instance()->runFile( si->scriptName );
- else {
- if ( si->loadOption == "LoadOnDemand" ) {
- KAction* newAction = new KAction(it.currentKey(), 0, 0, 0 );
- connect( newAction, SIGNAL( activated() ), addonMapper, SLOT( map()) );
- addonMapper->setMapping( newAction, newAction->text() );
- actions.append( newAction );
- } else {
- kdDebug(5600) << "WARNING: unknown LoadOption for " << it.currentKey() << endl;
- continue;
- }
- }
- }
-
unplugActionList( "addons_kontact" );
plugActionList( "addons_kontact", actions );
-
- //connect( scriptMenu->popupMenu(), SIGNAL(activated( int )), this, SLOT(runScript( int )));
}
-void MainWindow::runScript( int idx )
-{
- kdDebug() << "idx =" << idx << endl;
- QString menu = scriptMenu->popupMenu()->text( idx );
- menu.remove('&');
- kdDebug() << "menu item " << menu << " clicked" << endl;
- KPIM::ScriptManager::instance()->runScript( menu );
-}
-
-
-void MainWindow::runScript( const QString& idx )
-{
- QString menu = idx;
- menu.remove('&');
- KPIM::ScriptManager::instance()->runScript( menu );
-}
-
#include "mainwindow.moc"
--- branches/work/soc-kdepim-scripting/kontact/src/mainwindow.h #441929:441930
@@ -43,7 +43,6 @@
class QFrame;
class KAction;
-class KActionMenu;
class KPluginInfo;
class KRSqueezedTextLabel;
class KHTMLPart;
@@ -83,7 +82,8 @@
virtual PluginList pluginList() const { return mPlugins; }
void setActivePluginModule( const QString & );
void setupScripts();
- virtual void publishObjects();
+ void publishObjects();
+ void setupAddons();
public slots:
virtual void selectPlugin( Kontact::Plugin *plugin );
@@ -126,14 +126,10 @@
void paintAboutScreen( const QString& msg );
static QString introductionString();
- void publishObject();
-
private slots:
void pluginsChanged();
void configureShortcuts();
void configureToolbars();
- void runScript( int idx );
- void runScript( const QString& idx );
private:
QFrame *mTopWidget;
@@ -159,8 +155,9 @@
AboutDialog *mAboutDialog;
bool mReallyClose;
+
+ KPIM::ScriptManager* scriptManager;
- KActionMenu* scriptMenu;
};
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic