BibleTime
btfontsizewidget.cpp
Go to the documentation of this file.
1/*********
2*
3* In the name of the Father, and of the Son, and of the Holy Spirit.
4*
5* This file is part of BibleTime's source code, https://bibletime.info/
6*
7* Copyright 1999-2025 by the BibleTime developers.
8* The BibleTime source code is licensed under the GNU General Public License
9* version 2.0.
10*
11**********/
12
13#include "btfontsizewidget.h"
14
15#include <QCompleter>
16#include <QFontDatabase>
17#include <QIntValidator>
18#include <QNonConstOverload>
19#include <QVariant>
20#include "../../util/btconnect.h"
21
22
24 : QComboBox(parent)
25 , m_validator(new QIntValidator(1, 99, this))
26{
27 setEditable(true);
28 setValidator(m_validator);
29 completer()->setCompletionMode(QCompleter::PopupCompletion);
30
31 for (int const size : QFontDatabase::standardSizes()) {
32 if (size > m_validator->top())
33 m_validator->setTop(size);
34 addItem(QString::number(size), QVariant(size));
35 }
36
37 BT_CONNECT(this, qOverload<QString const &>(&QComboBox::currentTextChanged),
38 [this](QString const & text)
39 { Q_EMIT fontSizeChanged(text.toInt()); });
40}
41
43 if ((size < 1) || (size > m_validator->top()))
44 size = 12;
45 setCurrentText(QString::number(size));
46}
47
49 return currentText().toInt();
50}
#define BT_CONNECT(...)
Definition btconnect.h:20
QIntValidator *const m_validator
void setFontSize(int size)
BtFontSizeWidget(QWidget *parent=nullptr)
void fontSizeChanged(int)