2 * Copyright (C) 2011 Toni Gundogdu <legatvs@gmail.com>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <QCoreApplication>
21 #include <QDialogButtonBox>
22 #include <QMessageBox>
23 #include <QVBoxLayout>
26 #include <NSettingsMutator>
27 #include <NSettingsDialog>
30 extern nn::NSettingsMutator settings
; // main.cpp
35 NSettingsDialog::NSettingsDialog(QWidget
*parent
/*=NULL*/)
41 toolbox
= new QToolBox
;
42 toolbox
->addItem(new NSettingsOptions
, tr("Op&tions"));
43 toolbox
->addItem(new NSettingsCommands
, tr("Co&mmands"));
44 toolbox
->addItem(new NSettingsDownload
, tr("&Download"));
46 toolbox
->addItem(new NSettingsProxy
, tr("&Proxy"));
51 QDialogButtonBox
*btnBox
= new QDialogButtonBox(
52 QDialogButtonBox::Ok
| QDialogButtonBox::Cancel
);
54 connect(btnBox
, SIGNAL(accepted()), this, SLOT(accept()));
55 connect(btnBox
, SIGNAL(rejected()), this, SLOT(reject()));
59 QVBoxLayout
*box
= new QVBoxLayout
;
60 box
->addWidget(toolbox
);
61 box
->addWidget(btnBox
);
66 setWindowTitle(tr("Settings"));
67 setMinimumSize(QSize(540,450));
68 setSizeGripEnabled(true);
72 void NSettingsDialog::done(int n
)
74 if (n
== QDialog::Accepted
)
83 bool NSettingsDialog::foreachWidget(Mode mode
)
85 const int c
= toolbox
->count();
86 for (int i
=0; i
<c
; ++i
)
88 QWidget
*w
= toolbox
->widget(i
);
90 NSettingsWidget
*s
= dynamic_cast<NSettingsWidget
*>(w
);
93 if (mode
== To
&& !s
->verify(msg
))
95 toolbox
->setCurrentWidget(s
);
113 void NSettingsDialog::fromConfig()
118 bool NSettingsDialog::toConfig()
120 const bool r
= foreachWidget(To
);
126 NSettingsWidget::NSettingsWidget(QWidget
*parent
/*=NULL*/)
131 NSettingsTabWidget::NSettingsTabWidget(QWidget
*parent
/*=NULL*/)
138 /* vim: set ts=2 sw=2 tw=72 expandtab: */