From 41d040e7aab7a5c4415348c9c43256b9b9a150f3 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Fri, 21 Jan 2011 21:41:50 +0100 Subject: [PATCH] Initial support for bitrate management (under "Advanced Options"). --- gui/MainWindow.ui | 264 ++++++++++++++++++++++++++++++++++---- src/Config.h | 2 +- src/Dialog_MainWindow.cpp | 47 +++++++ src/Dialog_MainWindow.h | 3 + src/Model_Settings.cpp | 6 + src/Model_Settings.h | 4 + 6 files changed, 302 insertions(+), 24 deletions(-) diff --git a/gui/MainWindow.ui b/gui/MainWindow.ui index 238ca8d2..e534e418 100644 --- a/gui/MainWindow.ui +++ b/gui/MainWindow.ui @@ -985,7 +985,7 @@ - + 4 @@ -993,6 +993,9 @@ 1 + + 3 + Qt::Horizontal @@ -1004,7 +1007,7 @@ - + Qt::Horizontal @@ -1020,7 +1023,7 @@ - + Qt::Horizontal @@ -1036,30 +1039,14 @@ - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 8 - - - - - + Faster Processing - + @@ -1075,7 +1062,7 @@ - + Better quality @@ -1085,6 +1072,22 @@ + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 8 + + + + @@ -1092,11 +1095,14 @@ - + Qt::Vertical + + QSizePolicy::Expanding + 20 @@ -1105,6 +1111,151 @@ + + + + + 50 + false + + + + Bitrate Management + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + + + Enable Bitrate Management + + + + + + + false + + + 32 + + + 500 + + + 500 + + + + + + + false + + + 32 + + + 500 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 8 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 8 + 20 + + + + + + + + false + + + Minimum (kbps): + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + false + + + Maximum (kbps): + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + @@ -1546,6 +1697,9 @@ + + + @@ -1852,5 +2006,69 @@ + + checkBoxBitrateManagement + clicked(bool) + labelBitrateManagementMin + setEnabled(bool) + + + 123 + 214 + + + 256 + 214 + + + + + checkBoxBitrateManagement + clicked(bool) + labelBitrateManagementMax + setEnabled(bool) + + + 123 + 214 + + + 465 + 214 + + + + + checkBoxBitrateManagement + clicked(bool) + spinBoxBitrateManagementMin + setEnabled(bool) + + + 123 + 214 + + + 360 + 214 + + + + + checkBoxBitrateManagement + clicked(bool) + spinBoxBitrateManagementMax + setEnabled(bool) + + + 123 + 214 + + + 569 + 214 + + + diff --git a/src/Config.h b/src/Config.h index 636e7998..b2bafa15 100644 --- a/src/Config.h +++ b/src/Config.h @@ -25,7 +25,7 @@ #define VER_LAMEXP_MAJOR 4 #define VER_LAMEXP_MINOR_HI 0 #define VER_LAMEXP_MINOR_LO 0 -#define VER_LAMEXP_BUILD 243 +#define VER_LAMEXP_BUILD 245 #define VER_LAMEXP_SUFFIX Beta-1 /* diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index 5af1cc49..f72bb1fb 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -214,7 +214,13 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S //Setup "Advanced Options" tab sliderLameAlgoQuality->setValue(m_settings->lameAlgoQuality()); + spinBoxBitrateManagementMin->setValue(m_settings->bitrateManagementMinRate()); + spinBoxBitrateManagementMax->setValue(m_settings->bitrateManagementMaxRate()); + while(checkBoxBitrateManagement->isChecked() != m_settings->bitrateManagementEnabled()) checkBoxBitrateManagement->click(); connect(sliderLameAlgoQuality, SIGNAL(valueChanged(int)), this, SLOT(updateLameAlgoQuality(int))); + connect(checkBoxBitrateManagement, SIGNAL(clicked(bool)), this, SLOT(bitrateManagementEnabledChanged(bool))); + connect(spinBoxBitrateManagementMin, SIGNAL(valueChanged(int)), this, SLOT(bitrateManagementMinChanged(int))); + connect(spinBoxBitrateManagementMax, SIGNAL(valueChanged(int)), this, SLOT(bitrateManagementMaxChanged(int))); updateLameAlgoQuality(sliderLameAlgoQuality->value()); //Activate file menu actions @@ -1587,6 +1593,47 @@ void MainWindow::updateLameAlgoQuality(int value) } } +/* + * Bitrate management endabled/disabled + */ +void MainWindow::bitrateManagementEnabledChanged(bool checked) +{ + m_settings->bitrateManagementEnabled(checked); +} + +/* + * Minimum bitrate has changed + */ +void MainWindow::bitrateManagementMinChanged(int value) +{ + if(value > spinBoxBitrateManagementMax->value()) + { + spinBoxBitrateManagementMin->setValue(spinBoxBitrateManagementMax->value()); + m_settings->bitrateManagementMinRate(spinBoxBitrateManagementMax->value()); + } + else + { + m_settings->bitrateManagementMinRate(value); + } +} + +/* + * Maximum bitrate has changed + */ +void MainWindow::bitrateManagementMaxChanged(int value) +{ + if(value < spinBoxBitrateManagementMin->value()) + { + spinBoxBitrateManagementMax->setValue(spinBoxBitrateManagementMin->value()); + m_settings->bitrateManagementMaxRate(spinBoxBitrateManagementMin->value()); + } + else + { + m_settings->bitrateManagementMaxRate(value); + } +} + + /* * Model reset */ diff --git a/src/Dialog_MainWindow.h b/src/Dialog_MainWindow.h index 179851d5..2154d131 100644 --- a/src/Dialog_MainWindow.h +++ b/src/Dialog_MainWindow.h @@ -80,6 +80,9 @@ private slots: void updateRCMode(int id); void updateBitrate(int value); void updateLameAlgoQuality(int value); + void bitrateManagementEnabledChanged(bool checked); + void bitrateManagementMinChanged(int value); + void bitrateManagementMaxChanged(int value); void sourceModelChanged(void); void metaTagsEnabledChanged(void); void playlistEnabledChanged(void); diff --git a/src/Model_Settings.cpp b/src/Model_Settings.cpp index 26c21710..32657e4b 100644 --- a/src/Model_Settings.cpp +++ b/src/Model_Settings.cpp @@ -51,6 +51,9 @@ static const char *g_settingsId_wmaDecoderNotificationsEnabled = "Flags/EnableWm static const char *g_settingsId_dropBoxWidgetEnabled = "Flags/EnableDropBoxWidget"; static const char *g_settingsId_currentLanguage = "Localization/Language"; static const char *g_settingsId_lameAlgoQuality = "AdvancedOptions/LAME/AlgorithmQuality"; +static const char *g_settingsId_bitrateManagementEnabled = "AdvancedOptions/BitrateManagement/Enabled"; +static const char *g_settingsId_bitrateManagementMinRate = "AdvancedOptions/BitrateManagement/MinRate"; +static const char *g_settingsId_bitrateManagementMaxRate = "AdvancedOptions/BitrateManagement/MaxRate"; //Macros #define MAKE_OPTION1(OPT,DEF) \ @@ -188,3 +191,6 @@ MAKE_OPTION3(wmaDecoderNotificationsEnabled, true) MAKE_OPTION3(dropBoxWidgetEnabled, true) MAKE_OPTION2(currentLanguage, defaultLanguage()); MAKE_OPTION1(lameAlgoQuality, 3) +MAKE_OPTION3(bitrateManagementEnabled, false) +MAKE_OPTION1(bitrateManagementMinRate, 32) +MAKE_OPTION1(bitrateManagementMaxRate, 500) diff --git a/src/Model_Settings.h b/src/Model_Settings.h index 6a6ebc9f..e17e8910 100644 --- a/src/Model_Settings.h +++ b/src/Model_Settings.h @@ -80,6 +80,10 @@ public: MAKE_OPTION_DEC3(dropBoxWidgetEnabled) MAKE_OPTION_DEC2(currentLanguage); MAKE_OPTION_DEC1(lameAlgoQuality); + MAKE_OPTION_DEC3(bitrateManagementEnabled); + MAKE_OPTION_DEC1(bitrateManagementMinRate); + MAKE_OPTION_DEC1(bitrateManagementMaxRate); + //Misc void validate(void);