Skip to content

Commit c075948

Browse files
committed
set current language
1 parent 11a34a5 commit c075948

File tree

6 files changed

+82
-39
lines changed

6 files changed

+82
-39
lines changed

settingsdialog.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include "util.h"
44
#include "configmanager.h"
55

6+
#include <QDebug>
7+
68
extern ConfigManager *g_config;
79

810
SettingsDialog::SettingsDialog(QWidget *parent) :
@@ -11,9 +13,16 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
1113
{
1214
ui->setupUi(this);
1315
ui->comboBox->addItem(tr("System"), "System");
16+
1417
foreach(const auto &lang, Util::availableLanguages()) {
1518
ui->comboBox->addItem(lang.second, lang.first);
1619
}
20+
21+
for(int i = 0; i < ui->comboBox->count(); ++i) {
22+
if(ui->comboBox->itemData(i).toString() == g_config->value("language")) {
23+
ui->comboBox->setCurrentIndex(i);
24+
}
25+
}
1726
}
1827

1928
SettingsDialog::~SettingsDialog()
@@ -26,7 +35,7 @@ void SettingsDialog::on_pushButton_clicked()
2635
close();
2736
}
2837

29-
void SettingsDialog::on_comboBox_currentIndexChanged(int)
38+
void SettingsDialog::on_comboBox_activated(int index)
3039
{
31-
g_config->setValue("language", ui->comboBox->currentData().toString());
40+
g_config->setValue("language", ui->comboBox->itemData(index).toString());
3241
}

settingsdialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class SettingsDialog : public QDialog
1818
private slots:
1919
void on_pushButton_clicked();
2020

21-
void on_comboBox_currentIndexChanged(int index);
21+
void on_comboBox_activated(int index);
2222

2323
private:
2424
Ui::SettingsDialog *ui;

settingsdialog.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
14-
<string>Dialog</string>
14+
<string>Settings</string>
1515
</property>
1616
<layout class="QVBoxLayout" name="verticalLayout">
1717
<item>

translations/DBLParse_zh_CN.qm

112 Bytes
Binary file not shown.

translations/DBLParse_zh_CN.ts

Lines changed: 68 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -68,93 +68,96 @@
6868
<translation>文件 (&amp;F)</translation>
6969
</message>
7070
<message>
71-
<location filename="../mainwindow.ui" line="54"/>
71+
<location filename="../mainwindow.ui" line="55"/>
7272
<source>&amp;View</source>
7373
<translation>查看 (&amp;V)</translation>
7474
</message>
7575
<message>
76-
<location filename="../mainwindow.ui" line="61"/>
76+
<location filename="../mainwindow.ui" line="62"/>
7777
<source>&amp;Tools</source>
7878
<translation>工具 (&amp;T)</translation>
7979
</message>
8080
<message>
81-
<location filename="../mainwindow.ui" line="74"/>
81+
<location filename="../mainwindow.ui" line="75"/>
8282
<source>About &amp;Qt</source>
8383
<translation>关于Qt (&amp;Q)</translation>
8484
</message>
8585
<message>
86-
<location filename="../mainwindow.ui" line="79"/>
86+
<location filename="../mainwindow.ui" line="80"/>
8787
<source>&amp;About DBLParse</source>
8888
<translation>关于DBLParse (&amp;A)</translation>
8989
</message>
9090
<message>
91-
<location filename="../mainwindow.ui" line="84"/>
91+
<location filename="../mainwindow.ui" line="85"/>
9292
<source>About &amp;DBLP</source>
9393
<translation>关于DBLP (&amp;D)</translation>
9494
</message>
9595
<message>
96-
<location filename="../mainwindow.ui" line="89"/>
96+
<location filename="../mainwindow.ui" line="90"/>
9797
<source>E&amp;xit</source>
9898
<translation>退出 (&amp;X)</translation>
9999
</message>
100100
<message>
101-
<location filename="../mainwindow.ui" line="94"/>
101+
<location filename="../mainwindow.ui" line="95"/>
102102
<source>&amp;Open</source>
103103
<translation>打开 (&amp;O)</translation>
104104
</message>
105105
<message>
106-
<location filename="../mainwindow.ui" line="99"/>
106+
<location filename="../mainwindow.ui" line="100"/>
107107
<source>&amp;Status</source>
108108
<translation>状态 (&amp;S)</translation>
109109
</message>
110110
<message>
111-
<location filename="../mainwindow.ui" line="104"/>
111+
<location filename="../mainwindow.ui" line="105"/>
112112
<source>&amp;Clear Index</source>
113113
<translation>清除索引 (&amp;C)</translation>
114114
</message>
115115
<message>
116-
<location filename="../mainwindow.ui" line="109"/>
116+
<location filename="../mainwindow.ui" line="110"/>
117117
<source>&amp;Open Index Folder</source>
118118
<translation>打开索引文件夹 (&amp;O)</translation>
119119
</message>
120120
<message>
121-
<location filename="../mainwindow.ui" line="114"/>
121+
<location filename="../mainwindow.ui" line="115"/>
122122
<source>AuthorStac</source>
123123
<translation>作者统计</translation>
124124
</message>
125125
<message>
126-
<location filename="../mainwindow.ui" line="119"/>
126+
<location filename="../mainwindow.ui" line="120"/>
127127
<source>View &amp;Log</source>
128128
<translation>查看日志 (&amp;L)</translation>
129129
</message>
130130
<message>
131-
<location filename="../mainwindow.cpp" line="43"/>
131+
<location filename="../mainwindow.ui" line="125"/>
132+
<source>&amp;Settings</source>
133+
<translation>设置 (&amp;S)</translation>
134+
</message>
135+
<message>
136+
<location filename="../mainwindow.cpp" line="47"/>
132137
<source>Load finished.</source>
133138
<translation>加载完成。</translation>
134139
</message>
135140
<message>
136-
<location filename="../mainwindow.cpp" line="68"/>
141+
<location filename="../mainwindow.cpp" line="72"/>
137142
<source>About Qt</source>
138143
<translation>关于Qt</translation>
139144
</message>
140145
<message>
141-
<location filename="../mainwindow.cpp" line="73"/>
146+
<location filename="../mainwindow.cpp" line="77"/>
142147
<source>DBLParse&lt;br/&gt;&lt;br/&gt;
143148
DBLParse is an application that bases on dblp computer science bibliography.&lt;br/&gt;&lt;br/&gt;
144149
Please visit &lt;a href=&quot;https://github.com/tootal/DBLParse&quot;&gt;DBLParse&lt;/a&gt; for more information.</source>
145-
<translation>DBLP&lt;br/&gt;&lt;br/&gt;
146-
&lt;em&gt;DBLP&lt;/em&gt; 计算机科学文献集提供主要的计算机科学期刊和会议的开放数据信息。
147-
最初由&lt;a href=&quot;https://www.uni-trier.de/&quot;&gt;特里尔大学&lt;/a&gt; 在1993年创建,
148-
DBLP数据集现在由&lt;a href=&quot;https://www.dagstuhl.de/&quot;&gt;Schloss Dagstuhl&lt;/a&gt;维护。&lt;br/&gt;&lt;br/&gt;
149-
获取更多信息,请&lt;a href=&quot;https://dblp.uni-trier.de/faq/&quot;&gt;查看F.A.Q.&lt;/a&gt;。</translation>
150+
<translation>DBLParse&lt;br/&gt;&lt;br/&gt;
151+
DBLParse 是一个基于DBLP数据的应用。
152+
请访问&lt;a href=&quot;https://github.com/tootal/DBLParse&quot;&gt;DBLParse&lt;/a&gt;获取更多信息。</translation>
150153
</message>
151154
<message>
152-
<location filename="../mainwindow.cpp" line="76"/>
155+
<location filename="../mainwindow.cpp" line="80"/>
153156
<source>About DBLParse</source>
154157
<translation>关于DBLParse</translation>
155158
</message>
156159
<message>
157-
<location filename="../mainwindow.cpp" line="81"/>
160+
<location filename="../mainwindow.cpp" line="85"/>
158161
<source>DBLP&lt;br/&gt;&lt;br/&gt;
159162
The &lt;em&gt;dblp computer science bibliography&lt;/em&gt; provides
160163
open bibliographic information on major computer science journals and proceedings.
@@ -168,47 +171,47 @@ DBLP数据集现在由&lt;a href=&quot;https://www.dagstuhl.de/&quot;&gt;Schloss
168171
获取更多信息,请&lt;a href=&quot;https://dblp.uni-trier.de/faq/&quot;&gt;查看F.A.Q.&lt;/a&gt;</translation>
169172
</message>
170173
<message>
171-
<location filename="../mainwindow.cpp" line="87"/>
174+
<location filename="../mainwindow.cpp" line="91"/>
172175
<source>About DBLP</source>
173176
<translation>关于DBLP</translation>
174177
</message>
175178
<message>
176-
<location filename="../mainwindow.cpp" line="106"/>
179+
<location filename="../mainwindow.cpp" line="103"/>
177180
<source>Select XML file</source>
178181
<translation>选择XML文件</translation>
179182
</message>
180183
<message>
181-
<location filename="../mainwindow.cpp" line="108"/>
184+
<location filename="../mainwindow.cpp" line="105"/>
182185
<source>XML file (*.xml)</source>
183186
<translation>XML文件 (*.xml)</translation>
184187
</message>
185188
<message>
186-
<location filename="../mainwindow.cpp" line="115"/>
189+
<location filename="../mainwindow.cpp" line="112"/>
187190
<source>Parsing the file will last for a while and will take up a lot of memory.</source>
188191
<translation>解析文件将消耗大量内存并持续一段时间。</translation>
189192
</message>
190193
<message>
191-
<location filename="../mainwindow.cpp" line="116"/>
194+
<location filename="../mainwindow.cpp" line="113"/>
192195
<source>Do you want to continue?</source>
193196
<translation>是否要继续?</translation>
194197
</message>
195198
<message>
196-
<location filename="../mainwindow.cpp" line="148"/>
199+
<location filename="../mainwindow.cpp" line="145"/>
197200
<source>Parser: %1 &lt;br&gt;Loader: %2</source>
198201
<translation>解析器: %1 &lt;br&gt;加载器:%2</translation>
199202
</message>
200203
<message>
201-
<location filename="../mainwindow.cpp" line="155"/>
204+
<location filename="../mainwindow.cpp" line="152"/>
202205
<source>Open XML file</source>
203206
<translation>打开XML文件</translation>
204207
</message>
205208
<message>
206-
<location filename="../mainwindow.cpp" line="156"/>
209+
<location filename="../mainwindow.cpp" line="153"/>
207210
<source>Cancel</source>
208211
<translation>取消</translation>
209212
</message>
210213
<message>
211-
<location filename="../mainwindow.cpp" line="169"/>
214+
<location filename="../mainwindow.cpp" line="166"/>
212215
<source>Clear index file successful!</source>
213216
<translation>成功清除缓存文件!</translation>
214217
</message>
@@ -259,13 +262,46 @@ DBLP数据集现在由&lt;a href=&quot;https://www.dagstuhl.de/&quot;&gt;Schloss
259262
<translation>解析完成。用时:%1</translation>
260263
</message>
261264
</context>
265+
<context>
266+
<name>SettingsDialog</name>
267+
<message>
268+
<location filename="../settingsdialog.ui" line="14"/>
269+
<source>Settings</source>
270+
<translation>设置</translation>
271+
</message>
272+
<message>
273+
<location filename="../settingsdialog.ui" line="22"/>
274+
<source>Language: </source>
275+
<translation>语言: </translation>
276+
</message>
277+
<message>
278+
<location filename="../settingsdialog.ui" line="62"/>
279+
<source>OK</source>
280+
<translation>完成</translation>
281+
</message>
282+
<message>
283+
<location filename="../settingsdialog.cpp" line="13"/>
284+
<source>System</source>
285+
<translation>系统</translation>
286+
</message>
287+
</context>
262288
<context>
263289
<name>Util</name>
264290
<message>
265-
<location filename="../util.cpp" line="16"/>
291+
<location filename="../util.cpp" line="21"/>
266292
<source>s</source>
267293
<translation>秒</translation>
268294
</message>
295+
<message>
296+
<location filename="../util.cpp" line="98"/>
297+
<source>English (United States)</source>
298+
<translation>英语 (美国)</translation>
299+
</message>
300+
<message>
301+
<location filename="../util.cpp" line="99"/>
302+
<source>Chinese (China)</source>
303+
<translation>中文 (中国)</translation>
304+
</message>
269305
</context>
270306
<context>
271307
<name>WebView</name>

util.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ QString Util::readFile(const QString &fileName)
7777

7878
QString Util::getXmlFileName()
7979
{
80-
QSettings settings;
81-
Q_ASSERT(settings.contains("lastOpenFileName"));
82-
return settings.value("lastOpenFileName").toString();
80+
return g_config->value("lastOpenFileName");
8381
}
8482

8583
QString Util::formatUrl(const QString &url)

0 commit comments

Comments
 (0)