1 /**************************************************************************
2 * Otter Browser: Web browser controlled by the user, not vice-versa.
3 * Copyright (C) 2018 - 2019 Michal Dutkiewicz aka Emdek <michal@emdek.pl>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 **************************************************************************/
19 
20 #ifndef OTTER_TEXTBROWSERWIDGET_H
21 #define OTTER_TEXTBROWSERWIDGET_H
22 
23 #include <QtCore/QSet>
24 #include <QtCore/QUrl>
25 #include <QtWidgets/QTextBrowser>
26 
27 namespace Otter
28 {
29 
30 class TextBrowserWidget final : public QTextBrowser
31 {
32 public:
33 	enum ImagesPolicy
34 	{
35 		NoImages = 0,
36 		OnlyCachedImages,
37 		AllImages
38 	};
39 
40 	explicit TextBrowserWidget(QWidget *parent = nullptr);
41 
42 	void setImagesPolicy(ImagesPolicy policy);
43 	QVariant loadResource(int type, const QUrl &url) override;
44 
45 private:
46 	QSet<QUrl> m_resources;
47 	ImagesPolicy m_imagesPolicy;
48 };
49 
50 }
51 
52 #endif
53