GpgFrontend Project A Free, Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP(pgp) Crypto Tool.

PlainTextEditorPage.h
1
29 #ifndef __EDITORPAGE_H__
30 #define __EDITORPAGE_H__
31
32 #include <string>
33
34 #include "core/GpgConstants.h"
35 #include "ui/GpgFrontendUI.h"
36
37 class Ui_PlainTextEditor;
38
39 namespace GpgFrontend::UI {
40
45 class PlainTextEditorPage : public QWidget {
46 Q_OBJECT
47 public:
54 explicit PlainTextEditorPage(QString file_path = {},
55 QWidget* parent = nullptr);
56
60 [[nodiscard]] const QString& GetFilePath() const;
61
67 void SetFilePath(const QString& filePath);
68
72 QPlainTextEdit* GetTextPage();
73
80 void ShowNotificationWidget(QWidget* widget, const char* className);
81
87 void CloseNoteByClass(const char* className);
88
93 void ReadFile();
94
101 [[nodiscard]] bool ReadDone() const { return this->read_done_; }
102
107 bool WillCharsetChange() const;
108
113 void NotifyFileSaved();
114
115 signals:
116
121 void SignalUIBytesDisplayed();
122
123 private:
124 std::shared_ptr<Ui_PlainTextEditor> ui_;
125 QString full_file_path_;
126 bool sign_marked_{};
127 bool read_done_ = false;
128 bool binary_mode_ = false;
129 size_t read_bytes_ = 0;
130 std::string charset_name_;
131 std::string language_name_;
132 int32_t charset_confidence_{};
133 bool is_crlf_ = false;
134
140 void detect_encoding(const std::string& data);
141
147 void detect_cr_lf(const std::string& data);
148
149 private slots:
150
154 void slot_format_gpg_header();
155
161 void slot_insert_text(QByteArray bytes_data);
162 };
163
164 } // namespace GpgFrontend::UI
165
166 #endif // __EDITORPAGE_H__
GpgFrontend::UI::PlainTextEditorPage
Class for handling a single tab of the tabwidget.
Definition: PlainTextEditorPage.h:45
GpgFrontend::UI::PlainTextEditorPage::detect_encoding
void detect_encoding(const std::string &data)
Definition: PlainTextEditorPage.cpp:263
GpgFrontend::UI::PlainTextEditorPage::slot_insert_text
void slot_insert_text(QByteArray bytes_data)
Definition: PlainTextEditorPage.cpp:211
GpgFrontend::UI::PlainTextEditorPage::WillCharsetChange
bool WillCharsetChange() const
detect if the charset of the file will change
Definition: PlainTextEditorPage.cpp:90
GpgFrontend::UI::PlainTextEditorPage::NotifyFileSaved
void NotifyFileSaved()
notify the user that the file has been saved.
Definition: PlainTextEditorPage.cpp:101
GpgFrontend::UI::PlainTextEditorPage::slot_format_gpg_header
void slot_format_gpg_header()
Definition: PlainTextEditorPage.cpp:129
GpgFrontend::UI::PlainTextEditorPage::sign_marked_
bool sign_marked_
true, if the signed header is marked, false if not
Definition: PlainTextEditorPage.h:126
GpgFrontend::UI::PlainTextEditorPage::GetTextPage
QPlainTextEdit * GetTextPage()
Definition: PlainTextEditorPage.cpp:88
GpgFrontend::UI::PlainTextEditorPage::PlainTextEditorPage
PlainTextEditorPage(QString file_path={}, QWidget *parent=nullptr)
Definition: PlainTextEditorPage.cpp:42
GpgFrontend::UI::PlainTextEditorPage::SetFilePath
void SetFilePath(const QString &filePath)
Definition: PlainTextEditorPage.cpp:110
GpgFrontend::UI::PlainTextEditorPage::ReadDone
bool ReadDone() const
Definition: PlainTextEditorPage.h:101
GpgFrontend::UI::PlainTextEditorPage::full_file_path_
QString full_file_path_
The path to the file handled in the tab.
Definition: PlainTextEditorPage.h:125
GpgFrontend::UI::PlainTextEditorPage::CloseNoteByClass
void CloseNoteByClass(const char *className)
Definition: PlainTextEditorPage.cpp:120
GpgFrontend::UI::PlainTextEditorPage::detect_cr_lf
void detect_cr_lf(const std::string &data)
Definition: PlainTextEditorPage.cpp:287
GpgFrontend::UI::PlainTextEditorPage::ShowNotificationWidget
void ShowNotificationWidget(QWidget *widget, const char *className)
Definition: PlainTextEditorPage.cpp:114
GpgFrontend::UI::PlainTextEditorPage::SignalUIBytesDisplayed
void SignalUIBytesDisplayed()
this signal is emitted when the bytes has been append in texteditor.
GpgFrontend::UI::PlainTextEditorPage::GetFilePath
const QString & GetFilePath() const
Definition: PlainTextEditorPage.cpp:84
GpgFrontend::UI
Definition: FileReadTask.cpp:29