aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/thread/FileReadThread.cpp
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/thread/FileReadThread.cpp
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/thread/FileReadThread.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/ui/thread/FileReadThread.cpp b/src/ui/thread/FileReadThread.cpp
index 270f50e7..04f713bd 100644
--- a/src/ui/thread/FileReadThread.cpp
+++ b/src/ui/thread/FileReadThread.cpp
@@ -29,39 +29,41 @@
namespace GpgFrontend::UI {
-FileReadThread::FileReadThread(std::string path) : path(std::move(path)) {}
+FileReadThread::FileReadThread(std::string path) : path(std::move(path)) {
+ qRegisterMetaType<std::string>("std::string");
+}
void FileReadThread::run() {
- LOG(INFO) << "Started";
+ LOG(INFO) << "started";
boost::filesystem::path read_file_path(this->path);
if (is_regular_file(read_file_path)) {
- LOG(INFO) << "Read Open";
+ LOG(INFO) << "read open";
- auto fp = fopen(read_file_path.string().c_str(), "r");
+ auto fp = fopen(read_file_path.string().c_str(), "rb");
size_t read_size;
- LOG(INFO) << "Thread Start Reading";
+ LOG(INFO) << "thread start reading";
- char buffer[8192];
+ char buffer[4096];
while ((read_size = fread(buffer, sizeof(char), sizeof buffer, fp)) > 0) {
// Check isInterruptionRequested
if (QThread::currentThread()->isInterruptionRequested()) {
- LOG(INFO) << "Read Thread isInterruptionRequested ";
+ LOG(INFO) << "thread is interruption requested ";
fclose(fp);
return;
}
- LOG(INFO) << "Read Thread Read block size " << read_size;
+ LOG(INFO) << "block size " << read_size;
std::string buffer_str(buffer, read_size);
- emit sendReadBlock(QString::fromStdString(buffer_str));
+ emit sendReadBlock(buffer_str);
#ifdef RELEASE
QThread::msleep(32);
#else
- QThread::msleep(48);
+ QThread::msleep(128);
#endif
}
fclose(fp);
emit readDone();
- LOG(INFO) << "Thread End Reading";
+ LOG(INFO) << "thread end reading";
}
}