forked from torinkwok/wxNote
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptionsDialog.cpp
More file actions
244 lines (192 loc) · 10.6 KB
/
Copy pathOptionsDialog.cpp
File metadata and controls
244 lines (192 loc) · 10.6 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
///:
/*****************************************************************************
** **
** .======. **
** | INRI | **
** | | **
** | | **
** .========' '========. **
** | _ xxxx _ | **
** | /_;-.__ / _\ _.-;_\ | **
** | `-._`'`_/'`.-' | **
** '========.`\ /`========' **
** | | / | **
** |/-.( | **
** |\_._\ | **
** | \ \`;| **
** | > |/| **
** | / // | **
** | |// | **
** | \(\ | **
** | `` | **
** | | **
** | | **
** | | **
** | | **
** \\ _ _\\| \// |//_ _ \// _ **
** ^ `^`^ ^`` `^ ^` ``^^` `^^` `^ `^ **
** **
** Copyright © 1997-2013 by Tong G. **
** ALL RIGHTS RESERVED. **
** **
****************************************************************************/
#include "wxNote_Gui/wxNote_Dialog/OptionsDialog.h"
#include "wxNote_Gui/wxNote_Other/FontComboBox.h"
#include "wxNote_Gui/wxNote_Other/FontSizeComboBox.h"
#include "wxNote_Global.h"
#include <QTableWidget>
#include <QLabel>
#include <QGroupBox>
#include <QLayout>
#include <QPushButton>
#include <QCheckBox>
#include <QLineEdit>
#include <QFileDialog>
#include <QDialogButtonBox>
//.._OptionsDialog类实现
/* 构造函数实现 */
_OptionsDialog::_OptionsDialog(QWidget *_Parent)
: QDialog(_Parent, Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint),
mb_IsChanged(false)
{
m_TabWidgetOnDialog = new QTabWidget;
_CreateCommonOptionPage();
_CreateNoteOptionsPage();
m_ButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok
| QDialogButtonBox::Cancel);
m_ButtonBox->button(QDialogButtonBox::Ok)->setText("好的");
m_ButtonBox->button(QDialogButtonBox::Cancel)->setText("离开");
connect(m_ButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(m_ButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
QVBoxLayout* _MainLayout = new QVBoxLayout;
_MainLayout->addWidget(m_TabWidgetOnDialog);
_MainLayout->addWidget(m_ButtonBox);
setLayout(_MainLayout);
setFont(wxNote::g_StandardFont);
setFixedSize(QSize(430, 380));
setWindowTitle(tr("选项"));
}
/////////////////////////////////////////////////////////////////////////
//..protected部分
/* _CreateCommonOptionPage()函数实现 */
void _OptionsDialog::_CreateCommonOptionPage()
{
using namespace wxNote;
g_Settings.beginGroup("TextEditor");
QString _LocalFilePath = g_Settings.value("LocalFilePath").toString();
g_Settings.endGroup();
m_LocalFilePathLineEdit = new QLineEdit;
m_LocalFilePathLineEdit->setReadOnly(true);
m_LocalFilePathLineEdit->setText(_LocalFilePath.isEmpty() ? QDir::homePath() + tr("/wxNote_USER")
: _LocalFilePath);
m_ChangePathPushButton = new QPushButton(tr("更改(&A)..."));
connect(m_ChangePathPushButton, SIGNAL(clicked()),
this, SLOT(_ChangeLocalFilePathSlot()));
m_EditLocalFilePathLayout = new QHBoxLayout;
m_EditLocalFilePathLayout->addWidget(m_LocalFilePathLineEdit);
m_EditLocalFilePathLayout->addWidget(m_ChangePathPushButton);
m_LocalFileLayout = new QVBoxLayout;
m_LocalFileLayout->addLayout(m_EditLocalFilePathLayout);
m_LocalFileLayout->addStretch();
m_LocalFileGroupBox = new QGroupBox(tr("wxNote 本地文件"));
m_LocalFileGroupBox->setLayout(m_LocalFileLayout);
QVBoxLayout* _MainLayout = new QVBoxLayout;
_MainLayout->addWidget(m_LocalFileGroupBox);
m_CommonOptionPage = new QWidget;
m_CommonOptionPage->setLayout(_MainLayout);
m_TabWidgetOnDialog->addTab(m_CommonOptionPage, tr("通用"));
connect(m_LocalFilePathLineEdit, SIGNAL(textChanged(QString)),
this, SLOT(_SetCurrentSettingsChanged()));
}
/* _CNoreateteOptionsPage()函数实现 */
void _OptionsDialog::_CreateNoteOptionsPage()
{
using namespace wxNote;
m_NoteEditorFontLabel = new QLabel(tr("笔记编辑器字体(&N):"));
/////////////////////////////////////////////////////////////////////
/// 创建字体和字体大小选择框, 并读取用户设置
///
g_Settings.beginGroup("TextEditor");
QString _DefaultFontFamily
= g_Settings.value("DefaultFont", QString("微软雅黑")).toString();
int _DefaultFontSize = g_Settings.value("DefaultFontSize", 8).toInt();
g_Settings.endGroup();
m_FontComboBox = new _FontComboBox;
m_FontSizeComboBox = new _FontSizeComboBox;
m_FontSizeComboBox->setEditable(true);
m_FontSizeComboBox->setCurrentText(QString::number(_DefaultFontSize));
m_NoteEditorFontLabel->setBuddy(m_FontComboBox);
for (int _Index = _FontMinSize; _Index <= _FontMaxSize; _Index++)
m_FontSizeComboBox->addItem(QString::number(_Index), _Index);
m_FontComboBox->setCurrentFont(QFont(_DefaultFontFamily));
m_FontSizeComboBox->setCurrentText(QString::number(_DefaultFontSize));
/////////////////////////////////////////////////////////////////////
/* "字体设置"部分 */
m_ComboBoxLayout = new QHBoxLayout;
m_ComboBoxLayout->addWidget(m_FontComboBox);
m_ComboBoxLayout->addWidget(m_FontSizeComboBox);
m_ComboBoxLayout->addStretch();
m_FontLayout = new QVBoxLayout;
m_FontLayout->addWidget(m_NoteEditorFontLabel);
m_FontLayout->addLayout(m_ComboBoxLayout);
m_FontLayout->addStretch();
g_Settings.beginGroup("TextEditor");
bool _IsChecked = g_Settings.value("AcceptRichText", true).toBool();
g_Settings.endGroup();
m_AcceptRichTextCheckBox = new QCheckBox(tr("使用HTML存储笔记(&H)"));
m_AcceptRichTextCheckBox->setChecked(_IsChecked);
m_FontGroupBox = new QGroupBox;
m_FontGroupBox->setLayout(m_FontLayout);
/* 复选部分 */
m_AcceptGroupBox = new QGroupBox;
m_AcceptLayout = new QVBoxLayout;
m_AcceptLayout->addWidget(m_AcceptRichTextCheckBox);
m_AcceptLayout->addStretch();
m_AcceptGroupBox->setLayout(m_AcceptLayout);
QVBoxLayout* _MainLayout = new QVBoxLayout;
_MainLayout->addWidget(m_FontGroupBox);
_MainLayout->addWidget(m_AcceptGroupBox);
m_NoteOptionPage = new QWidget;
m_NoteOptionPage->setLayout(_MainLayout);
m_TabWidgetOnDialog->addTab(m_NoteOptionPage, tr("笔记"));
connect(m_AcceptRichTextCheckBox, SIGNAL(toggled(bool)),
this, SLOT(_SetCurrentSettingsChanged()));
}
/* _SetCurrentSettingsChanged()槽实现 */
void _OptionsDialog::_SetCurrentSettingsChanged()
{
mb_IsChanged = true;
}
/* _ChangeLocalFilePathSlot() */
void _OptionsDialog::_ChangeLocalFilePathSlot()
{
QStringList _DirSplit = wxNote::g_LocalFilePath.split('/');
_DirSplit.pop_back();
/* 取当前"本地文件夹"所在文件夹的path */
QString _Dir = (_DirSplit.count() > 1) ? _DirSplit.join('/')
: _DirSplit.at(0) + '/';
QString _NewPath =
QFileDialog::getExistingDirectory(this
, tr("浏览文件夹")
, _Dir);
if (!_NewPath.isEmpty())
{
m_LocalFilePathLineEdit->setText(_NewPath);
wxNote::g_LocalFilePath = _NewPath;
}
}
////////////////////////////////////////////////////////////////////////////
/***************************************************************************
** **
** _________ _______ **
** |___ ___| / ______ \ **
** | | _______ _______ _______ | / |_| **
** | | || || || || || || | | _ __ **
** | | || || || || || || | | |__ \ **
** | | || || || || || || | \_ _ __| | _ **
** |_| ||_____|| || || ||_____|| \________/ |_| **
** || **
** ||_____|| **
** **
***************************************************************************/
///:~