1/* This file is part of the KDE libraries
2
3 Copyright (C) 2008 Chusslove Illich <caslav.ilic@gmx.net>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library 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 GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20#ifndef KFONTCOMBOBOX_P_H
21#define KFONTCOMBOBOX_P_H
22
23#include <kdeui_export.h>
24
25#include <kcombobox.h>
26
27class KFontComboBoxPrivate;
28
29/**
30 * @short A lightweight font selection widget.
31 *
32 * A combobox to select the font from. Lightweight counterpart to KFontChooser,
33 * for situations where only the font family should be selected, while the
34 * font style and size are handled by other means. Like in KFontChooser,
35 * this widget will show the font previews in the unrolled dropdown list.
36 *
37 * @note The class is similar to QFontComboBox, but more tightly integrated
38 * with KDE desktop. Use it instead of QFontComboBox by default in KDE code.
39 *
40 * \image html kfontcombobox.png "KDE Font Combo Box"
41 *
42 * @author Chusslove Illich \<caslav.ilic@gmx.net\>
43 *
44 * @see KFontAction
45 * @see KFontChooser
46 *
47 * @since 4.1
48 */
49class KDEUI_EXPORT KFontComboBox : public KComboBox
50{
51 Q_OBJECT
52
53 Q_PROPERTY(QFont currentFont READ currentFont WRITE setCurrentFont NOTIFY currentFontChanged USER true)
54
55public:
56
57 /**
58 * Constructor.
59 *
60 * @param parent the parent widget
61 */
62 explicit KFontComboBox (QWidget *parent = 0);
63
64 /**
65 * Toggle selectable fonts to be only those of fixed width or all.
66 *
67 * @param onlyFixed only fixed width fonts when @p true,
68 * all fonts when @p false
69 */
70 void setOnlyFixed (bool onlyFixed);
71
72 /**
73 * Set selectable fonts to be only those present in the list.
74 *
75 * @param fontList a list of fonts as returned by QFontDatabase::families() or
76 * QFontChooser::getFontList(). If this is empty (default), then the list
77 * of fonts is constructed according to the @p onlyFixed setting.
78 * @since 4.9.2
79 */
80 void setFontList (const QStringList &fontList);
81
82 /**
83 * Destructor.
84 */
85 virtual ~KFontComboBox ();
86
87 /**
88 * The font currently selected from the list.
89 *
90 * @return the selected font
91 */
92 QFont currentFont () const;
93
94 /**
95 * The recommended size of the widget.
96 * Reimplemented to make the recommended width independent
97 * of the particular fonts installed.
98 *
99 * @return recommended size
100 */
101 virtual QSize sizeHint() const;
102
103public Q_SLOTS:
104 /**
105 * Set the font to show as selected in the combobox.
106 *
107 * @param font the new font
108 */
109 void setCurrentFont (const QFont &font);
110
111Q_SIGNALS:
112 /**
113 * Emitted when a new font has been selected,
114 * either through user input or by setFont().
115 *
116 * @param font the new font
117 */
118 void currentFontChanged (const QFont &font);
119
120protected:
121 bool event (QEvent *e);
122
123private:
124
125 friend class KFontComboBoxPrivate;
126 KFontComboBoxPrivate * const d;
127
128 Q_DISABLE_COPY(KFontComboBox)
129
130 Q_PRIVATE_SLOT(d, void _k_currentFontChanged (int))
131};
132
133#endif
134