-
-
Notifications
You must be signed in to change notification settings - Fork 342
Expand file tree
/
Copy pathFixedFontSelector.cpp
More file actions
68 lines (56 loc) · 1.25 KB
/
Copy pathFixedFontSelector.cpp
File metadata and controls
68 lines (56 loc) · 1.25 KB
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
/*
* Copyright (C) 2014 - 2025 Evan Teran <evan.teran@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "FixedFontSelector.h"
#include <QtDebug>
/**
* @brief
*/
FixedFontSelector::FixedFontSelector(QWidget *parent, Qt::WindowFlags f)
: QWidget(parent, f) {
ui.setupUi(this);
for (int size : QFontDatabase::standardSizes()) {
ui.fontSize->addItem(QStringLiteral("%1").arg(size), size);
}
}
/**
* @brief
*/
QFont FixedFontSelector::currentFont() const {
return ui.fontCombo->currentFont();
}
/**
* @brief
*/
void FixedFontSelector::setCurrentFont(const QString &font) {
QFont f;
f.fromString(font);
setCurrentFont(f);
}
/**
* @brief
*/
void FixedFontSelector::setCurrentFont(const QFont &font) {
ui.fontCombo->setCurrentFont(font);
int n = ui.fontSize->findData(font.pointSize());
if (n != -1) {
ui.fontSize->setCurrentIndex(n);
}
}
/**
* @brief
*/
void FixedFontSelector::on_fontCombo_currentFontChanged(const QFont &font) {
Q_EMIT currentFontChanged(font);
}
/**
* @brief
*/
void FixedFontSelector::on_fontSize_currentIndexChanged(int index) {
QFont font = ui.fontCombo->currentFont();
font.setPointSize(ui.fontSize->itemData(index).toInt());
ui.fontCombo->setCurrentFont(font);
Q_EMIT currentFontChanged(font);
}