Skip to content
Newer
Older
100644 456 lines (388 sloc) 14 KB
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2010 LoRd_MuldeR <MuldeR2@GMX.de>
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"
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
33
34 #include <QApplication>
35 #include <QRect>
36 #include <QDesktopWidget>
37 #include <QMovie>
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
38 #include <QMessageBox>
39 #include <QTimer>
40 #include <QCloseEvent>
41 #include <QDesktopServices>
42 #include <QUrl>
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
43 #include <QUuid>
44 #include <QFileInfo>
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
45 #include <QDir>
571df62 @lordmulder Implement support for Job Objects + improve log view.
authored
46 #include <QMenu>
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
47
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
48 #include <Windows.h>
49
50 ////////////////////////////////////////////////////////////
51 // Constructor
52 ////////////////////////////////////////////////////////////
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
53
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
54 ProcessingDialog::ProcessingDialog(FileListModel *fileListModel, AudioFileModel *metaInfo, SettingsModel *settings, QWidget *parent)
1633489 @lordmulder Actually use selected encoder in progress dialog + forward output dir.
authored
55 :
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
56 QDialog(parent),
57 m_settings(settings),
58 m_metaInfo(metaInfo)
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
59 {
60 //Init the dialog, from the .ui file
61 setupUi(this);
62 setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
092e664 @lordmulder More detailed error output when process failed to create + use UUID's…
authored
63
64 //Setup version info
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
65 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
66 label_versionInfo->installEventFilter(this);
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
67
092e664 @lordmulder More detailed error output when process failed to create + use UUID's…
authored
68 //Register meta type
69 qRegisterMetaType<QUuid>("QUuid");
70
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
71 //Center window in screen
72 QRect desktopRect = QApplication::desktop()->screenGeometry();
73 QRect thisRect = this->geometry();
74 move((desktopRect.width() - thisRect.width()) / 2, (desktopRect.height() - thisRect.height()) / 2);
75 setMinimumSize(thisRect.width(), thisRect.height());
76
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
77 //Enable buttons
78 connect(button_AbortProcess, SIGNAL(clicked()), this, SLOT(abortEncoding()));
79
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
80 //Init progress indicator
81 m_progressIndicator = new QMovie(":/images/Working.gif");
82 label_headerWorking->setMovie(m_progressIndicator);
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
83 progressBar->setValue(0);
84
85 //Init progress model
86 m_progressModel = new ProgressModel();
87 view_log->setModel(m_progressModel);
88 view_log->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
89 view_log->verticalHeader()->hide();
90 view_log->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
91 view_log->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
92 connect(m_progressModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(progressModelChanged()));
93 connect(m_progressModel, SIGNAL(modelReset()), this, SLOT(progressModelChanged()));
11f57ae @lordmulder Ogg Vorbis encoding support.
authored
94 connect(view_log, SIGNAL(activated(QModelIndex)), this, SLOT(logViewDoubleClicked(QModelIndex)));
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
95
571df62 @lordmulder Implement support for Job Objects + improve log view.
authored
96 //Create context menu
97 m_contextMenu = new QMenu();
98 QAction *contextMenuAction = m_contextMenu->addAction(QIcon(":/icons/zoom.png"), "Show details for selected job");
99 view_log->setContextMenuPolicy(Qt::CustomContextMenu);
100 connect(view_log, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTriggered(QPoint)));
101 connect(contextMenuAction, SIGNAL(triggered(bool)), this, SLOT(contextMenuActionTriggered()));
102
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
103 //Enque jobs
104 if(fileListModel)
105 {
106 for(int i = 0; i < fileListModel->rowCount(); i++)
107 {
108 m_pendingJobs.append(fileListModel->getFile(fileListModel->index(i,0)));
109 }
110 }
111
112 //Init other vars
113 m_runningThreads = 0;
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
114 m_currentFile = 0;
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
115 m_succeededFiles = 0;
116 m_failedFiles = 0;
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
117 m_userAborted = false;
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
118 }
119
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
120 ////////////////////////////////////////////////////////////
121 // Destructor
122 ////////////////////////////////////////////////////////////
123
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
124 ProcessingDialog::~ProcessingDialog(void)
125 {
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
126 view_log->setModel(NULL);
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
127 if(m_progressIndicator) m_progressIndicator->stop();
128 LAMEXP_DELETE(m_progressIndicator);
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
129 LAMEXP_DELETE(m_progressModel);
571df62 @lordmulder Implement support for Job Objects + improve log view.
authored
130 LAMEXP_DELETE(m_contextMenu);
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
131
132 while(!m_threadList.isEmpty())
133 {
1633489 @lordmulder Actually use selected encoder in progress dialog + forward output dir.
authored
134 ProcessThread *thread = m_threadList.takeFirst();
135 thread->terminate();
136 thread->wait(15000);
137 delete thread;
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
138 }
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
139 }
140
141 ////////////////////////////////////////////////////////////
142 // EVENTS
143 ////////////////////////////////////////////////////////////
144
145 void ProcessingDialog::showEvent(QShowEvent *event)
146 {
147 setCloseButtonEnabled(false);
148 button_closeDialog->setEnabled(false);
149 button_AbortProcess->setEnabled(false);
150
9947e9c @lordmulder Detect the entry points for some of the Win32 API functions on Runtim…
authored
151 if(!SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS))
152 {
153 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
154 }
155
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
156 QTimer::singleShot(1000, this, SLOT(initEncoding()));
157 }
158
159 void ProcessingDialog::closeEvent(QCloseEvent *event)
160 {
092e664 @lordmulder More detailed error output when process failed to create + use UUID's…
authored
161 if(!button_closeDialog->isEnabled()) event->ignore();
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
162 }
163
164 bool ProcessingDialog::eventFilter(QObject *obj, QEvent *event)
165 {
166 static QColor defaultColor = QColor();
167
168 if(obj == label_versionInfo)
169 {
170 if(event->type() == QEvent::Enter)
171 {
172 QPalette palette = label_versionInfo->palette();
173 defaultColor = palette.color(QPalette::Normal, QPalette::WindowText);
174 palette.setColor(QPalette::Normal, QPalette::WindowText, Qt::red);
175 label_versionInfo->setPalette(palette);
176 }
177 else if(event->type() == QEvent::Leave)
178 {
179 QPalette palette = label_versionInfo->palette();
180 palette.setColor(QPalette::Normal, QPalette::WindowText, defaultColor);
181 label_versionInfo->setPalette(palette);
182 }
183 else if(event->type() == QEvent::MouseButtonPress)
184 {
185 QUrl url("http://mulder.dummwiedeutsch.de/");
186 QDesktopServices::openUrl(url);
187 }
188 }
189
190 return false;
191 }
192
193 ////////////////////////////////////////////////////////////
194 // SLOTS
195 ////////////////////////////////////////////////////////////
196
197 void ProcessingDialog::initEncoding(void)
198 {
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
199 m_runningThreads = 0;
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
200 m_currentFile = 0;
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
201 m_succeededFiles = 0;
202 m_failedFiles = 0;
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
203 m_userAborted = false;
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
204 m_playList.clear();
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
205
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
206 label_progress->setText("Encoding files, please wait...");
207 m_progressIndicator->start();
208
209 button_closeDialog->setEnabled(false);
210 button_AbortProcess->setEnabled(true);
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
211 progressBar->setRange(0, m_pendingJobs.count());
212
571df62 @lordmulder Implement support for Job Objects + improve log view.
authored
213 lamexp_cpu_t cpuFeatures = lamexp_detect_cpu_features();
214
215 for(int i = 0; i < min(max(cpuFeatures.count, 1), 4); i++)
216 {
217 startNextJob();
218 }
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
219 }
220
221 void ProcessingDialog::abortEncoding(void)
222 {
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
223 m_userAborted = true;
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
224 button_AbortProcess->setEnabled(false);
225
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
226 for(int i = 0; i < m_threadList.count(); i++)
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
227 {
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
228 m_threadList.at(i)->abort();
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
229 }
230 }
231
232 void ProcessingDialog::doneEncoding(void)
233 {
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
234 m_runningThreads--;
235
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
236 progressBar->setValue(progressBar->value() + 1);
1633489 @lordmulder Actually use selected encoder in progress dialog + forward output dir.
authored
237 label_progress->setText(QString("Encoding: %1 files of %2 completed so far, please wait...").arg(QString::number(progressBar->value()), QString::number(progressBar->maximum())));
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
238
1633489 @lordmulder Actually use selected encoder in progress dialog + forward output dir.
authored
239 int index = m_threadList.indexOf(dynamic_cast<ProcessThread*>(QWidget::sender()));
240 if(index >= 0)
241 {
242 m_threadList.takeAt(index)->deleteLater();
243 }
244
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
245 if(!m_pendingJobs.isEmpty() && !m_userAborted)
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
246 {
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
247 startNextJob();
248 qDebug("Running jobs: %u", m_runningThreads);
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
249 return;
250 }
251
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
252 if(m_runningThreads > 0)
253 {
254 qDebug("Running jobs: %u", m_runningThreads);
255 return;
256 }
257
4fd8ec0 @lordmulder Addded context menu to "source file" view + make the "output folder" …
authored
258 QApplication::setOverrideCursor(Qt::WaitCursor);
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
259 qDebug("Running jobs: %u", m_runningThreads);
260
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
261 if(!m_userAborted && m_settings->createPlaylist() && !m_settings->outputToSourceDir())
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
262 {
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
263 label_progress->setText("Creatig the playlist file, please wait...");
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
264 QApplication::processEvents();
265 writePlayList();
266 }
267
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
268 if(m_userAborted)
269 {
11f57ae @lordmulder Ogg Vorbis encoding support.
authored
270 label_progress->setText((m_succeededFiles > 0) ? QString("Process was aborted by the user after %1 file(s)!").arg(QString::number(m_succeededFiles)) : "Process was aborted prematurely by the user!");
09bac5a @lordmulder Add more SFX for the user's pleasure.
authored
271 QApplication::processEvents();
53a1bf6 @lordmulder Implement update reminder + added options to disable the update remin…
authored
272 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
273 }
274 else
275 {
276 if(m_failedFiles)
277 {
a29780e @lordmulder Don't try to encode from source files that aren't supported by the en…
authored
278 label_progress->setText(QString("Error: %1 of %2 files failed. Double-click failed items for detailed information!").arg(QString::number(m_failedFiles), QString::number(m_failedFiles + m_succeededFiles)));
09bac5a @lordmulder Add more SFX for the user's pleasure.
authored
279 QApplication::processEvents();
53a1bf6 @lordmulder Implement update reminder + added options to disable the update remin…
authored
280 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
281 }
282 else
283 {
284 label_progress->setText("Alle files completed successfully.");
09bac5a @lordmulder Add more SFX for the user's pleasure.
authored
285 QApplication::processEvents();
53a1bf6 @lordmulder Implement update reminder + added options to disable the update remin…
authored
286 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
287 }
288 }
289
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
290 setCloseButtonEnabled(true);
291 button_closeDialog->setEnabled(true);
292 button_AbortProcess->setEnabled(false);
293
a29780e @lordmulder Don't try to encode from source files that aren't supported by the en…
authored
294 view_log->scrollToBottom();
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
295 m_progressIndicator->stop();
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
296 progressBar->setValue(100);
4fd8ec0 @lordmulder Addded context menu to "source file" view + make the "output folder" …
authored
297
298 QApplication::restoreOverrideCursor();
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
299 }
300
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
301 void ProcessingDialog::processFinished(const QUuid &jobId, const QString &outFileName, bool success)
302 {
303 if(success)
304 {
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
305 m_succeededFiles++;
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
306 m_playList.append(outFileName);
307 }
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
308 else
309 {
310 m_failedFiles++;
311 }
312 }
313
314 void ProcessingDialog::progressModelChanged(void)
315 {
316 view_log->scrollToBottom();
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
317 }
318
c0ece99 @lordmulder Implemented logging and added a log file view.
authored
319 void ProcessingDialog::logViewDoubleClicked(const QModelIndex &index)
320 {
321 if(m_runningThreads == 0)
322 {
323 const QStringList &logFile = m_progressModel->getLogFile(index);
324 LogViewDialog *logView = new LogViewDialog(this);
9947e9c @lordmulder Detect the entry points for some of the Win32 API functions on Runtim…
authored
325 logView->setWindowTitle(QString("LameXP - [%1]").arg(m_progressModel->data(index, Qt::DisplayRole).toString()));
c0ece99 @lordmulder Implemented logging and added a log file view.
authored
326 logView->exec(logFile);
327 LAMEXP_DELETE(logView);
328 }
571df62 @lordmulder Implement support for Job Objects + improve log view.
authored
329 else
330 {
331 MessageBeep(MB_ICONWARNING);
332 }
333 }
334
335 void ProcessingDialog::contextMenuTriggered(const QPoint &pos)
336 {
337 m_contextMenu->popup(view_log->mapToGlobal(pos));
338 }
339
340 void ProcessingDialog::contextMenuActionTriggered(void)
341 {
342 QModelIndex index = view_log->indexAt(view_log->mapFromGlobal(m_contextMenu->pos()));
343 logViewDoubleClicked(index.isValid() ? index : view_log->currentIndex());
c0ece99 @lordmulder Implemented logging and added a log file view.
authored
344 }
345
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
346 ////////////////////////////////////////////////////////////
347 // Private Functions
348 ////////////////////////////////////////////////////////////
349
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
350 void ProcessingDialog::startNextJob(void)
351 {
352 if(m_pendingJobs.isEmpty())
353 {
354 return;
355 }
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
356
357 m_currentFile++;
358 AudioFileModel currentFile = updateMetaInfo(m_pendingJobs.takeFirst());
1633489 @lordmulder Actually use selected encoder in progress dialog + forward output dir.
authored
359 AbstractEncoder *encoder = NULL;
360
361 switch(m_settings->compressionEncoder())
362 {
363 case SettingsModel::MP3Encoder:
364 {
365 MP3Encoder *mp3Encoder = new MP3Encoder();
366 mp3Encoder->setBitrate(m_settings->compressionBitrate());
367 mp3Encoder->setRCMode(m_settings->compressionRCMode());
368 encoder = mp3Encoder;
369 }
370 break;
11f57ae @lordmulder Ogg Vorbis encoding support.
authored
371 case SettingsModel::VorbisEncoder:
372 {
373 VorbisEncoder *vorbisEncoder = new VorbisEncoder();
374 vorbisEncoder->setBitrate(m_settings->compressionBitrate());
375 vorbisEncoder->setRCMode(m_settings->compressionRCMode());
376 encoder = vorbisEncoder;
377 }
378 break;
1633489 @lordmulder Actually use selected encoder in progress dialog + forward output dir.
authored
379 default:
380 throw "Unsupported encoder!";
381 }
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
382
383 ProcessThread *thread = new ProcessThread(currentFile, (m_settings->outputToSourceDir() ? QFileInfo(currentFile.filePath()).absolutePath(): m_settings->outputDir()), encoder);
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
384 m_threadList.append(thread);
11f57ae @lordmulder Ogg Vorbis encoding support.
authored
385
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
386 connect(thread, SIGNAL(finished()), this, SLOT(doneEncoding()), Qt::QueuedConnection);
387 connect(thread, SIGNAL(processStateInitialized(QUuid,QString,QString,int)), m_progressModel, SLOT(addJob(QUuid,QString,QString,int)), Qt::QueuedConnection);
388 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
389 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
390 connect(thread, SIGNAL(processMessageLogged(QUuid,QString)), m_progressModel, SLOT(appendToLog(QUuid,QString)), Qt::QueuedConnection);
11f57ae @lordmulder Ogg Vorbis encoding support.
authored
391
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
392 m_runningThreads++;
393 thread->start();
394 }
395
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
396 void ProcessingDialog::writePlayList(void)
397 {
398 QString playListName = (m_metaInfo->fileAlbum().isEmpty() ? "Playlist" : m_metaInfo->fileAlbum());
399
400 const static char *invalidChars = "\\/:*?\"<>|";
401 for(int i = 0; invalidChars[i]; i++)
402 {
403 playListName.replace(invalidChars[i], ' ');
404 playListName = playListName.simplified();
405 }
406
407 QString playListFile = QString("%1/%2.m3u").arg(m_settings->outputDir(), playListName);
408
409 int counter = 1;
410 while(QFileInfo(playListFile).exists())
411 {
412 playListFile = QString("%1/%2 (%3).m3u").arg(m_settings->outputDir(), playListName, QString::number(++counter));
413 }
414
415 QFile playList(playListFile);
416 if(playList.open(QIODevice::WriteOnly))
417 {
418 playList.write("#EXTM3U\r\n");
419 for(int i = 0; i < m_playList.count(); i++)
420 {
421 playList.write(QFileInfo(m_playList.at(i)).fileName().toUtf8().constData());
422 playList.write("\r\n");
423 }
424 playList.close();
425 }
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
426 else
427 {
428 QMessageBox::warning(this, "Playlist creation failed", QString("The playlist file could not be created:<br><nobr>%1</nobr>").arg(playListFile));
429 }
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
430 }
431
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
432 AudioFileModel ProcessingDialog::updateMetaInfo(const AudioFileModel &audioFile)
433 {
434 if(!m_settings->writeMetaTags())
435 {
436 return AudioFileModel(audioFile.filePath());
437 }
438
439 AudioFileModel result = audioFile;
440
441 if(!m_metaInfo->fileArtist().isEmpty()) result.setFileArtist(m_metaInfo->fileArtist());
442 if(!m_metaInfo->fileAlbum().isEmpty()) result.setFileAlbum(m_metaInfo->fileAlbum());
443 if(!m_metaInfo->fileGenre().isEmpty()) result.setFileGenre(m_metaInfo->fileGenre());
444 if(m_metaInfo->fileYear()) result.setFileYear(m_metaInfo->fileYear());
445 if(m_metaInfo->filePosition()) result.setFileYear(m_metaInfo->filePosition() != UINT_MAX ? m_metaInfo->filePosition() : m_currentFile);
446 if(!m_metaInfo->fileComment().isEmpty()) result.setFileComment(m_metaInfo->fileComment());
447
448 return result;
449 }
450
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
451 void ProcessingDialog::setCloseButtonEnabled(bool enabled)
452 {
453 HMENU hMenu = GetSystemMenu((HWND) winId(), FALSE);
454 EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_GRAYED));
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
455 }
Something went wrong with that request. Please try again.