[112] | 1 | /* smplayer, GUI front-end for mplayer.
|
---|
[188] | 2 | Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
[112] | 3 |
|
---|
| 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 2 of the License, or
|
---|
| 7 | (at your option) any later version.
|
---|
| 8 |
|
---|
| 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.
|
---|
| 13 |
|
---|
| 14 | You should have received a copy of the GNU General Public License
|
---|
| 15 | along with this program; if not, write to the Free Software
|
---|
| 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
| 17 | */
|
---|
| 18 |
|
---|
| 19 | #include "tvsettings.h"
|
---|
| 20 | #include "mediasettings.h"
|
---|
| 21 | #include <QSettings>
|
---|
| 22 | #include <QFileInfo>
|
---|
[181] | 23 | #include <QDebug>
|
---|
[112] | 24 |
|
---|
| 25 | TVSettings::TVSettings(QString directory) : FileSettingsBase(directory)
|
---|
| 26 | {
|
---|
| 27 | my_settings = new QSettings(directory + "/smplayer_tv.ini", QSettings::IniFormat);
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | TVSettings::~TVSettings() {
|
---|
| 31 | delete my_settings;
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | QString TVSettings::filenameToGroupname(const QString & filename) {
|
---|
| 35 | QString s = filename;
|
---|
| 36 | s = s.replace('/', '_');
|
---|
| 37 | s = s.replace('\\', '_');
|
---|
| 38 | s = s.replace(':', '_');
|
---|
| 39 | s = s.replace('.', '_');
|
---|
| 40 | s = s.replace(' ', '_');
|
---|
| 41 |
|
---|
| 42 | return s;
|
---|
| 43 | }
|
---|
| 44 |
|
---|
[181] | 45 | bool TVSettings::existSettingsFor(QString filename, int type) {
|
---|
| 46 | qDebug() << "TVSettings::existSettingsFor:" << filename;
|
---|
[112] | 47 |
|
---|
| 48 | QString group_name = filenameToGroupname(filename);
|
---|
| 49 |
|
---|
[181] | 50 | qDebug() << "TVSettings::existSettingsFor: group_name:'" << group_name;
|
---|
[112] | 51 |
|
---|
| 52 | my_settings->beginGroup( group_name );
|
---|
| 53 | bool saved = my_settings->value("saved", false).toBool();
|
---|
| 54 | my_settings->endGroup();
|
---|
| 55 |
|
---|
| 56 | return saved;
|
---|
| 57 | }
|
---|
| 58 |
|
---|
[181] | 59 | void TVSettings::loadSettingsFor(QString filename, int type, MediaSettings & mset, int player) {
|
---|
| 60 | qDebug() << "TVSettings::loadSettingsFor:" << filename;
|
---|
[112] | 61 |
|
---|
| 62 | QString group_name = filenameToGroupname(filename);
|
---|
| 63 |
|
---|
[181] | 64 | qDebug() << "TVSettings::loadSettingsFor: group_name:" << group_name;
|
---|
[112] | 65 |
|
---|
| 66 | mset.reset();
|
---|
[176] | 67 |
|
---|
[112] | 68 | my_settings->beginGroup( group_name );
|
---|
[176] | 69 | mset.load(my_settings, player);
|
---|
[112] | 70 | my_settings->endGroup();
|
---|
| 71 | }
|
---|
| 72 |
|
---|
[181] | 73 | void TVSettings::saveSettingsFor(QString filename, int type, MediaSettings & mset, int player) {
|
---|
| 74 | qDebug() << "TVSettings::saveSettingsFor" << filename;
|
---|
[112] | 75 |
|
---|
| 76 | QString group_name = filenameToGroupname(filename);
|
---|
| 77 |
|
---|
[181] | 78 | qDebug() << "TVSettings::saveSettingsFor: group_name:" << group_name;
|
---|
[112] | 79 |
|
---|
| 80 | my_settings->beginGroup( group_name );
|
---|
| 81 | my_settings->setValue("saved", true);
|
---|
[176] | 82 | mset.save(my_settings, player);
|
---|
[112] | 83 | my_settings->endGroup();
|
---|
| 84 | }
|
---|
| 85 |
|
---|