~ubuntu-branches/ubuntu/saucy/clementine/saucy

« back to all changes in this revision

Viewing changes to src/transcoder/transcoderoptionsvorbis.cpp

  • Committer: Package Import Robot
  • Author(s): Thomas PIERSON
  • Date: 2012-01-01 20:43:39 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120101204339-lsb6nndwhfy05sde
Tags: 1.0.1+dfsg-1
New upstream release. (Closes: #653926, #651611, #657391)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of Clementine.
 
2
   Copyright 2010, David Sansome <me@davidsansome.com>
 
3
 
 
4
   Clementine 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.
 
8
 
 
9
   Clementine 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 Clementine.  If not, see <http://www.gnu.org/licenses/>.
 
16
*/
 
17
 
 
18
#include "transcoderoptionsvorbis.h"
 
19
#include "ui_transcoderoptionsvorbis.h"
 
20
 
 
21
#include <QSettings>
 
22
 
 
23
const char* TranscoderOptionsVorbis::kSettingsGroup = "Transcoder/vorbisenc";
 
24
 
 
25
TranscoderOptionsVorbis::TranscoderOptionsVorbis(QWidget* parent)
 
26
  : TranscoderOptionsInterface(parent),
 
27
    ui_(new Ui_TranscoderOptionsVorbis)
 
28
{
 
29
  ui_->setupUi(this);
 
30
}
 
31
 
 
32
TranscoderOptionsVorbis::~TranscoderOptionsVorbis() {
 
33
  delete ui_;
 
34
}
 
35
 
 
36
void TranscoderOptionsVorbis::Load() {
 
37
  QSettings s;
 
38
  s.beginGroup(kSettingsGroup);
 
39
 
 
40
#define GET_BITRATE(variable, property) \
 
41
  int variable = s.value(property, -1).toInt(); \
 
42
  variable = variable == -1 ? 0 : variable / 1000
 
43
 
 
44
  GET_BITRATE(bitrate, "bitrate");
 
45
  GET_BITRATE(min_bitrate, "min-bitrate");
 
46
  GET_BITRATE(max_bitrate, "max-bitrate");
 
47
#undef GET_BITRATE
 
48
 
 
49
  ui_->quality_slider->setValue(s.value("quality", 0.3).toDouble() * 10);
 
50
  ui_->managed->setChecked(s.value("managed", false).toBool());
 
51
  ui_->max_bitrate_slider->setValue(max_bitrate);
 
52
  ui_->min_bitrate_slider->setValue(min_bitrate);
 
53
  ui_->bitrate_slider->setValue(bitrate);
 
54
}
 
55
 
 
56
void TranscoderOptionsVorbis::Save() {
 
57
  QSettings s;
 
58
  s.beginGroup(kSettingsGroup);
 
59
 
 
60
#define GET_BITRATE(variable, ui_slider) \
 
61
  int variable = ui_slider->value(); \
 
62
  variable = variable == 0 ? -1 : variable * 1000
 
63
 
 
64
  GET_BITRATE(bitrate, ui_->bitrate_slider);
 
65
  GET_BITRATE(min_bitrate, ui_->min_bitrate_slider);
 
66
  GET_BITRATE(max_bitrate, ui_->max_bitrate_slider);
 
67
#undef GET_BITRATE
 
68
 
 
69
  s.setValue("quality", double(ui_->quality_slider->value()) / 10);
 
70
  s.setValue("managed", ui_->managed->isChecked());
 
71
  s.setValue("bitrate", bitrate);
 
72
  s.setValue("min-bitrate", min_bitrate);
 
73
  s.setValue("max-bitrate", max_bitrate);
 
74
}