2
// C++ Interface: kraction
7
// Author: Krusader Krew <http://www.krusader.org>, (C) 2004, 2006
9
// Copyright: See COPYING file that comes with this distribution
1
/*****************************************************************************
2
* Copyright (C) 2004 Shie Erlich <erlich@users.sourceforge.net> *
3
* Copyright (C) 2004 Rafi Yanai <yanai@users.sourceforge.net> *
4
* Copyright (C) 2006 Jonas Bähr <jonas.baehr@web.de> *
6
* This program is free software; you can redistribute it and/or modify *
7
* it under the terms of the GNU General Public License as published by *
8
* the Free Software Foundation; either version 2 of the License, or *
9
* (at your option) any later version. *
11
* This package is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU General Public License for more details. *
16
* You should have received a copy of the GNU General Public License *
17
* along with this package; if not, write to the Free Software *
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
19
*****************************************************************************/
19
#include <qbytearray.h>
24
#include <QtCore/QByteArray>
20
31
#include "kractionbase.h"
22
33
class UserActionProperties;
24
36
class KActionCollection;
29
* This subclass of KAction extends it with an individual executor and a struct UserActionProperties. It is used to integrate useractions into KDE's KAction-System
30
* @author Jonas Bähr (http://www.jonas-baehr.de)
39
* This subclass of KAction extends it with an individual executor and
40
* a struct UserActionProperties.
41
* It is used to integrate useractions into KDE's KAction-System
32
class KrAction: public KAction, public KrActionBase {
35
KrAction( KActionCollection *parent, QString name = QString::null );
39
* This chekcs if the KrAction is for a specific file / location available
40
* @param currentURL Check for this file
41
* @return true if the KrAction if available
43
bool isAvailable( const KUrl& currentURL );
45
const QString& iconName() const { return _iconName; } // TODO: added for kde4 porting (functionality is missing)
46
void setIconName( const QString& name ) { _iconName = name; }
48
bool xmlRead( const QDomElement& element );
49
QDomElement xmlDump( QDomDocument& doc ) const;
51
void setName( const char* ) { /* empty reimplementation to prevent a name-change */ };
52
const QString & getName() { return _name; }
54
QString category() const { return _category; };
55
void setCategory( const QString& category ) { _category = category; };
57
QString command() const { return _command; };
58
void setCommand( const QString& command ) { _command = command; };
60
QString user() const { return _user; };
61
void setUser( const QString& user ) { _user = user; };
63
QString startpath() const { return _startpath; };
64
void setStartpath( const QString& startpath ) { _startpath = startpath; };
66
ExecType execType() const { return _execType; };
67
void setExecType( ExecType execType ) { _execType = execType; };
69
bool acceptURLs() const { return _acceptURLs; };
70
void setAcceptURLs(const bool& acceptURLs) { _acceptURLs = acceptURLs; };
72
bool confirmExecution() const { return _confirmExecution; };
73
void setConfirmExecution(const bool& confirmExecution) { _confirmExecution = confirmExecution; };
75
QStringList showonlyProtocol() const { return _showonlyProtocol; };
76
void setShowonlyProtocol( const QStringList& showonlyProtocol ) { _showonlyProtocol = showonlyProtocol; };
78
QStringList showonlyPath() const { return _showonlyPath; };
79
void setShowonlyPath( const QStringList& showonlyPath ) { _showonlyPath = showonlyPath; };
81
QStringList showonlyMime() const { return _showonlyMime; };
82
void setShowonlyMime( const QStringList& showonlyMime ) { _showonlyMime = showonlyMime; };
84
QStringList showonlyFile() const { return _showonlyFile; };
85
void setShowonlyFile( const QStringList& showonlyFile ) { _showonlyFile = showonlyFile; };
87
bool doSubstitution() const {
43
class KrAction: public KAction, public KrActionBase
47
KrAction(KActionCollection *parent, QString name = QString());
51
* This chekcs if the KrAction is for a specific file / location available
52
* @param currentURL Check for this file
53
* @return true if the KrAction if available
55
bool isAvailable(const KUrl& currentURL);
57
const QString& iconName() const {
59
} // TODO: added for kde4 porting (functionality is missing)
60
void setIconName(const QString& name) {
64
bool xmlRead(const QDomElement& element);
65
QDomElement xmlDump(QDomDocument& doc) const;
67
void setName(const char*) { /* empty reimplementation to prevent a name-change */ };
68
const QString & getName() {
72
QString category() const {
75
void setCategory(const QString& category) {
79
QString command() const {
82
void setCommand(const QString& command) {
86
QString user() const {
89
void setUser(const QString& user) {
93
QString startpath() const {
96
void setStartpath(const QString& startpath) {
97
_startpath = startpath;
100
ExecType execType() const {
103
void setExecType(ExecType execType) {
104
_execType = execType;
107
bool acceptURLs() const {
110
void setAcceptURLs(const bool& acceptURLs) {
111
_acceptURLs = acceptURLs;
114
bool confirmExecution() const {
115
return _confirmExecution;
117
void setConfirmExecution(const bool& confirmExecution) {
118
_confirmExecution = confirmExecution;
121
QStringList showonlyProtocol() const {
122
return _showonlyProtocol;
124
void setShowonlyProtocol(const QStringList& showonlyProtocol) {
125
_showonlyProtocol = showonlyProtocol;
128
QStringList showonlyPath() const {
129
return _showonlyPath;
131
void setShowonlyPath(const QStringList& showonlyPath) {
132
_showonlyPath = showonlyPath;
135
QStringList showonlyMime() const {
136
return _showonlyMime;
138
void setShowonlyMime(const QStringList& showonlyMime) {
139
_showonlyMime = showonlyMime;
142
QStringList showonlyFile() const {
143
return _showonlyFile;
145
void setShowonlyFile(const QStringList& showonlyFile) {
146
_showonlyFile = showonlyFile;
149
bool doSubstitution() const {
91
QString text() const {
153
QString text() const {
92
154
return KAction::text();
159
KrActionBase::exec();
102
void readCommand( const QDomElement& element );
103
QDomElement dumpCommand( QDomDocument& doc ) const;
105
void readAvailability( const QDomElement& element );
106
QDomElement dumpAvailability( QDomDocument& doc ) const;
115
bool _confirmExecution;
116
QStringList _showonlyProtocol;
117
QStringList _showonlyPath;
118
QStringList _showonlyMime;
119
QStringList _showonlyFile;
164
void readCommand(const QDomElement& element);
165
QDomElement dumpCommand(QDomDocument& doc) const;
167
void readAvailability(const QDomElement& element);
168
QDomElement dumpAvailability(QDomDocument& doc) const;
177
bool _confirmExecution;
178
QStringList _showonlyProtocol;
179
QStringList _showonlyPath;
180
QStringList _showonlyMime;
181
QStringList _showonlyFile;
126
188
* This displays the output of a process
127
* @author Shie Erlich, Jonas Bähr
129
class KrActionProcDlg: public KDialog {
132
KrActionProcDlg( QString caption, bool enableStderr = false, QWidget *parent = 0 );
135
void addStderr(const QString& str);
136
void addStdout(const QString& str);
139
void toggleFixedFont( bool state );
140
void slotUser1(); ///< This is used to save the buffer to disc
143
QTextEdit *_stdout, *_stderr, *_currentTextEdit;
144
QFont normalFont, fixedFont;
146
void currentTextEditChanged();
190
class KrActionProcDlg: public KDialog
194
KrActionProcDlg(QString caption, bool enableStderr = false, QWidget *parent = 0);
197
void addStderr(const QString& str);
198
void addStdout(const QString& str);
201
void toggleFixedFont(bool state);
202
void slotUser1(); ///< This is used to save the buffer to disc
207
KTextEdit *_currentTextEdit;
211
void currentTextEditChanged();
150
215
* This executes a command of a UserAction
151
* @author Shie Erlich, Jonas Bähr
152
* @todo jonas: call a list of commands separately (I began it but it doesn't work)
154
class KrActionProc: public QObject {
158
KrActionProc( KrActionBase* action );
159
virtual ~KrActionProc();
160
void start( QString cmdLine );
161
void start( QStringList cmdLineList );
164
void kill() { _proc->kill(); }
165
void processExited( int exitCode, QProcess::ExitStatus exitStatus );
170
KrActionBase* _action;
174
KrActionProcDlg *_output;
217
// TODO jonas: call a list of commands separately (I began it but it doesn't work)
218
class KrActionProc: public QObject
223
KrActionProc(KrActionBase* action);
224
virtual ~KrActionProc();
225
void start(QString cmdLine);
226
void start(QStringList cmdLineList);
232
void processExited(int exitCode, QProcess::ExitStatus exitStatus);
237
KrActionBase* _action;
241
KrActionProcDlg *_output;
178
244
#endif //KRACTION_H