-
Notifications
You must be signed in to change notification settings - Fork 103
/
stack.h
190 lines (162 loc) · 3.97 KB
/
stack.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/*
SPDX-FileCopyrightText: 2009-2019 Graeme Gott <graeme@gottcode.org>
SPDX-License-Identifier: GPL-3.0-or-later
*/
#ifndef FOCUSWRITER_STACK_H
#define FOCUSWRITER_STACK_H
#include "theme.h"
class AlertLayer;
class Document;
class FindDialog;
class SceneList;
class SymbolsDialog;
class ThemeRenderer;
#include <QWidget>
class QActionGroup;
class QGridLayout;
class QMenu;
class QPrinter;
class QStackedWidget;
class Stack : public QWidget
{
Q_OBJECT
public:
explicit Stack(QWidget* parent = nullptr);
~Stack();
void addDocument(Document* document);
AlertLayer* alerts() const;
QMenu* menu() const;
SymbolsDialog* symbols() const;
int count() const;
Document* currentDocument() const;
int currentIndex() const;
Document* document(int index) const;
void moveDocument(int from, int to);
void removeDocument(int index);
void updateDocument(int index);
void setCurrentDocument(int index);
void setMargins(int footer, int header);
void waitForThemeBackground();
bool eventFilter(QObject* watched, QEvent* event) override;
Q_SIGNALS:
void copyAvailable(bool);
void redoAvailable(bool);
void undoAvailable(bool);
void footerVisible(bool);
void headerVisible(bool);
void documentAdded(Document* document);
void documentRemoved(Document* document);
void documentSelected(int index);
void findNextAvailable(bool available);
void updateFormatActions();
void updateFormatAlignmentActions();
public Q_SLOTS:
void alignCenter();
void alignJustify();
void alignLeft();
void alignRight();
void autoCache();
void checkSpelling();
void cut();
void copy();
void decreaseIndent();
void find();
void findNext();
void findPrevious();
void increaseIndent();
void paste();
void pasteUnformatted();
void pageSetup();
void print();
void redo();
void reload();
void replace();
void save();
void saveAs();
void selectAll();
void selectScene();
void setFocusMode(QAction* action);
void setBlockHeading(int heading);
void setFontBold(bool bold);
void setFontItalic(bool italic);
void setFontStrikeOut(bool strikeout);
void setFontUnderline(bool underline);
void setFontSuperScript(bool super);
void setFontSubScript(bool sub);
void setTextDirectionLTR();
void setTextDirectionRTL();
void showSymbols();
void themeSelected(const Theme& theme);
void undo();
void updateSmartQuotes();
void updateSmartQuotesSelection();
void setFooterVisible(bool visible);
void setHeaderVisible(bool visible);
void setScenesVisible(bool visible);
void showHeader();
protected:
void mouseMoveEvent(QMouseEvent* event) override;
void paintEvent(QPaintEvent* event) override;
void resizeEvent(QResizeEvent* event) override;
private Q_SLOTS:
void actionTriggered(const QAction* action);
void insertSymbol(const QString& text);
void updateBackground();
void updateBackground(const QImage& image, const QRect& foreground);
void updateMargin();
void updateMask();
void updateMenuIndexes();
private:
void initPrinter();
private:
AlertLayer* m_alerts;
SceneList* m_scenes;
QMenu* m_menu;
QActionGroup* m_menu_group;
QGridLayout* m_layout;
FindDialog* m_find_dialog;
SymbolsDialog* m_symbols_dialog;
QPrinter* m_printer;
QStackedWidget* m_contents;
QList<Document*> m_documents;
QList<QAction*> m_document_actions;
Document* m_current_document;
ThemeRenderer* m_theme_renderer;
QPixmap m_background;
QSize m_foreground_size;
Theme m_theme;
QTimer* m_resize_timer;
int m_footer_margin;
int m_header_margin;
int m_footer_visible;
int m_header_visible;
};
inline AlertLayer* Stack::alerts() const
{
return m_alerts;
}
inline QMenu* Stack::menu() const
{
return m_menu;
}
inline SymbolsDialog* Stack::symbols() const
{
return m_symbols_dialog;
}
inline int Stack::count() const
{
return m_documents.count();
}
inline Document* Stack::currentDocument() const
{
return m_current_document;
}
inline int Stack::currentIndex() const
{
return m_documents.indexOf(m_current_document);
}
inline Document* Stack::document(int index) const
{
return m_documents[index];
}
#endif // FOCUSWRITER_STACK_H