forked from KDE/ghostwriter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.h
158 lines (141 loc) · 4.31 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
/*
* SPDX-FileCopyrightText: 2014-2022 Megan Conkle <[email protected]>
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H
#include <QAction>
#include <QLabel>
#include <QMainWindow>
#include <QPushButton>
#include <QSettings>
#include <QSplitter>
#include "../3rdparty/QtAwesome/QtAwesome.h"
#include "appsettings.h"
#include "documentmanager.h"
#include "documentstatistics.h"
#include "documentstatisticswidget.h"
#include "findreplace.h"
#include "htmlpreview.h"
#include "outlinewidget.h"
#include "sessionstatistics.h"
#include "sessionstatisticswidget.h"
#include "sidebar.h"
#include "statisticsindicator.h"
#include "theme.h"
#include "themerepository.h"
#include "timelabel.h"
#include "spelling/spellcheckdecorator.h"
#define MAX_RECENT_FILES 10
namespace ghostwriter
{
/**
* Main window for the application.
*/
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(const QString &filePath = QString(), QWidget *parent = nullptr);
virtual ~MainWindow();
protected:
QSize sizeHint() const override;
void resizeEvent(QResizeEvent *event) override;
void keyPressEvent(QKeyEvent *e) override;
bool eventFilter(QObject *obj, QEvent *event) override;
void closeEvent(QCloseEvent *event) override;
private slots:
void quitApplication();
void changeTheme();
void openPreferencesDialog();
void toggleHtmlPreview(bool checked);
void toggleHemingwayMode(bool checked);
void toggleFocusMode(bool checked);
void toggleFullScreen(bool checked);
void toggleHideMenuBarInFullScreen(bool checked);
void toggleFileHistoryEnabled(bool checked);
void toggleDisplayTimeInFullScreen(bool checked);
void changeEditorWidth(EditorWidth editorWidth);
void changeInterfaceStyle(InterfaceStyle style);
void showQuickReferenceGuide();
void showWikiPage();
void changeFocusMode(FocusMode focusMode);
void applyTheme();
void refreshRecentFiles();
void clearRecentFileHistory();
void changeDocumentDisplayName(const QString &displayName);
void onOperationStarted(const QString &description);
void onOperationFinished();
void changeFont();
void onFontSizeChanged(int size);
void onSetLocale();
void copyHtml();
void showPreviewOptions();
void onAboutToHideMenuBarMenu();
void onAboutToShowMenuBarMenu();
void onSidebarVisibilityChanged(bool visible);
void toggleSidebarVisible(bool visible);
void runSpellCheck();
private:
QtAwesome *awesome;
MarkdownEditor *editor;
SpellCheckDecorator *spelling;
FindReplace* findReplace;
QSplitter *previewSplitter;
QSplitter *splitter;
DocumentManager *documentManager;
ThemeRepository *themeRepo;
Theme theme;
QString language;
Sidebar *sidebar;
QPushButton *sidebarToggleButton;
StatisticsIndicator *statisticsIndicator;
QLabel *statusIndicator;
TimeLabel *timeIndicator;
QPushButton *toggleSidebarButton;
QPushButton *previewOptionsButton;
QPushButton *exportButton;
QPushButton *copyHtmlButton;
QPushButton *hemingwayModeButton;
QPushButton *focusModeButton;
QPushButton *htmlPreviewButton;
HtmlPreview *htmlPreview;
QAction *htmlPreviewMenuAction;
QAction *fullScreenMenuAction;
QPushButton *fullScreenButton;
OutlineWidget *outlineWidget;
DocumentStatistics *documentStats;
DocumentStatisticsWidget *documentStatsWidget;
SessionStatistics *sessionStats;
SessionStatisticsWidget *sessionStatsWidget;
QListWidget *cheatSheetWidget;
QAction *recentFilesActions[MAX_RECENT_FILES];
bool menuBarMenuActivated;
QAction *showSidebarAction;
bool sidebarHiddenForResize;
bool focusModeEnabled;
QList<QWidget *> statusBarButtons;
QList<QWidget *> statusBarWidgets;
AppSettings *appSettings;
QAction* createWindowAction
(
const QString &text,
QObject *receiver,
const char *member,
const QKeySequence &shortcut = QKeySequence()
);
QAction* createWidgetAction
(
const QString &text,
QWidget *receiver,
const char *member,
const QKeySequence &shortcut = QKeySequence()
);
void buildMenuBar();
void buildStatusBar();
void buildSidebar();
void adjustEditor();
};
} // namespace ghostwriter
#endif