diff options
| author | Felix (xq) Queißner <git@mq32.de> | 2020-06-06 23:14:21 +0200 |
|---|---|---|
| committer | Felix (xq) Queißner <git@mq32.de> | 2020-06-06 23:14:21 +0200 |
| commit | 3aed883402dc8da829fc304434c5efd0570cbb97 (patch) | |
| tree | 48c46ab087a950d80f78819ceb609e93d246b040 /src/geminirenderer.hpp | |
| parent | 44e85dce678e7e36f436a6d0a25c212c9a2d3657 (diff) | |
| download | kristall-3aed883402dc8da829fc304434c5efd0570cbb97.tar.gz | |
Moves source code into subdirectory.
Diffstat (limited to 'src/geminirenderer.hpp')
| -rw-r--r-- | src/geminirenderer.hpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/geminirenderer.hpp b/src/geminirenderer.hpp new file mode 100644 index 0000000..2ec1651 --- /dev/null +++ b/src/geminirenderer.hpp @@ -0,0 +1,76 @@ +#ifndef GEMINIRENDERER_HPP +#define GEMINIRENDERER_HPP + +#include <QTextDocument> +#include <QColor> +#include <QSettings> + +#include "documentoutlinemodel.hpp" + +struct GeminiStyle +{ + enum Theme { + Fixed = 0, + AutoDarkTheme = 1, + AutoLightTheme = 2 + }; + + GeminiStyle(); + + Theme theme; + + QFont standard_font; + QFont h1_font; + QFont h2_font; + QFont h3_font; + QFont preformatted_font; + + QColor background_color; + QColor standard_color; + QColor preformatted_color; + QColor h1_color; + QColor h2_color; + QColor h3_color; + + QColor internal_link_color; + QColor external_link_color; + QColor cross_scheme_link_color; + + QString internal_link_prefix; + QString external_link_prefix; + + double margin; + + bool save(QSettings & settings) const; + bool load(QSettings & settings); + + //! Create a new style with auto-generated colors for the given + //! url. The colors are based on the host name + GeminiStyle derive(QUrl const & url) const; +}; + +class GeminiDocument : + public QTextDocument +{ + Q_OBJECT +public: + explicit GeminiDocument(QObject * parent = nullptr); + ~GeminiDocument() override; + + QColor background_color; +}; + +class GeminiRenderer +{ + GeminiStyle style; +public: + GeminiRenderer(GeminiStyle const & style = GeminiStyle{}); + + std::unique_ptr<GeminiDocument> render( + QByteArray const & input, + QUrl const & root_url, + DocumentOutlineModel & outline + ); +}; + +#endif // GEMINIRENDERER_HPP |
