2018-02-27 18:06:05 +01:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
|
|
|
* This file was part of Clementine.
|
|
|
|
* Copyright 2010, David Sansome <me@davidsansome.com>
|
|
|
|
*
|
|
|
|
* Strawberry is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Strawberry is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
2018-08-09 18:39:44 +02:00
|
|
|
*
|
2018-02-27 18:06:05 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QWidget>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <QString>
|
|
|
|
#include <QStringBuilder>
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QSlider>
|
|
|
|
#include <QSettings>
|
|
|
|
|
|
|
|
#include "transcoderoptionsinterface.h"
|
2018-02-27 18:06:05 +01:00
|
|
|
#include "transcoderoptionsvorbis.h"
|
|
|
|
#include "ui_transcoderoptionsvorbis.h"
|
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
const char *TranscoderOptionsVorbis::kSettingsGroup = "Transcoder/vorbisenc";
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2021-07-11 07:40:57 +02:00
|
|
|
TranscoderOptionsVorbis::TranscoderOptionsVorbis(QWidget *parent) : TranscoderOptionsInterface(parent), ui_(new Ui_TranscoderOptionsVorbis) {
|
2018-02-27 18:06:05 +01:00
|
|
|
ui_->setupUi(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
TranscoderOptionsVorbis::~TranscoderOptionsVorbis() {
|
|
|
|
delete ui_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TranscoderOptionsVorbis::Load() {
|
|
|
|
|
|
|
|
QSettings s;
|
|
|
|
s.beginGroup(kSettingsGroup + settings_postfix_);
|
|
|
|
|
|
|
|
#define GET_BITRATE(variable, property) \
|
|
|
|
int variable = s.value(property, -1).toInt(); \
|
2021-06-20 19:04:08 +02:00
|
|
|
(variable) = ((variable) == -1 ? 0 : (variable) / 1000)
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
GET_BITRATE(bitrate, "bitrate");
|
|
|
|
GET_BITRATE(min_bitrate, "min-bitrate");
|
|
|
|
GET_BITRATE(max_bitrate, "max-bitrate");
|
|
|
|
#undef GET_BITRATE
|
|
|
|
|
2021-03-21 18:53:02 +01:00
|
|
|
ui_->quality_slider->setValue(static_cast<int>(s.value("quality", 1.0).toDouble() * 10));
|
2018-02-27 18:06:05 +01:00
|
|
|
ui_->managed->setChecked(s.value("managed", false).toBool());
|
|
|
|
ui_->max_bitrate_slider->setValue(max_bitrate);
|
|
|
|
ui_->min_bitrate_slider->setValue(min_bitrate);
|
|
|
|
ui_->bitrate_slider->setValue(bitrate);
|
|
|
|
|
2020-05-25 23:56:54 +02:00
|
|
|
s.endGroup();
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TranscoderOptionsVorbis::Save() {
|
|
|
|
|
|
|
|
QSettings s;
|
|
|
|
s.beginGroup(kSettingsGroup + settings_postfix_);
|
|
|
|
|
|
|
|
#define GET_BITRATE(variable, ui_slider) \
|
2021-06-20 19:04:08 +02:00
|
|
|
int variable = (ui_slider)->value(); \
|
|
|
|
(variable) = ((variable) == 0 ? -1 : (variable) * 1000)
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
GET_BITRATE(bitrate, ui_->bitrate_slider);
|
|
|
|
GET_BITRATE(min_bitrate, ui_->min_bitrate_slider);
|
|
|
|
GET_BITRATE(max_bitrate, ui_->max_bitrate_slider);
|
|
|
|
#undef GET_BITRATE
|
|
|
|
|
|
|
|
s.setValue("quality", double(ui_->quality_slider->value()) / 10);
|
|
|
|
s.setValue("managed", ui_->managed->isChecked());
|
|
|
|
s.setValue("bitrate", bitrate);
|
|
|
|
s.setValue("min-bitrate", min_bitrate);
|
|
|
|
s.setValue("max-bitrate", max_bitrate);
|
|
|
|
|
2020-05-25 23:56:54 +02:00
|
|
|
s.endGroup();
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
}
|