CuteLogger
Fast and simple logging solution for Qt based applications
htmleditor.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the Graphics Dojo project on Qt Labs.
7 **
8 ** This file may be used under the terms of the GNU General Public
9 ** License version 2.0 or 3.0 as published by the Free Software Foundation
10 ** and appearing in the file LICENSE.GPL included in the packaging of
11 ** this file. Please review the following information to ensure GNU
12 ** General Public Licensing requirements will be met:
13 ** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
14 ** http://www.gnu.org/copyleft/gpl.html.
15 **
16 ** If you are unsure which license is appropriate for your use, please
17 ** contact the sales department at qt-sales@nokia.com.
18 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 **
22 ****************************************************************************/
23 
24 
25 #ifndef HTML_EDITOR_H
26 #define HTML_EDITOR_H
27 
28 #include <QWidget>
29 #include "highlighter.h"
30 
31 #if QT_VERSION < 0x040500
32 #error You must use Qt >= 4.5.0!
33 #endif
34 
35 class Ui_HtmlEditor;
36 class Ui_Dialog;
37 
38 class QLabel;
39 class QSlider;
40 class QUrl;
41 
42 class HtmlEditor : public QWidget
43 {
44  Q_OBJECT
45 
46 public:
47  HtmlEditor(QWidget *parent = 0);
48  ~HtmlEditor();
49 
50  bool load(const QString &f);
51  void resizeWebView(int w, int h);
52 
53 public slots:
54  void changeZoom(int);
55 
56 signals:
57  void saved();
58  void closed();
59 
60 protected:
61  virtual void closeEvent(QCloseEvent *e);
62 
63 private:
64  void setupActions();
65  void setupToolBar();
66  void setupMenu();
67  bool maybeSave();
68  void setCurrentFileName(const QString &fileName);
69  void execCommand(const QString&);
70  void execCommand(const QString &cmd, const QString &arg);
71  bool queryCommandState(const QString&);
72  QString qmlFilePath(const QString& fileName);
73 
74 private slots:
75  void fileNew();
76  void fileOpen();
77  bool fileSave();
78  bool fileSaveAs();
79  void editSelectAll();
80  void styleParagraph();
81  void styleHeading1();
82  void styleHeading2();
83  void styleHeading3();
84  void styleHeading4();
85  void styleHeading5();
86  void styleHeading6();
87  void stylePreformatted();
88  void styleAddress();
89  void formatStrikeThrough();
90  void formatAlignLeft();
91  void formatAlignCenter();
92  void formatAlignRight();
93  void formatAlignJustify();
94  void formatIncreaseIndent();
95  void formatDecreaseIndent();
96  void formatNumberedList();
97  void formatBulletedList();
98  void formatFontName();
99  void formatFontSize();
100  void formatTextColor();
101  void formatBackgroundColor();
102  void insertImage();
103  void createLink();
104  void insertHtml();
105  void zoomOut();
106  void zoomIn();
107  void adjustActions();
108  void adjustSource();
109  void changeTab(int);
110  void openLink(const QUrl&);
111  void on_actionTextOutline_triggered();
112  void formatTextOutline(const QString&);
113  void on_actionTextShadow_triggered();
114  void formatTextShadow(const QString&);
115 
116 private:
117  Ui_HtmlEditor *ui;
118  QString fileName;
119  QLabel *zoomLabel;
120  QSlider *zoomSlider;
121  Highlighter *highlighter;
122  Ui_Dialog *ui_dialog;
123  QDialog *insertHtmlDialog;
124  QUrl baseUrl;
125 };
126 
127 #endif // HTML_EDITOR_H