-
Notifications
You must be signed in to change notification settings - Fork 28
/
MainWindow.h
260 lines (226 loc) · 7.15 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
/************************************************************************
**
** Copyright (C) 2019-2023 Kevin B. Hendricks, Stratford Ontario Canada
**
** This file is part of PageEdit.
**
** PageEdit 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 3 of the License, or
** (at your option) any later version.
**
** PageEdit 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 PageEdit. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#pragma once
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "ui_main.h"
#include <QSignalMapper>
#include <QMap>
#include <QtWebEngineWidgets>
#include <QWebEngineView>
#include <QMainWindow>
#include <QMoveEvent>
#include <QCloseEvent>
#include <QResizeEvent>
#include "Viewer.h"
#include "Inspector.h"
#include "ElementIndex.h"
#include "ClipEditorModel.h"
#include "webviewprinter.h"
class ClipsWindow;
class ClipEditor;
class WebViewEdit;
class Inspector;
class QWebEngineView;
class QVBoxLayout;
class QHBoxLayout;
class QSlider;
class QLabel;
class SelectCharacter;
class SearchToolbar;
const int STATUSBAR_MSG_DISPLAY_TIME = 7000;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QString filepath, QString spineno = "", QWidget *parent = 0);
~MainWindow();
QList<ElementIndex> GetCaretLocation();
bool IsVisible();
bool HasFocus();
bool eventFilter(QObject *object, QEvent *event);
// void setMathJaxURL(QString mathjaxurl) { m_mathjaxurl = mathjaxurl; };
void setUserCSSURL(QString usercssurl) { m_usercssurl = usercssurl; }
void ExtendIconSizes();
// Zoom Related
float GetZoomFactor();
int ZoomFactorToSliderRange(float zoom_factor);
float SliderRangeToZoomFactor(int slider_range_value);
void ZoomByStep(bool zoom_in);
void ZoomByFactor(float new_zoom_factor);
QString GetSandBoxPath() { return m_SandBoxPath; };
public slots:
// Zoom Related
void ZoomIn();
void ZoomOut();
void ZoomReset();
void SliderZoom(int slider_value);
void UpdateZoomSlider(float new_zoom_factor);
void UpdateZoomLabel(int slider_value);
void UpdateZoomLabel(float new_zoom_factor);
// General Slots
void DoUpdatePage();
void SetInitialSource();
void UpdatePage(const QString &filename, const QString &source="");
void RefreshPage();
void UpdateWindowTitle();
void ScrollTo(QList<ElementIndex> location);
void SetZoomFactor(float factor);
void EmitGoToPreviewLocationRequest();
void InspectPreviewPage();
void EditClips();
void OpenClipsWindow();
void ToggleClipToolbar();
void SelectAllPreview();
void CopyPreview();
void ReloadPreview();
void ShowMessageOnStatusBar(const QString &message = "", int millisecond_duration = STATUSBAR_MSG_DISPLAY_TIME);
void AboutPageEdit();
void PasteClipEntriesIntoTarget(QList<ClipEditorModel::clipEntry *>clips);
void PasteClipNumberIntoTarget(int clip_number);
void UpdateClipsUI();
// Navigation Slots
void EditNext();
void EditPrev();
void CBNavigateActivated(int index);
void LinkClicked(const QUrl &url);
void LinkReturn();
// Utility routines
QString GetCurrentFilePath();
QStringList GetAllFilePaths(int skip = -1);
// Mode slots
void ToggleMode(bool on);
static const QMap<QString, QString> GetLoadFiltersMap();
static const QMap<QString, QString> GetSaveFiltersMap();
// GUI slots
void sizeMenuIcons();
void SelectionChanged();
void CheckHeadingLevel(const QString &element_name);
void ApplyHeadingToSelection(const QString &heading_type);
void SetPreserveHeadingAttributes(bool new_state);
bool Save();
bool SaveAs();
void Open();
void Exit();
void Undo();
void Redo();
void Cut();
void Copy();
void SelectAll();
void Paste();
void PasteText(const QString& text);
void PreferencesDialog();
void SearchOnPage();
void InsertSpecialCharacter();
void InsertSGFSectionMarker();
void InsertBulletedList();
void InsertNumberedList();
void InsertId();
void InsertHyperlink();
void InsertFileDialog();
void InsertFiles(const QStringList &selected_files);
void Bold();
void Italic();
void Underline();
void Strikethrough();
void Subscript();
void Superscript();
void AlignLeft();
void AlignCenter();
void AlignRight();
void AlignJustify();
void DecreaseIndent();
void IncreaseIndent();
void UpdateActionState();
void ChangeCasing(int casing_mode);
void printRendered();
// void ToggleSpellCheck();
void ApplicationPaletteChanged();
signals:
void Shown();
void ZoomFactorChanged(float factor);
void GoToPreviewLocationRequest();
void RequestPreviewReload();
/**
* Emitted whenever m_WebView wants to open an URL.
* @param url The URL to open.
*/
void OpenUrlRequest(const QUrl &url);
protected:
virtual void hideEvent(QHideEvent* event);
virtual void showEvent(QShowEvent* event);
void resizeEvent(QResizeEvent * event);
void moveEvent(QMoveEvent *event);
void closeEvent(QCloseEvent * event);
bool MaybeSaveDialogSaysProceed(bool modified);
QString GetCleanHtml();
QString GetSource();
QString GetHTMLToPaste(const QString & hmtl_snippet);
private:
void SetupView();
void SetupFileList(const QString& filepath, const QString& spineno = "");
void SetupNavigationComboBox();
void LoadSettings();
void SaveSettings();
bool AllowSaveIfModified();
void UpdateClipButton(QAction *ui_action);
void ConnectSignalsToSlots();
WebViewEdit *m_WebView;
Inspector *m_Inspector;
QString m_Filepath;
bool m_GoToRequestPending;
bool m_MouseReleaseEventHappened;
// QString m_mathjaxurl;
QString m_usercssurl;
QSignalMapper *m_headingMapper;
QSignalMapper *m_casingChangeMapper;
bool m_preserveHeadingAttributes;
QString m_CurrentFilePath;
SelectCharacter* m_SelectCharacter;
QSlider *m_slZoomSlider;
QLabel *m_lbZoomLabel;
bool m_updateActionStatePending;
QByteArray m_LastWindowSize;
QString m_LastFolderOpen;
bool m_using_wsprewrap;
SearchToolbar * m_search;
QVBoxLayout * m_layout;
QString m_source;
QStringList m_SpineList;
QString m_Base;
int m_ListPtr;
bool m_UpdatePageInProgress;
QStringList m_CSSList;
QStringList m_MediaList;
QStringList m_MediaKind;
QString m_MediaBase;
QString m_SandBoxPath;
bool m_skipPrintWarnings;
bool m_skipPrintPreview;
WebViewPrinter *m_WebViewPrinter;
QList<ElementIndex> m_LastLocation;
ClipsWindow* m_Clips;
ClipEditor* m_ClipEditor;
QList<QAction*> m_clactions;
int m_LastPtr;
Ui::MainWindow ui;
};
#endif // MAINWINDOW_H