OSDN Git Service

Ver0.11
[gefu/Gefu.git] / preferencedialog.cpp
1 #include "colorsamplemodel.h"
2 #include"common.h"
3 #include "preferencedialog.h"
4 #include "ui_preferencedialog.h"
5
6 #include <QAbstractTableModel>
7 #include <QColorDialog>
8 #include <QSettings>
9 #include <QDebug>
10 #include <QDir>
11 #include <QFileDialog>
12 #include <QStandardPaths>
13 #include <QFontDialog>
14
15 PreferenceDialog::PreferenceDialog(QWidget *parent) :
16     QDialog(parent),
17     ui(new Ui::PreferenceDialog),
18     m_model(),
19     m_colorMap()
20 {
21     m_model.setColorMap(&m_colorMap);
22
23     ui->setupUi(this);
24     ui->tabWidget->setCurrentIndex(0);
25     // アドレスボックスの外観サンプル
26     ui->sampleEdit->setText(QDir::homePath());
27     // ファイルビューの外観サンプル
28     ui->sampleTable->setModel(&m_model);
29
30     QHeaderView *header;
31     header = ui->sampleTable->horizontalHeader();
32     header->setSectionResizeMode(0, QHeaderView::Stretch);
33     header->setSectionResizeMode(1, QHeaderView::ResizeToContents);
34     header->setSectionResizeMode(2, QHeaderView::ResizeToContents);
35     header = ui->sampleTable->verticalHeader();
36     header->setDefaultSectionSize(header->defaultSectionSize() * 0.75);
37
38     // シグナル&スロット
39     connect(ui->bootSize, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool)));
40     connect(ui->sizeAbsolute, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool)));
41     connect(ui->sizeRelative, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool)));
42     connect(ui->bootPos, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool)));
43     connect(ui->posAbsolute, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool)));
44     connect(ui->posRelative, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool)));
45
46     connect(ui->boxClrBg, SIGNAL(clicked()), this, SLOT(selectBoxColor()));
47     connect(ui->boxClrFg, SIGNAL(clicked()), this, SLOT(selectBoxColor()));
48
49     connect(ui->clrBgMark, SIGNAL(clicked()), this, SLOT(selectViewColor()));
50     connect(ui->clrBgNormal, SIGNAL(clicked()), this, SLOT(selectViewColor()));
51     connect(ui->clrFgHidden, SIGNAL(clicked()), this, SLOT(selectViewColor()));
52     connect(ui->clrFgMark, SIGNAL(clicked()), this, SLOT(selectViewColor()));
53     connect(ui->clrFgNormal, SIGNAL(clicked()), this, SLOT(selectViewColor()));
54     connect(ui->clrFgReadonly, SIGNAL(clicked()), this, SLOT(selectViewColor()));
55     connect(ui->clrFgSystem, SIGNAL(clicked()), this, SLOT(selectViewColor()));
56
57     connect(ui->chooseBoxFont, SIGNAL(clicked()), this, SLOT(chooseFont()));
58     connect(ui->chooseViewFont, SIGNAL(clicked()), this, SLOT(chooseFont()));
59
60     connect(ui->importAppearance, SIGNAL(clicked()), this, SLOT(importAppearance()));
61     connect(ui->exportAppearance, SIGNAL(clicked()), this, SLOT(exportAppearance()));
62     connect(ui->termBrowse, SIGNAL(clicked()), this, SLOT(browseApp()));
63     connect(ui->editorBrowse, SIGNAL(clicked()), this, SLOT(browseApp()));
64
65     connect(ui->chooseViewerFont, SIGNAL(clicked()), this, SLOT(chooseFont()));
66     connect(ui->viewerClrBg, SIGNAL(clicked()), this, SLOT(selectViewerColor()));
67     connect(ui->viewerClrFg, SIGNAL(clicked()), this, SLOT(selectViewerColor()));
68     connect(ui->viewerInherit, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool)));
69     connect(ui->enableViewerIgnoreExt, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool)));
70     connect(ui->defaultIgnoreExt, SIGNAL(clicked()), this, SLOT(setIgnoreExtDefault()));
71
72     // 現在の設定で各コントロールを初期化する
73     QSettings settings;
74     QString strValue;
75     QSize size;
76     QPoint point;
77     QRadioButton *radioBtn;
78
79     //>>>>> 起動と終了
80     // 終了時の確認ダイアログ
81     ui->confirmExit->setChecked(settings.value(IniKey_ConfirmExit).toBool());
82     // 起動時のサイズ
83     ui->bootSize->setChecked(true);
84     strValue = settings.value(IniKey_BootSizeSpec).toString();
85     radioBtn = findChild<QRadioButton*>(strValue);
86     if (radioBtn == NULL) {
87         radioBtn = ui->sizeRelative;
88     }
89     radioBtn->setChecked(true);
90     if (strValue.isEmpty()) {
91         ui->bootSize->setChecked(false);
92     }
93     size = settings.value(IniKey_BootSizeAbs).toSize();
94     ui->absoluteWidth->setValue(size.width());
95     ui->absoluteHeight->setValue(size.height());
96     size = settings.value(IniKey_BootSizeRel).toSize();
97     ui->relativeWidth->setValue(size.width());
98     ui->relativeHeight->setValue(size.height());
99     // 起動時の位置
100     ui->bootPos->setChecked(true);
101     strValue = settings.value(IniKey_BootPosSpec).toString();
102     radioBtn = findChild<QRadioButton*>(strValue);
103     if (radioBtn == NULL) {
104         radioBtn = ui->posCenter;
105     }
106     radioBtn->setChecked(true);
107     if (strValue.isEmpty()) {
108         ui->bootPos->setChecked(false);
109     }
110     point = settings.value(IniKey_BootPosAbs).toPoint();
111     ui->absoluteLeft->setValue(point.x());
112     ui->absoluteTop->setValue(point.y());
113     point = settings.value(IniKey_BootPosRel).toPoint();
114     ui->relativeLeft->setValue(point.x());
115     ui->relativeTop->setValue(point.y());
116     // 起動時の設定削除
117     ui->resetOnBoot->setChecked(settings.value(IniKey_ResetOnBoot).toBool());
118
119     //>>>>> 色とフォント、テキストビューア
120     loadAppearance(settings, false);
121
122     //>>>>> ファイル操作
123     // 確認ダイアログの表示
124     ui->confirmCopy->setChecked(settings.value(IniKey_ConfirmCopy).toBool());
125     ui->confirmDelete->setChecked(settings.value(IniKey_ConfirmDelete).toBool());
126     ui->confirmMove->setChecked(settings.value(IniKey_ConfirmMove).toBool());
127     ui->confirmRename->setChecked(settings.value(IniKey_ConfirmRename).toBool());
128     // 完了ダイアログの自動クローズ
129     ui->autoCloseCopy->setChecked(settings.value(IniKey_AutoCloseCopy).toBool());
130     ui->autoCloseDelete->setChecked(settings.value(IniKey_AutoCloseDelete).toBool());
131     ui->autoCloseMove->setChecked(settings.value(IniKey_AutoCloseMove).toBool());
132     ui->autoCloseRename->setChecked(settings.value(IniKey_AutoCloseRename).toBool());
133     // 上書き時の既定動作
134     strValue = settings.value(IniKey_DefaultOnCopy).toString();
135     if (strValue.isEmpty()) {
136         strValue = "owDefIfNew";
137     }
138     radioBtn = findChild<QRadioButton*>(strValue);
139     if (radioBtn == NULL) {
140         radioBtn = ui->rbOverWriteIfNew;
141     }
142     radioBtn->setChecked(true);
143     ui->moveAfterCreate->setChecked(settings.value(IniKey_MoveAfterCreateFolder).toBool());
144     ui->openAfterCreate->setChecked(settings.value(IniKey_OpenAfterCreateFile).toBool());
145
146     //>>>>> パス設定
147     // エディタ
148     ui->editorOpt->setText(settings.value(IniKey_EditorOption).toString());
149     ui->editorPath->setText(settings.value(IniKey_EditorPath).toString());
150     // ターミナル
151     ui->termOpt->setText(settings.value(IniKey_TerminalOption).toString());
152     ui->termPath->setText(settings.value(IniKey_TerminalPath).toString());
153
154     //>>>>> テキストビューア
155     ui->enableViewerIgnoreExt->setChecked(true);
156     ui->enableViewerIgnoreExt->setChecked(!settings.value(IniKey_ViewerForceOpen).toBool());
157     ui->viewerIgnoreExt->setPlainText(settings.value(IniKey_ViewerIgnoreExt).toString());
158 }
159
160 PreferenceDialog::~PreferenceDialog()
161 {
162     delete ui;
163 }
164
165 void PreferenceDialog::saveAppearance(QSettings &settings)
166 {
167     QFont font = ui->sampleEdit->font();
168     QPalette palette = ui->sampleEdit->palette();
169     settings.setValue(IniKey_BoxColorBg, palette.base().color());
170     settings.setValue(IniKey_BoxColorFg, palette.text().color());
171     settings.setValue(IniKey_BoxFont, font);
172
173     settings.setValue(IniKey_ViewColorBgMark, m_colorMap["clrBgMark"]);
174     settings.setValue(IniKey_ViewColorBgNormal, m_colorMap["clrBgNormal"]);
175     settings.setValue(IniKey_ViewColorFgHidden, m_colorMap["clrFgHidden"]);
176     settings.setValue(IniKey_ViewColorFgMark, m_colorMap["clrFgMark"]);
177     settings.setValue(IniKey_ViewColorFgNormal, m_colorMap["clrFgNormal"]);
178     settings.setValue(IniKey_ViewColorFgReadonly, m_colorMap["clrFgReadonly"]);
179     settings.setValue(IniKey_ViewColorFgSystem, m_colorMap["clrFgSystem"]);
180     settings.setValue(IniKey_ViewFont, m_model.font());
181 }
182
183 void PreferenceDialog::loadAppearance(QSettings &settings, bool import)
184 {
185     QPalette palette;
186     QColor color;
187     QFont font;
188
189     //>>>> アドレスボックス
190     palette = QPalette();
191     // 背景色
192     color = settings.value(IniKey_BoxColorBg).value<QColor>();
193     palette.setColor(QPalette::Base, color);
194     // 文字色
195     color = settings.value(IniKey_BoxColorFg).value<QColor>();
196     palette.setColor(QPalette::Text, color);
197     // フォント
198     font = settings.value(IniKey_BoxFont).value<QFont>();
199     ui->boxFont->setText(tr("%1, %2pt").arg(font.family()).arg(font.pointSize()));
200     // サンプル表示
201     ui->sampleEdit->setPalette(palette);
202     ui->sampleEdit->setFont(font);
203
204     //>>>> ファイルビュー
205     // 背景色
206     color = settings.value(IniKey_ViewColorBgMark).value<QColor>();
207     m_colorMap["clrBgMark"] = color;
208     color = settings.value(IniKey_ViewColorBgNormal).value<QColor>();
209     m_colorMap["clrBgNormal"] = color;
210     // 文字色
211     color = settings.value(IniKey_ViewColorFgHidden).value<QColor>();
212     m_colorMap["clrFgHidden"] = color;
213     color = settings.value(IniKey_ViewColorFgMark).value<QColor>();
214     m_colorMap["clrFgMark"] = color;
215     color = settings.value(IniKey_ViewColorFgNormal).value<QColor>();
216     m_colorMap["clrFgNormal"] = color;
217     color = settings.value(IniKey_ViewColorFgReadonly).value<QColor>();
218     m_colorMap["clrFgReadonly"] = color;
219     color = settings.value(IniKey_ViewColorFgSystem).value<QColor>();
220     m_colorMap["clrFgSystem"] = color;
221     // フォント
222     font = settings.value(IniKey_ViewFont).value<QFont>();
223     ui->viewFont->setText(tr("%1, %2pt").arg(font.family()).arg(font.pointSize()));
224     // サンプル表示
225     m_model.setFont(font);
226     m_model.update();
227
228     //>>>> テキストビューア
229     // 文字色と背景色
230     if (settings.value(IniKey_ViewerInherit).toBool()) {
231         ui->viewerInherit->setChecked(true);
232         color = settings.value(IniKey_ViewColorBgNormal).value<QColor>();
233         palette.setColor(QPalette::Base, color);
234         color = settings.value(IniKey_ViewColorFgNormal).value<QColor>();
235         palette.setColor(QPalette::Text, color);
236     }
237     else if (!import){
238         ui->viewerInherit->setChecked(false);
239         color = settings.value(IniKey_ViewerColorBg).value<QColor>();
240         palette.setColor(QPalette::Base, color);
241         color = settings.value(IniKey_ViewerColorFg).value<QColor>();
242         palette.setColor(QPalette::Text, color);
243     }
244     ui->viewerSample->setPalette(palette);
245     // フォント
246     if (!import) {
247         font = settings.value(IniKey_ViewerFont).value<QFont>();
248         ui->viewerFont->setText(tr("%1, %2pt").arg(font.family()).arg(font.pointSize()));
249         ui->viewerSample->setFont(font);
250     }
251 }
252
253 void PreferenceDialog::chooseFont()
254 {
255     bool ok;
256     QFont font;
257     QLabel *label = NULL;
258
259     if (sender() == ui->chooseViewerFont) {
260         font = ui->viewerSample->font();
261     }
262     else if (sender() == ui->chooseBoxFont) {
263         font = ui->sampleEdit->font();
264     }
265     else if (sender() == ui->chooseViewFont) {
266         font = m_model.font();
267     }
268
269     font = QFontDialog::getFont(&ok, font, this);
270
271     if (sender() == ui->chooseViewerFont) {
272         ui->viewerSample->setFont(font);
273         label = ui->viewerFont;
274     }
275     else if (sender() == ui->chooseBoxFont) {
276         ui->sampleEdit->setFont(font);
277         label = ui->boxFont;
278     }
279     else if (sender() == ui->chooseViewFont) {
280         m_model.setFont(font);
281         m_model.update();
282         label = ui->viewFont;
283     }
284     label->setText(tr("%1, %2pt").arg(font.family()).arg(font.pointSize()));
285
286 }
287
288 void PreferenceDialog::setControlsEnabled(bool enabled)
289 {
290     if (sender() == ui->bootSize) {
291         ui->sizeAbsolute->setEnabled(enabled);
292         ui->sizeLast->setEnabled(enabled);
293         ui->sizeRelative->setEnabled(enabled);
294         if (enabled) {
295             emit ui->sizeAbsolute->toggled(ui->sizeAbsolute->isChecked());
296             emit ui->sizeRelative->toggled(ui->sizeRelative->isChecked());
297         }
298         else {
299             emit ui->sizeAbsolute->toggled(false);
300             emit ui->sizeRelative->toggled(false);
301         }
302     }
303     else if (sender() == ui->sizeAbsolute) {
304         ui->absoluteHeight->setEnabled(enabled);
305         ui->absoluteWidth->setEnabled(enabled);
306     }
307     else if (sender() == ui->sizeRelative) {
308         ui->relativeHeight->setEnabled(enabled);
309         ui->relativeWidth->setEnabled(enabled);
310     }
311     else if (sender() == ui->bootPos) {
312         ui->posAbsolute->setEnabled(enabled);
313         ui->posCenter->setEnabled(enabled);
314         ui->posLast->setEnabled(enabled);
315         ui->posRelative->setEnabled(enabled);
316         if (enabled) {
317             emit ui->posAbsolute->toggled(ui->posAbsolute->isChecked());
318             emit ui->posRelative->toggled(ui->posRelative->isChecked());
319         }
320         else {
321             emit ui->posAbsolute->toggled(false);
322             emit ui->posRelative->toggled(false);
323         }
324     }
325     else if (sender() == ui->posAbsolute) {
326         ui->absoluteLeft->setEnabled(enabled);
327         ui->absoluteTop->setEnabled(enabled);
328     }
329     else if (sender() == ui->posRelative) {
330         ui->relativeLeft->setEnabled(enabled);
331         ui->relativeTop->setEnabled(enabled);
332     }
333     else if (sender() == ui->viewerInherit) {
334         ui->viewerClrBg->setEnabled(!enabled);
335         ui->viewerClrFg->setEnabled(!enabled);
336     }
337     else if (sender() == ui->enableViewerIgnoreExt) {
338         ui->viewerIgnoreExt->setEnabled(enabled);
339     }
340 }
341
342 void PreferenceDialog::setIgnoreExtDefault()
343 {
344     ui->viewerIgnoreExt->setPlainText(ViewerIgnoreExt());
345 }
346
347 void PreferenceDialog::selectBoxColor()
348 {
349     QColor color;
350     QPalette palette = ui->sampleEdit->palette();
351     if (sender() == ui->boxClrBg) {
352         color = palette.background().color();
353     }
354     else if (sender() == ui->boxClrFg) {
355         color = palette.text().color();
356     }
357
358     color = QColorDialog::getColor(color, this, tr("色選択"));
359     if (!color.isValid()) {
360         return;
361     }
362
363     if (sender() == ui->boxClrBg) {
364         palette.setColor(QPalette::Base, color);
365     }
366     else if (sender() == ui->boxClrFg) {
367         palette.setColor(QPalette::Text, color);
368     }
369     ui->sampleEdit->setPalette(palette);
370 }
371
372 void PreferenceDialog::selectViewColor()
373 {
374     const QString objName = sender()->objectName();
375     QColor color = m_colorMap[objName];
376
377     color = QColorDialog::getColor(color, this, tr("色選択"));
378     if (!color.isValid()) {
379         return;
380     }
381
382     m_colorMap[objName] = color;
383     m_model.update();
384 }
385
386 void PreferenceDialog::selectViewerColor()
387 {
388     QColor color;
389     QPalette palette = ui->viewerSample->palette();
390     if (sender() == ui->viewerClrBg) {
391         color = palette.background().color();
392     }
393     else if (sender() == ui->viewerClrFg) {
394         color = palette.text().color();
395     }
396
397     color = QColorDialog::getColor(color, this, tr("色選択"));
398     if (!color.isValid()) {
399         return;
400     }
401
402     if (sender() == ui->viewerClrBg) {
403         palette.setColor(QPalette::Base, color);
404     }
405     else if (sender() == ui->viewerClrFg) {
406         palette.setColor(QPalette::Text, color);
407     }
408     ui->viewerSample->setPalette(palette);
409 }
410
411 void PreferenceDialog::browseApp()
412 {
413     QStringList list = QStandardPaths::standardLocations(
414                 QStandardPaths::ApplicationsLocation);
415 #ifdef Q_OS_WIN
416     QString path = QFileDialog::getOpenFileName(
417                 this, tr("アプリケーションを選択"), list.at(0),
418                 tr("実行ファイル (*.exe *.com *.bat *.pif);;すべてのファイル (*)"));
419 #elif defined(Q_OS_MAC)
420     QString path = QFileDialog::getOpenFileName(
421                 this, tr("アプリケーションを選択"), list.at(0),
422                 tr("実行ファイル (*.app);;すべてのファイル (*)"));
423 #else
424     QString path = QFileDialog::getOpenFileName(
425                 this, tr("アプリケーションを選択"), list.at(0),
426                 tr("すべてのファイル (*)"));
427 #endif
428     if (!path.isEmpty()) {
429         if (sender() == ui->editorBrowse) {
430             ui->editorPath->setText(path);
431         }
432         else if (sender() == ui->termBrowse) {
433             ui->termPath->setText(path);
434         }
435     }
436 }
437
438 void PreferenceDialog::importAppearance()
439 {
440     QStringList list = QStandardPaths::standardLocations(
441                 QStandardPaths::DocumentsLocation);
442     QString path = QFileDialog::getOpenFileName(
443                 this, tr("ファイルを選択"), list.at(0),
444                 tr("設定ファイル (*.ini);;すべてのファイル (*)"));
445     if (path.isEmpty()) {
446         return;
447     }
448
449     QSettings settings(path, QSettings::IniFormat);
450     loadAppearance(settings, true);
451 }
452
453 void PreferenceDialog::exportAppearance()
454 {
455     QStringList list = QStandardPaths::standardLocations(
456                 QStandardPaths::DocumentsLocation);
457     QString path = QFileDialog::getSaveFileName(
458                 this, tr("ファイルを選択"), list.at(0) + "/gefu_appearance.ini",
459                 tr("設定ファイル (*.ini);;すべてのファイル (*)"));
460     if (path.isEmpty()) {
461         return;
462     }
463
464     QSettings settings(path, QSettings::IniFormat);
465     saveAppearance(settings);
466 }
467
468 void PreferenceDialog::accept()
469 {
470     QSettings settings;
471     QAbstractButton *selected;
472
473     //>>>>> 起動と終了
474     // 終了時の確認ダイアログ
475     settings.setValue(IniKey_ConfirmExit, ui->confirmExit->isChecked());
476     // 起動時のサイズ
477     if (!ui->bootSize->isChecked()) {
478         settings.setValue(IniKey_BootSizeSpec, "");
479     }
480     else {
481         selected = ui->sizeOptions->checkedButton();
482         settings.setValue(IniKey_BootSizeSpec, selected->objectName());
483         QSize size;
484         // 絶対指定
485         size = QSize(ui->absoluteWidth->value(), ui->absoluteHeight->value());
486         settings.setValue(IniKey_BootSizeAbs, size);
487         // 相対指定
488         size = QSize(ui->relativeWidth->value(), ui->relativeHeight->value());
489         settings.setValue(IniKey_BootSizeRel, size);
490     }
491     // 起動時の位置
492     if (!ui->bootPos->isChecked()) {
493         settings.setValue(IniKey_BootPosSpec, "");
494     }
495     else {
496         selected = ui->posOptions->checkedButton();
497         settings.setValue(IniKey_BootPosSpec, selected->objectName());
498         // 絶対指定
499         QPoint pos;
500         pos = QPoint(ui->absoluteLeft->value(), ui->absoluteTop->value());
501         settings.setValue(IniKey_BootPosAbs, pos);
502         // 相対指定
503         pos = QPoint(ui->relativeLeft->value(), ui->relativeTop->value());
504         settings.setValue(IniKey_BootPosRel, pos);
505     }
506     // 起動時の設定削除
507     settings.setValue(IniKey_ResetOnBoot, ui->resetOnBoot->isChecked());
508
509     //>>>>> 色とフォント
510     saveAppearance(settings);
511
512     //>>>>> ファイル操作
513     settings.setValue(IniKey_ConfirmCopy, ui->confirmCopy->isChecked());
514     settings.setValue(IniKey_ConfirmDelete, ui->confirmDelete->isChecked());
515     settings.setValue(IniKey_ConfirmMove, ui->confirmMove->isChecked());
516     settings.setValue(IniKey_ConfirmRename, ui->confirmRename->isChecked());
517
518     settings.setValue(IniKey_AutoCloseCopy, ui->autoCloseCopy->isChecked());
519     settings.setValue(IniKey_AutoCloseDelete, ui->autoCloseDelete->isChecked());
520     settings.setValue(IniKey_AutoCloseMove, ui->autoCloseMove->isChecked());
521     settings.setValue(IniKey_AutoCloseRename, ui->autoCloseRename->isChecked());
522
523     selected = ui->overwriteOptions->checkedButton();
524     settings.setValue(IniKey_DefaultOnCopy, selected->objectName());
525
526     settings.setValue(IniKey_MoveAfterCreateFolder, ui->moveAfterCreate->isChecked());
527     settings.setValue(IniKey_OpenAfterCreateFile, ui->openAfterCreate->isChecked());
528
529     //>>>>> パス設定
530     settings.setValue(IniKey_EditorOption, ui->editorOpt->text().trimmed());
531     settings.setValue(IniKey_EditorPath, ui->editorPath->text().trimmed());
532
533     settings.setValue(IniKey_TerminalOption, ui->termOpt->text().trimmed());
534     settings.setValue(IniKey_TerminalPath, ui->termPath->text().trimmed());
535
536     //>>>>> テキストビューア
537     settings.setValue(IniKey_ViewerFont, ui->viewerSample->font());
538     settings.setValue(IniKey_ViewerColorBg, ui->viewerSample->palette().base().color());
539     settings.setValue(IniKey_ViewerColorFg, ui->viewerSample->palette().text().color());
540     settings.setValue(IniKey_ViewerInherit, ui->viewerInherit->isChecked());
541     settings.setValue(IniKey_ViewerForceOpen, !ui->enableViewerIgnoreExt->isChecked());
542     QStringList list = ui->viewerIgnoreExt->toPlainText().split(",", QString::SkipEmptyParts);
543     QStringList::iterator it;
544     for (it = list.begin(); it != list.end(); it++) {
545         *it = it->trimmed();
546     }
547     settings.setValue(IniKey_ViewerIgnoreExt, list.join(","));
548
549     QDialog::accept();
550 }