浏览代码

TextEditor: Ask before opening a file if current document is dirty

This commit should be a fix of issue #892
Paweł Cholewa 5 年之前
父节点
当前提交
e2dcf27a2e
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      Applications/TextEditor/TextEditorWidget.cpp

+ 8 - 0
Applications/TextEditor/TextEditorWidget.cpp

@@ -153,6 +153,14 @@ TextEditorWidget::TextEditorWidget()
         if (!open_path.has_value())
             return;
 
+        if (m_document_dirty) {
+            auto save_document_first_box = GMessageBox::construct("Save Document First?", "Warning", GMessageBox::Type::Warning, GMessageBox::InputType::OKCancel, window());
+            auto save_document_first_result = save_document_first_box->exec();
+
+            if (save_document_first_result == GDialog::ExecResult::ExecOK)
+                m_save_action->activate();
+        }
+
         open_sesame(open_path.value());
     });