aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/main_window/MainWindowSlotFunction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/main_window/MainWindowSlotFunction.cpp')
-rw-r--r--src/ui/main_window/MainWindowSlotFunction.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp
index e4038f66..95eb9871 100644
--- a/src/ui/main_window/MainWindowSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowSlotFunction.cpp
@@ -28,6 +28,7 @@
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/posix_time/posix_time_io.hpp>
+#include <cstddef>
#include "MainWindow.h"
#include "core/GpgConstants.h"
@@ -249,7 +250,25 @@ void MainWindow::upload_key_to_server() {
dialog->SlotUpload();
}
-void MainWindow::SlotOpenFile(QString& path) { edit_->SlotOpenFile(path); }
+void MainWindow::SlotOpenFile(const QString& path) {
+ QFileInfo const info(path);
+ if (!info.isFile() || !info.isReadable()) {
+ QMessageBox::critical(this, _("Error"),
+ _("Cannot open this file. Please make sure that this "
+ "is a regular file and it's readable."));
+ return;
+ }
+
+ if (info.size() > static_cast<qint64>(1024 * 1024)) {
+ QMessageBox::critical(
+ this, _("Error"),
+ _("Cannot open this file. The file is TOO LARGE (>1MB) for "
+ "GpgFrontend Text Editor."));
+ return;
+ }
+
+ edit_->SlotOpenFile(path);
+}
void MainWindow::slot_version_upgrade_nofity() {
SPDLOG_DEBUG(