aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/widgets/PlainTextEditorPage.h
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2022-01-12 03:04:46 +0000
committerSaturneric <[email protected]>2022-01-12 03:04:46 +0000
commitd24f0251e8c8964bf42f4bf028023f02f4e96933 (patch)
treeb0d1fe016143274a66898ec6ca0913115400c033 /src/ui/widgets/PlainTextEditorPage.h
parent<refactor>(ui): Adjust src/ui/function to src/ui/thread (diff)
downloadGpgFrontend-d24f0251e8c8964bf42f4bf028023f02f4e96933.tar.gz
GpgFrontend-d24f0251e8c8964bf42f4bf028023f02f4e96933.zip
<refactor, feat>(ui): Text editor improvements.
1. Add binary display mode 2. Add information bar 3. Added character code recognition function. 4. Identify text encoding and line breaks 5. Count the number of characters 6. Code reconstruction
Diffstat (limited to '')
-rw-r--r--src/ui/widgets/PlainTextEditorPage.h (renamed from src/ui/widgets/EditorPage.h)27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/ui/widgets/EditorPage.h b/src/ui/widgets/PlainTextEditorPage.h
index d1bc1ac2..24823c06 100644
--- a/src/ui/widgets/EditorPage.h
+++ b/src/ui/widgets/PlainTextEditorPage.h
@@ -28,12 +28,7 @@
#include "gpg/GpgConstants.h"
#include "ui/GpgFrontendUI.h"
-QT_BEGIN_NAMESPACE
-class QVBoxLayout;
-class QHBoxLayout;
-class QString;
-class QLabel;
-QT_END_NAMESPACE
+class Ui_PlainTextEditor;
namespace GpgFrontend::UI {
@@ -41,7 +36,7 @@ namespace GpgFrontend::UI {
* @brief Class for handling a single tab of the tabwidget
*
*/
-class EditorPage : public QWidget {
+class PlainTextEditorPage : public QWidget {
Q_OBJECT
public:
/**
@@ -50,7 +45,8 @@ class EditorPage : public QWidget {
* @param filePath Path of the file handled in this tab
* @param parent Pointer to the parent widget
*/
- explicit EditorPage(QString filePath = "", QWidget* parent = nullptr);
+ explicit PlainTextEditorPage(QString filePath = "",
+ QWidget* parent = nullptr);
/**
* @details Get the filepath of the currently activated tab.
@@ -67,7 +63,7 @@ class EditorPage : public QWidget {
/**
* @details Return pointer tp the textedit of the currently activated tab.
*/
- QTextEdit* getTextPage();
+ QPlainTextEdit* getTextPage();
/**
* @details Show additional widget at buttom of currently active tab
@@ -91,12 +87,17 @@ class EditorPage : public QWidget {
void PrepareToDestroy();
private:
- QTextEdit* textPage; /** The textedit of the tab */
- QVBoxLayout* mainLayout; /** The layout for the tab */
+ std::shared_ptr<Ui_PlainTextEditor> ui;
QString full_file_path_; /** The path to the file handled in the tab */
bool signMarked{}; /** true, if the signed header is marked, false if not */
bool read_done_ = false;
- QThread* read_hread_ = nullptr;
+ QThread* read_thread_ = nullptr;
+ bool binary_mode_ = false;
+ size_t read_bytes_ = 0;
+
+ void detect_encoding(const std::string& data);
+
+ void detect_cr_lf(const QString& data);
private slots:
@@ -105,7 +106,7 @@ class EditorPage : public QWidget {
*/
void slotFormatGpgHeader();
- void slotInsertText(const QString& text);
+ void slotInsertText(const std::string& data);
};
} // namespace GpgFrontend::UI