Implemented processing dialog, no functionality yet.

This commit is contained in:
LoRd_MuldeR 2010-11-17 19:35:50 +01:00
parent b996bfdece
commit 7a79c476a3
11 changed files with 868 additions and 4 deletions

View File

@ -302,6 +302,10 @@
RelativePath=".\src\Dialog_MetaInfo.cpp"
>
</File>
<File
RelativePath=".\src\Dialog_Processing.cpp"
>
</File>
<File
RelativePath=".\src\Dialog_SplashScreen.cpp"
>
@ -478,6 +482,40 @@
/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\Dialog_Processing.h"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="MOC &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -o &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="&quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="MOC &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -o &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="&quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
/>
</FileConfiguration>
<FileConfiguration
Name="Release_Static|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="MOC &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -o &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="&quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\Dialog_SplashScreen.h"
>
@ -559,7 +597,7 @@
<Tool
Name="VCCustomBuildTool"
Description="MOC &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -o &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot; &quot;$(InputPath)&quot;"
CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -o &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="&quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
/>
</FileConfiguration>
@ -569,7 +607,7 @@
<Tool
Name="VCCustomBuildTool"
Description="MOC &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -o &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot; &quot;$(InputPath)&quot;"
CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -o &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="&quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
/>
</FileConfiguration>
@ -579,7 +617,7 @@
<Tool
Name="VCCustomBuildTool"
Description="MOC &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -o &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot; &quot;$(InputPath)&quot;"
CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -o &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="&quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
/>
</FileConfiguration>
@ -834,6 +872,10 @@
RelativePath=".\tmp\MOC_Dialog_MetaInfo.cpp"
>
</File>
<File
RelativePath=".\tmp\MOC_Dialog_Processing.cpp"
>
</File>
<File
RelativePath=".\tmp\MOC_Dialog_SplashScreen.cpp"
>
@ -1072,6 +1114,40 @@
/>
</FileConfiguration>
</File>
<File
RelativePath=".\gui\ProcessingDialog.ui"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="UIC &quot;$(SolutionDir)tmp\UIC_$(SafeInputName).h&quot;"
CommandLine="&quot;$(QTDIR)\bin\uic.exe&quot; -o &quot;$(SolutionDir)tmp\UIC_$(SafeInputName).h&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="&quot;$(SolutionDir)tmp\UIC_$(SafeInputName).h&quot;"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="UIC &quot;$(SolutionDir)tmp\UIC_$(SafeInputName).h&quot;"
CommandLine="&quot;$(QTDIR)\bin\uic.exe&quot; -o &quot;$(SolutionDir)tmp\UIC_$(SafeInputName).h&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="&quot;$(SolutionDir)tmp\UIC_$(SafeInputName).h&quot;"
/>
</FileConfiguration>
<FileConfiguration
Name="Release_Static|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="UIC &quot;$(SolutionDir)tmp\UIC_$(SafeInputName).h&quot;"
CommandLine="&quot;$(QTDIR)\bin\uic.exe&quot; -o &quot;$(SolutionDir)tmp\UIC_$(SafeInputName).h&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="&quot;$(SolutionDir)tmp\UIC_$(SafeInputName).h&quot;"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\gui\SplashScreen.ui"
>

443
gui/ProcessingDialog.ui Normal file
View File

@ -0,0 +1,443 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProcessingDialog</class>
<widget class="QDialog" name="ProcessingDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>663</width>
<height>458</height>
</rect>
</property>
<property name="windowTitle">
<string>LameXP - Processing</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="layout_base">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="frame_header">
<property name="minimumSize">
<size>
<width>0</width>
<height>72</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>72</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="margin">
<number>3</number>
</property>
<item>
<layout class="QHBoxLayout" name="layout_verticalHeader">
<item>
<spacer name="spacer_horizontalHeader2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>4</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_headerIcon">
<property name="minimumSize">
<size>
<width>60</width>
<height>56</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>56</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../res/Icons.qrc">:/MainIcon.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="spacer_horizontalHeader">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>12</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_headerStatus">
<property name="text">
<string>&lt;b&gt;Encoding Files&lt;/b&gt;&lt;br&gt;Your files are being encoded, please be pateint...</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_headerWorking">
<property name="maximumSize">
<size>
<width>48</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../res/Images.qrc">:/images/Working.gif</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_verticalLine">
<property name="minimumSize">
<size>
<width>0</width>
<height>2</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>2</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="layout_main">
<property name="spacing">
<number>8</number>
</property>
<property name="margin">
<number>21</number>
</property>
<item>
<widget class="QLabel" name="label_progress">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Initializing, please wait...</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>24</number>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QTableView" name="view_log">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_horizontal">
<item>
<widget class="QLabel" name="label_versionInfo">
<property name="enabled">
<bool>true</bool>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>85</red>
<green>85</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>85</red>
<green>85</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>(VERSION_TAG)</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="spacer_vertical">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="button_AbortProcess">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Abort</string>
</property>
<property name="icon">
<iconset resource="../res/Icons.qrc">
<normaloff>:/icons/cancel.png</normaloff>:/icons/cancel.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_closeDialog">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Close</string>
</property>
<property name="icon">
<iconset resource="../res/Icons.qrc">
<normaloff>:/icons/accept.png</normaloff>:/icons/accept.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../res/Icons.qrc"/>
<include location="../res/Images.qrc"/>
<include location="../res/Icons.qrc"/>
<include location="../res/Images.qrc"/>
<include location="../res/Icons.qrc"/>
<include location="../res/Images.qrc"/>
</resources>
<connections>
<connection>
<sender>button_closeDialog</sender>
<signal>clicked()</signal>
<receiver>ProcessingDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>579</x>
<y>422</y>
</hint>
<hint type="destinationlabel">
<x>331</x>
<y>228</y>
</hint>
</hints>
</connection>
<connection>
<sender>button_AbortProcess</sender>
<signal>clicked()</signal>
<receiver>ProcessingDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>453</x>
<y>422</y>
</hint>
<hint type="destinationlabel">
<x>331</x>
<y>228</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -11,5 +11,6 @@
<file>images/Construction.gif</file>
<file>images/Cogwheels.png</file>
<file>images/Qt.svg</file>
<file>images/Working.gif</file>
</qresource>
</RCC>

View File

@ -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 30
#define VER_LAMEXP_BUILD 33
#define VER_LAMEXP_SUFFIX TechPreview
/*

54
src/Dialog_Processing.cpp Normal file
View File

@ -0,0 +1,54 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2010 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.
//
// 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 "Dialog_Processing.h"
#include "Global.h"
#include <QApplication>
#include <QRect>
#include <QDesktopWidget>
#include <QMovie>
ProcessingDialog::ProcessingDialog(void)
{
//Init the dialog, from the .ui file
setupUi(this);
setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
label_versionInfo->setText(QString().sprintf("v%d.%02d %s (Build %d)", lamexp_version_major(), lamexp_version_minor(), lamexp_version_release(), lamexp_version_build()));
//Center window in screen
QRect desktopRect = QApplication::desktop()->screenGeometry();
QRect thisRect = this->geometry();
move((desktopRect.width() - thisRect.width()) / 2, (desktopRect.height() - thisRect.height()) / 2);
setMinimumSize(thisRect.width(), thisRect.height());
//Init progress indicator
m_progressIndicator = new QMovie(":/images/Working.gif");
label_headerWorking->setMovie(m_progressIndicator);
m_progressIndicator->start();
}
ProcessingDialog::~ProcessingDialog(void)
{
if(m_progressIndicator) m_progressIndicator->stop();
LAMEXP_DELETE(m_progressIndicator);
}

38
src/Dialog_Processing.h Normal file
View File

@ -0,0 +1,38 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2010 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.
//
// 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 "../tmp/UIC_ProcessingDialog.h"
class QMovie;
class ProcessingDialog : public QDialog, private Ui::ProcessingDialog
{
Q_OBJECT
public:
ProcessingDialog(void);
~ProcessingDialog(void);
private:
QMovie *m_progressIndicator;
};

39
src/Encoder_Abstract.cpp Normal file
View File

@ -0,0 +1,39 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2010 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.
//
// 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 "Encoder_Abstract.h"
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
AbstractEncoder::AbstractEncoder(void)
{
m_configBitrate = 0;
m_configRCMode = 0;
}
AbstractEncoder::~AbstractEncoder(void)
{
}
//Setters
void AbstractEncoder::setBitrate(int bitrate) { m_configBitrate = max(0, bitrate); }
void AbstractEncoder::setRCMode(int mode) { m_configRCMode = max(0, mode); }

43
src/Encoder_Abstract.h Normal file
View File

@ -0,0 +1,43 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2010 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.
//
// 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 "Model_AudioFile.h"
#include <QString>
class AbstractEncoder
{
public:
AbstractEncoder(void);
~AbstractEncoder(void);
virtual bool encode(const AudioFileModel &sourceFile, const QString &outputFile) = 0;
void setBitrate(int bitrate);
void setRCMode(int mode);
protected:
int m_configBitrate;
int m_configRCMode;
};

121
src/Encoder_MP3.cpp Normal file
View File

@ -0,0 +1,121 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2010 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.
//
// 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 "Encoder_MP3.h"
#include "Global.h"
#include "Model_Settings.h"
#include <QProcess>
#include <QDir>
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define IS_UNICODE(STR) (qstricmp(STR.toUtf8().constData(), QString::fromLocal8Bit(STR.toLocal8Bit()).toUtf8().constData()))
MP3Encoder::MP3Encoder(void) : m_binary(lamexp_lookup_tool("lame.exe"))
{
if(m_binary.isEmpty())
{
throw "Error initializing MP3 encoder. Tool 'lame.exe' is not registred!";
}
}
MP3Encoder::~MP3Encoder(void)
{
}
bool MP3Encoder::encode(const AudioFileModel &sourceFile, const QString &outputFile)
{
const QString baseName = QFileInfo(outputFile).fileName();
emit statusUpdated(baseName);
QProcess process;
process.setProcessChannelMode(QProcess::MergedChannels);
process.setReadChannel(QProcess::StandardOutput);
QStringList args;
args << "--nohist";
args << "-h";
switch(m_configRCMode)
{
case SettingsModel::VBRMode:
args << "-V" << QString::number(9 - min(9, m_configBitrate));
break;
case SettingsModel::ABRMode:
args << "--abr" << QString::number(SettingsModel::mp3Bitrates[min(13, m_configBitrate)]);
break;
case SettingsModel::CBRMode:
args << "--cbr";
args << "-b" << QString::number(SettingsModel::mp3Bitrates[min(13, m_configBitrate)]);
break;
default:
throw "Bad rate-control mode!";
break;
}
if(!sourceFile.fileName().isEmpty()) args << (IS_UNICODE(sourceFile.fileName()) ? "--uTitle" : "--lTitle") << sourceFile.fileName();
if(!sourceFile.fileArtist().isEmpty()) args << (IS_UNICODE(sourceFile.fileArtist()) ? "--uArtist" : "--lArtist") << sourceFile.fileArtist();
if(!sourceFile.fileGenre().isEmpty()) args << (IS_UNICODE(sourceFile.fileGenre()) ? "--uGenre" : "--lGenre") << sourceFile.fileGenre();
if(!sourceFile.fileComment().isEmpty()) args << (IS_UNICODE(sourceFile.fileComment()) ? "--uComment" : "--lComment") << sourceFile.fileComment();
args << QDir::toNativeSeparators(sourceFile.filePath());
args << QDir::toNativeSeparators(outputFile);
process.start(lamexp_lookup_tool("lame.exe"), args);
if(!process.waitForStarted())
{
return false;
}
QRegExp regExp("\\(.*(\\d+)%\\)\\|");
while(process.state() != QProcess::NotRunning)
{
process.waitForReadyRead();
while(process.bytesAvailable() > 0)
{
QByteArray line = process.readLine();
qDebug("%s", line.constData());
QString text = QString::fromLocal8Bit(line.constData()).simplified();
if(regExp.lastIndexIn(line) >= 0)
{
emit statusUpdated(QString("%1 [%2%]").arg(baseName, regExp.cap(1)));
}
}
}
process.waitForFinished();
if(process.state() != QProcess::NotRunning)
{
process.kill();
process.waitForFinished(-1);
}
if(process.exitStatus() != QProcess::NormalExit)
{
return false;
}
return true;
}

43
src/Encoder_MP3.h Normal file
View File

@ -0,0 +1,43 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2010 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.
//
// 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 "Encoder_Abstract.h"
#include <QObject>
class MP3Encoder : public QObject, public AbstractEncoder
{
Q_OBJECT
public:
MP3Encoder(void);
~MP3Encoder(void);
virtual bool encode(const AudioFileModel &sourceFile, const QString &outputFile);
signals:
void statusUpdated(const QString &text);
private:
const QString m_binary;
};

View File

@ -23,6 +23,7 @@
#include "Global.h"
#include "Dialog_SplashScreen.h"
#include "Dialog_MainWindow.h"
#include "Dialog_Processing.h"
#include "Thread_Initialization.h"
#include "Thread_MessageProducer.h"
#include "Model_Settings.h"
@ -121,6 +122,11 @@ int lamexp_main(int argc, char* argv[])
iResult = QApplication::instance()->exec();
LAMEXP_DELETE(poMainWindow);
//Show processing dialog
ProcessingDialog *processingDialog = new ProcessingDialog();
processingDialog->exec();
LAMEXP_DELETE(processingDialog);
//Final clean-up
qDebug("Shutting down, please wait...\n");