Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 594 lines (514 sloc) 19.738 kB
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
96db5e8 @lordmulder Happy new year!
authored
3 // Copyright (C) 2004-2011 LoRd_MuldeR <MuldeR2@GMX.de>
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
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"
11f57ae @lordmulder Ogg Vorbis encoding support.
authored
25 #include "Resource.h"
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
26 #include "Model_FileList.h"
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
27 #include "Model_Progress.h"
1633489 @lordmulder Actually use selected encoder in progress dialog + forward output dir.
authored
28 #include "Model_Settings.h"
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
29 #include "Thread_Process.h"
c0ece99 @lordmulder Implemented logging and added a log file view.
authored
30 #include "Dialog_LogView.h"
11f57ae @lordmulder Ogg Vorbis encoding support.
authored
31 #include "Encoder_MP3.h"
32 #include "Encoder_Vorbis.h"
be4ce0d @lordmulder Added AAC encoding support.
authored
33 #include "Encoder_AAC.h"
e6460b9 @lordmulder FLAC encoding support.
authored
34 #include "Encoder_FLAC.h"
e189eb0 @lordmulder Support for Wave (PCM) output.
authored
35 #include "Encoder_Wave.h"
58ded8c @lordmulder Added a normalization filter, based on SoX.
authored
36 #include "Filter_Normalize.h"
c2f1320 @lordmulder Added support for Windows 7 taskbar features (progress and overlay ic…
authored
37 #include "WinSevenTaskbar.h"
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
38
39 #include <QApplication>
40 #include <QRect>
41 #include <QDesktopWidget>
42 #include <QMovie>
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
43 #include <QMessageBox>
44 #include <QTimer>
45 #include <QCloseEvent>
46 #include <QDesktopServices>
47 #include <QUrl>
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
48 #include <QUuid>
49 #include <QFileInfo>
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
50 #include <QDir>
571df62 @lordmulder Implement support for Job Objects + improve log view.
authored
51 #include <QMenu>
18bed9e @lordmulder Added a system tray icon.
authored
52 #include <QSystemTrayIcon>
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
53
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
54 #include <Windows.h>
55
d6e5b9e @lordmulder AAC decoding support added.
authored
56 #define CHANGE_BACKGROUND_COLOR(WIDGET, COLOR) \
57 { \
58 QPalette palette = WIDGET->palette(); \
59 palette.setColor(QPalette::Background, COLOR); \
60 WIDGET->setPalette(palette); \
61 }
62
18bed9e @lordmulder Added a system tray icon.
authored
63 #define SET_PROGRESS_TEXT(TXT) \
64 { \
65 label_progress->setText(TXT); \
66 m_systemTray->setToolTip(QString().sprintf("LameXP v%d.%02d\n%ls", lamexp_version_major(), lamexp_version_minor(), QString(TXT).utf16())); \
67 }
68
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
69 ////////////////////////////////////////////////////////////
70 // Constructor
71 ////////////////////////////////////////////////////////////
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
72
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
73 ProcessingDialog::ProcessingDialog(FileListModel *fileListModel, AudioFileModel *metaInfo, SettingsModel *settings, QWidget *parent)
1633489 @lordmulder Actually use selected encoder in progress dialog + forward output dir.
authored
74 :
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
75 QDialog(parent),
0534264 @lordmulder WMA decoding support. Limitations in the WMA decoder we cannot do any…
authored
76 m_systemTray(new QSystemTrayIcon(QIcon(":/icons/cd_go.png"), this)),
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
77 m_settings(settings),
78 m_metaInfo(metaInfo)
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
79 {
80 //Init the dialog, from the .ui file
81 setupUi(this);
82 setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
092e664 @lordmulder More detailed error output when process failed to create + use UUID's…
authored
83
84 //Setup version info
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
85 label_versionInfo->setText(QString().sprintf("v%d.%02d %s (Build %d)", lamexp_version_major(), lamexp_version_minor(), lamexp_version_release(), lamexp_version_build()));
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
86 label_versionInfo->installEventFilter(this);
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
87
092e664 @lordmulder More detailed error output when process failed to create + use UUID's…
authored
88 //Register meta type
89 qRegisterMetaType<QUuid>("QUuid");
90
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
91 //Center window in screen
92 QRect desktopRect = QApplication::desktop()->screenGeometry();
93 QRect thisRect = this->geometry();
94 move((desktopRect.width() - thisRect.width()) / 2, (desktopRect.height() - thisRect.height()) / 2);
95 setMinimumSize(thisRect.width(), thisRect.height());
96
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
97 //Enable buttons
98 connect(button_AbortProcess, SIGNAL(clicked()), this, SLOT(abortEncoding()));
99
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
100 //Init progress indicator
101 m_progressIndicator = new QMovie(":/images/Working.gif");
102 label_headerWorking->setMovie(m_progressIndicator);
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
103 progressBar->setValue(0);
104
105 //Init progress model
106 m_progressModel = new ProgressModel();
107 view_log->setModel(m_progressModel);
108 view_log->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
109 view_log->verticalHeader()->hide();
110 view_log->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
111 view_log->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
112 connect(m_progressModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(progressModelChanged()));
113 connect(m_progressModel, SIGNAL(modelReset()), this, SLOT(progressModelChanged()));
11f57ae @lordmulder Ogg Vorbis encoding support.
authored
114 connect(view_log, SIGNAL(activated(QModelIndex)), this, SLOT(logViewDoubleClicked(QModelIndex)));
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
115
571df62 @lordmulder Implement support for Job Objects + improve log view.
authored
116 //Create context menu
117 m_contextMenu = new QMenu();
8c0fa11 @lordmulder make more strings translatable + try to load a default translation th…
authored
118 QAction *contextMenuAction = m_contextMenu->addAction(QIcon(":/icons/zoom.png"), tr("Show details for selected job"));
571df62 @lordmulder Implement support for Job Objects + improve log view.
authored
119 view_log->setContextMenuPolicy(Qt::CustomContextMenu);
120 connect(view_log, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTriggered(QPoint)));
121 connect(contextMenuAction, SIGNAL(triggered(bool)), this, SLOT(contextMenuActionTriggered()));
122
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
123 //Enque jobs
124 if(fileListModel)
125 {
126 for(int i = 0; i < fileListModel->rowCount(); i++)
127 {
128 m_pendingJobs.append(fileListModel->getFile(fileListModel->index(i,0)));
129 }
130 }
131
5a1ff67 @lordmulder Make more strings translatable.
authored
132 //Translate
133 label_headerStatus->setText(QString("<b>%1</b><br>%2").arg(tr("Encoding Files"), tr("Your files are being encoded, please be patient...")));
134
18bed9e @lordmulder Added a system tray icon.
authored
135 //Enable system tray icon
136 connect(m_systemTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systemTrayActivated(QSystemTrayIcon::ActivationReason)));
137
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
138 //Init other vars
139 m_runningThreads = 0;
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
140 m_currentFile = 0;
6491965 @lordmulder Add items to the playlist in the order the jobs are created, rather t…
authored
141 m_allJobs.clear();
142 m_succeededJobs.clear();
143 m_failedJobs.clear();
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
144 m_userAborted = false;
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
145 }
146
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
147 ////////////////////////////////////////////////////////////
148 // Destructor
149 ////////////////////////////////////////////////////////////
150
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
151 ProcessingDialog::~ProcessingDialog(void)
152 {
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
153 view_log->setModel(NULL);
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
154 if(m_progressIndicator) m_progressIndicator->stop();
155 LAMEXP_DELETE(m_progressIndicator);
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
156 LAMEXP_DELETE(m_progressModel);
571df62 @lordmulder Implement support for Job Objects + improve log view.
authored
157 LAMEXP_DELETE(m_contextMenu);
18bed9e @lordmulder Added a system tray icon.
authored
158 LAMEXP_DELETE(m_systemTray);
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
159
c2f1320 @lordmulder Added support for Windows 7 taskbar features (progress and overlay ic…
authored
160 WinSevenTaskbar::setOverlayIcon(this, NULL);
161 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNoState);
162
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
163 while(!m_threadList.isEmpty())
164 {
1633489 @lordmulder Actually use selected encoder in progress dialog + forward output dir.
authored
165 ProcessThread *thread = m_threadList.takeFirst();
166 thread->terminate();
167 thread->wait(15000);
168 delete thread;
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
169 }
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
170 }
171
172 ////////////////////////////////////////////////////////////
173 // EVENTS
174 ////////////////////////////////////////////////////////////
175
176 void ProcessingDialog::showEvent(QShowEvent *event)
177 {
178 setCloseButtonEnabled(false);
179 button_closeDialog->setEnabled(false);
180 button_AbortProcess->setEnabled(false);
18bed9e @lordmulder Added a system tray icon.
authored
181 m_systemTray->setVisible(true);
182
9947e9c @lordmulder Detect the entry points for some of the Win32 API functions on Runtim…
authored
183 if(!SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS))
184 {
185 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
186 }
187
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
188 QTimer::singleShot(1000, this, SLOT(initEncoding()));
189 }
190
191 void ProcessingDialog::closeEvent(QCloseEvent *event)
192 {
18bed9e @lordmulder Added a system tray icon.
authored
193 if(!button_closeDialog->isEnabled())
194 {
195 event->ignore();
196 }
197 else
198 {
199 m_systemTray->setVisible(false);
200 }
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
201 }
202
203 bool ProcessingDialog::eventFilter(QObject *obj, QEvent *event)
204 {
205 static QColor defaultColor = QColor();
206
207 if(obj == label_versionInfo)
208 {
209 if(event->type() == QEvent::Enter)
210 {
211 QPalette palette = label_versionInfo->palette();
212 defaultColor = palette.color(QPalette::Normal, QPalette::WindowText);
213 palette.setColor(QPalette::Normal, QPalette::WindowText, Qt::red);
214 label_versionInfo->setPalette(palette);
215 }
216 else if(event->type() == QEvent::Leave)
217 {
218 QPalette palette = label_versionInfo->palette();
219 palette.setColor(QPalette::Normal, QPalette::WindowText, defaultColor);
220 label_versionInfo->setPalette(palette);
221 }
222 else if(event->type() == QEvent::MouseButtonPress)
223 {
224 QUrl url("http://mulder.dummwiedeutsch.de/");
225 QDesktopServices::openUrl(url);
226 }
227 }
228
229 return false;
230 }
231
232 ////////////////////////////////////////////////////////////
233 // SLOTS
234 ////////////////////////////////////////////////////////////
235
236 void ProcessingDialog::initEncoding(void)
237 {
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
238 m_runningThreads = 0;
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
239 m_currentFile = 0;
6491965 @lordmulder Add items to the playlist in the order the jobs are created, rather t…
authored
240 m_allJobs.clear();
241 m_succeededJobs.clear();
242 m_failedJobs.clear();
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
243 m_userAborted = false;
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
244 m_playList.clear();
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
245
d6e5b9e @lordmulder AAC decoding support added.
authored
246 CHANGE_BACKGROUND_COLOR(frame_header, QColor(Qt::white));
8c0fa11 @lordmulder make more strings translatable + try to load a default translation th…
authored
247 SET_PROGRESS_TEXT(tr("Encoding files, please wait..."));
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
248 m_progressIndicator->start();
249
250 button_closeDialog->setEnabled(false);
251 button_AbortProcess->setEnabled(true);
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
252 progressBar->setRange(0, m_pendingJobs.count());
253
c2f1320 @lordmulder Added support for Windows 7 taskbar features (progress and overlay ic…
authored
254 WinSevenTaskbar::initTaskbar();
255 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNormalState);
256 WinSevenTaskbar::setTaskbarProgress(this, 0, m_pendingJobs.count());
257 WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/control_play_blue.png"));
258
571df62 @lordmulder Implement support for Job Objects + improve log view.
authored
259 lamexp_cpu_t cpuFeatures = lamexp_detect_cpu_features();
260
261 for(int i = 0; i < min(max(cpuFeatures.count, 1), 4); i++)
262 {
263 startNextJob();
264 }
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
265 }
266
267 void ProcessingDialog::abortEncoding(void)
268 {
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
269 m_userAborted = true;
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
270 button_AbortProcess->setEnabled(false);
271
8c0fa11 @lordmulder make more strings translatable + try to load a default translation th…
authored
272 SET_PROGRESS_TEXT(tr("Aborted! Waiting for running jobs to terminate..."));
d6e5b9e @lordmulder AAC decoding support added.
authored
273
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
274 for(int i = 0; i < m_threadList.count(); i++)
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
275 {
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
276 m_threadList.at(i)->abort();
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
277 }
278 }
279
280 void ProcessingDialog::doneEncoding(void)
281 {
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
282 m_runningThreads--;
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
283 progressBar->setValue(progressBar->value() + 1);
d6e5b9e @lordmulder AAC decoding support added.
authored
284
285 if(!m_userAborted)
286 {
8c0fa11 @lordmulder make more strings translatable + try to load a default translation th…
authored
287 SET_PROGRESS_TEXT(tr("Encoding: %1 files of %2 completed so far, please wait...").arg(QString::number(progressBar->value()), QString::number(progressBar->maximum())));
c2f1320 @lordmulder Added support for Windows 7 taskbar features (progress and overlay ic…
authored
288 WinSevenTaskbar::setTaskbarProgress(this, progressBar->value(), progressBar->maximum());
d6e5b9e @lordmulder AAC decoding support added.
authored
289 }
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
290
1633489 @lordmulder Actually use selected encoder in progress dialog + forward output dir.
authored
291 int index = m_threadList.indexOf(dynamic_cast<ProcessThread*>(QWidget::sender()));
292 if(index >= 0)
293 {
294 m_threadList.takeAt(index)->deleteLater();
295 }
296
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
297 if(!m_pendingJobs.isEmpty() && !m_userAborted)
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
298 {
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
299 startNextJob();
300 qDebug("Running jobs: %u", m_runningThreads);
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
301 return;
302 }
303
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
304 if(m_runningThreads > 0)
305 {
306 qDebug("Running jobs: %u", m_runningThreads);
307 return;
308 }
309
4fd8ec0 @lordmulder Addded context menu to "source file" view + make the "output folder" …
authored
310 QApplication::setOverrideCursor(Qt::WaitCursor);
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
311 qDebug("Running jobs: %u", m_runningThreads);
312
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
313 if(!m_userAborted && m_settings->createPlaylist() && !m_settings->outputToSourceDir())
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
314 {
c4e0415 @lordmulder Fix to more typos.
authored
315 SET_PROGRESS_TEXT(tr("Creating the playlist file, please wait..."));
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
316 QApplication::processEvents();
317 writePlayList();
318 }
319
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
320 if(m_userAborted)
321 {
d6e5b9e @lordmulder AAC decoding support added.
authored
322 CHANGE_BACKGROUND_COLOR(frame_header, QColor("#FFF3BA"));
c2f1320 @lordmulder Added support for Windows 7 taskbar features (progress and overlay ic…
authored
323 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarErrorState);
324 WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/error.png"));
f6465c7 @lordmulder Make 5 more strings translatable.
authored
325 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!"));
8c0fa11 @lordmulder make more strings translatable + try to load a default translation th…
authored
326 m_systemTray->showMessage(tr("LameXP - Aborted"), tr("Process was aborted by the user."), QSystemTrayIcon::Warning);
0534264 @lordmulder WMA decoding support. Limitations in the WMA decoder we cannot do any…
authored
327 m_systemTray->setIcon(QIcon(":/icons/cd_delete.png"));
09bac5a @lordmulder Add more SFX for the user's pleasure.
authored
328 QApplication::processEvents();
53a1bf6 @lordmulder Implement update reminder + added options to disable the update remin…
authored
329 if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABORTED), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
330 }
331 else
332 {
6491965 @lordmulder Add items to the playlist in the order the jobs are created, rather t…
authored
333 if(m_failedJobs.count() > 0)
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
334 {
d6e5b9e @lordmulder AAC decoding support added.
authored
335 CHANGE_BACKGROUND_COLOR(frame_header, QColor("#FFBABA"));
c2f1320 @lordmulder Added support for Windows 7 taskbar features (progress and overlay ic…
authored
336 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarErrorState);
337 WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/exclamation.png"));
8c0fa11 @lordmulder make more strings translatable + try to load a default translation th…
authored
338 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())));
339 m_systemTray->showMessage(tr("LameXP - Error"), tr("At least one file has failed!"), QSystemTrayIcon::Critical);
0534264 @lordmulder WMA decoding support. Limitations in the WMA decoder we cannot do any…
authored
340 m_systemTray->setIcon(QIcon(":/icons/cd_delete.png"));
09bac5a @lordmulder Add more SFX for the user's pleasure.
authored
341 QApplication::processEvents();
53a1bf6 @lordmulder Implement update reminder + added options to disable the update remin…
authored
342 if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ERROR), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
343 }
344 else
345 {
fc148e5 @lordmulder Implement filter framework + currently only the "downmix" filter is i…
authored
346 CHANGE_BACKGROUND_COLOR(frame_header, QColor("#E0FFE2"));
c2f1320 @lordmulder Added support for Windows 7 taskbar features (progress and overlay ic…
authored
347 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNormalState);
348 WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/accept.png"));
8c0fa11 @lordmulder make more strings translatable + try to load a default translation th…
authored
349 SET_PROGRESS_TEXT(tr("Alle files completed successfully."));
350 m_systemTray->showMessage(tr("LameXP - Done"), tr("All files completed successfully."), QSystemTrayIcon::Information);
0534264 @lordmulder WMA decoding support. Limitations in the WMA decoder we cannot do any…
authored
351 m_systemTray->setIcon(QIcon(":/icons/cd_add.png"));
09bac5a @lordmulder Add more SFX for the user's pleasure.
authored
352 QApplication::processEvents();
53a1bf6 @lordmulder Implement update reminder + added options to disable the update remin…
authored
353 if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_SUCCESS), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
354 }
355 }
356
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
357 setCloseButtonEnabled(true);
358 button_closeDialog->setEnabled(true);
359 button_AbortProcess->setEnabled(false);
360
a29780e @lordmulder Don't try to encode from source files that aren't supported by the en…
authored
361 view_log->scrollToBottom();
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
362 m_progressIndicator->stop();
c2f1320 @lordmulder Added support for Windows 7 taskbar features (progress and overlay ic…
authored
363 progressBar->setValue(progressBar->maximum());
364 WinSevenTaskbar::setTaskbarProgress(this, progressBar->value(), progressBar->maximum());
4fd8ec0 @lordmulder Addded context menu to "source file" view + make the "output folder" …
authored
365
366 QApplication::restoreOverrideCursor();
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
367 }
368
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
369 void ProcessingDialog::processFinished(const QUuid &jobId, const QString &outFileName, bool success)
370 {
371 if(success)
372 {
6491965 @lordmulder Add items to the playlist in the order the jobs are created, rather t…
authored
373 m_playList.insert(jobId, outFileName);
374 m_succeededJobs.append(jobId);
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
375 }
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
376 else
377 {
6491965 @lordmulder Add items to the playlist in the order the jobs are created, rather t…
authored
378 m_failedJobs.append(jobId);
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
379 }
380 }
381
382 void ProcessingDialog::progressModelChanged(void)
383 {
384 view_log->scrollToBottom();
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
385 }
386
c0ece99 @lordmulder Implemented logging and added a log file view.
authored
387 void ProcessingDialog::logViewDoubleClicked(const QModelIndex &index)
388 {
389 if(m_runningThreads == 0)
390 {
391 const QStringList &logFile = m_progressModel->getLogFile(index);
392 LogViewDialog *logView = new LogViewDialog(this);
9947e9c @lordmulder Detect the entry points for some of the Win32 API functions on Runtim…
authored
393 logView->setWindowTitle(QString("LameXP - [%1]").arg(m_progressModel->data(index, Qt::DisplayRole).toString()));
c0ece99 @lordmulder Implemented logging and added a log file view.
authored
394 logView->exec(logFile);
395 LAMEXP_DELETE(logView);
396 }
571df62 @lordmulder Implement support for Job Objects + improve log view.
authored
397 else
398 {
399 MessageBeep(MB_ICONWARNING);
400 }
401 }
402
403 void ProcessingDialog::contextMenuTriggered(const QPoint &pos)
404 {
38d60fe @lordmulder Fix context menu in progress dialog.
authored
405 if(pos.x() <= view_log->width() && pos.y() <= view_log->height() && pos.x() >= 0 && pos.y() >= 0)
406 {
407 m_contextMenu->popup(view_log->mapToGlobal(pos));
408 }
571df62 @lordmulder Implement support for Job Objects + improve log view.
authored
409 }
410
411 void ProcessingDialog::contextMenuActionTriggered(void)
412 {
413 QModelIndex index = view_log->indexAt(view_log->mapFromGlobal(m_contextMenu->pos()));
414 logViewDoubleClicked(index.isValid() ? index : view_log->currentIndex());
c0ece99 @lordmulder Implemented logging and added a log file view.
authored
415 }
416
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
417 ////////////////////////////////////////////////////////////
418 // Private Functions
419 ////////////////////////////////////////////////////////////
420
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
421 void ProcessingDialog::startNextJob(void)
422 {
423 if(m_pendingJobs.isEmpty())
424 {
425 return;
426 }
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
427
428 m_currentFile++;
429 AudioFileModel currentFile = updateMetaInfo(m_pendingJobs.takeFirst());
1633489 @lordmulder Actually use selected encoder in progress dialog + forward output dir.
authored
430 AbstractEncoder *encoder = NULL;
e6460b9 @lordmulder FLAC encoding support.
authored
431
1633489 @lordmulder Actually use selected encoder in progress dialog + forward output dir.
authored
432 switch(m_settings->compressionEncoder())
433 {
434 case SettingsModel::MP3Encoder:
435 {
436 MP3Encoder *mp3Encoder = new MP3Encoder();
437 mp3Encoder->setBitrate(m_settings->compressionBitrate());
438 mp3Encoder->setRCMode(m_settings->compressionRCMode());
476edeb @lordmulder Initial support for advanced options. Only "LAME Algorithm Quality" s…
authored
439 mp3Encoder->setAlgoQuality(m_settings->lameAlgoQuality());
3f0796d @lordmulder Added support for bitrate management to LAME and OggEnc2 encoders.
authored
440 if(m_settings->bitrateManagementEnabled())
441 {
442 mp3Encoder->setBitrateLimits(m_settings->bitrateManagementMinRate(), m_settings->bitrateManagementMaxRate());
443 }
7e44c69 @lordmulder Actually make the Nero AAC Profile/2-Pass options work. Also make the…
authored
444 mp3Encoder->setSamplingRate(SettingsModel::samplingRates[m_settings->samplingRate()]);
445 mp3Encoder->setChannelMode(m_settings->lameChannelMode());
1633489 @lordmulder Actually use selected encoder in progress dialog + forward output dir.
authored
446 encoder = mp3Encoder;
447 }
448 break;
11f57ae @lordmulder Ogg Vorbis encoding support.
authored
449 case SettingsModel::VorbisEncoder:
450 {
451 VorbisEncoder *vorbisEncoder = new VorbisEncoder();
452 vorbisEncoder->setBitrate(m_settings->compressionBitrate());
453 vorbisEncoder->setRCMode(m_settings->compressionRCMode());
3f0796d @lordmulder Added support for bitrate management to LAME and OggEnc2 encoders.
authored
454 if(m_settings->bitrateManagementEnabled())
455 {
456 vorbisEncoder->setBitrateLimits(m_settings->bitrateManagementMinRate(), m_settings->bitrateManagementMaxRate());
457 }
dcf4181 @lordmulder Make sampling rate option work with Vorbis encoder.
authored
458 vorbisEncoder->setSamplingRate(SettingsModel::samplingRates[m_settings->samplingRate()]);
11f57ae @lordmulder Ogg Vorbis encoding support.
authored
459 encoder = vorbisEncoder;
460 }
461 break;
be4ce0d @lordmulder Added AAC encoding support.
authored
462 case SettingsModel::AACEncoder:
463 {
464 AACEncoder *aacEncoder = new AACEncoder();
465 aacEncoder->setBitrate(m_settings->compressionBitrate());
466 aacEncoder->setRCMode(m_settings->compressionRCMode());
7e44c69 @lordmulder Actually make the Nero AAC Profile/2-Pass options work. Also make the…
authored
467 aacEncoder->setEnable2Pass(m_settings->neroAACEnable2Pass());
468 aacEncoder->setProfile(m_settings->neroAACProfile());
be4ce0d @lordmulder Added AAC encoding support.
authored
469 encoder = aacEncoder;
470 }
471 break;
e6460b9 @lordmulder FLAC encoding support.
authored
472 case SettingsModel::FLACEncoder:
473 {
474 FLACEncoder *flacEncoder = new FLACEncoder();
475 flacEncoder->setBitrate(m_settings->compressionBitrate());
476 flacEncoder->setRCMode(m_settings->compressionRCMode());
477 encoder = flacEncoder;
478 }
479 break;
e189eb0 @lordmulder Support for Wave (PCM) output.
authored
480 case SettingsModel::PCMEncoder:
481 {
482 WaveEncoder *waveEncoder = new WaveEncoder();
483 waveEncoder->setBitrate(m_settings->compressionBitrate());
484 waveEncoder->setRCMode(m_settings->compressionRCMode());
485 encoder = waveEncoder;
486 }
487 break;
1633489 @lordmulder Actually use selected encoder in progress dialog + forward output dir.
authored
488 default:
489 throw "Unsupported encoder!";
490 }
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
491
063c530 @lordmulder Added an option to prepend the source file's relative path to the out…
authored
492 ProcessThread *thread = new ProcessThread
493 (
494 currentFile,
495 (m_settings->outputToSourceDir() ? QFileInfo(currentFile.filePath()).absolutePath(): m_settings->outputDir()),
496 encoder,
497 m_settings->prependRelativeSourcePath()
498 );
58ded8c @lordmulder Added a normalization filter, based on SoX.
authored
499
500 if(m_settings->normalizationFilterEnabled())
501 {
502 thread->addFilter(new NormalizeFilter(m_settings->normalizationFilterMaxVolume()));
503 }
504
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
505 m_threadList.append(thread);
6491965 @lordmulder Add items to the playlist in the order the jobs are created, rather t…
authored
506 m_allJobs.append(thread->getId());
11f57ae @lordmulder Ogg Vorbis encoding support.
authored
507
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
508 connect(thread, SIGNAL(finished()), this, SLOT(doneEncoding()), Qt::QueuedConnection);
509 connect(thread, SIGNAL(processStateInitialized(QUuid,QString,QString,int)), m_progressModel, SLOT(addJob(QUuid,QString,QString,int)), Qt::QueuedConnection);
510 connect(thread, SIGNAL(processStateChanged(QUuid,QString,int)), m_progressModel, SLOT(updateJob(QUuid,QString,int)), Qt::QueuedConnection);
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
511 connect(thread, SIGNAL(processStateFinished(QUuid,QString,bool)), this, SLOT(processFinished(QUuid,QString,bool)), Qt::QueuedConnection);
c0ece99 @lordmulder Implemented logging and added a log file view.
authored
512 connect(thread, SIGNAL(processMessageLogged(QUuid,QString)), m_progressModel, SLOT(appendToLog(QUuid,QString)), Qt::QueuedConnection);
11f57ae @lordmulder Ogg Vorbis encoding support.
authored
513
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
514 m_runningThreads++;
515 thread->start();
516 }
517
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
518 void ProcessingDialog::writePlayList(void)
519 {
6491965 @lordmulder Add items to the playlist in the order the jobs are created, rather t…
authored
520 if(m_succeededJobs.count() <= 0 || m_allJobs.count() <= 0)
521 {
522 qWarning("WritePlayList: Nothing to do!");
523 return;
524 }
525
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
526 QString playListName = (m_metaInfo->fileAlbum().isEmpty() ? "Playlist" : m_metaInfo->fileAlbum());
527
528 const static char *invalidChars = "\\/:*?\"<>|";
529 for(int i = 0; invalidChars[i]; i++)
530 {
531 playListName.replace(invalidChars[i], ' ');
532 playListName = playListName.simplified();
533 }
534
535 QString playListFile = QString("%1/%2.m3u").arg(m_settings->outputDir(), playListName);
536
537 int counter = 1;
538 while(QFileInfo(playListFile).exists())
539 {
540 playListFile = QString("%1/%2 (%3).m3u").arg(m_settings->outputDir(), playListName, QString::number(++counter));
541 }
6491965 @lordmulder Add items to the playlist in the order the jobs are created, rather t…
authored
542
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
543 QFile playList(playListFile);
544 if(playList.open(QIODevice::WriteOnly))
545 {
546 playList.write("#EXTM3U\r\n");
6491965 @lordmulder Add items to the playlist in the order the jobs are created, rather t…
authored
547 for(int i = 0; i < m_allJobs.count(); i++)
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
548 {
6491965 @lordmulder Add items to the playlist in the order the jobs are created, rather t…
authored
549
550 if(!m_succeededJobs.contains(m_allJobs.at(i))) continue;
063c530 @lordmulder Added an option to prepend the source file's relative path to the out…
authored
551 playList.write(QDir::toNativeSeparators(QDir(m_settings->outputDir()).relativeFilePath(m_playList.value(m_allJobs.at(i), "N/A"))).toUtf8().constData());
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
552 playList.write("\r\n");
553 }
554 playList.close();
555 }
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
556 else
557 {
8c0fa11 @lordmulder make more strings translatable + try to load a default translation th…
authored
558 QMessageBox::warning(this, tr("Playlist creation failed"), QString("%1<br><nobr>%2</nobr>").arg(tr("The playlist file could not be created:"), playListFile));
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
559 }
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
560 }
561
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
562 AudioFileModel ProcessingDialog::updateMetaInfo(const AudioFileModel &audioFile)
563 {
564 if(!m_settings->writeMetaTags())
565 {
566 return AudioFileModel(audioFile.filePath());
567 }
568
569 AudioFileModel result = audioFile;
570
571 if(!m_metaInfo->fileArtist().isEmpty()) result.setFileArtist(m_metaInfo->fileArtist());
572 if(!m_metaInfo->fileAlbum().isEmpty()) result.setFileAlbum(m_metaInfo->fileAlbum());
573 if(!m_metaInfo->fileGenre().isEmpty()) result.setFileGenre(m_metaInfo->fileGenre());
574 if(m_metaInfo->fileYear()) result.setFileYear(m_metaInfo->fileYear());
e6460b9 @lordmulder FLAC encoding support.
authored
575 if(m_metaInfo->filePosition() == UINT_MAX) result.setFilePosition(m_currentFile);
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
576 if(!m_metaInfo->fileComment().isEmpty()) result.setFileComment(m_metaInfo->fileComment());
577
578 return result;
579 }
580
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
581 void ProcessingDialog::setCloseButtonEnabled(bool enabled)
582 {
583 HMENU hMenu = GetSystemMenu((HWND) winId(), FALSE);
584 EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_GRAYED));
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
585 }
18bed9e @lordmulder Added a system tray icon.
authored
586
587 void ProcessingDialog::systemTrayActivated(QSystemTrayIcon::ActivationReason reason)
588 {
589 if(reason == QSystemTrayIcon::DoubleClick)
590 {
591 SetForegroundWindow(this->winId());
592 }
593 }
Something went wrong with that request. Please try again.