1 #ifndef DOCUMENTSTYLE_HPP
2 #define DOCUMENTSTYLE_HPP
3 
4 #include <QUrl>
5 #include <QFont>
6 #include <QColor>
7 #include <QSettings>
8 #include <QTextListFormat>
9 
10 struct DocumentStyle
11 {
12     enum Theme {
13         Fixed = 0,
14         AutoDarkTheme = 1,
15         AutoLightTheme = 2
16     };
17 
18     struct DefaultFonts
19     {
20         QString regular, fixed;
21 
22         DefaultFonts();
23     };
24 
25     DocumentStyle();
26 
27     void initialiseDefaultFonts();
28 
29     //! Calculates a filtered/legal file name with all non-allowed chars escaped
30     static QString createFileNameFromName(QString const & src, int index);
31 
32     Theme theme;
33 
34     QFont standard_font;
35     QFont h1_font;
36     QFont h2_font;
37     QFont h3_font;
38     QFont preformatted_font;
39     QFont blockquote_font;
40 
41     QColor background_color;
42     QColor standard_color;
43     QColor preformatted_color;
44     QColor h1_color;
45     QColor h2_color;
46     QColor h3_color;
47     QColor blockquote_fgcolor;
48     QColor blockquote_bgcolor;
49 
50     QColor internal_link_color;
51     QColor external_link_color;
52     QColor cross_scheme_link_color;
53 
54     QString internal_link_prefix;
55     QString external_link_prefix;
56 
57     double margin_h, margin_v;
58 
59     double text_width;
60 
61     QStringList ansi_colors;
62 
63     bool justify_text, text_width_enabled, centre_h1;
64     double line_height_p;
65     double line_height_h;
66     int indent_bq, indent_p, indent_h, indent_l;
67     int indent_size;
68     QTextListFormat::Style list_symbol;
69 
70     bool save(QSettings & settings) const;
71     bool load(QSettings & settings);
72 
73     //! Create a new style with auto-generated colors for the given
74     //! url. The colors are based on the host name
75     DocumentStyle derive(QUrl const & url) const;
76 
77     //! Converts this style into a CSS document for
78     //! non-gemini rendered files.
79     QString toStyleSheet() const;
80 };
81 
82 #endif // DOCUMENTSTYLE_HPP
83