Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 867 lines (758 sloc) 28.242 kb
7a79c476 »
2010-11-17 Implemented processing dialog, no functionality yet.
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
96db5e86 »
2011-01-01 Happy new year!
3 // Copyright (C) 2004-2011 LoRd_MuldeR <MuldeR2@GMX.de>
7a79c476 »
2010-11-17 Implemented processing dialog, no functionality yet.
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
21
22 #include "Dialog_Processing.h"
23
24 #include "Global.h"
11f57aec »
2010-11-26 Ogg Vorbis encoding support.
25 #include "Resource.h"
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
26 #include "Model_FileList.h"
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
27 #include "Model_Progress.h"
1633489a »
2010-11-20 Actually use selected encoder in progress dialog + forward output dir.
28 #include "Model_Settings.h"
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
29 #include "Thread_Process.h"
23665ed4 »
2011-03-28 Implemented a new "disk observer" thread which will constantly check …
30 #include "Thread_DiskObserver.h"
c0ece99b »
2010-11-22 Implemented logging and added a log file view.
31 #include "Dialog_LogView.h"
11f57aec »
2010-11-26 Ogg Vorbis encoding support.
32 #include "Encoder_MP3.h"
33 #include "Encoder_Vorbis.h"
be4ce0d8 »
2010-12-03 Added AAC encoding support.
34 #include "Encoder_AAC.h"
84883ab5 »
2011-08-19 Added experimental(!) support for FhgAacEnc. Replaces the Nero AAC en…
35 #include "Encoder_AAC_FHG.h"
be71e483 »
2011-05-04 Initial ATSC A/52 (aka "AC-3", aka "Dolby Digital") encoding support,…
36 #include "Encoder_AC3.h"
e6460b97 »
2010-12-14 FLAC encoding support.
37 #include "Encoder_FLAC.h"
e189eb08 »
2010-12-17 Support for Wave (PCM) output.
38 #include "Encoder_Wave.h"
fbee147f »
2011-08-05 Added an option option to enforce Stereo Downmix.
39 #include "Filter_Downmix.h"
58ded8c2 »
2011-01-25 Added a normalization filter, based on SoX.
40 #include "Filter_Normalize.h"
d13050c3 »
2011-01-26 Added "Resample" filter, based on SoX. Used for encoders that don't s…
41 #include "Filter_Resample.h"
42 #include "Filter_ToneAdjust.h"
c2f13200 »
2010-12-05 Added support for Windows 7 taskbar features (progress and overlay ic…
43 #include "WinSevenTaskbar.h"
7a79c476 »
2010-11-17 Implemented processing dialog, no functionality yet.
44
45 #include <QApplication>
46 #include <QRect>
47 #include <QDesktopWidget>
48 #include <QMovie>
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
49 #include <QMessageBox>
50 #include <QTimer>
51 #include <QCloseEvent>
52 #include <QDesktopServices>
53 #include <QUrl>
970f2cd8 »
2010-11-20 Create playlist file + serialize filename generation, just to be sure.
54 #include <QUuid>
55 #include <QFileInfo>
47a6c2fd »
2010-11-21 Make "Save output files to the same location where the input file is …
56 #include <QDir>
571df62e »
2010-11-24 Implement support for Job Objects + improve log view.
57 #include <QMenu>
18bed9ea »
2010-12-10 Added a system tray icon.
58 #include <QSystemTrayIcon>
b12e524a »
2011-02-11 Add option "Brose Output File Location" to context menu in processing…
59 #include <QProcess>
108c1677 »
2011-03-18 Added an option to shutdown the computer as soon as all files are com…
60 #include <QProgressDialog>
970f2cd8 »
2010-11-20 Create playlist file + serialize filename generation, just to be sure.
61
8977e007 »
2011-04-11 Clean up #include directives: Don't include 'Windows.h' directly, as …
62 #include <MMSystem.h>
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
63
c967a013 »
2011-02-14 Properly map the popup menu position to global coordinates.
64 ////////////////////////////////////////////////////////////
65
63d6708f »
2011-02-28 Refactored a few constants.
66 //Maximum number of parallel instances
67 #define MAX_INSTANCES 16
68
69 //Maximum number of CPU cores for auto-detection
70 #define MAX_CPU_COUNT 4
71
72 ////////////////////////////////////////////////////////////
73
d6e5b9e0 »
2010-12-02 AAC decoding support added.
74 #define CHANGE_BACKGROUND_COLOR(WIDGET, COLOR) \
75 { \
76 QPalette palette = WIDGET->palette(); \
77 palette.setColor(QPalette::Background, COLOR); \
78 WIDGET->setPalette(palette); \
79 }
80
18bed9ea »
2010-12-10 Added a system tray icon.
81 #define SET_PROGRESS_TEXT(TXT) \
82 { \
83 label_progress->setText(TXT); \
84 m_systemTray->setToolTip(QString().sprintf("LameXP v%d.%02d\n%ls", lamexp_version_major(), lamexp_version_minor(), QString(TXT).utf16())); \
85 }
86
c967a013 »
2011-02-14 Properly map the popup menu position to global coordinates.
87 #define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); }
88
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
89 ////////////////////////////////////////////////////////////
90 // Constructor
91 ////////////////////////////////////////////////////////////
7a79c476 »
2010-11-17 Implemented processing dialog, no functionality yet.
92
cffa6a24 »
2010-11-20 Correctly forward meta info to MP3 encoder and apply.
93 ProcessingDialog::ProcessingDialog(FileListModel *fileListModel, AudioFileModel *metaInfo, SettingsModel *settings, QWidget *parent)
1633489a »
2010-11-20 Actually use selected encoder in progress dialog + forward output dir.
94 :
cffa6a24 »
2010-11-20 Correctly forward meta info to MP3 encoder and apply.
95 QDialog(parent),
0534264b »
2010-12-12 WMA decoding support. Limitations in the WMA decoder we cannot do any…
96 m_systemTray(new QSystemTrayIcon(QIcon(":/icons/cd_go.png"), this)),
cffa6a24 »
2010-11-20 Correctly forward meta info to MP3 encoder and apply.
97 m_settings(settings),
108c1677 »
2011-03-18 Added an option to shutdown the computer as soon as all files are com…
98 m_metaInfo(metaInfo),
23665ed4 »
2011-03-28 Implemented a new "disk observer" thread which will constantly check …
99 m_shutdownFlag(false),
100 m_diskObserver(NULL)
7a79c476 »
2010-11-17 Implemented processing dialog, no functionality yet.
101 {
102 //Init the dialog, from the .ui file
103 setupUi(this);
104 setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
092e664a »
2010-11-18 More detailed error output when process failed to create + use UUID's…
105
106 //Setup version info
7a79c476 »
2010-11-17 Implemented processing dialog, no functionality yet.
107 label_versionInfo->setText(QString().sprintf("v%d.%02d %s (Build %d)", lamexp_version_major(), lamexp_version_minor(), lamexp_version_release(), lamexp_version_build()));
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
108 label_versionInfo->installEventFilter(this);
7a79c476 »
2010-11-17 Implemented processing dialog, no functionality yet.
109
092e664a »
2010-11-18 More detailed error output when process failed to create + use UUID's…
110 //Register meta type
111 qRegisterMetaType<QUuid>("QUuid");
112
7a79c476 »
2010-11-17 Implemented processing dialog, no functionality yet.
113 //Center window in screen
114 QRect desktopRect = QApplication::desktop()->screenGeometry();
115 QRect thisRect = this->geometry();
116 move((desktopRect.width() - thisRect.width()) / 2, (desktopRect.height() - thisRect.height()) / 2);
117 setMinimumSize(thisRect.width(), thisRect.height());
118
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
119 //Enable buttons
120 connect(button_AbortProcess, SIGNAL(clicked()), this, SLOT(abortEncoding()));
121
7a79c476 »
2010-11-17 Implemented processing dialog, no functionality yet.
122 //Init progress indicator
123 m_progressIndicator = new QMovie(":/images/Working.gif");
124 label_headerWorking->setMovie(m_progressIndicator);
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
125 progressBar->setValue(0);
126
127 //Init progress model
128 m_progressModel = new ProgressModel();
129 view_log->setModel(m_progressModel);
130 view_log->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
131 view_log->verticalHeader()->hide();
132 view_log->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
133 view_log->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
13753592 »
2011-08-22 Workaround for a bug in Qt's TableView that causes column widths to n…
134 view_log->viewport()->installEventFilter(this);
47a6c2fd »
2010-11-21 Make "Save output files to the same location where the input file is …
135 connect(m_progressModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(progressModelChanged()));
136 connect(m_progressModel, SIGNAL(modelReset()), this, SLOT(progressModelChanged()));
11f57aec »
2010-11-26 Ogg Vorbis encoding support.
137 connect(view_log, SIGNAL(activated(QModelIndex)), this, SLOT(logViewDoubleClicked(QModelIndex)));
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
138
571df62e »
2010-11-24 Implement support for Job Objects + improve log view.
139 //Create context menu
140 m_contextMenu = new QMenu();
b12e524a »
2011-02-11 Add option "Brose Output File Location" to context menu in processing…
141 QAction *contextMenuDetailsAction = m_contextMenu->addAction(QIcon(":/icons/zoom.png"), tr("Show details for selected job"));
142 QAction *contextMenuShowFileAction = m_contextMenu->addAction(QIcon(":/icons/folder_go.png"), tr("Browse Output File Location"));
143
571df62e »
2010-11-24 Implement support for Job Objects + improve log view.
144 view_log->setContextMenuPolicy(Qt::CustomContextMenu);
145 connect(view_log, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTriggered(QPoint)));
b12e524a »
2011-02-11 Add option "Brose Output File Location" to context menu in processing…
146 connect(contextMenuDetailsAction, SIGNAL(triggered(bool)), this, SLOT(contextMenuDetailsActionTriggered()));
147 connect(contextMenuShowFileAction, SIGNAL(triggered(bool)), this, SLOT(contextMenuShowFileActionTriggered()));
c967a013 »
2011-02-14 Properly map the popup menu position to global coordinates.
148 SET_FONT_BOLD(contextMenuDetailsAction, true);
149
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
150 //Enque jobs
151 if(fileListModel)
152 {
153 for(int i = 0; i < fileListModel->rowCount(); i++)
154 {
155 m_pendingJobs.append(fileListModel->getFile(fileListModel->index(i,0)));
156 }
157 }
158
5a1ff67e »
2011-01-01 Make more strings translatable.
159 //Translate
160 label_headerStatus->setText(QString("<b>%1</b><br>%2").arg(tr("Encoding Files"), tr("Your files are being encoded, please be patient...")));
161
18bed9ea »
2010-12-10 Added a system tray icon.
162 //Enable system tray icon
163 connect(m_systemTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systemTrayActivated(QSystemTrayIcon::ActivationReason)));
164
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
165 //Init other vars
166 m_runningThreads = 0;
cffa6a24 »
2010-11-20 Correctly forward meta info to MP3 encoder and apply.
167 m_currentFile = 0;
64919656 »
2010-12-10 Add items to the playlist in the order the jobs are created, rather t…
168 m_allJobs.clear();
169 m_succeededJobs.clear();
170 m_failedJobs.clear();
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
171 m_userAborted = false;
7a79c476 »
2010-11-17 Implemented processing dialog, no functionality yet.
172 }
173
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
174 ////////////////////////////////////////////////////////////
175 // Destructor
176 ////////////////////////////////////////////////////////////
177
7a79c476 »
2010-11-17 Implemented processing dialog, no functionality yet.
178 ProcessingDialog::~ProcessingDialog(void)
179 {
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
180 view_log->setModel(NULL);
23665ed4 »
2011-03-28 Implemented a new "disk observer" thread which will constantly check …
181
182 if(m_progressIndicator)
183 {
184 m_progressIndicator->stop();
185 }
186
187 if(m_diskObserver)
188 {
189 m_diskObserver->stop();
190 m_diskObserver->wait(15000);
191 }
192
7a79c476 »
2010-11-17 Implemented processing dialog, no functionality yet.
193 LAMEXP_DELETE(m_progressIndicator);
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
194 LAMEXP_DELETE(m_progressModel);
571df62e »
2010-11-24 Implement support for Job Objects + improve log view.
195 LAMEXP_DELETE(m_contextMenu);
18bed9ea »
2010-12-10 Added a system tray icon.
196 LAMEXP_DELETE(m_systemTray);
23665ed4 »
2011-03-28 Implemented a new "disk observer" thread which will constantly check …
197 LAMEXP_DELETE(m_diskObserver);
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
198
c2f13200 »
2010-12-05 Added support for Windows 7 taskbar features (progress and overlay ic…
199 WinSevenTaskbar::setOverlayIcon(this, NULL);
200 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNoState);
201
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
202 while(!m_threadList.isEmpty())
203 {
1633489a »
2010-11-20 Actually use selected encoder in progress dialog + forward output dir.
204 ProcessThread *thread = m_threadList.takeFirst();
205 thread->terminate();
206 thread->wait(15000);
207 delete thread;
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
208 }
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
209 }
210
211 ////////////////////////////////////////////////////////////
212 // EVENTS
213 ////////////////////////////////////////////////////////////
214
215 void ProcessingDialog::showEvent(QShowEvent *event)
216 {
217 setCloseButtonEnabled(false);
218 button_closeDialog->setEnabled(false);
219 button_AbortProcess->setEnabled(false);
18bed9ea »
2010-12-10 Added a system tray icon.
220 m_systemTray->setVisible(true);
221
9947e9c8 »
2010-11-25 Detect the entry points for some of the Win32 API functions on Runtim…
222 if(!SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS))
223 {
224 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
225 }
226
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
227 QTimer::singleShot(1000, this, SLOT(initEncoding()));
228 }
229
230 void ProcessingDialog::closeEvent(QCloseEvent *event)
231 {
18bed9ea »
2010-12-10 Added a system tray icon.
232 if(!button_closeDialog->isEnabled())
233 {
234 event->ignore();
235 }
236 else
237 {
238 m_systemTray->setVisible(false);
239 }
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
240 }
241
242 bool ProcessingDialog::eventFilter(QObject *obj, QEvent *event)
243 {
244 static QColor defaultColor = QColor();
245
246 if(obj == label_versionInfo)
247 {
248 if(event->type() == QEvent::Enter)
249 {
250 QPalette palette = label_versionInfo->palette();
251 defaultColor = palette.color(QPalette::Normal, QPalette::WindowText);
252 palette.setColor(QPalette::Normal, QPalette::WindowText, Qt::red);
253 label_versionInfo->setPalette(palette);
254 }
255 else if(event->type() == QEvent::Leave)
256 {
257 QPalette palette = label_versionInfo->palette();
258 palette.setColor(QPalette::Normal, QPalette::WindowText, defaultColor);
259 label_versionInfo->setPalette(palette);
260 }
261 else if(event->type() == QEvent::MouseButtonPress)
262 {
63d6708f »
2011-02-28 Refactored a few constants.
263 QUrl url(lamexp_website_url());
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
264 QDesktopServices::openUrl(url);
265 }
266 }
13753592 »
2011-08-22 Workaround for a bug in Qt's TableView that causes column widths to n…
267 else if(obj == view_log->viewport())
268 {
269 view_log->resizeColumnToContents(1);
270 }
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
271
272 return false;
273 }
274
275 ////////////////////////////////////////////////////////////
276 // SLOTS
277 ////////////////////////////////////////////////////////////
278
279 void ProcessingDialog::initEncoding(void)
280 {
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
281 m_runningThreads = 0;
cffa6a24 »
2010-11-20 Correctly forward meta info to MP3 encoder and apply.
282 m_currentFile = 0;
64919656 »
2010-12-10 Add items to the playlist in the order the jobs are created, rather t…
283 m_allJobs.clear();
284 m_succeededJobs.clear();
285 m_failedJobs.clear();
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
286 m_userAborted = false;
970f2cd8 »
2010-11-20 Create playlist file + serialize filename generation, just to be sure.
287 m_playList.clear();
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
288
d6e5b9e0 »
2010-12-02 AAC decoding support added.
289 CHANGE_BACKGROUND_COLOR(frame_header, QColor(Qt::white));
8c0fa118 »
2011-01-02 make more strings translatable + try to load a default translation th…
290 SET_PROGRESS_TEXT(tr("Encoding files, please wait..."));
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
291 m_progressIndicator->start();
292
293 button_closeDialog->setEnabled(false);
294 button_AbortProcess->setEnabled(true);
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
295 progressBar->setRange(0, m_pendingJobs.count());
108c1677 »
2011-03-18 Added an option to shutdown the computer as soon as all files are com…
296 checkBox_shutdownComputer->setEnabled(true);
297 checkBox_shutdownComputer->setChecked(false);
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
298
c2f13200 »
2010-12-05 Added support for Windows 7 taskbar features (progress and overlay ic…
299 WinSevenTaskbar::initTaskbar();
300 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNormalState);
301 WinSevenTaskbar::setTaskbarProgress(this, 0, m_pendingJobs.count());
302 WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/control_play_blue.png"));
303
23665ed4 »
2011-03-28 Implemented a new "disk observer" thread which will constantly check …
304 if(!m_diskObserver)
305 {
306 m_diskObserver = new DiskObserverThread(m_settings->customTempPathEnabled() ? m_settings->customTempPath() : lamexp_temp_folder2());
307 connect(m_diskObserver, SIGNAL(messageLogged(QString,bool)), m_progressModel, SLOT(addSystemMessage(QString,bool)), Qt::QueuedConnection);
308 m_diskObserver->start();
309 }
310
63d6708f »
2011-02-28 Refactored a few constants.
311 int maximumInstances = max(min(m_settings->maximumInstances(), MAX_INSTANCES), 0);
f75c3ca4 »
2011-02-25 Added an option to manually specify the number of parallel instances.
312 if(maximumInstances < 1)
313 {
314 lamexp_cpu_t cpuFeatures = lamexp_detect_cpu_features();
63d6708f »
2011-02-28 Refactored a few constants.
315 maximumInstances = max(min(cpuFeatures.count, MAX_CPU_COUNT), 1);
f75c3ca4 »
2011-02-25 Added an option to manually specify the number of parallel instances.
316 }
571df62e »
2010-11-24 Implement support for Job Objects + improve log view.
317
f75c3ca4 »
2011-02-25 Added an option to manually specify the number of parallel instances.
318 int parallelThreadCount = max(min(maximumInstances, m_pendingJobs.count()), 1);
d9e775b4 »
2011-02-02 Show notification in progress window, if multi-threading is activated.
319 if(parallelThreadCount > 1)
320 {
321 m_progressModel->addSystemMessage(tr("Multi-threading enabled: Running %1 instances in parallel!").arg(QString::number(parallelThreadCount)));
322 }
323
324 for(int i = 0; i < parallelThreadCount; i++)
571df62e »
2010-11-24 Implement support for Job Objects + improve log view.
325 {
326 startNextJob();
327 }
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
328 }
329
330 void ProcessingDialog::abortEncoding(void)
331 {
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
332 m_userAborted = true;
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
333 button_AbortProcess->setEnabled(false);
334
8c0fa118 »
2011-01-02 make more strings translatable + try to load a default translation th…
335 SET_PROGRESS_TEXT(tr("Aborted! Waiting for running jobs to terminate..."));
d6e5b9e0 »
2010-12-02 AAC decoding support added.
336
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
337 for(int i = 0; i < m_threadList.count(); i++)
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
338 {
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
339 m_threadList.at(i)->abort();
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
340 }
341 }
342
343 void ProcessingDialog::doneEncoding(void)
344 {
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
345 m_runningThreads--;
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
346 progressBar->setValue(progressBar->value() + 1);
d6e5b9e0 »
2010-12-02 AAC decoding support added.
347
348 if(!m_userAborted)
349 {
8c0fa118 »
2011-01-02 make more strings translatable + try to load a default translation th…
350 SET_PROGRESS_TEXT(tr("Encoding: %1 files of %2 completed so far, please wait...").arg(QString::number(progressBar->value()), QString::number(progressBar->maximum())));
c2f13200 »
2010-12-05 Added support for Windows 7 taskbar features (progress and overlay ic…
351 WinSevenTaskbar::setTaskbarProgress(this, progressBar->value(), progressBar->maximum());
d6e5b9e0 »
2010-12-02 AAC decoding support added.
352 }
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
353
1633489a »
2010-11-20 Actually use selected encoder in progress dialog + forward output dir.
354 int index = m_threadList.indexOf(dynamic_cast<ProcessThread*>(QWidget::sender()));
355 if(index >= 0)
356 {
357 m_threadList.takeAt(index)->deleteLater();
358 }
359
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
360 if(!m_pendingJobs.isEmpty() && !m_userAborted)
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
361 {
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
362 startNextJob();
363 qDebug("Running jobs: %u", m_runningThreads);
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
364 return;
365 }
366
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
367 if(m_runningThreads > 0)
368 {
369 qDebug("Running jobs: %u", m_runningThreads);
370 return;
371 }
372
4fd8ec06 »
2010-11-25 Addded context menu to "source file" view + make the "output folder" …
373 QApplication::setOverrideCursor(Qt::WaitCursor);
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
374 qDebug("Running jobs: %u", m_runningThreads);
375
47a6c2fd »
2010-11-21 Make "Save output files to the same location where the input file is …
376 if(!m_userAborted && m_settings->createPlaylist() && !m_settings->outputToSourceDir())
970f2cd8 »
2010-11-20 Create playlist file + serialize filename generation, just to be sure.
377 {
c4e0415e »
2011-01-13 Fix to more typos.
378 SET_PROGRESS_TEXT(tr("Creating the playlist file, please wait..."));
970f2cd8 »
2010-11-20 Create playlist file + serialize filename generation, just to be sure.
379 QApplication::processEvents();
380 writePlayList();
381 }
382
47a6c2fd »
2010-11-21 Make "Save output files to the same location where the input file is …
383 if(m_userAborted)
384 {
d6e5b9e0 »
2010-12-02 AAC decoding support added.
385 CHANGE_BACKGROUND_COLOR(frame_header, QColor("#FFF3BA"));
c2f13200 »
2010-12-05 Added support for Windows 7 taskbar features (progress and overlay ic…
386 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarErrorState);
387 WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/error.png"));
f6465c7c »
2011-01-14 Make 5 more strings translatable.
388 SET_PROGRESS_TEXT((m_succeededJobs.count() > 0) ? tr("Process was aborted by the user after %1 file(s)!").arg(QString::number(m_succeededJobs.count())) : tr("Process was aborted prematurely by the user!"));
8c0fa118 »
2011-01-02 make more strings translatable + try to load a default translation th…
389 m_systemTray->showMessage(tr("LameXP - Aborted"), tr("Process was aborted by the user."), QSystemTrayIcon::Warning);
0534264b »
2010-12-12 WMA decoding support. Limitations in the WMA decoder we cannot do any…
390 m_systemTray->setIcon(QIcon(":/icons/cd_delete.png"));
09bac5a0 »
2010-11-25 Add more SFX for the user's pleasure.
391 QApplication::processEvents();
53a1bf6e »
2010-11-29 Implement update reminder + added options to disable the update remin…
392 if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABORTED), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
47a6c2fd »
2010-11-21 Make "Save output files to the same location where the input file is …
393 }
394 else
395 {
64919656 »
2010-12-10 Add items to the playlist in the order the jobs are created, rather t…
396 if(m_failedJobs.count() > 0)
47a6c2fd »
2010-11-21 Make "Save output files to the same location where the input file is …
397 {
d6e5b9e0 »
2010-12-02 AAC decoding support added.
398 CHANGE_BACKGROUND_COLOR(frame_header, QColor("#FFBABA"));
c2f13200 »
2010-12-05 Added support for Windows 7 taskbar features (progress and overlay ic…
399 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarErrorState);
400 WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/exclamation.png"));
8c0fa118 »
2011-01-02 make more strings translatable + try to load a default translation th…
401 SET_PROGRESS_TEXT(tr("Error: %1 of %2 files failed. Double-click failed items for detailed information!").arg(QString::number(m_failedJobs.count()), QString::number(m_failedJobs.count() + m_succeededJobs.count())));
402 m_systemTray->showMessage(tr("LameXP - Error"), tr("At least one file has failed!"), QSystemTrayIcon::Critical);
0534264b »
2010-12-12 WMA decoding support. Limitations in the WMA decoder we cannot do any…
403 m_systemTray->setIcon(QIcon(":/icons/cd_delete.png"));
09bac5a0 »
2010-11-25 Add more SFX for the user's pleasure.
404 QApplication::processEvents();
53a1bf6e »
2010-11-29 Implement update reminder + added options to disable the update remin…
405 if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ERROR), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
47a6c2fd »
2010-11-21 Make "Save output files to the same location where the input file is …
406 }
407 else
408 {
fc148e5e »
2010-12-19 Implement filter framework + currently only the "downmix" filter is i…
409 CHANGE_BACKGROUND_COLOR(frame_header, QColor("#E0FFE2"));
c2f13200 »
2010-12-05 Added support for Windows 7 taskbar features (progress and overlay ic…
410 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNormalState);
411 WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/accept.png"));
979205e4 »
2011-02-21 Fixed one typo.
412 SET_PROGRESS_TEXT(tr("All files completed successfully."));
8c0fa118 »
2011-01-02 make more strings translatable + try to load a default translation th…
413 m_systemTray->showMessage(tr("LameXP - Done"), tr("All files completed successfully."), QSystemTrayIcon::Information);
0534264b »
2010-12-12 WMA decoding support. Limitations in the WMA decoder we cannot do any…
414 m_systemTray->setIcon(QIcon(":/icons/cd_add.png"));
09bac5a0 »
2010-11-25 Add more SFX for the user's pleasure.
415 QApplication::processEvents();
53a1bf6e »
2010-11-29 Implement update reminder + added options to disable the update remin…
416 if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_SUCCESS), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
47a6c2fd »
2010-11-21 Make "Save output files to the same location where the input file is …
417 }
418 }
419
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
420 setCloseButtonEnabled(true);
421 button_closeDialog->setEnabled(true);
422 button_AbortProcess->setEnabled(false);
108c1677 »
2011-03-18 Added an option to shutdown the computer as soon as all files are com…
423 checkBox_shutdownComputer->setEnabled(false);
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
424
5c2961e1 »
2011-06-13 Don't display more than 50 table items in the processing window. It s…
425 m_progressModel->restoreHiddenItems();
a29780ef »
2010-11-25 Don't try to encode from source files that aren't supported by the en…
426 view_log->scrollToBottom();
47a6c2fd »
2010-11-21 Make "Save output files to the same location where the input file is …
427 m_progressIndicator->stop();
c2f13200 »
2010-12-05 Added support for Windows 7 taskbar features (progress and overlay ic…
428 progressBar->setValue(progressBar->maximum());
429 WinSevenTaskbar::setTaskbarProgress(this, progressBar->value(), progressBar->maximum());
4fd8ec06 »
2010-11-25 Addded context menu to "source file" view + make the "output folder" …
430
431 QApplication::restoreOverrideCursor();
108c1677 »
2011-03-18 Added an option to shutdown the computer as soon as all files are com…
432
433 if(!m_userAborted && checkBox_shutdownComputer->isChecked())
434 {
f60515ca »
2011-03-18 Use custom Wave files instead of Beep(), as the Beep() function doesn…
435 if(shutdownComputer())
436 {
437 m_shutdownFlag = true;
438 accept();
439 }
108c1677 »
2011-03-18 Added an option to shutdown the computer as soon as all files are com…
440 }
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
441 }
442
970f2cd8 »
2010-11-20 Create playlist file + serialize filename generation, just to be sure.
443 void ProcessingDialog::processFinished(const QUuid &jobId, const QString &outFileName, bool success)
444 {
445 if(success)
446 {
64919656 »
2010-12-10 Add items to the playlist in the order the jobs are created, rather t…
447 m_playList.insert(jobId, outFileName);
448 m_succeededJobs.append(jobId);
970f2cd8 »
2010-11-20 Create playlist file + serialize filename generation, just to be sure.
449 }
47a6c2fd »
2010-11-21 Make "Save output files to the same location where the input file is …
450 else
451 {
64919656 »
2010-12-10 Add items to the playlist in the order the jobs are created, rather t…
452 m_failedJobs.append(jobId);
47a6c2fd »
2010-11-21 Make "Save output files to the same location where the input file is …
453 }
454 }
455
456 void ProcessingDialog::progressModelChanged(void)
457 {
458 view_log->scrollToBottom();
970f2cd8 »
2010-11-20 Create playlist file + serialize filename generation, just to be sure.
459 }
460
c0ece99b »
2010-11-22 Implemented logging and added a log file view.
461 void ProcessingDialog::logViewDoubleClicked(const QModelIndex &index)
462 {
463 if(m_runningThreads == 0)
464 {
465 const QStringList &logFile = m_progressModel->getLogFile(index);
d9e775b4 »
2011-02-02 Show notification in progress window, if multi-threading is activated.
466
467 if(!logFile.isEmpty())
468 {
469 LogViewDialog *logView = new LogViewDialog(this);
470 logView->setWindowTitle(QString("LameXP - [%1]").arg(m_progressModel->data(index, Qt::DisplayRole).toString()));
471 logView->exec(logFile);
472 LAMEXP_DELETE(logView);
473 }
474 else
475 {
476 MessageBeep(MB_ICONWARNING);
477 }
c0ece99b »
2010-11-22 Implemented logging and added a log file view.
478 }
571df62e »
2010-11-24 Implement support for Job Objects + improve log view.
479 else
480 {
481 MessageBeep(MB_ICONWARNING);
482 }
483 }
484
485 void ProcessingDialog::contextMenuTriggered(const QPoint &pos)
486 {
c967a013 »
2011-02-14 Properly map the popup menu position to global coordinates.
487 QAbstractScrollArea *scrollArea = dynamic_cast<QAbstractScrollArea*>(QObject::sender());
488 QWidget *sender = scrollArea ? scrollArea->viewport() : dynamic_cast<QWidget*>(QObject::sender());
489
490 if(pos.x() <= sender->width() && pos.y() <= sender->height() && pos.x() >= 0 && pos.y() >= 0)
38d60fe6 »
2010-12-22 Fix context menu in progress dialog.
491 {
c967a013 »
2011-02-14 Properly map the popup menu position to global coordinates.
492 m_contextMenu->popup(sender->mapToGlobal(pos));
38d60fe6 »
2010-12-22 Fix context menu in progress dialog.
493 }
571df62e »
2010-11-24 Implement support for Job Objects + improve log view.
494 }
495
b12e524a »
2011-02-11 Add option "Brose Output File Location" to context menu in processing…
496 void ProcessingDialog::contextMenuDetailsActionTriggered(void)
571df62e »
2010-11-24 Implement support for Job Objects + improve log view.
497 {
498 QModelIndex index = view_log->indexAt(view_log->mapFromGlobal(m_contextMenu->pos()));
499 logViewDoubleClicked(index.isValid() ? index : view_log->currentIndex());
c0ece99b »
2010-11-22 Implemented logging and added a log file view.
500 }
501
b12e524a »
2011-02-11 Add option "Brose Output File Location" to context menu in processing…
502 void ProcessingDialog::contextMenuShowFileActionTriggered(void)
503 {
504 QModelIndex index = view_log->indexAt(view_log->mapFromGlobal(m_contextMenu->pos()));
505 const QUuid &jobId = m_progressModel->getJobId(index.isValid() ? index : view_log->currentIndex());
506 QString filePath = m_playList.value(jobId, QString());
507
508 if(filePath.isEmpty())
509 {
510 MessageBeep(MB_ICONWARNING);
511 return;
512 }
513
514 if(QFileInfo(filePath).exists())
515 {
516 QString systemRootPath;
517
518 QDir systemRoot(lamexp_known_folder(lamexp_folder_systemfolder));
519 if(systemRoot.exists() && systemRoot.cdUp())
520 {
521 systemRootPath = systemRoot.canonicalPath();
522 }
523
524 if(!systemRootPath.isEmpty())
525 {
526 QFileInfo explorer(QString("%1/explorer.exe").arg(systemRootPath));
527 if(explorer.exists() && explorer.isFile())
528 {
529 QProcess::execute(explorer.canonicalFilePath(), QStringList() << "/select," << QDir::toNativeSeparators(QFileInfo(filePath).canonicalFilePath()));
530 return;
531 }
532 }
533 else
534 {
535 qWarning("SystemRoot directory could not be detected!");
536 }
537 }
538 else
539 {
540 qWarning("File not found: %s", filePath.toLatin1().constData());
541 MessageBeep(MB_ICONERROR);
542 }
543 }
544
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
545 ////////////////////////////////////////////////////////////
546 // Private Functions
547 ////////////////////////////////////////////////////////////
548
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
549 void ProcessingDialog::startNextJob(void)
550 {
551 if(m_pendingJobs.isEmpty())
552 {
553 return;
554 }
cffa6a24 »
2010-11-20 Correctly forward meta info to MP3 encoder and apply.
555
556 m_currentFile++;
557 AudioFileModel currentFile = updateMetaInfo(m_pendingJobs.takeFirst());
1633489a »
2010-11-20 Actually use selected encoder in progress dialog + forward output dir.
558 AbstractEncoder *encoder = NULL;
d13050c3 »
2011-01-26 Added "Resample" filter, based on SoX. Used for encoders that don't s…
559 bool nativeResampling = false;
e6460b97 »
2010-12-14 FLAC encoding support.
560
ce872af9 »
2011-08-06 Apply "Force Stereo Downmix" only for sources with more than two chan…
561 //Create encoder instance
1633489a »
2010-11-20 Actually use selected encoder in progress dialog + forward output dir.
562 switch(m_settings->compressionEncoder())
563 {
564 case SettingsModel::MP3Encoder:
565 {
566 MP3Encoder *mp3Encoder = new MP3Encoder();
567 mp3Encoder->setBitrate(m_settings->compressionBitrate());
568 mp3Encoder->setRCMode(m_settings->compressionRCMode());
476edebd »
2011-01-21 Initial support for advanced options. Only "LAME Algorithm Quality" s…
569 mp3Encoder->setAlgoQuality(m_settings->lameAlgoQuality());
3f0796d2 »
2011-01-21 Added support for bitrate management to LAME and OggEnc2 encoders.
570 if(m_settings->bitrateManagementEnabled())
571 {
572 mp3Encoder->setBitrateLimits(m_settings->bitrateManagementMinRate(), m_settings->bitrateManagementMaxRate());
573 }
d13050c3 »
2011-01-26 Added "Resample" filter, based on SoX. Used for encoders that don't s…
574 if(m_settings->samplingRate() > 0)
575 {
576 mp3Encoder->setSamplingRate(SettingsModel::samplingRates[m_settings->samplingRate()]);
577 nativeResampling = true;
578 }
7e44c69c »
2011-01-23 Actually make the Nero AAC Profile/2-Pass options work. Also make the…
579 mp3Encoder->setChannelMode(m_settings->lameChannelMode());
cfb20fe3 »
2011-02-09 Added support for custom encoder parameters.
580 mp3Encoder->setCustomParams(m_settings->customParametersLAME());
1633489a »
2010-11-20 Actually use selected encoder in progress dialog + forward output dir.
581 encoder = mp3Encoder;
582 }
583 break;
11f57aec »
2010-11-26 Ogg Vorbis encoding support.
584 case SettingsModel::VorbisEncoder:
585 {
586 VorbisEncoder *vorbisEncoder = new VorbisEncoder();
587 vorbisEncoder->setBitrate(m_settings->compressionBitrate());
588 vorbisEncoder->setRCMode(m_settings->compressionRCMode());
3f0796d2 »
2011-01-21 Added support for bitrate management to LAME and OggEnc2 encoders.
589 if(m_settings->bitrateManagementEnabled())
590 {
591 vorbisEncoder->setBitrateLimits(m_settings->bitrateManagementMinRate(), m_settings->bitrateManagementMaxRate());
592 }
d13050c3 »
2011-01-26 Added "Resample" filter, based on SoX. Used for encoders that don't s…
593 if(m_settings->samplingRate() > 0)
594 {
595 vorbisEncoder->setSamplingRate(SettingsModel::samplingRates[m_settings->samplingRate()]);
596 nativeResampling = true;
597 }
cfb20fe3 »
2011-02-09 Added support for custom encoder parameters.
598 vorbisEncoder->setCustomParams(m_settings->customParametersOggEnc());
11f57aec »
2010-11-26 Ogg Vorbis encoding support.
599 encoder = vorbisEncoder;
600 }
601 break;
be4ce0d8 »
2010-12-03 Added AAC encoding support.
602 case SettingsModel::AACEncoder:
603 {
95f627ee »
2011-08-21 Some more clean-up for FhgAacEnc support + updated documents.
604 if(lamexp_check_tool("fhgaacenc.exe") && lamexp_check_tool("enc_fhgaac.dll"))
84883ab5 »
2011-08-19 Added experimental(!) support for FhgAacEnc. Replaces the Nero AAC en…
605 {
95f627ee »
2011-08-21 Some more clean-up for FhgAacEnc support + updated documents.
606 FHGAACEncoder *aacEncoder = new FHGAACEncoder();
84883ab5 »
2011-08-19 Added experimental(!) support for FhgAacEnc. Replaces the Nero AAC en…
607 aacEncoder->setBitrate(m_settings->compressionBitrate());
608 aacEncoder->setRCMode(m_settings->compressionRCMode());
95f627ee »
2011-08-21 Some more clean-up for FhgAacEnc support + updated documents.
609 aacEncoder->setProfile(m_settings->aacEncProfile());
610 aacEncoder->setCustomParams(m_settings->customParametersAacEnc());
84883ab5 »
2011-08-19 Added experimental(!) support for FhgAacEnc. Replaces the Nero AAC en…
611 encoder = aacEncoder;
612 }
613 else
614 {
95f627ee »
2011-08-21 Some more clean-up for FhgAacEnc support + updated documents.
615 AACEncoder *aacEncoder = new AACEncoder();
84883ab5 »
2011-08-19 Added experimental(!) support for FhgAacEnc. Replaces the Nero AAC en…
616 aacEncoder->setBitrate(m_settings->compressionBitrate());
617 aacEncoder->setRCMode(m_settings->compressionRCMode());
95f627ee »
2011-08-21 Some more clean-up for FhgAacEnc support + updated documents.
618 aacEncoder->setEnable2Pass(m_settings->neroAACEnable2Pass());
619 aacEncoder->setProfile(m_settings->aacEncProfile());
620 aacEncoder->setCustomParams(m_settings->customParametersAacEnc());
84883ab5 »
2011-08-19 Added experimental(!) support for FhgAacEnc. Replaces the Nero AAC en…
621 encoder = aacEncoder;
622 }
be4ce0d8 »
2010-12-03 Added AAC encoding support.
623 }
624 break;
be71e483 »
2011-05-04 Initial ATSC A/52 (aka "AC-3", aka "Dolby Digital") encoding support,…
625 case SettingsModel::AC3Encoder:
626 {
627 AC3Encoder *ac3Encoder = new AC3Encoder();
628 ac3Encoder->setBitrate(m_settings->compressionBitrate());
629 ac3Encoder->setRCMode(m_settings->compressionRCMode());
0d2b1642 »
2011-05-05 Implemented encoding mode and bitrate selection for AC-3 encoder. Als…
630 ac3Encoder->setCustomParams(m_settings->customParametersAften());
e01f6853 »
2011-05-07 Added more options for Aften to the "Advanced Options" tab.
631 ac3Encoder->setAudioCodingMode(m_settings->aftenAudioCodingMode());
632 ac3Encoder->setDynamicRangeCompression(m_settings->aftenDynamicRangeCompression());
633 ac3Encoder->setExponentSearchSize(m_settings->aftenExponentSearchSize());
634 ac3Encoder->setFastBitAllocation(m_settings->aftenFastBitAllocation());
be71e483 »
2011-05-04 Initial ATSC A/52 (aka "AC-3", aka "Dolby Digital") encoding support,…
635 encoder = ac3Encoder;
636 }
637 break;
e6460b97 »
2010-12-14 FLAC encoding support.
638 case SettingsModel::FLACEncoder:
639 {
640 FLACEncoder *flacEncoder = new FLACEncoder();
641 flacEncoder->setBitrate(m_settings->compressionBitrate());
642 flacEncoder->setRCMode(m_settings->compressionRCMode());
cfb20fe3 »
2011-02-09 Added support for custom encoder parameters.
643 flacEncoder->setCustomParams(m_settings->customParametersFLAC());
e6460b97 »
2010-12-14 FLAC encoding support.
644 encoder = flacEncoder;
645 }
646 break;
e189eb08 »
2010-12-17 Support for Wave (PCM) output.
647 case SettingsModel::PCMEncoder:
648 {
649 WaveEncoder *waveEncoder = new WaveEncoder();
650 waveEncoder->setBitrate(m_settings->compressionBitrate());
651 waveEncoder->setRCMode(m_settings->compressionRCMode());
652 encoder = waveEncoder;
653 }
654 break;
1633489a »
2010-11-20 Actually use selected encoder in progress dialog + forward output dir.
655 default:
656 throw "Unsupported encoder!";
657 }
47a6c2fd »
2010-11-21 Make "Save output files to the same location where the input file is …
658
ce872af9 »
2011-08-06 Apply "Force Stereo Downmix" only for sources with more than two chan…
659 //Create processing thread
063c5301 »
2010-12-14 Added an option to prepend the source file's relative path to the out…
660 ProcessThread *thread = new ProcessThread
661 (
662 currentFile,
f829d696 »
2011-02-25 Added an option to select a user-defined TEMP directory.
663 (m_settings->outputToSourceDir() ? QFileInfo(currentFile.filePath()).absolutePath() : m_settings->outputDir()),
664 (m_settings->customTempPathEnabled() ? m_settings->customTempPath() : lamexp_temp_folder2()),
063c5301 »
2010-12-14 Added an option to prepend the source file's relative path to the out…
665 encoder,
666 m_settings->prependRelativeSourcePath()
667 );
58ded8c2 »
2011-01-25 Added a normalization filter, based on SoX.
668
ce872af9 »
2011-08-06 Apply "Force Stereo Downmix" only for sources with more than two chan…
669 //Add audio filters
dae4def2 »
2011-08-07 Downmix filter will now check if the input already is Mono/Stereo, so…
670 if(m_settings->forceStereoDownmix())
fbee147f »
2011-08-05 Added an option option to enforce Stereo Downmix.
671 {
672 thread->addFilter(new DownmixFilter());
673 }
d13050c3 »
2011-01-26 Added "Resample" filter, based on SoX. Used for encoders that don't s…
674 if((m_settings->samplingRate() > 0) && !nativeResampling)
675 {
c1cde1ac »
2011-02-20 Invoke the "resampling" filter only if the target sampling rate is re…
676 if(SettingsModel::samplingRates[m_settings->samplingRate()] != currentFile.formatAudioSamplerate() || currentFile.formatAudioSamplerate() == 0)
677 {
678 thread->addFilter(new ResampleFilter(SettingsModel::samplingRates[m_settings->samplingRate()]));
679 }
d13050c3 »
2011-01-26 Added "Resample" filter, based on SoX. Used for encoders that don't s…
680 }
681 if((m_settings->toneAdjustBass() != 0) || (m_settings->toneAdjustTreble() != 0))
682 {
683 thread->addFilter(new ToneAdjustFilter(m_settings->toneAdjustBass(), m_settings->toneAdjustTreble()));
684 }
58ded8c2 »
2011-01-25 Added a normalization filter, based on SoX.
685 if(m_settings->normalizationFilterEnabled())
686 {
687 thread->addFilter(new NormalizeFilter(m_settings->normalizationFilterMaxVolume()));
688 }
ce872af9 »
2011-08-06 Apply "Force Stereo Downmix" only for sources with more than two chan…
689 if(m_settings->renameOutputFilesEnabled() && (!m_settings->renameOutputFilesPattern().simplified().isEmpty()))
7e1f790e »
2011-08-04 Added an option to rename the output files (based on an user-defined …
690 {
691 thread->setRenamePattern(m_settings->renameOutputFilesPattern());
692 }
58ded8c2 »
2011-01-25 Added a normalization filter, based on SoX.
693
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
694 m_threadList.append(thread);
64919656 »
2010-12-10 Add items to the playlist in the order the jobs are created, rather t…
695 m_allJobs.append(thread->getId());
11f57aec »
2010-11-26 Ogg Vorbis encoding support.
696
ce872af9 »
2011-08-06 Apply "Force Stereo Downmix" only for sources with more than two chan…
697 //Connect thread signals
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
698 connect(thread, SIGNAL(finished()), this, SLOT(doneEncoding()), Qt::QueuedConnection);
699 connect(thread, SIGNAL(processStateInitialized(QUuid,QString,QString,int)), m_progressModel, SLOT(addJob(QUuid,QString,QString,int)), Qt::QueuedConnection);
700 connect(thread, SIGNAL(processStateChanged(QUuid,QString,int)), m_progressModel, SLOT(updateJob(QUuid,QString,int)), Qt::QueuedConnection);
970f2cd8 »
2010-11-20 Create playlist file + serialize filename generation, just to be sure.
701 connect(thread, SIGNAL(processStateFinished(QUuid,QString,bool)), this, SLOT(processFinished(QUuid,QString,bool)), Qt::QueuedConnection);
c0ece99b »
2010-11-22 Implemented logging and added a log file view.
702 connect(thread, SIGNAL(processMessageLogged(QUuid,QString)), m_progressModel, SLOT(appendToLog(QUuid,QString)), Qt::QueuedConnection);
11f57aec »
2010-11-26 Ogg Vorbis encoding support.
703
ce872af9 »
2011-08-06 Apply "Force Stereo Downmix" only for sources with more than two chan…
704 //Give it a go!
28a926b8 »
2010-11-19 Implement multi-theaded processing in progress dialog.
705 m_runningThreads++;
706 thread->start();
707 }
708
970f2cd8 »
2010-11-20 Create playlist file + serialize filename generation, just to be sure.
709 void ProcessingDialog::writePlayList(void)
710 {
64919656 »
2010-12-10 Add items to the playlist in the order the jobs are created, rather t…
711 if(m_succeededJobs.count() <= 0 || m_allJobs.count() <= 0)
712 {
713 qWarning("WritePlayList: Nothing to do!");
714 return;
715 }
716
e076c5b5 »
2011-06-02 Create proper .m3u8 playlist with UTF-8 BOM, if the file names contai…
717 //Init local variables
718 const static char *invalidChars = "\\/:*?\"<>|";
719 QStringList list;
720 bool useUtf8 = false;
721 int counter = 1;
722
723 //Generate playlist name
970f2cd8 »
2010-11-20 Create playlist file + serialize filename generation, just to be sure.
724 QString playListName = (m_metaInfo->fileAlbum().isEmpty() ? "Playlist" : m_metaInfo->fileAlbum());
e076c5b5 »
2011-06-02 Create proper .m3u8 playlist with UTF-8 BOM, if the file names contai…
725 if(!m_metaInfo->fileArtist().isEmpty())
726 {
727 playListName = QString("%1 - %2").arg(m_metaInfo->fileArtist(), playListName);
728 }
970f2cd8 »
2010-11-20 Create playlist file + serialize filename generation, just to be sure.
729
e076c5b5 »
2011-06-02 Create proper .m3u8 playlist with UTF-8 BOM, if the file names contai…
730 //Clean playlist name
970f2cd8 »
2010-11-20 Create playlist file + serialize filename generation, just to be sure.
731 for(int i = 0; invalidChars[i]; i++)
732 {
e076c5b5 »
2011-06-02 Create proper .m3u8 playlist with UTF-8 BOM, if the file names contai…
733 playListName = playListName.replace(invalidChars[i], ' ').simplified();
970f2cd8 »
2010-11-20 Create playlist file + serialize filename generation, just to be sure.
734 }
735
e076c5b5 »
2011-06-02 Create proper .m3u8 playlist with UTF-8 BOM, if the file names contai…
736 //Create list of audio files
737 for(int i = 0; i < m_allJobs.count(); i++)
738 {
739 if(!m_succeededJobs.contains(m_allJobs.at(i))) continue;
740 list << QDir::toNativeSeparators(QDir(m_settings->outputDir()).relativeFilePath(m_playList.value(m_allJobs.at(i), "N/A")));
741 }
742
743 //Do we need an UTF-8 playlist?
744 for(int i = 0; i < list.count(); i++)
745 {
746 if(wcscmp(QWCHAR(QString::fromLatin1(list.at(i).toLatin1().constData())), QWCHAR(list.at(i))))
747 {
748 useUtf8 = true;
749 break;
750 }
751 }
752
753 //Generate playlist output file
754 QString playListFile = QString("%1/%2.%3").arg(m_settings->outputDir(), playListName, (useUtf8 ? "m3u8" : "m3u"));
970f2cd8 »
2010-11-20 Create playlist file + serialize filename generation, just to be sure.
755 while(QFileInfo(playListFile).exists())
756 {
e076c5b5 »
2011-06-02 Create proper .m3u8 playlist with UTF-8 BOM, if the file names contai…
757 playListFile = QString("%1/%2 (%3).%4").arg(m_settings->outputDir(), playListName, QString::number(++counter), (useUtf8 ? "m3u8" : "m3u"));
970f2cd8 »
2010-11-20 Create playlist file + serialize filename generation, just to be sure.
758 }
64919656 »
2010-12-10 Add items to the playlist in the order the jobs are created, rather t…
759
e076c5b5 »
2011-06-02 Create proper .m3u8 playlist with UTF-8 BOM, if the file names contai…
760 //Now write playlist to output file
970f2cd8 »
2010-11-20 Create playlist file + serialize filename generation, just to be sure.
761 QFile playList(playListFile);
762 if(playList.open(QIODevice::WriteOnly))
763 {
e076c5b5 »
2011-06-02 Create proper .m3u8 playlist with UTF-8 BOM, if the file names contai…
764 if(useUtf8)
765 {
766 playList.write("\xef\xbb\xbf");
767 }
970f2cd8 »
2010-11-20 Create playlist file + serialize filename generation, just to be sure.
768 playList.write("#EXTM3U\r\n");
e076c5b5 »
2011-06-02 Create proper .m3u8 playlist with UTF-8 BOM, if the file names contai…
769 while(!list.isEmpty())
970f2cd8 »
2010-11-20 Create playlist file + serialize filename generation, just to be sure.
770 {
e076c5b5 »
2011-06-02 Create proper .m3u8 playlist with UTF-8 BOM, if the file names contai…
771 playList.write(useUtf8 ? list.takeFirst().toUtf8().constData() : list.takeFirst().toLatin1().constData());
970f2cd8 »
2010-11-20 Create playlist file + serialize filename generation, just to be sure.
772 playList.write("\r\n");
773 }
774 playList.close();
775 }
47a6c2fd »
2010-11-21 Make "Save output files to the same location where the input file is …
776 else
777 {
8c0fa118 »
2011-01-02 make more strings translatable + try to load a default translation th…
778 QMessageBox::warning(this, tr("Playlist creation failed"), QString("%1<br><nobr>%2</nobr>").arg(tr("The playlist file could not be created:"), playListFile));
47a6c2fd »
2010-11-21 Make "Save output files to the same location where the input file is …
779 }
970f2cd8 »
2010-11-20 Create playlist file + serialize filename generation, just to be sure.
780 }
781
cffa6a24 »
2010-11-20 Correctly forward meta info to MP3 encoder and apply.
782 AudioFileModel ProcessingDialog::updateMetaInfo(const AudioFileModel &audioFile)
783 {
784 if(!m_settings->writeMetaTags())
785 {
0fd4b56a »
2011-02-06 Refactor audio file model.
786 return AudioFileModel(audioFile, false);
cffa6a24 »
2010-11-20 Correctly forward meta info to MP3 encoder and apply.
787 }
788
789 AudioFileModel result = audioFile;
0fd4b56a »
2011-02-06 Refactor audio file model.
790 result.updateMetaInfo(*m_metaInfo);
791
792 if(m_metaInfo->filePosition() == UINT_MAX)
793 {
794 result.setFilePosition(m_currentFile);
795 }
cffa6a24 »
2010-11-20 Correctly forward meta info to MP3 encoder and apply.
796
797 return result;
798 }
799
3170f358 »
2010-11-18 Implement processing thread and connect to processing dialog.
800 void ProcessingDialog::setCloseButtonEnabled(bool enabled)
801 {
802 HMENU hMenu = GetSystemMenu((HWND) winId(), FALSE);
803 EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_GRAYED));
7a79c476 »
2010-11-17 Implemented processing dialog, no functionality yet.
804 }
18bed9ea »
2010-12-10 Added a system tray icon.
805
806 void ProcessingDialog::systemTrayActivated(QSystemTrayIcon::ActivationReason reason)
807 {
808 if(reason == QSystemTrayIcon::DoubleClick)
809 {
810 SetForegroundWindow(this->winId());
811 }
812 }
108c1677 »
2011-03-18 Added an option to shutdown the computer as soon as all files are com…
813
f60515ca »
2011-03-18 Use custom Wave files instead of Beep(), as the Beep() function doesn…
814 bool ProcessingDialog::shutdownComputer(void)
108c1677 »
2011-03-18 Added an option to shutdown the computer as soon as all files are com…
815 {
816 const int iTimeout = 30;
817 const Qt::WindowFlags flags = Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowSystemMenuHint;
818 const QString text = QString("%1%2%1").arg(QString().fill(' ', 18), tr("Warning: Computer will shutdown in %1 seconds..."));
819
f60515ca »
2011-03-18 Use custom Wave files instead of Beep(), as the Beep() function doesn…
820 qWarning("Initiating shutdown sequence!");
821
108c1677 »
2011-03-18 Added an option to shutdown the computer as soon as all files are com…
822 QProgressDialog progressDialog(text.arg(iTimeout), tr("Cancel Shutdown"), 0, iTimeout + 1, this, flags);
eeab6155 »
2011-03-28 Updated version info: v4.01 RC-1.
823 QPushButton *cancelButton = new QPushButton(tr("Cancel Shutdown"), &progressDialog);
824 cancelButton->setIcon(QIcon(":/icons/power_on.png"));
108c1677 »
2011-03-18 Added an option to shutdown the computer as soon as all files are com…
825 progressDialog.setModal(true);
826 progressDialog.setAutoClose(false);
827 progressDialog.setAutoReset(false);
eeab6155 »
2011-03-28 Updated version info: v4.01 RC-1.
828 progressDialog.setWindowIcon(QIcon(":/icons/power_off.png"));
829 progressDialog.setCancelButton(cancelButton);
108c1677 »
2011-03-18 Added an option to shutdown the computer as soon as all files are com…
830 progressDialog.show();
831
832 QApplication::processEvents();
833
834 if(m_settings->soundsEnabled())
835 {
f60515ca »
2011-03-18 Use custom Wave files instead of Beep(), as the Beep() function doesn…
836 QApplication::setOverrideCursor(Qt::WaitCursor);
108c1677 »
2011-03-18 Added an option to shutdown the computer as soon as all files are com…
837 PlaySound(MAKEINTRESOURCE(IDR_WAVE_SHUTDOWN), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
f60515ca »
2011-03-18 Use custom Wave files instead of Beep(), as the Beep() function doesn…
838 QApplication::restoreOverrideCursor();
108c1677 »
2011-03-18 Added an option to shutdown the computer as soon as all files are com…
839 }
840
841 QTimer timer;
842 timer.setInterval(1000);
843 timer.start();
844
845 QEventLoop eventLoop(this);
846 connect(&timer, SIGNAL(timeout()), &eventLoop, SLOT(quit()));
847 connect(&progressDialog, SIGNAL(canceled()), &eventLoop, SLOT(quit()));
848
849 for(int i = 1; i <= iTimeout; i++)
850 {
851 eventLoop.exec();
f60515ca »
2011-03-18 Use custom Wave files instead of Beep(), as the Beep() function doesn…
852 if(progressDialog.wasCanceled())
853 {
854 progressDialog.close();
855 return false;
856 }
108c1677 »
2011-03-18 Added an option to shutdown the computer as soon as all files are com…
857 progressDialog.setValue(i+1);
858 progressDialog.setLabelText(text.arg(iTimeout-i));
eeab6155 »
2011-03-28 Updated version info: v4.01 RC-1.
859 if(iTimeout-i == 3) progressDialog.setCancelButton(NULL);
108c1677 »
2011-03-18 Added an option to shutdown the computer as soon as all files are com…
860 QApplication::processEvents();
f60515ca »
2011-03-18 Use custom Wave files instead of Beep(), as the Beep() function doesn…
861 PlaySound(MAKEINTRESOURCE((i < iTimeout) ? IDR_WAVE_BEEP : IDR_WAVE_BEEP_LONG), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
108c1677 »
2011-03-18 Added an option to shutdown the computer as soon as all files are com…
862 }
863
864 progressDialog.close();
f60515ca »
2011-03-18 Use custom Wave files instead of Beep(), as the Beep() function doesn…
865 return true;
108c1677 »
2011-03-18 Added an option to shutdown the computer as soon as all files are com…
866 }
Something went wrong with that request. Please try again.