Implemented file extension replacement model + moved extension() function from AbstractEncoder class to AbstractEncoderInfo class.
This commit is contained in:
parent
e35aff3907
commit
def8a9cd6e
@ -324,6 +324,7 @@ copy /Y "$(SolutionDir)\..\Prerequisites\VisualLeakDetector\bin\Win32\*.manifest
|
||||
<ClCompile Include="src\Model_Artwork.cpp" />
|
||||
<ClCompile Include="src\Model_AudioFile.cpp" />
|
||||
<ClCompile Include="src\Model_CueSheet.cpp" />
|
||||
<ClCompile Include="src\Model_FileExts.cpp" />
|
||||
<ClCompile Include="src\Model_FileList.cpp" />
|
||||
<ClCompile Include="src\Model_FileSystem.cpp" />
|
||||
<ClCompile Include="src\Model_MetaInfo.cpp" />
|
||||
@ -373,6 +374,7 @@ copy /Y "$(SolutionDir)\..\Prerequisites\VisualLeakDetector\bin\Win32\*.manifest
|
||||
<ClCompile Include="tmp\LameXP\MOC_Filter_Abstract.cpp" />
|
||||
<ClCompile Include="tmp\LameXP\MOC_Model_AudioFile.cpp" />
|
||||
<ClCompile Include="tmp\LameXP\MOC_Model_CueSheet.cpp" />
|
||||
<ClCompile Include="tmp\LameXP\MOC_Model_FileExts.cpp" />
|
||||
<ClCompile Include="tmp\LameXP\MOC_Model_FileList.cpp" />
|
||||
<ClCompile Include="tmp\LameXP\MOC_Model_MetaInfo.cpp" />
|
||||
<ClCompile Include="tmp\LameXP\MOC_Model_Progress.cpp" />
|
||||
@ -421,6 +423,17 @@ copy /Y "$(SolutionDir)\..\Prerequisites\VisualLeakDetector\bin\Win32\*.manifest
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp;%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
<ClInclude Include="src\IPCCommands.h" />
|
||||
<CustomBuild Include="src\Model_FileExts.h">
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MOC "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp"</Message>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">MOC "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp"</Message>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MOC "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp"</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp;%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
<ClInclude Include="tmp\LameXP\UIC_AboutDialog.h" />
|
||||
<ClInclude Include="tmp\LameXP\UIC_CueSheetImport.h" />
|
||||
<ClInclude Include="tmp\LameXP\UIC_DropBox.h" />
|
||||
|
@ -415,6 +415,12 @@
|
||||
<ClCompile Include="tmp\LameXP\MOC_Encoder_AAC_FDK.cpp">
|
||||
<Filter>Generated Files\MOC</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Model_FileExts.cpp">
|
||||
<Filter>Source Files\Models</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="tmp\LameXP\MOC_Model_FileExts.cpp">
|
||||
<Filter>Generated Files\MOC</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\Config.h">
|
||||
@ -761,6 +767,9 @@
|
||||
<CustomBuild Include="src\Encoder_AAC_FDK.h">
|
||||
<Filter>Header Files\Encoders</Filter>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="src\Model_FileExts.h">
|
||||
<Filter>Header Files\Models</Filter>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ReadMe.txt" />
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -31,7 +31,7 @@
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
<message numerus="yes">
|
||||
<location filename="../../src/Dialog_MainWindow.cpp" line="834"/>
|
||||
<location filename="../../src/Dialog_MainWindow.cpp" line="844"/>
|
||||
<source>%n file(s) have been rejected, because read access was not granted!</source>
|
||||
<translation>
|
||||
<numerusform>%n file have been rejected, because read access was not granted!</numerusform>
|
||||
@ -39,7 +39,7 @@
|
||||
</translation>
|
||||
</message>
|
||||
<message numerus="yes">
|
||||
<location filename="../../src/Dialog_MainWindow.cpp" line="838"/>
|
||||
<location filename="../../src/Dialog_MainWindow.cpp" line="848"/>
|
||||
<source>%n file(s) have been rejected, because they are dummy CDDA files!</source>
|
||||
<translation>
|
||||
<numerusform>%n file have been rejected, because they are dummy CDDA files!</numerusform>
|
||||
@ -47,7 +47,7 @@
|
||||
</translation>
|
||||
</message>
|
||||
<message numerus="yes">
|
||||
<location filename="../../src/Dialog_MainWindow.cpp" line="842"/>
|
||||
<location filename="../../src/Dialog_MainWindow.cpp" line="852"/>
|
||||
<source>%n file(s) have been rejected, because they appear to be Cue Sheet images!</source>
|
||||
<translation>
|
||||
<numerusform>%n file have been rejected, because they appear to be Cue Sheet images!</numerusform>
|
||||
@ -55,7 +55,7 @@
|
||||
</translation>
|
||||
</message>
|
||||
<message numerus="yes">
|
||||
<location filename="../../src/Dialog_MainWindow.cpp" line="846"/>
|
||||
<location filename="../../src/Dialog_MainWindow.cpp" line="856"/>
|
||||
<source>%n file(s) have been rejected, because the file format could not be recognized!</source>
|
||||
<translation>
|
||||
<numerusform>%n file have been rejected, because the file format could not be recognized!</numerusform>
|
||||
@ -63,7 +63,7 @@
|
||||
</translation>
|
||||
</message>
|
||||
<message numerus="yes">
|
||||
<location filename="../../src/Dialog_MainWindow.cpp" line="4083"/>
|
||||
<location filename="../../src/Dialog_MainWindow.cpp" line="4125"/>
|
||||
<source>%n Instance(s)</source>
|
||||
<translation>
|
||||
<numerusform>%n Instance</numerusform>
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -3949,7 +3949,81 @@
|
||||
<widget class="QWidget" name="pageRename_FileEx">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<widget class="QListView" name="listView"/>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTableView" name="tableViewFileExts">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Ignored">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="cornerButtonEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderHighlightSections">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderHighlightSections">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_14">
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonFileExts_Add">
|
||||
<property name="text">
|
||||
<string>Add Overwrite </string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../res/Icons.qrc">
|
||||
<normaloff>:/icons/add.png</normaloff>:/icons/add.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonFileExts_Remove">
|
||||
<property name="text">
|
||||
<string>Remove Overwrite </string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../res/Icons.qrc">
|
||||
<normaloff>:/icons/delete.png</normaloff>:/icons/delete.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_72">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -113,6 +113,7 @@
|
||||
<file>icons/table_edit.png</file>
|
||||
<file>icons/table_save.png</file>
|
||||
<file>icons/tag_blue.png</file>
|
||||
<file>icons/tag_red.png</file>
|
||||
<file>icons/tick.png</file>
|
||||
<file>icons/timeline_marker.png</file>
|
||||
<file>icons/transmit.png</file>
|
||||
|
@ -35,7 +35,7 @@
|
||||
#define VER_LAMEXP_MINOR_LO 2
|
||||
#define VER_LAMEXP_TYPE Alpha
|
||||
#define VER_LAMEXP_PATCH 2
|
||||
#define VER_LAMEXP_BUILD 1725
|
||||
#define VER_LAMEXP_BUILD 1729
|
||||
#define VER_LAMEXP_CONFG 1700
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "Model_Settings.h"
|
||||
#include "Model_FileList.h"
|
||||
#include "Model_FileSystem.h"
|
||||
#include "Model_FileExts.h"
|
||||
#include "Registry_Encoder.h"
|
||||
#include "Registry_Decoder.h"
|
||||
#include "Encoder_Abstract.h"
|
||||
@ -288,7 +289,7 @@ MainWindow::MainWindow(MUtils::IPCChannel *const ipcChannel, FileListModel *cons
|
||||
//--------------------------------
|
||||
|
||||
ui->sourceFileView->setModel(m_fileListModel);
|
||||
ui->sourceFileView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
|
||||
ui->sourceFileView->verticalHeader() ->setResizeMode(QHeaderView::ResizeToContents);
|
||||
ui->sourceFileView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
|
||||
ui->sourceFileView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
ui->sourceFileView->viewport()->installEventFilter(this);
|
||||
@ -522,6 +523,12 @@ MainWindow::MainWindow(MUtils::IPCChannel *const ipcChannel, FileListModel *cons
|
||||
ui->radioButtonOverwriteModeSkipFile->setChecked(m_settings->overwriteMode() == SettingsModel::Overwrite_SkipFile);
|
||||
ui->radioButtonOverwriteModeReplaces->setChecked(m_settings->overwriteMode() == SettingsModel::Overwrite_Replaces);
|
||||
|
||||
FileExtsModel *fileExtModel = new FileExtsModel(this);
|
||||
fileExtModel->importItems(m_settings->renameFiles_fileExtension());
|
||||
ui->tableViewFileExts->setModel(fileExtModel);
|
||||
ui->tableViewFileExts->verticalHeader() ->setResizeMode(QHeaderView::ResizeToContents);
|
||||
ui->tableViewFileExts->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
|
||||
|
||||
connect(ui->sliderLameAlgoQuality, SIGNAL(valueChanged(int)), this, SLOT(updateLameAlgoQuality(int)));
|
||||
connect(ui->checkBoxBitrateManagement, SIGNAL(clicked(bool)), this, SLOT(bitrateManagementEnabledChanged(bool)));
|
||||
connect(ui->spinBoxBitrateManagementMin, SIGNAL(valueChanged(int)), this, SLOT(bitrateManagementMinChanged(int)));
|
||||
@ -572,8 +579,11 @@ MainWindow::MainWindow(MUtils::IPCChannel *const ipcChannel, FileListModel *cons
|
||||
connect(ui->buttonRename_Rename, SIGNAL(clicked(bool)), this, SLOT(renameButtonClicked(bool)));
|
||||
connect(ui->buttonRename_RegExp, SIGNAL(clicked(bool)), this, SLOT(renameButtonClicked(bool)));
|
||||
connect(ui->buttonRename_FileEx, SIGNAL(clicked(bool)), this, SLOT(renameButtonClicked(bool)));
|
||||
connect(ui->buttonFileExts_Add, SIGNAL(clicked()), this, SLOT(fileExtAddButtonClicked()));
|
||||
connect(ui->buttonFileExts_Remove, SIGNAL(clicked()), this, SLOT(fileExtRemoveButtonClicked()));
|
||||
connect(m_overwriteButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(overwriteModeChanged(int)));
|
||||
connect(m_evenFilterCustumParamsHelp, SIGNAL(eventOccurred(QWidget*, QEvent*)), this, SLOT(customParamsHelpRequested(QWidget*, QEvent*)));
|
||||
connect(fileExtModel, SIGNAL(modelReset()), this, SLOT(fileExtModelChanged()));
|
||||
|
||||
//--------------------------------
|
||||
// Force initial GUI update
|
||||
@ -4070,6 +4080,38 @@ void MainWindow::showRenameMacros(const QString &text)
|
||||
QMessageBox::information(this, tr("Rename Macros"), message, tr("Discard"));
|
||||
}
|
||||
|
||||
void MainWindow::fileExtAddButtonClicked(void)
|
||||
{
|
||||
if(FileExtsModel *const model = dynamic_cast<FileExtsModel*>(ui->tableViewFileExts->model()))
|
||||
{
|
||||
model->addOverwrite(this);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::fileExtRemoveButtonClicked(void)
|
||||
{
|
||||
if(FileExtsModel *const model = dynamic_cast<FileExtsModel*>(ui->tableViewFileExts->model()))
|
||||
{
|
||||
const QModelIndex selected = ui->tableViewFileExts->currentIndex();
|
||||
if(selected.isValid())
|
||||
{
|
||||
model->removeOverwrite(selected);
|
||||
}
|
||||
else
|
||||
{
|
||||
MUtils::Sound::beep(MUtils::Sound::BEEP_ERR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::fileExtModelChanged(void)
|
||||
{
|
||||
if(FileExtsModel *const model = dynamic_cast<FileExtsModel*>(ui->tableViewFileExts->model()))
|
||||
{
|
||||
m_settings->renameFiles_fileExtension(model->exportItems());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::forceStereoDownmixEnabledChanged(bool checked)
|
||||
{
|
||||
m_settings->forceStereoDownmix(checked);
|
||||
@ -4308,6 +4350,11 @@ void MainWindow::resetAdvancedOptionsButtonClicked(void)
|
||||
if(m_settings->overwriteModeDefault() == SettingsModel::Overwrite_SkipFile) ui->radioButtonOverwriteModeSkipFile->click();
|
||||
if(m_settings->overwriteModeDefault() == SettingsModel::Overwrite_Replaces) ui->radioButtonOverwriteModeReplaces->click();
|
||||
|
||||
if(FileExtsModel *const model = dynamic_cast<FileExtsModel*>(ui->tableViewFileExts->model()))
|
||||
{
|
||||
model->importItems(m_settings->renameFiles_fileExtensionDefault());
|
||||
}
|
||||
|
||||
ui->scrollArea->verticalScrollBar()->setValue(0);
|
||||
ui->buttonRename_Rename->click();
|
||||
customParamsChanged();
|
||||
|
@ -106,6 +106,9 @@ private slots:
|
||||
void encodeButtonClicked(void);
|
||||
void exportCsvContextActionTriggered(void);
|
||||
void fileDownButtonClicked(void);
|
||||
void fileExtAddButtonClicked();
|
||||
void fileExtModelChanged();
|
||||
void fileExtRemoveButtonClicked();
|
||||
void fileUpButtonClicked(void);
|
||||
void findFileContextActionTriggered(void);
|
||||
void forceStereoDownmixEnabledChanged(bool checked);
|
||||
|
@ -108,6 +108,12 @@ class AACEncoderInfo : public AbstractEncoderInfo
|
||||
static const char* s_description = "Nero AAC Encoder (\x0C2\x0A9 Nero AG)";
|
||||
return s_description;
|
||||
}
|
||||
|
||||
virtual const char *extension(void) const
|
||||
{
|
||||
static const char* s_extension = "mp4";
|
||||
return s_extension;
|
||||
}
|
||||
}
|
||||
static const g_aacEncoderInfo;
|
||||
|
||||
@ -346,11 +352,6 @@ bool AACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
|
||||
return true;
|
||||
}
|
||||
|
||||
QString AACEncoder::extension(void)
|
||||
{
|
||||
return "mp4";
|
||||
}
|
||||
|
||||
bool AACEncoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("Wave", Qt::CaseInsensitive) == 0)
|
||||
|
@ -36,7 +36,6 @@ public:
|
||||
|
||||
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const QString &outputFile, volatile bool *abortFlag);
|
||||
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
|
||||
virtual QString extension(void);
|
||||
virtual const bool needsTimingInfo(void);
|
||||
|
||||
//Advanced options
|
||||
|
@ -114,6 +114,12 @@ class FDKAACEncoderInfo : public AbstractEncoderInfo
|
||||
static const char* s_description = "fdkaac (libfdk-aac encoder)";
|
||||
return s_description;
|
||||
}
|
||||
|
||||
virtual const char *extension(void) const
|
||||
{
|
||||
static const char* s_extension = "mp4";
|
||||
return s_extension;
|
||||
}
|
||||
}
|
||||
static const g_fdkAacEncoderInfo;
|
||||
|
||||
@ -255,11 +261,6 @@ bool FDKAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaI
|
||||
return true;
|
||||
}
|
||||
|
||||
QString FDKAACEncoder::extension(void)
|
||||
{
|
||||
return "mp4";
|
||||
}
|
||||
|
||||
bool FDKAACEncoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("Wave", Qt::CaseInsensitive) == 0)
|
||||
|
@ -36,7 +36,6 @@ public:
|
||||
|
||||
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const QString &outputFile, volatile bool *abortFlag);
|
||||
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
|
||||
virtual QString extension(void);
|
||||
|
||||
//Advanced options
|
||||
virtual void setProfile(int profile);
|
||||
|
@ -111,6 +111,12 @@ class FHGAACEncoderInfo : public AbstractEncoderInfo
|
||||
static const char* s_description = "fhgaacenc/Winamp (\x0C2\x0A9 Nullsoft)";
|
||||
return s_description;
|
||||
}
|
||||
|
||||
virtual const char *extension(void) const
|
||||
{
|
||||
static const char* s_extension = "mp4";
|
||||
return s_extension;
|
||||
}
|
||||
}
|
||||
static const g_fhgAacEncoderInfo;
|
||||
|
||||
@ -248,11 +254,6 @@ bool FHGAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaI
|
||||
return true;
|
||||
}
|
||||
|
||||
QString FHGAACEncoder::extension(void)
|
||||
{
|
||||
return "mp4";
|
||||
}
|
||||
|
||||
bool FHGAACEncoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("Wave", Qt::CaseInsensitive) == 0)
|
||||
|
@ -36,7 +36,6 @@ public:
|
||||
|
||||
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const QString &outputFile, volatile bool *abortFlag);
|
||||
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
|
||||
virtual QString extension(void);
|
||||
virtual const unsigned int *supportedChannelCount(void);
|
||||
virtual const unsigned int *supportedBitdepths(void);
|
||||
virtual const unsigned int *supportedSamplerates(void);
|
||||
|
@ -119,6 +119,12 @@ class QAACEncoderInfo : public AbstractEncoderInfo
|
||||
static const char* s_description = "QAAC/QuickTime (\x0C2\x0A9 Apple Inc.)";
|
||||
return s_description;
|
||||
}
|
||||
|
||||
virtual const char *extension(void) const
|
||||
{
|
||||
static const char* s_extension = "mp4";
|
||||
return s_extension;
|
||||
}
|
||||
}
|
||||
static const g_qaacEncoderInfo;
|
||||
|
||||
@ -265,11 +271,6 @@ bool QAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf
|
||||
return true;
|
||||
}
|
||||
|
||||
QString QAACEncoder::extension(void)
|
||||
{
|
||||
return "mp4";
|
||||
}
|
||||
|
||||
bool QAACEncoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("Wave", Qt::CaseInsensitive) == 0)
|
||||
|
@ -36,7 +36,6 @@ public:
|
||||
|
||||
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const QString &outputFile, volatile bool *abortFlag);
|
||||
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
|
||||
virtual QString extension(void);
|
||||
|
||||
//Advanced options
|
||||
virtual void setProfile(int profile);
|
||||
|
@ -107,6 +107,12 @@ class AC3EncoderInfo : public AbstractEncoderInfo
|
||||
static const char* s_description = "Aften: A/52 Audio Encoder";
|
||||
return s_description;
|
||||
}
|
||||
|
||||
virtual const char *extension(void) const
|
||||
{
|
||||
static const char* s_extension = "ac3";
|
||||
return s_extension;
|
||||
}
|
||||
}
|
||||
static const g_aftenEncoderInfo;
|
||||
|
||||
@ -261,11 +267,6 @@ void AC3Encoder::setFastBitAllocation(bool value)
|
||||
m_configFastBitAllocation = value;
|
||||
}
|
||||
|
||||
QString AC3Encoder::extension(void)
|
||||
{
|
||||
return "ac3";
|
||||
}
|
||||
|
||||
const unsigned int *AC3Encoder::supportedChannelCount(void)
|
||||
{
|
||||
static const unsigned int supportedChannels[] = {1, 2, 3, 4, 5, 6, NULL};
|
||||
|
@ -36,7 +36,6 @@ public:
|
||||
|
||||
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const QString &outputFile, volatile bool *abortFlag);
|
||||
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
|
||||
virtual QString extension(void);
|
||||
virtual const unsigned int *supportedChannelCount(void);
|
||||
virtual const unsigned int *supportedSamplerates(void);
|
||||
|
||||
|
@ -48,11 +48,12 @@ public:
|
||||
}
|
||||
value_type_t;
|
||||
|
||||
virtual bool isModeSupported(int mode) const = 0; //Returns whether the encoder does support the current RC mode
|
||||
virtual int valueCount(int mode) const = 0; //The number of bitrate/quality values for current RC mode
|
||||
virtual bool isModeSupported(int mode) const = 0; //Returns whether the encoder does support the current RC mode
|
||||
virtual int valueCount(int mode) const = 0; //The number of bitrate/quality values for current RC mode
|
||||
virtual int valueAt(int mode, int index) const = 0; //The bitrate/quality value at 'index' for the current RC mode
|
||||
virtual int valueType(int mode) const = 0; //The display type of the values for the current RC mode
|
||||
virtual const char* description(void) const = 0; //Description of the encoder that can be displayed to the user
|
||||
virtual int valueType(int mode) const = 0; //The display type of the values for the current RC mode
|
||||
virtual const char* description(void) const = 0; //Description of the encoder that can be displayed to the user
|
||||
virtual const char* extension(void) const = 0; //The default file extension for files created by this encoder
|
||||
};
|
||||
|
||||
class AbstractEncoder : public AbstractTool
|
||||
@ -66,7 +67,6 @@ public:
|
||||
//Internal encoder API
|
||||
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const QString &outputFile, volatile bool *abortFlag) = 0;
|
||||
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion) = 0;
|
||||
virtual QString extension(void) = 0;
|
||||
virtual const unsigned int *supportedSamplerates(void);
|
||||
virtual const unsigned int *supportedChannelCount(void);
|
||||
virtual const unsigned int *supportedBitdepths(void);
|
||||
|
@ -109,6 +109,12 @@ class DCAEncoderInfo : public AbstractEncoderInfo
|
||||
static const char* s_description = "dcaenc-2 by Alexander E. Patrakov";
|
||||
return s_description;
|
||||
}
|
||||
|
||||
virtual const char *extension(void) const
|
||||
{
|
||||
static const char* s_extension = "dts";
|
||||
return s_extension;
|
||||
}
|
||||
}
|
||||
static const g_dcaEncoderInfo;
|
||||
|
||||
@ -207,11 +213,6 @@ bool DCAEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
|
||||
return true;
|
||||
}
|
||||
|
||||
QString DCAEncoder::extension(void)
|
||||
{
|
||||
return "dts";
|
||||
}
|
||||
|
||||
bool DCAEncoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("Wave", Qt::CaseInsensitive) == 0)
|
||||
|
@ -36,7 +36,6 @@ public:
|
||||
|
||||
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const QString &outputFile, volatile bool *abortFlag);
|
||||
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
|
||||
virtual QString extension(void);
|
||||
virtual const unsigned int *supportedChannelCount(void);
|
||||
virtual const unsigned int *supportedBitdepths(void);
|
||||
virtual const unsigned int *supportedSamplerates(void);
|
||||
|
@ -103,6 +103,12 @@ public:
|
||||
static const char* s_description = "Free Lossless Audio Codec (FLAC)";
|
||||
return s_description;
|
||||
}
|
||||
|
||||
virtual const char *extension(void) const
|
||||
{
|
||||
static const char* s_extension = "flac";
|
||||
return s_extension;
|
||||
}
|
||||
}
|
||||
static const g_flacEncoderInfo;
|
||||
|
||||
@ -216,11 +222,6 @@ bool FLACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf
|
||||
return true;
|
||||
}
|
||||
|
||||
QString FLACEncoder::extension(void)
|
||||
{
|
||||
return "flac";
|
||||
}
|
||||
|
||||
bool FLACEncoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("Wave", Qt::CaseInsensitive) == 0)
|
||||
|
@ -36,7 +36,6 @@ public:
|
||||
|
||||
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const QString &outputFile, volatile bool *abortFlag);
|
||||
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
|
||||
virtual QString extension(void);
|
||||
virtual const unsigned int *supportedChannelCount(void);
|
||||
virtual const unsigned int *supportedBitdepths(void);
|
||||
|
||||
|
@ -103,6 +103,12 @@ class MACEncoderInfo : public AbstractEncoderInfo
|
||||
static const char* s_description = "Monkey's Audio (MAC)";
|
||||
return s_description;
|
||||
}
|
||||
|
||||
virtual const char *extension(void) const
|
||||
{
|
||||
static const char* s_extension = "ape";
|
||||
return s_extension;
|
||||
}
|
||||
}
|
||||
static const g_macEncoderInfo;
|
||||
|
||||
@ -278,11 +284,6 @@ bool MACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
|
||||
return true;
|
||||
}
|
||||
|
||||
QString MACEncoder::extension(void)
|
||||
{
|
||||
return "ape";
|
||||
}
|
||||
|
||||
bool MACEncoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("Wave", Qt::CaseInsensitive) == 0)
|
||||
|
@ -36,7 +36,6 @@ public:
|
||||
|
||||
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const QString &outputFile, volatile bool *abortFlag);
|
||||
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
|
||||
virtual QString extension(void);
|
||||
|
||||
//Encoder info
|
||||
static const AbstractEncoderInfo *getEncoderInfo(void);
|
||||
|
@ -108,6 +108,12 @@ class MP3EncoderInfo : public AbstractEncoderInfo
|
||||
static const char* s_description = "LAME MP3 Encoder";
|
||||
return s_description;
|
||||
}
|
||||
|
||||
virtual const char *extension(void) const
|
||||
{
|
||||
static const char* s_extension = "mp3";
|
||||
return s_extension;
|
||||
}
|
||||
}
|
||||
static const g_mp3EncoderInfo;
|
||||
|
||||
@ -285,11 +291,6 @@ bool MP3Encoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
|
||||
return true;
|
||||
}
|
||||
|
||||
QString MP3Encoder::extension(void)
|
||||
{
|
||||
return "mp3";
|
||||
}
|
||||
|
||||
bool MP3Encoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("Wave", Qt::CaseInsensitive) == 0)
|
||||
|
@ -36,7 +36,6 @@ public:
|
||||
|
||||
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const QString &outputFile, volatile bool *abortFlag);
|
||||
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
|
||||
virtual QString extension(void);
|
||||
virtual const unsigned int *supportedChannelCount(void);
|
||||
|
||||
//Advanced options
|
||||
|
@ -98,6 +98,12 @@ class OpusEncoderInfo : public AbstractEncoderInfo
|
||||
static const char* s_description = "Opus-Tools OpusEnc (libopus)";
|
||||
return s_description;
|
||||
}
|
||||
|
||||
virtual const char *extension(void) const
|
||||
{
|
||||
static const char* s_extension = "opus";
|
||||
return s_extension;
|
||||
}
|
||||
}
|
||||
static const g_opusEncoderInfo;
|
||||
|
||||
@ -266,11 +272,6 @@ void OpusEncoder::setFrameSize(int frameSize)
|
||||
m_configFrameSize = qBound(0, frameSize, 5);
|
||||
}
|
||||
|
||||
QString OpusEncoder::extension(void)
|
||||
{
|
||||
return "opus";
|
||||
}
|
||||
|
||||
bool OpusEncoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("Wave", Qt::CaseInsensitive) == 0)
|
||||
|
@ -36,7 +36,6 @@ public:
|
||||
|
||||
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const QString &outputFile, volatile bool *abortFlag);
|
||||
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
|
||||
virtual QString extension(void);
|
||||
virtual const unsigned int *supportedChannelCount(void);
|
||||
virtual const unsigned int *supportedBitdepths(void);
|
||||
virtual const bool needsTimingInfo(void);
|
||||
|
@ -105,6 +105,12 @@ class VorbisEncoderInfo : public AbstractEncoderInfo
|
||||
static const char* s_description = "OggEnc2 Vorbis Encoder (aoTuV)";
|
||||
return s_description;
|
||||
}
|
||||
|
||||
virtual const char *extension(void) const
|
||||
{
|
||||
static const char* s_extension = "ogg";
|
||||
return s_extension;
|
||||
}
|
||||
}
|
||||
static const g_vorbisEncoderInfo;
|
||||
|
||||
@ -243,11 +249,6 @@ bool VorbisEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaI
|
||||
return true;
|
||||
}
|
||||
|
||||
QString VorbisEncoder::extension(void)
|
||||
{
|
||||
return "ogg";
|
||||
}
|
||||
|
||||
bool VorbisEncoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("Wave", Qt::CaseInsensitive) == 0)
|
||||
|
@ -36,7 +36,6 @@ public:
|
||||
|
||||
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const QString &outputFile, volatile bool *abortFlag);
|
||||
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
|
||||
virtual QString extension(void);
|
||||
virtual void setBitrateLimits(int minimumBitrate, int maximumBitrate);
|
||||
virtual void setSamplingRate(int value);
|
||||
|
||||
|
@ -105,6 +105,12 @@ public:
|
||||
static const char* s_description = "Wave Audio (PCM)";
|
||||
return s_description;
|
||||
}
|
||||
|
||||
virtual const char *extension(void) const
|
||||
{
|
||||
static const char* s_extension = "wav";
|
||||
return s_extension;
|
||||
}
|
||||
}
|
||||
static const g_waveEncoderInfo;
|
||||
|
||||
@ -171,11 +177,6 @@ bool WaveEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf
|
||||
return (result == 0 && fileOperation.fAnyOperationsAborted == false);
|
||||
}
|
||||
|
||||
QString WaveEncoder::extension(void)
|
||||
{
|
||||
return "wav";
|
||||
}
|
||||
|
||||
bool WaveEncoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("Wave", Qt::CaseInsensitive) == 0)
|
||||
|
@ -36,7 +36,6 @@ public:
|
||||
|
||||
virtual bool encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const QString &outputFile, volatile bool *abortFlag);
|
||||
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
|
||||
virtual QString extension(void);
|
||||
|
||||
//Encoder info
|
||||
static const AbstractEncoderInfo *getEncoderInfo(void);
|
||||
|
309
src/Model_FileExts.cpp
Normal file
309
src/Model_FileExts.cpp
Normal file
@ -0,0 +1,309 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// LameXP - Audio Encoder Front-End
|
||||
// Copyright (C) 2004-2015 LoRd_MuldeR <MuldeR2@GMX.de>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version, but always including the *additional*
|
||||
// restrictions defined in the "License.txt" file.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
// http://www.gnu.org/licenses/gpl-2.0.txt
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Model_FileExts.h"
|
||||
|
||||
//Internal
|
||||
#include "Global.h"
|
||||
#include "Registry_Encoder.h"
|
||||
|
||||
//MUtils
|
||||
#include <MUtils/Global.h>
|
||||
#include <MUtils/Sound.h>
|
||||
|
||||
//Qt
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QTextCodec>
|
||||
#include <QTextStream>
|
||||
#include <QInputDialog>
|
||||
|
||||
static inline int LOG10(int x)
|
||||
{
|
||||
int ret = 1;
|
||||
while(x >= 10)
|
||||
{
|
||||
ret++; x /= 10;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline QString EXTENSION(const QString &string)
|
||||
{
|
||||
QRegExp regExp("^\\*\\.([A-Za-z0-9]+)$");
|
||||
if(regExp.indexIn(string) >= 0)
|
||||
{
|
||||
return regExp.cap(1).trimmed().toLower();
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
static inline bool VALIDATE(const QString &string)
|
||||
{
|
||||
QRegExp regExp("^[A-Za-z0-9]+$");
|
||||
return (regExp.indexIn(string) >= 0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Constructor & Destructor
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
FileExtsModel::FileExtsModel(QObject *const parent )
|
||||
:
|
||||
QAbstractItemModel(parent),
|
||||
m_label_1(":/icons/tag_blue.png"),
|
||||
m_label_2(":/icons/tag_red.png")
|
||||
{
|
||||
//m_fileExts.append("mp4");
|
||||
//m_replace.insert(m_fileExts.first(), "m4a");
|
||||
}
|
||||
|
||||
FileExtsModel::~FileExtsModel(void)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Public Functions
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
int FileExtsModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
int FileExtsModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return m_fileExt.count();
|
||||
}
|
||||
|
||||
QVariant FileExtsModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if(((role == Qt::DisplayRole) || (role == Qt::ToolTipRole)) && (index.row() < m_fileExt.count()) && (index.row() >= 0))
|
||||
{
|
||||
switch(index.column())
|
||||
{
|
||||
case 0:
|
||||
return QString("*.%0").arg(m_fileExt.at(index.row()));
|
||||
case 1:
|
||||
return QString("*.%0").arg(m_replace.value(m_fileExt.at(index.row())));
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
else if((role == Qt::DecorationRole))
|
||||
{
|
||||
switch(index.column())
|
||||
{
|
||||
case 0:
|
||||
return m_label_1;
|
||||
case 1:
|
||||
return m_label_2;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
QVariant FileExtsModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if(role == Qt::DisplayRole)
|
||||
{
|
||||
if(orientation == Qt::Horizontal)
|
||||
{
|
||||
switch(section)
|
||||
{
|
||||
case 0:
|
||||
return QVariant(tr("File Extension"));
|
||||
case 1:
|
||||
return QVariant(tr("Repalce With"));
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return int2str(section + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex FileExtsModel::index(int row, int column, const QModelIndex & parent) const
|
||||
{
|
||||
return createIndex(row, column, qHash((qint64(row) << 32)| qint64(column)));
|
||||
}
|
||||
|
||||
QModelIndex FileExtsModel::parent(const QModelIndex & index) const
|
||||
{
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Edit Functions
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
bool FileExtsModel::addOverwrite(QWidget *const parent)
|
||||
{
|
||||
const QStringList allExts = EncoderRegistry::getOutputFileExtensions();
|
||||
QStringList extensions;
|
||||
for(QStringList::ConstIterator iter = allExts.constBegin(); iter != allExts.constEnd(); iter++)
|
||||
{
|
||||
if(!m_fileExt.contains((*iter), Qt::CaseInsensitive))
|
||||
{
|
||||
extensions << QString("*.%0").arg(*iter);
|
||||
}
|
||||
}
|
||||
if(extensions.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QInputDialog dialog(parent);
|
||||
dialog.setLabelText(tr("Select file extensions to overwrite:"));
|
||||
dialog.setInputMode(QInputDialog::TextInput);
|
||||
dialog.setTextEchoMode(QLineEdit::Normal);
|
||||
dialog.setComboBoxEditable(false);
|
||||
dialog.setComboBoxItems(extensions);
|
||||
|
||||
if(dialog.exec() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString selectedExt = EXTENSION(dialog.textValue());
|
||||
if(selectedExt.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
dialog.setComboBoxEditable(true);
|
||||
dialog.setComboBoxItems(QStringList());
|
||||
dialog.setLabelText(tr("Enter the new file extension:"));
|
||||
|
||||
QString replacement;
|
||||
while(replacement.isEmpty())
|
||||
{
|
||||
dialog.setTextValue(QString("*.%0").arg(selectedExt));
|
||||
if(dialog.exec() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
replacement = EXTENSION(dialog.textValue());
|
||||
if(!replacement.compare(selectedExt, Qt::CaseInsensitive))
|
||||
{
|
||||
replacement.clear();
|
||||
}
|
||||
if(replacement.isEmpty())
|
||||
{
|
||||
MUtils::Sound::beep(MUtils::Sound::BEEP_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
beginResetModel();
|
||||
m_fileExt.append(selectedExt);
|
||||
m_fileExt.sort();
|
||||
m_replace.insert(selectedExt, replacement);
|
||||
endResetModel();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileExtsModel::removeOverwrite(const QModelIndex &index)
|
||||
{
|
||||
if((index.row() < m_fileExt.count()) && (index.row() >= 0))
|
||||
{
|
||||
beginResetModel();
|
||||
m_replace.remove(m_fileExt.at(index.row()));
|
||||
m_fileExt.removeAt(index.row());
|
||||
endResetModel();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Export and Import
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
QString FileExtsModel::exportItems(void) const
|
||||
{
|
||||
QString exported;
|
||||
for(QStringList::ConstIterator iter = m_fileExt.constBegin(); iter != m_fileExt.constEnd(); iter++)
|
||||
{
|
||||
if(m_replace.contains(*iter))
|
||||
{
|
||||
if(!exported.isEmpty()) exported.append('|');
|
||||
exported.append(QString("%0>%1").arg(iter->trimmed(), m_replace.value(*iter).trimmed()));
|
||||
}
|
||||
}
|
||||
return exported;
|
||||
}
|
||||
|
||||
void FileExtsModel::importItems(const QString &data)
|
||||
{
|
||||
beginResetModel();
|
||||
m_fileExt.clear();
|
||||
m_replace.clear();
|
||||
|
||||
const QStringList list = data.split('|', QString::SkipEmptyParts);
|
||||
for(QStringList::ConstIterator iter = list.constBegin(); iter != list.constEnd(); iter++)
|
||||
{
|
||||
const QStringList item = iter->trimmed().split('>');
|
||||
if(item.count() >= 2)
|
||||
{
|
||||
const QString fileExt = item.at(0).simplified().toLower();
|
||||
const QString replace = item.at(1).simplified().toLower();
|
||||
if(VALIDATE(fileExt) && VALIDATE(replace) && (!m_fileExt.contains(fileExt)))
|
||||
{
|
||||
m_fileExt.append(fileExt);
|
||||
m_replace.insert(fileExt, replace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_fileExt.sort();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Private Functions
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
QString FileExtsModel::int2str(const int &value) const
|
||||
{
|
||||
if(m_fileExt.count() < 10)
|
||||
{
|
||||
return QString().sprintf("%d", value);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QString format = QString().sprintf("%%0%dd", LOG10(m_fileExt.count()));
|
||||
return QString().sprintf(format.toLatin1().constData(), value);
|
||||
}
|
||||
}
|
62
src/Model_FileExts.h
Normal file
62
src/Model_FileExts.h
Normal file
@ -0,0 +1,62 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// LameXP - Audio Encoder Front-End
|
||||
// Copyright (C) 2004-2015 LoRd_MuldeR <MuldeR2@GMX.de>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version, but always including the *additional*
|
||||
// restrictions defined in the "License.txt" file.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
// http://www.gnu.org/licenses/gpl-2.0.txt
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QIcon>
|
||||
|
||||
class FileExtsModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FileExtsModel(QObject *const parent = 0);
|
||||
~FileExtsModel(void);
|
||||
|
||||
//Model functions
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
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;
|
||||
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
|
||||
QModelIndex parent(const QModelIndex & index) const;
|
||||
|
||||
//Edit functions
|
||||
bool addOverwrite(QWidget *const parent);
|
||||
bool removeOverwrite(const QModelIndex &index);
|
||||
|
||||
//Export and Import
|
||||
QString exportItems(void) const;
|
||||
void importItems(const QString &data);
|
||||
|
||||
signals:
|
||||
void rowAppended(void);
|
||||
|
||||
private:
|
||||
QString int2str(const int &value) const;
|
||||
|
||||
QStringList m_fileExt;
|
||||
QHash<QString, QString> m_replace;
|
||||
const QIcon m_label_1;
|
||||
const QIcon m_label_2;
|
||||
};
|
@ -40,6 +40,16 @@
|
||||
#define CHECK_HDR(STR,NAM) (!(STR).compare((NAM), Qt::CaseInsensitive))
|
||||
#define MAKE_KEY(PATH) (QDir::fromNativeSeparators(PATH).toLower())
|
||||
|
||||
static inline int LOG10(int x)
|
||||
{
|
||||
int ret = 1;
|
||||
while(x >= 10)
|
||||
{
|
||||
ret++; x /= 10;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Constructor & Destructor
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -71,7 +81,7 @@ int FileListModel::rowCount(const QModelIndex &parent) const
|
||||
|
||||
QVariant FileListModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if((role == Qt::DisplayRole || role == Qt::ToolTipRole) && index.row() < m_fileList.count() && index.row() >= 0)
|
||||
if(((role == Qt::DisplayRole) || (role == Qt::ToolTipRole)) && (index.row() < m_fileList.count()) && (index.row() >= 0))
|
||||
{
|
||||
switch(index.column())
|
||||
{
|
||||
@ -86,7 +96,7 @@ QVariant FileListModel::data(const QModelIndex &index, int role) const
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(role == Qt::DecorationRole && index.column() == 0)
|
||||
else if((role == Qt::DecorationRole) && (index.column() == 0))
|
||||
{
|
||||
return m_fileIcon;
|
||||
}
|
||||
@ -117,22 +127,7 @@ QVariant FileListModel::headerData(int section, Qt::Orientation orientation, int
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_fileList.count() < 10)
|
||||
{
|
||||
return QVariant(QString().sprintf("%d", section + 1));
|
||||
}
|
||||
else if(m_fileList.count() < 100)
|
||||
{
|
||||
return QVariant(QString().sprintf("%02d", section + 1));
|
||||
}
|
||||
else if(m_fileList.count() < 1000)
|
||||
{
|
||||
return QVariant(QString().sprintf("%03d", section + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
return QVariant(QString().sprintf("%04d", section + 1));
|
||||
}
|
||||
return int2str(section + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -527,3 +522,16 @@ bool FileListModel::checkArray(const bool *a, const bool val, size_t len)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QString FileListModel::int2str(const int &value) const
|
||||
{
|
||||
if(m_fileList.count() < 10)
|
||||
{
|
||||
return QString().sprintf("%d", value);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QString format = QString().sprintf("%%0%dd", LOG10(m_fileList.count()));
|
||||
return QString().sprintf(format.toLatin1().constData(), value);
|
||||
}
|
||||
}
|
||||
|
@ -88,5 +88,6 @@ private:
|
||||
QHash<QString, AudioFileModel> m_fileStore;
|
||||
const QIcon m_fileIcon;
|
||||
|
||||
QString int2str(const int &value) const;
|
||||
static bool checkArray(const bool *a, const bool val, size_t len);
|
||||
};
|
||||
|
@ -279,6 +279,7 @@ LAMEXP_MAKE_ID(renameFiles_regExpSearch, "AdvancedOptions/RenameOutputFiles/
|
||||
LAMEXP_MAKE_ID(renameFiles_regExpReplace, "AdvancedOptions/RenameOutputFiles/RegExp/Replacement");
|
||||
LAMEXP_MAKE_ID(renameFiles_renameEnabled, "AdvancedOptions/RenameOutputFiles/Rename/Enabled");
|
||||
LAMEXP_MAKE_ID(renameFiles_renamePattern, "AdvancedOptions/RenameOutputFiles/Rename/Pattern");
|
||||
LAMEXP_MAKE_ID(renameFiles_fileExtension, "AdvancedOptions/RenameOutputFiles/FileExtensions/Overwrite");
|
||||
LAMEXP_MAKE_ID(samplingRate, "AdvancedOptions/Common/Resampling");
|
||||
LAMEXP_MAKE_ID(shellIntegrationEnabled, "Flags/EnableShellIntegration");
|
||||
LAMEXP_MAKE_ID(slowStartup, "Flags/SlowStartupDetected");
|
||||
@ -660,6 +661,7 @@ LAMEXP_MAKE_OPTION_S(renameFiles_regExpSearch, QString())
|
||||
LAMEXP_MAKE_OPTION_S(renameFiles_regExpReplace, QString())
|
||||
LAMEXP_MAKE_OPTION_B(renameFiles_renameEnabled, false)
|
||||
LAMEXP_MAKE_OPTION_S(renameFiles_renamePattern, "[<TrackNo>] <Artist> - <Title>")
|
||||
LAMEXP_MAKE_OPTION_S(renameFiles_fileExtension, QString())
|
||||
LAMEXP_MAKE_OPTION_I(samplingRate, 0)
|
||||
LAMEXP_MAKE_OPTION_B(shellIntegrationEnabled, !lamexp_version_portable())
|
||||
LAMEXP_MAKE_OPTION_B(slowStartup, false)
|
||||
|
@ -197,6 +197,7 @@ public:
|
||||
LAMEXP_MAKE_OPTION_S(renameFiles_regExpReplace)
|
||||
LAMEXP_MAKE_OPTION_B(renameFiles_renameEnabled)
|
||||
LAMEXP_MAKE_OPTION_S(renameFiles_renamePattern)
|
||||
LAMEXP_MAKE_OPTION_S(renameFiles_fileExtension)
|
||||
LAMEXP_MAKE_OPTION_I(samplingRate)
|
||||
LAMEXP_MAKE_OPTION_B(shellIntegrationEnabled)
|
||||
LAMEXP_MAKE_OPTION_B(slowStartup)
|
||||
|
@ -479,6 +479,24 @@ void EncoderRegistry::resetAllEncoders(SettingsModel *settings)
|
||||
RESET_SETTING(settings, compressionVbrQualityWave);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Get File Extensions
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
QStringList EncoderRegistry::getOutputFileExtensions(void)
|
||||
{
|
||||
QStringList list;
|
||||
for(int encoderId = SettingsModel::MP3Encoder; encoderId < SettingsModel::ENCODER_COUNT; encoderId++)
|
||||
{
|
||||
if((encoderId == SettingsModel::AACEncoder) && (getAacEncoder() == SettingsModel::AAC_ENCODER_NONE))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
list << QString::fromLatin1(getEncoderInfo(encoderId)->extension());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Static Functions
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -23,6 +23,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
|
||||
class AbstractEncoder;
|
||||
class AbstractEncoderInfo;
|
||||
@ -46,5 +47,6 @@ public:
|
||||
static QString loadEncoderCustomParams(const SettingsModel *settings, const int encoderId);
|
||||
|
||||
static void resetAllEncoders(SettingsModel *settings);
|
||||
static QStringList getOutputFileExtensions(void);
|
||||
static int getAacEncoder(void);
|
||||
};
|
||||
|
@ -440,7 +440,8 @@ int ProcessThread::generateOutFileName(QString &outFileName)
|
||||
const QString fileName = MUtils::clean_file_name(applyRegularExpression(applyRenamePattern(baseName, m_audioFile.metaInfo())));
|
||||
|
||||
//Generate full output path
|
||||
outFileName = QString("%1/%2.%3").arg(targetDir.canonicalPath(), fileName, m_encoder->extension());
|
||||
const QString fileExt = QString::fromUtf8(m_encoder->getEncoderInfo()->extension());
|
||||
outFileName = QString("%1/%2.%3").arg(targetDir.canonicalPath(), fileName, fileExt);
|
||||
|
||||
//Skip file, if target file exists (optional!)
|
||||
if((m_overwriteMode == OverwriteMode_SkipExisting) && QFileInfo(outFileName).exists())
|
||||
@ -476,7 +477,7 @@ int ProcessThread::generateOutFileName(QString &outFileName)
|
||||
//Generate final name
|
||||
while(QFileInfo(outFileName).exists() && (n < (INT_MAX/2)))
|
||||
{
|
||||
outFileName = QString("%1/%2 (%3).%4").arg(targetDir.canonicalPath(), fileName, QString::number(++n), m_encoder->extension());
|
||||
outFileName = QString("%1/%2 (%3).%4").arg(targetDir.canonicalPath(), fileName, QString::number(++n), fileExt);
|
||||
}
|
||||
|
||||
//Create placeholder
|
||||
|
Loading…
Reference in New Issue
Block a user