Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 791 lines (683 sloc) 25.778 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"
23665ed @lordmulder Implemented a new "disk observer" thread which will constantly check …
authored
30 #include "Thread_DiskObserver.h"
c0ece99 @lordmulder Implemented logging and added a log file view.
authored
31 #include "Dialog_LogView.h"
11f57ae @lordmulder Ogg Vorbis encoding support.
authored
32 #include "Encoder_MP3.h"
33 #include "Encoder_Vorbis.h"
be4ce0d @lordmulder Added AAC encoding support.
authored
34 #include "Encoder_AAC.h"
e6460b9 @lordmulder FLAC encoding support.
authored
35 #include "Encoder_FLAC.h"
e189eb0 @lordmulder Support for Wave (PCM) output.
authored
36 #include "Encoder_Wave.h"
58ded8c @lordmulder Added a normalization filter, based on SoX.
authored
37 #include "Filter_Normalize.h"
d13050c @lordmulder Added "Resample" filter, based on SoX. Used for encoders that don't s…
authored
38 #include "Filter_Resample.h"
39 #include "Filter_ToneAdjust.h"
c2f1320 @lordmulder Added support for Windows 7 taskbar features (progress and overlay ic…
authored
40 #include "WinSevenTaskbar.h"
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
41
42 #include <QApplication>
43 #include <QRect>
44 #include <QDesktopWidget>
45 #include <QMovie>
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
46 #include <QMessageBox>
47 #include <QTimer>
48 #include <QCloseEvent>
49 #include <QDesktopServices>
50 #include <QUrl>
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
51 #include <QUuid>
52 #include <QFileInfo>
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
53 #include <QDir>
571df62 @lordmulder Implement support for Job Objects + improve log view.
authored
54 #include <QMenu>
18bed9e @lordmulder Added a system tray icon.
authored
55 #include <QSystemTrayIcon>
b12e524 @lordmulder Add option "Brose Output File Location" to context menu in processing…
authored
56 #include <QProcess>
108c167 @lordmulder Added an option to shutdown the computer as soon as all files are com…
authored
57 #include <QProgressDialog>
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
58
8977e00 @lordmulder Clean up #include directives: Don't include 'Windows.h' directly, as …
authored
59 #include <MMSystem.h>
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
60
c967a01 @lordmulder Properly map the popup menu position to global coordinates.
authored
61 ////////////////////////////////////////////////////////////
62
63d6708 @lordmulder Refactored a few constants.
authored
63 //Maximum number of parallel instances
64 #define MAX_INSTANCES 16
65
66 //Maximum number of CPU cores for auto-detection
67 #define MAX_CPU_COUNT 4
68
69 ////////////////////////////////////////////////////////////
70
d6e5b9e @lordmulder AAC decoding support added.
authored
71 #define CHANGE_BACKGROUND_COLOR(WIDGET, COLOR) \
72 { \
73 QPalette palette = WIDGET->palette(); \
74 palette.setColor(QPalette::Background, COLOR); \
75 WIDGET->setPalette(palette); \
76 }
77
18bed9e @lordmulder Added a system tray icon.
authored
78 #define SET_PROGRESS_TEXT(TXT) \
79 { \
80 label_progress->setText(TXT); \
81 m_systemTray->setToolTip(QString().sprintf("LameXP v%d.%02d\n%ls", lamexp_version_major(), lamexp_version_minor(), QString(TXT).utf16())); \
82 }
83
c967a01 @lordmulder Properly map the popup menu position to global coordinates.
authored
84 #define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); }
85
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
86 ////////////////////////////////////////////////////////////
87 // Constructor
88 ////////////////////////////////////////////////////////////
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
89
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
90 ProcessingDialog::ProcessingDialog(FileListModel *fileListModel, AudioFileModel *metaInfo, SettingsModel *settings, QWidget *parent)
1633489 @lordmulder Actually use selected encoder in progress dialog + forward output dir.
authored
91 :
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
92 QDialog(parent),
0534264 @lordmulder WMA decoding support. Limitations in the WMA decoder we cannot do any…
authored
93 m_systemTray(new QSystemTrayIcon(QIcon(":/icons/cd_go.png"), this)),
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
94 m_settings(settings),
108c167 @lordmulder Added an option to shutdown the computer as soon as all files are com…
authored
95 m_metaInfo(metaInfo),
23665ed @lordmulder Implemented a new "disk observer" thread which will constantly check …
authored
96 m_shutdownFlag(false),
97 m_diskObserver(NULL)
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
98 {
99 //Init the dialog, from the .ui file
100 setupUi(this);
101 setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
092e664 @lordmulder More detailed error output when process failed to create + use UUID's…
authored
102
103 //Setup version info
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
104 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
105 label_versionInfo->installEventFilter(this);
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
106
092e664 @lordmulder More detailed error output when process failed to create + use UUID's…
authored
107 //Register meta type
108 qRegisterMetaType<QUuid>("QUuid");
109
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
110 //Center window in screen
111 QRect desktopRect = QApplication::desktop()->screenGeometry();
112 QRect thisRect = this->geometry();
113 move((desktopRect.width() - thisRect.width()) / 2, (desktopRect.height() - thisRect.height()) / 2);
114 setMinimumSize(thisRect.width(), thisRect.height());
115
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
116 //Enable buttons
117 connect(button_AbortProcess, SIGNAL(clicked()), this, SLOT(abortEncoding()));
118
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
119 //Init progress indicator
120 m_progressIndicator = new QMovie(":/images/Working.gif");
121 label_headerWorking->setMovie(m_progressIndicator);
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
122 progressBar->setValue(0);
123
124 //Init progress model
125 m_progressModel = new ProgressModel();
126 view_log->setModel(m_progressModel);
127 view_log->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
128 view_log->verticalHeader()->hide();
129 view_log->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
130 view_log->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
131 connect(m_progressModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(progressModelChanged()));
132 connect(m_progressModel, SIGNAL(modelReset()), this, SLOT(progressModelChanged()));
11f57ae @lordmulder Ogg Vorbis encoding support.
authored
133 connect(view_log, SIGNAL(activated(QModelIndex)), this, SLOT(logViewDoubleClicked(QModelIndex)));
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
134
571df62 @lordmulder Implement support for Job Objects + improve log view.
authored
135 //Create context menu
136 m_contextMenu = new QMenu();
b12e524 @lordmulder Add option "Brose Output File Location" to context menu in processing…
authored
137 QAction *contextMenuDetailsAction = m_contextMenu->addAction(QIcon(":/icons/zoom.png"), tr("Show details for selected job"));
138 QAction *contextMenuShowFileAction = m_contextMenu->addAction(QIcon(":/icons/folder_go.png"), tr("Browse Output File Location"));
139
571df62 @lordmulder Implement support for Job Objects + improve log view.
authored
140 view_log->setContextMenuPolicy(Qt::CustomContextMenu);
141 connect(view_log, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTriggered(QPoint)));
b12e524 @lordmulder Add option "Brose Output File Location" to context menu in processing…
authored
142 connect(contextMenuDetailsAction, SIGNAL(triggered(bool)), this, SLOT(contextMenuDetailsActionTriggered()));
143 connect(contextMenuShowFileAction, SIGNAL(triggered(bool)), this, SLOT(contextMenuShowFileActionTriggered()));
c967a01 @lordmulder Properly map the popup menu position to global coordinates.
authored
144 SET_FONT_BOLD(contextMenuDetailsAction, true);
145
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
146 //Enque jobs
147 if(fileListModel)
148 {
149 for(int i = 0; i < fileListModel->rowCount(); i++)
150 {
151 m_pendingJobs.append(fileListModel->getFile(fileListModel->index(i,0)));
152 }
153 }
154
5a1ff67 @lordmulder Make more strings translatable.
authored
155 //Translate
156 label_headerStatus->setText(QString("<b>%1</b><br>%2").arg(tr("Encoding Files"), tr("Your files are being encoded, please be patient...")));
157
18bed9e @lordmulder Added a system tray icon.
authored
158 //Enable system tray icon
159 connect(m_systemTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systemTrayActivated(QSystemTrayIcon::ActivationReason)));
160
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
161 //Init other vars
162 m_runningThreads = 0;
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
163 m_currentFile = 0;
6491965 @lordmulder Add items to the playlist in the order the jobs are created, rather t…
authored
164 m_allJobs.clear();
165 m_succeededJobs.clear();
166 m_failedJobs.clear();
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
167 m_userAborted = false;
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
168 }
169
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
170 ////////////////////////////////////////////////////////////
171 // Destructor
172 ////////////////////////////////////////////////////////////
173
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
174 ProcessingDialog::~ProcessingDialog(void)
175 {
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
176 view_log->setModel(NULL);
23665ed @lordmulder Implemented a new "disk observer" thread which will constantly check …
authored
177
178 if(m_progressIndicator)
179 {
180 m_progressIndicator->stop();
181 }
182
183 if(m_diskObserver)
184 {
185 m_diskObserver->stop();
186 m_diskObserver->wait(15000);
187 }
188
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
189 LAMEXP_DELETE(m_progressIndicator);
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
190 LAMEXP_DELETE(m_progressModel);
571df62 @lordmulder Implement support for Job Objects + improve log view.
authored
191 LAMEXP_DELETE(m_contextMenu);
18bed9e @lordmulder Added a system tray icon.
authored
192 LAMEXP_DELETE(m_systemTray);
23665ed @lordmulder Implemented a new "disk observer" thread which will constantly check …
authored
193 LAMEXP_DELETE(m_diskObserver);
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
194
c2f1320 @lordmulder Added support for Windows 7 taskbar features (progress and overlay ic…
authored
195 WinSevenTaskbar::setOverlayIcon(this, NULL);
196 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNoState);
197
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
198 while(!m_threadList.isEmpty())
199 {
1633489 @lordmulder Actually use selected encoder in progress dialog + forward output dir.
authored
200 ProcessThread *thread = m_threadList.takeFirst();
201 thread->terminate();
202 thread->wait(15000);
203 delete thread;
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
204 }
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
205 }
206
207 ////////////////////////////////////////////////////////////
208 // EVENTS
209 ////////////////////////////////////////////////////////////
210
211 void ProcessingDialog::showEvent(QShowEvent *event)
212 {
213 setCloseButtonEnabled(false);
214 button_closeDialog->setEnabled(false);
215 button_AbortProcess->setEnabled(false);
18bed9e @lordmulder Added a system tray icon.
authored
216 m_systemTray->setVisible(true);
217
9947e9c @lordmulder Detect the entry points for some of the Win32 API functions on Runtim…
authored
218 if(!SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS))
219 {
220 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
221 }
222
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
223 QTimer::singleShot(1000, this, SLOT(initEncoding()));
224 }
225
226 void ProcessingDialog::closeEvent(QCloseEvent *event)
227 {
18bed9e @lordmulder Added a system tray icon.
authored
228 if(!button_closeDialog->isEnabled())
229 {
230 event->ignore();
231 }
232 else
233 {
234 m_systemTray->setVisible(false);
235 }
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
236 }
237
238 bool ProcessingDialog::eventFilter(QObject *obj, QEvent *event)
239 {
240 static QColor defaultColor = QColor();
241
242 if(obj == label_versionInfo)
243 {
244 if(event->type() == QEvent::Enter)
245 {
246 QPalette palette = label_versionInfo->palette();
247 defaultColor = palette.color(QPalette::Normal, QPalette::WindowText);
248 palette.setColor(QPalette::Normal, QPalette::WindowText, Qt::red);
249 label_versionInfo->setPalette(palette);
250 }
251 else if(event->type() == QEvent::Leave)
252 {
253 QPalette palette = label_versionInfo->palette();
254 palette.setColor(QPalette::Normal, QPalette::WindowText, defaultColor);
255 label_versionInfo->setPalette(palette);
256 }
257 else if(event->type() == QEvent::MouseButtonPress)
258 {
63d6708 @lordmulder Refactored a few constants.
authored
259 QUrl url(lamexp_website_url());
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
260 QDesktopServices::openUrl(url);
261 }
262 }
263
264 return false;
265 }
266
267 ////////////////////////////////////////////////////////////
268 // SLOTS
269 ////////////////////////////////////////////////////////////
270
271 void ProcessingDialog::initEncoding(void)
272 {
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
273 m_runningThreads = 0;
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
274 m_currentFile = 0;
6491965 @lordmulder Add items to the playlist in the order the jobs are created, rather t…
authored
275 m_allJobs.clear();
276 m_succeededJobs.clear();
277 m_failedJobs.clear();
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
278 m_userAborted = false;
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
279 m_playList.clear();
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
280
d6e5b9e @lordmulder AAC decoding support added.
authored
281 CHANGE_BACKGROUND_COLOR(frame_header, QColor(Qt::white));
8c0fa11 @lordmulder make more strings translatable + try to load a default translation th…
authored
282 SET_PROGRESS_TEXT(tr("Encoding files, please wait..."));
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
283 m_progressIndicator->start();
284
285 button_closeDialog->setEnabled(false);
286 button_AbortProcess->setEnabled(true);
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
287 progressBar->setRange(0, m_pendingJobs.count());
108c167 @lordmulder Added an option to shutdown the computer as soon as all files are com…
authored
288 checkBox_shutdownComputer->setEnabled(true);
289 checkBox_shutdownComputer->setChecked(false);
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
290
c2f1320 @lordmulder Added support for Windows 7 taskbar features (progress and overlay ic…
authored
291 WinSevenTaskbar::initTaskbar();
292 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNormalState);
293 WinSevenTaskbar::setTaskbarProgress(this, 0, m_pendingJobs.count());
294 WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/control_play_blue.png"));
295
23665ed @lordmulder Implemented a new "disk observer" thread which will constantly check …
authored
296 if(!m_diskObserver)
297 {
298 m_diskObserver = new DiskObserverThread(m_settings->customTempPathEnabled() ? m_settings->customTempPath() : lamexp_temp_folder2());
299 connect(m_diskObserver, SIGNAL(messageLogged(QString,bool)), m_progressModel, SLOT(addSystemMessage(QString,bool)), Qt::QueuedConnection);
300 m_diskObserver->start();
301 }
302
63d6708 @lordmulder Refactored a few constants.
authored
303 int maximumInstances = max(min(m_settings->maximumInstances(), MAX_INSTANCES), 0);
f75c3ca @lordmulder Added an option to manually specify the number of parallel instances.
authored
304 if(maximumInstances < 1)
305 {
306 lamexp_cpu_t cpuFeatures = lamexp_detect_cpu_features();
63d6708 @lordmulder Refactored a few constants.
authored
307 maximumInstances = max(min(cpuFeatures.count, MAX_CPU_COUNT), 1);
f75c3ca @lordmulder Added an option to manually specify the number of parallel instances.
authored
308 }
571df62 @lordmulder Implement support for Job Objects + improve log view.
authored
309
f75c3ca @lordmulder Added an option to manually specify the number of parallel instances.
authored
310 int parallelThreadCount = max(min(maximumInstances, m_pendingJobs.count()), 1);
d9e775b @lordmulder Show notification in progress window, if multi-threading is activated.
authored
311 if(parallelThreadCount > 1)
312 {
313 m_progressModel->addSystemMessage(tr("Multi-threading enabled: Running %1 instances in parallel!").arg(QString::number(parallelThreadCount)));
314 }
315
316 for(int i = 0; i < parallelThreadCount; i++)
571df62 @lordmulder Implement support for Job Objects + improve log view.
authored
317 {
318 startNextJob();
319 }
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
320 }
321
322 void ProcessingDialog::abortEncoding(void)
323 {
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
324 m_userAborted = true;
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
325 button_AbortProcess->setEnabled(false);
326
8c0fa11 @lordmulder make more strings translatable + try to load a default translation th…
authored
327 SET_PROGRESS_TEXT(tr("Aborted! Waiting for running jobs to terminate..."));
d6e5b9e @lordmulder AAC decoding support added.
authored
328
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
329 for(int i = 0; i < m_threadList.count(); i++)
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
330 {
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
331 m_threadList.at(i)->abort();
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
332 }
333 }
334
335 void ProcessingDialog::doneEncoding(void)
336 {
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
337 m_runningThreads--;
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
338 progressBar->setValue(progressBar->value() + 1);
d6e5b9e @lordmulder AAC decoding support added.
authored
339
340 if(!m_userAborted)
341 {
8c0fa11 @lordmulder make more strings translatable + try to load a default translation th…
authored
342 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
343 WinSevenTaskbar::setTaskbarProgress(this, progressBar->value(), progressBar->maximum());
d6e5b9e @lordmulder AAC decoding support added.
authored
344 }
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
345
1633489 @lordmulder Actually use selected encoder in progress dialog + forward output dir.
authored
346 int index = m_threadList.indexOf(dynamic_cast<ProcessThread*>(QWidget::sender()));
347 if(index >= 0)
348 {
349 m_threadList.takeAt(index)->deleteLater();
350 }
351
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
352 if(!m_pendingJobs.isEmpty() && !m_userAborted)
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
353 {
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
354 startNextJob();
355 qDebug("Running jobs: %u", m_runningThreads);
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
356 return;
357 }
358
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
359 if(m_runningThreads > 0)
360 {
361 qDebug("Running jobs: %u", m_runningThreads);
362 return;
363 }
364
4fd8ec0 @lordmulder Addded context menu to "source file" view + make the "output folder" …
authored
365 QApplication::setOverrideCursor(Qt::WaitCursor);
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
366 qDebug("Running jobs: %u", m_runningThreads);
367
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
368 if(!m_userAborted && m_settings->createPlaylist() && !m_settings->outputToSourceDir())
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
369 {
c4e0415 @lordmulder Fix to more typos.
authored
370 SET_PROGRESS_TEXT(tr("Creating the playlist file, please wait..."));
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
371 QApplication::processEvents();
372 writePlayList();
373 }
374
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
375 if(m_userAborted)
376 {
d6e5b9e @lordmulder AAC decoding support added.
authored
377 CHANGE_BACKGROUND_COLOR(frame_header, QColor("#FFF3BA"));
c2f1320 @lordmulder Added support for Windows 7 taskbar features (progress and overlay ic…
authored
378 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarErrorState);
379 WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/error.png"));
f6465c7 @lordmulder Make 5 more strings translatable.
authored
380 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
381 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
382 m_systemTray->setIcon(QIcon(":/icons/cd_delete.png"));
09bac5a @lordmulder Add more SFX for the user's pleasure.
authored
383 QApplication::processEvents();
53a1bf6 @lordmulder Implement update reminder + added options to disable the update remin…
authored
384 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
385 }
386 else
387 {
6491965 @lordmulder Add items to the playlist in the order the jobs are created, rather t…
authored
388 if(m_failedJobs.count() > 0)
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
389 {
d6e5b9e @lordmulder AAC decoding support added.
authored
390 CHANGE_BACKGROUND_COLOR(frame_header, QColor("#FFBABA"));
c2f1320 @lordmulder Added support for Windows 7 taskbar features (progress and overlay ic…
authored
391 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarErrorState);
392 WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/exclamation.png"));
8c0fa11 @lordmulder make more strings translatable + try to load a default translation th…
authored
393 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())));
394 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
395 m_systemTray->setIcon(QIcon(":/icons/cd_delete.png"));
09bac5a @lordmulder Add more SFX for the user's pleasure.
authored
396 QApplication::processEvents();
53a1bf6 @lordmulder Implement update reminder + added options to disable the update remin…
authored
397 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
398 }
399 else
400 {
fc148e5 @lordmulder Implement filter framework + currently only the "downmix" filter is i…
authored
401 CHANGE_BACKGROUND_COLOR(frame_header, QColor("#E0FFE2"));
c2f1320 @lordmulder Added support for Windows 7 taskbar features (progress and overlay ic…
authored
402 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNormalState);
403 WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/accept.png"));
979205e @lordmulder Fixed one typo.
authored
404 SET_PROGRESS_TEXT(tr("All files completed successfully."));
8c0fa11 @lordmulder make more strings translatable + try to load a default translation th…
authored
405 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
406 m_systemTray->setIcon(QIcon(":/icons/cd_add.png"));
09bac5a @lordmulder Add more SFX for the user's pleasure.
authored
407 QApplication::processEvents();
53a1bf6 @lordmulder Implement update reminder + added options to disable the update remin…
authored
408 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
409 }
410 }
411
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
412 setCloseButtonEnabled(true);
413 button_closeDialog->setEnabled(true);
414 button_AbortProcess->setEnabled(false);
108c167 @lordmulder Added an option to shutdown the computer as soon as all files are com…
authored
415 checkBox_shutdownComputer->setEnabled(false);
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
416
a29780e @lordmulder Don't try to encode from source files that aren't supported by the en…
authored
417 view_log->scrollToBottom();
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
418 m_progressIndicator->stop();
c2f1320 @lordmulder Added support for Windows 7 taskbar features (progress and overlay ic…
authored
419 progressBar->setValue(progressBar->maximum());
420 WinSevenTaskbar::setTaskbarProgress(this, progressBar->value(), progressBar->maximum());
4fd8ec0 @lordmulder Addded context menu to "source file" view + make the "output folder" …
authored
421
422 QApplication::restoreOverrideCursor();
108c167 @lordmulder Added an option to shutdown the computer as soon as all files are com…
authored
423
424 if(!m_userAborted && checkBox_shutdownComputer->isChecked())
425 {
f60515c @lordmulder Use custom Wave files instead of Beep(), as the Beep() function doesn…
authored
426 if(shutdownComputer())
427 {
428 m_shutdownFlag = true;
429 accept();
430 }
108c167 @lordmulder Added an option to shutdown the computer as soon as all files are com…
authored
431 }
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
432 }
433
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
434 void ProcessingDialog::processFinished(const QUuid &jobId, const QString &outFileName, bool success)
435 {
436 if(success)
437 {
6491965 @lordmulder Add items to the playlist in the order the jobs are created, rather t…
authored
438 m_playList.insert(jobId, outFileName);
439 m_succeededJobs.append(jobId);
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
440 }
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
441 else
442 {
6491965 @lordmulder Add items to the playlist in the order the jobs are created, rather t…
authored
443 m_failedJobs.append(jobId);
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
444 }
445 }
446
447 void ProcessingDialog::progressModelChanged(void)
448 {
449 view_log->scrollToBottom();
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
450 }
451
c0ece99 @lordmulder Implemented logging and added a log file view.
authored
452 void ProcessingDialog::logViewDoubleClicked(const QModelIndex &index)
453 {
454 if(m_runningThreads == 0)
455 {
456 const QStringList &logFile = m_progressModel->getLogFile(index);
d9e775b @lordmulder Show notification in progress window, if multi-threading is activated.
authored
457
458 if(!logFile.isEmpty())
459 {
460 LogViewDialog *logView = new LogViewDialog(this);
461 logView->setWindowTitle(QString("LameXP - [%1]").arg(m_progressModel->data(index, Qt::DisplayRole).toString()));
462 logView->exec(logFile);
463 LAMEXP_DELETE(logView);
464 }
465 else
466 {
467 MessageBeep(MB_ICONWARNING);
468 }
c0ece99 @lordmulder Implemented logging and added a log file view.
authored
469 }
571df62 @lordmulder Implement support for Job Objects + improve log view.
authored
470 else
471 {
472 MessageBeep(MB_ICONWARNING);
473 }
474 }
475
476 void ProcessingDialog::contextMenuTriggered(const QPoint &pos)
477 {
c967a01 @lordmulder Properly map the popup menu position to global coordinates.
authored
478 QAbstractScrollArea *scrollArea = dynamic_cast<QAbstractScrollArea*>(QObject::sender());
479 QWidget *sender = scrollArea ? scrollArea->viewport() : dynamic_cast<QWidget*>(QObject::sender());
480
481 if(pos.x() <= sender->width() && pos.y() <= sender->height() && pos.x() >= 0 && pos.y() >= 0)
38d60fe @lordmulder Fix context menu in progress dialog.
authored
482 {
c967a01 @lordmulder Properly map the popup menu position to global coordinates.
authored
483 m_contextMenu->popup(sender->mapToGlobal(pos));
38d60fe @lordmulder Fix context menu in progress dialog.
authored
484 }
571df62 @lordmulder Implement support for Job Objects + improve log view.
authored
485 }
486
b12e524 @lordmulder Add option "Brose Output File Location" to context menu in processing…
authored
487 void ProcessingDialog::contextMenuDetailsActionTriggered(void)
571df62 @lordmulder Implement support for Job Objects + improve log view.
authored
488 {
489 QModelIndex index = view_log->indexAt(view_log->mapFromGlobal(m_contextMenu->pos()));
490 logViewDoubleClicked(index.isValid() ? index : view_log->currentIndex());
c0ece99 @lordmulder Implemented logging and added a log file view.
authored
491 }
492
b12e524 @lordmulder Add option "Brose Output File Location" to context menu in processing…
authored
493 void ProcessingDialog::contextMenuShowFileActionTriggered(void)
494 {
495 QModelIndex index = view_log->indexAt(view_log->mapFromGlobal(m_contextMenu->pos()));
496 const QUuid &jobId = m_progressModel->getJobId(index.isValid() ? index : view_log->currentIndex());
497 QString filePath = m_playList.value(jobId, QString());
498
499 if(filePath.isEmpty())
500 {
501 MessageBeep(MB_ICONWARNING);
502 return;
503 }
504
505 if(QFileInfo(filePath).exists())
506 {
507 QString systemRootPath;
508
509 QDir systemRoot(lamexp_known_folder(lamexp_folder_systemfolder));
510 if(systemRoot.exists() && systemRoot.cdUp())
511 {
512 systemRootPath = systemRoot.canonicalPath();
513 }
514
515 if(!systemRootPath.isEmpty())
516 {
517 QFileInfo explorer(QString("%1/explorer.exe").arg(systemRootPath));
518 if(explorer.exists() && explorer.isFile())
519 {
520 QProcess::execute(explorer.canonicalFilePath(), QStringList() << "/select," << QDir::toNativeSeparators(QFileInfo(filePath).canonicalFilePath()));
521 return;
522 }
523 }
524 else
525 {
526 qWarning("SystemRoot directory could not be detected!");
527 }
528 }
529 else
530 {
531 qWarning("File not found: %s", filePath.toLatin1().constData());
532 MessageBeep(MB_ICONERROR);
533 }
534 }
535
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
536 ////////////////////////////////////////////////////////////
537 // Private Functions
538 ////////////////////////////////////////////////////////////
539
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
540 void ProcessingDialog::startNextJob(void)
541 {
542 if(m_pendingJobs.isEmpty())
543 {
544 return;
545 }
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
546
547 m_currentFile++;
548 AudioFileModel currentFile = updateMetaInfo(m_pendingJobs.takeFirst());
1633489 @lordmulder Actually use selected encoder in progress dialog + forward output dir.
authored
549 AbstractEncoder *encoder = NULL;
d13050c @lordmulder Added "Resample" filter, based on SoX. Used for encoders that don't s…
authored
550 bool nativeResampling = false;
e6460b9 @lordmulder FLAC encoding support.
authored
551
1633489 @lordmulder Actually use selected encoder in progress dialog + forward output dir.
authored
552 switch(m_settings->compressionEncoder())
553 {
554 case SettingsModel::MP3Encoder:
555 {
556 MP3Encoder *mp3Encoder = new MP3Encoder();
557 mp3Encoder->setBitrate(m_settings->compressionBitrate());
558 mp3Encoder->setRCMode(m_settings->compressionRCMode());
476edeb @lordmulder Initial support for advanced options. Only "LAME Algorithm Quality" s…
authored
559 mp3Encoder->setAlgoQuality(m_settings->lameAlgoQuality());
3f0796d @lordmulder Added support for bitrate management to LAME and OggEnc2 encoders.
authored
560 if(m_settings->bitrateManagementEnabled())
561 {
562 mp3Encoder->setBitrateLimits(m_settings->bitrateManagementMinRate(), m_settings->bitrateManagementMaxRate());
563 }
d13050c @lordmulder Added "Resample" filter, based on SoX. Used for encoders that don't s…
authored
564 if(m_settings->samplingRate() > 0)
565 {
566 mp3Encoder->setSamplingRate(SettingsModel::samplingRates[m_settings->samplingRate()]);
567 nativeResampling = true;
568 }
7e44c69 @lordmulder Actually make the Nero AAC Profile/2-Pass options work. Also make the…
authored
569 mp3Encoder->setChannelMode(m_settings->lameChannelMode());
cfb20fe @lordmulder Added support for custom encoder parameters.
authored
570 mp3Encoder->setCustomParams(m_settings->customParametersLAME());
1633489 @lordmulder Actually use selected encoder in progress dialog + forward output dir.
authored
571 encoder = mp3Encoder;
572 }
573 break;
11f57ae @lordmulder Ogg Vorbis encoding support.
authored
574 case SettingsModel::VorbisEncoder:
575 {
576 VorbisEncoder *vorbisEncoder = new VorbisEncoder();
577 vorbisEncoder->setBitrate(m_settings->compressionBitrate());
578 vorbisEncoder->setRCMode(m_settings->compressionRCMode());
3f0796d @lordmulder Added support for bitrate management to LAME and OggEnc2 encoders.
authored
579 if(m_settings->bitrateManagementEnabled())
580 {
581 vorbisEncoder->setBitrateLimits(m_settings->bitrateManagementMinRate(), m_settings->bitrateManagementMaxRate());
582 }
d13050c @lordmulder Added "Resample" filter, based on SoX. Used for encoders that don't s…
authored
583 if(m_settings->samplingRate() > 0)
584 {
585 vorbisEncoder->setSamplingRate(SettingsModel::samplingRates[m_settings->samplingRate()]);
586 nativeResampling = true;
587 }
cfb20fe @lordmulder Added support for custom encoder parameters.
authored
588 vorbisEncoder->setCustomParams(m_settings->customParametersOggEnc());
11f57ae @lordmulder Ogg Vorbis encoding support.
authored
589 encoder = vorbisEncoder;
590 }
591 break;
be4ce0d @lordmulder Added AAC encoding support.
authored
592 case SettingsModel::AACEncoder:
593 {
594 AACEncoder *aacEncoder = new AACEncoder();
595 aacEncoder->setBitrate(m_settings->compressionBitrate());
596 aacEncoder->setRCMode(m_settings->compressionRCMode());
7e44c69 @lordmulder Actually make the Nero AAC Profile/2-Pass options work. Also make the…
authored
597 aacEncoder->setEnable2Pass(m_settings->neroAACEnable2Pass());
598 aacEncoder->setProfile(m_settings->neroAACProfile());
cfb20fe @lordmulder Added support for custom encoder parameters.
authored
599 aacEncoder->setCustomParams(m_settings->customParametersNeroAAC());
be4ce0d @lordmulder Added AAC encoding support.
authored
600 encoder = aacEncoder;
601 }
602 break;
e6460b9 @lordmulder FLAC encoding support.
authored
603 case SettingsModel::FLACEncoder:
604 {
605 FLACEncoder *flacEncoder = new FLACEncoder();
606 flacEncoder->setBitrate(m_settings->compressionBitrate());
607 flacEncoder->setRCMode(m_settings->compressionRCMode());
cfb20fe @lordmulder Added support for custom encoder parameters.
authored
608 flacEncoder->setCustomParams(m_settings->customParametersFLAC());
e6460b9 @lordmulder FLAC encoding support.
authored
609 encoder = flacEncoder;
610 }
611 break;
e189eb0 @lordmulder Support for Wave (PCM) output.
authored
612 case SettingsModel::PCMEncoder:
613 {
614 WaveEncoder *waveEncoder = new WaveEncoder();
615 waveEncoder->setBitrate(m_settings->compressionBitrate());
616 waveEncoder->setRCMode(m_settings->compressionRCMode());
617 encoder = waveEncoder;
618 }
619 break;
1633489 @lordmulder Actually use selected encoder in progress dialog + forward output dir.
authored
620 default:
621 throw "Unsupported encoder!";
622 }
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
623
063c530 @lordmulder Added an option to prepend the source file's relative path to the out…
authored
624 ProcessThread *thread = new ProcessThread
625 (
626 currentFile,
f829d69 @lordmulder Added an option to select a user-defined TEMP directory.
authored
627 (m_settings->outputToSourceDir() ? QFileInfo(currentFile.filePath()).absolutePath() : m_settings->outputDir()),
628 (m_settings->customTempPathEnabled() ? m_settings->customTempPath() : lamexp_temp_folder2()),
063c530 @lordmulder Added an option to prepend the source file's relative path to the out…
authored
629 encoder,
630 m_settings->prependRelativeSourcePath()
631 );
58ded8c @lordmulder Added a normalization filter, based on SoX.
authored
632
d13050c @lordmulder Added "Resample" filter, based on SoX. Used for encoders that don't s…
authored
633 if((m_settings->samplingRate() > 0) && !nativeResampling)
634 {
c1cde1a @lordmulder Invoke the "resampling" filter only if the target sampling rate is re…
authored
635 if(SettingsModel::samplingRates[m_settings->samplingRate()] != currentFile.formatAudioSamplerate() || currentFile.formatAudioSamplerate() == 0)
636 {
637 thread->addFilter(new ResampleFilter(SettingsModel::samplingRates[m_settings->samplingRate()]));
638 }
d13050c @lordmulder Added "Resample" filter, based on SoX. Used for encoders that don't s…
authored
639 }
640 if((m_settings->toneAdjustBass() != 0) || (m_settings->toneAdjustTreble() != 0))
641 {
642 thread->addFilter(new ToneAdjustFilter(m_settings->toneAdjustBass(), m_settings->toneAdjustTreble()));
643 }
58ded8c @lordmulder Added a normalization filter, based on SoX.
authored
644 if(m_settings->normalizationFilterEnabled())
645 {
646 thread->addFilter(new NormalizeFilter(m_settings->normalizationFilterMaxVolume()));
647 }
648
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
649 m_threadList.append(thread);
6491965 @lordmulder Add items to the playlist in the order the jobs are created, rather t…
authored
650 m_allJobs.append(thread->getId());
11f57ae @lordmulder Ogg Vorbis encoding support.
authored
651
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
652 connect(thread, SIGNAL(finished()), this, SLOT(doneEncoding()), Qt::QueuedConnection);
653 connect(thread, SIGNAL(processStateInitialized(QUuid,QString,QString,int)), m_progressModel, SLOT(addJob(QUuid,QString,QString,int)), Qt::QueuedConnection);
654 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
655 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
656 connect(thread, SIGNAL(processMessageLogged(QUuid,QString)), m_progressModel, SLOT(appendToLog(QUuid,QString)), Qt::QueuedConnection);
11f57ae @lordmulder Ogg Vorbis encoding support.
authored
657
28a926b @lordmulder Implement multi-theaded processing in progress dialog.
authored
658 m_runningThreads++;
659 thread->start();
660 }
661
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
662 void ProcessingDialog::writePlayList(void)
663 {
6491965 @lordmulder Add items to the playlist in the order the jobs are created, rather t…
authored
664 if(m_succeededJobs.count() <= 0 || m_allJobs.count() <= 0)
665 {
666 qWarning("WritePlayList: Nothing to do!");
667 return;
668 }
669
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
670 QString playListName = (m_metaInfo->fileAlbum().isEmpty() ? "Playlist" : m_metaInfo->fileAlbum());
671
672 const static char *invalidChars = "\\/:*?\"<>|";
673 for(int i = 0; invalidChars[i]; i++)
674 {
675 playListName.replace(invalidChars[i], ' ');
676 playListName = playListName.simplified();
677 }
678
679 QString playListFile = QString("%1/%2.m3u").arg(m_settings->outputDir(), playListName);
680
681 int counter = 1;
682 while(QFileInfo(playListFile).exists())
683 {
684 playListFile = QString("%1/%2 (%3).m3u").arg(m_settings->outputDir(), playListName, QString::number(++counter));
685 }
6491965 @lordmulder Add items to the playlist in the order the jobs are created, rather t…
authored
686
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
687 QFile playList(playListFile);
688 if(playList.open(QIODevice::WriteOnly))
689 {
690 playList.write("#EXTM3U\r\n");
6491965 @lordmulder Add items to the playlist in the order the jobs are created, rather t…
authored
691 for(int i = 0; i < m_allJobs.count(); i++)
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
692 {
6491965 @lordmulder Add items to the playlist in the order the jobs are created, rather t…
authored
693
694 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
695 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
696 playList.write("\r\n");
697 }
698 playList.close();
699 }
47a6c2f @lordmulder Make "Save output files to the same location where the input file is …
authored
700 else
701 {
8c0fa11 @lordmulder make more strings translatable + try to load a default translation th…
authored
702 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
703 }
970f2cd @lordmulder Create playlist file + serialize filename generation, just to be sure.
authored
704 }
705
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
706 AudioFileModel ProcessingDialog::updateMetaInfo(const AudioFileModel &audioFile)
707 {
708 if(!m_settings->writeMetaTags())
709 {
0fd4b56 @lordmulder Refactor audio file model.
authored
710 return AudioFileModel(audioFile, false);
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
711 }
712
713 AudioFileModel result = audioFile;
0fd4b56 @lordmulder Refactor audio file model.
authored
714 result.updateMetaInfo(*m_metaInfo);
715
716 if(m_metaInfo->filePosition() == UINT_MAX)
717 {
718 result.setFilePosition(m_currentFile);
719 }
cffa6a2 @lordmulder Correctly forward meta info to MP3 encoder and apply.
authored
720
721 return result;
722 }
723
3170f35 @lordmulder Implement processing thread and connect to processing dialog.
authored
724 void ProcessingDialog::setCloseButtonEnabled(bool enabled)
725 {
726 HMENU hMenu = GetSystemMenu((HWND) winId(), FALSE);
727 EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_GRAYED));
7a79c47 @lordmulder Implemented processing dialog, no functionality yet.
authored
728 }
18bed9e @lordmulder Added a system tray icon.
authored
729
730 void ProcessingDialog::systemTrayActivated(QSystemTrayIcon::ActivationReason reason)
731 {
732 if(reason == QSystemTrayIcon::DoubleClick)
733 {
734 SetForegroundWindow(this->winId());
735 }
736 }
108c167 @lordmulder Added an option to shutdown the computer as soon as all files are com…
authored
737
f60515c @lordmulder Use custom Wave files instead of Beep(), as the Beep() function doesn…
authored
738 bool ProcessingDialog::shutdownComputer(void)
108c167 @lordmulder Added an option to shutdown the computer as soon as all files are com…
authored
739 {
740 const int iTimeout = 30;
741 const Qt::WindowFlags flags = Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowSystemMenuHint;
742 const QString text = QString("%1%2%1").arg(QString().fill(' ', 18), tr("Warning: Computer will shutdown in %1 seconds..."));
743
f60515c @lordmulder Use custom Wave files instead of Beep(), as the Beep() function doesn…
authored
744 qWarning("Initiating shutdown sequence!");
745
108c167 @lordmulder Added an option to shutdown the computer as soon as all files are com…
authored
746 QProgressDialog progressDialog(text.arg(iTimeout), tr("Cancel Shutdown"), 0, iTimeout + 1, this, flags);
eeab615 @lordmulder Updated version info: v4.01 RC-1.
authored
747 QPushButton *cancelButton = new QPushButton(tr("Cancel Shutdown"), &progressDialog);
748 cancelButton->setIcon(QIcon(":/icons/power_on.png"));
108c167 @lordmulder Added an option to shutdown the computer as soon as all files are com…
authored
749 progressDialog.setModal(true);
750 progressDialog.setAutoClose(false);
751 progressDialog.setAutoReset(false);
eeab615 @lordmulder Updated version info: v4.01 RC-1.
authored
752 progressDialog.setWindowIcon(QIcon(":/icons/power_off.png"));
753 progressDialog.setCancelButton(cancelButton);
108c167 @lordmulder Added an option to shutdown the computer as soon as all files are com…
authored
754 progressDialog.show();
755
756 QApplication::processEvents();
757
758 if(m_settings->soundsEnabled())
759 {
f60515c @lordmulder Use custom Wave files instead of Beep(), as the Beep() function doesn…
authored
760 QApplication::setOverrideCursor(Qt::WaitCursor);
108c167 @lordmulder Added an option to shutdown the computer as soon as all files are com…
authored
761 PlaySound(MAKEINTRESOURCE(IDR_WAVE_SHUTDOWN), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
f60515c @lordmulder Use custom Wave files instead of Beep(), as the Beep() function doesn…
authored
762 QApplication::restoreOverrideCursor();
108c167 @lordmulder Added an option to shutdown the computer as soon as all files are com…
authored
763 }
764
765 QTimer timer;
766 timer.setInterval(1000);
767 timer.start();
768
769 QEventLoop eventLoop(this);
770 connect(&timer, SIGNAL(timeout()), &eventLoop, SLOT(quit()));
771 connect(&progressDialog, SIGNAL(canceled()), &eventLoop, SLOT(quit()));
772
773 for(int i = 1; i <= iTimeout; i++)
774 {
775 eventLoop.exec();
f60515c @lordmulder Use custom Wave files instead of Beep(), as the Beep() function doesn…
authored
776 if(progressDialog.wasCanceled())
777 {
778 progressDialog.close();
779 return false;
780 }
108c167 @lordmulder Added an option to shutdown the computer as soon as all files are com…
authored
781 progressDialog.setValue(i+1);
782 progressDialog.setLabelText(text.arg(iTimeout-i));
eeab615 @lordmulder Updated version info: v4.01 RC-1.
authored
783 if(iTimeout-i == 3) progressDialog.setCancelButton(NULL);
108c167 @lordmulder Added an option to shutdown the computer as soon as all files are com…
authored
784 QApplication::processEvents();
f60515c @lordmulder Use custom Wave files instead of Beep(), as the Beep() function doesn…
authored
785 PlaySound(MAKEINTRESOURCE((i < iTimeout) ? IDR_WAVE_BEEP : IDR_WAVE_BEEP_LONG), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
108c167 @lordmulder Added an option to shutdown the computer as soon as all files are com…
authored
786 }
787
788 progressDialog.close();
f60515c @lordmulder Use custom Wave files instead of Beep(), as the Beep() function doesn…
authored
789 return true;
108c167 @lordmulder Added an option to shutdown the computer as soon as all files are com…
authored
790 }
Something went wrong with that request. Please try again.