summaryrefslogtreecommitdiff
path: root/src/frontend/settingsdialogs/cfontchooser.h
blob: 7dcefda2d014768ae79d68df688a58add4046c70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//
// C++ Interface: CFontChooser
//
// Description: BibleTime font chooser
//
//
// Author: The BibleTime team <info@bibletime.info>, (C) 1999-2008
//
// Copyright: See COPYING file that comes with this distribution
//
//

#ifndef CFONTCHOOSER_H
#define CFONTCHOOSER_H

// These following two defines allow chosing between using KDE and
// Qt only for rendering the preview text


#include <QWidget>
#include <QFrame>

class QString;
class QFrame;
class QListWidget;
class QListWidgetItem;
class QVBoxLayout;
class QWebView;
class CListWidget;

class CFontChooser : public QFrame {
        Q_OBJECT

    public:
        CFontChooser(QWidget* parent = 0);
        ~CFontChooser();
        void setFont(const QFont& font);
        void setSampleText(const QString& text);
        QSize sizeHint() const;

    private:
        void createFontAreaLayout();
        void createLayout();
        void createTextAreaLayout();
        void connectListWidgets();
        QString formatAsHtml(const QString& text);
        void loadFonts();
        void loadSizes(const QString& font, const QString& style);
        void loadStyles(const QString& font);
        void outputHtmlText();
        void restoreListWidgetValue(QListWidget* listWidget, const QString& value);
        QString saveListWidgetValue(QListWidget* listWidget);

        QFrame* m_fontWidget;
        QWebView* m_webView;
        CListWidget* m_fontListWidget;
        CListWidget* m_styleListWidget;
        CListWidget* m_sizeListWidget;
        QString m_htmlText;
        QFont m_font;
        QVBoxLayout* m_vBoxLayout;
        QString m_choosenStyle;

    private slots:
        void fontChanged(QListWidgetItem* current, QListWidgetItem* previous);
        void setFontStyle(const QString& styleString, QFont* font);
        void sizeChanged(QListWidgetItem* current, QListWidgetItem* previous);
        void styleChanged(QListWidgetItem* current, QListWidgetItem* previous);

    signals:
        void fontSelected(const QFont&);
};

#endif