]> git.sven.stormbind.net Git - sven/vym.git/blob - texteditor.h
5d461fe09ad4e6c193ddfe2100451b5bcabb1791
[sven/vym.git] / texteditor.h
1 #ifndef TEXTEDITOR_H 
2 #define TEXTEDITOR_H
3
4 #include <QtGui>
5 #include <QMainWindow>
6
7 class QTextEdit;
8 class QComboBox;
9
10 #include "vymtext.h"
11
12 enum EditorState {inactiveEditor,emptyEditor,filledEditor};
13
14 class TextEditor : public QMainWindow
15 {    Q_OBJECT
16 public:
17     TextEditor();
18     ~TextEditor();
19
20     void init(const QString &ename);
21     bool isEmpty();
22     void setEditorName( const QString & );
23     void setEditorTitle(const QString &);
24     QString getEditorTitle();
25     void setFont (const QFont &);
26     void setFontHint(const QString&);
27     QString getFontHint();
28     QString getFontHintDefault();
29     void setFilename (const QString&);
30     QString getFilename ();
31     void setFilenameHint (const QString&);
32     QString getFilenameHint ();
33     QString getText();
34     VymText getVymText();
35
36     bool findText(const QString &, const QTextDocument::FindFlags &); 
37     bool findText(const QString &, const QTextDocument::FindFlags &,int i); 
38     void setTextCursor (const QTextCursor & cursor );
39     QTextCursor getTextCursor();
40     void setFocus();
41
42 protected:
43     void setupFileActions();
44     void setupEditActions();
45     void setupFormatActions();
46     void setupSettingsActions();
47     void closeEvent( QCloseEvent* );
48     bool eventFilter(QObject *obj, QEvent *ev);
49
50 public slots:
51     void editorChanged();           // received when text() changed
52     void setRichText(const QString &t);
53     void setPlainText(const QString &t);
54     void setTextAuto(const QString &);  // set Text and autodetect mode
55     void setVymText(const VymText &vt);
56     void setInactive();             // Nothing can be entered
57     void editCopyAll();
58     void reset();
59
60 signals:
61     void textHasChanged();
62     void windowClosed();
63     void fontFamilyHasChanged();
64     void fontSizeHasChanged();
65     
66 private slots:
67     void textLoad();
68     void textSaveAs();
69     void textSave();
70     void textExportAsASCII();
71     void textPrint();
72     void textEditUndo();
73     void toggleFonthint();
74     void setRichTextMode(bool b);
75     void toggleRichText();
76     void setFixedFont();
77     void setVarFont();
78     void textBold();
79     void textUnderline();
80     void textItalic();
81     void textFamily( const QString &f );
82     void textSize( const QString &p );
83     void textColor();
84     void textAlign(QAction*);
85     void textVAlign();
86     void fontChanged( const QFont &f );
87     void colorChanged( const QColor &c );
88     void formatChanged (const QTextCharFormat &f);
89     void alignmentChanged( int a );
90     void verticalAlignmentChanged(QTextCharFormat::VerticalAlignment);
91     void updateActions();
92     void setState (EditorState);
93     void setEmptyEditorColor();
94     void setInactiveEditorColor();
95     void setFilledEditorColor();
96     void setFontColor();
97
98 protected:
99     QString shortcutScope;  // used for settings and shortcut scopes
100     QTextEdit *e;
101     QPoint lastPos;         // save last position of window
102     QString editorName;     // Name of editor, e.g. note editor, heading editor, ...
103     QString editorTitle;    // window title: Editor name + selected branch
104     QString filename;
105     QString filenameHint;
106
107     QBrush emptyPaper;      // setting the background color
108     QBrush filledPaper;     // depending on the state
109     QBrush inactivePaper;   // depending on the state
110     EditorState state;
111     bool blockChangedSignal;
112
113     QColor colorEmptyEditor;
114     QColor colorFilledEditor;
115     QColor colorInactiveEditor;
116     QColor colorFont;
117
118     QFont varFont;
119     QFont fixedFont;
120     QComboBox *comboFont, *comboSize;
121     
122     QToolBar *editToolBar;
123     QToolBar *fontToolBar;
124     QToolBar *fontHintsToolBar;
125     QToolBar *formatToolBar;
126
127     QAction *actionFileLoad,
128     *actionFileSave,
129     *actionFileSaveAs,
130     *actionFilePrint,
131     *actionFileDeleteAll,
132     *actionEditUndo,
133     *actionEditRedo,
134     *actionEditCopy,
135     *actionEditCut,
136     *actionEditPaste,
137     *actionFormatUseFixedFont,
138     *actionFormatRichText,
139     *actionSettingsVarFont,
140     *actionSettingsFixedFont,
141     *actionSettingsFonthintDefault,
142     *actionEmptyEditorColor,
143     *actionFilledEditorColor,
144     *actionInactiveEditorColor,
145     *actionFontColor;
146
147     QAction *actionTextBold,
148     *actionTextUnderline,
149     *actionTextItalic,
150     *actionTextColor,
151     *actionAlignSubScript,
152     *actionAlignSuperScript,
153     *actionAlignLeft,
154     *actionAlignCenter,
155     *actionAlignRight,
156     *actionAlignJustify;
157 };
158
159 #endif