-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetting.cpp
More file actions
122 lines (79 loc) · 2.36 KB
/
setting.cpp
File metadata and controls
122 lines (79 loc) · 2.36 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
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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFont>
#include <QColor>
void MainWindow::setBold(bool selected)
{
QFont font = this->ui->textEdit->font();
font.setBold(selected);
this->ui->textEdit->setFont(font);
}
void MainWindow::setUnderline(bool selected)
{
QFont font = this->ui->textEdit->font();
font.setUnderline(selected);
this->ui->textEdit->setFont(font);
}
void MainWindow::setItalic(bool selected)
{
QFont font = this->ui->textEdit->font();
font.setItalic(selected);
this->ui->textEdit->setFont(font);
}
void MainWindow::setFont()
{
/*
QFontDialog * wfont = new QFontDialog(QFont("Courier new", 11), this);
wfont->setWindowIcon(QIcon(":/icon/font"));
wfont->setWindowTitle(tr("字体选择"));
QFont font = wfont->selectedFont();
if(wfont->exec() == QDialog::Accepted)
{
this->ui->textEdit->setFont(font);
}
delete wfont;
*/
bool ok;
QFont font = QFontDialog::getFont(&ok, QFont("Courier new", 11), this, tr("选择字体"));
if(ok)
{
this->ui->textEdit->setFont(font);
}
else
{
return;
}
}
void MainWindow::setFontColor()
{
// bool ok;
QColor color = QColorDialog::getColor(Qt::black, this, tr("选择颜色"));
this->ui->textEdit->setTextColor(color);
}
void MainWindow::ini_init()
{
if(QFileInfo::exists("user.ini"))
{
this->ini = new QSettings("user.ini", QSettings::IniFormat);
this->ui->textEdit->setFont(QFont(this->ini->value("/Font/fontfamily").toString()));
this->ui->textEdit->setFontPointSize(qreal(this->ini->value("/Font/fontsize").toInt()));
this->ui->textEdit->setTextColor(QColor(this->ini->value("/Font/color").toString()));
this->tempPath = this->ini->value("/Path/path").toString();
delete this->ini;
}
else
{
this->ini = new QSettings("user.ini", QSettings::IniFormat);
ini->setValue("/user/first", 0);
delete this->ini;
}
}
void MainWindow::change_ini()
{
this->ini = new QSettings("user.ini", QSettings::IniFormat);
ini->setValue("Font/fontfamily", this->ui->textEdit->font());
ini->setValue("Font/fontsize", this->ui->textEdit->fontPointSize());
ini->setValue("Font/color", this->ui->textEdit->textColor());
ini->setValue("Path/path", this->path);
delete this->ini;
}