forked from KDE/ghostwriter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simplefontdialog.h
102 lines (87 loc) · 2.55 KB
/
simplefontdialog.h
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* SPDX-FileCopyrightText: 2014-2022 Megan Conkle <[email protected]>
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#ifndef SIMPLEFONTDIALOG_H
#define SIMPLEFONTDIALOG_H
#include <QDialog>
#include <QFont>
#include <QScopedPointer>
namespace ghostwriter
{
/**
* A simplified font dialog displaying only the font family and font size as
* options for the user to choose. This class will also render a preview
* of the font.
*/
class SimpleFontDialogPrivate;
class SimpleFontDialog : public QDialog
{
Q_OBJECT
Q_DECLARE_PRIVATE(SimpleFontDialog)
public:
/**
* Constructor.
*/
SimpleFontDialog(QWidget *parent = nullptr);
/**
* Constructor. Takes initial font to display as a parameter.
*/
SimpleFontDialog(const QFont &initial, QWidget *parent = nullptr);
/**
* Destructor.
*/
~SimpleFontDialog();
/**
* Sets whether only monospace are shown (true), or whether all fonts are
* shown (false). The option to toggle the setting with a checkbox can
* be hidden from the user by setting hideCheckbox to true.
*/
void setMonospaceOnly(bool available, bool hideCheckbox = false);
/**
* Returns whether only monospace are shown (true), or whether all fonts
* are shown (false).
*/
bool monospaceOnly() const;
/**
* Gets the currently selected font. Call this method after exec()
* returns.
*/
QFont selectedFont() const;
/**
* Convenience method to create the dialog and extract the font in
* one easy call. Takes initial font to display as a parameter.
*/
static QFont font
(
bool *ok,
const QFont &initial,
QWidget *parent = nullptr
);
/**
* Convenience method to create the dialog and extract the font in
* one easy call.
*/
static QFont font(bool *ok, QWidget *parent = nullptr);
/**
* Convenience method to create the dialog and extract the font in
* one easy call. Takes initial font to display as a parameter.
* Only shows monospace fonts as available choices.
*/
static QFont monospaceFont
(
bool *ok,
const QFont &initial,
QWidget *parent = nullptr
);
/**
* Convenience method to create the dialog and extract the font in
* one easy call. Only shows monospace fonts as available choices.
*/
static QFont monospaceFont(bool *ok, QWidget *parent = nullptr);
private:
QScopedPointer<SimpleFontDialogPrivate> d_ptr;
};
} // namespace ghostwriter
#endif // SIMPLEFONTDIALOG_H