1
2 #include "ttaenccodecglobal.h"
3
4 #include "ttaenccodecwidget.h"
5 #include "../../core/conversionoptions.h"
6
7 #include <QLayout>
8 #include <QCheckBox>
9 #include <KLineEdit>
10 #include <KLocale>
11
12
TTAEncCodecWidget()13 TTAEncCodecWidget::TTAEncCodecWidget()
14 : CodecWidget(),
15 currentFormat( "tta" )
16 {
17 QGridLayout *grid = new QGridLayout( this );
18 grid->setContentsMargins( 0, 0, 0, 0 );
19
20 // cmd arguments box
21
22 QHBoxLayout *cmdArgumentsBox = new QHBoxLayout();
23 grid->addLayout( cmdArgumentsBox, 1, 0 );
24
25 cCmdArguments = new QCheckBox( i18n("Additional encoder arguments:"), this );
26 cmdArgumentsBox->addWidget( cCmdArguments );
27 lCmdArguments = new KLineEdit( this );
28 lCmdArguments->setEnabled( false );
29 cmdArgumentsBox->addWidget( lCmdArguments );
30 connect( cCmdArguments, SIGNAL(toggled(bool)), lCmdArguments, SLOT(setEnabled(bool)) );
31
32 grid->setRowStretch( 2, 1 );
33 }
34
~TTAEncCodecWidget()35 TTAEncCodecWidget::~TTAEncCodecWidget()
36 {}
37
currentConversionOptions()38 ConversionOptions *TTAEncCodecWidget::currentConversionOptions()
39 {
40 ConversionOptions *options = new ConversionOptions();
41 options->qualityMode = ConversionOptions::Lossless;
42 if( cCmdArguments->isChecked() )
43 options->cmdArguments = lCmdArguments->text();
44 else
45 options->cmdArguments = "";
46
47 return options;
48 }
49
setCurrentConversionOptions(const ConversionOptions * _options)50 bool TTAEncCodecWidget::setCurrentConversionOptions( const ConversionOptions *_options )
51 {
52 if( !_options || _options->pluginName != global_plugin_name )
53 return false;
54
55 const ConversionOptions *options = _options;
56 cCmdArguments->setChecked( !options->cmdArguments.isEmpty() );
57 if( !options->cmdArguments.isEmpty() )
58 lCmdArguments->setText( options->cmdArguments );
59
60 return true;
61 }
62
setCurrentFormat(const QString & format)63 void TTAEncCodecWidget::setCurrentFormat( const QString& format )
64 {
65 if( currentFormat == format )
66 return;
67
68 currentFormat = format;
69 setEnabled( currentFormat != "wav" );
70 }
71
currentProfile()72 QString TTAEncCodecWidget::currentProfile()
73 {
74 return i18n("Lossless");
75 }
76
setCurrentProfile(const QString & profile)77 bool TTAEncCodecWidget::setCurrentProfile( const QString& profile )
78 {
79 return profile == i18n("Lossless");
80 }
81
currentDataRate()82 int TTAEncCodecWidget::currentDataRate()
83 {
84 int dataRate;
85
86 if( currentFormat == "wav" )
87 {
88 dataRate = 10590000;
89 }
90 else
91 {
92 dataRate = 6400000;
93 }
94
95 return dataRate;
96 }
97
98
99