kwave  18.07.70
Kwave::CompressionWidget Class Reference

#include <CompressionWidget.h>

Inheritance diagram for Kwave::CompressionWidget:
Inheritance graph
Collaboration diagram for Kwave::CompressionWidget:
Collaboration graph

Public Types

enum  Mode { ABR_MODE = 0, VBR_MODE }
 

Public Member Functions

 CompressionWidget (QWidget *parent)
 
virtual ~CompressionWidget ()
 
virtual void init (Kwave::FileInfo &info)
 
virtual void enableABR (bool enable, bool lowest, bool highest)
 
virtual void enableVBR (bool enable)
 
virtual void setBitrates (int nominal, int lower, int upper)
 
virtual void setQuality (int quality)
 
virtual Mode mode ()
 
virtual void setMode (Mode mode)
 
virtual bool lowestEnabled ()
 
virtual bool highestEnabled ()
 
virtual void getABRrates (int &nominal, int &lowest, int &highest)
 
virtual int baseQuality ()
 

Private Slots

virtual void selectABR (bool checked)
 
virtual void lowestToggled (bool on)
 
virtual void abrChanged (int value)
 
virtual void lowestChanged (int value)
 
virtual void highestChanged (int value)
 
virtual void highestToggled (bool on)
 

Private Member Functions

void describeWidget (QWidget *widget, const QString &name, const QString &description)
 
void initInfo (QLabel *label, QWidget *widget, Kwave::FileProperty property, Kwave::FileInfo &info)
 

Detailed Description

Definition at line 33 of file CompressionWidget.h.

Member Enumeration Documentation

◆ Mode

Compression Mode: ABR or VBR

Enumerator
ABR_MODE 

average bitrate mode

VBR_MODE 

variable bitrate mode

Definition at line 39 of file CompressionWidget.h.

Constructor & Destructor Documentation

◆ CompressionWidget()

Kwave::CompressionWidget::CompressionWidget ( QWidget *  parent)
explicit

Constructor

Definition at line 39 of file CompressionWidget.cpp.

References abrChanged(), Kwave::connect(), enableABR(), enableVBR(), highestChanged(), highestToggled(), Kwave::StandardBitrates::instance(), lowestChanged(), lowestToggled(), and selectABR().

40  :QWidget(parent), Ui::CompressionWidgetBase()
41 {
42  setupUi(this);
43 
44  // use well-known bitrates from MP3
46  abrBitrate->allowRates(rates);
47  abrHighestBitrate->allowRates(rates);
48  abrLowestBitrate->allowRates(rates);
49 
50  connect(rbABR, SIGNAL(toggled(bool)),
51  this, SLOT(selectABR(bool)));
52  connect(chkLowestBitrate, SIGNAL(toggled(bool)),
53  this, SLOT(lowestToggled(bool)));
54  connect(chkHighestBitrate, SIGNAL(toggled(bool)),
55  this, SLOT(highestToggled(bool)));
56  connect(abrBitrate, SIGNAL(valueChanged(int)),
57  this, SLOT(abrChanged(int)));
58  connect(abrLowestBitrate, SIGNAL(valueChanged(int)),
59  this, SLOT(lowestChanged(int)));
60  connect(abrHighestBitrate, SIGNAL(valueChanged(int)),
61  this, SLOT(highestChanged(int)));
62 
63  enableABR(false, false, false);
64  enableVBR(false);
65 }
virtual void lowestChanged(int value)
virtual void highestChanged(int value)
virtual void enableABR(bool enable, bool lowest, bool highest)
bool connect(Kwave::StreamObject &source, const char *output, Kwave::StreamObject &sink, const char *input)
Definition: Connect.cpp:48
virtual void selectABR(bool checked)
virtual void abrChanged(int value)
virtual void enableVBR(bool enable)
virtual void highestToggled(bool on)
virtual void lowestToggled(bool on)
static const StandardBitrates & instance()
Here is the call graph for this function:

◆ ~CompressionWidget()

Kwave::CompressionWidget::~CompressionWidget ( )
virtual

Destructor

Definition at line 68 of file CompressionWidget.cpp.

69 {
70 }

Member Function Documentation

◆ abrChanged

void Kwave::CompressionWidget::abrChanged ( int  value)
privatevirtualslot

called when the "average bitrate" slider has changed

Definition at line 175 of file CompressionWidget.cpp.

Referenced by CompressionWidget().

176 {
177  if (value < abrLowestBitrate->value())
178  abrLowestBitrate->setValue(value);
179  if (value > abrHighestBitrate->value())
180  abrHighestBitrate->setValue(value);
181 }
Here is the caller graph for this function:

◆ baseQuality()

int Kwave::CompressionWidget::baseQuality ( )
virtual

Returns the base quality in VBR mode, as percentage from 1...100

Definition at line 272 of file CompressionWidget.cpp.

273 {
274  return sbBaseQuality->value();
275 }

◆ describeWidget()

void Kwave::CompressionWidget::describeWidget ( QWidget *  widget,
const QString &  name,
const QString &  description 
)
private

Sets the tooltip and "what's this" of a widget.

Parameters
widgetany QWidget derived widget
nameof the setting, normally equal to it's label
descriptionverbose descriptive text that says what can be set

Definition at line 88 of file CompressionWidget.cpp.

References _.

Referenced by initInfo().

91 {
92  if (!widget) return;
93  widget->setToolTip(description);
94  widget->setWhatsThis(_("<b>") + name + _("</b><br>") + description);
95 }
const char name[16]
Definition: memcpy.c:510
#define _(m)
Definition: memcpy.c:66
Here is the caller graph for this function:

◆ enableABR()

void Kwave::CompressionWidget::enableABR ( bool  enable,
bool  lowest,
bool  highest 
)
virtual

Enable or disable ABR mode controls

Parameters
enablecontrols the global ABR mode setting enable/disable
lowestchecks/unchecks the lowest bitrate setting checkbox
highestchecks/unchecks the highest bitrate setting checkbox

Definition at line 109 of file CompressionWidget.cpp.

Referenced by CompressionWidget().

110 {
111  rbABR->setEnabled(enable);
112  if (!enable) rbABR->setChecked(false);
113 
114  const bool on = (rbABR->isChecked() && enable);
115  lblCompressionNominalBitrate->setEnabled(on);
116  abrBitrate->setEnabled(on);
117  abrHighestBitrate->setEnabled(on);
118  abrLowestBitrate->setEnabled(on);
119  chkHighestBitrate->setEnabled(on);
120  chkLowestBitrate->setEnabled(on);
121 
122  chkLowestBitrate->setChecked(lowest);
123  chkHighestBitrate->setChecked(highest);
124 }
Here is the caller graph for this function:

◆ enableVBR()

void Kwave::CompressionWidget::enableVBR ( bool  enable)
virtual

Enable or disable VBR mode

Definition at line 127 of file CompressionWidget.cpp.

Referenced by CompressionWidget().

128 {
129  rbVBR->setEnabled(enable);
130  if (!enable) rbVBR->setChecked(false);
131 
132  const bool on = (rbVBR->isChecked() && enable);
133  lblCompressionBaseQuality->setEnabled(on);
134  sbBaseQuality->setEnabled(on);
135  slBaseQuality->setEnabled(on);
136 
137 }
Here is the caller graph for this function:

◆ getABRrates()

void Kwave::CompressionWidget::getABRrates ( int &  nominal,
int &  lowest,
int &  highest 
)
virtual

Returns the bitrate settings of ABR mode

Parameters
nominalreceives the nominal bitrate
lowestreceives the lowest bitrate or null if unused
highestreceives the highest bitrate or null if unused

Definition at line 263 of file CompressionWidget.cpp.

265 {
266  nominal = abrBitrate->value();
267  lowest = abrLowestBitrate->value();
268  highest = abrHighestBitrate->value();
269 }

◆ highestChanged

void Kwave::CompressionWidget::highestChanged ( int  value)
privatevirtualslot

called when the "highest bitrate" slider has changed

Definition at line 193 of file CompressionWidget.cpp.

Referenced by CompressionWidget().

194 {
195  if (value < abrLowestBitrate->value())
196  abrLowestBitrate->setValue(value);
197  if (value < abrBitrate->value())
198  abrBitrate->setValue(value);
199 }
Here is the caller graph for this function:

◆ highestEnabled()

bool Kwave::CompressionWidget::highestEnabled ( )
virtual

Returns the state of the "use highest" checkbox

Definition at line 257 of file CompressionWidget.cpp.

258 {
259  return chkHighestBitrate->isChecked();
260 }

◆ highestToggled

void Kwave::CompressionWidget::highestToggled ( bool  on)
privatevirtualslot

called when the "highest bitrate" checkbox has been toggled

Definition at line 161 of file CompressionWidget.cpp.

Referenced by CompressionWidget().

162 {
163  if (on) {
164  // if previous state was off: transition off->on
165  // make sure that the highest ABR is above the current ABR
166  int abr = abrBitrate->value();
167  if (abrHighestBitrate->value() < abr)
168  abrHighestBitrate->setValue(abr);
169  }
170  abrHighestBitrate->setEnabled(chkHighestBitrate->isEnabled() && on);
171 }
Here is the caller graph for this function:

◆ init()

void Kwave::CompressionWidget::init ( Kwave::FileInfo info)
virtual
Parameters
infothe FileInfo used for getting the property descriptions

Definition at line 73 of file CompressionWidget.cpp.

References Kwave::INF_BITRATE_LOWER, Kwave::INF_BITRATE_NOMINAL, Kwave::INF_BITRATE_UPPER, Kwave::INF_VBR_QUALITY, and initInfo().

74 {
75  initInfo(lblCompressionNominalBitrate, abrBitrate,
77  initInfo(Q_NULLPTR, abrHighestBitrate,
79  initInfo(Q_NULLPTR, abrLowestBitrate,
81  initInfo(lblCompressionBaseQuality, sbBaseQuality,
83  initInfo(Q_NULLPTR, slBaseQuality,
85 }
void initInfo(QLabel *label, QWidget *widget, Kwave::FileProperty property, Kwave::FileInfo &info)
Here is the call graph for this function:

◆ initInfo()

void Kwave::CompressionWidget::initInfo ( QLabel *  label,
QWidget *  widget,
Kwave::FileProperty  property,
Kwave::FileInfo info 
)
private

Sets the text of the label to the name of a file property and initializes the tool tip of the corresponding edit/display control.

Parameters
labelthe label to be set
widgetthe control to get the tool tip
propertythe file property which it belongs to
infothe FileInfo used for getting the property descriptions

Definition at line 98 of file CompressionWidget.cpp.

References _, describeWidget(), Kwave::FileInfo::description(), and Kwave::FileInfo::name().

Referenced by init().

101 {
102  Q_ASSERT(widget);
103  if (label) label->setText(i18n(info.name(property).toLatin1()) + _(":"));
104  describeWidget(widget, i18n(info.name(property).toLatin1()),
105  i18n(info.description(property).toLatin1()));
106 }
void describeWidget(QWidget *widget, const QString &name, const QString &description)
QString name(FileProperty key) const
Definition: FileInfo.h:227
QString description(FileProperty key) const
Definition: FileInfo.h:234
#define _(m)
Definition: memcpy.c:66
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lowestChanged

void Kwave::CompressionWidget::lowestChanged ( int  value)
privatevirtualslot

called when the "lowest bitrate" slider has changed

Definition at line 184 of file CompressionWidget.cpp.

Referenced by CompressionWidget().

185 {
186  if (value > abrBitrate->value())
187  abrBitrate->setValue(value);
188  if (value > abrHighestBitrate->value())
189  abrHighestBitrate->setValue(value);
190 }
Here is the caller graph for this function:

◆ lowestEnabled()

bool Kwave::CompressionWidget::lowestEnabled ( )
virtual

Returns the state of the "use lowest" checkbox

Definition at line 251 of file CompressionWidget.cpp.

252 {
253  return chkLowestBitrate->isChecked();
254 }

◆ lowestToggled

void Kwave::CompressionWidget::lowestToggled ( bool  on)
privatevirtualslot

called when the "lowest bitrate" checkbox has been toggled

Definition at line 147 of file CompressionWidget.cpp.

Referenced by CompressionWidget().

148 {
149  if (on) {
150  // if previous state was off: transition off->on
151  // make sure that the lowest ABR is below the current ABR
152  int abr = abrBitrate->value();
153  if (abrLowestBitrate->value() > abr)
154  abrLowestBitrate->setValue(abr);
155  }
156  abrLowestBitrate->setEnabled(chkLowestBitrate->isEnabled() && on);
157 }
Here is the caller graph for this function:

◆ mode()

Kwave::CompressionWidget::Mode Kwave::CompressionWidget::mode ( )
virtual

Returns the current bitrate mode: ABR or VBR

Definition at line 216 of file CompressionWidget.cpp.

References ABR_MODE, and VBR_MODE.

◆ selectABR

void Kwave::CompressionWidget::selectABR ( bool  checked)
privatevirtualslot

called when the selection state of the ABR radio button changed

Definition at line 140 of file CompressionWidget.cpp.

Referenced by CompressionWidget().

141 {
142  abrHighestBitrate->setEnabled(checked && chkHighestBitrate->isChecked());
143  abrLowestBitrate->setEnabled( checked && chkLowestBitrate->isChecked());
144 }
Here is the caller graph for this function:

◆ setBitrates()

void Kwave::CompressionWidget::setBitrates ( int  nominal,
int  lower,
int  upper 
)
virtual

Sets the bitrates in ABR mode

Parameters
nominalthe nominal bitrate or zero if not used
lowerthe lowest bitrate or zero if not used
upperthe highest bitrate or zero if not used

Definition at line 202 of file CompressionWidget.cpp.

203 {
204  abrLowestBitrate->setValue(lower);
205  abrHighestBitrate->setValue(upper);
206  abrBitrate->setValue(nominal);
207 }

◆ setMode()

void Kwave::CompressionWidget::setMode ( Mode  mode)
virtual

Selects ABR or VBR mode

Definition at line 222 of file CompressionWidget.cpp.

References ABR_MODE, and VBR_MODE.

223 {
224  bool abr = rbABR->isEnabled();
225  bool vbr = rbVBR->isEnabled();
226  switch (mode) {
227  case ABR_MODE:
228  rbVBR->setChecked(false);
229  rbVBR->setChecked(true);
230  rbVBR->setChecked(false);
231 
232  rbABR->setChecked(true);
233  rbABR->setChecked(false);
234  rbABR->setChecked(true);
235  rbABR->setChecked(abr);
236  break;
237  case VBR_MODE:
238  rbABR->setChecked(false);
239  rbABR->setChecked(true);
240  rbABR->setChecked(false);
241 
242  rbVBR->setChecked(true);
243  rbVBR->setChecked(false);
244  rbVBR->setChecked(true);
245  rbVBR->setChecked(vbr);
246  break;
247  }
248 }

◆ setQuality()

void Kwave::CompressionWidget::setQuality ( int  quality)
virtual

Sets the VBR base quality or zero if unused.

Definition at line 210 of file CompressionWidget.cpp.

211 {
212  sbBaseQuality->setValue(quality);
213 }

The documentation for this class was generated from the following files: