1 /*****************************************************************************
2 * settingsdialog.cpp - QStarDict, a StarDict clone written with using Qt *
3 * Copyright (C) 2008 Alexander Rodin *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License along *
16 * with this program; if not, write to the Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
18 *****************************************************************************/
20 #include "settingsdialog.h"
22 #include <QFileDialog>
25 SettingsDialog::SettingsDialog(StarDict *plugin, QWidget *parent)
31 reformatListsBox->setChecked(m_plugin->m_reformatLists);
32 expandAbbreviationsBox->setChecked(m_plugin->m_expandAbbreviations);
33 dictDirsList->addItems(m_plugin->m_dictDirs);
34 dictDirsList->setProperty("FingerScrollable", true);
36 connect(this, SIGNAL(accepted()), SLOT(apply()));
39 void SettingsDialog::on_addDictDirButton_clicked()
41 QString dirName = QFileDialog::getExistingDirectory(this, tr("Select dictionaries directory"));
42 if (! dirName.isEmpty())
44 dictDirsList->addItem(dirName);
48 void SettingsDialog::on_removeDictDirButton_clicked()
50 delete dictDirsList->takeItem(dictDirsList->currentRow());
53 void SettingsDialog::on_moveUpDictDirButton_clicked()
55 if (dictDirsList->currentRow() > 0)
57 dictDirsList->insertItem(dictDirsList->currentRow(),
58 dictDirsList->takeItem(dictDirsList->currentRow()));
59 dictDirsList->setCurrentRow(dictDirsList->currentRow() - 1);
63 void SettingsDialog::on_moveDownDictDirButton_clicked()
65 if (dictDirsList->currentRow() < dictDirsList->count() - 1)
66 dictDirsList->insertItem(dictDirsList->currentRow(),
67 dictDirsList->takeItem(dictDirsList->currentRow() + 1));
70 void SettingsDialog::apply()
72 m_plugin->m_reformatLists = reformatListsBox->isChecked();
73 m_plugin->m_expandAbbreviations = expandAbbreviationsBox->isChecked();
74 m_plugin->m_dictDirs.clear();
75 for (int i = 0; i < dictDirsList->count(); ++i)
76 m_plugin->m_dictDirs << dictDirsList->item(i)->text();
79 void SettingsDialog::closeEvent(QCloseEvent *event)
81 SettingsDialog::apply();
84 // vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab cindent textwidth=120 formatoptions=tc