Skip to content

Commit

Permalink
Only show relevant widgets on the export dialog
Browse files Browse the repository at this point in the history
Only show widgets on the export dialog that are relevant to the selected
file format (Wave/Ogg):
* Sample rate is always shown.
* Bit depth settings are only shown when Wave is selected.
* Bit rate settings are only shown when Ogg is selected.

Remove the label that informs the user that not all settings apply to
all export formats as it is not needed anymore. The english text of that
label was: "Please note that not all of the parameters above apply for
all file formats."
  • Loading branch information
michaelgregorius committed May 12, 2017
1 parent d5fc38e commit 4ac6aa9
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 65 deletions.
2 changes: 2 additions & 0 deletions include/ExportProjectDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ private slots:
void accept();
void startExport();

void onFileFormatChanged(int);

private:
QString m_fileName;
QString m_dirName;
Expand Down
28 changes: 28 additions & 0 deletions src/gui/ExportProjectDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,35 @@ void ExportProjectDialog::startExport()
}


ProjectRenderer::ExportFileFormats convertIndexToExportFileFormat(int index)
{
switch (index)
{
case 0:
return ProjectRenderer::WaveFile;
case 1:
return ProjectRenderer::OggFile;
default:
Q_ASSERT(false);
break;
}

return ProjectRenderer::NumFileFormats;
}


void ExportProjectDialog::onFileFormatChanged(int index)
{
ProjectRenderer::ExportFileFormats exportFormat =
convertIndexToExportFileFormat(index);

bool bitRateControlsEnabled = exportFormat == ProjectRenderer::OggFile;
bool bitDepthControlEnabled = exportFormat == ProjectRenderer::WaveFile;

bitrateWidget->setVisible(bitRateControlsEnabled);

depthWidget->setVisible(bitDepthControlEnabled);
}

void ExportProjectDialog::startBtnClicked()
{
Expand Down
129 changes: 64 additions & 65 deletions src/gui/dialogs/export_project.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>519</width>
<height>412</height>
<width>715</width>
<height>447</height>
</rect>
</property>
<property name="minimumSize">
Expand Down Expand Up @@ -81,54 +81,39 @@
</widget>
</item>
<item>
<widget class="QWidget" name="bitrateWidget" native="true">
<widget class="QWidget" name="depthWidget" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<layout class="QVBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_5">
<widget class="QLabel" name="labelBitDepth">
<property name="text">
<string>Bitrate:</string>
<string>Depth:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="bitrateCB">
<property name="currentIndex">
<number>2</number>
</property>
<item>
<property name="text">
<string>64 KBit/s</string>
</property>
</item>
<item>
<property name="text">
<string>128 KBit/s</string>
</property>
</item>
<item>
<property name="text">
<string>160 KBit/s</string>
</property>
</item>
<widget class="QComboBox" name="depthCB">
<item>
<property name="text">
<string>192 KBit/s</string>
<string>16 Bit Integer</string>
</property>
</item>
<item>
<property name="text">
<string>256 KBit/s</string>
<string>24 Bit Float</string>
</property>
</item>
<item>
<property name="text">
<string>320 KBit/s</string>
<string>32 Bit Float</string>
</property>
</item>
</widget>
Expand All @@ -137,66 +122,61 @@
</widget>
</item>
<item>
<widget class="QWidget" name="depthWidget" native="true">
<widget class="QWidget" name="bitrateWidget" native="true">
<layout class="QVBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_6">
<widget class="QLabel" name="labelBitRate">
<property name="text">
<string>Depth:</string>
<string>Bitrate:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="depthCB">
<widget class="QComboBox" name="bitrateCB">
<property name="currentIndex">
<number>2</number>
</property>
<item>
<property name="text">
<string>16 Bit Integer</string>
<string>64 KBit/s</string>
</property>
</item>
<item>
<property name="text">
<string>24 Bit Float</string>
<string>128 KBit/s</string>
</property>
</item>
<item>
<property name="text">
<string>32 Bit Float</string>
<string>160 KBit/s</string>
</property>
</item>
<item>
<property name="text">
<string>192 KBit/s</string>
</property>
</item>
<item>
<property name="text">
<string>256 KBit/s</string>
</property>
</item>
<item>
<property name="text">
<string>320 KBit/s</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Please note that not all of the parameters above apply for all file formats.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
Expand Down Expand Up @@ -368,14 +348,33 @@
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>357</x>
<y>293</y>
<x>511</x>
<y>372</y>
</hint>
<hint type="destinationlabel">
<x>202</x>
<y>175</y>
</hint>
</hints>
</connection>
<connection>
<sender>fileFormatCB</sender>
<signal>currentIndexChanged(int)</signal>
<receiver>ExportProjectDialog</receiver>
<slot>onFileFormatChanged(int)</slot>
<hints>
<hint type="sourcelabel">
<x>111</x>
<y>85</y>
</hint>
<hint type="destinationlabel">
<x>518</x>
<y>212</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>onFileFormatChanged(int)</slot>
</slots>
</ui>

0 comments on commit 4ac6aa9

Please sign in to comment.