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 <QVBoxLayout>
23 #include <NSettingsMutator>
24 #include <NSettingsDialog>
26 extern nn::NSettingsMutator settings
; // main.cpp
31 NSettingsBehaviour::NSettingsBehaviour(QWidget
*parent
/*=NULL*/)
32 : NSettingsTabWidget(parent
)
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
);
52 void NSettingsBehaviour::createWidgets()
55 new QCheckBox(tr("&Keep application window on top"));
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"));
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
);
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
&)
116 /* vim: set ts=2 sw=2 tw=72 expandtab: */