GpgFrontend Project
A Free, Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP(pgp) Crypto Tool.
TextEdit.h
1 
29 #pragma once
30 
31 #include "ui/dialog/QuitDialog.h"
32 #include "ui/widgets/FilePage.h"
33 #include "ui/widgets/HelpPage.h"
34 #include "ui/widgets/PlainTextEditorPage.h"
35 
36 namespace GpgFrontend::UI {
40 class TextEdit : public QWidget {
41  Q_OBJECT
42  public:
46  TextEdit(QWidget* parent);
47 
54  void LoadFile(const QString& fileName);
55 
63  bool MaybeSaveAnyTab();
64 
70  [[nodiscard]] int TabCount() const;
71 
77  [[nodiscard]] PlainTextEditorPage* CurTextPage() const;
78 
84  [[nodiscard]] FilePage* CurFilePage() const;
85 
90  [[nodiscard]] QHash<int, QString> UnsavedDocuments() const;
91 
92  QTabWidget* tab_widget_;
94  public slots:
95 
101 
107 
111  void SlotQuote() const;
112 
117  void SlotFillTextEditWithText(const QString& text) const;
118 
123  void SlotSave();
124 
131  bool SlotSaveAs();
132 
138  void SlotOpen();
139 
143  void SlotPrint();
144 
150  void SlotNewTab();
151 
156  void SlotNewTabWithContent(QString title, const QString& content);
157 
161  void SlotOpenFile(const QString& path);
162 
169  void slotNewHelpTab(const QString& title, const QString& path) const;
170 
174  void SlotNewFileTab();
175 
180  void SlotShowModified(bool) const;
181 
186  void SlotCloseTab();
187 
192  void SlotSwitchTabUp() const;
193 
198  void SlotSwitchTabDown() const;
199 
200  private:
201  uint text_page_data_modified_count_ = 0;
202 
209  static QString stripped_name(const QString& full_file_name);
210 
216  bool maybe_save_current_tab(bool askToSave);
217 
219 
220  private slots:
221 
222  void slot_file_page_path_changed(const QString& path) const;
223 
229  void slot_remove_tab(int index);
230 
237 
238  public slots:
239 
243  void SlotCut() const;
244 
248  void SlotCopy() const;
249 
253  void SlotPaste() const;
254 
259  void SlotUndo() const;
260 
265  void SlotRedo() const;
266 
271  void SlotZoomIn() const;
272 
277  void SlotZoomOut() const;
278 
283  void SlotSelectAll() const;
284 
290  void SlotAppendText2CurTextPage(const QString& text);
291 
292  protected:
298  bool save_file(const QString& fileName);
299 };
300 
301 } // namespace GpgFrontend::UI
Definition: FilePage.h:43
Class for handling a single tab of the tabwidget.
Definition: PlainTextEditorPage.h:39
TextEdit class.
Definition: TextEdit.h:40
int TabCount() const
Definition: TextEdit.cpp:375
void slot_remove_tab(int index)
Definition: TextEdit.cpp:231
void SlotOpen()
Definition: TextEdit.cpp:150
void SlotNewFileTab()
Definition: TextEdit.cpp:106
void slot_save_status_to_cache_for_revovery()
Definition: TextEdit.cpp:608
bool MaybeSaveAnyTab()
Definition: TextEdit.cpp:306
bool SlotSaveAs()
Definition: TextEdit.cpp:208
void SlotCopy() const
Definition: TextEdit.cpp:531
void slotNewHelpTab(const QString &title, const QString &path) const
Definition: TextEdit.cpp:100
PlainTextEditorPage * SlotCurPageTextEdit() const
Definition: TextEdit.cpp:377
void SlotUndo() const
Definition: TextEdit.cpp:549
void SlotSwitchTabDown() const
Definition: TextEdit.cpp:493
void SlotNewTab()
Definition: TextEdit.cpp:61
void SlotOpenFile(const QString &path)
Definition: TextEdit.cpp:121
bool save_file(const QString &fileName)
Saves the content of currentTab to the file filename.
Definition: TextEdit.cpp:176
void SlotQuote() const
Definition: TextEdit.cpp:388
void SlotSelectAll() const
select all in current text page
Definition: TextEdit.cpp:585
FilePage * SlotCurPageFileTreeView() const
Definition: TextEdit.cpp:383
void LoadFile(const QString &fileName)
Definition: TextEdit.cpp:418
int count_page_
int containing the number of added tabs
Definition: TextEdit.h:218
PlainTextEditorPage * CurTextPage() const
Definition: TextEdit.cpp:358
QHash< int, QString > UnsavedDocuments() const
Definition: TextEdit.cpp:504
bool maybe_save_current_tab(bool askToSave)
Definition: TextEdit.cpp:264
void SlotCloseTab()
Definition: TextEdit.cpp:224
void SlotPaste() const
Definition: TextEdit.cpp:541
FilePage * CurFilePage() const
Definition: TextEdit.cpp:367
void SlotShowModified(bool) const
Definition: TextEdit.cpp:466
void SlotSave()
Definition: TextEdit.cpp:160
void SlotPrint()
Definition: TextEdit.cpp:440
void SlotCut() const
Definition: TextEdit.cpp:523
void SlotRedo() const
redo last change in current text page
Definition: TextEdit.cpp:557
void SlotAppendText2CurTextPage(const QString &text)
Definition: TextEdit.cpp:362
void SlotSwitchTabUp() const
Definition: TextEdit.cpp:486
void SlotFillTextEditWithText(const QString &text) const
Definition: TextEdit.cpp:410
static QString stripped_name(const QString &full_file_name)
Definition: TextEdit.cpp:436
Definition: FileReadTask.cpp:31