forked from Mudlet/Mudlet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTAction.h
147 lines (128 loc) · 5.77 KB
/
TAction.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#ifndef MUDLET_TACTION_H
#define MUDLET_TACTION_H
/***************************************************************************
* Copyright (C) 2008-2012 by Heiko Koehn - KoehnHeiko@googlemail.com *
* Copyright (C) 2014 by Ahmed Charles - acharles@outlook.com *
* Copyright (C) 2017, 2020-2021 by Stephen Lyons *
* - slysven@virginmedia.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "Tree.h"
#include "pre_guard.h"
#include <QColor>
#include <QIcon>
#include <QPointer>
#include "post_guard.h"
class EAction;
class Host;
class mudlet;
class TEasyButtonBar;
class TFlipButton;
class TLuaInterpreter;
class TToolBar;
class QMenu;
class TAction : public Tree<TAction>, public QObject
{
friend class XMLexport;
friend class XMLimport;
public:
virtual ~TAction();
TAction(TAction* parent, Host* pHost);
TAction(const QString& name, Host* pHost);
void compileAll();
QString getName() { return mName; }
void setName(const QString& name);
void setButtonColor(QColor c) { if(c != mButtonColor) { setDataChanged(); mButtonColor = c; } }
QColor getButtonColor() { return mButtonColor; }
void setButtonRotation(int r) { if(r != mButtonRotation) { setDataChanged(); mButtonRotation = r; } }
int getButtonRotation() { return mButtonRotation; }
void setButtonColumns(int c) { if(c != mButtonColumns) { setDataChanged(); mButtonColumns = c; } }
int getButtonColumns() { return mButtonColumns; }
bool getButtonFlat() { return mButtonFlat; }
void setButtonFlat(bool flat) { if(flat != mButtonFlat) { setDataChanged(); mButtonFlat = flat; } }
void setSizeX(int s) { if(s != mSizeX) { setDataChanged(); mSizeX = s; } }
int getSizeX() { return mSizeX; }
void setSizeY(int s) { if(s != mSizeY) { setDataChanged(); mSizeY = s; } }
int getSizeY() { return mSizeY; }
void fillMenu(TEasyButtonBar* pT, QMenu* menu);
void compile();
bool compileScript();
void execute();
QString getIcon() { return mIcon; }
void setIcon(const QString& icon) { if(icon != mIcon) { mIcon = icon; } }
QString getScript() { return mScript; }
bool setScript(const QString& script);
QString getCommandButtonUp() { return mCommandButtonUp; }
void setCommandButtonUp(const QString& cmd) { if(cmd != mCommandButtonUp) { setDataChanged(); mCommandButtonUp = cmd; } }
void setCommandButtonDown(const QString& cmd) { if(cmd != mCommandButtonDown) { setDataChanged(); mCommandButtonDown = cmd; } }
QString getCommandButtonDown() { return mCommandButtonDown; }
bool isPushDownButton() { return mIsPushDownButton; }
void setIsPushDownButton(bool b) { if(b != mIsPushDownButton) { setDataChanged(); mIsPushDownButton = b; } }
void setIsFolder(bool b) { if(b != isFolder()) { setDataChanged(); this->Tree::setIsFolder(b);} }
bool registerAction();
void insertActions(TToolBar* pT, QMenu* menu);
void expandToolbar(TToolBar* pT);
void insertActions(TEasyButtonBar* pT, QMenu* menu);
void expandToolbar(TEasyButtonBar* pT);
void setDataSaved() { if(mpParent) { mpParent->setDataSaved(); } mDataChanged = false; }
void setDataChanged() { if(mpParent) { mpParent->setDataChanged(); } mDataChanged = true; }
bool isDataChanged() { return mDataChanged; }
QPointer<TToolBar> mpToolBar;
QPointer<TEasyButtonBar> mpEasyButtonBar;
QPointer<EAction> mpEButton;
QPointer<TFlipButton> mpFButton;
// The following was an int but there was confusion over:
// EITHER: "1" = released/unclicked/up & "2" = pressed/clicked/down
// OR: "1" = pressed/clicked/down & "0" = released/unclicked/up
// The Wiki says it should be "1" and "2" but the code sort of did "0"/"1"
// in some places.
// Now uses a boolean:
// "true" = pressed/clicked/down & "false" = released/unclicked/up
bool mButtonState;
int mPosX;
int mPosY;
int mOrientation;
int mLocation;
bool mIsPushDownButton;
bool mNeedsToBeCompiled;
QString mIcon;
QIcon mIconPix;
int mButtonRotation;
int mButtonColumns;
bool mButtonFlat;
int mSizeX;
int mSizeY;
bool mIsLabel;
bool mUseCustomLayout;
QString css;
QColor mButtonColor;
QPointer<Host> mpHost;
bool exportItem;
bool mModuleMasterFolder;
Qt::DockWidgetArea mToolbarLastDockArea;
bool mToolbarLastFloatingState;
private:
TAction() = default;
QString mName;
QString mCommandButtonUp;
QString mCommandButtonDown;
QString mScript;
QString mFuncName;
bool mModuleMember;
bool mDataChanged;
};
#endif // MUDLET_TACTION_H