[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-07-31 22:10:13
Message-ID: 1122847813.718220.25704.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 441775 by kunxi:
Now, everything works.
We just need to refactor scriptManager. -- We don't need a singleton pattern.
Each part would have a scriptManager, and the part-specific menu items are connected \
to it. With GUI rc, the part-specific menu items are merged to the Kontact Add-on \
Menu.
M +5 -3 kontactui.rc
M +28 -12 mainwindow.cpp
M +1 -0 mainwindow.h
--- branches/work/soc-kdepim-scripting/kontact/src/kontactui.rc #441774:441775
@@ -12,6 +12,11 @@
<Merge/>
</Menu>
<Merge />
+ <Menu name="addons"><text>&Add-ons</text>
+ <ActionList name="addons_kontact" />
+ <Separator />
+ <DefineGroup name="addons_plugins" append="addons_plugins_merge"/>
+ </Menu>
<Menu name="settings">
<text>&Settings</text>
<Merge append="save_merge"/>
@@ -27,9 +32,6 @@
<Action name="options_configure_toolbars"/>
-->
</Menu>
- <Menu name="tools"><text>&Tools</text>
- <Action name="scripts"/>
- </Menu>
<Menu name="help"><text>&Help</text>
<Action name="help_introduction"/>
<Action name="help_tipofday"/>
--- branches/work/soc-kdepim-scripting/kontact/src/mainwindow.cpp #441774:441775
@@ -65,11 +65,6 @@
#include <kaboutdata.h>
#include <kmenubar.h>
-#include <kjsembed/kjsembedpart.h>
-#include <kdesktopfile.h>
-#include "kjsengine.h"
-#include "scriptmanager.h"
-
#include "aboutdialog.h"
#include "iconsidepane.h"
#include "mainwindow.h"
@@ -79,6 +74,12 @@
#include "statusbarprogresswidget.h"
#include "broadcaststatus.h"
+#include <kjsembed/kjsembedpart.h>
+#include <kdesktopfile.h>
+#include <qsignalmapper.h>
+#include "kjsengine.h"
+#include "scriptmanager.h"
+
using namespace Kontact;
class SettingsDialogWrapper : public KSettings::Dialog
@@ -106,10 +107,11 @@
// Set this to be the group leader for all subdialogs - this means
// modal subdialogs will only affect this dialog, not the other windows
setWFlags( getWFlags() | WGroupLeader );
- setupScripts();
initGUI();
initObject();
+
+ setupScripts();
publishObjects();
}
@@ -893,12 +895,9 @@
void MainWindow::setupScripts()
{
// refered to kate/app/katemainwindow.cpp
- kdDebug() << "setupScripts" << endl;
- kdDebug() << "path:" << QString(kapp->name()) +"/scripts/" << endl;
QStringList scripts = KGlobal::dirs()->findAllResources("data", \
QString(kapp->name()) + "/scripts/*.desktop", false, true );
for (QStringList::Iterator it = scripts.begin(); it != scripts.end(); ++it ) {
- kdDebug() << "finding Add-on " << *it << endl;
KPIM::ScriptManager::instance()->addScript( *it );
}
}
@@ -906,17 +905,23 @@
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& )));
QDictIterator<KPIM::ScriptInfo> it ( KPIM::ScriptManager::instance()->scripts());
for(; it.current(); ++it )
{
KPIM::ScriptInfo* si = it.current();
- kdDebug(5600) << "Loading Add-on: " << it.currentKey() << endl;
+ kdDebug() << "Loading Add-on: " << it.currentKey() << endl;
if( si->loadOption == "Autoload" )
KPIM::KJSEngine::instance()->runFile( si->scriptName );
else {
if ( si->loadOption == "LoadOnDemand" ) {
- scriptMenu->popupMenu()->insertItem( it.currentKey());
+ 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;
@@ -924,7 +929,10 @@
}
}
- connect( scriptMenu->popupMenu(), SIGNAL(activated( int )), this, SLOT(runScript( \
int ))); + unplugActionList( "addons_kontact" );
+ plugActionList( "addons_kontact", actions );
+
+ //connect( scriptMenu->popupMenu(), SIGNAL(activated( int )), this, \
SLOT(runScript( int ))); }
void MainWindow::runScript( int idx )
@@ -936,4 +944,12 @@
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 #441774:441775
@@ -133,6 +133,7 @@
void configureShortcuts();
void configureToolbars();
void runScript( int idx );
+ void runScript( const QString& idx );
private:
QFrame *mTopWidget;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic