-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathasettingwidget.cpp
79 lines (75 loc) · 2.57 KB
/
asettingwidget.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
#include "asettingwidget.h"
#include <QSettings>
#include <QDebug>
ASettingWidget::ASettingWidget(QWidget *parent) :
QWidget(parent)
{
this->setupUi(this);
updateSetting();
theProjectDescribe = new AGetTheProjectDescribe();
theProjectDescribe->getAboutContent();
connect(theProjectDescribe,&AGetTheProjectDescribe::sig_aboutContent,[=](QByteArray data){
if(!data.isEmpty())
textBrowserAbout->setText(QString(data));
});
}
ASettingWidget::~ASettingWidget()
{
delete theProjectDescribe;
}
void ASettingWidget::showEvent(QShowEvent *event)
{
updateSetting();
}
void ASettingWidget::updateSetting()
{
QSettings *configIniRead = new QSettings("./config/main.ini", QSettings::IniFormat);
m_ak = configIniRead->value("/qiniu/ak").toString();
m_sk = configIniRead->value("/qiniu/sk").toString();
m_bucket = configIniRead->value("/qiniu/bucket").toString();
m_domain = configIniRead->value("/qiniu/domain").toString();
m_mdurl = configIniRead->value("/preference/mdurl").toString().toInt();
m_stayOnTop = configIniRead->value("/preference/stayontop").toString().toInt();
m_autodup = configIniRead->value("/preference/autodup").toString().toInt();
lineEditAK->setText(m_ak);
lineEditSK->setText(m_sk);
lineEditBucket->setText(m_bucket);
lineEditDomain->setText(m_domain);
checkBoxAutoDup->setChecked(m_autodup);
radioButtonOriginUrl->setChecked(!m_mdurl);
radioButtonMarkdownUrl->setChecked(m_mdurl);
checkBoxStaysOnTop->setChecked(m_stayOnTop);
}
QString ASettingWidget::getDomain()
{
return m_domain;
}
bool ASettingWidget::getIfStayOnTop()
{
return m_stayOnTop;
}
bool ASettingWidget::getIfAutoDup()
{
return m_autodup;
}
bool ASettingWidget::getIfCopyMDUrl()
{
return m_mdurl;
}
void ASettingWidget::on_pushButtonSubmitSetting_clicked()
{
QSettings *configIniWrite = new QSettings("./config/main.ini", QSettings::IniFormat);
configIniWrite->setValue("/qiniu/ak",lineEditAK->text());
configIniWrite->setValue("/qiniu/sk",lineEditSK->text());
configIniWrite->setValue("/qiniu/bucket",lineEditBucket->text());
configIniWrite->setValue("/qiniu/domain",lineEditDomain->text());
configIniWrite->setValue("/preference/autodup",checkBoxAutoDup->isChecked()?"1":"0");
configIniWrite->setValue("/preference/mdurl",radioButtonMarkdownUrl->isChecked()?"1":"0");
configIniWrite->setValue("/preference/stayontop",checkBoxStaysOnTop->isChecked()?"1":"0");
updateSetting();
this->close();
}
void ASettingWidget::on_pushButtonCancelSetting_clicked()
{
this->close();
}