~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to plasma/desktop/shell/interactiveconsole.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Copyright 2009 Aaron Seigo <aseigo@kde.org>
 
3
 *
 
4
 *   This program is free software; you can redistribute it and/or modify
 
5
 *   it under the terms of the GNU Library General Public License as
 
6
 *   published by the Free Software Foundation; either version 2, or
 
7
 *   (at your option) any later version.
 
8
 *
 
9
 *   This program is distributed in the hope that it will be useful,
 
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 *   GNU General Public License for more details
 
13
 *
 
14
 *   You should have received a copy of the GNU Library General Public
 
15
 *   License along with this program; if not, write to the
 
16
 *   Free Software Foundation, Inc.,
 
17
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
18
 */
 
19
 
 
20
#ifndef INTERACTIVECONSOLE
 
21
#define INTERACTIVECONSOLE
 
22
 
 
23
#include <QWeakPointer>
 
24
#include <QScriptValue>
 
25
 
 
26
#include <KDialog>
 
27
 
 
28
#include <KIO/Job>
 
29
 
 
30
class QSplitter;
 
31
 
 
32
class KAction;
 
33
class KFileDialog;
 
34
class KMenu;
 
35
class KTextEdit;
 
36
class KTextBrowser;
 
37
 
 
38
namespace KTextEditor
 
39
{
 
40
    class Document;
 
41
} // namespace KParts
 
42
 
 
43
namespace Plasma
 
44
{
 
45
    class Corona;
 
46
} // namespace Plasma
 
47
 
 
48
class ScriptEngine;
 
49
 
 
50
class InteractiveConsole : public KDialog
 
51
{
 
52
    Q_OBJECT
 
53
 
 
54
public:
 
55
    InteractiveConsole(Plasma::Corona *corona, QWidget *parent = 0);
 
56
    ~InteractiveConsole();
 
57
 
 
58
    void loadScript(const QString &path);
 
59
 
 
60
protected:
 
61
    void showEvent(QShowEvent *);
 
62
    void closeEvent(QCloseEvent *event);
 
63
 
 
64
protected Q_SLOTS:
 
65
    void print(const QString &string);
 
66
    void reject();
 
67
 
 
68
private Q_SLOTS:
 
69
    void openScriptFile();
 
70
    void saveScript();
 
71
    void scriptTextChanged();
 
72
    void evaluateScript();
 
73
    void clearEditor();
 
74
    void clearOutput();
 
75
    void scriptFileDataRecvd(KIO::Job *job, const QByteArray &data);
 
76
    void scriptFileDataReq(KIO::Job *job, QByteArray &data);
 
77
    void reenableEditor(KJob *job);
 
78
    void saveScriptUrlSelected();
 
79
    void openScriptUrlSelected();
 
80
    void loadScriptFromUrl(const KUrl &url);
 
81
    void populateTemplatesMenu();
 
82
    void loadTemplate(QAction *);
 
83
    void useTemplate(QAction *);
 
84
 
 
85
private:
 
86
    void onClose();
 
87
    void saveScript(const KUrl &url);
 
88
 
 
89
    Plasma::Corona *m_corona;
 
90
    QSplitter *m_splitter;
 
91
    KTextEditor::Document *m_editorPart;
 
92
    KTextEdit *m_editor;
 
93
    KTextBrowser *m_output;
 
94
    KAction *m_loadAction;
 
95
    KAction *m_saveAction;
 
96
    KAction *m_clearAction;
 
97
    KAction *m_executeAction;
 
98
    KMenu *m_snippetsMenu;
 
99
 
 
100
    KFileDialog *m_fileDialog;
 
101
    QWeakPointer<KIO::Job> m_job;
 
102
    bool m_closeWhenCompleted;
 
103
};
 
104
 
 
105
#endif
 
106