-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMarkdownEditor.h
More file actions
72 lines (60 loc) · 1.74 KB
/
MarkdownEditor.h
File metadata and controls
72 lines (60 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef MARKDOWNEDITOR_H
#define MARKDOWNEDITOR_H
#include <QWidget>
#include <QUrl>
#include "cppGUI_global.h"
namespace Ui {
class MarkdownEditor ;
}
//Editot for markdown (left) with HTML view (right)
class CPPGUISHARED_EXPORT MarkdownEditor
: public QWidget
{
Q_OBJECT
public:
MarkdownEditor(QWidget *parent = nullptr);
~MarkdownEditor();
//Set tab stop width in pixels
void setTabStopWidth(qreal tab_dist);
//Set font
void setFont(QFont font);
//Set base folder for links
void setBaseFolder(QString folder);
//Returns if the file was modified
bool isModified() const { return is_modified_;}
//Returns the currently loaded filename (with path)
QString file() const { return file_;}
//Returns the base folder
QString baseFolder() const { return base_folder_;}
public slots:
//Load a file and optinally set base folder for links
void loadFile(QString filename);
//Store opened file
void storeFile();
//Clears the loaded file
void clear();
//Set strings to highlight in HTML view
void setHighlightStrings(QStringList strings);
//Toggle edit area
void toggleEditArea();
//Toggle if editing is enabled
void toggleEditingEnabled();
signals:
//Emitted when the file modification state changes
void modificationStateChanged();
protected slots:
void openExternalLink(QUrl url);
void textChanged();
void updateHTML();
QString markdownToHtml(QString in, bool prescale_images);
void askIfFileShouldBeStored();
void contextMenuHtml(QPoint pos);
private:
Ui::MarkdownEditor* ui_;
QString file_; //canonical path
QString file_folder_; //canonical path of the file folder
QString base_folder_; //canonocal path of the base folder (links can be relative to this)
bool is_modified_;
QStringList highlight_;
};
#endif // MARKDOWNEDITOR_H