~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to parts/scripting/scriptingpart.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2006-05-23 18:39:42 UTC
  • Revision ID: james.westby@ubuntu.com-20060523183942-hucifbvh68k2bwz7
Tags: upstream-3.3.2
Import upstream version 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2005 by ian reinhart geiser                             *
 
3
 *   ian@geiseri.com                                                       *
 
4
 *                                                                         *
 
5
 *   This program is free software; you can redistribute it and/or modify  *
 
6
 *   it under the terms of the GNU General Public License as published by  *
 
7
 *   the Free Software Foundation; either version 2 of the License, or     *
 
8
 *   (at your option) any later version.                                   *
 
9
 *                                                                         *
 
10
 *   This program is distributed in the hope that it will be useful,       *
 
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
13
 *   GNU General Public License for more details.                          *
 
14
 *                                                                         *
 
15
 *   You should have received a copy of the GNU General Public License     *
 
16
 *   along with this program; if not, write to the                         *
 
17
 *   Free Software Foundation, Inc.,                                       *
 
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 
19
 ***************************************************************************/
 
20
 
 
21
#include "scriptingpart.h"
 
22
 
 
23
#include <qtimer.h>
 
24
#include <qpopupmenu.h>
 
25
#include <qwhatsthis.h>
 
26
 
 
27
#include <klocale.h>
 
28
#include <kaction.h>
 
29
#include <kdialogbase.h>
 
30
#include <kiconloader.h>
 
31
#include <kmessagebox.h>
 
32
#include <kdevplugininfo.h>
 
33
#include <kdevgenericfactory.h>
 
34
 
 
35
#include <kdevcore.h>
 
36
#include <kdevmainwindow.h>
 
37
#include <configwidgetproxy.h>
 
38
#include <kapplication.h>
 
39
#include <kconfig.h>
 
40
#include "scriptingglobalconfig.h"
 
41
#include "kscriptactionmanager.h"
 
42
 
 
43
typedef KDevGenericFactory<scriptingPart> scriptingFactory;
 
44
KDevPluginInfo data("kdevscripting");
 
45
K_EXPORT_COMPONENT_FACTORY( libkdevscripting, scriptingFactory( data ) )
 
46
 
 
47
#define GLOBALDOC_OPTIONS 1
 
48
#define PROJECTDOC_OPTIONS 2
 
49
 
 
50
scriptingPart::scriptingPart(QObject *parent, const char *name, const QStringList &/*args*/)
 
51
    : KDevPlugin(&data, parent, name ? name : "scriptingPart"), m_scripts(0L)
 
52
{
 
53
    setInstance(scriptingFactory::instance());
 
54
    setXMLFile("kdevscripting.rc");
 
55
 
 
56
    m_configProxy = new ConfigWidgetProxy(core());
 
57
    m_configProxy->createGlobalConfigPage(i18n("Scripting"), GLOBALDOC_OPTIONS, info()->icon());
 
58
    connect(m_configProxy, SIGNAL(insertConfigWidget(const KDialogBase*, QWidget*, unsigned int )),
 
59
        this, SLOT(insertConfigWidget(const KDialogBase*, QWidget*, unsigned int)));
 
60
 
 
61
  
 
62
        
 
63
    QTimer::singleShot(0, this, SLOT(init()));
 
64
}
 
65
 
 
66
scriptingPart::~scriptingPart()
 
67
{
 
68
    delete m_configProxy;
 
69
    delete m_scripts;
 
70
}
 
71
 
 
72
void scriptingPart::init()
 
73
{
 
74
// delayed initialization stuff goes here
 
75
    m_scripts = new KScriptActionManager(this,actionCollection());
 
76
    setupActions();
 
77
}
 
78
 
 
79
void scriptingPart::setupActions()
 
80
{
 
81
    kdDebug() << "Load plugins" << endl;
 
82
    // Read KConfig and get the list of custom directories.
 
83
    QStringList searchDirs;
 
84
    searchDirs += "kate/scripts";
 
85
    
 
86
    KConfig *cfg = kapp->config();
 
87
    searchDirs += cfg->readListEntry("SearchDirs");
 
88
    
 
89
    unplugActionList(QString::fromLatin1( "script_actions" ));
 
90
    plugActionList( QString::fromLatin1( "script_actions" ), m_scripts->scripts(core(),searchDirs));
 
91
}
 
92
 
 
93
void scriptingPart::insertConfigWidget(const KDialogBase *dlg, QWidget *page, unsigned int pageNo)
 
94
{
 
95
// create configuraton dialogs here
 
96
    switch (pageNo)
 
97
    {
 
98
        case GLOBALDOC_OPTIONS:
 
99
        {
 
100
            scriptingGlobalConfig *w = new scriptingGlobalConfig(this, page, "global config");
 
101
            connect(dlg, SIGNAL(okClicked()), w, SLOT(accept()));
 
102
            break;
 
103
        }
 
104
    }
 
105
}
 
106
 
 
107
 
 
108
#include "scriptingpart.moc"