-
Notifications
You must be signed in to change notification settings - Fork 0
/
dialogoptions.cpp
89 lines (73 loc) · 3.15 KB
/
dialogoptions.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
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
#include "dialogoptions.h"
#include "ui_dialogoptions.h"
#include <QSettings>
#include <QDebug>
DialogOptions::DialogOptions(QWidget *parent) :
QDialog(parent),
ui(new Ui::DialogOptions)
{
ui->setupUi(this);
this->setAttribute(Qt::WA_DeleteOnClose);
QFontDatabase db;
foreach(int size, db.standardSizes()){
ui->comboFontSize->addItem(QString::number(size));
}
loadSettings();
}
DialogOptions::~DialogOptions()
{
qDebug()<<"delet";
delete ui;
}
void DialogOptions::loadSettings()
{
QSettings setting(QApplication::applicationName(),"settings");
setting.beginGroup("Main");
QString fQ= setting.value("fontQuran","Amiri Quran").toString();
int indx= ui->fontComboQuran->findText(fQ);
ui->fontComboQuran->setCurrentIndex(indx);
QString fT= setting.value("fontTafsir","Traditional Arabic").toString();
int ind= ui->fontComboQuran->findText(fT);
ui->fontComboTefsir->setCurrentIndex(ind);
ui->comboFontSize->setEditText(setting.value("fontSize",22).toString());
QColor m_fontColor=setting.value("fontColor",QColor("#000000")).value<QColor>();
QColor m_backColor=setting.value("backColor",QColor("#FFFFFF")).value<QColor>();
QColor m_symbolColor=setting.value("symbolColor",QColor("#008000")).value<QColor>();
QColor m_findColor=setting.value("findColor",QColor("#FF0000")).value<QColor>();
setting.endGroup();
btnColorBack=new ButtonColor(m_backColor,this);
btnColorFont=new ButtonColor(m_fontColor,this);
btnColorSymbol=new ButtonColor(m_symbolColor,this);
btnColorFind=new ButtonColor(m_findColor,this);
ui->horizontalLayoutBack->addWidget(btnColorBack);
ui->horizontalLayoutFont->addWidget(btnColorFont);
ui->horizontalLayoutSymbol->addWidget(btnColorSymbol);
ui->horizontalLayoutFind->addWidget(btnColorFind);
ui->comboFontSize->setCurrentIndex(ui->comboFontSize->findText(ui->comboFontSize->currentText()));
}
void DialogOptions::saveSettings()
{
int size=ui->comboFontSize->currentText().toInt();
if(size<=0)size=QApplication::font().pointSize();
QSettings setting(QApplication::applicationName(),"settings");
setting.beginGroup("Main");
setting.setValue("fontQuran",ui->fontComboQuran->currentText());
setting.setValue("fontTafsir",ui->fontComboTefsir->currentText());
setting.setValue("fontSize", size);
setting.setValue("fontColor",btnColorFont->color());
setting.setValue("backColor",btnColorBack->color());
setting.setValue("symbolColor",btnColorSymbol->color());
setting.setValue("findColor",btnColorFind->color());
setting.endGroup();
}
void DialogOptions::on_buttonBox_clicked(QAbstractButton *button)
{
if(ui->buttonBox->standardButton(button)==QDialogButtonBox::Ok){
saveSettings();
emit settingsChanged();
this->accept();
}else if(ui->buttonBox->standardButton(button)==QDialogButtonBox::Apply){
saveSettings();
emit settingsChanged();
}
}