From 476265df3af0b82f8e5fef96b0ad0982e6fb04e8 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Thu, 10 Feb 2011 16:08:03 +0100 Subject: [PATCH] Save the "Position" field on the "Meta Data" tab. --- gui/LogViewDialog.ui | 19 +++++++++ gui/MetaInfo.ui | 25 +++++++++++ gui/ProcessingDialog.ui | 14 ++++++ gui/UpdateDialog.ui | 26 ++++++++++++ src/Config.h | 2 +- src/Dialog_About.cpp | 7 +++ src/Dialog_MainWindow.cpp | 11 ++++- src/Model_MetaInfo.cpp | 50 ++++++++++++++++++++++ src/Model_MetaInfo.h | 1 + src/Model_Settings.cpp | 89 +++++++++++++++++++++++---------------- src/Model_Settings.h | 13 ++++++ 11 files changed, 219 insertions(+), 38 deletions(-) diff --git a/gui/LogViewDialog.ui b/gui/LogViewDialog.ui index a321a1c0..23fe1768 100644 --- a/gui/LogViewDialog.ui +++ b/gui/LogViewDialog.ui @@ -311,6 +311,12 @@ RUN\DOS\RUN :/icons/cross.png:/icons/cross.png + + + 16 + 16 + + @@ -328,6 +334,12 @@ RUN\DOS\RUN :/icons/disk.png:/icons/disk.png + + + 16 + 16 + + @@ -358,6 +370,12 @@ RUN\DOS\RUN :/icons/paste_plain.png:/icons/paste_plain.png + + + 16 + 16 + + @@ -373,6 +391,7 @@ RUN\DOS\RUN + diff --git a/gui/MetaInfo.ui b/gui/MetaInfo.ui index ab066860..f9df2e30 100644 --- a/gui/MetaInfo.ui +++ b/gui/MetaInfo.ui @@ -213,6 +213,12 @@ :/icons/arrow_up.png:/icons/arrow_up.png + + + 16 + 16 + + false @@ -227,6 +233,12 @@ :/icons/arrow_down.png:/icons/arrow_down.png + + + 16 + 16 + + false @@ -263,6 +275,12 @@ :/icons/table_edit.png:/icons/table_edit.png + + + 16 + 16 + + false @@ -283,6 +301,12 @@ :/icons/cross.png:/icons/cross.png + + + 16 + 16 + + false @@ -319,6 +343,7 @@ + diff --git a/gui/ProcessingDialog.ui b/gui/ProcessingDialog.ui index 2fdf7939..1f37b2f9 100644 --- a/gui/ProcessingDialog.ui +++ b/gui/ProcessingDialog.ui @@ -390,6 +390,12 @@ :/icons/cancel.png:/icons/cancel.png + + + 16 + 16 + + @@ -407,6 +413,12 @@ :/icons/accept.png:/icons/accept.png + + + 16 + 16 + + @@ -438,6 +450,8 @@ + + diff --git a/gui/UpdateDialog.ui b/gui/UpdateDialog.ui index b3e3c090..5e01a3f3 100644 --- a/gui/UpdateDialog.ui +++ b/gui/UpdateDialog.ui @@ -374,6 +374,12 @@ :/icons/arrow_refresh.png:/icons/arrow_refresh.png + + + 16 + 16 + + @@ -391,6 +397,12 @@ :/icons/application_view_list.png:/icons/application_view_list.png + + + 16 + 16 + + @@ -473,6 +485,12 @@ :/icons/accept.png:/icons/accept.png + + + 16 + 16 + + @@ -490,6 +508,12 @@ :/icons/cross.png:/icons/cross.png + + + 16 + 16 + + @@ -559,6 +583,8 @@ + + diff --git a/src/Config.h b/src/Config.h index 37347154..dfaddec4 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 300 +#define VER_LAMEXP_BUILD 302 #define VER_LAMEXP_SUFFIX Beta-4 /* diff --git a/src/Dialog_About.cpp b/src/Dialog_About.cpp index 5874144a..adcb9136 100644 --- a/src/Dialog_About.cpp +++ b/src/Dialog_About.cpp @@ -104,16 +104,19 @@ AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstSta { QPushButton *firstButton = addButton(tr("Show License Text"), QMessageBox::AcceptRole); firstButton->setIcon(QIcon(":/icons/script.png")); + firstButton->setIconSize(QSize(16, 16)); firstButton->setMinimumWidth(135); firstButton->disconnect(); connect(firstButton, SIGNAL(clicked()), this, SLOT(openLicenseText())); QPushButton *secondButton = addButton(tr("Accept License"), QMessageBox::AcceptRole); secondButton->setIcon(QIcon(":/icons/accept.png")); + secondButton->setIconSize(QSize(16, 16)); secondButton->setMinimumWidth(120); QPushButton *thirdButton = addButton(tr("Decline License"), QMessageBox::AcceptRole); thirdButton->setIcon(QIcon(":/icons/delete.png")); + thirdButton->setIconSize(QSize(16, 16)); thirdButton->setMinimumWidth(120); thirdButton->setEnabled(false); } @@ -121,24 +124,28 @@ AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstSta { QPushButton *firstButton = addButton(tr("3rd Party S/W"), QMessageBox::AcceptRole); firstButton->setIcon(QIcon(":/icons/page_white_cplusplus.png")); + firstButton->setIconSize(QSize(16, 16)); firstButton->setMinimumWidth(120); firstButton->disconnect(); connect(firstButton, SIGNAL(clicked()), this, SLOT(showMoreAbout())); QPushButton *secondButton = addButton(tr("Contributors"), QMessageBox::AcceptRole); secondButton->setIcon(QIcon(":icons/user_suit.png")); + secondButton->setIconSize(QSize(16, 16)); secondButton->setMinimumWidth(120); secondButton->disconnect(); connect(secondButton, SIGNAL(clicked()), this, SLOT(showAboutContributors())); QPushButton *thirdButton = addButton(tr("About Qt4"), QMessageBox::AcceptRole); thirdButton->setIcon(QIcon(":/images/Qt.svg")); + thirdButton->setIconSize(QSize(16, 16)); thirdButton->setMinimumWidth(120); thirdButton->disconnect(); connect(thirdButton, SIGNAL(clicked()), this, SLOT(showAboutQt())); QPushButton *fourthButton = addButton(tr("Discard"), QMessageBox::AcceptRole); fourthButton->setIcon(QIcon(":/icons/cross.png")); + fourthButton->setIconSize(QSize(16, 16)); fourthButton->setMinimumWidth(90); } diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index 7b20ae50..132cc655 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -168,6 +168,7 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S //Setup "Meta Data" tab m_metaInfoModel = new MetaInfoModel(m_metaData, 6); m_metaInfoModel->clearData(); + m_metaInfoModel->setData(m_metaInfoModel->index(4, 1), m_settings->metaInfoPosition()); metaDataView->setModel(m_metaInfoModel); metaDataView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); metaDataView->verticalHeader()->hide(); @@ -574,6 +575,7 @@ void MainWindow::changeEvent(QEvent *e) //Force GUI update m_metaInfoModel->clearData(); + m_metaInfoModel->setData(m_metaInfoModel->index(4, 1), m_settings->metaInfoPosition()); updateEncoder(m_settings->compressionEncoder()); updateLameAlgoQuality(sliderLameAlgoQuality->value()); @@ -1406,7 +1408,14 @@ void MainWindow::makeFolderButtonClicked(void) void MainWindow::editMetaButtonClicked(void) { ABORT_IF_BUSY; - m_metaInfoModel->editItem(metaDataView->currentIndex(), this); + + const QModelIndex index = metaDataView->currentIndex(); + m_metaInfoModel->editItem(index, this); + + if(index.row() == 4) + { + m_settings->metaInfoPosition(m_metaData->filePosition()); + } } /* diff --git a/src/Model_MetaInfo.cpp b/src/Model_MetaInfo.cpp index fe985e9d..104bd216 100644 --- a/src/Model_MetaInfo.cpp +++ b/src/Model_MetaInfo.cpp @@ -244,6 +244,56 @@ QVariant MetaInfoModel::headerData(int section, Qt::Orientation orientation, int } } +bool MetaInfoModel::setData (const QModelIndex &index, const QVariant &value, int role) +{ + if((role != Qt::EditRole) || (index.column() != 1) || !value.isValid()) + { + return false; + } + + switch(index.row() + m_offset) + { + case 0: + m_audioFile->setFilePath(value.toString()); + break; + case 1: + case 2: + case 3: + return false; + break; + case 4: + m_audioFile->setFileDuration(value.toUInt()); + break; + case 5: + m_audioFile->setFileName(value.toString()); + break; + case 6: + m_audioFile->setFileArtist(value.toString()); + break; + case 7: + m_audioFile->setFileAlbum(value.toString()); + break; + case 8: + m_audioFile->setFileGenre(value.toString()); + break; + case 9: + m_audioFile->setFileYear(value.toUInt()); + break; + case 10: + m_audioFile->setFilePosition(value.toUInt()); + break; + case 11: + m_audioFile->setFileComment(value.toString()); + break; + default: + return false; + break; + } + + emit dataChanged(index, index); + return true; +} + void MetaInfoModel::editItem(const QModelIndex &index, QWidget *parent) { bool ok = false; diff --git a/src/Model_MetaInfo.h b/src/Model_MetaInfo.h index ff030228..74711092 100644 --- a/src/Model_MetaInfo.h +++ b/src/Model_MetaInfo.h @@ -39,6 +39,7 @@ public: int rowCount(const QModelIndex &parent = QModelIndex()) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + bool setData (const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); Qt::ItemFlags flags(const QModelIndex &index) const; void editItem(const QModelIndex &index, QWidget *parent); void clearData(void); diff --git a/src/Model_Settings.cpp b/src/Model_Settings.cpp index 039c549d..46962aa0 100644 --- a/src/Model_Settings.cpp +++ b/src/Model_Settings.cpp @@ -32,44 +32,11 @@ #include #include -//Constants -static const char *g_settingsId_versionNumber = "VersionNumber"; -static const char *g_settingsId_licenseAccepted = "LicenseAccepted"; -static const char *g_settingsId_interfaceStyle = "InterfaceStyle"; -static const char *g_settingsId_compressionEncoder = "Compression/Encoder"; -static const char *g_settingsId_compressionRCMode = "Compression/RCMode"; -static const char *g_settingsId_compressionBitrate = "Compression/Bitrate"; -static const char *g_settingsId_outputDir = "OutputDirectory/SelectedPath"; -static const char *g_settingsId_outputToSourceDir = "OutputDirectory/OutputToSourceFolder"; -static const char *g_settingsId_prependRelativeSourcePath = "OutputDirectory/PrependRelativeSourcePath"; -static const char *g_settingsId_writeMetaTags = "Flags/WriteMetaTags"; -static const char *g_settingsId_createPlaylist = "Flags/AutoCreatePlaylist"; -static const char *g_settingsId_autoUpdateLastCheck = "AutoUpdate/LastCheck"; -static const char *g_settingsId_autoUpdateEnabled = "AutoUpdate/Enabled"; -static const char *g_settingsId_soundsEnabled = "Flags/EnableSounds"; -static const char *g_settingsId_neroAacNotificationsEnabled = "Flags/EnableNeroAacNotifications"; -static const char *g_settingsId_wmaDecoderNotificationsEnabled = "Flags/EnableWmaDecoderNotifications"; -static const char *g_settingsId_dropBoxWidgetEnabled = "Flags/EnableDropBoxWidget"; -static const char *g_settingsId_shellIntegrationEnabled = "Flags/EnableShellIntegration"; -static const char *g_settingsId_currentLanguage = "Localization/Language"; -static const char *g_settingsId_lameAlgoQuality = "AdvancedOptions/LAME/AlgorithmQuality"; -static const char *g_settingsId_lameChannelMode = "AdvancedOptions/LAME/ChannelMode"; -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"; -static const char *g_settingsId_samplingRate = "AdvancedOptions/Common/Resampling"; -static const char *g_settingsId_neroAACEnable2Pass = "AdvancedOptions/NeroAAC/Enable2Pass"; -static const char *g_settingsId_neroAACProfile = "AdvancedOptions/NeroAAC/ForceProfile"; -static const char *g_settingsId_normalizationFilterEnabled = "AdvancedOptions/VolumeNormalization/Enabled"; -static const char *g_settingsId_normalizationFilterMaxVolume = "AdvancedOptions/VolumeNormalization/MaxVolume"; -static const char *g_settingsId_toneAdjustBass = "AdvancedOptions/ToneAdjustment/Bass"; -static const char *g_settingsId_toneAdjustTreble = "AdvancedOptions/ToneAdjustment/Treble"; -static const char *g_settingsId_customParametersLAME = "AdvancedOptions/CustomParameters/LAME"; -static const char *g_settingsId_customParametersOggEnc = "AdvancedOptions/CustomParameters/OggEnc"; -static const char *g_settingsId_customParametersNeroAAC = "AdvancedOptions/CustomParameters/NeroAAC"; -static const char *g_settingsId_customParametersFLAC = "AdvancedOptions/CustomParameters/FLAC"; +//////////////////////////////////////////////////////////// //Macros +//////////////////////////////////////////////////////////// + #define MAKE_OPTION1(OPT,DEF) \ int SettingsModel::OPT(void) { return m_settings->value(g_settingsId_##OPT, DEF).toInt(); } \ void SettingsModel::OPT(int value) { m_settings->setValue(g_settingsId_##OPT, value); } \ @@ -85,6 +52,55 @@ bool SettingsModel::OPT(void) { return m_settings->value(g_settingsId_##OPT, DEF void SettingsModel::OPT(bool value) { m_settings->setValue(g_settingsId_##OPT, value); } \ bool SettingsModel::OPT##Default(void) { return DEF; } +#define MAKE_OPTION4(OPT,DEF) \ +unsigned int SettingsModel::OPT(void) { return m_settings->value(g_settingsId_##OPT, DEF).toUInt(); } \ +void SettingsModel::OPT(unsigned int value) { m_settings->setValue(g_settingsId_##OPT, value); } \ +unsigned int SettingsModel::OPT##Default(void) { return DEF; } + +#define MAKE_ID(DEC,STR) static const char *g_settingsId_##DEC = STR + +//////////////////////////////////////////////////////////// +//Constants +//////////////////////////////////////////////////////////// + +//Setting ID's +MAKE_ID(versionNumber, "VersionNumber"); +MAKE_ID(licenseAccepted, "LicenseAccepted"); +MAKE_ID(interfaceStyle, "InterfaceStyle"); +MAKE_ID(compressionEncoder, "Compression/Encoder"); +MAKE_ID(compressionRCMode, "Compression/RCMode"); +MAKE_ID(compressionBitrate, "Compression/Bitrate"); +MAKE_ID(outputDir, "OutputDirectory/SelectedPath"); +MAKE_ID(outputToSourceDir, "OutputDirectory/OutputToSourceFolder"); +MAKE_ID(prependRelativeSourcePath, "OutputDirectory/PrependRelativeSourcePath"); +MAKE_ID(writeMetaTags, "Flags/WriteMetaTags"); +MAKE_ID(createPlaylist, "Flags/AutoCreatePlaylist"); +MAKE_ID(autoUpdateLastCheck, "AutoUpdate/LastCheck"); +MAKE_ID(autoUpdateEnabled, "AutoUpdate/Enabled"); +MAKE_ID(soundsEnabled, "Flags/EnableSounds"); +MAKE_ID(neroAacNotificationsEnabled, "Flags/EnableNeroAacNotifications"); +MAKE_ID(wmaDecoderNotificationsEnabled, "Flags/EnableWmaDecoderNotifications"); +MAKE_ID(dropBoxWidgetEnabled, "Flags/EnableDropBoxWidget"); +MAKE_ID(shellIntegrationEnabled, "Flags/EnableShellIntegration"); +MAKE_ID(currentLanguage, "Localization/Language"); +MAKE_ID(lameAlgoQuality, "AdvancedOptions/LAME/AlgorithmQuality"); +MAKE_ID(lameChannelMode, "AdvancedOptions/LAME/ChannelMode"); +MAKE_ID(bitrateManagementEnabled, "AdvancedOptions/BitrateManagement/Enabled"); +MAKE_ID(bitrateManagementMinRate, "AdvancedOptions/BitrateManagement/MinRate"); +MAKE_ID(bitrateManagementMaxRate, "AdvancedOptions/BitrateManagement/MaxRate"); +MAKE_ID(samplingRate, "AdvancedOptions/Common/Resampling"); +MAKE_ID(neroAACEnable2Pass, "AdvancedOptions/NeroAAC/Enable2Pass"); +MAKE_ID(neroAACProfile, "AdvancedOptions/NeroAAC/ForceProfile"); +MAKE_ID(normalizationFilterEnabled, "AdvancedOptions/VolumeNormalization/Enabled"); +MAKE_ID(normalizationFilterMaxVolume, "AdvancedOptions/VolumeNormalization/MaxVolume"); +MAKE_ID(toneAdjustBass, "AdvancedOptions/ToneAdjustment/Bass"); +MAKE_ID(toneAdjustTreble, "AdvancedOptions/ToneAdjustment/Treble"); +MAKE_ID(customParametersLAME, "AdvancedOptions/CustomParameters/LAME"); +MAKE_ID(customParametersOggEnc, "AdvancedOptions/CustomParameters/OggEnc"); +MAKE_ID(customParametersNeroAAC, "AdvancedOptions/CustomParameters/NeroAAC"); +MAKE_ID(customParametersFLAC, "AdvancedOptions/CustomParameters/FLAC"); +MAKE_ID(metaInfoPosition, "MetaInformation/PlaylistPosition"); + //LUT const int SettingsModel::mp3Bitrates[15] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, -1}; const int SettingsModel::samplingRates[8] = {0, 16000, 22050, 24000, 32000, 44100, 48000, -1}; @@ -241,3 +257,4 @@ MAKE_OPTION2(customParametersLAME, QString()); MAKE_OPTION2(customParametersOggEnc, QString()); MAKE_OPTION2(customParametersNeroAAC, QString()); MAKE_OPTION2(customParametersFLAC, QString()); +MAKE_OPTION4(metaInfoPosition, UINT_MAX); diff --git a/src/Model_Settings.h b/src/Model_Settings.h index 655324e5..7c4b5c92 100644 --- a/src/Model_Settings.h +++ b/src/Model_Settings.h @@ -24,6 +24,8 @@ class QSettings; class QString; +/////////////////////////////////////////////////////////////////////////////// + #define MAKE_OPTION_DEC1(OPT) \ int OPT(void); \ void OPT(int value); \ @@ -39,6 +41,13 @@ bool OPT(void); \ void OPT(bool value); \ bool OPT##Default(void); +#define MAKE_OPTION_DEC4(OPT) \ +unsigned int OPT(void); \ +void OPT(unsigned int value); \ +unsigned int OPT##Default(void); + +/////////////////////////////////////////////////////////////////////////////// + class SettingsModel { public: @@ -100,6 +109,7 @@ public: MAKE_OPTION_DEC2(customParametersOggEnc); MAKE_OPTION_DEC2(customParametersNeroAAC); MAKE_OPTION_DEC2(customParametersFLAC); + MAKE_OPTION_DEC4(metaInfoPosition); //Misc void validate(void); @@ -110,6 +120,9 @@ private: QString defaultLanguage(void); }; +/////////////////////////////////////////////////////////////////////////////// + #undef MAKE_OPTION_DEC1 #undef MAKE_OPTION_DEC2 #undef MAKE_OPTION_DEC3 +#undef MAKE_OPTION_DEC4