Added indicators for current CPU usage, RAM usage and free disk space to the processi...
[LameXP.git] / src / Dialog_MainWindow.cpp
blobcafecd92769321a83525e31256ab62bdffbe579c
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2011 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.
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.
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
22 #include "Dialog_MainWindow.h"
24 //LameXP includes
25 #include "Global.h"
26 #include "Resource.h"
27 #include "Dialog_WorkingBanner.h"
28 #include "Dialog_MetaInfo.h"
29 #include "Dialog_About.h"
30 #include "Dialog_Update.h"
31 #include "Dialog_DropBox.h"
32 #include "Dialog_CueImport.h"
33 #include "Thread_FileAnalyzer.h"
34 #include "Thread_MessageHandler.h"
35 #include "Model_MetaInfo.h"
36 #include "Model_Settings.h"
37 #include "Model_FileList.h"
38 #include "Model_FileSystem.h"
39 #include "WinSevenTaskbar.h"
40 #include "Registry_Decoder.h"
41 #include "ShellIntegration.h"
43 //Qt includes
44 #include <QMessageBox>
45 #include <QTimer>
46 #include <QDesktopWidget>
47 #include <QDate>
48 #include <QFileDialog>
49 #include <QInputDialog>
50 #include <QFileSystemModel>
51 #include <QDesktopServices>
52 #include <QUrl>
53 #include <QPlastiqueStyle>
54 #include <QCleanlooksStyle>
55 #include <QWindowsVistaStyle>
56 #include <QWindowsStyle>
57 #include <QSysInfo>
58 #include <QDragEnterEvent>
59 #include <QWindowsMime>
60 #include <QProcess>
61 #include <QUuid>
62 #include <QProcessEnvironment>
63 #include <QCryptographicHash>
64 #include <QTranslator>
65 #include <QResource>
66 #include <QScrollBar>
68 //System includes
69 #include <MMSystem.h>
70 #include <ShellAPI.h>
72 //Helper macros
73 #define ABORT_IF_BUSY if(m_banner->isVisible() || m_delayedFileTimer->isActive()) { MessageBeep(MB_ICONEXCLAMATION); return; }
74 #define SET_TEXT_COLOR(WIDGET,COLOR) { QPalette _palette = WIDGET->palette(); _palette.setColor(QPalette::WindowText, (COLOR)); _palette.setColor(QPalette::Text, (COLOR)); WIDGET->setPalette(_palette); }
75 #define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); }
76 #define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(QString(URL).replace("-", "&minus;"))
77 #define FSLINK(PATH) QString("<a href=\"file:///%1\">%2</a>").arg(PATH).arg(QString(PATH).replace("-", "&minus;"))
78 #define TEMP_HIDE_DROPBOX(CMD) { bool __dropBoxVisible = m_dropBox->isVisible(); if(__dropBoxVisible) m_dropBox->hide(); {CMD}; if(__dropBoxVisible) m_dropBox->show(); }
79 #define USE_NATIVE_FILE_DIALOG (lamexp_themes_enabled() || ((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) < QSysInfo::WV_XP))
81 ////////////////////////////////////////////////////////////
82 // Constructor
83 ////////////////////////////////////////////////////////////
85 MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, SettingsModel *settingsModel, QWidget *parent)
87 QMainWindow(parent),
88 m_fileListModel(fileListModel),
89 m_metaData(metaInfo),
90 m_settings(settingsModel),
91 m_neroEncoderAvailable(lamexp_check_tool("neroAacEnc.exe") && lamexp_check_tool("neroAacDec.exe") && lamexp_check_tool("neroAacTag.exe")),
92 m_fhgEncoderAvailable(lamexp_check_tool("fhgaacenc.exe") && lamexp_check_tool("enc_fhgaac.dll") && lamexp_check_tool("nsutil.dll") && lamexp_check_tool("libmp4v2.dll")),
93 m_accepted(false),
94 m_firstTimeShown(true),
95 m_OutputFolderViewInitialized(false)
97 //Init the dialog, from the .ui file
98 setupUi(this);
99 setWindowFlags(windowFlags() ^ Qt::WindowMaximizeButtonHint);
101 //Register meta types
102 qRegisterMetaType<AudioFileModel>("AudioFileModel");
104 //Enabled main buttons
105 connect(buttonAbout, SIGNAL(clicked()), this, SLOT(aboutButtonClicked()));
106 connect(buttonStart, SIGNAL(clicked()), this, SLOT(encodeButtonClicked()));
107 connect(buttonQuit, SIGNAL(clicked()), this, SLOT(closeButtonClicked()));
109 //Setup tab widget
110 tabWidget->setCurrentIndex(0);
111 connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabPageChanged(int)));
113 //Setup "Source" tab
114 sourceFileView->setModel(m_fileListModel);
115 sourceFileView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
116 sourceFileView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
117 sourceFileView->setContextMenuPolicy(Qt::CustomContextMenu);
118 sourceFileView->viewport()->installEventFilter(this);
119 m_dropNoteLabel = new QLabel(sourceFileView);
120 m_dropNoteLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
121 SET_FONT_BOLD(m_dropNoteLabel, true);
122 SET_TEXT_COLOR(m_dropNoteLabel, Qt::darkGray);
123 m_sourceFilesContextMenu = new QMenu();
124 m_showDetailsContextAction = m_sourceFilesContextMenu->addAction(QIcon(":/icons/zoom.png"), "N/A");
125 m_previewContextAction = m_sourceFilesContextMenu->addAction(QIcon(":/icons/sound.png"), "N/A");
126 m_findFileContextAction = m_sourceFilesContextMenu->addAction(QIcon(":/icons/folder_go.png"), "N/A");
127 SET_FONT_BOLD(m_showDetailsContextAction, true);
128 connect(buttonAddFiles, SIGNAL(clicked()), this, SLOT(addFilesButtonClicked()));
129 connect(buttonRemoveFile, SIGNAL(clicked()), this, SLOT(removeFileButtonClicked()));
130 connect(buttonClearFiles, SIGNAL(clicked()), this, SLOT(clearFilesButtonClicked()));
131 connect(buttonFileUp, SIGNAL(clicked()), this, SLOT(fileUpButtonClicked()));
132 connect(buttonFileDown, SIGNAL(clicked()), this, SLOT(fileDownButtonClicked()));
133 connect(buttonShowDetails, SIGNAL(clicked()), this, SLOT(showDetailsButtonClicked()));
134 connect(m_fileListModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(sourceModelChanged()));
135 connect(m_fileListModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(sourceModelChanged()));
136 connect(m_fileListModel, SIGNAL(modelReset()), this, SLOT(sourceModelChanged()));
137 connect(sourceFileView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(sourceFilesContextMenu(QPoint)));
138 connect(sourceFileView->verticalScrollBar(), SIGNAL(sliderMoved(int)), this, SLOT(sourceFilesScrollbarMoved(int)));
139 connect(sourceFileView->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(sourceFilesScrollbarMoved(int)));
140 connect(m_showDetailsContextAction, SIGNAL(triggered(bool)), this, SLOT(showDetailsButtonClicked()));
141 connect(m_previewContextAction, SIGNAL(triggered(bool)), this, SLOT(previewContextActionTriggered()));
142 connect(m_findFileContextAction, SIGNAL(triggered(bool)), this, SLOT(findFileContextActionTriggered()));
144 //Setup "Output" tab
145 m_fileSystemModel = new QFileSystemModelEx();
146 m_fileSystemModel->installEventFilter(this);
147 outputFolderView->setModel(m_fileSystemModel);
148 outputFolderView->header()->setStretchLastSection(true);
149 outputFolderView->header()->hideSection(1);
150 outputFolderView->header()->hideSection(2);
151 outputFolderView->header()->hideSection(3);
152 outputFolderView->setHeaderHidden(true);
153 outputFolderView->setAnimated(false);
154 outputFolderView->setMouseTracking(false);
155 outputFolderView->setContextMenuPolicy(Qt::CustomContextMenu);
156 outputFolderView->installEventFilter(this);
157 outputFoldersFovoritesLabel->installEventFilter(this);
158 while(saveToSourceFolderCheckBox->isChecked() != m_settings->outputToSourceDir()) saveToSourceFolderCheckBox->click();
159 prependRelativePathCheckBox->setChecked(m_settings->prependRelativeSourcePath());
160 connect(outputFolderView, SIGNAL(clicked(QModelIndex)), this, SLOT(outputFolderViewClicked(QModelIndex)));
161 connect(outputFolderView, SIGNAL(activated(QModelIndex)), this, SLOT(outputFolderViewClicked(QModelIndex)));
162 connect(outputFolderView, SIGNAL(pressed(QModelIndex)), this, SLOT(outputFolderViewClicked(QModelIndex)));
163 connect(outputFolderView, SIGNAL(entered(QModelIndex)), this, SLOT(outputFolderViewMoved(QModelIndex)));
164 connect(buttonMakeFolder, SIGNAL(clicked()), this, SLOT(makeFolderButtonClicked()));
165 connect(buttonGotoHome, SIGNAL(clicked()), SLOT(gotoHomeFolderButtonClicked()));
166 connect(buttonGotoDesktop, SIGNAL(clicked()), this, SLOT(gotoDesktopButtonClicked()));
167 connect(buttonGotoMusic, SIGNAL(clicked()), this, SLOT(gotoMusicFolderButtonClicked()));
168 connect(saveToSourceFolderCheckBox, SIGNAL(clicked()), this, SLOT(saveToSourceFolderChanged()));
169 connect(prependRelativePathCheckBox, SIGNAL(clicked()), this, SLOT(prependRelativePathChanged()));
170 m_outputFolderContextMenu = new QMenu();
171 m_showFolderContextAction = m_outputFolderContextMenu->addAction(QIcon(":/icons/zoom.png"), "N/A");
172 m_outputFolderFavoritesMenu = new QMenu();
173 m_addFavoriteFolderAction = m_outputFolderFavoritesMenu->addAction(QIcon(":/icons/add.png"), "N/A");
174 m_outputFolderFavoritesMenu->insertSeparator(m_addFavoriteFolderAction);
175 connect(outputFolderView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(outputFolderContextMenu(QPoint)));
176 connect(m_showFolderContextAction, SIGNAL(triggered(bool)), this, SLOT(showFolderContextActionTriggered()));
177 connect(m_addFavoriteFolderAction, SIGNAL(triggered(bool)), this, SLOT(addFavoriteFolderActionTriggered()));
178 outputFolderLabel->installEventFilter(this);
179 outputFolderView->setCurrentIndex(m_fileSystemModel->index(m_settings->outputDir()));
180 outputFolderViewClicked(outputFolderView->currentIndex());
181 refreshFavorites();
183 //Setup "Meta Data" tab
184 m_metaInfoModel = new MetaInfoModel(m_metaData, 6);
185 m_metaInfoModel->clearData();
186 m_metaInfoModel->setData(m_metaInfoModel->index(4, 1), m_settings->metaInfoPosition());
187 metaDataView->setModel(m_metaInfoModel);
188 metaDataView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
189 metaDataView->verticalHeader()->hide();
190 metaDataView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
191 while(writeMetaDataCheckBox->isChecked() != m_settings->writeMetaTags()) writeMetaDataCheckBox->click();
192 generatePlaylistCheckBox->setChecked(m_settings->createPlaylist());
193 connect(buttonEditMeta, SIGNAL(clicked()), this, SLOT(editMetaButtonClicked()));
194 connect(buttonClearMeta, SIGNAL(clicked()), this, SLOT(clearMetaButtonClicked()));
195 connect(writeMetaDataCheckBox, SIGNAL(clicked()), this, SLOT(metaTagsEnabledChanged()));
196 connect(generatePlaylistCheckBox, SIGNAL(clicked()), this, SLOT(playlistEnabledChanged()));
198 //Setup "Compression" tab
199 m_encoderButtonGroup = new QButtonGroup(this);
200 m_encoderButtonGroup->addButton(radioButtonEncoderMP3, SettingsModel::MP3Encoder);
201 m_encoderButtonGroup->addButton(radioButtonEncoderVorbis, SettingsModel::VorbisEncoder);
202 m_encoderButtonGroup->addButton(radioButtonEncoderAAC, SettingsModel::AACEncoder);
203 m_encoderButtonGroup->addButton(radioButtonEncoderAC3, SettingsModel::AC3Encoder);
204 m_encoderButtonGroup->addButton(radioButtonEncoderFLAC, SettingsModel::FLACEncoder);
205 m_encoderButtonGroup->addButton(radioButtonEncoderPCM, SettingsModel::PCMEncoder);
206 m_modeButtonGroup = new QButtonGroup(this);
207 m_modeButtonGroup->addButton(radioButtonModeQuality, SettingsModel::VBRMode);
208 m_modeButtonGroup->addButton(radioButtonModeAverageBitrate, SettingsModel::ABRMode);
209 m_modeButtonGroup->addButton(radioButtonConstBitrate, SettingsModel::CBRMode);
210 radioButtonEncoderAAC->setEnabled(m_neroEncoderAvailable || m_fhgEncoderAvailable);
211 radioButtonEncoderMP3->setChecked(m_settings->compressionEncoder() == SettingsModel::MP3Encoder);
212 radioButtonEncoderVorbis->setChecked(m_settings->compressionEncoder() == SettingsModel::VorbisEncoder);
213 radioButtonEncoderAAC->setChecked((m_settings->compressionEncoder() == SettingsModel::AACEncoder) && (m_neroEncoderAvailable || m_fhgEncoderAvailable));
214 radioButtonEncoderAC3->setChecked(m_settings->compressionEncoder() == SettingsModel::AC3Encoder);
215 radioButtonEncoderFLAC->setChecked(m_settings->compressionEncoder() == SettingsModel::FLACEncoder);
216 radioButtonEncoderPCM->setChecked(m_settings->compressionEncoder() == SettingsModel::PCMEncoder);
217 radioButtonModeQuality->setChecked(m_settings->compressionRCMode() == SettingsModel::VBRMode);
218 radioButtonModeAverageBitrate->setChecked(m_settings->compressionRCMode() == SettingsModel::ABRMode);
219 radioButtonConstBitrate->setChecked(m_settings->compressionRCMode() == SettingsModel::CBRMode);
220 sliderBitrate->setValue(m_settings->compressionBitrate());
221 connect(m_encoderButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(updateEncoder(int)));
222 connect(m_modeButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(updateRCMode(int)));
223 connect(sliderBitrate, SIGNAL(valueChanged(int)), this, SLOT(updateBitrate(int)));
224 updateEncoder(m_encoderButtonGroup->checkedId());
226 //Setup "Advanced Options" tab
227 sliderLameAlgoQuality->setValue(m_settings->lameAlgoQuality());
228 if(m_settings->maximumInstances() > 0) sliderMaxInstances->setValue(m_settings->maximumInstances());
229 spinBoxBitrateManagementMin->setValue(m_settings->bitrateManagementMinRate());
230 spinBoxBitrateManagementMax->setValue(m_settings->bitrateManagementMaxRate());
231 spinBoxNormalizationFilter->setValue(static_cast<double>(m_settings->normalizationFilterMaxVolume()) / 100.0);
232 spinBoxToneAdjustBass->setValue(static_cast<double>(m_settings->toneAdjustBass()) / 100.0);
233 spinBoxToneAdjustTreble->setValue(static_cast<double>(m_settings->toneAdjustTreble()) / 100.0);
234 spinBoxAftenSearchSize->setValue(m_settings->aftenExponentSearchSize());
235 comboBoxMP3ChannelMode->setCurrentIndex(m_settings->lameChannelMode());
236 comboBoxSamplingRate->setCurrentIndex(m_settings->samplingRate());
237 comboBoxAACProfile->setCurrentIndex(m_settings->aacEncProfile());
238 comboBoxAftenCodingMode->setCurrentIndex(m_settings->aftenAudioCodingMode());
239 comboBoxAftenDRCMode->setCurrentIndex(m_settings->aftenDynamicRangeCompression());
240 comboBoxNormalizationMode->setCurrentIndex(m_settings->normalizationFilterEqualizationMode());
241 while(checkBoxBitrateManagement->isChecked() != m_settings->bitrateManagementEnabled()) checkBoxBitrateManagement->click();
242 while(checkBoxNeroAAC2PassMode->isChecked() != m_settings->neroAACEnable2Pass()) checkBoxNeroAAC2PassMode->click();
243 while(checkBoxAftenFastAllocation->isChecked() != m_settings->aftenFastBitAllocation()) checkBoxAftenFastAllocation->click();
244 while(checkBoxNormalizationFilter->isChecked() != m_settings->normalizationFilterEnabled()) checkBoxNormalizationFilter->click();
245 while(checkBoxAutoDetectInstances->isChecked() != (m_settings->maximumInstances() < 1)) checkBoxAutoDetectInstances->click();
246 while(checkBoxUseSystemTempFolder->isChecked() == m_settings->customTempPathEnabled()) checkBoxUseSystemTempFolder->click();
247 while(checkBoxRenameOutput->isChecked() != m_settings->renameOutputFilesEnabled()) checkBoxRenameOutput->click();
248 while(checkBoxForceStereoDownmix->isChecked() != m_settings->forceStereoDownmix()) checkBoxForceStereoDownmix->click();
249 checkBoxNeroAAC2PassMode->setEnabled(!m_fhgEncoderAvailable);
250 lineEditCustomParamLAME->setText(m_settings->customParametersLAME());
251 lineEditCustomParamOggEnc->setText(m_settings->customParametersOggEnc());
252 lineEditCustomParamNeroAAC->setText(m_settings->customParametersAacEnc());
253 lineEditCustomParamFLAC->setText(m_settings->customParametersFLAC());
254 lineEditCustomParamAften->setText(m_settings->customParametersAften());
255 lineEditCustomTempFolder->setText(QDir::toNativeSeparators(m_settings->customTempPath()));
256 lineEditRenamePattern->setText(m_settings->renameOutputFilesPattern());
257 connect(sliderLameAlgoQuality, SIGNAL(valueChanged(int)), this, SLOT(updateLameAlgoQuality(int)));
258 connect(checkBoxBitrateManagement, SIGNAL(clicked(bool)), this, SLOT(bitrateManagementEnabledChanged(bool)));
259 connect(spinBoxBitrateManagementMin, SIGNAL(valueChanged(int)), this, SLOT(bitrateManagementMinChanged(int)));
260 connect(spinBoxBitrateManagementMax, SIGNAL(valueChanged(int)), this, SLOT(bitrateManagementMaxChanged(int)));
261 connect(comboBoxMP3ChannelMode, SIGNAL(currentIndexChanged(int)), this, SLOT(channelModeChanged(int)));
262 connect(comboBoxSamplingRate, SIGNAL(currentIndexChanged(int)), this, SLOT(samplingRateChanged(int)));
263 connect(checkBoxNeroAAC2PassMode, SIGNAL(clicked(bool)), this, SLOT(neroAAC2PassChanged(bool)));
264 connect(comboBoxAACProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(neroAACProfileChanged(int)));
265 connect(checkBoxNormalizationFilter, SIGNAL(clicked(bool)), this, SLOT(normalizationEnabledChanged(bool)));
266 connect(comboBoxAftenCodingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(aftenCodingModeChanged(int)));
267 connect(comboBoxAftenDRCMode, SIGNAL(currentIndexChanged(int)), this, SLOT(aftenDRCModeChanged(int)));
268 connect(spinBoxAftenSearchSize, SIGNAL(valueChanged(int)), this, SLOT(aftenSearchSizeChanged(int)));
269 connect(checkBoxAftenFastAllocation, SIGNAL(clicked(bool)), this, SLOT(aftenFastAllocationChanged(bool)));
270 connect(spinBoxNormalizationFilter, SIGNAL(valueChanged(double)), this, SLOT(normalizationMaxVolumeChanged(double)));
271 connect(comboBoxNormalizationMode, SIGNAL(currentIndexChanged(int)), this, SLOT(normalizationModeChanged(int)));
272 connect(spinBoxToneAdjustBass, SIGNAL(valueChanged(double)), this, SLOT(toneAdjustBassChanged(double)));
273 connect(spinBoxToneAdjustTreble, SIGNAL(valueChanged(double)), this, SLOT(toneAdjustTrebleChanged(double)));
274 connect(buttonToneAdjustReset, SIGNAL(clicked()), this, SLOT(toneAdjustTrebleReset()));
275 connect(lineEditCustomParamLAME, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
276 connect(lineEditCustomParamOggEnc, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
277 connect(lineEditCustomParamNeroAAC, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
278 connect(lineEditCustomParamFLAC, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
279 connect(lineEditCustomParamAften, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
280 connect(sliderMaxInstances, SIGNAL(valueChanged(int)), this, SLOT(updateMaximumInstances(int)));
281 connect(checkBoxAutoDetectInstances, SIGNAL(clicked(bool)), this, SLOT(autoDetectInstancesChanged(bool)));
282 connect(buttonBrowseCustomTempFolder, SIGNAL(clicked()), this, SLOT(browseCustomTempFolderButtonClicked()));
283 connect(lineEditCustomTempFolder, SIGNAL(textChanged(QString)), this, SLOT(customTempFolderChanged(QString)));
284 connect(checkBoxUseSystemTempFolder, SIGNAL(clicked(bool)), this, SLOT(useCustomTempFolderChanged(bool)));
285 connect(buttonResetAdvancedOptions, SIGNAL(clicked()), this, SLOT(resetAdvancedOptionsButtonClicked()));
286 connect(checkBoxRenameOutput, SIGNAL(clicked(bool)), this, SLOT(renameOutputEnabledChanged(bool)));
287 connect(lineEditRenamePattern, SIGNAL(editingFinished()), this, SLOT(renameOutputPatternChanged()));
288 connect(lineEditRenamePattern, SIGNAL(textChanged(QString)), this, SLOT(renameOutputPatternChanged(QString)));
289 connect(labelShowRenameMacros, SIGNAL(linkActivated(QString)), this, SLOT(showRenameMacros(QString)));
290 connect(checkBoxForceStereoDownmix, SIGNAL(clicked(bool)), this, SLOT(forceStereoDownmixEnabledChanged(bool)));
291 updateLameAlgoQuality(sliderLameAlgoQuality->value());
292 updateMaximumInstances(sliderMaxInstances->value());
293 toneAdjustTrebleChanged(spinBoxToneAdjustTreble->value());
294 toneAdjustBassChanged(spinBoxToneAdjustBass->value());
295 customParamsChanged();
297 //Activate file menu actions
298 actionOpenFolder->setData(QVariant::fromValue<bool>(false));
299 actionOpenFolderRecursively->setData(QVariant::fromValue<bool>(true));
300 connect(actionOpenFolder, SIGNAL(triggered()), this, SLOT(openFolderActionActivated()));
301 connect(actionOpenFolderRecursively, SIGNAL(triggered()), this, SLOT(openFolderActionActivated()));
303 //Activate view menu actions
304 m_tabActionGroup = new QActionGroup(this);
305 m_tabActionGroup->addAction(actionSourceFiles);
306 m_tabActionGroup->addAction(actionOutputDirectory);
307 m_tabActionGroup->addAction(actionCompression);
308 m_tabActionGroup->addAction(actionMetaData);
309 m_tabActionGroup->addAction(actionAdvancedOptions);
310 actionSourceFiles->setData(0);
311 actionOutputDirectory->setData(1);
312 actionMetaData->setData(2);
313 actionCompression->setData(3);
314 actionAdvancedOptions->setData(4);
315 actionSourceFiles->setChecked(true);
316 connect(m_tabActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(tabActionActivated(QAction*)));
318 //Activate style menu actions
319 m_styleActionGroup = new QActionGroup(this);
320 m_styleActionGroup->addAction(actionStylePlastique);
321 m_styleActionGroup->addAction(actionStyleCleanlooks);
322 m_styleActionGroup->addAction(actionStyleWindowsVista);
323 m_styleActionGroup->addAction(actionStyleWindowsXP);
324 m_styleActionGroup->addAction(actionStyleWindowsClassic);
325 actionStylePlastique->setData(0);
326 actionStyleCleanlooks->setData(1);
327 actionStyleWindowsVista->setData(2);
328 actionStyleWindowsXP->setData(3);
329 actionStyleWindowsClassic->setData(4);
330 actionStylePlastique->setChecked(true);
331 actionStyleWindowsXP->setEnabled((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) >= QSysInfo::WV_XP && lamexp_themes_enabled());
332 actionStyleWindowsVista->setEnabled((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) >= QSysInfo::WV_VISTA && lamexp_themes_enabled());
333 connect(m_styleActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(styleActionActivated(QAction*)));
334 styleActionActivated(NULL);
336 //Populate the language menu
337 m_languageActionGroup = new QActionGroup(this);
338 QStringList translations = lamexp_query_translations();
339 while(!translations.isEmpty())
341 QString langId = translations.takeFirst();
342 QAction *currentLanguage = new QAction(this);
343 currentLanguage->setData(langId);
344 currentLanguage->setText(lamexp_translation_name(langId));
345 currentLanguage->setIcon(QIcon(QString(":/flags/%1.png").arg(langId)));
346 currentLanguage->setCheckable(true);
347 m_languageActionGroup->addAction(currentLanguage);
348 menuLanguage->insertAction(actionLoadTranslationFromFile, currentLanguage);
350 menuLanguage->insertSeparator(actionLoadTranslationFromFile);
351 connect(actionLoadTranslationFromFile, SIGNAL(triggered(bool)), this, SLOT(languageFromFileActionActivated(bool)));
352 connect(m_languageActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(languageActionActivated(QAction*)));
354 //Activate tools menu actions
355 actionDisableUpdateReminder->setChecked(!m_settings->autoUpdateEnabled());
356 actionDisableSounds->setChecked(!m_settings->soundsEnabled());
357 actionDisableNeroAacNotifications->setChecked(!m_settings->neroAacNotificationsEnabled());
358 actionDisableSlowStartupNotifications->setChecked(!m_settings->antivirNotificationsEnabled());
359 actionDisableShellIntegration->setChecked(!m_settings->shellIntegrationEnabled());
360 actionDisableShellIntegration->setDisabled(lamexp_portable_mode() && actionDisableShellIntegration->isChecked());
361 actionCheckForBetaUpdates->setChecked(m_settings->autoUpdateCheckBeta() || lamexp_version_demo());
362 actionCheckForBetaUpdates->setEnabled(!lamexp_version_demo());
363 actionHibernateComputer->setChecked(m_settings->hibernateComputer());
364 actionHibernateComputer->setEnabled(lamexp_is_hibernation_supported());
365 connect(actionDisableUpdateReminder, SIGNAL(triggered(bool)), this, SLOT(disableUpdateReminderActionTriggered(bool)));
366 connect(actionDisableSounds, SIGNAL(triggered(bool)), this, SLOT(disableSoundsActionTriggered(bool)));
367 connect(actionDisableNeroAacNotifications, SIGNAL(triggered(bool)), this, SLOT(disableNeroAacNotificationsActionTriggered(bool)));
368 connect(actionDisableSlowStartupNotifications, SIGNAL(triggered(bool)), this, SLOT(disableSlowStartupNotificationsActionTriggered(bool)));
369 connect(actionDisableShellIntegration, SIGNAL(triggered(bool)), this, SLOT(disableShellIntegrationActionTriggered(bool)));
370 connect(actionShowDropBoxWidget, SIGNAL(triggered(bool)), this, SLOT(showDropBoxWidgetActionTriggered(bool)));
371 connect(actionHibernateComputer, SIGNAL(triggered(bool)), this, SLOT(hibernateComputerActionTriggered(bool)));
372 connect(actionCheckForBetaUpdates, SIGNAL(triggered(bool)), this, SLOT(checkForBetaUpdatesActionTriggered(bool)));
373 connect(actionImportCueSheet, SIGNAL(triggered(bool)), this, SLOT(importCueSheetActionTriggered(bool)));
375 //Activate help menu actions
376 actionVisitHomepage->setData(QString::fromLatin1(lamexp_website_url()));
377 actionVisitSupport->setData(QString::fromLatin1(lamexp_support_url()));
378 actionDocumentFAQ->setData(QString("%1/FAQ.html").arg(QApplication::applicationDirPath()));
379 actionDocumentChangelog->setData(QString("%1/Changelog.html").arg(QApplication::applicationDirPath()));
380 actionDocumentTranslate->setData(QString("%1/Translate.html").arg(QApplication::applicationDirPath()));
381 connect(actionCheckUpdates, SIGNAL(triggered()), this, SLOT(checkUpdatesActionActivated()));
382 connect(actionVisitHomepage, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated()));
383 connect(actionVisitSupport, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated()));
384 connect(actionDocumentFAQ, SIGNAL(triggered()), this, SLOT(documentActionActivated()));
385 connect(actionDocumentChangelog, SIGNAL(triggered()), this, SLOT(documentActionActivated()));
386 connect(actionDocumentTranslate, SIGNAL(triggered()), this, SLOT(documentActionActivated()));
388 //Center window in screen
389 QRect desktopRect = QApplication::desktop()->screenGeometry();
390 QRect thisRect = this->geometry();
391 move((desktopRect.width() - thisRect.width()) / 2, (desktopRect.height() - thisRect.height()) / 2);
392 setMinimumSize(thisRect.width(), thisRect.height());
394 //Create banner
395 m_banner = new WorkingBanner(this);
397 //Create DropBox widget
398 m_dropBox = new DropBox(this, m_fileListModel, m_settings);
399 connect(m_fileListModel, SIGNAL(modelReset()), m_dropBox, SLOT(modelChanged()));
400 connect(m_fileListModel, SIGNAL(rowsInserted(QModelIndex,int,int)), m_dropBox, SLOT(modelChanged()));
401 connect(m_fileListModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), m_dropBox, SLOT(modelChanged()));
403 //Create message handler thread
404 m_messageHandler = new MessageHandlerThread();
405 m_delayedFileList = new QStringList();
406 m_delayedFileTimer = new QTimer();
407 m_delayedFileTimer->setSingleShot(true);
408 m_delayedFileTimer->setInterval(5000);
409 connect(m_messageHandler, SIGNAL(otherInstanceDetected()), this, SLOT(notifyOtherInstance()), Qt::QueuedConnection);
410 connect(m_messageHandler, SIGNAL(fileReceived(QString)), this, SLOT(addFileDelayed(QString)), Qt::QueuedConnection);
411 connect(m_messageHandler, SIGNAL(folderReceived(QString, bool)), this, SLOT(addFolderDelayed(QString, bool)), Qt::QueuedConnection);
412 connect(m_messageHandler, SIGNAL(killSignalReceived()), this, SLOT(close()), Qt::QueuedConnection);
413 connect(m_delayedFileTimer, SIGNAL(timeout()), this, SLOT(handleDelayedFiles()));
414 m_messageHandler->start();
416 //Load translation file
417 QList<QAction*> languageActions = m_languageActionGroup->actions();
418 while(!languageActions.isEmpty())
420 QAction *currentLanguage = languageActions.takeFirst();
421 if(currentLanguage->data().toString().compare(m_settings->currentLanguage(), Qt::CaseInsensitive) == 0)
423 currentLanguage->setChecked(true);
424 languageActionActivated(currentLanguage);
428 //Re-translate (make sure we translate once)
429 QEvent languageChangeEvent(QEvent::LanguageChange);
430 changeEvent(&languageChangeEvent);
432 //Enable Drag & Drop
433 this->setAcceptDrops(true);
436 ////////////////////////////////////////////////////////////
437 // Destructor
438 ////////////////////////////////////////////////////////////
440 MainWindow::~MainWindow(void)
442 //Stop message handler thread
443 if(m_messageHandler && m_messageHandler->isRunning())
445 m_messageHandler->stop();
446 if(!m_messageHandler->wait(10000))
448 m_messageHandler->terminate();
449 m_messageHandler->wait();
453 //Unset models
454 sourceFileView->setModel(NULL);
455 metaDataView->setModel(NULL);
457 //Free memory
458 LAMEXP_DELETE(m_tabActionGroup);
459 LAMEXP_DELETE(m_styleActionGroup);
460 LAMEXP_DELETE(m_languageActionGroup);
461 LAMEXP_DELETE(m_banner);
462 LAMEXP_DELETE(m_fileSystemModel);
463 LAMEXP_DELETE(m_messageHandler);
464 LAMEXP_DELETE(m_delayedFileList);
465 LAMEXP_DELETE(m_delayedFileTimer);
466 LAMEXP_DELETE(m_metaInfoModel);
467 LAMEXP_DELETE(m_encoderButtonGroup);
468 LAMEXP_DELETE(m_encoderButtonGroup);
469 LAMEXP_DELETE(m_sourceFilesContextMenu);
470 LAMEXP_DELETE(m_outputFolderFavoritesMenu);
471 LAMEXP_DELETE(m_dropBox);
474 ////////////////////////////////////////////////////////////
475 // PRIVATE FUNCTIONS
476 ////////////////////////////////////////////////////////////
479 * Add file to source list
481 void MainWindow::addFiles(const QStringList &files)
483 if(files.isEmpty())
485 return;
488 tabWidget->setCurrentIndex(0);
490 FileAnalyzer *analyzer = new FileAnalyzer(files);
491 connect(analyzer, SIGNAL(fileSelected(QString)), m_banner, SLOT(setText(QString)), Qt::QueuedConnection);
492 connect(analyzer, SIGNAL(fileAnalyzed(AudioFileModel)), m_fileListModel, SLOT(addFile(AudioFileModel)), Qt::QueuedConnection);
493 connect(m_banner, SIGNAL(userAbort()), analyzer, SLOT(abortProcess()), Qt::DirectConnection);
495 m_banner->show(tr("Adding file(s), please wait..."), analyzer);
497 if(analyzer->filesDenied())
499 QMessageBox::warning(this, tr("Access Denied"), QString("%1<br>%2").arg(NOBR(tr("%1 file(s) have been rejected, because read access was not granted!").arg(analyzer->filesDenied())), NOBR(tr("This usually means the file is locked by another process."))));
501 if(analyzer->filesDummyCDDA())
503 QMessageBox::warning(this, tr("CDDA Files"), QString("%1<br><br>%2<br>%3").arg(NOBR(tr("%1 file(s) have been rejected, because they are dummy CDDA files!").arg(analyzer->filesDummyCDDA())), NOBR(tr("Sorry, LameXP cannot extract audio tracks from an Audio-CD at present.")), NOBR(tr("We recommend using %1 for that purpose.").arg("<a href=\"http://www.exactaudiocopy.de/\">Exact Audio Copy</a>"))));
505 if(analyzer->filesCueSheet())
507 QMessageBox::warning(this, tr("Cue Sheet"), QString("%1<br>%2").arg(NOBR(tr("%1 file(s) have been rejected, because they appear to be Cue Sheet images!").arg(analyzer->filesCueSheet())), NOBR(tr("Please use LameXP's Cue Sheet wizard for importing Cue Sheet files."))));
509 if(analyzer->filesRejected())
511 QMessageBox::warning(this, tr("Files Rejected"), QString("%1<br>%2").arg(NOBR(tr("%1 file(s) have been rejected, because the file format could not be recognized!").arg(analyzer->filesRejected())), NOBR(tr("This usually means the file is damaged or the file format is not supported."))));
514 LAMEXP_DELETE(analyzer);
515 sourceFileView->scrollToBottom();
516 m_banner->close();
520 * Add folder to source list
522 void MainWindow::addFolder(const QString &path, bool recursive, bool delayed)
524 QFileInfoList folderInfoList;
525 folderInfoList << QFileInfo(path);
526 QStringList fileList;
528 m_banner->show(tr("Scanning folder(s) for files, please wait..."));
530 QApplication::processEvents();
531 GetAsyncKeyState(VK_ESCAPE);
533 while(!folderInfoList.isEmpty())
535 if(GetAsyncKeyState(VK_ESCAPE) & 0x0001)
537 MessageBeep(MB_ICONERROR);
538 qWarning("Operation cancelled by user!");
539 fileList.clear();
540 break;
543 QDir currentDir(folderInfoList.takeFirst().canonicalFilePath());
544 QFileInfoList fileInfoList = currentDir.entryInfoList(QDir::Files | QDir::NoSymLinks);
546 while(!fileInfoList.isEmpty())
548 fileList << fileInfoList.takeFirst().canonicalFilePath();
551 QApplication::processEvents();
553 if(recursive)
555 folderInfoList.append(currentDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks));
556 QApplication::processEvents();
560 m_banner->close();
561 QApplication::processEvents();
563 if(!fileList.isEmpty())
565 if(delayed)
567 addFilesDelayed(fileList);
569 else
571 addFiles(fileList);
577 * Check for updates
579 bool MainWindow::checkForUpdates(void)
581 bool bReadyToInstall = false;
583 UpdateDialog *updateDialog = new UpdateDialog(m_settings, this);
584 updateDialog->exec();
586 if(updateDialog->getSuccess())
588 m_settings->autoUpdateLastCheck(QDate::currentDate().toString(Qt::ISODate));
589 bReadyToInstall = updateDialog->updateReadyToInstall();
592 LAMEXP_DELETE(updateDialog);
593 return bReadyToInstall;
596 void MainWindow::refreshFavorites(void)
598 QList<QAction*> folderList = m_outputFolderFavoritesMenu->actions();
599 QStringList favorites = m_settings->favoriteOutputFolders().split("|", QString::SkipEmptyParts);
600 while(favorites.count() > 6) favorites.removeFirst();
602 while(!folderList.isEmpty())
604 QAction *currentItem = folderList.takeFirst();
605 if(currentItem->isSeparator()) break;
606 m_outputFolderFavoritesMenu->removeAction(currentItem);
607 LAMEXP_DELETE(currentItem);
610 QAction *lastItem = m_outputFolderFavoritesMenu->actions().first();
612 while(!favorites.isEmpty())
614 QString path = favorites.takeLast();
615 if(QDir(path).exists())
617 QAction *action = new QAction(QIcon(":/icons/folder_go.png"), QDir::toNativeSeparators(path), this);
618 action->setData(path);
619 m_outputFolderFavoritesMenu->insertAction(lastItem, action);
620 connect(action, SIGNAL(triggered(bool)), this, SLOT(gotoFavoriteFolder()));
621 lastItem = action;
626 ////////////////////////////////////////////////////////////
627 // EVENTS
628 ////////////////////////////////////////////////////////////
631 * Window is about to be shown
633 void MainWindow::showEvent(QShowEvent *event)
635 m_accepted = false;
636 m_dropNoteLabel->setGeometry(0, 0, sourceFileView->width(), sourceFileView->height());
637 sourceModelChanged();
639 if(!event->spontaneous())
641 tabWidget->setCurrentIndex(0);
644 if(m_firstTimeShown)
646 m_firstTimeShown = false;
647 QTimer::singleShot(0, this, SLOT(windowShown()));
649 else
651 if(m_settings->dropBoxWidgetEnabled())
653 m_dropBox->setVisible(true);
659 * Re-translate the UI
661 void MainWindow::changeEvent(QEvent *e)
663 if(e->type() == QEvent::LanguageChange)
665 int comboBoxIndex[6];
667 //Backup combobox indices, as retranslateUi() resets
668 comboBoxIndex[0] = comboBoxMP3ChannelMode->currentIndex();
669 comboBoxIndex[1] = comboBoxSamplingRate->currentIndex();
670 comboBoxIndex[2] = comboBoxAACProfile->currentIndex();
671 comboBoxIndex[3] = comboBoxAftenCodingMode->currentIndex();
672 comboBoxIndex[4] = comboBoxAftenDRCMode->currentIndex();
673 comboBoxIndex[5] = comboBoxNormalizationMode->currentIndex();
675 //Re-translate from UIC
676 Ui::MainWindow::retranslateUi(this);
678 //Restore combobox indices
679 comboBoxMP3ChannelMode->setCurrentIndex(comboBoxIndex[0]);
680 comboBoxSamplingRate->setCurrentIndex(comboBoxIndex[1]);
681 comboBoxAACProfile->setCurrentIndex(comboBoxIndex[2]);
682 comboBoxAftenCodingMode->setCurrentIndex(comboBoxIndex[3]);
683 comboBoxAftenDRCMode->setCurrentIndex(comboBoxIndex[4]);
684 comboBoxNormalizationMode->setCurrentIndex(comboBoxIndex[5]);
686 //Update the window title
687 if(LAMEXP_DEBUG)
689 setWindowTitle(QString("%1 [!!! DEBUG BUILD !!!]").arg(windowTitle()));
691 else if(lamexp_version_demo())
693 setWindowTitle(QString("%1 [%2]").arg(windowTitle(), tr("DEMO VERSION")));
696 //Manually re-translate widgets that UIC doesn't handle
697 m_dropNoteLabel->setText(QString("» %1 «").arg(tr("You can drop in audio files here!")));
698 m_showDetailsContextAction->setText(tr("Show Details"));
699 m_previewContextAction->setText(tr("Open File in External Application"));
700 m_findFileContextAction->setText(tr("Browse File Location"));
701 m_showFolderContextAction->setText(tr("Browse Selected Folder"));
702 m_addFavoriteFolderAction->setText(tr("Bookmark Current Output Folder"));
704 //Force GUI update
705 m_metaInfoModel->clearData();
706 m_metaInfoModel->setData(m_metaInfoModel->index(4, 1), m_settings->metaInfoPosition());
707 updateEncoder(m_settings->compressionEncoder());
708 updateLameAlgoQuality(sliderLameAlgoQuality->value());
709 updateMaximumInstances(sliderMaxInstances->value());
710 renameOutputPatternChanged(lineEditRenamePattern->text());
712 //Re-install shell integration
713 if(m_settings->shellIntegrationEnabled())
715 ShellIntegration::install();
718 //Force resize, if needed
719 tabPageChanged(tabWidget->currentIndex());
724 * File dragged over window
726 void MainWindow::dragEnterEvent(QDragEnterEvent *event)
728 QStringList formats = event->mimeData()->formats();
730 if(formats.contains("application/x-qt-windows-mime;value=\"FileNameW\"", Qt::CaseInsensitive) && formats.contains("text/uri-list", Qt::CaseInsensitive))
732 event->acceptProposedAction();
737 * File dropped onto window
739 void MainWindow::dropEvent(QDropEvent *event)
741 ABORT_IF_BUSY;
743 QStringList droppedFiles;
744 QList<QUrl> urls = event->mimeData()->urls();
746 while(!urls.isEmpty())
748 QUrl currentUrl = urls.takeFirst();
749 QFileInfo file(currentUrl.toLocalFile());
750 if(!file.exists())
752 continue;
754 if(file.isFile())
756 qDebug("Dropped File: %s", file.canonicalFilePath().toUtf8().constData());
757 droppedFiles << file.canonicalFilePath();
758 continue;
760 if(file.isDir())
762 qDebug("Dropped Folder: %s", file.canonicalFilePath().toUtf8().constData());
763 QList<QFileInfo> list = QDir(file.canonicalFilePath()).entryInfoList(QDir::Files | QDir::NoSymLinks);
764 if(list.count() > 0)
766 for(int j = 0; j < list.count(); j++)
768 droppedFiles << list.at(j).canonicalFilePath();
771 else
773 list = QDir(file.canonicalFilePath()).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
774 for(int j = 0; j < list.count(); j++)
776 qDebug("Descending to Folder: %s", list.at(j).canonicalFilePath().toUtf8().constData());
777 urls.prepend(QUrl::fromLocalFile(list.at(j).canonicalFilePath()));
783 if(!droppedFiles.isEmpty())
785 addFilesDelayed(droppedFiles, true);
790 * Window tries to close
792 void MainWindow::closeEvent(QCloseEvent *event)
794 if(m_banner->isVisible() || m_delayedFileTimer->isActive())
796 MessageBeep(MB_ICONEXCLAMATION);
797 event->ignore();
800 if(m_dropBox)
802 m_dropBox->hide();
807 * Window was resized
809 void MainWindow::resizeEvent(QResizeEvent *event)
811 QMainWindow::resizeEvent(event);
812 m_dropNoteLabel->setGeometry(0, 0, sourceFileView->width(), sourceFileView->height());
816 * Event filter
818 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
820 if(obj == m_fileSystemModel)
822 if(QApplication::overrideCursor() == NULL)
824 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
825 QTimer::singleShot(250, this, SLOT(restoreCursor()));
828 else if(obj == outputFolderView)
830 switch(event->type())
832 case QEvent::Enter:
833 case QEvent::Leave:
834 case QEvent::KeyPress:
835 case QEvent::KeyRelease:
836 case QEvent::FocusIn:
837 case QEvent::FocusOut:
838 case QEvent::TouchEnd:
839 outputFolderViewClicked(outputFolderView->currentIndex());
840 break;
843 else if(obj == outputFolderLabel)
845 switch(event->type())
847 case QEvent::MouseButtonPress:
848 if(dynamic_cast<QMouseEvent*>(event)->button() == Qt::LeftButton)
850 QDesktopServices::openUrl(QString("file:///%1").arg(outputFolderLabel->text()));
852 break;
853 case QEvent::Enter:
854 outputFolderLabel->setForegroundRole(QPalette::Link);
855 break;
856 case QEvent::Leave:
857 outputFolderLabel->setForegroundRole(QPalette::WindowText);
858 break;
861 else if(obj == outputFoldersFovoritesLabel)
863 QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(event);
864 QPoint pos = (mouseEvent != NULL) ? mouseEvent->pos() : QPoint();
865 QWidget *sender = dynamic_cast<QLabel*>(obj);
867 switch(event->type())
869 case QEvent::Enter:
870 outputFoldersFovoritesLabel->setFrameShadow(QFrame::Raised);
871 break;
872 case QEvent::MouseButtonPress:
873 outputFoldersFovoritesLabel->setFrameShadow(QFrame::Sunken);
874 break;
875 case QEvent::MouseButtonRelease:
876 outputFoldersFovoritesLabel->setFrameShadow(QFrame::Raised);
877 if(sender && mouseEvent)
879 if(pos.x() <= sender->width() && pos.y() <= sender->height() && pos.x() >= 0 && pos.y() >= 0 && mouseEvent->button() != Qt::MidButton)
881 m_outputFolderFavoritesMenu->popup(sender->mapToGlobal(pos));
884 break;
885 case QEvent::Leave:
886 outputFoldersFovoritesLabel->setFrameShadow(QFrame::Plain);
887 break;
891 return false;
894 ////////////////////////////////////////////////////////////
895 // Slots
896 ////////////////////////////////////////////////////////////
898 // =========================================================
899 // Show window slots
900 // =========================================================
903 * Window shown
905 void MainWindow::windowShown(void)
907 QStringList arguments = QApplication::arguments();
909 //First run?
910 bool firstRun = false;
911 for(int i = 0; i < arguments.count(); i++)
913 if(!arguments[i].compare("--first-run", Qt::CaseInsensitive)) firstRun = true;
916 //Check license
917 if((m_settings->licenseAccepted() <= 0) || firstRun)
919 int iAccepted = -1;
921 if((m_settings->licenseAccepted() == 0) || firstRun)
923 AboutDialog *about = new AboutDialog(m_settings, this, true);
924 iAccepted = about->exec();
925 LAMEXP_DELETE(about);
928 if(iAccepted <= 0)
930 m_settings->licenseAccepted(-1);
931 QApplication::processEvents();
932 PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
933 QMessageBox::critical(this, tr("License Declined"), tr("You have declined the license. Consequently the application will exit now!"), tr("Goodbye!"));
934 QFileInfo uninstallerInfo = QFileInfo(QString("%1/Uninstall.exe").arg(QApplication::applicationDirPath()));
935 if(uninstallerInfo.exists())
937 QString uninstallerDir = uninstallerInfo.canonicalPath();
938 QString uninstallerPath = uninstallerInfo.canonicalFilePath();
939 for(int i = 0; i < 3; i++)
941 HINSTANCE res = ShellExecuteW(this->winId(), L"open", QWCHAR(QDir::toNativeSeparators(uninstallerPath)), L"/Force", QWCHAR(QDir::toNativeSeparators(uninstallerDir)), SW_SHOWNORMAL);
942 if(reinterpret_cast<int>(res) > 32) break;
945 else
947 MoveFileEx(QWCHAR(QDir::toNativeSeparators(QFileInfo(QApplication::applicationFilePath()).canonicalFilePath())), NULL, MOVEFILE_DELAY_UNTIL_REBOOT | MOVEFILE_REPLACE_EXISTING);
949 QApplication::quit();
950 return;
953 PlaySound(MAKEINTRESOURCE(IDR_WAVE_WOOHOO), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
954 m_settings->licenseAccepted(1);
955 if(lamexp_version_demo()) showAnnounceBox();
958 //Check for expiration
959 if(lamexp_version_demo())
961 if(QDate::currentDate() >= lamexp_version_expires())
963 qWarning("Binary has expired !!!");
964 PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
965 if(QMessageBox::warning(this, tr("LameXP - Expired"), QString("%1<br>%2").arg(NOBR(tr("This demo (pre-release) version of LameXP has expired at %1.").arg(lamexp_version_expires().toString(Qt::ISODate))), NOBR(tr("LameXP is free software and release versions won't expire."))), tr("Check for Updates"), tr("Exit Program")) == 0)
967 checkForUpdates();
969 QApplication::quit();
970 return;
974 //Slow startup indicator
975 if(m_settings->slowStartup() && m_settings->antivirNotificationsEnabled())
977 QString message;
978 message += NOBR(tr("It seems that a bogus anti-virus software is slowing down the startup of LameXP.")).append("<br>");
979 message += NOBR(tr("Please refer to the %1 document for details and solutions!")).arg("<a href=\"http://lamexp.git.sourceforge.net/git/gitweb.cgi?p=lamexp/lamexp;a=blob_plain;f=doc/FAQ.html;hb=HEAD#df406578\">F.A.Q.</a>").append("<br>");
980 if(QMessageBox::warning(this, tr("Slow Startup"), message, tr("Discard"), tr("Don't Show Again")) == 1)
982 m_settings->antivirNotificationsEnabled(false);
983 actionDisableSlowStartupNotifications->setChecked(!m_settings->antivirNotificationsEnabled());
987 //Update reminder
988 if(QDate::currentDate() >= lamexp_version_date().addYears(1))
990 qWarning("Binary is more than a year old, time to update!");
991 if(QMessageBox::warning(this, tr("Urgent Update"), NOBR(tr("Your version of LameXP is more than a year old. Time for an update!")), tr("Check for Updates"), tr("Exit Program")) == 0)
993 if(checkForUpdates())
995 QApplication::quit();
996 return;
999 else
1001 QApplication::quit();
1002 return;
1005 else if(m_settings->autoUpdateEnabled())
1007 QDate lastUpdateCheck = QDate::fromString(m_settings->autoUpdateLastCheck(), Qt::ISODate);
1008 if(!firstRun && (!lastUpdateCheck.isValid() || QDate::currentDate() >= lastUpdateCheck.addDays(14)))
1010 if(QMessageBox::information(this, tr("Update Reminder"), NOBR(lastUpdateCheck.isValid() ? tr("Your last update check was more than 14 days ago. Check for updates now?") : tr("Your did not check for LameXP updates yet. Check for updates now?")), tr("Check for Updates"), tr("Postpone")) == 0)
1012 if(checkForUpdates())
1014 QApplication::quit();
1015 return;
1021 //Check for AAC support
1022 if(m_neroEncoderAvailable)
1024 if(m_settings->neroAacNotificationsEnabled())
1026 if(lamexp_tool_version("neroAacEnc.exe") < lamexp_toolver_neroaac())
1028 QString messageText;
1029 messageText += NOBR(tr("LameXP detected that your version of the Nero AAC encoder is outdated!")).append("<br>");
1030 messageText += NOBR(tr("The current version available is %1 (or later), but you still have version %2 installed.").arg(lamexp_version2string("?.?.?.?", lamexp_toolver_neroaac(), tr("n/a")), lamexp_version2string("?.?.?.?", lamexp_tool_version("neroAacEnc.exe"), tr("n/a")))).append("<br><br>");
1031 messageText += NOBR(tr("You can download the latest version of the Nero AAC encoder from the Nero website at:")).append("<br>");
1032 messageText += "<nobr><tt>" + LINK(AboutDialog::neroAacUrl) + "</tt></nobr><br><br>";
1033 messageText += NOBR(tr("(Hint: Please ignore the name of the downloaded ZIP file and check the included 'changelog.txt' instead!)")).append("<br>");
1034 QMessageBox::information(this, tr("AAC Encoder Outdated"), messageText);
1038 else
1040 if(m_settings->neroAacNotificationsEnabled() && (!m_fhgEncoderAvailable))
1042 QString appPath = QDir(QCoreApplication::applicationDirPath()).canonicalPath();
1043 if(appPath.isEmpty()) appPath = QCoreApplication::applicationDirPath();
1044 QString messageText;
1045 messageText += NOBR(tr("The Nero AAC encoder could not be found. AAC encoding support will be disabled.")).append("<br>");
1046 messageText += NOBR(tr("Please put 'neroAacEnc.exe', 'neroAacDec.exe' and 'neroAacTag.exe' into the LameXP directory!")).append("<br><br>");
1047 messageText += NOBR(tr("Your LameXP directory is located here:")).append("<br>");
1048 messageText += QString("<nobr><tt>%1</tt></nobr><br><br>").arg(FSLINK(QDir::toNativeSeparators(appPath)));
1049 messageText += NOBR(tr("You can download the Nero AAC encoder for free from the official Nero website at:")).append("<br>");
1050 messageText += "<nobr><tt>" + LINK(AboutDialog::neroAacUrl) + "</tt></nobr><br>";
1051 if(QMessageBox::information(this, tr("AAC Support Disabled"), messageText, tr("Discard"), tr("Don't Show Again")) == 1)
1053 m_settings->neroAacNotificationsEnabled(false);
1054 actionDisableNeroAacNotifications->setChecked(!m_settings->neroAacNotificationsEnabled());
1059 //Add files from the command-line
1060 for(int i = 0; i < arguments.count() - 1; i++)
1062 QStringList addedFiles;
1063 if(!arguments[i].compare("--add", Qt::CaseInsensitive))
1065 QFileInfo currentFile(arguments[++i].trimmed());
1066 qDebug("Adding file from CLI: %s", currentFile.absoluteFilePath().toUtf8().constData());
1067 addedFiles.append(currentFile.absoluteFilePath());
1069 if(!addedFiles.isEmpty())
1071 addFilesDelayed(addedFiles);
1075 //Add folders from the command-line
1076 for(int i = 0; i < arguments.count() - 1; i++)
1078 if(!arguments[i].compare("--add-folder", Qt::CaseInsensitive))
1080 QFileInfo currentFile(arguments[++i].trimmed());
1081 qDebug("Adding folder from CLI: %s", currentFile.absoluteFilePath().toUtf8().constData());
1082 addFolder(currentFile.absoluteFilePath(), false, true);
1084 if(!arguments[i].compare("--add-recursive", Qt::CaseInsensitive))
1086 QFileInfo currentFile(arguments[++i].trimmed());
1087 qDebug("Adding folder recursively from CLI: %s", currentFile.absoluteFilePath().toUtf8().constData());
1088 addFolder(currentFile.absoluteFilePath(), true, true);
1092 //Enable shell integration
1093 if(m_settings->shellIntegrationEnabled())
1095 ShellIntegration::install();
1098 //Make DropBox visible
1099 if(m_settings->dropBoxWidgetEnabled())
1101 m_dropBox->setVisible(true);
1106 * Show announce box
1108 void MainWindow::showAnnounceBox(void)
1110 const QString announceText = QString("%1<br><br>%2<br><nobr><tt>%3</tt></nobr><br>").arg
1112 NOBR("We are still looking for LameXP translators!"),
1113 NOBR("If you are willing to translate LameXP to your language or to complete an existing translation, please refer to:"),
1114 LINK("http://mulder.brhack.net/public/doc/lamexp_translate.html")
1117 QMessageBox *announceBox = new QMessageBox(QMessageBox::Warning, "We want you!", announceText, QMessageBox::NoButton, this);
1118 announceBox->setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
1119 announceBox->setIconPixmap(QIcon(":/images/Announcement.png").pixmap(64,79));
1120 QPushButton *button1 = announceBox->addButton(tr("Discard"), QMessageBox::AcceptRole);
1121 QPushButton *button2 = announceBox->addButton(tr("Discard"), QMessageBox::NoRole);
1122 button1->setVisible(false);
1123 button2->setEnabled(false);
1125 QTimer *announceTimer = new QTimer(this);
1126 announceTimer->setSingleShot(true);
1127 announceTimer->setInterval(8000);
1128 connect(announceTimer, SIGNAL(timeout()), button1, SLOT(show()));
1129 connect(announceTimer, SIGNAL(timeout()), button2, SLOT(hide()));
1131 announceTimer->start();
1132 while(announceTimer->isActive()) announceBox->exec();
1133 announceTimer->stop();
1135 LAMEXP_DELETE(announceTimer);
1136 LAMEXP_DELETE(announceBox);
1139 // =========================================================
1140 // Main button solots
1141 // =========================================================
1144 * Encode button
1146 void MainWindow::encodeButtonClicked(void)
1148 static const unsigned __int64 oneGigabyte = 1073741824ui64;
1149 static const unsigned __int64 minimumFreeDiskspaceMultiplier = 2ui64;
1150 static const char *writeTestBuffer = "LAMEXP_WRITE_TEST";
1152 ABORT_IF_BUSY;
1154 if(m_fileListModel->rowCount() < 1)
1156 QMessageBox::warning(this, tr("LameXP"), NOBR(tr("You must add at least one file to the list before proceeding!")));
1157 tabWidget->setCurrentIndex(0);
1158 return;
1161 QString tempFolder = m_settings->customTempPathEnabled() ? m_settings->customTempPath() : lamexp_temp_folder2();
1162 if(!QFileInfo(tempFolder).exists() || !QFileInfo(tempFolder).isDir())
1164 if(QMessageBox::warning(this, tr("Not Found"), QString("%1<br><tt>%2</tt>").arg(NOBR(tr("Your currently selected TEMP folder does not exist anymore:")), NOBR(QDir::toNativeSeparators(tempFolder))), tr("Restore Default"), tr("Cancel")) == 0)
1166 while(checkBoxUseSystemTempFolder->isChecked() == m_settings->customTempPathEnabledDefault()) checkBoxUseSystemTempFolder->click();
1168 return;
1171 bool ok = false;
1172 unsigned __int64 currentFreeDiskspace = lamexp_free_diskspace(tempFolder, &ok);
1174 if(ok && (currentFreeDiskspace < (oneGigabyte * minimumFreeDiskspaceMultiplier)))
1176 QStringList tempFolderParts = tempFolder.split("/", QString::SkipEmptyParts, Qt::CaseInsensitive);
1177 tempFolderParts.takeLast();
1178 if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
1179 QString lowDiskspaceMsg = QString("%1<br>%2<br><br>%3<br>%4<br>").arg
1181 NOBR(tr("There are less than %1 GB of free diskspace available on your system's TEMP folder.").arg(QString::number(minimumFreeDiskspaceMultiplier))),
1182 NOBR(tr("It is highly recommend to free up more diskspace before proceeding with the encode!")),
1183 NOBR(tr("Your TEMP folder is located at:")),
1184 QString("<nobr><tt>%1</tt></nobr>").arg(FSLINK(tempFolderParts.join("\\")))
1186 switch(QMessageBox::warning(this, tr("Low Diskspace Warning"), lowDiskspaceMsg, tr("Abort Encoding Process"), tr("Clean Disk Now"), tr("Ignore")))
1188 case 1:
1189 QProcess::startDetached(QString("%1/cleanmgr.exe").arg(lamexp_known_folder(lamexp_folder_systemfolder)), QStringList() << "/D" << tempFolderParts.first());
1190 case 0:
1191 return;
1192 break;
1193 default:
1194 QMessageBox::warning(this, tr("Low Diskspace"), tr("You are proceeding with low diskspace. Problems might occur!"));
1195 break;
1199 switch(m_settings->compressionEncoder())
1201 case SettingsModel::MP3Encoder:
1202 case SettingsModel::VorbisEncoder:
1203 case SettingsModel::AACEncoder:
1204 case SettingsModel::AC3Encoder:
1205 case SettingsModel::FLACEncoder:
1206 case SettingsModel::PCMEncoder:
1207 break;
1208 default:
1209 QMessageBox::warning(this, tr("LameXP"), tr("Sorry, an unsupported encoder has been chosen!"));
1210 tabWidget->setCurrentIndex(3);
1211 return;
1214 if(!m_settings->outputToSourceDir())
1216 QFile writeTest(QString("%1/~%2.txt").arg(m_settings->outputDir(), lamexp_rand_str()));
1217 if(!(writeTest.open(QIODevice::ReadWrite) && (writeTest.write(writeTestBuffer) == strlen(writeTestBuffer))))
1219 QMessageBox::warning(this, tr("LameXP"), QString("%1<br><nobr>%2</nobr><br><br>%3").arg(tr("Cannot write to the selected output directory."), m_settings->outputDir(), tr("Please choose a different directory!")));
1220 tabWidget->setCurrentIndex(1);
1221 return;
1223 else
1225 writeTest.close();
1226 writeTest.remove();
1230 m_accepted = true;
1231 close();
1235 * About button
1237 void MainWindow::aboutButtonClicked(void)
1239 ABORT_IF_BUSY;
1241 TEMP_HIDE_DROPBOX
1243 AboutDialog *aboutBox = new AboutDialog(m_settings, this);
1244 aboutBox->exec();
1245 LAMEXP_DELETE(aboutBox);
1250 * Close button
1252 void MainWindow::closeButtonClicked(void)
1254 ABORT_IF_BUSY;
1255 close();
1258 // =========================================================
1259 // Tab widget slots
1260 // =========================================================
1263 * Tab page changed
1265 void MainWindow::tabPageChanged(int idx)
1267 QList<QAction*> actions = m_tabActionGroup->actions();
1268 for(int i = 0; i < actions.count(); i++)
1270 bool ok = false;
1271 int actionIndex = actions.at(i)->data().toInt(&ok);
1272 if(ok && actionIndex == idx)
1274 actions.at(i)->setChecked(true);
1278 int initialWidth = this->width();
1279 int maximumWidth = QApplication::desktop()->width();
1281 if(this->isVisible())
1283 while(tabWidget->width() < tabWidget->sizeHint().width())
1285 int previousWidth = this->width();
1286 this->resize(this->width() + 1, this->height());
1287 if(this->frameGeometry().width() >= maximumWidth) break;
1288 if(this->width() <= previousWidth) break;
1292 if(idx == tabWidget->indexOf(tabOptions) && scrollArea->widget() && this->isVisible())
1294 for(int i = 0; i < 2; i++)
1296 QApplication::processEvents();
1297 while(scrollArea->viewport()->width() < scrollArea->widget()->width())
1299 int previousWidth = this->width();
1300 this->resize(this->width() + 1, this->height());
1301 if(this->frameGeometry().width() >= maximumWidth) break;
1302 if(this->width() <= previousWidth) break;
1306 else if(idx == tabWidget->indexOf(tabSourceFiles))
1308 m_dropNoteLabel->setGeometry(0, 0, sourceFileView->width(), sourceFileView->height());
1310 else if(idx == tabWidget->indexOf(tabOutputDir))
1312 if(!m_OutputFolderViewInitialized)
1314 QTimer::singleShot(0, this, SLOT(initOutputFolderModel()));
1318 if(initialWidth < this->width())
1320 QPoint prevPos = this->pos();
1321 int delta = (this->width() - initialWidth) >> 2;
1322 move(prevPos.x() - delta, prevPos.y());
1327 * Tab action triggered
1329 void MainWindow::tabActionActivated(QAction *action)
1331 if(action && action->data().isValid())
1333 bool ok = false;
1334 int index = action->data().toInt(&ok);
1335 if(ok)
1337 tabWidget->setCurrentIndex(index);
1342 // =========================================================
1343 // View menu slots
1344 // =========================================================
1347 * Style action triggered
1349 void MainWindow::styleActionActivated(QAction *action)
1351 //Change style setting
1352 if(action && action->data().isValid())
1354 bool ok = false;
1355 int actionIndex = action->data().toInt(&ok);
1356 if(ok)
1358 m_settings->interfaceStyle(actionIndex);
1362 //Set up the new style
1363 switch(m_settings->interfaceStyle())
1365 case 1:
1366 if(actionStyleCleanlooks->isEnabled())
1368 actionStyleCleanlooks->setChecked(true);
1369 QApplication::setStyle(new QCleanlooksStyle());
1370 break;
1372 case 2:
1373 if(actionStyleWindowsVista->isEnabled())
1375 actionStyleWindowsVista->setChecked(true);
1376 QApplication::setStyle(new QWindowsVistaStyle());
1377 break;
1379 case 3:
1380 if(actionStyleWindowsXP->isEnabled())
1382 actionStyleWindowsXP->setChecked(true);
1383 QApplication::setStyle(new QWindowsXPStyle());
1384 break;
1386 case 4:
1387 if(actionStyleWindowsClassic->isEnabled())
1389 actionStyleWindowsClassic->setChecked(true);
1390 QApplication::setStyle(new QWindowsStyle());
1391 break;
1393 default:
1394 actionStylePlastique->setChecked(true);
1395 QApplication::setStyle(new QPlastiqueStyle());
1396 break;
1399 //Force re-translate after style change
1400 changeEvent(new QEvent(QEvent::LanguageChange));
1404 * Language action triggered
1406 void MainWindow::languageActionActivated(QAction *action)
1408 if(action->data().type() == QVariant::String)
1410 QString langId = action->data().toString();
1412 if(lamexp_install_translator(langId))
1414 action->setChecked(true);
1415 m_settings->currentLanguage(langId);
1421 * Load language from file action triggered
1423 void MainWindow::languageFromFileActionActivated(bool checked)
1425 QFileDialog dialog(this, tr("Load Translation"));
1426 dialog.setFileMode(QFileDialog::ExistingFile);
1427 dialog.setNameFilter(QString("%1 (*.qm)").arg(tr("Translation Files")));
1429 if(dialog.exec())
1431 QStringList selectedFiles = dialog.selectedFiles();
1432 if(lamexp_install_translator_from_file(selectedFiles.first()))
1434 QList<QAction*> actions = m_languageActionGroup->actions();
1435 while(!actions.isEmpty())
1437 actions.takeFirst()->setChecked(false);
1440 else
1442 languageActionActivated(m_languageActionGroup->actions().first());
1447 // =========================================================
1448 // Tools menu slots
1449 // =========================================================
1452 * Disable update reminder action
1454 void MainWindow::disableUpdateReminderActionTriggered(bool checked)
1456 if(checked)
1458 if(0 == QMessageBox::question(this, tr("Disable Update Reminder"), NOBR(tr("Do you really want to disable the update reminder?")), tr("Yes"), tr("No"), QString(), 1))
1460 QMessageBox::information(this, tr("Update Reminder"), QString("%1<br>%2").arg(NOBR(tr("The update reminder has been disabled.")), NOBR(tr("Please remember to check for updates at regular intervals!"))));
1461 m_settings->autoUpdateEnabled(false);
1463 else
1465 m_settings->autoUpdateEnabled(true);
1468 else
1470 QMessageBox::information(this, tr("Update Reminder"), NOBR(tr("The update reminder has been re-enabled.")));
1471 m_settings->autoUpdateEnabled(true);
1474 actionDisableUpdateReminder->setChecked(!m_settings->autoUpdateEnabled());
1478 * Disable sound effects action
1480 void MainWindow::disableSoundsActionTriggered(bool checked)
1482 if(checked)
1484 if(0 == QMessageBox::question(this, tr("Disable Sound Effects"), NOBR(tr("Do you really want to disable all sound effects?")), tr("Yes"), tr("No"), QString(), 1))
1486 QMessageBox::information(this, tr("Sound Effects"), NOBR(tr("All sound effects have been disabled.")));
1487 m_settings->soundsEnabled(false);
1489 else
1491 m_settings->soundsEnabled(true);
1494 else
1496 QMessageBox::information(this, tr("Sound Effects"), NOBR(tr("The sound effects have been re-enabled.")));
1497 m_settings->soundsEnabled(true);
1500 actionDisableSounds->setChecked(!m_settings->soundsEnabled());
1504 * Disable Nero AAC encoder action
1506 void MainWindow::disableNeroAacNotificationsActionTriggered(bool checked)
1508 if(checked)
1510 if(0 == QMessageBox::question(this, tr("Nero AAC Notifications"), NOBR(tr("Do you really want to disable all Nero AAC Encoder notifications?")), tr("Yes"), tr("No"), QString(), 1))
1512 QMessageBox::information(this, tr("Nero AAC Notifications"), NOBR(tr("All Nero AAC Encoder notifications have been disabled.")));
1513 m_settings->neroAacNotificationsEnabled(false);
1515 else
1517 m_settings->neroAacNotificationsEnabled(true);
1520 else
1522 QMessageBox::information(this, tr("Nero AAC Notifications"), NOBR(tr("The Nero AAC Encoder notifications have been re-enabled.")));
1523 m_settings->neroAacNotificationsEnabled(true);
1526 actionDisableNeroAacNotifications->setChecked(!m_settings->neroAacNotificationsEnabled());
1530 * Disable slow startup action
1532 void MainWindow::disableSlowStartupNotificationsActionTriggered(bool checked)
1534 if(checked)
1536 if(0 == QMessageBox::question(this, tr("Slow Startup Notifications"), NOBR(tr("Do you really want to disable the slow startup notifications?")), tr("Yes"), tr("No"), QString(), 1))
1538 QMessageBox::information(this, tr("Slow Startup Notifications"), NOBR(tr("The slow startup notifications have been disabled.")));
1539 m_settings->antivirNotificationsEnabled(false);
1541 else
1543 m_settings->antivirNotificationsEnabled(true);
1546 else
1548 QMessageBox::information(this, tr("Slow Startup Notifications"), NOBR(tr("The slow startup notifications have been re-enabled.")));
1549 m_settings->antivirNotificationsEnabled(true);
1552 actionDisableSlowStartupNotifications->setChecked(!m_settings->antivirNotificationsEnabled());
1556 * Import a Cue Sheet file
1558 void MainWindow::importCueSheetActionTriggered(bool checked)
1560 ABORT_IF_BUSY;
1562 TEMP_HIDE_DROPBOX
1564 while(true)
1566 int result = 0;
1567 QString selectedCueFile;
1569 if(USE_NATIVE_FILE_DIALOG)
1571 selectedCueFile = QFileDialog::getOpenFileName(this, tr("Open Cue Sheet"), m_settings->mostRecentInputPath(), QString("%1 (*.cue)").arg(tr("Cue Sheet File")));
1573 else
1575 QFileDialog dialog(this, tr("Open Cue Sheet"));
1576 dialog.setFileMode(QFileDialog::ExistingFile);
1577 dialog.setNameFilter(QString("%1 (*.cue)").arg(tr("Cue Sheet File")));
1578 dialog.setDirectory(m_settings->mostRecentInputPath());
1579 if(dialog.exec())
1581 selectedCueFile = dialog.selectedFiles().first();
1585 if(!selectedCueFile.isEmpty())
1587 m_settings->mostRecentInputPath(QFileInfo(selectedCueFile).canonicalPath());
1588 CueImportDialog *cueImporter = new CueImportDialog(this, m_fileListModel, selectedCueFile);
1589 result = cueImporter->exec();
1590 LAMEXP_DELETE(cueImporter);
1593 if(result != (-1)) break;
1599 * Show the "drop box" widget
1601 void MainWindow::showDropBoxWidgetActionTriggered(bool checked)
1603 m_settings->dropBoxWidgetEnabled(true);
1605 if(!m_dropBox->isVisible())
1607 m_dropBox->show();
1610 lamexp_blink_window(m_dropBox);
1614 * Check for beta (pre-release) updates
1616 void MainWindow::checkForBetaUpdatesActionTriggered(bool checked)
1618 bool checkUpdatesNow = false;
1620 if(checked)
1622 if(0 == QMessageBox::question(this, tr("Beta Updates"), NOBR(tr("Do you really want LameXP to check for Beta (pre-release) updates?")), tr("Yes"), tr("No"), QString(), 1))
1624 if(0 == QMessageBox::information(this, tr("Beta Updates"), NOBR(tr("LameXP will check for Beta (pre-release) updates from now on.")), tr("Check Now"), tr("Discard")))
1626 checkUpdatesNow = true;
1628 m_settings->autoUpdateCheckBeta(true);
1630 else
1632 m_settings->autoUpdateCheckBeta(false);
1635 else
1637 QMessageBox::information(this, tr("Beta Updates"), NOBR(tr("LameXP will <i>not</i> check for Beta (pre-release) updates from now on.")));
1638 m_settings->autoUpdateCheckBeta(false);
1641 actionCheckForBetaUpdates->setChecked(m_settings->autoUpdateCheckBeta());
1643 if(checkUpdatesNow)
1645 if(checkForUpdates())
1647 QApplication::quit();
1653 * Hibernate computer action
1655 void MainWindow::hibernateComputerActionTriggered(bool checked)
1657 if(checked)
1659 if(0 == QMessageBox::question(this, tr("Hibernate Computer"), NOBR(tr("Do you really want the computer to be hibernated on shutdown?")), tr("Yes"), tr("No"), QString(), 1))
1661 QMessageBox::information(this, tr("Hibernate Computer"), NOBR(tr("LameXP will hibernate the computer on shutdown from now on.")));
1662 m_settings->hibernateComputer(true);
1664 else
1666 m_settings->hibernateComputer(false);
1669 else
1671 QMessageBox::information(this, tr("Hibernate Computer"), NOBR(tr("LameXP will <i>not</i> hibernate the computer on shutdown from now on.")));
1672 m_settings->hibernateComputer(false);
1675 actionHibernateComputer->setChecked(m_settings->hibernateComputer());
1679 * Disable shell integration action
1681 void MainWindow::disableShellIntegrationActionTriggered(bool checked)
1683 if(checked)
1685 if(0 == QMessageBox::question(this, tr("Shell Integration"), NOBR(tr("Do you really want to disable the LameXP shell integration?")), tr("Yes"), tr("No"), QString(), 1))
1687 ShellIntegration::remove();
1688 QMessageBox::information(this, tr("Shell Integration"), NOBR(tr("The LameXP shell integration has been disabled.")));
1689 m_settings->shellIntegrationEnabled(false);
1691 else
1693 m_settings->shellIntegrationEnabled(true);
1696 else
1698 ShellIntegration::install();
1699 QMessageBox::information(this, tr("Shell Integration"), NOBR(tr("The LameXP shell integration has been re-enabled.")));
1700 m_settings->shellIntegrationEnabled(true);
1703 actionDisableShellIntegration->setChecked(!m_settings->shellIntegrationEnabled());
1705 if(lamexp_portable_mode() && actionDisableShellIntegration->isChecked())
1707 actionDisableShellIntegration->setEnabled(false);
1711 // =========================================================
1712 // Help menu slots
1713 // =========================================================
1716 * Visit homepage action
1718 void MainWindow::visitHomepageActionActivated(void)
1720 if(QAction *action = dynamic_cast<QAction*>(QObject::sender()))
1722 if(action->data().isValid() && (action->data().type() == QVariant::String))
1724 QDesktopServices::openUrl(QUrl(action->data().toString()));
1730 * Show document
1732 void MainWindow::documentActionActivated(void)
1734 if(QAction *action = dynamic_cast<QAction*>(QObject::sender()))
1736 if(action->data().isValid() && (action->data().type() == QVariant::String))
1738 QFileInfo document(action->data().toString());
1739 QFileInfo resource(QString(":/doc/%1.html").arg(document.baseName()));
1740 if(document.exists() && document.isFile() && (document.size() == resource.size()))
1742 QDesktopServices::openUrl(QUrl::fromLocalFile(document.canonicalFilePath()));
1744 else
1746 QFile source(resource.filePath());
1747 QFile output(QString("%1/%2.%3.html").arg(lamexp_temp_folder2(), document.baseName(), lamexp_rand_str().left(8)));
1748 if(source.open(QIODevice::ReadOnly) && output.open(QIODevice::ReadWrite))
1750 output.write(source.readAll());
1751 action->setData(output.fileName());
1752 source.close();
1753 output.close();
1754 QDesktopServices::openUrl(QUrl::fromLocalFile(output.fileName()));
1762 * Check for updates action
1764 void MainWindow::checkUpdatesActionActivated(void)
1766 ABORT_IF_BUSY;
1767 bool bFlag = false;
1769 TEMP_HIDE_DROPBOX
1771 bFlag = checkForUpdates();
1774 if(bFlag)
1776 QApplication::quit();
1780 // =========================================================
1781 // Source file slots
1782 // =========================================================
1785 * Add file(s) button
1787 void MainWindow::addFilesButtonClicked(void)
1789 ABORT_IF_BUSY;
1791 TEMP_HIDE_DROPBOX
1793 if(USE_NATIVE_FILE_DIALOG)
1795 QStringList fileTypeFilters = DecoderRegistry::getSupportedTypes();
1796 QStringList selectedFiles = QFileDialog::getOpenFileNames(this, tr("Add file(s)"), m_settings->mostRecentInputPath(), fileTypeFilters.join(";;"));
1797 if(!selectedFiles.isEmpty())
1799 m_settings->mostRecentInputPath(QFileInfo(selectedFiles.first()).canonicalPath());
1800 addFiles(selectedFiles);
1803 else
1805 QFileDialog dialog(this, tr("Add file(s)"));
1806 QStringList fileTypeFilters = DecoderRegistry::getSupportedTypes();
1807 dialog.setFileMode(QFileDialog::ExistingFiles);
1808 dialog.setNameFilter(fileTypeFilters.join(";;"));
1809 dialog.setDirectory(m_settings->mostRecentInputPath());
1810 if(dialog.exec())
1812 QStringList selectedFiles = dialog.selectedFiles();
1813 if(!selectedFiles.isEmpty())
1815 m_settings->mostRecentInputPath(QFileInfo(selectedFiles.first()).canonicalPath());
1816 addFiles(selectedFiles);
1824 * Open folder action
1826 void MainWindow::openFolderActionActivated(void)
1828 ABORT_IF_BUSY;
1829 QString selectedFolder;
1831 if(QAction *action = dynamic_cast<QAction*>(QObject::sender()))
1833 TEMP_HIDE_DROPBOX
1835 if(USE_NATIVE_FILE_DIALOG)
1837 selectedFolder = QFileDialog::getExistingDirectory(this, tr("Add Folder"), m_settings->mostRecentInputPath());
1839 else
1841 QFileDialog dialog(this, tr("Add Folder"));
1842 dialog.setFileMode(QFileDialog::DirectoryOnly);
1843 dialog.setDirectory(m_settings->mostRecentInputPath());
1844 if(dialog.exec())
1846 selectedFolder = dialog.selectedFiles().first();
1850 if(!selectedFolder.isEmpty())
1852 m_settings->mostRecentInputPath(QDir(selectedFolder).canonicalPath());
1853 addFolder(selectedFolder, action->data().toBool());
1860 * Remove file button
1862 void MainWindow::removeFileButtonClicked(void)
1864 if(sourceFileView->currentIndex().isValid())
1866 int iRow = sourceFileView->currentIndex().row();
1867 m_fileListModel->removeFile(sourceFileView->currentIndex());
1868 sourceFileView->selectRow(iRow < m_fileListModel->rowCount() ? iRow : m_fileListModel->rowCount()-1);
1873 * Clear files button
1875 void MainWindow::clearFilesButtonClicked(void)
1877 m_fileListModel->clearFiles();
1881 * Move file up button
1883 void MainWindow::fileUpButtonClicked(void)
1885 if(sourceFileView->currentIndex().isValid())
1887 int iRow = sourceFileView->currentIndex().row() - 1;
1888 m_fileListModel->moveFile(sourceFileView->currentIndex(), -1);
1889 sourceFileView->selectRow(iRow >= 0 ? iRow : 0);
1894 * Move file down button
1896 void MainWindow::fileDownButtonClicked(void)
1898 if(sourceFileView->currentIndex().isValid())
1900 int iRow = sourceFileView->currentIndex().row() + 1;
1901 m_fileListModel->moveFile(sourceFileView->currentIndex(), 1);
1902 sourceFileView->selectRow(iRow < m_fileListModel->rowCount() ? iRow : m_fileListModel->rowCount()-1);
1907 * Show details button
1909 void MainWindow::showDetailsButtonClicked(void)
1911 ABORT_IF_BUSY;
1913 int iResult = 0;
1914 MetaInfoDialog *metaInfoDialog = new MetaInfoDialog(this);
1915 QModelIndex index = sourceFileView->currentIndex();
1917 while(index.isValid())
1919 if(iResult > 0)
1921 index = m_fileListModel->index(index.row() + 1, index.column());
1922 sourceFileView->selectRow(index.row());
1924 if(iResult < 0)
1926 index = m_fileListModel->index(index.row() - 1, index.column());
1927 sourceFileView->selectRow(index.row());
1930 AudioFileModel &file = (*m_fileListModel)[index];
1931 TEMP_HIDE_DROPBOX
1933 iResult = metaInfoDialog->exec(file, index.row() > 0, index.row() < m_fileListModel->rowCount() - 1);
1936 if(iResult == INT_MAX)
1938 m_metaInfoModel->assignInfoFrom(file);
1939 tabWidget->setCurrentIndex(tabWidget->indexOf(tabMetaData));
1940 break;
1943 if(!iResult) break;
1946 LAMEXP_DELETE(metaInfoDialog);
1950 * Show context menu for source files
1952 void MainWindow::sourceFilesContextMenu(const QPoint &pos)
1954 QAbstractScrollArea *scrollArea = dynamic_cast<QAbstractScrollArea*>(QObject::sender());
1955 QWidget *sender = scrollArea ? scrollArea->viewport() : dynamic_cast<QWidget*>(QObject::sender());
1957 if(sender)
1959 if(pos.x() <= sender->width() && pos.y() <= sender->height() && pos.x() >= 0 && pos.y() >= 0)
1961 m_sourceFilesContextMenu->popup(sender->mapToGlobal(pos));
1967 * Scrollbar of source files moved
1969 void MainWindow::sourceFilesScrollbarMoved(int)
1971 sourceFileView->resizeColumnToContents(0);
1975 * Open selected file in external player
1977 void MainWindow::previewContextActionTriggered(void)
1979 const static char *appNames[3] = {"smplayer_portable.exe", "smplayer.exe", "mplayer.exe"};
1980 const static wchar_t *registryKey = L"SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{DB9E4EAB-2717-499F-8D56-4CC8A644AB60}";
1982 QModelIndex index = sourceFileView->currentIndex();
1983 if(!index.isValid())
1985 return;
1988 QString mplayerPath;
1989 HKEY registryKeyHandle;
1991 if(RegOpenKeyExW(HKEY_LOCAL_MACHINE, registryKey, 0, KEY_READ, &registryKeyHandle) == ERROR_SUCCESS)
1993 wchar_t Buffer[4096];
1994 DWORD BuffSize = sizeof(wchar_t*) * 4096;
1995 if(RegQueryValueExW(registryKeyHandle, L"InstallLocation", 0, 0, reinterpret_cast<BYTE*>(Buffer), &BuffSize) == ERROR_SUCCESS)
1997 mplayerPath = QString::fromUtf16(reinterpret_cast<const unsigned short*>(Buffer));
2001 if(!mplayerPath.isEmpty())
2003 QDir mplayerDir(mplayerPath);
2004 if(mplayerDir.exists())
2006 for(int i = 0; i < 3; i++)
2008 if(mplayerDir.exists(appNames[i]))
2010 QProcess::startDetached(mplayerDir.absoluteFilePath(appNames[i]), QStringList() << QDir::toNativeSeparators(m_fileListModel->getFile(index).filePath()));
2011 return;
2017 QDesktopServices::openUrl(QString("file:///").append(m_fileListModel->getFile(index).filePath()));
2021 * Find selected file in explorer
2023 void MainWindow::findFileContextActionTriggered(void)
2025 QModelIndex index = sourceFileView->currentIndex();
2026 if(index.isValid())
2028 QString systemRootPath;
2030 QDir systemRoot(lamexp_known_folder(lamexp_folder_systemfolder));
2031 if(systemRoot.exists() && systemRoot.cdUp())
2033 systemRootPath = systemRoot.canonicalPath();
2036 if(!systemRootPath.isEmpty())
2038 QFileInfo explorer(QString("%1/explorer.exe").arg(systemRootPath));
2039 if(explorer.exists() && explorer.isFile())
2041 QProcess::execute(explorer.canonicalFilePath(), QStringList() << "/select," << QDir::toNativeSeparators(m_fileListModel->getFile(index).filePath()));
2042 return;
2045 else
2047 qWarning("SystemRoot directory could not be detected!");
2053 * Add all pending files
2055 void MainWindow::handleDelayedFiles(void)
2057 m_delayedFileTimer->stop();
2059 if(m_delayedFileList->isEmpty())
2061 return;
2064 if(m_banner->isVisible())
2066 m_delayedFileTimer->start(5000);
2067 return;
2070 QStringList selectedFiles;
2071 tabWidget->setCurrentIndex(0);
2073 while(!m_delayedFileList->isEmpty())
2075 QFileInfo currentFile = QFileInfo(m_delayedFileList->takeFirst());
2076 if(!currentFile.exists() || !currentFile.isFile())
2078 continue;
2080 selectedFiles << currentFile.canonicalFilePath();
2083 addFiles(selectedFiles);
2087 * Show or hide Drag'n'Drop notice after model reset
2089 void MainWindow::sourceModelChanged(void)
2091 m_dropNoteLabel->setVisible(m_fileListModel->rowCount() <= 0);
2094 // =========================================================
2095 // Output folder slots
2096 // =========================================================
2099 * Output folder changed (mouse clicked)
2101 void MainWindow::outputFolderViewClicked(const QModelIndex &index)
2103 if(outputFolderView->currentIndex() != index)
2105 outputFolderView->setCurrentIndex(index);
2107 QString selectedDir = m_fileSystemModel->filePath(index);
2108 if(selectedDir.length() < 3) selectedDir.append(QDir::separator());
2109 outputFolderLabel->setText(QDir::toNativeSeparators(selectedDir));
2110 m_settings->outputDir(selectedDir);
2114 * Output folder changed (mouse moved)
2116 void MainWindow::outputFolderViewMoved(const QModelIndex &index)
2118 if(QApplication::mouseButtons() & Qt::LeftButton)
2120 outputFolderViewClicked(index);
2125 * Goto desktop button
2127 void MainWindow::gotoDesktopButtonClicked(void)
2129 QString desktopPath = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation);
2131 if(!desktopPath.isEmpty() && QDir(desktopPath).exists())
2133 outputFolderView->setCurrentIndex(m_fileSystemModel->index(desktopPath));
2134 outputFolderViewClicked(outputFolderView->currentIndex());
2135 outputFolderView->setFocus();
2137 else
2139 buttonGotoDesktop->setEnabled(false);
2144 * Goto home folder button
2146 void MainWindow::gotoHomeFolderButtonClicked(void)
2148 QString homePath = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
2150 if(!homePath.isEmpty() && QDir(homePath).exists())
2152 outputFolderView->setCurrentIndex(m_fileSystemModel->index(homePath));
2153 outputFolderViewClicked(outputFolderView->currentIndex());
2154 outputFolderView->setFocus();
2156 else
2158 buttonGotoHome->setEnabled(false);
2163 * Goto music folder button
2165 void MainWindow::gotoMusicFolderButtonClicked(void)
2167 QString musicPath = QDesktopServices::storageLocation(QDesktopServices::MusicLocation);
2169 if(!musicPath.isEmpty() && QDir(musicPath).exists())
2171 outputFolderView->setCurrentIndex(m_fileSystemModel->index(musicPath));
2172 outputFolderViewClicked(outputFolderView->currentIndex());
2173 outputFolderView->setFocus();
2175 else
2177 buttonGotoMusic->setEnabled(false);
2182 * Goto music favorite output folder
2184 void MainWindow::gotoFavoriteFolder(void)
2186 QAction *item = dynamic_cast<QAction*>(QObject::sender());
2188 if(item)
2190 QDir path(item->data().toString());
2191 if(path.exists())
2193 outputFolderView->setCurrentIndex(m_fileSystemModel->index(path.canonicalPath()));
2194 outputFolderViewClicked(outputFolderView->currentIndex());
2195 outputFolderView->setFocus();
2197 else
2199 MessageBeep(MB_ICONERROR);
2200 m_outputFolderFavoritesMenu->removeAction(item);
2201 item->deleteLater();
2207 * Make folder button
2209 void MainWindow::makeFolderButtonClicked(void)
2211 ABORT_IF_BUSY;
2213 QDir basePath(m_fileSystemModel->fileInfo(outputFolderView->currentIndex()).absoluteFilePath());
2214 QString suggestedName = tr("New Folder");
2216 if(!m_metaData->fileArtist().isEmpty() && !m_metaData->fileAlbum().isEmpty())
2218 suggestedName = QString("%1 - %2").arg(m_metaData->fileArtist(), m_metaData->fileAlbum());
2220 else if(!m_metaData->fileArtist().isEmpty())
2222 suggestedName = m_metaData->fileArtist();
2224 else if(!m_metaData->fileAlbum().isEmpty())
2226 suggestedName = m_metaData->fileAlbum();
2228 else
2230 for(int i = 0; i < m_fileListModel->rowCount(); i++)
2232 AudioFileModel audioFile = m_fileListModel->getFile(m_fileListModel->index(i, 0));
2233 if(!audioFile.fileAlbum().isEmpty() || !audioFile.fileArtist().isEmpty())
2235 if(!audioFile.fileArtist().isEmpty() && !audioFile.fileAlbum().isEmpty())
2237 suggestedName = QString("%1 - %2").arg(audioFile.fileArtist(), audioFile.fileAlbum());
2239 else if(!audioFile.fileArtist().isEmpty())
2241 suggestedName = audioFile.fileArtist();
2243 else if(!audioFile.fileAlbum().isEmpty())
2245 suggestedName = audioFile.fileAlbum();
2247 break;
2252 suggestedName = lamexp_clean_filename(suggestedName);
2254 while(true)
2256 bool bApplied = false;
2257 QString folderName = QInputDialog::getText(this, tr("New Folder"), tr("Enter the name of the new folder:").leftJustified(96, ' '), QLineEdit::Normal, suggestedName, &bApplied, Qt::WindowStaysOnTopHint).simplified();
2259 if(bApplied)
2261 folderName = lamexp_clean_filepath(folderName.simplified());
2263 if(folderName.isEmpty())
2265 MessageBeep(MB_ICONERROR);
2266 continue;
2269 int i = 1;
2270 QString newFolder = folderName;
2272 while(basePath.exists(newFolder))
2274 newFolder = QString(folderName).append(QString().sprintf(" (%d)", ++i));
2277 if(basePath.mkpath(newFolder))
2279 QDir createdDir = basePath;
2280 if(createdDir.cd(newFolder))
2282 outputFolderView->setCurrentIndex(m_fileSystemModel->index(createdDir.canonicalPath()));
2283 outputFolderViewClicked(outputFolderView->currentIndex());
2284 outputFolderView->setFocus();
2287 else
2289 QMessageBox::warning(this, tr("Failed to create folder"), QString("%1<br><nobr>%2</nobr><br><br>%3").arg(tr("The new folder could not be created:"), basePath.absoluteFilePath(newFolder), tr("Drive is read-only or insufficient access rights!")));
2292 break;
2297 * Output to source dir changed
2299 void MainWindow::saveToSourceFolderChanged(void)
2301 m_settings->outputToSourceDir(saveToSourceFolderCheckBox->isChecked());
2305 * Prepend relative source file path to output file name changed
2307 void MainWindow::prependRelativePathChanged(void)
2309 m_settings->prependRelativeSourcePath(prependRelativePathCheckBox->isChecked());
2313 * Show context menu for output folder
2315 void MainWindow::outputFolderContextMenu(const QPoint &pos)
2317 QAbstractScrollArea *scrollArea = dynamic_cast<QAbstractScrollArea*>(QObject::sender());
2318 QWidget *sender = scrollArea ? scrollArea->viewport() : dynamic_cast<QWidget*>(QObject::sender());
2320 if(pos.x() <= sender->width() && pos.y() <= sender->height() && pos.x() >= 0 && pos.y() >= 0)
2322 m_outputFolderContextMenu->popup(sender->mapToGlobal(pos));
2327 * Show selected folder in explorer
2329 void MainWindow::showFolderContextActionTriggered(void)
2331 QDesktopServices::openUrl(QUrl::fromLocalFile(m_fileSystemModel->filePath(outputFolderView->currentIndex())));
2335 * Add current folder to favorites
2337 void MainWindow::addFavoriteFolderActionTriggered(void)
2339 QString path = m_fileSystemModel->filePath(outputFolderView->currentIndex());
2340 QStringList favorites = m_settings->favoriteOutputFolders().split("|", QString::SkipEmptyParts);
2342 if(!favorites.contains(path, Qt::CaseInsensitive))
2344 favorites.append(path);
2345 while(favorites.count() > 6) favorites.removeFirst();
2347 else
2349 MessageBeep(MB_ICONWARNING);
2352 m_settings->favoriteOutputFolders(favorites.join("|"));
2353 refreshFavorites();
2357 * Initialize file system model
2359 void MainWindow::initOutputFolderModel(void)
2361 QModelIndex previousIndex = outputFolderView->currentIndex();
2362 m_fileSystemModel->setRootPath(m_fileSystemModel->rootPath());
2363 QApplication::processEvents();
2364 outputFolderView->reset();
2365 outputFolderView->setCurrentIndex(previousIndex);
2366 m_OutputFolderViewInitialized = true;
2369 // =========================================================
2370 // Metadata tab slots
2371 // =========================================================
2374 * Edit meta button clicked
2376 void MainWindow::editMetaButtonClicked(void)
2378 ABORT_IF_BUSY;
2380 const QModelIndex index = metaDataView->currentIndex();
2382 if(index.isValid())
2384 m_metaInfoModel->editItem(index, this);
2386 if(index.row() == 4)
2388 m_settings->metaInfoPosition(m_metaData->filePosition());
2394 * Reset meta button clicked
2396 void MainWindow::clearMetaButtonClicked(void)
2398 ABORT_IF_BUSY;
2399 m_metaInfoModel->clearData();
2403 * Meta tags enabled changed
2405 void MainWindow::metaTagsEnabledChanged(void)
2407 m_settings->writeMetaTags(writeMetaDataCheckBox->isChecked());
2411 * Playlist enabled changed
2413 void MainWindow::playlistEnabledChanged(void)
2415 m_settings->createPlaylist(generatePlaylistCheckBox->isChecked());
2418 // =========================================================
2419 // Compression tab slots
2420 // =========================================================
2423 * Update encoder
2425 void MainWindow::updateEncoder(int id)
2427 m_settings->compressionEncoder(id);
2429 switch(m_settings->compressionEncoder())
2431 case SettingsModel::VorbisEncoder:
2432 radioButtonModeQuality->setEnabled(true);
2433 radioButtonModeAverageBitrate->setEnabled(true);
2434 radioButtonConstBitrate->setEnabled(false);
2435 if(radioButtonConstBitrate->isChecked()) radioButtonModeQuality->setChecked(true);
2436 sliderBitrate->setEnabled(true);
2437 break;
2438 case SettingsModel::AC3Encoder:
2439 radioButtonModeQuality->setEnabled(true);
2440 radioButtonModeQuality->setChecked(true);
2441 radioButtonModeAverageBitrate->setEnabled(false);
2442 radioButtonConstBitrate->setEnabled(true);
2443 sliderBitrate->setEnabled(true);
2444 break;
2445 case SettingsModel::FLACEncoder:
2446 radioButtonModeQuality->setEnabled(false);
2447 radioButtonModeQuality->setChecked(true);
2448 radioButtonModeAverageBitrate->setEnabled(false);
2449 radioButtonConstBitrate->setEnabled(false);
2450 sliderBitrate->setEnabled(true);
2451 break;
2452 case SettingsModel::PCMEncoder:
2453 radioButtonModeQuality->setEnabled(false);
2454 radioButtonModeQuality->setChecked(true);
2455 radioButtonModeAverageBitrate->setEnabled(false);
2456 radioButtonConstBitrate->setEnabled(false);
2457 sliderBitrate->setEnabled(false);
2458 break;
2459 case SettingsModel::AACEncoder:
2460 radioButtonModeQuality->setEnabled(true);
2461 radioButtonModeAverageBitrate->setEnabled(!m_fhgEncoderAvailable);
2462 if(m_fhgEncoderAvailable && radioButtonModeAverageBitrate->isChecked()) radioButtonConstBitrate->setChecked(true);
2463 radioButtonConstBitrate->setEnabled(true);
2464 sliderBitrate->setEnabled(true);
2465 break;
2466 default:
2467 radioButtonModeQuality->setEnabled(true);
2468 radioButtonModeAverageBitrate->setEnabled(true);
2469 radioButtonConstBitrate->setEnabled(true);
2470 sliderBitrate->setEnabled(true);
2471 break;
2474 updateRCMode(m_modeButtonGroup->checkedId());
2478 * Update rate-control mode
2480 void MainWindow::updateRCMode(int id)
2482 m_settings->compressionRCMode(id);
2484 switch(m_settings->compressionEncoder())
2486 case SettingsModel::MP3Encoder:
2487 switch(m_settings->compressionRCMode())
2489 case SettingsModel::VBRMode:
2490 sliderBitrate->setMinimum(0);
2491 sliderBitrate->setMaximum(9);
2492 break;
2493 default:
2494 sliderBitrate->setMinimum(0);
2495 sliderBitrate->setMaximum(13);
2496 break;
2498 break;
2499 case SettingsModel::VorbisEncoder:
2500 switch(m_settings->compressionRCMode())
2502 case SettingsModel::VBRMode:
2503 sliderBitrate->setMinimum(-2);
2504 sliderBitrate->setMaximum(10);
2505 break;
2506 default:
2507 sliderBitrate->setMinimum(4);
2508 sliderBitrate->setMaximum(63);
2509 break;
2511 break;
2512 case SettingsModel::AC3Encoder:
2513 switch(m_settings->compressionRCMode())
2515 case SettingsModel::VBRMode:
2516 sliderBitrate->setMinimum(0);
2517 sliderBitrate->setMaximum(16);
2518 break;
2519 default:
2520 sliderBitrate->setMinimum(0);
2521 sliderBitrate->setMaximum(18);
2522 break;
2524 break;
2525 case SettingsModel::AACEncoder:
2526 switch(m_settings->compressionRCMode())
2528 case SettingsModel::VBRMode:
2529 sliderBitrate->setMinimum(0);
2530 sliderBitrate->setMaximum(20);
2531 break;
2532 default:
2533 sliderBitrate->setMinimum(4);
2534 sliderBitrate->setMaximum(63);
2535 break;
2537 break;
2538 case SettingsModel::FLACEncoder:
2539 sliderBitrate->setMinimum(0);
2540 sliderBitrate->setMaximum(8);
2541 break;
2542 case SettingsModel::PCMEncoder:
2543 sliderBitrate->setMinimum(0);
2544 sliderBitrate->setMaximum(2);
2545 sliderBitrate->setValue(1);
2546 break;
2547 default:
2548 sliderBitrate->setMinimum(0);
2549 sliderBitrate->setMaximum(0);
2550 break;
2553 updateBitrate(sliderBitrate->value());
2557 * Update bitrate
2559 void MainWindow::updateBitrate(int value)
2561 m_settings->compressionBitrate(value);
2563 switch(m_settings->compressionRCMode())
2565 case SettingsModel::VBRMode:
2566 switch(m_settings->compressionEncoder())
2568 case SettingsModel::MP3Encoder:
2569 labelBitrate->setText(tr("Quality Level %1").arg(9 - value));
2570 break;
2571 case SettingsModel::VorbisEncoder:
2572 labelBitrate->setText(tr("Quality Level %1").arg(value));
2573 break;
2574 case SettingsModel::AACEncoder:
2575 labelBitrate->setText(tr("Quality Level %1").arg(QString().sprintf("%.2f", static_cast<double>(value * 5) / 100.0)));
2576 break;
2577 case SettingsModel::FLACEncoder:
2578 labelBitrate->setText(tr("Compression %1").arg(value));
2579 break;
2580 case SettingsModel::AC3Encoder:
2581 labelBitrate->setText(tr("Quality Level %1").arg(min(1024, max(0, value * 64))));
2582 break;
2583 case SettingsModel::PCMEncoder:
2584 labelBitrate->setText(tr("Uncompressed"));
2585 break;
2586 default:
2587 labelBitrate->setText(QString::number(value));
2588 break;
2590 break;
2591 case SettingsModel::ABRMode:
2592 switch(m_settings->compressionEncoder())
2594 case SettingsModel::MP3Encoder:
2595 labelBitrate->setText(QString("&asymp; %1 kbps").arg(SettingsModel::mp3Bitrates[value]));
2596 break;
2597 case SettingsModel::FLACEncoder:
2598 labelBitrate->setText(tr("Compression %1").arg(value));
2599 break;
2600 case SettingsModel::AC3Encoder:
2601 labelBitrate->setText(QString("&asymp; %1 kbps").arg(SettingsModel::ac3Bitrates[value]));
2602 break;
2603 case SettingsModel::PCMEncoder:
2604 labelBitrate->setText(tr("Uncompressed"));
2605 break;
2606 default:
2607 labelBitrate->setText(QString("&asymp; %1 kbps").arg(min(500, value * 8)));
2608 break;
2610 break;
2611 default:
2612 switch(m_settings->compressionEncoder())
2614 case SettingsModel::MP3Encoder:
2615 labelBitrate->setText(QString("%1 kbps").arg(SettingsModel::mp3Bitrates[value]));
2616 break;
2617 case SettingsModel::FLACEncoder:
2618 labelBitrate->setText(tr("Compression %1").arg(value));
2619 break;
2620 case SettingsModel::AC3Encoder:
2621 labelBitrate->setText(QString("%1 kbps").arg(SettingsModel::ac3Bitrates[value]));
2622 break;
2623 case SettingsModel::PCMEncoder:
2624 labelBitrate->setText(tr("Uncompressed"));
2625 break;
2626 default:
2627 labelBitrate->setText(QString("%1 kbps").arg(min(500, value * 8)));
2628 break;
2630 break;
2634 // =========================================================
2635 // Advanced option slots
2636 // =========================================================
2639 * Lame algorithm quality changed
2641 void MainWindow::updateLameAlgoQuality(int value)
2643 QString text;
2645 switch(value)
2647 case 4:
2648 text = tr("Best Quality (Very Slow)");
2649 break;
2650 case 3:
2651 text = tr("High Quality (Recommended)");
2652 break;
2653 case 2:
2654 text = tr("Average Quality (Default)");
2655 break;
2656 case 1:
2657 text = tr("Low Quality (Fast)");
2658 break;
2659 case 0:
2660 text = tr("Poor Quality (Very Fast)");
2661 break;
2664 if(!text.isEmpty())
2666 m_settings->lameAlgoQuality(value);
2667 labelLameAlgoQuality->setText(text);
2670 bool warning = (value == 0), notice = (value == 4);
2671 labelLameAlgoQualityWarning->setVisible(warning);
2672 labelLameAlgoQualityWarningIcon->setVisible(warning);
2673 labelLameAlgoQualityNotice->setVisible(notice);
2674 labelLameAlgoQualityNoticeIcon->setVisible(notice);
2675 labelLameAlgoQualitySpacer->setVisible(warning || notice);
2679 * Bitrate management endabled/disabled
2681 void MainWindow::bitrateManagementEnabledChanged(bool checked)
2683 m_settings->bitrateManagementEnabled(checked);
2687 * Minimum bitrate has changed
2689 void MainWindow::bitrateManagementMinChanged(int value)
2691 if(value > spinBoxBitrateManagementMax->value())
2693 spinBoxBitrateManagementMin->setValue(spinBoxBitrateManagementMax->value());
2694 m_settings->bitrateManagementMinRate(spinBoxBitrateManagementMax->value());
2696 else
2698 m_settings->bitrateManagementMinRate(value);
2703 * Maximum bitrate has changed
2705 void MainWindow::bitrateManagementMaxChanged(int value)
2707 if(value < spinBoxBitrateManagementMin->value())
2709 spinBoxBitrateManagementMax->setValue(spinBoxBitrateManagementMin->value());
2710 m_settings->bitrateManagementMaxRate(spinBoxBitrateManagementMin->value());
2712 else
2714 m_settings->bitrateManagementMaxRate(value);
2719 * Channel mode has changed
2721 void MainWindow::channelModeChanged(int value)
2723 if(value >= 0) m_settings->lameChannelMode(value);
2727 * Sampling rate has changed
2729 void MainWindow::samplingRateChanged(int value)
2731 if(value >= 0) m_settings->samplingRate(value);
2735 * Nero AAC 2-Pass mode changed
2737 void MainWindow::neroAAC2PassChanged(bool checked)
2739 m_settings->neroAACEnable2Pass(checked);
2743 * Nero AAC profile mode changed
2745 void MainWindow::neroAACProfileChanged(int value)
2747 if(value >= 0) m_settings->aacEncProfile(value);
2751 * Aften audio coding mode changed
2753 void MainWindow::aftenCodingModeChanged(int value)
2755 if(value >= 0) m_settings->aftenAudioCodingMode(value);
2759 * Aften DRC mode changed
2761 void MainWindow::aftenDRCModeChanged(int value)
2763 if(value >= 0) m_settings->aftenDynamicRangeCompression(value);
2767 * Aften exponent search size changed
2769 void MainWindow::aftenSearchSizeChanged(int value)
2771 if(value >= 0) m_settings->aftenExponentSearchSize(value);
2775 * Aften fast bit allocation changed
2777 void MainWindow::aftenFastAllocationChanged(bool checked)
2779 m_settings->aftenFastBitAllocation(checked);
2783 * Normalization filter enabled changed
2785 void MainWindow::normalizationEnabledChanged(bool checked)
2787 m_settings->normalizationFilterEnabled(checked);
2791 * Normalization max. volume changed
2793 void MainWindow::normalizationMaxVolumeChanged(double value)
2795 m_settings->normalizationFilterMaxVolume(static_cast<int>(value * 100.0));
2799 * Normalization equalization mode changed
2801 void MainWindow::normalizationModeChanged(int mode)
2803 m_settings->normalizationFilterEqualizationMode(mode);
2807 * Tone adjustment has changed (Bass)
2809 void MainWindow::toneAdjustBassChanged(double value)
2811 m_settings->toneAdjustBass(static_cast<int>(value * 100.0));
2812 spinBoxToneAdjustBass->setPrefix((value > 0) ? "+" : QString());
2816 * Tone adjustment has changed (Treble)
2818 void MainWindow::toneAdjustTrebleChanged(double value)
2820 m_settings->toneAdjustTreble(static_cast<int>(value * 100.0));
2821 spinBoxToneAdjustTreble->setPrefix((value > 0) ? "+" : QString());
2825 * Tone adjustment has been reset
2827 void MainWindow::toneAdjustTrebleReset(void)
2829 spinBoxToneAdjustBass->setValue(m_settings->toneAdjustBassDefault());
2830 spinBoxToneAdjustTreble->setValue(m_settings->toneAdjustTrebleDefault());
2831 toneAdjustBassChanged(spinBoxToneAdjustBass->value());
2832 toneAdjustTrebleChanged(spinBoxToneAdjustTreble->value());
2836 * Custom encoder parameters changed
2838 void MainWindow::customParamsChanged(void)
2840 lineEditCustomParamLAME->setText(lineEditCustomParamLAME->text().simplified());
2841 lineEditCustomParamOggEnc->setText(lineEditCustomParamOggEnc->text().simplified());
2842 lineEditCustomParamNeroAAC->setText(lineEditCustomParamNeroAAC->text().simplified());
2843 lineEditCustomParamFLAC->setText(lineEditCustomParamFLAC->text().simplified());
2844 lineEditCustomParamAften->setText(lineEditCustomParamAften->text().simplified());
2846 bool customParamsUsed = false;
2847 if(!lineEditCustomParamLAME->text().isEmpty()) customParamsUsed = true;
2848 if(!lineEditCustomParamOggEnc->text().isEmpty()) customParamsUsed = true;
2849 if(!lineEditCustomParamNeroAAC->text().isEmpty()) customParamsUsed = true;
2850 if(!lineEditCustomParamFLAC->text().isEmpty()) customParamsUsed = true;
2851 if(!lineEditCustomParamAften->text().isEmpty()) customParamsUsed = true;
2853 labelCustomParamsIcon->setVisible(customParamsUsed);
2854 labelCustomParamsText->setVisible(customParamsUsed);
2855 labelCustomParamsSpacer->setVisible(customParamsUsed);
2857 m_settings->customParametersLAME(lineEditCustomParamLAME->text());
2858 m_settings->customParametersOggEnc(lineEditCustomParamOggEnc->text());
2859 m_settings->customParametersAacEnc(lineEditCustomParamNeroAAC->text());
2860 m_settings->customParametersFLAC(lineEditCustomParamFLAC->text());
2861 m_settings->customParametersAften(lineEditCustomParamAften->text());
2866 * Rename output files enabled changed
2868 void MainWindow::renameOutputEnabledChanged(bool checked)
2870 m_settings->renameOutputFilesEnabled(checked);
2874 * Rename output files patterm changed
2876 void MainWindow::renameOutputPatternChanged(void)
2878 QString temp = lineEditRenamePattern->text().simplified();
2879 lineEditRenamePattern->setText(temp.isEmpty() ? m_settings->renameOutputFilesPatternDefault() : temp);
2880 m_settings->renameOutputFilesPattern(lineEditRenamePattern->text());
2884 * Rename output files patterm changed
2886 void MainWindow::renameOutputPatternChanged(const QString &text)
2888 QString pattern(text.simplified());
2890 pattern.replace("<BaseName>", "The_White_Stripes_-_Fell_In_Love_With_A_Girl", Qt::CaseInsensitive);
2891 pattern.replace("<TrackNo>", "04", Qt::CaseInsensitive);
2892 pattern.replace("<Title>", "Fell In Love With A Girl", Qt::CaseInsensitive);
2893 pattern.replace("<Artist>", "The White Stripes", Qt::CaseInsensitive);
2894 pattern.replace("<Album>", "White Blood Cells", Qt::CaseInsensitive);
2895 pattern.replace("<Year>", "2001", Qt::CaseInsensitive);
2896 pattern.replace("<Comment>", "Encoded by LameXP", Qt::CaseInsensitive);
2898 if(pattern.compare(lamexp_clean_filename(pattern)))
2900 if(lineEditRenamePattern->palette().color(QPalette::Text) != Qt::red)
2902 MessageBeep(MB_ICONERROR);
2903 SET_TEXT_COLOR(lineEditRenamePattern, Qt::red);
2906 else
2908 if(lineEditRenamePattern->palette().color(QPalette::Text) != Qt::black)
2910 MessageBeep(MB_ICONINFORMATION);
2911 SET_TEXT_COLOR(lineEditRenamePattern, Qt::black);
2915 labelRanameExample->setText(lamexp_clean_filename(pattern));
2919 * Show list of rename macros
2921 void MainWindow::showRenameMacros(const QString &text)
2923 if(text.compare("reset", Qt::CaseInsensitive) == 0)
2925 lineEditRenamePattern->setText(m_settings->renameOutputFilesPatternDefault());
2926 return;
2929 const QString format = QString("<tr><td><tt>&lt;%1&gt;</tt></td><td>&nbsp;&nbsp;</td><td>%2</td></tr>");
2931 QString message = QString("<table>");
2932 message += QString(format).arg("BaseName", tr("File name without extension"));
2933 message += QString(format).arg("TrackNo", tr("Track number with leading zero"));
2934 message += QString(format).arg("Title", tr("Track title"));
2935 message += QString(format).arg("Artist", tr("Artist name"));
2936 message += QString(format).arg("Album", tr("Album name"));
2937 message += QString(format).arg("Year", tr("Year with (at least) four digits"));
2938 message += QString(format).arg("Comment", tr("Comment"));
2939 message += "</table><br><br>";
2940 message += QString("%1<br>").arg(tr("Characters forbidden in file names:"));
2941 message += "<b><tt>\\ / : * ? &lt; &gt; |<br>";
2943 QMessageBox::information(this, tr("Rename Macros"), message, tr("Discard"));
2946 void MainWindow::forceStereoDownmixEnabledChanged(bool checked)
2948 m_settings->forceStereoDownmix(checked);
2952 * Maximum number of instances changed
2954 void MainWindow::updateMaximumInstances(int value)
2956 labelMaxInstances->setText(tr("%1 Instance(s)").arg(QString::number(value)));
2957 m_settings->maximumInstances(checkBoxAutoDetectInstances->isChecked() ? NULL : value);
2961 * Auto-detect number of instances
2963 void MainWindow::autoDetectInstancesChanged(bool checked)
2965 m_settings->maximumInstances(checked ? NULL : sliderMaxInstances->value());
2969 * Browse for custom TEMP folder button clicked
2971 void MainWindow::browseCustomTempFolderButtonClicked(void)
2973 QString newTempFolder;
2975 if(USE_NATIVE_FILE_DIALOG)
2977 newTempFolder = QFileDialog::getExistingDirectory(this, QString(), m_settings->customTempPath());
2979 else
2981 QFileDialog dialog(this);
2982 dialog.setFileMode(QFileDialog::DirectoryOnly);
2983 dialog.setDirectory(m_settings->customTempPath());
2984 if(dialog.exec())
2986 newTempFolder = dialog.selectedFiles().first();
2990 if(!newTempFolder.isEmpty())
2992 QFile writeTest(QString("%1/~%2.tmp").arg(newTempFolder, lamexp_rand_str()));
2993 if(writeTest.open(QIODevice::ReadWrite))
2995 writeTest.remove();
2996 lineEditCustomTempFolder->setText(QDir::toNativeSeparators(newTempFolder));
2998 else
3000 QMessageBox::warning(this, tr("Access Denied"), tr("Cannot write to the selected directory. Please choose another directory!"));
3006 * Custom TEMP folder changed
3008 void MainWindow::customTempFolderChanged(const QString &text)
3010 m_settings->customTempPath(QDir::fromNativeSeparators(text));
3014 * Use custom TEMP folder option changed
3016 void MainWindow::useCustomTempFolderChanged(bool checked)
3018 m_settings->customTempPathEnabled(!checked);
3022 * Reset all advanced options to their defaults
3024 void MainWindow::resetAdvancedOptionsButtonClicked(void)
3026 sliderLameAlgoQuality->setValue(m_settings->lameAlgoQualityDefault());
3027 spinBoxBitrateManagementMin->setValue(m_settings->bitrateManagementMinRateDefault());
3028 spinBoxBitrateManagementMax->setValue(m_settings->bitrateManagementMaxRateDefault());
3029 spinBoxNormalizationFilter->setValue(static_cast<double>(m_settings->normalizationFilterMaxVolumeDefault()) / 100.0);
3030 spinBoxToneAdjustBass->setValue(static_cast<double>(m_settings->toneAdjustBassDefault()) / 100.0);
3031 spinBoxToneAdjustTreble->setValue(static_cast<double>(m_settings->toneAdjustTrebleDefault()) / 100.0);
3032 spinBoxAftenSearchSize->setValue(m_settings->aftenExponentSearchSizeDefault());
3033 comboBoxMP3ChannelMode->setCurrentIndex(m_settings->lameChannelModeDefault());
3034 comboBoxSamplingRate->setCurrentIndex(m_settings->samplingRateDefault());
3035 comboBoxAACProfile->setCurrentIndex(m_settings->aacEncProfileDefault());
3036 comboBoxAftenCodingMode->setCurrentIndex(m_settings->aftenAudioCodingModeDefault());
3037 comboBoxAftenDRCMode->setCurrentIndex(m_settings->aftenDynamicRangeCompressionDefault());
3038 comboBoxNormalizationMode->setCurrentIndex(m_settings->normalizationFilterEqualizationModeDefault());
3039 while(checkBoxBitrateManagement->isChecked() != m_settings->bitrateManagementEnabledDefault()) checkBoxBitrateManagement->click();
3040 while(checkBoxNeroAAC2PassMode->isChecked() != m_settings->neroAACEnable2PassDefault()) checkBoxNeroAAC2PassMode->click();
3041 while(checkBoxNormalizationFilter->isChecked() != m_settings->normalizationFilterEnabledDefault()) checkBoxNormalizationFilter->click();
3042 while(checkBoxAutoDetectInstances->isChecked() != (m_settings->maximumInstancesDefault() < 1)) checkBoxAutoDetectInstances->click();
3043 while(checkBoxUseSystemTempFolder->isChecked() == m_settings->customTempPathEnabledDefault()) checkBoxUseSystemTempFolder->click();
3044 while(checkBoxAftenFastAllocation->isChecked() != m_settings->aftenFastBitAllocationDefault()) checkBoxAftenFastAllocation->click();
3045 while(checkBoxRenameOutput->isChecked() != m_settings->renameOutputFilesEnabledDefault()) checkBoxRenameOutput->click();
3046 while(checkBoxForceStereoDownmix->isChecked() != m_settings->forceStereoDownmixDefault()) checkBoxForceStereoDownmix->click();
3047 lineEditCustomParamLAME->setText(m_settings->customParametersLAMEDefault());
3048 lineEditCustomParamOggEnc->setText(m_settings->customParametersOggEncDefault());
3049 lineEditCustomParamNeroAAC->setText(m_settings->customParametersAacEncDefault());
3050 lineEditCustomParamFLAC->setText(m_settings->customParametersFLACDefault());
3051 lineEditCustomTempFolder->setText(QDir::toNativeSeparators(m_settings->customTempPathDefault()));
3052 lineEditRenamePattern->setText(m_settings->renameOutputFilesPatternDefault());
3053 customParamsChanged();
3054 scrollArea->verticalScrollBar()->setValue(0);
3057 // =========================================================
3058 // Multi-instance handling slots
3059 // =========================================================
3062 * Other instance detected
3064 void MainWindow::notifyOtherInstance(void)
3066 if(!m_banner->isVisible())
3068 QMessageBox msgBox(QMessageBox::Warning, tr("Already Running"), tr("LameXP is already running, please use the running instance!"), QMessageBox::NoButton, this, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowStaysOnTopHint);
3069 msgBox.exec();
3074 * Add file from another instance
3076 void MainWindow::addFileDelayed(const QString &filePath, bool tryASAP)
3078 if(tryASAP && !m_delayedFileTimer->isActive())
3080 qDebug("Received file: %s", filePath.toUtf8().constData());
3081 m_delayedFileList->append(filePath);
3082 QTimer::singleShot(0, this, SLOT(handleDelayedFiles()));
3085 m_delayedFileTimer->stop();
3086 qDebug("Received file: %s", filePath.toUtf8().constData());
3087 m_delayedFileList->append(filePath);
3088 m_delayedFileTimer->start(5000);
3092 * Add files from another instance
3094 void MainWindow::addFilesDelayed(const QStringList &filePaths, bool tryASAP)
3096 if(tryASAP && !m_delayedFileTimer->isActive())
3098 qDebug("Received %d file(s).", filePaths.count());
3099 m_delayedFileList->append(filePaths);
3100 QTimer::singleShot(0, this, SLOT(handleDelayedFiles()));
3102 else
3104 m_delayedFileTimer->stop();
3105 qDebug("Received %d file(s).", filePaths.count());
3106 m_delayedFileList->append(filePaths);
3107 m_delayedFileTimer->start(5000);
3112 * Add folder from another instance
3114 void MainWindow::addFolderDelayed(const QString &folderPath, bool recursive)
3116 if(!m_banner->isVisible())
3118 addFolder(folderPath, recursive, true);
3122 // =========================================================
3123 // Misc slots
3124 // =========================================================
3127 * Restore the override cursor
3129 void MainWindow::restoreCursor(void)
3131 QApplication::restoreOverrideCursor();