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