DynExp
Highly flexible laboratory automation for dynamically changing experiments.
TextEditor.h
Go to the documentation of this file.
1 // This file is part of DynExp.
2 
8 #pragma once
9 
11 #include "stdafx.h"
12 
13 #include <QWidget>
14 #include "ui_TextEditor.h"
15 
16 class TextEditor : public QWidget
17 {
18  Q_OBJECT
19 
20  // Better DynExp::ItemIDType, but this is incompatible with g++ compiler. Should equal ParamsConfigDialog::IndexType.
21  using IndexType = qulonglong;
22 
23 public:
24  TextEditor(QWidget* parent, const std::filesystem::path& Filename);
25  ~TextEditor() = default;
26 
27  auto& GetFilename() const { return Filename; }
28 
29 private:
30  virtual void showEvent(QShowEvent* event) override;
31  virtual void closeEvent(QCloseEvent* event) override;
32 
37  bool DoSave();
38 
39  Ui::TextEditor ui;
40 
41  const std::filesystem::path Filename;
42 
43  QSyntaxHighlighter* SyntaxHighlighter = nullptr;
44 
45 private slots:
46  void OnSave();
47  void OnClose();
48 };
~TextEditor()=default
TextEditor(QWidget *parent, const std::filesystem::path &Filename)
Definition: TextEditor.cpp:7
QSyntaxHighlighter * SyntaxHighlighter
Definition: TextEditor.h:43
virtual void showEvent(QShowEvent *event) override
Definition: TextEditor.cpp:21
Ui::TextEditor ui
Definition: TextEditor.h:39
auto & GetFilename() const
Definition: TextEditor.h:27
const std::filesystem::path Filename
Definition: TextEditor.h:41
bool DoSave()
Saves the editor's content to the file Filename.
Definition: TextEditor.cpp:87
qulonglong IndexType
Definition: TextEditor.h:21
virtual void closeEvent(QCloseEvent *event) override
Definition: TextEditor.cpp:47
void OnClose()
Definition: TextEditor.cpp:104
void OnSave()
Definition: TextEditor.cpp:99
Accumulates include statements to provide a precompiled header.