-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettingsdialog.cpp
57 lines (39 loc) · 1.3 KB
/
settingsdialog.cpp
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
#include "settingsdialog.h"
#include "ui_settingsdialog.h"
#include <QTimer>
QPlainTextEdit* g_mReferenceTextEdit;
QTimer* g_mTimerTick;
SettingsDialog::SettingsDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::SettingsDialog)
{
ui->setupUi(this);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); // Remove question mark button.
connect(ui->CBoxEditorTextFont, &QFontComboBox::currentFontChanged, this, &SettingsDialog::fontChanged);
resetTickLabel();
g_mTimerTick = new QTimer();
g_mTimerTick->setInterval(1500);
g_mTimerTick->setSingleShot(true);
connect(g_mTimerTick, &QTimer::timeout, this, QOverload<>::of(&SettingsDialog::resetTickLabel));
}
SettingsDialog::~SettingsDialog()
{
delete ui;
}
void SettingsDialog::setEditorTextFont(const QFont font) {
ui->CBoxEditorTextFont->setCurrentFont(font);
}
void SettingsDialog::fontChanged(const QFont &f) {
if (!g_mReferenceTextEdit) return;
if (g_mTimerTick->isActive())
g_mTimerTick->stop();
g_mReferenceTextEdit->setFont(f);
ui->TickLabelFont->setVisible(true);
g_mTimerTick->start();
}
void SettingsDialog::setReferenceTextEdit(QPlainTextEdit* w) {
g_mReferenceTextEdit = w;
}
void SettingsDialog::resetTickLabel() {
ui->TickLabelFont->setVisible(false);
}