-
Notifications
You must be signed in to change notification settings - Fork 24
/
mainwindow.h
188 lines (155 loc) · 4.68 KB
/
mainwindow.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
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QMap>
class QAction;
class QMenu;
class QTextEdit;
class QProcess;
class PreviewWidget;
class QTimer;
class QLabel;
class QSignalMapper;
class QToolBox;
class QListWidget;
class QListWidgetItem;
class FileCache;
class RecentDocuments;
class QSignalMapper;
class QScrollArea;
class TextEdit;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
void openDocument(const QString& path);
public slots:
void newDocument();
private slots:
void about();
void refresh(bool forced = false);
void refreshFinished();
void changeImageFormat();
void undo();
void redo();
void copyImage();
void onAutoRefreshActionToggled(bool state);
void onEditorChanged();
void onRefreshActionTriggered();
void onPreferencesActionTriggered();
void onOpenDocumentActionTriggered();
void onSaveActionTriggered();
void onSaveAsActionTriggered();
void onExportImageActionTriggered();
void onExportAsImageActionTriggered();
void onRecentDocumentsActionTriggered(const QString& path);
void onAssistanItemDoubleClicked(QListWidgetItem* item);
void onSingleApplicationReceivedMessage(const QString& message);
void onAssistantFocus();
void onAssistantItemInsert(QWidget* widget);
void onNextAssistant();
void onPrevAssistant();
void onAssistantItemSelectionChanged();
void onCurrentAssistantChanged(int index);
private:
enum ImageFormat { SvgFormat, PngFormat };
void closeEvent(QCloseEvent *event);
bool maybeSave();
void readSettings(bool reload = false);
void writeSettings();
bool saveDocument(const QString& name);
void exportImage(const QString& name);
QString makeKeyForDocument(QByteArray current_document);
void createActions();
void createMenus();
void createToolBars();
void createStatusBar();
void createDockWindows();
void enableUndoRedoActions();
void addZoomActions(QWidget* widget);
void checkPaths();
void reloadAssistantXml(const QString& path);
void insertAssistantCode(const QString& code);
bool refreshFromCache();
void updateCacheSizeInfo();
void focusAssistant();
QLabel *m_currentImageFormatLabel;
QLabel *m_autoRefreshLabel;
QLabel *m_exportPathLabel;
QLabel *m_cacheSizeLabel;
QString m_documentPath;
QString m_exportPath;
QString m_lastKey;
QByteArray m_cachedImage;
QString m_assistantXmlPath;
QList<QListWidget*> m_assistantWidgets;
bool m_useCustomJava;
bool m_useCustomPlantUml;
bool m_useCustomGraphiz;
bool m_useCache;
bool m_useCustomCache;
bool m_refreshOnSave;
int m_cacheMaxSize;
QString m_javaPath;
QString m_plantUmlPath;
QString m_graphizPath;
QString m_cachePath;
QString m_customJavaPath;
QString m_customPlantUmlPath;
QString m_customGraphizPath;
QString m_customCachePath;
bool m_hasValidPaths;
QProcess *m_process;
QMap<ImageFormat, QString> m_imageFormatNames;
ImageFormat m_currentImageFormat;
QTimer *m_autoRefreshTimer;
bool m_needsRefresh;
TextEdit *m_editor;
// the main image widget, which renders to svg or png
// and the scroll area container used to add scroll bars
PreviewWidget *m_imageWidget;
QScrollArea* m_imageWidgetScrollArea;
QToolBox *m_assistantToolBox;
QLabel *m_assistantPreviewNotes;
QTextEdit *m_assistantCodePreview;
QToolBar *m_mainToolBar;
QToolBar *m_zoomToolBar;
QMenu *m_fileMenu;
QAction *m_newDocumentAction;
QAction *m_openDocumentAction;
QAction *m_saveDocumentAction;
QAction *m_saveAsDocumentAction;
QAction *m_exportImageAction;
QAction *m_exportAsImageAction;
QAction *m_quitAction;
QMenu *m_editMenu;
QAction *m_undoAction;
QAction *m_copyImageAction;
QAction *m_redoAction;
QAction *m_refreshAction;
QMenu *m_settingsMenu;
QAction *m_showAssistantDockAction;
QAction *m_showAssistantInfoDockAction;
QAction *m_showEditorDockAction;
QAction *m_showMainToolbarAction;
QAction *m_showStatusBarAction;
QAction *m_pngPreviewAction;
QAction *m_svgPreviewAction;
QAction *m_autoRefreshAction;
QAction *m_autoSaveImageAction;
QAction *m_preferencesAction;
QMenu *m_zoomMenu;
QAction *m_zoomInAction;
QAction *m_zoomOutAction;
QAction *m_zoomOriginalAction;
QMenu *m_helpMenu;
QAction *m_aboutAction;
QAction *m_aboutQtAction;
QSignalMapper* m_assistantInsertSignalMapper;
FileCache* m_cache;
RecentDocuments* m_recentDocuments;
QString m_lastDir;
};
#endif // MAINWINDOW_H