-
Notifications
You must be signed in to change notification settings - Fork 27
/
MenuEditControl.hpp
71 lines (60 loc) · 1.68 KB
/
MenuEditControl.hpp
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
#ifndef MENUEDITCONTROL_HPP
#define MENUEDITCONTROL_HPP
#include <QObject>
#include <vector>
class QAction;
class QWidget;
class MenuEditControl : public QObject
{
Q_OBJECT
private:
class ITextDoc
{
public: //delete from MenuEditControl
ITextDoc(MenuEditControl* parent);
virtual ~ITextDoc(){};
public:
virtual bool initWidget(QWidget* focused) = 0;
virtual void copy() = 0;
virtual void cut() = 0;
virtual void paste() = 0;
virtual void selectAll() = 0;
virtual bool isSelected() = 0;
virtual bool canPaste() = 0;
virtual bool canCut() = 0;
virtual void connectSelectionChanged(bool fConnect, QWidget* widget) = 0;
protected:
QWidget* _focused;
MenuEditControl* _parent;
};
template<class TWidgetClass> class ATextDoc;
class TextEdit;
class LineEdit;
class PlainTextEdit;
public:
explicit MenuEditControl(QObject *parent, QAction *actionCopy, QAction *actionCut, QAction *actionPaste);
virtual ~MenuEditControl();
void copy() const;
void cut();
void paste();
void selectAll();
///Notify when focus changed in the KeyhoteeMainWindow
void onFocusChanged(QWidget *old, QWidget *now);
///Notify when Keyhotee application is closing
void onClosingApp();
private:
bool isSelected(QWidget* focused, bool& canCut) const;
bool connectSelectionChangedSignal(bool fConnect, QWidget* widget);
signals:
private slots:
void onSelectionChanged();
void onDestroyed ( QObject * obj = 0 );
private:
QAction* _actionCopy;
QAction* _actionCut;
QAction* _actionPaste;
QWidget * _currentWidget;
std::vector<ITextDoc*> _textDocs;
bool _isClosingApp;
};
#endif // MENUEDITCONTROL_HPP