1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
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.
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"
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_FileAnalyzer_ST.h"
35 #include "Thread_MessageHandler.h"
36 #include "Model_MetaInfo.h"
37 #include "Model_Settings.h"
38 #include "Model_FileList.h"
39 #include "Model_FileSystem.h"
40 #include "WinSevenTaskbar.h"
41 #include "Registry_Decoder.h"
42 #include "ShellIntegration.h"
45 #include <QMessageBox>
47 #include <QDesktopWidget>
49 #include <QFileDialog>
50 #include <QInputDialog>
51 #include <QFileSystemModel>
52 #include <QDesktopServices>
54 #include <QPlastiqueStyle>
55 #include <QCleanlooksStyle>
56 #include <QWindowsVistaStyle>
57 #include <QWindowsStyle>
59 #include <QDragEnterEvent>
63 #include <QProcessEnvironment>
64 #include <QCryptographicHash>
65 #include <QTranslator>
74 #define ABORT_IF_BUSY if(m_banner->isVisible() || m_delayedFileTimer->isActive()) { MessageBeep(MB_ICONEXCLAMATION); return; }
75 #define SET_TEXT_COLOR(WIDGET,COLOR) { QPalette _palette = WIDGET->palette(); _palette.setColor(QPalette::WindowText, (COLOR)); _palette.setColor(QPalette::Text, (COLOR)); WIDGET->setPalette(_palette); }
76 #define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); }
77 #define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(QString(URL).replace("-", "−"))
78 #define FSLINK(PATH) QString("<a href=\"file:///%1\">%2</a>").arg(PATH).arg(QString(PATH).replace("-", "−"))
79 #define TEMP_HIDE_DROPBOX(CMD) { bool __dropBoxVisible = m_dropBox->isVisible(); if(__dropBoxVisible) m_dropBox->hide(); {CMD}; if(__dropBoxVisible) m_dropBox->show(); }
80 #define USE_NATIVE_FILE_DIALOG (lamexp_themes_enabled() || ((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) < QSysInfo::WV_XP))
81 #define CENTER_CURRENT_OUTPUT_FOLDER_DELAYED QTimer::singleShot(125, this, SLOT(centerOutputFolderModel()))
82 #define SET_MODEL(VIEW, MODEL) { QItemSelectionModel *_tmp = (VIEW)->selectionModel(); (VIEW)->setModel(MODEL); LAMEXP_DELETE(_tmp); }
84 ////////////////////////////////////////////////////////////
86 ////////////////////////////////////////////////////////////
88 MainWindow::MainWindow(FileListModel
*fileListModel
, AudioFileModel
*metaInfo
, SettingsModel
*settingsModel
, QWidget
*parent
)
91 m_fileListModel(fileListModel
),
93 m_settings(settingsModel
),
94 m_fileSystemModel(NULL
),
95 m_neroEncoderAvailable(lamexp_check_tool("neroAacEnc.exe") && lamexp_check_tool("neroAacDec.exe") && lamexp_check_tool("neroAacTag.exe")),
96 m_fhgEncoderAvailable(lamexp_check_tool("fhgaacenc.exe") && lamexp_check_tool("enc_fhgaac.dll") && lamexp_check_tool("nsutil.dll") && lamexp_check_tool("libmp4v2.dll")),
97 m_qaacEncoderAvailable(lamexp_check_tool("qaac.exe") && lamexp_check_tool("libsoxrate.dll")),
99 m_firstTimeShown(true),
100 m_outputFolderViewCentering(false),
101 m_outputFolderViewInitCounter(0)
103 //Init the dialog, from the .ui file
105 setWindowFlags(windowFlags() ^ Qt::WindowMaximizeButtonHint
);
107 //Register meta types
108 qRegisterMetaType
<AudioFileModel
>("AudioFileModel");
110 //Enabled main buttons
111 connect(buttonAbout
, SIGNAL(clicked()), this, SLOT(aboutButtonClicked()));
112 connect(buttonStart
, SIGNAL(clicked()), this, SLOT(encodeButtonClicked()));
113 connect(buttonQuit
, SIGNAL(clicked()), this, SLOT(closeButtonClicked()));
116 tabWidget
->setCurrentIndex(0);
117 connect(tabWidget
, SIGNAL(currentChanged(int)), this, SLOT(tabPageChanged(int)));
120 sourceFileView
->setModel(m_fileListModel
);
121 sourceFileView
->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents
);
122 sourceFileView
->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents
);
123 sourceFileView
->setContextMenuPolicy(Qt::CustomContextMenu
);
124 sourceFileView
->viewport()->installEventFilter(this);
125 m_dropNoteLabel
= new QLabel(sourceFileView
);
126 m_dropNoteLabel
->setAlignment(Qt::AlignHCenter
| Qt::AlignVCenter
);
127 SET_FONT_BOLD(m_dropNoteLabel
, true);
128 SET_TEXT_COLOR(m_dropNoteLabel
, Qt::darkGray
);
129 m_sourceFilesContextMenu
= new QMenu();
130 m_showDetailsContextAction
= m_sourceFilesContextMenu
->addAction(QIcon(":/icons/zoom.png"), "N/A");
131 m_previewContextAction
= m_sourceFilesContextMenu
->addAction(QIcon(":/icons/sound.png"), "N/A");
132 m_findFileContextAction
= m_sourceFilesContextMenu
->addAction(QIcon(":/icons/folder_go.png"), "N/A");
133 m_sourceFilesContextMenu
->addSeparator();
134 m_exportCsvContextAction
= m_sourceFilesContextMenu
->addAction(QIcon(":/icons/table_save.png"), "N/A");
135 m_importCsvContextAction
= m_sourceFilesContextMenu
->addAction(QIcon(":/icons/folder_table.png"), "N/A");
136 SET_FONT_BOLD(m_showDetailsContextAction
, true);
137 connect(buttonAddFiles
, SIGNAL(clicked()), this, SLOT(addFilesButtonClicked()));
138 connect(buttonRemoveFile
, SIGNAL(clicked()), this, SLOT(removeFileButtonClicked()));
139 connect(buttonClearFiles
, SIGNAL(clicked()), this, SLOT(clearFilesButtonClicked()));
140 connect(buttonFileUp
, SIGNAL(clicked()), this, SLOT(fileUpButtonClicked()));
141 connect(buttonFileDown
, SIGNAL(clicked()), this, SLOT(fileDownButtonClicked()));
142 connect(buttonShowDetails
, SIGNAL(clicked()), this, SLOT(showDetailsButtonClicked()));
143 connect(m_fileListModel
, SIGNAL(rowsInserted(QModelIndex
,int,int)), this, SLOT(sourceModelChanged()));
144 connect(m_fileListModel
, SIGNAL(rowsRemoved(QModelIndex
,int,int)), this, SLOT(sourceModelChanged()));
145 connect(m_fileListModel
, SIGNAL(modelReset()), this, SLOT(sourceModelChanged()));
146 connect(sourceFileView
, SIGNAL(customContextMenuRequested(QPoint
)), this, SLOT(sourceFilesContextMenu(QPoint
)));
147 connect(sourceFileView
->verticalScrollBar(), SIGNAL(sliderMoved(int)), this, SLOT(sourceFilesScrollbarMoved(int)));
148 connect(sourceFileView
->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(sourceFilesScrollbarMoved(int)));
149 connect(m_showDetailsContextAction
, SIGNAL(triggered(bool)), this, SLOT(showDetailsButtonClicked()));
150 connect(m_previewContextAction
, SIGNAL(triggered(bool)), this, SLOT(previewContextActionTriggered()));
151 connect(m_findFileContextAction
, SIGNAL(triggered(bool)), this, SLOT(findFileContextActionTriggered()));
152 connect(m_exportCsvContextAction
, SIGNAL(triggered(bool)), this, SLOT(exportCsvContextActionTriggered()));
153 connect(m_importCsvContextAction
, SIGNAL(triggered(bool)), this, SLOT(importCsvContextActionTriggered()));
156 outputFolderView
->setHeaderHidden(true);
157 outputFolderView
->setAnimated(false);
158 outputFolderView
->setMouseTracking(false);
159 outputFolderView
->setContextMenuPolicy(Qt::CustomContextMenu
);
160 outputFolderView
->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn
);
161 outputFolderView
->installEventFilter(this);
162 outputFoldersEditorLabel
->installEventFilter(this);
163 outputFoldersFovoritesLabel
->installEventFilter(this);
164 while(saveToSourceFolderCheckBox
->isChecked() != m_settings
->outputToSourceDir()) saveToSourceFolderCheckBox
->click();
165 prependRelativePathCheckBox
->setChecked(m_settings
->prependRelativeSourcePath());
166 connect(outputFolderView
, SIGNAL(clicked(QModelIndex
)), this, SLOT(outputFolderViewClicked(QModelIndex
)));
167 connect(outputFolderView
, SIGNAL(activated(QModelIndex
)), this, SLOT(outputFolderViewClicked(QModelIndex
)));
168 connect(outputFolderView
, SIGNAL(pressed(QModelIndex
)), this, SLOT(outputFolderViewClicked(QModelIndex
)));
169 connect(outputFolderView
, SIGNAL(entered(QModelIndex
)), this, SLOT(outputFolderViewMoved(QModelIndex
)));
170 connect(outputFolderView
, SIGNAL(expanded(QModelIndex
)), this, SLOT(outputFolderItemExpanded(QModelIndex
)));
171 connect(buttonMakeFolder
, SIGNAL(clicked()), this, SLOT(makeFolderButtonClicked()));
172 connect(buttonGotoHome
, SIGNAL(clicked()), SLOT(gotoHomeFolderButtonClicked()));
173 connect(buttonGotoDesktop
, SIGNAL(clicked()), this, SLOT(gotoDesktopButtonClicked()));
174 connect(buttonGotoMusic
, SIGNAL(clicked()), this, SLOT(gotoMusicFolderButtonClicked()));
175 connect(saveToSourceFolderCheckBox
, SIGNAL(clicked()), this, SLOT(saveToSourceFolderChanged()));
176 connect(prependRelativePathCheckBox
, SIGNAL(clicked()), this, SLOT(prependRelativePathChanged()));
177 connect(outputFolderEdit
, SIGNAL(editingFinished()), this, SLOT(outputFolderEditFinished()));
178 if(m_outputFolderContextMenu
= new QMenu())
180 m_showFolderContextAction
= m_outputFolderContextMenu
->addAction(QIcon(":/icons/zoom.png"), "N/A");
181 m_refreshFolderContextAction
= m_outputFolderContextMenu
->addAction(QIcon(":/icons/arrow_refresh.png"), "N/A");
182 m_outputFolderContextMenu
->setDefaultAction(m_showFolderContextAction
);
183 connect(outputFolderView
, SIGNAL(customContextMenuRequested(QPoint
)), this, SLOT(outputFolderContextMenu(QPoint
)));
184 connect(m_showFolderContextAction
, SIGNAL(triggered(bool)), this, SLOT(showFolderContextActionTriggered()));
185 connect(m_refreshFolderContextAction
, SIGNAL(triggered(bool)), this, SLOT(refreshFolderContextActionTriggered()));
187 if(m_outputFolderFavoritesMenu
= new QMenu())
189 m_addFavoriteFolderAction
= m_outputFolderFavoritesMenu
->addAction(QIcon(":/icons/add.png"), "N/A");
190 m_outputFolderFavoritesMenu
->insertSeparator(m_addFavoriteFolderAction
);
191 connect(m_addFavoriteFolderAction
, SIGNAL(triggered(bool)), this, SLOT(addFavoriteFolderActionTriggered()));
193 outputFolderEdit
->setVisible(false);
194 outputFolderLabel
->installEventFilter(this);
195 if(m_outputFolderNoteBox
= new QLabel(outputFolderView
))
197 m_outputFolderNoteBox
->setAutoFillBackground(true);
198 m_outputFolderNoteBox
->setAlignment(Qt::AlignHCenter
| Qt::AlignVCenter
);
199 m_outputFolderNoteBox
->setFrameShape(QFrame::StyledPanel
);
200 SET_FONT_BOLD(m_outputFolderNoteBox
, true);
201 m_outputFolderNoteBox
->hide();
204 outputFolderViewClicked(QModelIndex());
207 //Setup "Meta Data" tab
208 m_metaInfoModel
= new MetaInfoModel(m_metaData
, 6);
209 m_metaInfoModel
->clearData();
210 m_metaInfoModel
->setData(m_metaInfoModel
->index(4, 1), m_settings
->metaInfoPosition());
211 metaDataView
->setModel(m_metaInfoModel
);
212 metaDataView
->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents
);
213 metaDataView
->verticalHeader()->hide();
214 metaDataView
->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents
);
215 while(writeMetaDataCheckBox
->isChecked() != m_settings
->writeMetaTags()) writeMetaDataCheckBox
->click();
216 generatePlaylistCheckBox
->setChecked(m_settings
->createPlaylist());
217 connect(buttonEditMeta
, SIGNAL(clicked()), this, SLOT(editMetaButtonClicked()));
218 connect(buttonClearMeta
, SIGNAL(clicked()), this, SLOT(clearMetaButtonClicked()));
219 connect(writeMetaDataCheckBox
, SIGNAL(clicked()), this, SLOT(metaTagsEnabledChanged()));
220 connect(generatePlaylistCheckBox
, SIGNAL(clicked()), this, SLOT(playlistEnabledChanged()));
222 //Setup "Compression" tab
223 m_encoderButtonGroup
= new QButtonGroup(this);
224 m_encoderButtonGroup
->addButton(radioButtonEncoderMP3
, SettingsModel::MP3Encoder
);
225 m_encoderButtonGroup
->addButton(radioButtonEncoderVorbis
, SettingsModel::VorbisEncoder
);
226 m_encoderButtonGroup
->addButton(radioButtonEncoderAAC
, SettingsModel::AACEncoder
);
227 m_encoderButtonGroup
->addButton(radioButtonEncoderAC3
, SettingsModel::AC3Encoder
);
228 m_encoderButtonGroup
->addButton(radioButtonEncoderFLAC
, SettingsModel::FLACEncoder
);
229 m_encoderButtonGroup
->addButton(radioButtonEncoderOpus
, SettingsModel::OpusEncoder
);
230 m_encoderButtonGroup
->addButton(radioButtonEncoderDCA
, SettingsModel::DCAEncoder
);
231 m_encoderButtonGroup
->addButton(radioButtonEncoderPCM
, SettingsModel::PCMEncoder
);
232 m_modeButtonGroup
= new QButtonGroup(this);
233 m_modeButtonGroup
->addButton(radioButtonModeQuality
, SettingsModel::VBRMode
);
234 m_modeButtonGroup
->addButton(radioButtonModeAverageBitrate
, SettingsModel::ABRMode
);
235 m_modeButtonGroup
->addButton(radioButtonConstBitrate
, SettingsModel::CBRMode
);
236 radioButtonEncoderAAC
->setEnabled(m_neroEncoderAvailable
|| m_fhgEncoderAvailable
|| m_qaacEncoderAvailable
);
237 radioButtonEncoderMP3
->setChecked(m_settings
->compressionEncoder() == SettingsModel::MP3Encoder
);
238 radioButtonEncoderVorbis
->setChecked(m_settings
->compressionEncoder() == SettingsModel::VorbisEncoder
);
239 radioButtonEncoderAAC
->setChecked((m_settings
->compressionEncoder() == SettingsModel::AACEncoder
) && (m_neroEncoderAvailable
|| m_fhgEncoderAvailable
|| m_qaacEncoderAvailable
));
240 radioButtonEncoderAC3
->setChecked(m_settings
->compressionEncoder() == SettingsModel::AC3Encoder
);
241 radioButtonEncoderFLAC
->setChecked(m_settings
->compressionEncoder() == SettingsModel::FLACEncoder
);
242 radioButtonEncoderOpus
->setChecked(m_settings
->compressionEncoder() == SettingsModel::OpusEncoder
);
243 radioButtonEncoderDCA
->setChecked(m_settings
->compressionEncoder() == SettingsModel::DCAEncoder
);
244 radioButtonEncoderPCM
->setChecked(m_settings
->compressionEncoder() == SettingsModel::PCMEncoder
);
245 radioButtonModeQuality
->setChecked(m_settings
->compressionRCMode() == SettingsModel::VBRMode
);
246 radioButtonModeAverageBitrate
->setChecked(m_settings
->compressionRCMode() == SettingsModel::ABRMode
);
247 radioButtonConstBitrate
->setChecked(m_settings
->compressionRCMode() == SettingsModel::CBRMode
);
248 sliderBitrate
->setValue(m_settings
->compressionBitrate());
249 connect(m_encoderButtonGroup
, SIGNAL(buttonClicked(int)), this, SLOT(updateEncoder(int)));
250 connect(m_modeButtonGroup
, SIGNAL(buttonClicked(int)), this, SLOT(updateRCMode(int)));
251 connect(sliderBitrate
, SIGNAL(valueChanged(int)), this, SLOT(updateBitrate(int)));
252 updateEncoder(m_encoderButtonGroup
->checkedId());
254 //Setup "Advanced Options" tab
255 sliderLameAlgoQuality
->setValue(m_settings
->lameAlgoQuality());
256 if(m_settings
->maximumInstances() > 0) sliderMaxInstances
->setValue(m_settings
->maximumInstances());
257 spinBoxBitrateManagementMin
->setValue(m_settings
->bitrateManagementMinRate());
258 spinBoxBitrateManagementMax
->setValue(m_settings
->bitrateManagementMaxRate());
259 spinBoxNormalizationFilter
->setValue(static_cast<double>(m_settings
->normalizationFilterMaxVolume()) / 100.0);
260 spinBoxToneAdjustBass
->setValue(static_cast<double>(m_settings
->toneAdjustBass()) / 100.0);
261 spinBoxToneAdjustTreble
->setValue(static_cast<double>(m_settings
->toneAdjustTreble()) / 100.0);
262 spinBoxAftenSearchSize
->setValue(m_settings
->aftenExponentSearchSize());
263 spinBoxOpusComplexity
->setValue(m_settings
->opusComplexity());
264 comboBoxMP3ChannelMode
->setCurrentIndex(m_settings
->lameChannelMode());
265 comboBoxSamplingRate
->setCurrentIndex(m_settings
->samplingRate());
266 comboBoxAACProfile
->setCurrentIndex(m_settings
->aacEncProfile());
267 comboBoxAftenCodingMode
->setCurrentIndex(m_settings
->aftenAudioCodingMode());
268 comboBoxAftenDRCMode
->setCurrentIndex(m_settings
->aftenDynamicRangeCompression());
269 comboBoxNormalizationMode
->setCurrentIndex(m_settings
->normalizationFilterEqualizationMode());
270 comboBoxOpusOptimize
->setCurrentIndex(m_settings
->opusOptimizeFor());
271 comboBoxOpusFramesize
->setCurrentIndex(m_settings
->opusFramesize());
272 while(checkBoxBitrateManagement
->isChecked() != m_settings
->bitrateManagementEnabled()) checkBoxBitrateManagement
->click();
273 while(checkBoxNeroAAC2PassMode
->isChecked() != m_settings
->neroAACEnable2Pass()) checkBoxNeroAAC2PassMode
->click();
274 while(checkBoxAftenFastAllocation
->isChecked() != m_settings
->aftenFastBitAllocation()) checkBoxAftenFastAllocation
->click();
275 while(checkBoxNormalizationFilter
->isChecked() != m_settings
->normalizationFilterEnabled()) checkBoxNormalizationFilter
->click();
276 while(checkBoxAutoDetectInstances
->isChecked() != (m_settings
->maximumInstances() < 1)) checkBoxAutoDetectInstances
->click();
277 while(checkBoxUseSystemTempFolder
->isChecked() == m_settings
->customTempPathEnabled()) checkBoxUseSystemTempFolder
->click();
278 while(checkBoxRenameOutput
->isChecked() != m_settings
->renameOutputFilesEnabled()) checkBoxRenameOutput
->click();
279 while(checkBoxForceStereoDownmix
->isChecked() != m_settings
->forceStereoDownmix()) checkBoxForceStereoDownmix
->click();
280 checkBoxNeroAAC2PassMode
->setEnabled(!(m_fhgEncoderAvailable
|| m_qaacEncoderAvailable
));
281 lineEditCustomParamLAME
->setText(m_settings
->customParametersLAME());
282 lineEditCustomParamOggEnc
->setText(m_settings
->customParametersOggEnc());
283 lineEditCustomParamNeroAAC
->setText(m_settings
->customParametersAacEnc());
284 lineEditCustomParamFLAC
->setText(m_settings
->customParametersFLAC());
285 lineEditCustomParamAften
->setText(m_settings
->customParametersAften());
286 lineEditCustomTempFolder
->setText(QDir::toNativeSeparators(m_settings
->customTempPath()));
287 lineEditRenamePattern
->setText(m_settings
->renameOutputFilesPattern());
288 connect(sliderLameAlgoQuality
, SIGNAL(valueChanged(int)), this, SLOT(updateLameAlgoQuality(int)));
289 connect(checkBoxBitrateManagement
, SIGNAL(clicked(bool)), this, SLOT(bitrateManagementEnabledChanged(bool)));
290 connect(spinBoxBitrateManagementMin
, SIGNAL(valueChanged(int)), this, SLOT(bitrateManagementMinChanged(int)));
291 connect(spinBoxBitrateManagementMax
, SIGNAL(valueChanged(int)), this, SLOT(bitrateManagementMaxChanged(int)));
292 connect(comboBoxMP3ChannelMode
, SIGNAL(currentIndexChanged(int)), this, SLOT(channelModeChanged(int)));
293 connect(comboBoxSamplingRate
, SIGNAL(currentIndexChanged(int)), this, SLOT(samplingRateChanged(int)));
294 connect(checkBoxNeroAAC2PassMode
, SIGNAL(clicked(bool)), this, SLOT(neroAAC2PassChanged(bool)));
295 connect(comboBoxAACProfile
, SIGNAL(currentIndexChanged(int)), this, SLOT(neroAACProfileChanged(int)));
296 connect(checkBoxNormalizationFilter
, SIGNAL(clicked(bool)), this, SLOT(normalizationEnabledChanged(bool)));
297 connect(comboBoxAftenCodingMode
, SIGNAL(currentIndexChanged(int)), this, SLOT(aftenCodingModeChanged(int)));
298 connect(comboBoxAftenDRCMode
, SIGNAL(currentIndexChanged(int)), this, SLOT(aftenDRCModeChanged(int)));
299 connect(spinBoxAftenSearchSize
, SIGNAL(valueChanged(int)), this, SLOT(aftenSearchSizeChanged(int)));
300 connect(checkBoxAftenFastAllocation
, SIGNAL(clicked(bool)), this, SLOT(aftenFastAllocationChanged(bool)));
301 connect(spinBoxNormalizationFilter
, SIGNAL(valueChanged(double)), this, SLOT(normalizationMaxVolumeChanged(double)));
302 connect(comboBoxNormalizationMode
, SIGNAL(currentIndexChanged(int)), this, SLOT(normalizationModeChanged(int)));
303 connect(spinBoxToneAdjustBass
, SIGNAL(valueChanged(double)), this, SLOT(toneAdjustBassChanged(double)));
304 connect(spinBoxToneAdjustTreble
, SIGNAL(valueChanged(double)), this, SLOT(toneAdjustTrebleChanged(double)));
305 connect(buttonToneAdjustReset
, SIGNAL(clicked()), this, SLOT(toneAdjustTrebleReset()));
306 connect(lineEditCustomParamLAME
, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
307 connect(lineEditCustomParamOggEnc
, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
308 connect(lineEditCustomParamNeroAAC
, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
309 connect(lineEditCustomParamFLAC
, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
310 connect(lineEditCustomParamAften
, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
311 connect(sliderMaxInstances
, SIGNAL(valueChanged(int)), this, SLOT(updateMaximumInstances(int)));
312 connect(checkBoxAutoDetectInstances
, SIGNAL(clicked(bool)), this, SLOT(autoDetectInstancesChanged(bool)));
313 connect(buttonBrowseCustomTempFolder
, SIGNAL(clicked()), this, SLOT(browseCustomTempFolderButtonClicked()));
314 connect(lineEditCustomTempFolder
, SIGNAL(textChanged(QString
)), this, SLOT(customTempFolderChanged(QString
)));
315 connect(checkBoxUseSystemTempFolder
, SIGNAL(clicked(bool)), this, SLOT(useCustomTempFolderChanged(bool)));
316 connect(buttonResetAdvancedOptions
, SIGNAL(clicked()), this, SLOT(resetAdvancedOptionsButtonClicked()));
317 connect(checkBoxRenameOutput
, SIGNAL(clicked(bool)), this, SLOT(renameOutputEnabledChanged(bool)));
318 connect(lineEditRenamePattern
, SIGNAL(editingFinished()), this, SLOT(renameOutputPatternChanged()));
319 connect(lineEditRenamePattern
, SIGNAL(textChanged(QString
)), this, SLOT(renameOutputPatternChanged(QString
)));
320 connect(labelShowRenameMacros
, SIGNAL(linkActivated(QString
)), this, SLOT(showRenameMacros(QString
)));
321 connect(checkBoxForceStereoDownmix
, SIGNAL(clicked(bool)), this, SLOT(forceStereoDownmixEnabledChanged(bool)));
322 connect(comboBoxOpusOptimize
, SIGNAL(currentIndexChanged(int)), SLOT(opusSettingsChanged()));
323 connect(comboBoxOpusFramesize
, SIGNAL(currentIndexChanged(int)), this, SLOT(opusSettingsChanged()));
324 connect(spinBoxOpusComplexity
, SIGNAL(valueChanged(int)), this, SLOT(opusSettingsChanged()));
325 updateLameAlgoQuality(sliderLameAlgoQuality
->value());
326 updateMaximumInstances(sliderMaxInstances
->value());
327 toneAdjustTrebleChanged(spinBoxToneAdjustTreble
->value());
328 toneAdjustBassChanged(spinBoxToneAdjustBass
->value());
329 customParamsChanged();
331 //Activate file menu actions
332 actionOpenFolder
->setData(QVariant::fromValue
<bool>(false));
333 actionOpenFolderRecursively
->setData(QVariant::fromValue
<bool>(true));
334 connect(actionOpenFolder
, SIGNAL(triggered()), this, SLOT(openFolderActionActivated()));
335 connect(actionOpenFolderRecursively
, SIGNAL(triggered()), this, SLOT(openFolderActionActivated()));
337 //Activate view menu actions
338 m_tabActionGroup
= new QActionGroup(this);
339 m_tabActionGroup
->addAction(actionSourceFiles
);
340 m_tabActionGroup
->addAction(actionOutputDirectory
);
341 m_tabActionGroup
->addAction(actionCompression
);
342 m_tabActionGroup
->addAction(actionMetaData
);
343 m_tabActionGroup
->addAction(actionAdvancedOptions
);
344 actionSourceFiles
->setData(0);
345 actionOutputDirectory
->setData(1);
346 actionMetaData
->setData(2);
347 actionCompression
->setData(3);
348 actionAdvancedOptions
->setData(4);
349 actionSourceFiles
->setChecked(true);
350 connect(m_tabActionGroup
, SIGNAL(triggered(QAction
*)), this, SLOT(tabActionActivated(QAction
*)));
352 //Activate style menu actions
353 m_styleActionGroup
= new QActionGroup(this);
354 m_styleActionGroup
->addAction(actionStylePlastique
);
355 m_styleActionGroup
->addAction(actionStyleCleanlooks
);
356 m_styleActionGroup
->addAction(actionStyleWindowsVista
);
357 m_styleActionGroup
->addAction(actionStyleWindowsXP
);
358 m_styleActionGroup
->addAction(actionStyleWindowsClassic
);
359 actionStylePlastique
->setData(0);
360 actionStyleCleanlooks
->setData(1);
361 actionStyleWindowsVista
->setData(2);
362 actionStyleWindowsXP
->setData(3);
363 actionStyleWindowsClassic
->setData(4);
364 actionStylePlastique
->setChecked(true);
365 actionStyleWindowsXP
->setEnabled((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based
) >= QSysInfo::WV_XP
&& lamexp_themes_enabled());
366 actionStyleWindowsVista
->setEnabled((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based
) >= QSysInfo::WV_VISTA
&& lamexp_themes_enabled());
367 connect(m_styleActionGroup
, SIGNAL(triggered(QAction
*)), this, SLOT(styleActionActivated(QAction
*)));
368 styleActionActivated(NULL
);
370 //Populate the language menu
371 m_languageActionGroup
= new QActionGroup(this);
372 QStringList translations
= lamexp_query_translations();
373 while(!translations
.isEmpty())
375 QString langId
= translations
.takeFirst();
376 QAction
*currentLanguage
= new QAction(this);
377 currentLanguage
->setData(langId
);
378 currentLanguage
->setText(lamexp_translation_name(langId
));
379 currentLanguage
->setIcon(QIcon(QString(":/flags/%1.png").arg(langId
)));
380 currentLanguage
->setCheckable(true);
381 m_languageActionGroup
->addAction(currentLanguage
);
382 menuLanguage
->insertAction(actionLoadTranslationFromFile
, currentLanguage
);
384 menuLanguage
->insertSeparator(actionLoadTranslationFromFile
);
385 connect(actionLoadTranslationFromFile
, SIGNAL(triggered(bool)), this, SLOT(languageFromFileActionActivated(bool)));
386 connect(m_languageActionGroup
, SIGNAL(triggered(QAction
*)), this, SLOT(languageActionActivated(QAction
*)));
388 //Activate tools menu actions
389 actionDisableUpdateReminder
->setChecked(!m_settings
->autoUpdateEnabled());
390 actionDisableSounds
->setChecked(!m_settings
->soundsEnabled());
391 actionDisableNeroAacNotifications
->setChecked(!m_settings
->neroAacNotificationsEnabled());
392 actionDisableSlowStartupNotifications
->setChecked(!m_settings
->antivirNotificationsEnabled());
393 actionDisableShellIntegration
->setChecked(!m_settings
->shellIntegrationEnabled());
394 actionDisableShellIntegration
->setDisabled(lamexp_portable_mode() && actionDisableShellIntegration
->isChecked());
395 actionCheckForBetaUpdates
->setChecked(m_settings
->autoUpdateCheckBeta() || lamexp_version_demo());
396 actionCheckForBetaUpdates
->setEnabled(!lamexp_version_demo());
397 actionHibernateComputer
->setChecked(m_settings
->hibernateComputer());
398 actionHibernateComputer
->setEnabled(lamexp_is_hibernation_supported());
399 connect(actionDisableUpdateReminder
, SIGNAL(triggered(bool)), this, SLOT(disableUpdateReminderActionTriggered(bool)));
400 connect(actionDisableSounds
, SIGNAL(triggered(bool)), this, SLOT(disableSoundsActionTriggered(bool)));
401 connect(actionDisableNeroAacNotifications
, SIGNAL(triggered(bool)), this, SLOT(disableNeroAacNotificationsActionTriggered(bool)));
402 connect(actionDisableSlowStartupNotifications
, SIGNAL(triggered(bool)), this, SLOT(disableSlowStartupNotificationsActionTriggered(bool)));
403 connect(actionDisableShellIntegration
, SIGNAL(triggered(bool)), this, SLOT(disableShellIntegrationActionTriggered(bool)));
404 connect(actionShowDropBoxWidget
, SIGNAL(triggered(bool)), this, SLOT(showDropBoxWidgetActionTriggered(bool)));
405 connect(actionHibernateComputer
, SIGNAL(triggered(bool)), this, SLOT(hibernateComputerActionTriggered(bool)));
406 connect(actionCheckForBetaUpdates
, SIGNAL(triggered(bool)), this, SLOT(checkForBetaUpdatesActionTriggered(bool)));
407 connect(actionImportCueSheet
, SIGNAL(triggered(bool)), this, SLOT(importCueSheetActionTriggered(bool)));
409 //Activate help menu actions
410 actionVisitHomepage
->setData(QString::fromLatin1(lamexp_website_url()));
411 actionVisitSupport
->setData(QString::fromLatin1(lamexp_support_url()));
412 actionDocumentFAQ
->setData(QString("%1/FAQ.html").arg(QApplication::applicationDirPath()));
413 actionDocumentChangelog
->setData(QString("%1/Changelog.html").arg(QApplication::applicationDirPath()));
414 actionDocumentTranslate
->setData(QString("%1/Translate.html").arg(QApplication::applicationDirPath()));
415 connect(actionCheckUpdates
, SIGNAL(triggered()), this, SLOT(checkUpdatesActionActivated()));
416 connect(actionVisitHomepage
, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated()));
417 connect(actionVisitSupport
, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated()));
418 connect(actionDocumentFAQ
, SIGNAL(triggered()), this, SLOT(documentActionActivated()));
419 connect(actionDocumentChangelog
, SIGNAL(triggered()), this, SLOT(documentActionActivated()));
420 connect(actionDocumentTranslate
, SIGNAL(triggered()), this, SLOT(documentActionActivated()));
422 //Center window in screen
423 QRect desktopRect
= QApplication::desktop()->screenGeometry();
424 QRect thisRect
= this->geometry();
425 move((desktopRect
.width() - thisRect
.width()) / 2, (desktopRect
.height() - thisRect
.height()) / 2);
426 setMinimumSize(thisRect
.width(), thisRect
.height());
429 m_banner
= new WorkingBanner(this);
431 //Create DropBox widget
432 m_dropBox
= new DropBox(this, m_fileListModel
, m_settings
);
433 connect(m_fileListModel
, SIGNAL(modelReset()), m_dropBox
, SLOT(modelChanged()));
434 connect(m_fileListModel
, SIGNAL(rowsInserted(QModelIndex
,int,int)), m_dropBox
, SLOT(modelChanged()));
435 connect(m_fileListModel
, SIGNAL(rowsRemoved(QModelIndex
,int,int)), m_dropBox
, SLOT(modelChanged()));
436 connect(m_fileListModel
, SIGNAL(rowAppended()), m_dropBox
, SLOT(modelChanged()));
438 //Create message handler thread
439 m_messageHandler
= new MessageHandlerThread();
440 m_delayedFileList
= new QStringList();
441 m_delayedFileTimer
= new QTimer();
442 m_delayedFileTimer
->setSingleShot(true);
443 m_delayedFileTimer
->setInterval(5000);
444 connect(m_messageHandler
, SIGNAL(otherInstanceDetected()), this, SLOT(notifyOtherInstance()), Qt::QueuedConnection
);
445 connect(m_messageHandler
, SIGNAL(fileReceived(QString
)), this, SLOT(addFileDelayed(QString
)), Qt::QueuedConnection
);
446 connect(m_messageHandler
, SIGNAL(folderReceived(QString
, bool)), this, SLOT(addFolderDelayed(QString
, bool)), Qt::QueuedConnection
);
447 connect(m_messageHandler
, SIGNAL(killSignalReceived()), this, SLOT(close()), Qt::QueuedConnection
);
448 connect(m_delayedFileTimer
, SIGNAL(timeout()), this, SLOT(handleDelayedFiles()));
449 m_messageHandler
->start();
451 //Load translation file
452 QList
<QAction
*> languageActions
= m_languageActionGroup
->actions();
453 while(!languageActions
.isEmpty())
455 QAction
*currentLanguage
= languageActions
.takeFirst();
456 if(currentLanguage
->data().toString().compare(m_settings
->currentLanguage(), Qt::CaseInsensitive
) == 0)
458 currentLanguage
->setChecked(true);
459 languageActionActivated(currentLanguage
);
463 //Re-translate (make sure we translate once)
464 QEvent
languageChangeEvent(QEvent::LanguageChange
);
465 changeEvent(&languageChangeEvent
);
468 this->setAcceptDrops(true);
471 ////////////////////////////////////////////////////////////
473 ////////////////////////////////////////////////////////////
475 MainWindow::~MainWindow(void)
477 //Stop message handler thread
478 if(m_messageHandler
&& m_messageHandler
->isRunning())
480 m_messageHandler
->stop();
481 if(!m_messageHandler
->wait(2500))
483 m_messageHandler
->terminate();
484 m_messageHandler
->wait();
489 SET_MODEL(sourceFileView
, NULL
);
490 SET_MODEL(outputFolderView
, NULL
);
491 SET_MODEL(metaDataView
, NULL
);
494 LAMEXP_DELETE(m_tabActionGroup
);
495 LAMEXP_DELETE(m_styleActionGroup
);
496 LAMEXP_DELETE(m_languageActionGroup
);
497 LAMEXP_DELETE(m_banner
);
498 LAMEXP_DELETE(m_fileSystemModel
);
499 LAMEXP_DELETE(m_messageHandler
);
500 LAMEXP_DELETE(m_delayedFileList
);
501 LAMEXP_DELETE(m_delayedFileTimer
);
502 LAMEXP_DELETE(m_metaInfoModel
);
503 LAMEXP_DELETE(m_encoderButtonGroup
);
504 LAMEXP_DELETE(m_encoderButtonGroup
);
505 LAMEXP_DELETE(m_sourceFilesContextMenu
);
506 LAMEXP_DELETE(m_outputFolderFavoritesMenu
);
507 LAMEXP_DELETE(m_outputFolderContextMenu
);
508 LAMEXP_DELETE(m_dropBox
);
511 ////////////////////////////////////////////////////////////
513 ////////////////////////////////////////////////////////////
516 * Add file to source list
518 void MainWindow::addFiles(const QStringList
&files
)
525 tabWidget
->setCurrentIndex(0);
527 //int timeMT = 0, timeST = 0;
531 //FileAnalyzer_ST *analyzerPre = new FileAnalyzer_ST(files);
532 //connect(analyzerPre, SIGNAL(fileSelected(QString)), m_banner, SLOT(setText(QString)), Qt::QueuedConnection);
533 //connect(analyzerPre, SIGNAL(progressValChanged(unsigned int)), m_banner, SLOT(setProgressVal(unsigned int)), Qt::QueuedConnection);
534 //connect(analyzerPre, SIGNAL(progressMaxChanged(unsigned int)), m_banner, SLOT(setProgressMax(unsigned int)), Qt::QueuedConnection);
535 //connect(analyzerPre, SIGNAL(fileAnalyzed(AudioFileModel)), m_fileListModel, SLOT(addFile(AudioFileModel)), Qt::QueuedConnection);
536 //connect(m_banner, SIGNAL(userAbort()), analyzerPre, SLOT(abortProcess()), Qt::DirectConnection);
540 // m_fileListModel->setBlockUpdates(true);
541 // m_banner->show(tr("Adding file(s), please wait..."), analyzerPre);
545 // /* ignore any exceptions that may occur */
550 FileAnalyzer
*analyzer
= new FileAnalyzer(files
);
551 connect(analyzer
, SIGNAL(fileSelected(QString
)), m_banner
, SLOT(setText(QString
)), Qt::QueuedConnection
);
552 connect(analyzer
, SIGNAL(progressValChanged(unsigned int)), m_banner
, SLOT(setProgressVal(unsigned int)), Qt::QueuedConnection
);
553 connect(analyzer
, SIGNAL(progressMaxChanged(unsigned int)), m_banner
, SLOT(setProgressMax(unsigned int)), Qt::QueuedConnection
);
554 connect(analyzer
, SIGNAL(fileAnalyzed(AudioFileModel
)), m_fileListModel
, SLOT(addFile(AudioFileModel
)), Qt::QueuedConnection
);
555 connect(m_banner
, SIGNAL(userAbort()), analyzer
, SLOT(abortProcess()), Qt::DirectConnection
);
559 m_fileListModel
->setBlockUpdates(true);
560 QTime startTime
= QTime::currentTime();
561 m_banner
->show(tr("Adding file(s), please wait..."), analyzer
);
562 //timeMT = startTime.secsTo(QTime::currentTime());
566 /* ignore any exceptions that may occur */
571 //FileAnalyzer_ST *analyzerST = new FileAnalyzer_ST(files);
572 //connect(analyzerST, SIGNAL(fileSelected(QString)), m_banner, SLOT(setText(QString)), Qt::QueuedConnection);
573 //connect(analyzerST, SIGNAL(progressValChanged(unsigned int)), m_banner, SLOT(setProgressVal(unsigned int)), Qt::QueuedConnection);
574 //connect(analyzerST, SIGNAL(progressMaxChanged(unsigned int)), m_banner, SLOT(setProgressMax(unsigned int)), Qt::QueuedConnection);
575 //connect(analyzerST, SIGNAL(fileAnalyzed(AudioFileModel)), m_fileListModel, SLOT(addFile(AudioFileModel)), Qt::QueuedConnection);
576 //connect(m_banner, SIGNAL(userAbort()), analyzerST, SLOT(abortProcess()), Qt::DirectConnection);
580 // m_fileListModel->setBlockUpdates(true);
581 // QTime startTime = QTime::currentTime();
582 // m_banner->show(tr("Adding file(s), please wait..."), analyzerST);
583 // timeST = startTime.secsTo(QTime::currentTime());
587 // /* ignore any exceptions that may occur */
592 //if(timeST > 0 && timeMT > 0)
594 // double speedUp = static_cast<double>(timeST) / static_cast<double>(timeMT);
595 // qWarning("ST: %d, MT: %d", timeST, timeMT);
596 // QMessageBox::information(this, "Speed Up", QString().sprintf("Announcement: The new multi-threaded file analyzer is %.1fx faster !!!", speedUp), QMessageBox::Ok);
600 // QMessageBox::information(this, "Speed Up", "Couldn't compare the the new multi-threaded file analyzer this time!", QMessageBox::Ok);
605 m_fileListModel
->setBlockUpdates(false);
606 qApp
->processEvents(QEventLoop::ExcludeUserInputEvents
);
607 sourceFileView
->update();
608 qApp
->processEvents(QEventLoop::ExcludeUserInputEvents
);
609 sourceFileView
->scrollToBottom();
610 qApp
->processEvents(QEventLoop::ExcludeUserInputEvents
);
612 if(analyzer
->filesDenied())
614 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."))));
616 if(analyzer
->filesDummyCDDA())
618 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>"))));
620 if(analyzer
->filesCueSheet())
622 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."))));
624 if(analyzer
->filesRejected())
626 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."))));
629 LAMEXP_DELETE(analyzer
);
630 //LAMEXP_DELETE(analyzerST);
631 //LAMEXP_DELETE(analyzerPre);
637 * Add folder to source list
639 void MainWindow::addFolder(const QString
&path
, bool recursive
, bool delayed
)
641 QFileInfoList folderInfoList
;
642 folderInfoList
<< QFileInfo(path
);
643 QStringList fileList
;
645 m_banner
->show(tr("Scanning folder(s) for files, please wait..."));
647 QApplication::processEvents();
648 GetAsyncKeyState(VK_ESCAPE
);
650 while(!folderInfoList
.isEmpty())
652 if(GetAsyncKeyState(VK_ESCAPE
) & 0x0001)
654 MessageBeep(MB_ICONERROR
);
655 qWarning("Operation cancelled by user!");
660 QDir
currentDir(folderInfoList
.takeFirst().canonicalFilePath());
661 QFileInfoList fileInfoList
= currentDir
.entryInfoList(QDir::Files
| QDir::NoSymLinks
);
663 while(!fileInfoList
.isEmpty())
665 fileList
<< fileInfoList
.takeFirst().canonicalFilePath();
668 QApplication::processEvents();
672 folderInfoList
.append(currentDir
.entryInfoList(QDir::Dirs
| QDir::NoDotAndDotDot
| QDir::NoSymLinks
));
673 QApplication::processEvents();
678 QApplication::processEvents();
680 if(!fileList
.isEmpty())
684 addFilesDelayed(fileList
);
696 bool MainWindow::checkForUpdates(void)
698 bool bReadyToInstall
= false;
700 UpdateDialog
*updateDialog
= new UpdateDialog(m_settings
, this);
701 updateDialog
->exec();
703 if(updateDialog
->getSuccess())
705 m_settings
->autoUpdateLastCheck(QDate::currentDate().toString(Qt::ISODate
));
706 bReadyToInstall
= updateDialog
->updateReadyToInstall();
709 LAMEXP_DELETE(updateDialog
);
710 return bReadyToInstall
;
713 void MainWindow::refreshFavorites(void)
715 QList
<QAction
*> folderList
= m_outputFolderFavoritesMenu
->actions();
716 QStringList favorites
= m_settings
->favoriteOutputFolders().split("|", QString::SkipEmptyParts
);
717 while(favorites
.count() > 6) favorites
.removeFirst();
719 while(!folderList
.isEmpty())
721 QAction
*currentItem
= folderList
.takeFirst();
722 if(currentItem
->isSeparator()) break;
723 m_outputFolderFavoritesMenu
->removeAction(currentItem
);
724 LAMEXP_DELETE(currentItem
);
727 QAction
*lastItem
= m_outputFolderFavoritesMenu
->actions().first();
729 while(!favorites
.isEmpty())
731 QString path
= favorites
.takeLast();
732 if(QDir(path
).exists())
734 QAction
*action
= new QAction(QIcon(":/icons/folder_go.png"), QDir::toNativeSeparators(path
), this);
735 action
->setData(path
);
736 m_outputFolderFavoritesMenu
->insertAction(lastItem
, action
);
737 connect(action
, SIGNAL(triggered(bool)), this, SLOT(gotoFavoriteFolder()));
743 ////////////////////////////////////////////////////////////
745 ////////////////////////////////////////////////////////////
748 * Window is about to be shown
750 void MainWindow::showEvent(QShowEvent
*event
)
753 m_dropNoteLabel
->setGeometry(0, 0, sourceFileView
->width(), sourceFileView
->height());
754 sourceModelChanged();
756 if(!event
->spontaneous())
758 tabWidget
->setCurrentIndex(0);
763 m_firstTimeShown
= false;
764 QTimer::singleShot(0, this, SLOT(windowShown()));
768 if(m_settings
->dropBoxWidgetEnabled())
770 m_dropBox
->setVisible(true);
776 * Re-translate the UI
778 void MainWindow::changeEvent(QEvent
*e
)
780 if(e
->type() == QEvent::LanguageChange
)
782 int comboBoxIndex
[8];
784 //Backup combobox indices, as retranslateUi() resets
785 comboBoxIndex
[0] = comboBoxMP3ChannelMode
->currentIndex();
786 comboBoxIndex
[1] = comboBoxSamplingRate
->currentIndex();
787 comboBoxIndex
[2] = comboBoxAACProfile
->currentIndex();
788 comboBoxIndex
[3] = comboBoxAftenCodingMode
->currentIndex();
789 comboBoxIndex
[4] = comboBoxAftenDRCMode
->currentIndex();
790 comboBoxIndex
[5] = comboBoxNormalizationMode
->currentIndex();
791 comboBoxIndex
[6] = comboBoxOpusOptimize
->currentIndex();
792 comboBoxIndex
[7] = comboBoxOpusFramesize
->currentIndex();
794 //Re-translate from UIC
795 Ui::MainWindow::retranslateUi(this);
797 //Restore combobox indices
798 comboBoxMP3ChannelMode
->setCurrentIndex(comboBoxIndex
[0]);
799 comboBoxSamplingRate
->setCurrentIndex(comboBoxIndex
[1]);
800 comboBoxAACProfile
->setCurrentIndex(comboBoxIndex
[2]);
801 comboBoxAftenCodingMode
->setCurrentIndex(comboBoxIndex
[3]);
802 comboBoxAftenDRCMode
->setCurrentIndex(comboBoxIndex
[4]);
803 comboBoxNormalizationMode
->setCurrentIndex(comboBoxIndex
[5]);
804 comboBoxOpusOptimize
->setCurrentIndex(comboBoxIndex
[6]);
805 comboBoxOpusFramesize
->setCurrentIndex(comboBoxIndex
[7]);
807 //Update the window title
810 setWindowTitle(QString("%1 [!!! DEBUG BUILD !!!]").arg(windowTitle()));
812 else if(lamexp_version_demo())
814 setWindowTitle(QString("%1 [%2]").arg(windowTitle(), tr("DEMO VERSION")));
817 //Manually re-translate widgets that UIC doesn't handle
818 m_dropNoteLabel
->setText(QString("» %1 «").arg(tr("You can drop in audio files here!")));
819 m_outputFolderNoteBox
->setText(tr("Initializing directory outline, please be patient..."));
820 m_showDetailsContextAction
->setText(tr("Show Details"));
821 m_previewContextAction
->setText(tr("Open File in External Application"));
822 m_findFileContextAction
->setText(tr("Browse File Location"));
823 m_showFolderContextAction
->setText(tr("Browse Selected Folder"));
824 m_refreshFolderContextAction
->setText(tr("Refresh Directory Outline"));
825 m_addFavoriteFolderAction
->setText(tr("Bookmark Current Output Folder"));
826 m_exportCsvContextAction
->setText(tr("Export Meta Tags to CSV File"));
827 m_importCsvContextAction
->setText(tr("Import Meta Tags from CSV File"));
830 m_metaInfoModel
->clearData();
831 m_metaInfoModel
->setData(m_metaInfoModel
->index(4, 1), m_settings
->metaInfoPosition());
832 updateEncoder(m_settings
->compressionEncoder());
833 updateLameAlgoQuality(sliderLameAlgoQuality
->value());
834 updateMaximumInstances(sliderMaxInstances
->value());
835 renameOutputPatternChanged(lineEditRenamePattern
->text());
837 //Re-install shell integration
838 if(m_settings
->shellIntegrationEnabled())
840 ShellIntegration::install();
843 //Force resize, if needed
844 tabPageChanged(tabWidget
->currentIndex());
849 * File dragged over window
851 void MainWindow::dragEnterEvent(QDragEnterEvent
*event
)
853 QStringList formats
= event
->mimeData()->formats();
855 if(formats
.contains("application/x-qt-windows-mime;value=\"FileNameW\"", Qt::CaseInsensitive
) && formats
.contains("text/uri-list", Qt::CaseInsensitive
))
857 event
->acceptProposedAction();
862 * File dropped onto window
864 void MainWindow::dropEvent(QDropEvent
*event
)
868 QStringList droppedFiles
;
869 QList
<QUrl
> urls
= event
->mimeData()->urls();
871 while(!urls
.isEmpty())
873 QUrl currentUrl
= urls
.takeFirst();
874 QFileInfo
file(currentUrl
.toLocalFile());
881 qDebug("Dropped File: %s", file
.canonicalFilePath().toUtf8().constData());
882 droppedFiles
<< file
.canonicalFilePath();
887 qDebug("Dropped Folder: %s", file
.canonicalFilePath().toUtf8().constData());
888 QList
<QFileInfo
> list
= QDir(file
.canonicalFilePath()).entryInfoList(QDir::Files
| QDir::NoSymLinks
);
891 for(int j
= 0; j
< list
.count(); j
++)
893 droppedFiles
<< list
.at(j
).canonicalFilePath();
898 list
= QDir(file
.canonicalFilePath()).entryInfoList(QDir::Dirs
| QDir::NoDotAndDotDot
| QDir::NoSymLinks
);
899 for(int j
= 0; j
< list
.count(); j
++)
901 qDebug("Descending to Folder: %s", list
.at(j
).canonicalFilePath().toUtf8().constData());
902 urls
.prepend(QUrl::fromLocalFile(list
.at(j
).canonicalFilePath()));
908 if(!droppedFiles
.isEmpty())
910 addFilesDelayed(droppedFiles
, true);
915 * Window tries to close
917 void MainWindow::closeEvent(QCloseEvent
*event
)
919 if(m_banner
->isVisible() || m_delayedFileTimer
->isActive())
921 MessageBeep(MB_ICONEXCLAMATION
);
934 void MainWindow::resizeEvent(QResizeEvent
*event
)
936 if(event
) QMainWindow::resizeEvent(event
);
937 m_dropNoteLabel
->setGeometry(0, 0, sourceFileView
->width(), sourceFileView
->height());
939 if(QWidget
*port
= outputFolderView
->viewport())
941 m_outputFolderNoteBox
->setGeometry(16, (port
->height() - 64) / 2, port
->width() - 32, 64);
946 * Key press event filter
948 void MainWindow::keyPressEvent(QKeyEvent
*e
)
950 if(e
->key() == Qt::Key_F5
)
952 if(outputFolderView
->isVisible())
954 QTimer::singleShot(0, this, SLOT(refreshFolderContextActionTriggered()));
959 if(e
->key() == Qt::Key_Delete
)
961 if(sourceFileView
->isVisible())
963 QTimer::singleShot(0, this, SLOT(removeFileButtonClicked()));
968 QMainWindow::keyPressEvent(e
);
974 bool MainWindow::eventFilter(QObject
*obj
, QEvent
*event
)
976 if(obj
== m_fileSystemModel
)
978 if(QApplication::overrideCursor() == NULL
)
980 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor
));
981 QTimer::singleShot(250, this, SLOT(restoreCursor()));
984 else if(obj
== outputFolderView
)
986 switch(event
->type())
990 case QEvent::KeyPress
:
991 case QEvent::KeyRelease
:
992 case QEvent::FocusIn
:
993 case QEvent::FocusOut
:
994 case QEvent::TouchEnd
:
995 outputFolderViewClicked(outputFolderView
->currentIndex());
999 else if(obj
== outputFolderLabel
)
1001 switch(event
->type())
1003 case QEvent::MouseButtonPress
:
1004 if(dynamic_cast<QMouseEvent
*>(event
)->button() == Qt::LeftButton
)
1006 QString path
= outputFolderLabel
->text();
1007 if(!path
.endsWith(QDir::separator())) path
.append(QDir::separator());
1008 ShellExecuteW(reinterpret_cast<HWND
>(this->winId()), L
"explore", QWCHAR(path
), NULL
, NULL
, SW_SHOW
);
1012 outputFolderLabel
->setForegroundRole(QPalette::Link
);
1015 outputFolderLabel
->setForegroundRole(QPalette::WindowText
);
1019 else if(obj
== outputFoldersFovoritesLabel
)
1021 QMouseEvent
*mouseEvent
= dynamic_cast<QMouseEvent
*>(event
);
1022 QPoint pos
= (mouseEvent
!= NULL
) ? mouseEvent
->pos() : QPoint();
1023 QWidget
*sender
= dynamic_cast<QLabel
*>(obj
);
1025 switch(event
->type())
1028 outputFoldersFovoritesLabel
->setFrameShadow(QFrame::Raised
);
1030 case QEvent::MouseButtonPress
:
1031 outputFoldersFovoritesLabel
->setFrameShadow(QFrame::Sunken
);
1033 case QEvent::MouseButtonRelease
:
1034 outputFoldersFovoritesLabel
->setFrameShadow(QFrame::Raised
);
1035 if(sender
&& mouseEvent
)
1037 if(pos
.x() <= sender
->width() && pos
.y() <= sender
->height() && pos
.x() >= 0 && pos
.y() >= 0 && mouseEvent
->button() != Qt::MidButton
)
1039 if(outputFolderView
->isEnabled())
1041 m_outputFolderFavoritesMenu
->popup(sender
->mapToGlobal(pos
));
1047 outputFoldersFovoritesLabel
->setFrameShadow(QFrame::Plain
);
1051 else if(obj
== outputFoldersEditorLabel
)
1053 QMouseEvent
*mouseEvent
= dynamic_cast<QMouseEvent
*>(event
);
1054 QPoint pos
= (mouseEvent
!= NULL
) ? mouseEvent
->pos() : QPoint();
1055 QWidget
*sender
= dynamic_cast<QLabel
*>(obj
);
1057 switch(event
->type())
1060 outputFoldersEditorLabel
->setFrameShadow(QFrame::Raised
);
1062 case QEvent::MouseButtonPress
:
1063 outputFoldersEditorLabel
->setFrameShadow(QFrame::Sunken
);
1065 case QEvent::MouseButtonRelease
:
1066 outputFoldersEditorLabel
->setFrameShadow(QFrame::Raised
);
1067 if(sender
&& mouseEvent
)
1069 if(pos
.x() <= sender
->width() && pos
.y() <= sender
->height() && pos
.x() >= 0 && pos
.y() >= 0 && mouseEvent
->button() != Qt::MidButton
)
1071 if(outputFolderView
->isEnabled())
1073 outputFolderView
->setEnabled(false);
1074 outputFolderLabel
->setVisible(false);
1075 outputFolderEdit
->setVisible(true);
1076 outputFolderEdit
->setText(outputFolderLabel
->text());
1077 outputFolderEdit
->selectAll();
1078 outputFolderEdit
->setFocus();
1084 outputFoldersEditorLabel
->setFrameShadow(QFrame::Plain
);
1089 return QMainWindow::eventFilter(obj
, event
);
1092 bool MainWindow::event(QEvent
*e
)
1096 case lamexp_event_queryendsession
:
1097 qWarning("System is shutting down, main window prepares to close...");
1098 if(m_banner
->isVisible()) m_banner
->close();
1099 if(m_delayedFileTimer
->isActive()) m_delayedFileTimer
->stop();
1101 case lamexp_event_endsession
:
1102 qWarning("System is shutting down, main window will close now...");
1107 QApplication::processEvents(QEventLoop::WaitForMoreEvents
& QEventLoop::ExcludeUserInputEvents
);
1110 m_fileListModel
->clearFiles();
1112 case QEvent::MouseButtonPress
:
1113 if(outputFolderEdit
->isVisible())
1115 QTimer::singleShot(0, this, SLOT(outputFolderEditFinished()));
1118 return QMainWindow::event(e
);
1122 bool MainWindow::winEvent(MSG
*message
, long *result
)
1124 return WinSevenTaskbar::handleWinEvent(message
, result
);
1127 ////////////////////////////////////////////////////////////
1129 ////////////////////////////////////////////////////////////
1131 // =========================================================
1132 // Show window slots
1133 // =========================================================
1138 void MainWindow::windowShown(void)
1140 const QStringList
&arguments
= lamexp_arguments(); //QApplication::arguments();
1143 bool firstRun
= false;
1144 for(int i
= 0; i
< arguments
.count(); i
++)
1146 /*QMessageBox::information(this, QString::number(i), arguments[i]);*/
1147 if(!arguments
[i
].compare("--first-run", Qt::CaseInsensitive
)) firstRun
= true;
1151 if((m_settings
->licenseAccepted() <= 0) || firstRun
)
1155 if((m_settings
->licenseAccepted() == 0) || firstRun
)
1157 AboutDialog
*about
= new AboutDialog(m_settings
, this, true);
1158 iAccepted
= about
->exec();
1159 LAMEXP_DELETE(about
);
1164 m_settings
->licenseAccepted(-1);
1165 QApplication::processEvents();
1166 PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY
), GetModuleHandle(NULL
), SND_RESOURCE
| SND_SYNC
);
1167 QMessageBox::critical(this, tr("License Declined"), tr("You have declined the license. Consequently the application will exit now!"), tr("Goodbye!"));
1168 QFileInfo uninstallerInfo
= QFileInfo(QString("%1/Uninstall.exe").arg(QApplication::applicationDirPath()));
1169 if(uninstallerInfo
.exists())
1171 QString uninstallerDir
= uninstallerInfo
.canonicalPath();
1172 QString uninstallerPath
= uninstallerInfo
.canonicalFilePath();
1173 for(int i
= 0; i
< 3; i
++)
1175 HINSTANCE res
= ShellExecuteW(reinterpret_cast<HWND
>(this->winId()), L
"open", QWCHAR(QDir::toNativeSeparators(uninstallerPath
)), L
"/Force", QWCHAR(QDir::toNativeSeparators(uninstallerDir
)), SW_SHOWNORMAL
);
1176 if(reinterpret_cast<int>(res
) > 32) break;
1181 MoveFileEx(QWCHAR(QDir::toNativeSeparators(QFileInfo(QApplication::applicationFilePath()).canonicalFilePath())), NULL
, MOVEFILE_DELAY_UNTIL_REBOOT
| MOVEFILE_REPLACE_EXISTING
);
1183 QApplication::quit();
1187 PlaySound(MAKEINTRESOURCE(IDR_WAVE_WOOHOO
), GetModuleHandle(NULL
), SND_RESOURCE
| SND_SYNC
);
1188 m_settings
->licenseAccepted(1);
1189 if(lamexp_version_demo()) showAnnounceBox();
1192 //Check for expiration
1193 if(lamexp_version_demo())
1195 if(QDate::currentDate() >= lamexp_version_expires())
1197 qWarning("Binary has expired !!!");
1198 PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY
), GetModuleHandle(NULL
), SND_RESOURCE
| SND_SYNC
);
1199 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)
1203 QApplication::quit();
1208 //Slow startup indicator
1209 if(m_settings
->slowStartup() && m_settings
->antivirNotificationsEnabled())
1212 message
+= NOBR(tr("It seems that a bogus anti-virus software is slowing down the startup of LameXP.")).append("<br>");
1213 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>");
1214 if(QMessageBox::warning(this, tr("Slow Startup"), message
, tr("Discard"), tr("Don't Show Again")) == 1)
1216 m_settings
->antivirNotificationsEnabled(false);
1217 actionDisableSlowStartupNotifications
->setChecked(!m_settings
->antivirNotificationsEnabled());
1222 if(QDate::currentDate() >= lamexp_version_date().addYears(1))
1224 qWarning("Binary is more than a year old, time to update!");
1225 int ret
= 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"), tr("Ignore"));
1229 if(checkForUpdates())
1231 QApplication::quit();
1236 QApplication::quit();
1239 QEventLoop loop
; QTimer::singleShot(7000, &loop
, SLOT(quit()));
1240 PlaySound(MAKEINTRESOURCE(IDR_WAVE_WAITING
), GetModuleHandle(NULL
), SND_RESOURCE
| SND_ASYNC
);
1241 m_banner
->show(tr("Skipping update check this time, please be patient..."), &loop
);
1245 else if(m_settings
->autoUpdateEnabled())
1247 QDate lastUpdateCheck
= QDate::fromString(m_settings
->autoUpdateLastCheck(), Qt::ISODate
);
1248 if(!firstRun
&& (!lastUpdateCheck
.isValid() || QDate::currentDate() >= lastUpdateCheck
.addDays(14)))
1250 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)
1252 if(checkForUpdates())
1254 QApplication::quit();
1261 //Check for AAC support
1262 if(m_neroEncoderAvailable
)
1264 if(m_settings
->neroAacNotificationsEnabled())
1266 if(lamexp_tool_version("neroAacEnc.exe") < lamexp_toolver_neroaac())
1268 QString messageText
;
1269 messageText
+= NOBR(tr("LameXP detected that your version of the Nero AAC encoder is outdated!")).append("<br>");
1270 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>");
1271 messageText
+= NOBR(tr("You can download the latest version of the Nero AAC encoder from the Nero website at:")).append("<br>");
1272 messageText
+= "<nobr><tt>" + LINK(AboutDialog::neroAacUrl
) + "</tt></nobr><br><br>";
1273 messageText
+= NOBR(tr("(Hint: Please ignore the name of the downloaded ZIP file and check the included 'changelog.txt' instead!)")).append("<br>");
1274 QMessageBox::information(this, tr("AAC Encoder Outdated"), messageText
);
1280 if(m_settings
->neroAacNotificationsEnabled() && (!(m_fhgEncoderAvailable
|| m_qaacEncoderAvailable
)))
1282 QString appPath
= QDir(QCoreApplication::applicationDirPath()).canonicalPath();
1283 if(appPath
.isEmpty()) appPath
= QCoreApplication::applicationDirPath();
1284 QString messageText
;
1285 messageText
+= NOBR(tr("The Nero AAC encoder could not be found. AAC encoding support will be disabled.")).append("<br>");
1286 messageText
+= NOBR(tr("Please put 'neroAacEnc.exe', 'neroAacDec.exe' and 'neroAacTag.exe' into the LameXP directory!")).append("<br><br>");
1287 messageText
+= NOBR(tr("Your LameXP directory is located here:")).append("<br>");
1288 messageText
+= QString("<nobr><tt>%1</tt></nobr><br><br>").arg(FSLINK(QDir::toNativeSeparators(appPath
)));
1289 messageText
+= NOBR(tr("You can download the Nero AAC encoder for free from the official Nero website at:")).append("<br>");
1290 messageText
+= "<nobr><tt>" + LINK(AboutDialog::neroAacUrl
) + "</tt></nobr><br>";
1291 if(QMessageBox::information(this, tr("AAC Support Disabled"), messageText
, tr("Discard"), tr("Don't Show Again")) == 1)
1293 m_settings
->neroAacNotificationsEnabled(false);
1294 actionDisableNeroAacNotifications
->setChecked(!m_settings
->neroAacNotificationsEnabled());
1299 //Add files from the command-line
1300 for(int i
= 0; i
< arguments
.count() - 1; i
++)
1302 QStringList addedFiles
;
1303 if(!arguments
[i
].compare("--add", Qt::CaseInsensitive
))
1305 QFileInfo
currentFile(arguments
[++i
].trimmed());
1306 qDebug("Adding file from CLI: %s", currentFile
.absoluteFilePath().toUtf8().constData());
1307 addedFiles
.append(currentFile
.absoluteFilePath());
1309 if(!addedFiles
.isEmpty())
1311 addFilesDelayed(addedFiles
);
1315 //Add folders from the command-line
1316 for(int i
= 0; i
< arguments
.count() - 1; i
++)
1318 if(!arguments
[i
].compare("--add-folder", Qt::CaseInsensitive
))
1320 QFileInfo
currentFile(arguments
[++i
].trimmed());
1321 qDebug("Adding folder from CLI: %s", currentFile
.absoluteFilePath().toUtf8().constData());
1322 addFolder(currentFile
.absoluteFilePath(), false, true);
1324 if(!arguments
[i
].compare("--add-recursive", Qt::CaseInsensitive
))
1326 QFileInfo
currentFile(arguments
[++i
].trimmed());
1327 qDebug("Adding folder recursively from CLI: %s", currentFile
.absoluteFilePath().toUtf8().constData());
1328 addFolder(currentFile
.absoluteFilePath(), true, true);
1332 //Enable shell integration
1333 if(m_settings
->shellIntegrationEnabled())
1335 ShellIntegration::install();
1338 //Make DropBox visible
1339 if(m_settings
->dropBoxWidgetEnabled())
1341 m_dropBox
->setVisible(true);
1348 void MainWindow::showAnnounceBox(void)
1350 const unsigned int timeout
= 8U;
1352 const QString announceText
= QString("%1<br><br>%2<br><nobr><tt>%3</tt></nobr><br>").arg
1354 NOBR("We are still looking for LameXP translators!"),
1355 NOBR("If you are willing to translate LameXP to your language or to complete an existing translation, please refer to:"),
1356 LINK("http://mulder.brhack.net/public/doc/lamexp_translate.html")
1359 QMessageBox
*announceBox
= new QMessageBox(QMessageBox::Warning
, "We want you!", announceText
, QMessageBox::NoButton
, this);
1360 announceBox
->setWindowFlags(Qt::Window
| Qt::WindowTitleHint
| Qt::CustomizeWindowHint
);
1361 announceBox
->setIconPixmap(QIcon(":/images/Announcement.png").pixmap(64,79));
1363 QTimer
*timers
[timeout
+1];
1364 QPushButton
*buttons
[timeout
+1];
1366 for(unsigned int i
= 0; i
<= timeout
; i
++)
1368 QString text
= (i
> 0) ? QString("%1 (%2)").arg(tr("Discard"), QString::number(i
)) : tr("Discard");
1369 buttons
[i
] = announceBox
->addButton(text
, (i
> 0) ? QMessageBox::NoRole
: QMessageBox::AcceptRole
);
1372 for(unsigned int i
= 0; i
<= timeout
; i
++)
1374 buttons
[i
]->setEnabled(i
== 0);
1375 buttons
[i
]->setVisible(i
== timeout
);
1378 for(unsigned int i
= 0; i
< timeout
; i
++)
1380 timers
[i
] = new QTimer(this);
1381 timers
[i
]->setSingleShot(true);
1382 timers
[i
]->setInterval(1000);
1383 connect(timers
[i
], SIGNAL(timeout()), buttons
[i
+1], SLOT(hide()));
1384 connect(timers
[i
], SIGNAL(timeout()), buttons
[i
], SLOT(show()));
1387 connect(timers
[i
], SIGNAL(timeout()), timers
[i
-1], SLOT(start()));
1391 timers
[timeout
-1]->start();
1392 announceBox
->exec();
1394 for(unsigned int i
= 0; i
< timeout
; i
++)
1397 LAMEXP_DELETE(timers
[i
]);
1400 LAMEXP_DELETE(announceBox
);
1403 // =========================================================
1404 // Main button solots
1405 // =========================================================
1410 void MainWindow::encodeButtonClicked(void)
1412 static const unsigned __int64 oneGigabyte
= 1073741824ui
64;
1413 static const unsigned __int64 minimumFreeDiskspaceMultiplier
= 2ui
64;
1414 static const char *writeTestBuffer
= "LAMEXP_WRITE_TEST";
1418 if(m_fileListModel
->rowCount() < 1)
1420 QMessageBox::warning(this, tr("LameXP"), NOBR(tr("You must add at least one file to the list before proceeding!")));
1421 tabWidget
->setCurrentIndex(0);
1425 QString tempFolder
= m_settings
->customTempPathEnabled() ? m_settings
->customTempPath() : lamexp_temp_folder2();
1426 if(!QFileInfo(tempFolder
).exists() || !QFileInfo(tempFolder
).isDir())
1428 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)
1430 while(checkBoxUseSystemTempFolder
->isChecked() == m_settings
->customTempPathEnabledDefault()) checkBoxUseSystemTempFolder
->click();
1436 unsigned __int64 currentFreeDiskspace
= lamexp_free_diskspace(tempFolder
, &ok
);
1438 if(ok
&& (currentFreeDiskspace
< (oneGigabyte
* minimumFreeDiskspaceMultiplier
)))
1440 QStringList tempFolderParts
= tempFolder
.split("/", QString::SkipEmptyParts
, Qt::CaseInsensitive
);
1441 tempFolderParts
.takeLast();
1442 if(m_settings
->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY
), GetModuleHandle(NULL
), SND_RESOURCE
| SND_SYNC
);
1443 QString lowDiskspaceMsg
= QString("%1<br>%2<br><br>%3<br>%4<br>").arg
1445 NOBR(tr("There are less than %1 GB of free diskspace available on your system's TEMP folder.").arg(QString::number(minimumFreeDiskspaceMultiplier
))),
1446 NOBR(tr("It is highly recommend to free up more diskspace before proceeding with the encode!")),
1447 NOBR(tr("Your TEMP folder is located at:")),
1448 QString("<nobr><tt>%1</tt></nobr>").arg(FSLINK(tempFolderParts
.join("\\")))
1450 switch(QMessageBox::warning(this, tr("Low Diskspace Warning"), lowDiskspaceMsg
, tr("Abort Encoding Process"), tr("Clean Disk Now"), tr("Ignore")))
1453 QProcess::startDetached(QString("%1/cleanmgr.exe").arg(lamexp_known_folder(lamexp_folder_systemfolder
)), QStringList() << "/D" << tempFolderParts
.first());
1458 QMessageBox::warning(this, tr("Low Diskspace"), NOBR(tr("You are proceeding with low diskspace. Problems might occur!")));
1463 switch(m_settings
->compressionEncoder())
1465 case SettingsModel::MP3Encoder
:
1466 case SettingsModel::VorbisEncoder
:
1467 case SettingsModel::AACEncoder
:
1468 case SettingsModel::AC3Encoder
:
1469 case SettingsModel::FLACEncoder
:
1470 case SettingsModel::OpusEncoder
:
1471 case SettingsModel::DCAEncoder
:
1472 case SettingsModel::PCMEncoder
:
1475 QMessageBox::warning(this, tr("LameXP"), tr("Sorry, an unsupported encoder has been chosen!"));
1476 tabWidget
->setCurrentIndex(3);
1480 if(!m_settings
->outputToSourceDir())
1482 QFile
writeTest(QString("%1/~%2.txt").arg(m_settings
->outputDir(), lamexp_rand_str()));
1483 if(!(writeTest
.open(QIODevice::ReadWrite
) && (writeTest
.write(writeTestBuffer
) == strlen(writeTestBuffer
))))
1485 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!")));
1486 tabWidget
->setCurrentIndex(1);
1503 void MainWindow::aboutButtonClicked(void)
1509 AboutDialog
*aboutBox
= new AboutDialog(m_settings
, this);
1511 LAMEXP_DELETE(aboutBox
);
1518 void MainWindow::closeButtonClicked(void)
1524 // =========================================================
1526 // =========================================================
1531 void MainWindow::tabPageChanged(int idx
)
1535 QList
<QAction
*> actions
= m_tabActionGroup
->actions();
1536 for(int i
= 0; i
< actions
.count(); i
++)
1539 int actionIndex
= actions
.at(i
)->data().toInt(&ok
);
1540 if(ok
&& actionIndex
== idx
)
1542 actions
.at(i
)->setChecked(true);
1546 int initialWidth
= this->width();
1547 int maximumWidth
= QApplication::desktop()->width();
1549 if(this->isVisible())
1551 while(tabWidget
->width() < tabWidget
->sizeHint().width())
1553 int previousWidth
= this->width();
1554 this->resize(this->width() + 1, this->height());
1555 if(this->frameGeometry().width() >= maximumWidth
) break;
1556 if(this->width() <= previousWidth
) break;
1560 if(idx
== tabWidget
->indexOf(tabOptions
) && scrollArea
->widget() && this->isVisible())
1562 for(int i
= 0; i
< 2; i
++)
1564 QApplication::processEvents();
1565 while(scrollArea
->viewport()->width() < scrollArea
->widget()->width())
1567 int previousWidth
= this->width();
1568 this->resize(this->width() + 1, this->height());
1569 if(this->frameGeometry().width() >= maximumWidth
) break;
1570 if(this->width() <= previousWidth
) break;
1574 else if(idx
== tabWidget
->indexOf(tabSourceFiles
))
1576 m_dropNoteLabel
->setGeometry(0, 0, sourceFileView
->width(), sourceFileView
->height());
1578 else if(idx
== tabWidget
->indexOf(tabOutputDir
))
1580 if(!m_fileSystemModel
)
1582 QTimer::singleShot(125, this, SLOT(initOutputFolderModel()));
1586 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
1590 if(initialWidth
< this->width())
1592 QPoint prevPos
= this->pos();
1593 int delta
= (this->width() - initialWidth
) >> 2;
1594 move(prevPos
.x() - delta
, prevPos
.y());
1599 * Tab action triggered
1601 void MainWindow::tabActionActivated(QAction
*action
)
1603 if(action
&& action
->data().isValid())
1606 int index
= action
->data().toInt(&ok
);
1609 tabWidget
->setCurrentIndex(index
);
1614 // =========================================================
1616 // =========================================================
1619 * Style action triggered
1621 void MainWindow::styleActionActivated(QAction
*action
)
1623 //Change style setting
1624 if(action
&& action
->data().isValid())
1627 int actionIndex
= action
->data().toInt(&ok
);
1630 m_settings
->interfaceStyle(actionIndex
);
1634 //Set up the new style
1635 switch(m_settings
->interfaceStyle())
1638 if(actionStyleCleanlooks
->isEnabled())
1640 actionStyleCleanlooks
->setChecked(true);
1641 QApplication::setStyle(new QCleanlooksStyle());
1645 if(actionStyleWindowsVista
->isEnabled())
1647 actionStyleWindowsVista
->setChecked(true);
1648 QApplication::setStyle(new QWindowsVistaStyle());
1652 if(actionStyleWindowsXP
->isEnabled())
1654 actionStyleWindowsXP
->setChecked(true);
1655 QApplication::setStyle(new QWindowsXPStyle());
1659 if(actionStyleWindowsClassic
->isEnabled())
1661 actionStyleWindowsClassic
->setChecked(true);
1662 QApplication::setStyle(new QWindowsStyle());
1666 actionStylePlastique
->setChecked(true);
1667 QApplication::setStyle(new QPlastiqueStyle());
1671 //Force re-translate after style change
1672 if(QEvent
*e
= new QEvent(QEvent::LanguageChange
))
1680 * Language action triggered
1682 void MainWindow::languageActionActivated(QAction
*action
)
1684 if(action
->data().type() == QVariant::String
)
1686 QString langId
= action
->data().toString();
1688 if(lamexp_install_translator(langId
))
1690 action
->setChecked(true);
1691 m_settings
->currentLanguage(langId
);
1697 * Load language from file action triggered
1699 void MainWindow::languageFromFileActionActivated(bool checked
)
1701 QFileDialog
dialog(this, tr("Load Translation"));
1702 dialog
.setFileMode(QFileDialog::ExistingFile
);
1703 dialog
.setNameFilter(QString("%1 (*.qm)").arg(tr("Translation Files")));
1707 QStringList selectedFiles
= dialog
.selectedFiles();
1708 if(lamexp_install_translator_from_file(selectedFiles
.first()))
1710 QList
<QAction
*> actions
= m_languageActionGroup
->actions();
1711 while(!actions
.isEmpty())
1713 actions
.takeFirst()->setChecked(false);
1718 languageActionActivated(m_languageActionGroup
->actions().first());
1723 // =========================================================
1725 // =========================================================
1728 * Disable update reminder action
1730 void MainWindow::disableUpdateReminderActionTriggered(bool checked
)
1734 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))
1736 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!"))));
1737 m_settings
->autoUpdateEnabled(false);
1741 m_settings
->autoUpdateEnabled(true);
1746 QMessageBox::information(this, tr("Update Reminder"), NOBR(tr("The update reminder has been re-enabled.")));
1747 m_settings
->autoUpdateEnabled(true);
1750 actionDisableUpdateReminder
->setChecked(!m_settings
->autoUpdateEnabled());
1754 * Disable sound effects action
1756 void MainWindow::disableSoundsActionTriggered(bool checked
)
1760 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))
1762 QMessageBox::information(this, tr("Sound Effects"), NOBR(tr("All sound effects have been disabled.")));
1763 m_settings
->soundsEnabled(false);
1767 m_settings
->soundsEnabled(true);
1772 QMessageBox::information(this, tr("Sound Effects"), NOBR(tr("The sound effects have been re-enabled.")));
1773 m_settings
->soundsEnabled(true);
1776 actionDisableSounds
->setChecked(!m_settings
->soundsEnabled());
1780 * Disable Nero AAC encoder action
1782 void MainWindow::disableNeroAacNotificationsActionTriggered(bool checked
)
1786 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))
1788 QMessageBox::information(this, tr("Nero AAC Notifications"), NOBR(tr("All Nero AAC Encoder notifications have been disabled.")));
1789 m_settings
->neroAacNotificationsEnabled(false);
1793 m_settings
->neroAacNotificationsEnabled(true);
1798 QMessageBox::information(this, tr("Nero AAC Notifications"), NOBR(tr("The Nero AAC Encoder notifications have been re-enabled.")));
1799 m_settings
->neroAacNotificationsEnabled(true);
1802 actionDisableNeroAacNotifications
->setChecked(!m_settings
->neroAacNotificationsEnabled());
1806 * Disable slow startup action
1808 void MainWindow::disableSlowStartupNotificationsActionTriggered(bool checked
)
1812 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))
1814 QMessageBox::information(this, tr("Slow Startup Notifications"), NOBR(tr("The slow startup notifications have been disabled.")));
1815 m_settings
->antivirNotificationsEnabled(false);
1819 m_settings
->antivirNotificationsEnabled(true);
1824 QMessageBox::information(this, tr("Slow Startup Notifications"), NOBR(tr("The slow startup notifications have been re-enabled.")));
1825 m_settings
->antivirNotificationsEnabled(true);
1828 actionDisableSlowStartupNotifications
->setChecked(!m_settings
->antivirNotificationsEnabled());
1832 * Import a Cue Sheet file
1834 void MainWindow::importCueSheetActionTriggered(bool checked
)
1843 QString selectedCueFile
;
1845 if(USE_NATIVE_FILE_DIALOG
)
1847 selectedCueFile
= QFileDialog::getOpenFileName(this, tr("Open Cue Sheet"), m_settings
->mostRecentInputPath(), QString("%1 (*.cue)").arg(tr("Cue Sheet File")));
1851 QFileDialog
dialog(this, tr("Open Cue Sheet"));
1852 dialog
.setFileMode(QFileDialog::ExistingFile
);
1853 dialog
.setNameFilter(QString("%1 (*.cue)").arg(tr("Cue Sheet File")));
1854 dialog
.setDirectory(m_settings
->mostRecentInputPath());
1857 selectedCueFile
= dialog
.selectedFiles().first();
1861 if(!selectedCueFile
.isEmpty())
1863 m_settings
->mostRecentInputPath(QFileInfo(selectedCueFile
).canonicalPath());
1864 CueImportDialog
*cueImporter
= new CueImportDialog(this, m_fileListModel
, selectedCueFile
);
1865 result
= cueImporter
->exec();
1866 LAMEXP_DELETE(cueImporter
);
1869 if(result
!= (-1)) break;
1875 * Show the "drop box" widget
1877 void MainWindow::showDropBoxWidgetActionTriggered(bool checked
)
1879 m_settings
->dropBoxWidgetEnabled(true);
1881 if(!m_dropBox
->isVisible())
1886 lamexp_blink_window(m_dropBox
);
1890 * Check for beta (pre-release) updates
1892 void MainWindow::checkForBetaUpdatesActionTriggered(bool checked
)
1894 bool checkUpdatesNow
= false;
1898 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))
1900 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")))
1902 checkUpdatesNow
= true;
1904 m_settings
->autoUpdateCheckBeta(true);
1908 m_settings
->autoUpdateCheckBeta(false);
1913 QMessageBox::information(this, tr("Beta Updates"), NOBR(tr("LameXP will <i>not</i> check for Beta (pre-release) updates from now on.")));
1914 m_settings
->autoUpdateCheckBeta(false);
1917 actionCheckForBetaUpdates
->setChecked(m_settings
->autoUpdateCheckBeta());
1921 if(checkForUpdates())
1923 QApplication::quit();
1929 * Hibernate computer action
1931 void MainWindow::hibernateComputerActionTriggered(bool checked
)
1935 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))
1937 QMessageBox::information(this, tr("Hibernate Computer"), NOBR(tr("LameXP will hibernate the computer on shutdown from now on.")));
1938 m_settings
->hibernateComputer(true);
1942 m_settings
->hibernateComputer(false);
1947 QMessageBox::information(this, tr("Hibernate Computer"), NOBR(tr("LameXP will <i>not</i> hibernate the computer on shutdown from now on.")));
1948 m_settings
->hibernateComputer(false);
1951 actionHibernateComputer
->setChecked(m_settings
->hibernateComputer());
1955 * Disable shell integration action
1957 void MainWindow::disableShellIntegrationActionTriggered(bool checked
)
1961 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))
1963 ShellIntegration::remove();
1964 QMessageBox::information(this, tr("Shell Integration"), NOBR(tr("The LameXP shell integration has been disabled.")));
1965 m_settings
->shellIntegrationEnabled(false);
1969 m_settings
->shellIntegrationEnabled(true);
1974 ShellIntegration::install();
1975 QMessageBox::information(this, tr("Shell Integration"), NOBR(tr("The LameXP shell integration has been re-enabled.")));
1976 m_settings
->shellIntegrationEnabled(true);
1979 actionDisableShellIntegration
->setChecked(!m_settings
->shellIntegrationEnabled());
1981 if(lamexp_portable_mode() && actionDisableShellIntegration
->isChecked())
1983 actionDisableShellIntegration
->setEnabled(false);
1987 // =========================================================
1989 // =========================================================
1992 * Visit homepage action
1994 void MainWindow::visitHomepageActionActivated(void)
1996 if(QAction
*action
= dynamic_cast<QAction
*>(QObject::sender()))
1998 if(action
->data().isValid() && (action
->data().type() == QVariant::String
))
2000 QDesktopServices::openUrl(QUrl(action
->data().toString()));
2008 void MainWindow::documentActionActivated(void)
2010 if(QAction
*action
= dynamic_cast<QAction
*>(QObject::sender()))
2012 if(action
->data().isValid() && (action
->data().type() == QVariant::String
))
2014 QFileInfo
document(action
->data().toString());
2015 QFileInfo
resource(QString(":/doc/%1.html").arg(document
.baseName()));
2016 if(document
.exists() && document
.isFile() && (document
.size() == resource
.size()))
2018 QDesktopServices::openUrl(QUrl::fromLocalFile(document
.canonicalFilePath()));
2022 QFile
source(resource
.filePath());
2023 QFile
output(QString("%1/%2.%3.html").arg(lamexp_temp_folder2(), document
.baseName(), lamexp_rand_str().left(8)));
2024 if(source
.open(QIODevice::ReadOnly
) && output
.open(QIODevice::ReadWrite
))
2026 output
.write(source
.readAll());
2027 action
->setData(output
.fileName());
2030 QDesktopServices::openUrl(QUrl::fromLocalFile(output
.fileName()));
2038 * Check for updates action
2040 void MainWindow::checkUpdatesActionActivated(void)
2047 bFlag
= checkForUpdates();
2052 QApplication::quit();
2056 // =========================================================
2057 // Source file slots
2058 // =========================================================
2061 * Add file(s) button
2063 void MainWindow::addFilesButtonClicked(void)
2069 if(USE_NATIVE_FILE_DIALOG
)
2071 QStringList fileTypeFilters
= DecoderRegistry::getSupportedTypes();
2072 QStringList selectedFiles
= QFileDialog::getOpenFileNames(this, tr("Add file(s)"), m_settings
->mostRecentInputPath(), fileTypeFilters
.join(";;"));
2073 if(!selectedFiles
.isEmpty())
2075 m_settings
->mostRecentInputPath(QFileInfo(selectedFiles
.first()).canonicalPath());
2076 addFiles(selectedFiles
);
2081 QFileDialog
dialog(this, tr("Add file(s)"));
2082 QStringList fileTypeFilters
= DecoderRegistry::getSupportedTypes();
2083 dialog
.setFileMode(QFileDialog::ExistingFiles
);
2084 dialog
.setNameFilter(fileTypeFilters
.join(";;"));
2085 dialog
.setDirectory(m_settings
->mostRecentInputPath());
2088 QStringList selectedFiles
= dialog
.selectedFiles();
2089 if(!selectedFiles
.isEmpty())
2091 m_settings
->mostRecentInputPath(QFileInfo(selectedFiles
.first()).canonicalPath());
2092 addFiles(selectedFiles
);
2100 * Open folder action
2102 void MainWindow::openFolderActionActivated(void)
2105 QString selectedFolder
;
2107 if(QAction
*action
= dynamic_cast<QAction
*>(QObject::sender()))
2111 if(USE_NATIVE_FILE_DIALOG
)
2113 selectedFolder
= QFileDialog::getExistingDirectory(this, tr("Add Folder"), m_settings
->mostRecentInputPath());
2117 QFileDialog
dialog(this, tr("Add Folder"));
2118 dialog
.setFileMode(QFileDialog::DirectoryOnly
);
2119 dialog
.setDirectory(m_settings
->mostRecentInputPath());
2122 selectedFolder
= dialog
.selectedFiles().first();
2126 if(!selectedFolder
.isEmpty())
2128 m_settings
->mostRecentInputPath(QDir(selectedFolder
).canonicalPath());
2129 addFolder(selectedFolder
, action
->data().toBool());
2136 * Remove file button
2138 void MainWindow::removeFileButtonClicked(void)
2140 if(sourceFileView
->currentIndex().isValid())
2142 int iRow
= sourceFileView
->currentIndex().row();
2143 m_fileListModel
->removeFile(sourceFileView
->currentIndex());
2144 sourceFileView
->selectRow(iRow
< m_fileListModel
->rowCount() ? iRow
: m_fileListModel
->rowCount()-1);
2149 * Clear files button
2151 void MainWindow::clearFilesButtonClicked(void)
2153 m_fileListModel
->clearFiles();
2157 * Move file up button
2159 void MainWindow::fileUpButtonClicked(void)
2161 if(sourceFileView
->currentIndex().isValid())
2163 int iRow
= sourceFileView
->currentIndex().row() - 1;
2164 m_fileListModel
->moveFile(sourceFileView
->currentIndex(), -1);
2165 sourceFileView
->selectRow(iRow
>= 0 ? iRow
: 0);
2170 * Move file down button
2172 void MainWindow::fileDownButtonClicked(void)
2174 if(sourceFileView
->currentIndex().isValid())
2176 int iRow
= sourceFileView
->currentIndex().row() + 1;
2177 m_fileListModel
->moveFile(sourceFileView
->currentIndex(), 1);
2178 sourceFileView
->selectRow(iRow
< m_fileListModel
->rowCount() ? iRow
: m_fileListModel
->rowCount()-1);
2183 * Show details button
2185 void MainWindow::showDetailsButtonClicked(void)
2190 MetaInfoDialog
*metaInfoDialog
= new MetaInfoDialog(this);
2191 QModelIndex index
= sourceFileView
->currentIndex();
2193 while(index
.isValid())
2197 index
= m_fileListModel
->index(index
.row() + 1, index
.column());
2198 sourceFileView
->selectRow(index
.row());
2202 index
= m_fileListModel
->index(index
.row() - 1, index
.column());
2203 sourceFileView
->selectRow(index
.row());
2206 AudioFileModel
&file
= (*m_fileListModel
)[index
];
2209 iResult
= metaInfoDialog
->exec(file
, index
.row() > 0, index
.row() < m_fileListModel
->rowCount() - 1);
2212 if(iResult
== INT_MAX
)
2214 m_metaInfoModel
->assignInfoFrom(file
);
2215 tabWidget
->setCurrentIndex(tabWidget
->indexOf(tabMetaData
));
2222 LAMEXP_DELETE(metaInfoDialog
);
2223 QApplication::processEvents(QEventLoop::ExcludeUserInputEvents
);
2224 sourceFilesScrollbarMoved(0);
2228 * Show context menu for source files
2230 void MainWindow::sourceFilesContextMenu(const QPoint
&pos
)
2232 QAbstractScrollArea
*scrollArea
= dynamic_cast<QAbstractScrollArea
*>(QObject::sender());
2233 QWidget
*sender
= scrollArea
? scrollArea
->viewport() : dynamic_cast<QWidget
*>(QObject::sender());
2237 if(pos
.x() <= sender
->width() && pos
.y() <= sender
->height() && pos
.x() >= 0 && pos
.y() >= 0)
2239 m_sourceFilesContextMenu
->popup(sender
->mapToGlobal(pos
));
2245 * Scrollbar of source files moved
2247 void MainWindow::sourceFilesScrollbarMoved(int)
2249 sourceFileView
->resizeColumnToContents(0);
2253 * Open selected file in external player
2255 void MainWindow::previewContextActionTriggered(void)
2257 const static char *appNames
[3] = {"smplayer_portable.exe", "smplayer.exe", "mplayer.exe"};
2258 const static wchar_t *registryKey
= L
"SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{DB9E4EAB-2717-499F-8D56-4CC8A644AB60}";
2260 QModelIndex index
= sourceFileView
->currentIndex();
2261 if(!index
.isValid())
2266 QString mplayerPath
;
2267 HKEY registryKeyHandle
;
2269 if(RegOpenKeyExW(HKEY_LOCAL_MACHINE
, registryKey
, 0, KEY_READ
, ®istryKeyHandle
) == ERROR_SUCCESS
)
2271 wchar_t Buffer
[4096];
2272 DWORD BuffSize
= sizeof(wchar_t*) * 4096;
2273 if(RegQueryValueExW(registryKeyHandle
, L
"InstallLocation", 0, 0, reinterpret_cast<BYTE
*>(Buffer
), &BuffSize
) == ERROR_SUCCESS
)
2275 mplayerPath
= QString::fromUtf16(reinterpret_cast<const unsigned short*>(Buffer
));
2279 if(!mplayerPath
.isEmpty())
2281 QDir
mplayerDir(mplayerPath
);
2282 if(mplayerDir
.exists())
2284 for(int i
= 0; i
< 3; i
++)
2286 if(mplayerDir
.exists(appNames
[i
]))
2288 QProcess::startDetached(mplayerDir
.absoluteFilePath(appNames
[i
]), QStringList() << QDir::toNativeSeparators(m_fileListModel
->getFile(index
).filePath()));
2295 QDesktopServices::openUrl(QString("file:///").append(m_fileListModel
->getFile(index
).filePath()));
2299 * Find selected file in explorer
2301 void MainWindow::findFileContextActionTriggered(void)
2303 QModelIndex index
= sourceFileView
->currentIndex();
2306 QString systemRootPath
;
2308 QDir
systemRoot(lamexp_known_folder(lamexp_folder_systemfolder
));
2309 if(systemRoot
.exists() && systemRoot
.cdUp())
2311 systemRootPath
= systemRoot
.canonicalPath();
2314 if(!systemRootPath
.isEmpty())
2316 QFileInfo
explorer(QString("%1/explorer.exe").arg(systemRootPath
));
2317 if(explorer
.exists() && explorer
.isFile())
2319 QProcess::execute(explorer
.canonicalFilePath(), QStringList() << "/select," << QDir::toNativeSeparators(m_fileListModel
->getFile(index
).filePath()));
2325 qWarning("SystemRoot directory could not be detected!");
2331 * Add all pending files
2333 void MainWindow::handleDelayedFiles(void)
2335 m_delayedFileTimer
->stop();
2337 if(m_delayedFileList
->isEmpty())
2342 if(m_banner
->isVisible())
2344 m_delayedFileTimer
->start(5000);
2348 QStringList selectedFiles
;
2349 tabWidget
->setCurrentIndex(0);
2351 while(!m_delayedFileList
->isEmpty())
2353 QFileInfo currentFile
= QFileInfo(m_delayedFileList
->takeFirst());
2354 if(!currentFile
.exists() || !currentFile
.isFile())
2358 selectedFiles
<< currentFile
.canonicalFilePath();
2361 addFiles(selectedFiles
);
2365 * Export Meta tags to CSV file
2367 void MainWindow::exportCsvContextActionTriggered(void)
2371 QString selectedCsvFile
;
2373 if(USE_NATIVE_FILE_DIALOG
)
2375 selectedCsvFile
= QFileDialog::getSaveFileName(this, tr("Save CSV file"), m_settings
->mostRecentInputPath(), QString("%1 (*.csv)").arg(tr("CSV File")));
2379 QFileDialog
dialog(this, tr("Save CSV file"));
2380 dialog
.setFileMode(QFileDialog::AnyFile
);
2381 dialog
.setAcceptMode(QFileDialog::AcceptSave
);
2382 dialog
.setNameFilter(QString("%1 (*.csv)").arg(tr("CSV File")));
2383 dialog
.setDirectory(m_settings
->mostRecentInputPath());
2386 selectedCsvFile
= dialog
.selectedFiles().first();
2390 if(!selectedCsvFile
.isEmpty())
2392 m_settings
->mostRecentInputPath(QFileInfo(selectedCsvFile
).canonicalPath());
2393 switch(m_fileListModel
->exportToCsv(selectedCsvFile
))
2395 case FileListModel::CsvError_NoTags
:
2396 QMessageBox::critical(this, tr("CSV Export"), NOBR(tr("Sorry, there are no meta tags that can be exported!")));
2398 case FileListModel::CsvError_FileOpen
:
2399 QMessageBox::critical(this, tr("CSV Export"), NOBR(tr("Sorry, failed to open CSV file for writing!")));
2401 case FileListModel::CsvError_FileWrite
:
2402 QMessageBox::critical(this, tr("CSV Export"), NOBR(tr("Sorry, failed to write to the CSV file!")));
2404 case FileListModel::CsvError_OK
:
2405 QMessageBox::information(this, tr("CSV Export"), NOBR(tr("The CSV files was created successfully!")));
2408 qWarning("exportToCsv: Unknown return code!");
2416 * Import Meta tags from CSV file
2418 void MainWindow::importCsvContextActionTriggered(void)
2422 QString selectedCsvFile
;
2424 if(USE_NATIVE_FILE_DIALOG
)
2426 selectedCsvFile
= QFileDialog::getOpenFileName(this, tr("Open CSV file"), m_settings
->mostRecentInputPath(), QString("%1 (*.csv)").arg(tr("CSV File")));
2430 QFileDialog
dialog(this, tr("Open CSV file"));
2431 dialog
.setFileMode(QFileDialog::ExistingFile
);
2432 dialog
.setNameFilter(QString("%1 (*.csv)").arg(tr("CSV File")));
2433 dialog
.setDirectory(m_settings
->mostRecentInputPath());
2436 selectedCsvFile
= dialog
.selectedFiles().first();
2440 if(!selectedCsvFile
.isEmpty())
2442 m_settings
->mostRecentInputPath(QFileInfo(selectedCsvFile
).canonicalPath());
2443 switch(m_fileListModel
->importFromCsv(this, selectedCsvFile
))
2445 case FileListModel::CsvError_FileOpen
:
2446 QMessageBox::critical(this, tr("CSV Import"), NOBR(tr("Sorry, failed to open CSV file for reading!")));
2448 case FileListModel::CsvError_FileRead
:
2449 QMessageBox::critical(this, tr("CSV Import"), NOBR(tr("Sorry, failed to read from the CSV file!")));
2451 case FileListModel::CsvError_NoTags
:
2452 QMessageBox::critical(this, tr("CSV Import"), NOBR(tr("Sorry, the CSV file does not contain any known fields!")));
2454 case FileListModel::CsvError_Incomplete
:
2455 QMessageBox::warning(this, tr("CSV Import"), NOBR(tr("CSV file is incomplete. Not all files were updated!")));
2457 case FileListModel::CsvError_OK
:
2458 QMessageBox::information(this, tr("CSV Import"), NOBR(tr("The CSV files was imported successfully!")));
2460 case FileListModel::CsvError_Aborted
:
2461 /* User aborted, ignore! */
2464 qWarning("exportToCsv: Unknown return code!");
2471 * Show or hide Drag'n'Drop notice after model reset
2473 void MainWindow::sourceModelChanged(void)
2475 m_dropNoteLabel
->setVisible(m_fileListModel
->rowCount() <= 0);
2478 // =========================================================
2479 // Output folder slots
2480 // =========================================================
2483 * Output folder changed (mouse clicked)
2485 void MainWindow::outputFolderViewClicked(const QModelIndex
&index
)
2487 if(index
.isValid() && (outputFolderView
->currentIndex() != index
))
2489 outputFolderView
->setCurrentIndex(index
);
2492 if(m_fileSystemModel
&& index
.isValid())
2494 QString selectedDir
= m_fileSystemModel
->filePath(index
);
2495 if(selectedDir
.length() < 3) selectedDir
.append(QDir::separator());
2496 outputFolderLabel
->setText(QDir::toNativeSeparators(selectedDir
));
2497 m_settings
->outputDir(selectedDir
);
2501 outputFolderLabel
->setText(QDir::toNativeSeparators(m_settings
->outputDir()));
2506 * Output folder changed (mouse moved)
2508 void MainWindow::outputFolderViewMoved(const QModelIndex
&index
)
2510 if(QApplication::mouseButtons() & Qt::LeftButton
)
2512 outputFolderViewClicked(index
);
2517 * Goto desktop button
2519 void MainWindow::gotoDesktopButtonClicked(void)
2521 if(!m_fileSystemModel
)
2523 qWarning("File system model not initialized yet!");
2527 QString desktopPath
= QDesktopServices::storageLocation(QDesktopServices::DesktopLocation
);
2529 if(!desktopPath
.isEmpty() && QDir(desktopPath
).exists())
2531 outputFolderView
->setCurrentIndex(m_fileSystemModel
->index(desktopPath
));
2532 outputFolderViewClicked(outputFolderView
->currentIndex());
2533 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
2537 buttonGotoDesktop
->setEnabled(false);
2542 * Goto home folder button
2544 void MainWindow::gotoHomeFolderButtonClicked(void)
2546 if(!m_fileSystemModel
)
2548 qWarning("File system model not initialized yet!");
2552 QString homePath
= QDesktopServices::storageLocation(QDesktopServices::HomeLocation
);
2554 if(!homePath
.isEmpty() && QDir(homePath
).exists())
2556 outputFolderView
->setCurrentIndex(m_fileSystemModel
->index(homePath
));
2557 outputFolderViewClicked(outputFolderView
->currentIndex());
2558 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
2562 buttonGotoHome
->setEnabled(false);
2567 * Goto music folder button
2569 void MainWindow::gotoMusicFolderButtonClicked(void)
2571 if(!m_fileSystemModel
)
2573 qWarning("File system model not initialized yet!");
2577 QString musicPath
= QDesktopServices::storageLocation(QDesktopServices::MusicLocation
);
2579 if(!musicPath
.isEmpty() && QDir(musicPath
).exists())
2581 outputFolderView
->setCurrentIndex(m_fileSystemModel
->index(musicPath
));
2582 outputFolderViewClicked(outputFolderView
->currentIndex());
2583 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
2587 buttonGotoMusic
->setEnabled(false);
2592 * Goto music favorite output folder
2594 void MainWindow::gotoFavoriteFolder(void)
2596 if(!m_fileSystemModel
)
2598 qWarning("File system model not initialized yet!");
2602 QAction
*item
= dynamic_cast<QAction
*>(QObject::sender());
2606 QDir
path(item
->data().toString());
2609 outputFolderView
->setCurrentIndex(m_fileSystemModel
->index(path
.canonicalPath()));
2610 outputFolderViewClicked(outputFolderView
->currentIndex());
2611 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
2615 MessageBeep(MB_ICONERROR
);
2616 m_outputFolderFavoritesMenu
->removeAction(item
);
2617 item
->deleteLater();
2623 * Make folder button
2625 void MainWindow::makeFolderButtonClicked(void)
2629 if(!m_fileSystemModel
)
2631 qWarning("File system model not initialized yet!");
2635 QDir
basePath(m_fileSystemModel
->fileInfo(outputFolderView
->currentIndex()).absoluteFilePath());
2636 QString suggestedName
= tr("New Folder");
2638 if(!m_metaData
->fileArtist().isEmpty() && !m_metaData
->fileAlbum().isEmpty())
2640 suggestedName
= QString("%1 - %2").arg(m_metaData
->fileArtist(), m_metaData
->fileAlbum());
2642 else if(!m_metaData
->fileArtist().isEmpty())
2644 suggestedName
= m_metaData
->fileArtist();
2646 else if(!m_metaData
->fileAlbum().isEmpty())
2648 suggestedName
= m_metaData
->fileAlbum();
2652 for(int i
= 0; i
< m_fileListModel
->rowCount(); i
++)
2654 AudioFileModel audioFile
= m_fileListModel
->getFile(m_fileListModel
->index(i
, 0));
2655 if(!audioFile
.fileAlbum().isEmpty() || !audioFile
.fileArtist().isEmpty())
2657 if(!audioFile
.fileArtist().isEmpty() && !audioFile
.fileAlbum().isEmpty())
2659 suggestedName
= QString("%1 - %2").arg(audioFile
.fileArtist(), audioFile
.fileAlbum());
2661 else if(!audioFile
.fileArtist().isEmpty())
2663 suggestedName
= audioFile
.fileArtist();
2665 else if(!audioFile
.fileAlbum().isEmpty())
2667 suggestedName
= audioFile
.fileAlbum();
2674 suggestedName
= lamexp_clean_filename(suggestedName
);
2678 bool bApplied
= false;
2679 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();
2683 folderName
= lamexp_clean_filepath(folderName
.simplified());
2685 if(folderName
.isEmpty())
2687 MessageBeep(MB_ICONERROR
);
2692 QString newFolder
= folderName
;
2694 while(basePath
.exists(newFolder
))
2696 newFolder
= QString(folderName
).append(QString().sprintf(" (%d)", ++i
));
2699 if(basePath
.mkpath(newFolder
))
2701 QDir createdDir
= basePath
;
2702 if(createdDir
.cd(newFolder
))
2704 QModelIndex newIndex
= m_fileSystemModel
->index(createdDir
.canonicalPath());
2705 outputFolderView
->setCurrentIndex(newIndex
);
2706 outputFolderViewClicked(newIndex
);
2707 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
2712 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!")));
2720 * Output to source dir changed
2722 void MainWindow::saveToSourceFolderChanged(void)
2724 m_settings
->outputToSourceDir(saveToSourceFolderCheckBox
->isChecked());
2728 * Prepend relative source file path to output file name changed
2730 void MainWindow::prependRelativePathChanged(void)
2732 m_settings
->prependRelativeSourcePath(prependRelativePathCheckBox
->isChecked());
2736 * Show context menu for output folder
2738 void MainWindow::outputFolderContextMenu(const QPoint
&pos
)
2740 QAbstractScrollArea
*scrollArea
= dynamic_cast<QAbstractScrollArea
*>(QObject::sender());
2741 QWidget
*sender
= scrollArea
? scrollArea
->viewport() : dynamic_cast<QWidget
*>(QObject::sender());
2743 if(pos
.x() <= sender
->width() && pos
.y() <= sender
->height() && pos
.x() >= 0 && pos
.y() >= 0)
2745 m_outputFolderContextMenu
->popup(sender
->mapToGlobal(pos
));
2750 * Show selected folder in explorer
2752 void MainWindow::showFolderContextActionTriggered(void)
2754 if(!m_fileSystemModel
)
2756 qWarning("File system model not initialized yet!");
2760 QString path
= QDir::toNativeSeparators(m_fileSystemModel
->filePath(outputFolderView
->currentIndex()));
2761 if(!path
.endsWith(QDir::separator())) path
.append(QDir::separator());
2762 ShellExecuteW(reinterpret_cast<HWND
>(this->winId()), L
"explore", QWCHAR(path
), NULL
, NULL
, SW_SHOW
);
2766 * Refresh the directory outline
2768 void MainWindow::refreshFolderContextActionTriggered(void)
2770 //force re-initialization
2771 QTimer::singleShot(0, this, SLOT(initOutputFolderModel()));
2775 * Add current folder to favorites
2777 void MainWindow::addFavoriteFolderActionTriggered(void)
2779 QString path
= m_fileSystemModel
->filePath(outputFolderView
->currentIndex());
2780 QStringList favorites
= m_settings
->favoriteOutputFolders().split("|", QString::SkipEmptyParts
);
2782 if(!favorites
.contains(path
, Qt::CaseInsensitive
))
2784 favorites
.append(path
);
2785 while(favorites
.count() > 6) favorites
.removeFirst();
2789 MessageBeep(MB_ICONWARNING
);
2792 m_settings
->favoriteOutputFolders(favorites
.join("|"));
2797 * Output folder edit finished
2799 void MainWindow::outputFolderEditFinished(void)
2801 if(outputFolderEdit
->isHidden())
2803 return; //Not currently in edit mode!
2808 QString text
= QDir::fromNativeSeparators(outputFolderEdit
->text().trimmed());
2809 while(text
.startsWith('"') || text
.startsWith('/')) text
= text
.right(text
.length() - 1).trimmed();
2810 while(text
.endsWith('"') || text
.endsWith('/')) text
= text
.left(text
.length() - 1).trimmed();
2812 static const char *str
= "?*<>|\"";
2813 for(size_t i
= 0; str
[i
]; i
++) text
.replace(str
[i
], "_");
2815 if(!((text
.length() >= 2) && text
.at(0).isLetter() && text
.at(1) == QChar(':')))
2817 text
= QString("%1/%2").arg(QDir::fromNativeSeparators(outputFolderLabel
->text()), text
);
2820 if(text
.length() == 2) text
+= "/"; /* "X:" => "X:/" */
2822 while(text
.length() > 2)
2824 QFileInfo
info(text
);
2825 if(info
.exists() && info
.isDir())
2827 QModelIndex index
= m_fileSystemModel
->index(QFileInfo(info
.canonicalFilePath()).absoluteFilePath());
2831 outputFolderView
->setCurrentIndex(index
);
2832 outputFolderViewClicked(index
);
2836 else if(info
.exists() && info
.isFile())
2838 QModelIndex index
= m_fileSystemModel
->index(QFileInfo(info
.canonicalPath()).absoluteFilePath());
2842 outputFolderView
->setCurrentIndex(index
);
2843 outputFolderViewClicked(index
);
2848 text
= text
.left(text
.length() - 1).trimmed();
2851 outputFolderEdit
->setVisible(false);
2852 outputFolderLabel
->setVisible(true);
2853 outputFolderView
->setEnabled(true);
2855 if(!ok
) MessageBeep(MB_ICONERROR
);
2856 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
2860 * Initialize file system model
2862 void MainWindow::initOutputFolderModel(void)
2864 if(m_outputFolderNoteBox
->isHidden())
2866 m_outputFolderNoteBox
->show();
2867 m_outputFolderNoteBox
->repaint();
2868 m_outputFolderViewInitCounter
= 4;
2870 if(m_fileSystemModel
)
2872 SET_MODEL(outputFolderView
, NULL
);
2873 LAMEXP_DELETE(m_fileSystemModel
);
2874 outputFolderView
->repaint();
2877 if(m_fileSystemModel
= new QFileSystemModelEx())
2879 m_fileSystemModel
->installEventFilter(this);
2880 connect(m_fileSystemModel
, SIGNAL(directoryLoaded(QString
)), this, SLOT(outputFolderDirectoryLoaded(QString
)));
2881 connect(m_fileSystemModel
, SIGNAL(rowsInserted(QModelIndex
,int,int)), this, SLOT(outputFolderRowsInserted(QModelIndex
,int,int)));
2883 SET_MODEL(outputFolderView
, m_fileSystemModel
);
2884 outputFolderView
->header()->setStretchLastSection(true);
2885 outputFolderView
->header()->hideSection(1);
2886 outputFolderView
->header()->hideSection(2);
2887 outputFolderView
->header()->hideSection(3);
2889 m_fileSystemModel
->setRootPath("");
2890 QModelIndex index
= m_fileSystemModel
->index(m_settings
->outputDir());
2891 if(index
.isValid()) outputFolderView
->setCurrentIndex(index
);
2892 outputFolderViewClicked(outputFolderView
->currentIndex());
2895 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
2896 QTimer::singleShot(125, this, SLOT(initOutputFolderModel_doAsync()));
2901 * Initialize file system model (do NOT call this one directly!)
2903 void MainWindow::initOutputFolderModel_doAsync(void)
2905 if(m_outputFolderViewInitCounter
> 0)
2907 m_outputFolderViewInitCounter
--;
2908 QTimer::singleShot(125, this, SLOT(initOutputFolderModel_doAsync()));
2912 QTimer::singleShot(125, m_outputFolderNoteBox
, SLOT(hide()));
2913 outputFolderView
->setFocus();
2918 * Center current folder in view
2920 void MainWindow::centerOutputFolderModel(void)
2922 if(outputFolderView
->isVisible())
2924 centerOutputFolderModel_doAsync();
2925 QTimer::singleShot(125, this, SLOT(centerOutputFolderModel_doAsync()));
2930 * Center current folder in view (do NOT call this one directly!)
2932 void MainWindow::centerOutputFolderModel_doAsync(void)
2934 if(outputFolderView
->isVisible())
2936 m_outputFolderViewCentering
= true;
2937 const QModelIndex index
= outputFolderView
->currentIndex();
2938 outputFolderView
->scrollTo(index
, QAbstractItemView::PositionAtCenter
);
2939 outputFolderView
->setFocus();
2944 * File system model asynchronously loaded a dir
2946 void MainWindow::outputFolderDirectoryLoaded(const QString
&path
)
2948 if(m_outputFolderViewCentering
)
2950 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
2955 * File system model inserted new items
2957 void MainWindow::outputFolderRowsInserted(const QModelIndex
&parent
, int start
, int end
)
2959 if(m_outputFolderViewCentering
)
2961 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
2966 * Directory view item was expanded by user
2968 void MainWindow::outputFolderItemExpanded(const QModelIndex
&item
)
2970 //We need to stop centering as soon as the user has expanded an item manually!
2971 m_outputFolderViewCentering
= false;
2974 // =========================================================
2975 // Metadata tab slots
2976 // =========================================================
2979 * Edit meta button clicked
2981 void MainWindow::editMetaButtonClicked(void)
2985 const QModelIndex index
= metaDataView
->currentIndex();
2989 m_metaInfoModel
->editItem(index
, this);
2991 if(index
.row() == 4)
2993 m_settings
->metaInfoPosition(m_metaData
->filePosition());
2999 * Reset meta button clicked
3001 void MainWindow::clearMetaButtonClicked(void)
3004 m_metaInfoModel
->clearData();
3008 * Meta tags enabled changed
3010 void MainWindow::metaTagsEnabledChanged(void)
3012 m_settings
->writeMetaTags(writeMetaDataCheckBox
->isChecked());
3016 * Playlist enabled changed
3018 void MainWindow::playlistEnabledChanged(void)
3020 m_settings
->createPlaylist(generatePlaylistCheckBox
->isChecked());
3023 // =========================================================
3024 // Compression tab slots
3025 // =========================================================
3030 void MainWindow::updateEncoder(int id
)
3032 m_settings
->compressionEncoder(id
);
3034 switch(m_settings
->compressionEncoder())
3036 case SettingsModel::VorbisEncoder
:
3037 radioButtonModeQuality
->setEnabled(true);
3038 radioButtonModeAverageBitrate
->setEnabled(true);
3039 radioButtonConstBitrate
->setEnabled(false);
3040 if(radioButtonConstBitrate
->isChecked()) radioButtonModeQuality
->setChecked(true);
3041 sliderBitrate
->setEnabled(true);
3043 case SettingsModel::AC3Encoder
:
3044 radioButtonModeQuality
->setEnabled(true);
3045 radioButtonModeQuality
->setChecked(true);
3046 radioButtonModeAverageBitrate
->setEnabled(false);
3047 radioButtonConstBitrate
->setEnabled(true);
3048 sliderBitrate
->setEnabled(true);
3050 case SettingsModel::FLACEncoder
:
3051 radioButtonModeQuality
->setEnabled(false);
3052 radioButtonModeQuality
->setChecked(true);
3053 radioButtonModeAverageBitrate
->setEnabled(false);
3054 radioButtonConstBitrate
->setEnabled(false);
3055 sliderBitrate
->setEnabled(true);
3057 case SettingsModel::PCMEncoder
:
3058 radioButtonModeQuality
->setEnabled(false);
3059 radioButtonModeQuality
->setChecked(true);
3060 radioButtonModeAverageBitrate
->setEnabled(false);
3061 radioButtonConstBitrate
->setEnabled(false);
3062 sliderBitrate
->setEnabled(false);
3064 case SettingsModel::AACEncoder
:
3065 radioButtonModeQuality
->setEnabled(true);
3066 radioButtonModeAverageBitrate
->setEnabled(!m_fhgEncoderAvailable
);
3067 if(m_fhgEncoderAvailable
&& radioButtonModeAverageBitrate
->isChecked()) radioButtonConstBitrate
->setChecked(true);
3068 radioButtonConstBitrate
->setEnabled(true);
3069 sliderBitrate
->setEnabled(true);
3071 case SettingsModel::DCAEncoder
:
3072 radioButtonModeQuality
->setEnabled(false);
3073 radioButtonModeAverageBitrate
->setEnabled(false);
3074 radioButtonConstBitrate
->setEnabled(true);
3075 radioButtonConstBitrate
->setChecked(true);
3076 sliderBitrate
->setEnabled(true);
3079 radioButtonModeQuality
->setEnabled(true);
3080 radioButtonModeAverageBitrate
->setEnabled(true);
3081 radioButtonConstBitrate
->setEnabled(true);
3082 sliderBitrate
->setEnabled(true);
3086 if(m_settings
->compressionEncoder() == SettingsModel::AACEncoder
)
3088 const QString encoderName
= m_qaacEncoderAvailable
? tr("QAAC (Apple)") : (m_fhgEncoderAvailable
? tr("FHG AAC (Winamp)") : (m_neroEncoderAvailable
? tr("Nero AAC") : tr("Not available!")));
3089 labelEncoderInfo
->setVisible(true);
3090 labelEncoderInfo
->setText(tr("Current AAC Encoder: %1").arg(encoderName
));
3094 labelEncoderInfo
->setVisible(false);
3097 updateRCMode(m_modeButtonGroup
->checkedId());
3101 * Update rate-control mode
3103 void MainWindow::updateRCMode(int id
)
3105 m_settings
->compressionRCMode(id
);
3107 switch(m_settings
->compressionEncoder())
3109 case SettingsModel::MP3Encoder
:
3110 switch(m_settings
->compressionRCMode())
3112 case SettingsModel::VBRMode
:
3113 sliderBitrate
->setMinimum(0);
3114 sliderBitrate
->setMaximum(9);
3117 sliderBitrate
->setMinimum(0);
3118 sliderBitrate
->setMaximum(13);
3122 case SettingsModel::VorbisEncoder
:
3123 switch(m_settings
->compressionRCMode())
3125 case SettingsModel::VBRMode
:
3126 sliderBitrate
->setMinimum(-2);
3127 sliderBitrate
->setMaximum(10);
3130 sliderBitrate
->setMinimum(4);
3131 sliderBitrate
->setMaximum(63);
3135 case SettingsModel::AC3Encoder
:
3136 switch(m_settings
->compressionRCMode())
3138 case SettingsModel::VBRMode
:
3139 sliderBitrate
->setMinimum(0);
3140 sliderBitrate
->setMaximum(16);
3143 sliderBitrate
->setMinimum(0);
3144 sliderBitrate
->setMaximum(18);
3148 case SettingsModel::AACEncoder
:
3149 switch(m_settings
->compressionRCMode())
3151 case SettingsModel::VBRMode
:
3152 sliderBitrate
->setMinimum(0);
3153 sliderBitrate
->setMaximum(20);
3156 sliderBitrate
->setMinimum(4);
3157 sliderBitrate
->setMaximum(63);
3161 case SettingsModel::FLACEncoder
:
3162 sliderBitrate
->setMinimum(0);
3163 sliderBitrate
->setMaximum(8);
3165 case SettingsModel::OpusEncoder
:
3166 sliderBitrate
->setMinimum(1);
3167 sliderBitrate
->setMaximum(32);
3169 case SettingsModel::DCAEncoder
:
3170 sliderBitrate
->setMinimum(1);
3171 sliderBitrate
->setMaximum(128);
3173 case SettingsModel::PCMEncoder
:
3174 sliderBitrate
->setMinimum(0);
3175 sliderBitrate
->setMaximum(2);
3176 sliderBitrate
->setValue(1);
3179 sliderBitrate
->setMinimum(0);
3180 sliderBitrate
->setMaximum(0);
3184 updateBitrate(sliderBitrate
->value());
3190 void MainWindow::updateBitrate(int value
)
3192 m_settings
->compressionBitrate(value
);
3194 switch(m_settings
->compressionRCMode())
3196 case SettingsModel::VBRMode
:
3197 switch(m_settings
->compressionEncoder())
3199 case SettingsModel::MP3Encoder
:
3200 labelBitrate
->setText(tr("Quality Level %1").arg(9 - value
));
3202 case SettingsModel::VorbisEncoder
:
3203 labelBitrate
->setText(tr("Quality Level %1").arg(value
));
3205 case SettingsModel::AACEncoder
:
3206 labelBitrate
->setText(tr("Quality Level %1").arg(QString().sprintf("%.2f", static_cast<double>(value
* 5) / 100.0)));
3208 case SettingsModel::FLACEncoder
:
3209 labelBitrate
->setText(tr("Compression %1").arg(value
));
3211 case SettingsModel::OpusEncoder
:
3212 labelBitrate
->setText(QString("≈ %1 kbps").arg(qMin(500, value
* 8)));
3214 case SettingsModel::AC3Encoder
:
3215 labelBitrate
->setText(tr("Quality Level %1").arg(qMin(1024, qMax(0, value
* 64))));
3217 case SettingsModel::PCMEncoder
:
3218 labelBitrate
->setText(tr("Uncompressed"));
3221 labelBitrate
->setText(QString::number(value
));
3225 case SettingsModel::ABRMode
:
3226 switch(m_settings
->compressionEncoder())
3228 case SettingsModel::MP3Encoder
:
3229 labelBitrate
->setText(QString("≈ %1 kbps").arg(SettingsModel::mp3Bitrates
[value
]));
3231 case SettingsModel::FLACEncoder
:
3232 labelBitrate
->setText(tr("Compression %1").arg(value
));
3234 case SettingsModel::AC3Encoder
:
3235 labelBitrate
->setText(QString("≈ %1 kbps").arg(SettingsModel::ac3Bitrates
[value
]));
3237 case SettingsModel::PCMEncoder
:
3238 labelBitrate
->setText(tr("Uncompressed"));
3241 labelBitrate
->setText(QString("≈ %1 kbps").arg(qMin(500, value
* 8)));
3246 switch(m_settings
->compressionEncoder())
3248 case SettingsModel::MP3Encoder
:
3249 labelBitrate
->setText(QString("%1 kbps").arg(SettingsModel::mp3Bitrates
[value
]));
3251 case SettingsModel::FLACEncoder
:
3252 labelBitrate
->setText(tr("Compression %1").arg(value
));
3254 case SettingsModel::AC3Encoder
:
3255 labelBitrate
->setText(QString("%1 kbps").arg(SettingsModel::ac3Bitrates
[value
]));
3257 case SettingsModel::DCAEncoder
:
3258 labelBitrate
->setText(QString("%1 kbps").arg(value
* 32));
3260 case SettingsModel::PCMEncoder
:
3261 labelBitrate
->setText(tr("Uncompressed"));
3264 labelBitrate
->setText(QString("%1 kbps").arg(qMin(500, value
* 8)));
3271 // =========================================================
3272 // Advanced option slots
3273 // =========================================================
3276 * Lame algorithm quality changed
3278 void MainWindow::updateLameAlgoQuality(int value
)
3285 text
= tr("Best Quality (Very Slow)");
3288 text
= tr("High Quality (Recommended)");
3291 text
= tr("Average Quality (Default)");
3294 text
= tr("Low Quality (Fast)");
3297 text
= tr("Poor Quality (Very Fast)");
3303 m_settings
->lameAlgoQuality(value
);
3304 labelLameAlgoQuality
->setText(text
);
3307 bool warning
= (value
== 0), notice
= (value
== 4);
3308 labelLameAlgoQualityWarning
->setVisible(warning
);
3309 labelLameAlgoQualityWarningIcon
->setVisible(warning
);
3310 labelLameAlgoQualityNotice
->setVisible(notice
);
3311 labelLameAlgoQualityNoticeIcon
->setVisible(notice
);
3312 labelLameAlgoQualitySpacer
->setVisible(warning
|| notice
);
3316 * Bitrate management endabled/disabled
3318 void MainWindow::bitrateManagementEnabledChanged(bool checked
)
3320 m_settings
->bitrateManagementEnabled(checked
);
3324 * Minimum bitrate has changed
3326 void MainWindow::bitrateManagementMinChanged(int value
)
3328 if(value
> spinBoxBitrateManagementMax
->value())
3330 spinBoxBitrateManagementMin
->setValue(spinBoxBitrateManagementMax
->value());
3331 m_settings
->bitrateManagementMinRate(spinBoxBitrateManagementMax
->value());
3335 m_settings
->bitrateManagementMinRate(value
);
3340 * Maximum bitrate has changed
3342 void MainWindow::bitrateManagementMaxChanged(int value
)
3344 if(value
< spinBoxBitrateManagementMin
->value())
3346 spinBoxBitrateManagementMax
->setValue(spinBoxBitrateManagementMin
->value());
3347 m_settings
->bitrateManagementMaxRate(spinBoxBitrateManagementMin
->value());
3351 m_settings
->bitrateManagementMaxRate(value
);
3356 * Channel mode has changed
3358 void MainWindow::channelModeChanged(int value
)
3360 if(value
>= 0) m_settings
->lameChannelMode(value
);
3364 * Sampling rate has changed
3366 void MainWindow::samplingRateChanged(int value
)
3368 if(value
>= 0) m_settings
->samplingRate(value
);
3372 * Nero AAC 2-Pass mode changed
3374 void MainWindow::neroAAC2PassChanged(bool checked
)
3376 m_settings
->neroAACEnable2Pass(checked
);
3380 * Nero AAC profile mode changed
3382 void MainWindow::neroAACProfileChanged(int value
)
3384 if(value
>= 0) m_settings
->aacEncProfile(value
);
3388 * Aften audio coding mode changed
3390 void MainWindow::aftenCodingModeChanged(int value
)
3392 if(value
>= 0) m_settings
->aftenAudioCodingMode(value
);
3396 * Aften DRC mode changed
3398 void MainWindow::aftenDRCModeChanged(int value
)
3400 if(value
>= 0) m_settings
->aftenDynamicRangeCompression(value
);
3404 * Aften exponent search size changed
3406 void MainWindow::aftenSearchSizeChanged(int value
)
3408 if(value
>= 0) m_settings
->aftenExponentSearchSize(value
);
3412 * Aften fast bit allocation changed
3414 void MainWindow::aftenFastAllocationChanged(bool checked
)
3416 m_settings
->aftenFastBitAllocation(checked
);
3421 * Opus encoder settings changed
3423 void MainWindow::opusSettingsChanged(void)
3425 m_settings
->opusOptimizeFor(comboBoxOpusOptimize
->currentIndex());
3426 m_settings
->opusFramesize(comboBoxOpusFramesize
->currentIndex());
3427 m_settings
->opusComplexity(spinBoxOpusComplexity
->value());
3431 * Normalization filter enabled changed
3433 void MainWindow::normalizationEnabledChanged(bool checked
)
3435 m_settings
->normalizationFilterEnabled(checked
);
3439 * Normalization max. volume changed
3441 void MainWindow::normalizationMaxVolumeChanged(double value
)
3443 m_settings
->normalizationFilterMaxVolume(static_cast<int>(value
* 100.0));
3447 * Normalization equalization mode changed
3449 void MainWindow::normalizationModeChanged(int mode
)
3451 m_settings
->normalizationFilterEqualizationMode(mode
);
3455 * Tone adjustment has changed (Bass)
3457 void MainWindow::toneAdjustBassChanged(double value
)
3459 m_settings
->toneAdjustBass(static_cast<int>(value
* 100.0));
3460 spinBoxToneAdjustBass
->setPrefix((value
> 0) ? "+" : QString());
3464 * Tone adjustment has changed (Treble)
3466 void MainWindow::toneAdjustTrebleChanged(double value
)
3468 m_settings
->toneAdjustTreble(static_cast<int>(value
* 100.0));
3469 spinBoxToneAdjustTreble
->setPrefix((value
> 0) ? "+" : QString());
3473 * Tone adjustment has been reset
3475 void MainWindow::toneAdjustTrebleReset(void)
3477 spinBoxToneAdjustBass
->setValue(m_settings
->toneAdjustBassDefault());
3478 spinBoxToneAdjustTreble
->setValue(m_settings
->toneAdjustTrebleDefault());
3479 toneAdjustBassChanged(spinBoxToneAdjustBass
->value());
3480 toneAdjustTrebleChanged(spinBoxToneAdjustTreble
->value());
3484 * Custom encoder parameters changed
3486 void MainWindow::customParamsChanged(void)
3488 lineEditCustomParamLAME
->setText(lineEditCustomParamLAME
->text().simplified());
3489 lineEditCustomParamOggEnc
->setText(lineEditCustomParamOggEnc
->text().simplified());
3490 lineEditCustomParamNeroAAC
->setText(lineEditCustomParamNeroAAC
->text().simplified());
3491 lineEditCustomParamFLAC
->setText(lineEditCustomParamFLAC
->text().simplified());
3492 lineEditCustomParamAften
->setText(lineEditCustomParamAften
->text().simplified());
3494 bool customParamsUsed
= false;
3495 if(!lineEditCustomParamLAME
->text().isEmpty()) customParamsUsed
= true;
3496 if(!lineEditCustomParamOggEnc
->text().isEmpty()) customParamsUsed
= true;
3497 if(!lineEditCustomParamNeroAAC
->text().isEmpty()) customParamsUsed
= true;
3498 if(!lineEditCustomParamFLAC
->text().isEmpty()) customParamsUsed
= true;
3499 if(!lineEditCustomParamAften
->text().isEmpty()) customParamsUsed
= true;
3501 labelCustomParamsIcon
->setVisible(customParamsUsed
);
3502 labelCustomParamsText
->setVisible(customParamsUsed
);
3503 labelCustomParamsSpacer
->setVisible(customParamsUsed
);
3505 m_settings
->customParametersLAME(lineEditCustomParamLAME
->text());
3506 m_settings
->customParametersOggEnc(lineEditCustomParamOggEnc
->text());
3507 m_settings
->customParametersAacEnc(lineEditCustomParamNeroAAC
->text());
3508 m_settings
->customParametersFLAC(lineEditCustomParamFLAC
->text());
3509 m_settings
->customParametersAften(lineEditCustomParamAften
->text());
3514 * Rename output files enabled changed
3516 void MainWindow::renameOutputEnabledChanged(bool checked
)
3518 m_settings
->renameOutputFilesEnabled(checked
);
3522 * Rename output files patterm changed
3524 void MainWindow::renameOutputPatternChanged(void)
3526 QString temp
= lineEditRenamePattern
->text().simplified();
3527 lineEditRenamePattern
->setText(temp
.isEmpty() ? m_settings
->renameOutputFilesPatternDefault() : temp
);
3528 m_settings
->renameOutputFilesPattern(lineEditRenamePattern
->text());
3532 * Rename output files patterm changed
3534 void MainWindow::renameOutputPatternChanged(const QString
&text
)
3536 QString
pattern(text
.simplified());
3538 pattern
.replace("<BaseName>", "The_White_Stripes_-_Fell_In_Love_With_A_Girl", Qt::CaseInsensitive
);
3539 pattern
.replace("<TrackNo>", "04", Qt::CaseInsensitive
);
3540 pattern
.replace("<Title>", "Fell In Love With A Girl", Qt::CaseInsensitive
);
3541 pattern
.replace("<Artist>", "The White Stripes", Qt::CaseInsensitive
);
3542 pattern
.replace("<Album>", "White Blood Cells", Qt::CaseInsensitive
);
3543 pattern
.replace("<Year>", "2001", Qt::CaseInsensitive
);
3544 pattern
.replace("<Comment>", "Encoded by LameXP", Qt::CaseInsensitive
);
3546 if(pattern
.compare(lamexp_clean_filename(pattern
)))
3548 if(lineEditRenamePattern
->palette().color(QPalette::Text
) != Qt::red
)
3550 MessageBeep(MB_ICONERROR
);
3551 SET_TEXT_COLOR(lineEditRenamePattern
, Qt::red
);
3556 if(lineEditRenamePattern
->palette().color(QPalette::Text
) != Qt::black
)
3558 MessageBeep(MB_ICONINFORMATION
);
3559 SET_TEXT_COLOR(lineEditRenamePattern
, Qt::black
);
3563 labelRanameExample
->setText(lamexp_clean_filename(pattern
));
3567 * Show list of rename macros
3569 void MainWindow::showRenameMacros(const QString
&text
)
3571 if(text
.compare("reset", Qt::CaseInsensitive
) == 0)
3573 lineEditRenamePattern
->setText(m_settings
->renameOutputFilesPatternDefault());
3577 const QString format
= QString("<tr><td><tt><%1></tt></td><td> </td><td>%2</td></tr>");
3579 QString message
= QString("<table>");
3580 message
+= QString(format
).arg("BaseName", tr("File name without extension"));
3581 message
+= QString(format
).arg("TrackNo", tr("Track number with leading zero"));
3582 message
+= QString(format
).arg("Title", tr("Track title"));
3583 message
+= QString(format
).arg("Artist", tr("Artist name"));
3584 message
+= QString(format
).arg("Album", tr("Album name"));
3585 message
+= QString(format
).arg("Year", tr("Year with (at least) four digits"));
3586 message
+= QString(format
).arg("Comment", tr("Comment"));
3587 message
+= "</table><br><br>";
3588 message
+= QString("%1<br>").arg(tr("Characters forbidden in file names:"));
3589 message
+= "<b><tt>\\ / : * ? < > |<br>";
3591 QMessageBox::information(this, tr("Rename Macros"), message
, tr("Discard"));
3594 void MainWindow::forceStereoDownmixEnabledChanged(bool checked
)
3596 m_settings
->forceStereoDownmix(checked
);
3600 * Maximum number of instances changed
3602 void MainWindow::updateMaximumInstances(int value
)
3604 labelMaxInstances
->setText(tr("%1 Instance(s)").arg(QString::number(value
)));
3605 m_settings
->maximumInstances(checkBoxAutoDetectInstances
->isChecked() ? NULL
: value
);
3609 * Auto-detect number of instances
3611 void MainWindow::autoDetectInstancesChanged(bool checked
)
3613 m_settings
->maximumInstances(checked
? NULL
: sliderMaxInstances
->value());
3617 * Browse for custom TEMP folder button clicked
3619 void MainWindow::browseCustomTempFolderButtonClicked(void)
3621 QString newTempFolder
;
3623 if(USE_NATIVE_FILE_DIALOG
)
3625 newTempFolder
= QFileDialog::getExistingDirectory(this, QString(), m_settings
->customTempPath());
3629 QFileDialog
dialog(this);
3630 dialog
.setFileMode(QFileDialog::DirectoryOnly
);
3631 dialog
.setDirectory(m_settings
->customTempPath());
3634 newTempFolder
= dialog
.selectedFiles().first();
3638 if(!newTempFolder
.isEmpty())
3640 QFile
writeTest(QString("%1/~%2.tmp").arg(newTempFolder
, lamexp_rand_str()));
3641 if(writeTest
.open(QIODevice::ReadWrite
))
3644 lineEditCustomTempFolder
->setText(QDir::toNativeSeparators(newTempFolder
));
3648 QMessageBox::warning(this, tr("Access Denied"), tr("Cannot write to the selected directory. Please choose another directory!"));
3654 * Custom TEMP folder changed
3656 void MainWindow::customTempFolderChanged(const QString
&text
)
3658 m_settings
->customTempPath(QDir::fromNativeSeparators(text
));
3662 * Use custom TEMP folder option changed
3664 void MainWindow::useCustomTempFolderChanged(bool checked
)
3666 m_settings
->customTempPathEnabled(!checked
);
3670 * Reset all advanced options to their defaults
3672 void MainWindow::resetAdvancedOptionsButtonClicked(void)
3674 sliderLameAlgoQuality
->setValue(m_settings
->lameAlgoQualityDefault());
3675 spinBoxBitrateManagementMin
->setValue(m_settings
->bitrateManagementMinRateDefault());
3676 spinBoxBitrateManagementMax
->setValue(m_settings
->bitrateManagementMaxRateDefault());
3677 spinBoxNormalizationFilter
->setValue(static_cast<double>(m_settings
->normalizationFilterMaxVolumeDefault()) / 100.0);
3678 spinBoxToneAdjustBass
->setValue(static_cast<double>(m_settings
->toneAdjustBassDefault()) / 100.0);
3679 spinBoxToneAdjustTreble
->setValue(static_cast<double>(m_settings
->toneAdjustTrebleDefault()) / 100.0);
3680 spinBoxAftenSearchSize
->setValue(m_settings
->aftenExponentSearchSizeDefault());
3681 spinBoxOpusComplexity
->setValue(m_settings
->opusComplexityDefault());
3682 comboBoxMP3ChannelMode
->setCurrentIndex(m_settings
->lameChannelModeDefault());
3683 comboBoxSamplingRate
->setCurrentIndex(m_settings
->samplingRateDefault());
3684 comboBoxAACProfile
->setCurrentIndex(m_settings
->aacEncProfileDefault());
3685 comboBoxAftenCodingMode
->setCurrentIndex(m_settings
->aftenAudioCodingModeDefault());
3686 comboBoxAftenDRCMode
->setCurrentIndex(m_settings
->aftenDynamicRangeCompressionDefault());
3687 comboBoxNormalizationMode
->setCurrentIndex(m_settings
->normalizationFilterEqualizationModeDefault());
3688 comboBoxOpusOptimize
->setCurrentIndex(m_settings
->opusOptimizeForDefault());
3689 comboBoxOpusFramesize
->setCurrentIndex(m_settings
->opusFramesizeDefault());
3690 while(checkBoxBitrateManagement
->isChecked() != m_settings
->bitrateManagementEnabledDefault()) checkBoxBitrateManagement
->click();
3691 while(checkBoxNeroAAC2PassMode
->isChecked() != m_settings
->neroAACEnable2PassDefault()) checkBoxNeroAAC2PassMode
->click();
3692 while(checkBoxNormalizationFilter
->isChecked() != m_settings
->normalizationFilterEnabledDefault()) checkBoxNormalizationFilter
->click();
3693 while(checkBoxAutoDetectInstances
->isChecked() != (m_settings
->maximumInstancesDefault() < 1)) checkBoxAutoDetectInstances
->click();
3694 while(checkBoxUseSystemTempFolder
->isChecked() == m_settings
->customTempPathEnabledDefault()) checkBoxUseSystemTempFolder
->click();
3695 while(checkBoxAftenFastAllocation
->isChecked() != m_settings
->aftenFastBitAllocationDefault()) checkBoxAftenFastAllocation
->click();
3696 while(checkBoxRenameOutput
->isChecked() != m_settings
->renameOutputFilesEnabledDefault()) checkBoxRenameOutput
->click();
3697 while(checkBoxForceStereoDownmix
->isChecked() != m_settings
->forceStereoDownmixDefault()) checkBoxForceStereoDownmix
->click();
3698 lineEditCustomParamLAME
->setText(m_settings
->customParametersLAMEDefault());
3699 lineEditCustomParamOggEnc
->setText(m_settings
->customParametersOggEncDefault());
3700 lineEditCustomParamNeroAAC
->setText(m_settings
->customParametersAacEncDefault());
3701 lineEditCustomParamFLAC
->setText(m_settings
->customParametersFLACDefault());
3702 lineEditCustomTempFolder
->setText(QDir::toNativeSeparators(m_settings
->customTempPathDefault()));
3703 lineEditRenamePattern
->setText(m_settings
->renameOutputFilesPatternDefault());
3704 customParamsChanged();
3705 scrollArea
->verticalScrollBar()->setValue(0);
3708 // =========================================================
3709 // Multi-instance handling slots
3710 // =========================================================
3713 * Other instance detected
3715 void MainWindow::notifyOtherInstance(void)
3717 if(!m_banner
->isVisible())
3719 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
);
3725 * Add file from another instance
3727 void MainWindow::addFileDelayed(const QString
&filePath
, bool tryASAP
)
3729 if(tryASAP
&& !m_delayedFileTimer
->isActive())
3731 qDebug("Received file: %s", filePath
.toUtf8().constData());
3732 m_delayedFileList
->append(filePath
);
3733 QTimer::singleShot(0, this, SLOT(handleDelayedFiles()));
3736 m_delayedFileTimer
->stop();
3737 qDebug("Received file: %s", filePath
.toUtf8().constData());
3738 m_delayedFileList
->append(filePath
);
3739 m_delayedFileTimer
->start(5000);
3743 * Add files from another instance
3745 void MainWindow::addFilesDelayed(const QStringList
&filePaths
, bool tryASAP
)
3747 if(tryASAP
&& !m_delayedFileTimer
->isActive())
3749 qDebug("Received %d file(s).", filePaths
.count());
3750 m_delayedFileList
->append(filePaths
);
3751 QTimer::singleShot(0, this, SLOT(handleDelayedFiles()));
3755 m_delayedFileTimer
->stop();
3756 qDebug("Received %d file(s).", filePaths
.count());
3757 m_delayedFileList
->append(filePaths
);
3758 m_delayedFileTimer
->start(5000);
3763 * Add folder from another instance
3765 void MainWindow::addFolderDelayed(const QString
&folderPath
, bool recursive
)
3767 if(!m_banner
->isVisible())
3769 addFolder(folderPath
, recursive
, true);
3773 // =========================================================
3775 // =========================================================
3778 * Restore the override cursor
3780 void MainWindow::restoreCursor(void)
3782 QApplication::restoreOverrideCursor();