Update Finnish translation
[nomnom.git] / src / settings / nsettingsdialog_options_behaviour.cpp
blob522942efcd94876e5ed0d73ad788d8eb4eb798d2
1 /* NomNom
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/>.
18 #include "config.h"
20 #include <QVBoxLayout>
21 #include <QCheckBox>
23 #include <NSettingsMutator>
24 #include <NSettingsDialog>
26 extern nn::NSettingsMutator settings; // main.cpp
28 namespace nn
31 NSettingsBehaviour::NSettingsBehaviour(QWidget *parent/*=NULL*/)
32 : NSettingsTabWidget(parent)
35 // Widgets
37 createWidgets();
39 // Layout
41 QVBoxLayout *box = new QVBoxLayout;
42 box->addWidget(clearURLRecordAtExitBox);
43 box->addWidget(getBestFormatBox);
44 box->addWidget(askWhereSaveMediaBox);
45 box->addWidget(replaceExistingMediaBox);
46 box->addWidget(keepAppWinTopBox);
47 box->addWidget(playWhenDoneBox);
48 box->addStretch(0);
49 setLayout(box);
52 void NSettingsBehaviour::createWidgets()
54 keepAppWinTopBox =
55 new QCheckBox(tr("&Keep application window on top"));
57 playWhenDoneBox =
58 new QCheckBox(tr("Pla&y media when done downloading"));
60 askWhereSaveMediaBox =
61 new QCheckBox(tr("A&sk where to save media"));
63 clearURLRecordAtExitBox =
64 new QCheckBox(tr("C&lear record of visited URLs at exit"));
66 replaceExistingMediaBox =
67 new QCheckBox(tr("Al&ways replace existing media"));
69 getBestFormatBox =
70 new QCheckBox(tr("Always &get the best media format"));
73 void NSettingsBehaviour::init()
77 static void _write(SettingKey k, QCheckBox *c)
79 settings.setValue(k, c->checkState());
82 void NSettingsBehaviour::write()
84 _write(ReplaceExistingMedia, replaceExistingMediaBox);
85 _write(ClearURLRecordAtExit, clearURLRecordAtExitBox);
86 _write(AskWhereToSaveMediaFile, askWhereSaveMediaBox);
87 _write(KeepApplicationWindowOnTop, keepAppWinTopBox);
88 _write(GetBestFormat, getBestFormatBox);
89 _write(PlayWhenDoneDownloading, playWhenDoneBox);
92 static void _read(SettingKey k, QCheckBox *c)
94 const int n = settings.value(k).toInt();
95 const Qt::CheckState s = static_cast<Qt::CheckState>(n);
96 c->setCheckState(s);
99 void NSettingsBehaviour::read()
101 _read(ReplaceExistingMedia, replaceExistingMediaBox);
102 _read(ClearURLRecordAtExit, clearURLRecordAtExitBox);
103 _read(AskWhereToSaveMediaFile, askWhereSaveMediaBox);
104 _read(GetBestFormat, getBestFormatBox);
105 _read(KeepApplicationWindowOnTop, keepAppWinTopBox);
106 _read(PlayWhenDoneDownloading, playWhenDoneBox);
109 bool NSettingsBehaviour::verify(QString&)
111 return true;
114 } // namespace nn
116 /* vim: set ts=2 sw=2 tw=72 expandtab: */