1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2015 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, but always including the *additional*
9 // restrictions defined in the "License.txt" file.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this program; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 // http://www.gnu.org/licenses/gpl-2.0.txt
21 ///////////////////////////////////////////////////////////////////////////////
23 #include "Dialog_MainWindow.h"
26 #include "UIC_MainWindow.h"
30 #include "Dialog_WorkingBanner.h"
31 #include "Dialog_MetaInfo.h"
32 #include "Dialog_About.h"
33 #include "Dialog_Update.h"
34 #include "Dialog_DropBox.h"
35 #include "Dialog_CueImport.h"
36 #include "Dialog_LogView.h"
37 #include "Thread_FileAnalyzer.h"
38 #include "Thread_MessageHandler.h"
39 #include "Model_MetaInfo.h"
40 #include "Model_Settings.h"
41 #include "Model_FileList.h"
42 #include "Model_FileSystem.h"
43 #include "Model_FileExts.h"
44 #include "Registry_Encoder.h"
45 #include "Registry_Decoder.h"
46 #include "Encoder_Abstract.h"
47 #include "ShellIntegration.h"
48 #include "CustomEventFilter.h"
51 #include <MUtils/Global.h>
52 #include <MUtils/OSSupport.h>
53 #include <MUtils/GUI.h>
54 #include <MUtils/Exception.h>
55 #include <MUtils/Sound.h>
56 #include <MUtils/Translation.h>
57 #include <MUtils/Version.h>
60 #include <QMessageBox>
62 #include <QDesktopWidget>
64 #include <QFileDialog>
65 #include <QInputDialog>
66 #include <QFileSystemModel>
67 #include <QDesktopServices>
69 #include <QPlastiqueStyle>
70 #include <QCleanlooksStyle>
71 #include <QWindowsVistaStyle>
72 #include <QWindowsStyle>
74 #include <QDragEnterEvent>
78 #include <QProcessEnvironment>
79 #include <QCryptographicHash>
80 #include <QTranslator>
84 ////////////////////////////////////////////////////////////
86 ////////////////////////////////////////////////////////////
88 #define BANNER_VISIBLE ((m_banner != NULL) && m_banner->isVisible())
90 #define INIT_BANNER() do \
92 if(m_banner == NULL) \
94 m_banner = new WorkingBanner(this); \
99 #define SHOW_BANNER(TXT) do \
102 m_banner->show((TXT)); \
106 #define SHOW_BANNER_ARG(TXT, ARG) do \
109 m_banner->show((TXT), (ARG)); \
114 #define SHOW_BANNER_CONDITIONALLY(FLAG, TEST, TXT) do \
116 if((!(FLAG)) && ((TEST))) \
119 m_banner->show((TXT)); \
125 #define ABORT_IF_BUSY do \
127 if(BANNER_VISIBLE || m_delayedFileTimer->isActive() || (QApplication::activeModalWidget() != NULL)) \
129 MUtils::Sound::beep(MUtils::Sound::BEEP_WRN); \
135 #define SET_TEXT_COLOR(WIDGET, COLOR) do \
137 QPalette _palette = WIDGET->palette(); \
138 _palette.setColor(QPalette::WindowText, (COLOR)); \
139 _palette.setColor(QPalette::Text, (COLOR)); \
140 WIDGET->setPalette(_palette); \
144 #define SET_FONT_BOLD(WIDGET,BOLD) do \
146 QFont _font = WIDGET->font(); \
147 _font.setBold(BOLD); \
148 WIDGET->setFont(_font); \
152 #define TEMP_HIDE_DROPBOX(CMD) do \
154 bool _dropBoxVisible = m_dropBox->isVisible(); \
155 if(_dropBoxVisible) m_dropBox->hide(); \
156 do { CMD } while(0); \
157 if(_dropBoxVisible) m_dropBox->show(); \
161 #define SET_MODEL(VIEW, MODEL) do \
163 QItemSelectionModel *_tmp = (VIEW)->selectionModel(); \
164 (VIEW)->setModel(MODEL); \
165 MUTILS_DELETE(_tmp); \
169 #define SET_CHECKBOX_STATE(CHCKBX, STATE) do \
171 const bool isDisabled = (!(CHCKBX)->isEnabled()); \
174 (CHCKBX)->setEnabled(true); \
176 if((CHCKBX)->isChecked() != (STATE)) \
180 if((CHCKBX)->isChecked() != (STATE)) \
182 qWarning("Warning: Failed to set checkbox " #CHCKBX " state!"); \
186 (CHCKBX)->setEnabled(false); \
191 #define TRIM_STRING_RIGHT(STR) do \
193 while((STR.length() > 0) && STR[STR.length()-1].isSpace()) STR.chop(1); \
197 #define MAKE_TRANSPARENT(WIDGET, FLAG) do \
199 QPalette _p = (WIDGET)->palette(); \
200 _p.setColor(QPalette::Background, Qt::transparent); \
201 (WIDGET)->setPalette(FLAG ? _p : QPalette()); \
205 #define WITH_BLOCKED_SIGNALS(WIDGET, CMD, ...) do \
207 const bool _flag = (WIDGET)->blockSignals(true); \
208 (WIDGET)->CMD(__VA_ARGS__); \
209 if(!(_flag)) { (WIDGET)->blockSignals(false); } \
213 #define PLAY_SOUND_OPTIONAL(NAME, ASYNC) do \
215 if(m_settings->soundsEnabled()) MUtils::Sound::play_sound((NAME), (ASYNC)); \
219 #define SHOW_CORNER_WIDGET(FLAG) do \
221 if(QWidget *cornerWidget = ui->menubar->cornerWidget()) \
223 cornerWidget->setVisible((FLAG)); \
228 #define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(QString(URL).replace("-", "−"))
229 #define FSLINK(PATH) QString("<a href=\"file:///%1\">%2</a>").arg(PATH).arg(QString(PATH).replace("-", "−"))
230 #define CENTER_CURRENT_OUTPUT_FOLDER_DELAYED QTimer::singleShot(125, this, SLOT(centerOutputFolderModel()))
232 static const unsigned int IDM_ABOUTBOX
= 0xEFF0;
233 static const char *g_hydrogen_audio_url
= "http://wiki.hydrogenaud.io/index.php?title=Main_Page";
234 static const char *g_documents_base_url
= "http://lamexp.sourceforge.net/doc";
236 ////////////////////////////////////////////////////////////
238 ////////////////////////////////////////////////////////////
240 MainWindow::MainWindow(MUtils::IPCChannel
*const ipcChannel
, FileListModel
*const fileListModel
, AudioFileModel_MetaInfo
*const metaInfo
, SettingsModel
*const settingsModel
, QWidget
*const parent
)
243 ui(new Ui::MainWindow
),
244 m_fileListModel(fileListModel
),
245 m_metaData(metaInfo
),
246 m_settings(settingsModel
),
247 m_fileSystemModel(NULL
),
250 m_firstTimeShown(true),
251 m_outputFolderViewCentering(false),
252 m_outputFolderViewInitCounter(0)
254 //Init the dialog, from the .ui file
256 setWindowFlags(windowFlags() ^ Qt::WindowMaximizeButtonHint
);
259 MUtils::GUI::set_window_icon(this, lamexp_app_icon(), true);
261 //Register meta types
262 qRegisterMetaType
<AudioFileModel
>("AudioFileModel");
264 //Enabled main buttons
265 connect(ui
->buttonAbout
, SIGNAL(clicked()), this, SLOT(aboutButtonClicked()));
266 connect(ui
->buttonStart
, SIGNAL(clicked()), this, SLOT(encodeButtonClicked()));
267 connect(ui
->buttonQuit
, SIGNAL(clicked()), this, SLOT(closeButtonClicked()));
270 ui
->tabWidget
->setCurrentIndex(0);
271 connect(ui
->tabWidget
, SIGNAL(currentChanged(int)), this, SLOT(tabPageChanged(int)));
274 MUtils::GUI::sysmenu_append(this, IDM_ABOUTBOX
, "About...");
276 //Setup corner widget
277 QLabel
*cornerWidget
= new QLabel(ui
->menubar
);
278 m_evenFilterCornerWidget
= new CustomEventFilter
;
279 cornerWidget
->setText("N/A");
280 cornerWidget
->setFixedHeight(ui
->menubar
->height());
281 cornerWidget
->setCursor(QCursor(Qt::PointingHandCursor
));
282 cornerWidget
->hide();
283 cornerWidget
->installEventFilter(m_evenFilterCornerWidget
);
284 connect(m_evenFilterCornerWidget
, SIGNAL(eventOccurred(QWidget
*, QEvent
*)), this, SLOT(cornerWidgetEventOccurred(QWidget
*, QEvent
*)));
285 ui
->menubar
->setCornerWidget(cornerWidget
);
287 //--------------------------------
288 // Setup "Source" tab
289 //--------------------------------
291 ui
->sourceFileView
->setModel(m_fileListModel
);
292 ui
->sourceFileView
->verticalHeader() ->setResizeMode(QHeaderView::ResizeToContents
);
293 ui
->sourceFileView
->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents
);
294 ui
->sourceFileView
->setContextMenuPolicy(Qt::CustomContextMenu
);
295 ui
->sourceFileView
->viewport()->installEventFilter(this);
296 m_dropNoteLabel
= new QLabel(ui
->sourceFileView
);
297 m_dropNoteLabel
->setAlignment(Qt::AlignHCenter
| Qt::AlignVCenter
);
298 SET_FONT_BOLD(m_dropNoteLabel
, true);
299 SET_TEXT_COLOR(m_dropNoteLabel
, Qt::darkGray
);
300 m_sourceFilesContextMenu
= new QMenu();
301 m_showDetailsContextAction
= m_sourceFilesContextMenu
->addAction(QIcon(":/icons/zoom.png"), "N/A");
302 m_previewContextAction
= m_sourceFilesContextMenu
->addAction(QIcon(":/icons/sound.png"), "N/A");
303 m_findFileContextAction
= m_sourceFilesContextMenu
->addAction(QIcon(":/icons/folder_go.png"), "N/A");
304 m_sourceFilesContextMenu
->addSeparator();
305 m_exportCsvContextAction
= m_sourceFilesContextMenu
->addAction(QIcon(":/icons/table_save.png"), "N/A");
306 m_importCsvContextAction
= m_sourceFilesContextMenu
->addAction(QIcon(":/icons/folder_table.png"), "N/A");
307 SET_FONT_BOLD(m_showDetailsContextAction
, true);
309 connect(ui
->buttonAddFiles
, SIGNAL(clicked()), this, SLOT(addFilesButtonClicked()));
310 connect(ui
->buttonRemoveFile
, SIGNAL(clicked()), this, SLOT(removeFileButtonClicked()));
311 connect(ui
->buttonClearFiles
, SIGNAL(clicked()), this, SLOT(clearFilesButtonClicked()));
312 connect(ui
->buttonFileUp
, SIGNAL(clicked()), this, SLOT(fileUpButtonClicked()));
313 connect(ui
->buttonFileDown
, SIGNAL(clicked()), this, SLOT(fileDownButtonClicked()));
314 connect(ui
->buttonShowDetails
, SIGNAL(clicked()), this, SLOT(showDetailsButtonClicked()));
315 connect(m_fileListModel
, SIGNAL(rowsInserted(QModelIndex
,int,int)), this, SLOT(sourceModelChanged()));
316 connect(m_fileListModel
, SIGNAL(rowsRemoved(QModelIndex
,int,int)), this, SLOT(sourceModelChanged()));
317 connect(m_fileListModel
, SIGNAL(modelReset()), this, SLOT(sourceModelChanged()));
318 connect(ui
->sourceFileView
, SIGNAL(customContextMenuRequested(QPoint
)), this, SLOT(sourceFilesContextMenu(QPoint
)));
319 connect(ui
->sourceFileView
->verticalScrollBar(), SIGNAL(sliderMoved(int)), this, SLOT(sourceFilesScrollbarMoved(int)));
320 connect(ui
->sourceFileView
->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(sourceFilesScrollbarMoved(int)));
321 connect(m_showDetailsContextAction
, SIGNAL(triggered(bool)), this, SLOT(showDetailsButtonClicked()));
322 connect(m_previewContextAction
, SIGNAL(triggered(bool)), this, SLOT(previewContextActionTriggered()));
323 connect(m_findFileContextAction
, SIGNAL(triggered(bool)), this, SLOT(findFileContextActionTriggered()));
324 connect(m_exportCsvContextAction
, SIGNAL(triggered(bool)), this, SLOT(exportCsvContextActionTriggered()));
325 connect(m_importCsvContextAction
, SIGNAL(triggered(bool)), this, SLOT(importCsvContextActionTriggered()));
327 //--------------------------------
328 // Setup "Output" tab
329 //--------------------------------
331 ui
->outputFolderView
->setHeaderHidden(true);
332 ui
->outputFolderView
->setAnimated(false);
333 ui
->outputFolderView
->setMouseTracking(false);
334 ui
->outputFolderView
->setContextMenuPolicy(Qt::CustomContextMenu
);
335 ui
->outputFolderView
->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn
);
337 m_evenFilterOutputFolderMouse
= new CustomEventFilter
;
338 ui
->outputFoldersGoUpLabel
->installEventFilter(m_evenFilterOutputFolderMouse
);
339 ui
->outputFoldersEditorLabel
->installEventFilter(m_evenFilterOutputFolderMouse
);
340 ui
->outputFoldersFovoritesLabel
->installEventFilter(m_evenFilterOutputFolderMouse
);
341 ui
->outputFolderLabel
->installEventFilter(m_evenFilterOutputFolderMouse
);
343 m_evenFilterOutputFolderView
= new CustomEventFilter
;
344 ui
->outputFolderView
->installEventFilter(m_evenFilterOutputFolderView
);
346 SET_CHECKBOX_STATE(ui
->saveToSourceFolderCheckBox
, m_settings
->outputToSourceDir());
347 ui
->prependRelativePathCheckBox
->setChecked(m_settings
->prependRelativeSourcePath());
349 connect(ui
->outputFolderView
, SIGNAL(clicked(QModelIndex
)), this, SLOT(outputFolderViewClicked(QModelIndex
)));
350 connect(ui
->outputFolderView
, SIGNAL(activated(QModelIndex
)), this, SLOT(outputFolderViewClicked(QModelIndex
)));
351 connect(ui
->outputFolderView
, SIGNAL(pressed(QModelIndex
)), this, SLOT(outputFolderViewClicked(QModelIndex
)));
352 connect(ui
->outputFolderView
, SIGNAL(entered(QModelIndex
)), this, SLOT(outputFolderViewMoved(QModelIndex
)));
353 connect(ui
->outputFolderView
, SIGNAL(expanded(QModelIndex
)), this, SLOT(outputFolderItemExpanded(QModelIndex
)));
354 connect(ui
->buttonMakeFolder
, SIGNAL(clicked()), this, SLOT(makeFolderButtonClicked()));
355 connect(ui
->buttonGotoHome
, SIGNAL(clicked()), SLOT(gotoHomeFolderButtonClicked()));
356 connect(ui
->buttonGotoDesktop
, SIGNAL(clicked()), this, SLOT(gotoDesktopButtonClicked()));
357 connect(ui
->buttonGotoMusic
, SIGNAL(clicked()), this, SLOT(gotoMusicFolderButtonClicked()));
358 connect(ui
->saveToSourceFolderCheckBox
, SIGNAL(clicked()), this, SLOT(saveToSourceFolderChanged()));
359 connect(ui
->prependRelativePathCheckBox
, SIGNAL(clicked()), this, SLOT(prependRelativePathChanged()));
360 connect(ui
->outputFolderEdit
, SIGNAL(editingFinished()), this, SLOT(outputFolderEditFinished()));
361 connect(m_evenFilterOutputFolderMouse
, SIGNAL(eventOccurred(QWidget
*, QEvent
*)), this, SLOT(outputFolderMouseEventOccurred(QWidget
*, QEvent
*)));
362 connect(m_evenFilterOutputFolderView
, SIGNAL(eventOccurred(QWidget
*, QEvent
*)), this, SLOT(outputFolderViewEventOccurred(QWidget
*, QEvent
*)));
364 if(m_outputFolderContextMenu
= new QMenu())
366 m_showFolderContextAction
= m_outputFolderContextMenu
->addAction(QIcon(":/icons/zoom.png"), "N/A");
367 m_goUpFolderContextAction
= m_outputFolderContextMenu
->addAction(QIcon(":/icons/folder_up.png"), "N/A");
368 m_outputFolderContextMenu
->addSeparator();
369 m_refreshFolderContextAction
= m_outputFolderContextMenu
->addAction(QIcon(":/icons/arrow_refresh.png"), "N/A");
370 m_outputFolderContextMenu
->setDefaultAction(m_showFolderContextAction
);
371 connect(ui
->outputFolderView
, SIGNAL(customContextMenuRequested(QPoint
)), this, SLOT(outputFolderContextMenu(QPoint
)));
372 connect(m_showFolderContextAction
, SIGNAL(triggered(bool)), this, SLOT(showFolderContextActionTriggered()));
373 connect(m_refreshFolderContextAction
, SIGNAL(triggered(bool)), this, SLOT(refreshFolderContextActionTriggered()));
374 connect(m_goUpFolderContextAction
, SIGNAL(triggered(bool)), this, SLOT(goUpFolderContextActionTriggered()));
377 if(m_outputFolderFavoritesMenu
= new QMenu())
379 m_addFavoriteFolderAction
= m_outputFolderFavoritesMenu
->addAction(QIcon(":/icons/add.png"), "N/A");
380 m_outputFolderFavoritesMenu
->insertSeparator(m_addFavoriteFolderAction
);
381 connect(m_addFavoriteFolderAction
, SIGNAL(triggered(bool)), this, SLOT(addFavoriteFolderActionTriggered()));
384 ui
->outputFolderEdit
->setVisible(false);
385 if(m_outputFolderNoteBox
= new QLabel(ui
->outputFolderView
))
387 m_outputFolderNoteBox
->setAutoFillBackground(true);
388 m_outputFolderNoteBox
->setAlignment(Qt::AlignHCenter
| Qt::AlignVCenter
);
389 m_outputFolderNoteBox
->setFrameShape(QFrame::StyledPanel
);
390 SET_FONT_BOLD(m_outputFolderNoteBox
, true);
391 m_outputFolderNoteBox
->hide();
395 outputFolderViewClicked(QModelIndex());
398 //--------------------------------
399 // Setup "Meta Data" tab
400 //--------------------------------
402 m_metaInfoModel
= new MetaInfoModel(m_metaData
);
403 m_metaInfoModel
->clearData();
404 m_metaInfoModel
->setData(m_metaInfoModel
->index(4, 1), m_settings
->metaInfoPosition());
405 ui
->metaDataView
->setModel(m_metaInfoModel
);
406 ui
->metaDataView
->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents
);
407 ui
->metaDataView
->verticalHeader()->hide();
408 ui
->metaDataView
->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents
);
409 SET_CHECKBOX_STATE(ui
->writeMetaDataCheckBox
, m_settings
->writeMetaTags());
410 ui
->generatePlaylistCheckBox
->setChecked(m_settings
->createPlaylist());
411 connect(ui
->buttonEditMeta
, SIGNAL(clicked()), this, SLOT(editMetaButtonClicked()));
412 connect(ui
->buttonClearMeta
, SIGNAL(clicked()), this, SLOT(clearMetaButtonClicked()));
413 connect(ui
->writeMetaDataCheckBox
, SIGNAL(clicked()), this, SLOT(metaTagsEnabledChanged()));
414 connect(ui
->generatePlaylistCheckBox
, SIGNAL(clicked()), this, SLOT(playlistEnabledChanged()));
416 //--------------------------------
417 //Setup "Compression" tab
418 //--------------------------------
420 m_encoderButtonGroup
= new QButtonGroup(this);
421 m_encoderButtonGroup
->addButton(ui
->radioButtonEncoderMP3
, SettingsModel::MP3Encoder
);
422 m_encoderButtonGroup
->addButton(ui
->radioButtonEncoderVorbis
, SettingsModel::VorbisEncoder
);
423 m_encoderButtonGroup
->addButton(ui
->radioButtonEncoderAAC
, SettingsModel::AACEncoder
);
424 m_encoderButtonGroup
->addButton(ui
->radioButtonEncoderAC3
, SettingsModel::AC3Encoder
);
425 m_encoderButtonGroup
->addButton(ui
->radioButtonEncoderFLAC
, SettingsModel::FLACEncoder
);
426 m_encoderButtonGroup
->addButton(ui
->radioButtonEncoderAPE
, SettingsModel::MACEncoder
);
427 m_encoderButtonGroup
->addButton(ui
->radioButtonEncoderOpus
, SettingsModel::OpusEncoder
);
428 m_encoderButtonGroup
->addButton(ui
->radioButtonEncoderDCA
, SettingsModel::DCAEncoder
);
429 m_encoderButtonGroup
->addButton(ui
->radioButtonEncoderPCM
, SettingsModel::PCMEncoder
);
431 const int aacEncoder
= EncoderRegistry::getAacEncoder();
432 ui
->radioButtonEncoderAAC
->setEnabled(aacEncoder
> SettingsModel::AAC_ENCODER_NONE
);
434 m_modeButtonGroup
= new QButtonGroup(this);
435 m_modeButtonGroup
->addButton(ui
->radioButtonModeQuality
, SettingsModel::VBRMode
);
436 m_modeButtonGroup
->addButton(ui
->radioButtonModeAverageBitrate
, SettingsModel::ABRMode
);
437 m_modeButtonGroup
->addButton(ui
->radioButtonConstBitrate
, SettingsModel::CBRMode
);
439 ui
->radioButtonEncoderMP3
->setChecked(true);
440 foreach(QAbstractButton
*currentButton
, m_encoderButtonGroup
->buttons())
442 if(currentButton
->isEnabled() && (m_encoderButtonGroup
->id(currentButton
) == m_settings
->compressionEncoder()))
444 currentButton
->setChecked(true);
449 m_evenFilterCompressionTab
= new CustomEventFilter();
450 ui
->labelCompressionHelp
->installEventFilter(m_evenFilterCompressionTab
);
451 ui
->labelResetEncoders
->installEventFilter(m_evenFilterCompressionTab
);
453 connect(m_encoderButtonGroup
, SIGNAL(buttonClicked(int)), this, SLOT(updateEncoder(int)));
454 connect(m_modeButtonGroup
, SIGNAL(buttonClicked(int)), this, SLOT(updateRCMode(int)));
455 connect(m_evenFilterCompressionTab
, SIGNAL(eventOccurred(QWidget
*, QEvent
*)), this, SLOT(compressionTabEventOccurred(QWidget
*, QEvent
*)));
456 connect(ui
->sliderBitrate
, SIGNAL(valueChanged(int)), this, SLOT(updateBitrate(int)));
458 updateEncoder(m_encoderButtonGroup
->checkedId());
460 //--------------------------------
461 //Setup "Advanced Options" tab
462 //--------------------------------
464 ui
->sliderLameAlgoQuality
->setValue(m_settings
->lameAlgoQuality());
465 if(m_settings
->maximumInstances() > 0) ui
->sliderMaxInstances
->setValue(m_settings
->maximumInstances());
467 ui
->spinBoxBitrateManagementMin
->setValue(m_settings
->bitrateManagementMinRate());
468 ui
->spinBoxBitrateManagementMax
->setValue(m_settings
->bitrateManagementMaxRate());
469 ui
->spinBoxNormalizationFilterPeak
->setValue(static_cast<double>(m_settings
->normalizationFilterMaxVolume()) / 100.0);
470 ui
->spinBoxNormalizationFilterSize
->setValue(m_settings
->normalizationFilterSize());
471 ui
->spinBoxToneAdjustBass
->setValue(static_cast<double>(m_settings
->toneAdjustBass()) / 100.0);
472 ui
->spinBoxToneAdjustTreble
->setValue(static_cast<double>(m_settings
->toneAdjustTreble()) / 100.0);
473 ui
->spinBoxAftenSearchSize
->setValue(m_settings
->aftenExponentSearchSize());
474 ui
->spinBoxOpusComplexity
->setValue(m_settings
->opusComplexity());
476 ui
->comboBoxMP3ChannelMode
->setCurrentIndex(m_settings
->lameChannelMode());
477 ui
->comboBoxSamplingRate
->setCurrentIndex(m_settings
->samplingRate());
478 ui
->comboBoxAACProfile
->setCurrentIndex(m_settings
->aacEncProfile());
479 ui
->comboBoxAftenCodingMode
->setCurrentIndex(m_settings
->aftenAudioCodingMode());
480 ui
->comboBoxAftenDRCMode
->setCurrentIndex(m_settings
->aftenDynamicRangeCompression());
481 ui
->comboBoxOpusFramesize
->setCurrentIndex(m_settings
->opusFramesize());
483 SET_CHECKBOX_STATE(ui
->checkBoxBitrateManagement
, m_settings
->bitrateManagementEnabled());
484 SET_CHECKBOX_STATE(ui
->checkBoxNeroAAC2PassMode
, m_settings
->neroAACEnable2Pass());
485 SET_CHECKBOX_STATE(ui
->checkBoxAftenFastAllocation
, m_settings
->aftenFastBitAllocation());
486 SET_CHECKBOX_STATE(ui
->checkBoxNormalizationFilterEnabled
, m_settings
->normalizationFilterEnabled());
487 SET_CHECKBOX_STATE(ui
->checkBoxNormalizationFilterDynamic
, m_settings
->normalizationFilterDynamic());
488 SET_CHECKBOX_STATE(ui
->checkBoxNormalizationFilterCoupled
, m_settings
->normalizationFilterCoupled());
489 SET_CHECKBOX_STATE(ui
->checkBoxAutoDetectInstances
, (m_settings
->maximumInstances() < 1));
490 SET_CHECKBOX_STATE(ui
->checkBoxUseSystemTempFolder
, (!m_settings
->customTempPathEnabled()));
491 SET_CHECKBOX_STATE(ui
->checkBoxRename_Rename
, m_settings
->renameFiles_renameEnabled());
492 SET_CHECKBOX_STATE(ui
->checkBoxRename_RegExp
, m_settings
->renameFiles_regExpEnabled());
493 SET_CHECKBOX_STATE(ui
->checkBoxForceStereoDownmix
, m_settings
->forceStereoDownmix());
494 SET_CHECKBOX_STATE(ui
->checkBoxOpusDisableResample
, m_settings
->opusDisableResample());
496 ui
->checkBoxNeroAAC2PassMode
->setEnabled(aacEncoder
== SettingsModel::AAC_ENCODER_NERO
);
498 ui
->lineEditCustomParamLAME
->setText(EncoderRegistry::loadEncoderCustomParams(m_settings
, SettingsModel::MP3Encoder
));
499 ui
->lineEditCustomParamOggEnc
->setText(EncoderRegistry::loadEncoderCustomParams(m_settings
, SettingsModel::VorbisEncoder
));
500 ui
->lineEditCustomParamNeroAAC
->setText(EncoderRegistry::loadEncoderCustomParams(m_settings
, SettingsModel::AACEncoder
));
501 ui
->lineEditCustomParamFLAC
->setText(EncoderRegistry::loadEncoderCustomParams(m_settings
, SettingsModel::FLACEncoder
));
502 ui
->lineEditCustomParamAften
->setText(EncoderRegistry::loadEncoderCustomParams(m_settings
, SettingsModel::AC3Encoder
));
503 ui
->lineEditCustomParamOpus
->setText(EncoderRegistry::loadEncoderCustomParams(m_settings
, SettingsModel::OpusEncoder
));
504 ui
->lineEditCustomTempFolder
->setText(QDir::toNativeSeparators(m_settings
->customTempPath()));
505 ui
->lineEditRenamePattern
->setText(m_settings
->renameFiles_renamePattern());
506 ui
->lineEditRenameRegExp_Search
->setText(m_settings
->renameFiles_regExpSearch ());
507 ui
->lineEditRenameRegExp_Replace
->setText(m_settings
->renameFiles_regExpReplace());
509 m_evenFilterCustumParamsHelp
= new CustomEventFilter();
510 ui
->helpCustomParamLAME
->installEventFilter(m_evenFilterCustumParamsHelp
);
511 ui
->helpCustomParamOggEnc
->installEventFilter(m_evenFilterCustumParamsHelp
);
512 ui
->helpCustomParamNeroAAC
->installEventFilter(m_evenFilterCustumParamsHelp
);
513 ui
->helpCustomParamFLAC
->installEventFilter(m_evenFilterCustumParamsHelp
);
514 ui
->helpCustomParamAften
->installEventFilter(m_evenFilterCustumParamsHelp
);
515 ui
->helpCustomParamOpus
->installEventFilter(m_evenFilterCustumParamsHelp
);
517 m_overwriteButtonGroup
= new QButtonGroup(this);
518 m_overwriteButtonGroup
->addButton(ui
->radioButtonOverwriteModeKeepBoth
, SettingsModel::Overwrite_KeepBoth
);
519 m_overwriteButtonGroup
->addButton(ui
->radioButtonOverwriteModeSkipFile
, SettingsModel::Overwrite_SkipFile
);
520 m_overwriteButtonGroup
->addButton(ui
->radioButtonOverwriteModeReplaces
, SettingsModel::Overwrite_Replaces
);
522 ui
->radioButtonOverwriteModeKeepBoth
->setChecked(m_settings
->overwriteMode() == SettingsModel::Overwrite_KeepBoth
);
523 ui
->radioButtonOverwriteModeSkipFile
->setChecked(m_settings
->overwriteMode() == SettingsModel::Overwrite_SkipFile
);
524 ui
->radioButtonOverwriteModeReplaces
->setChecked(m_settings
->overwriteMode() == SettingsModel::Overwrite_Replaces
);
526 FileExtsModel
*fileExtModel
= new FileExtsModel(this);
527 fileExtModel
->importItems(m_settings
->renameFiles_fileExtension());
528 ui
->tableViewFileExts
->setModel(fileExtModel
);
529 ui
->tableViewFileExts
->verticalHeader() ->setResizeMode(QHeaderView::ResizeToContents
);
530 ui
->tableViewFileExts
->horizontalHeader()->setResizeMode(QHeaderView::Stretch
);
532 connect(ui
->sliderLameAlgoQuality
, SIGNAL(valueChanged(int)), this, SLOT(updateLameAlgoQuality(int)));
533 connect(ui
->checkBoxBitrateManagement
, SIGNAL(clicked(bool)), this, SLOT(bitrateManagementEnabledChanged(bool)));
534 connect(ui
->spinBoxBitrateManagementMin
, SIGNAL(valueChanged(int)), this, SLOT(bitrateManagementMinChanged(int)));
535 connect(ui
->spinBoxBitrateManagementMax
, SIGNAL(valueChanged(int)), this, SLOT(bitrateManagementMaxChanged(int)));
536 connect(ui
->comboBoxMP3ChannelMode
, SIGNAL(currentIndexChanged(int)), this, SLOT(channelModeChanged(int)));
537 connect(ui
->comboBoxSamplingRate
, SIGNAL(currentIndexChanged(int)), this, SLOT(samplingRateChanged(int)));
538 connect(ui
->checkBoxNeroAAC2PassMode
, SIGNAL(clicked(bool)), this, SLOT(neroAAC2PassChanged(bool)));
539 connect(ui
->comboBoxAACProfile
, SIGNAL(currentIndexChanged(int)), this, SLOT(neroAACProfileChanged(int)));
540 connect(ui
->checkBoxNormalizationFilterEnabled
, SIGNAL(clicked(bool)), this, SLOT(normalizationEnabledChanged(bool)));
541 connect(ui
->checkBoxNormalizationFilterDynamic
, SIGNAL(clicked(bool)), this, SLOT(normalizationDynamicChanged(bool)));
542 connect(ui
->checkBoxNormalizationFilterCoupled
, SIGNAL(clicked(bool)), this, SLOT(normalizationCoupledChanged(bool)));
543 connect(ui
->comboBoxAftenCodingMode
, SIGNAL(currentIndexChanged(int)), this, SLOT(aftenCodingModeChanged(int)));
544 connect(ui
->comboBoxAftenDRCMode
, SIGNAL(currentIndexChanged(int)), this, SLOT(aftenDRCModeChanged(int)));
545 connect(ui
->spinBoxAftenSearchSize
, SIGNAL(valueChanged(int)), this, SLOT(aftenSearchSizeChanged(int)));
546 connect(ui
->checkBoxAftenFastAllocation
, SIGNAL(clicked(bool)), this, SLOT(aftenFastAllocationChanged(bool)));
547 connect(ui
->spinBoxNormalizationFilterPeak
, SIGNAL(valueChanged(double)), this, SLOT(normalizationMaxVolumeChanged(double)));
548 connect(ui
->spinBoxNormalizationFilterSize
, SIGNAL(valueChanged(int)), this, SLOT(normalizationFilterSizeChanged(int)));
549 connect(ui
->spinBoxNormalizationFilterSize
, SIGNAL(editingFinished()), this, SLOT(normalizationFilterSizeFinished()));
550 connect(ui
->spinBoxToneAdjustBass
, SIGNAL(valueChanged(double)), this, SLOT(toneAdjustBassChanged(double)));
551 connect(ui
->spinBoxToneAdjustTreble
, SIGNAL(valueChanged(double)), this, SLOT(toneAdjustTrebleChanged(double)));
552 connect(ui
->buttonToneAdjustReset
, SIGNAL(clicked()), this, SLOT(toneAdjustTrebleReset()));
553 connect(ui
->lineEditCustomParamLAME
, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
554 connect(ui
->lineEditCustomParamOggEnc
, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
555 connect(ui
->lineEditCustomParamNeroAAC
, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
556 connect(ui
->lineEditCustomParamFLAC
, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
557 connect(ui
->lineEditCustomParamAften
, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
558 connect(ui
->lineEditCustomParamOpus
, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
559 connect(ui
->sliderMaxInstances
, SIGNAL(valueChanged(int)), this, SLOT(updateMaximumInstances(int)));
560 connect(ui
->checkBoxAutoDetectInstances
, SIGNAL(clicked(bool)), this, SLOT(autoDetectInstancesChanged(bool)));
561 connect(ui
->buttonBrowseCustomTempFolder
, SIGNAL(clicked()), this, SLOT(browseCustomTempFolderButtonClicked()));
562 connect(ui
->lineEditCustomTempFolder
, SIGNAL(textChanged(QString
)), this, SLOT(customTempFolderChanged(QString
)));
563 connect(ui
->checkBoxUseSystemTempFolder
, SIGNAL(clicked(bool)), this, SLOT(useCustomTempFolderChanged(bool)));
564 connect(ui
->buttonResetAdvancedOptions
, SIGNAL(clicked()), this, SLOT(resetAdvancedOptionsButtonClicked()));
565 connect(ui
->checkBoxRename_Rename
, SIGNAL(clicked(bool)), this, SLOT(renameOutputEnabledChanged(bool)));
566 connect(ui
->checkBoxRename_RegExp
, SIGNAL(clicked(bool)), this, SLOT(renameRegExpEnabledChanged(bool)));
567 connect(ui
->lineEditRenamePattern
, SIGNAL(editingFinished()), this, SLOT(renameOutputPatternChanged()));
568 connect(ui
->lineEditRenamePattern
, SIGNAL(textChanged(QString
)), this, SLOT(renameOutputPatternChanged(QString
)));
569 connect(ui
->lineEditRenameRegExp_Search
, SIGNAL(editingFinished()), this, SLOT(renameRegExpValueChanged()));
570 connect(ui
->lineEditRenameRegExp_Search
, SIGNAL(textChanged(QString
)), this, SLOT(renameRegExpSearchChanged(QString
)));
571 connect(ui
->lineEditRenameRegExp_Replace
, SIGNAL(editingFinished()), this, SLOT(renameRegExpValueChanged()));
572 connect(ui
->lineEditRenameRegExp_Replace
, SIGNAL(textChanged(QString
)), this, SLOT(renameRegExpReplaceChanged(QString
)));
573 connect(ui
->labelShowRenameMacros
, SIGNAL(linkActivated(QString
)), this, SLOT(showRenameMacros(QString
)));
574 connect(ui
->labelShowRegExpHelp
, SIGNAL(linkActivated(QString
)), this, SLOT(showRenameMacros(QString
)));
575 connect(ui
->checkBoxForceStereoDownmix
, SIGNAL(clicked(bool)), this, SLOT(forceStereoDownmixEnabledChanged(bool)));
576 connect(ui
->comboBoxOpusFramesize
, SIGNAL(currentIndexChanged(int)), this, SLOT(opusSettingsChanged()));
577 connect(ui
->spinBoxOpusComplexity
, SIGNAL(valueChanged(int)), this, SLOT(opusSettingsChanged()));
578 connect(ui
->checkBoxOpusDisableResample
, SIGNAL(clicked(bool)), this, SLOT(opusSettingsChanged()));
579 connect(ui
->buttonRename_Rename
, SIGNAL(clicked(bool)), this, SLOT(renameButtonClicked(bool)));
580 connect(ui
->buttonRename_RegExp
, SIGNAL(clicked(bool)), this, SLOT(renameButtonClicked(bool)));
581 connect(ui
->buttonRename_FileEx
, SIGNAL(clicked(bool)), this, SLOT(renameButtonClicked(bool)));
582 connect(ui
->buttonFileExts_Add
, SIGNAL(clicked()), this, SLOT(fileExtAddButtonClicked()));
583 connect(ui
->buttonFileExts_Remove
, SIGNAL(clicked()), this, SLOT(fileExtRemoveButtonClicked()));
584 connect(m_overwriteButtonGroup
, SIGNAL(buttonClicked(int)), this, SLOT(overwriteModeChanged(int)));
585 connect(m_evenFilterCustumParamsHelp
, SIGNAL(eventOccurred(QWidget
*, QEvent
*)), this, SLOT(customParamsHelpRequested(QWidget
*, QEvent
*)));
586 connect(fileExtModel
, SIGNAL(modelReset()), this, SLOT(fileExtModelChanged()));
588 //--------------------------------
589 // Force initial GUI update
590 //--------------------------------
592 updateLameAlgoQuality(ui
->sliderLameAlgoQuality
->value());
593 updateMaximumInstances(ui
->sliderMaxInstances
->value());
594 toneAdjustTrebleChanged(ui
->spinBoxToneAdjustTreble
->value());
595 toneAdjustBassChanged(ui
->spinBoxToneAdjustBass
->value());
596 normalizationEnabledChanged(ui
->checkBoxNormalizationFilterEnabled
->isChecked());
597 customParamsChanged();
599 //--------------------------------
600 // Initialize actions
601 //--------------------------------
603 //Activate file menu actions
604 ui
->actionOpenFolder
->setData(QVariant::fromValue
<bool>(false));
605 ui
->actionOpenFolderRecursively
->setData(QVariant::fromValue
<bool>(true));
606 connect(ui
->actionOpenFolder
, SIGNAL(triggered()), this, SLOT(openFolderActionActivated()));
607 connect(ui
->actionOpenFolderRecursively
, SIGNAL(triggered()), this, SLOT(openFolderActionActivated()));
609 //Activate view menu actions
610 m_tabActionGroup
= new QActionGroup(this);
611 m_tabActionGroup
->addAction(ui
->actionSourceFiles
);
612 m_tabActionGroup
->addAction(ui
->actionOutputDirectory
);
613 m_tabActionGroup
->addAction(ui
->actionCompression
);
614 m_tabActionGroup
->addAction(ui
->actionMetaData
);
615 m_tabActionGroup
->addAction(ui
->actionAdvancedOptions
);
616 ui
->actionSourceFiles
->setData(0);
617 ui
->actionOutputDirectory
->setData(1);
618 ui
->actionMetaData
->setData(2);
619 ui
->actionCompression
->setData(3);
620 ui
->actionAdvancedOptions
->setData(4);
621 ui
->actionSourceFiles
->setChecked(true);
622 connect(m_tabActionGroup
, SIGNAL(triggered(QAction
*)), this, SLOT(tabActionActivated(QAction
*)));
624 //Activate style menu actions
625 m_styleActionGroup
= new QActionGroup(this);
626 m_styleActionGroup
->addAction(ui
->actionStylePlastique
);
627 m_styleActionGroup
->addAction(ui
->actionStyleCleanlooks
);
628 m_styleActionGroup
->addAction(ui
->actionStyleWindowsVista
);
629 m_styleActionGroup
->addAction(ui
->actionStyleWindowsXP
);
630 m_styleActionGroup
->addAction(ui
->actionStyleWindowsClassic
);
631 ui
->actionStylePlastique
->setData(0);
632 ui
->actionStyleCleanlooks
->setData(1);
633 ui
->actionStyleWindowsVista
->setData(2);
634 ui
->actionStyleWindowsXP
->setData(3);
635 ui
->actionStyleWindowsClassic
->setData(4);
636 ui
->actionStylePlastique
->setChecked(true);
637 ui
->actionStyleWindowsXP
->setEnabled((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based
) >= QSysInfo::WV_XP
&& MUtils::GUI::themes_enabled());
638 ui
->actionStyleWindowsVista
->setEnabled((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based
) >= QSysInfo::WV_VISTA
&& MUtils::GUI::themes_enabled());
639 connect(m_styleActionGroup
, SIGNAL(triggered(QAction
*)), this, SLOT(styleActionActivated(QAction
*)));
640 styleActionActivated(NULL
);
642 //Populate the language menu
643 m_languageActionGroup
= new QActionGroup(this);
644 QStringList translations
;
645 if(MUtils::Translation::enumerate(translations
) > 0)
647 for(QStringList::ConstIterator iter
= translations
.constBegin(); iter
!= translations
.constEnd(); iter
++)
649 QAction
*currentLanguage
= new QAction(this);
650 currentLanguage
->setData(*iter
);
651 currentLanguage
->setText(MUtils::Translation::get_name(*iter
));
652 currentLanguage
->setIcon(QIcon(QString(":/flags/%1.png").arg(*iter
)));
653 currentLanguage
->setCheckable(true);
654 currentLanguage
->setChecked(false);
655 m_languageActionGroup
->addAction(currentLanguage
);
656 ui
->menuLanguage
->insertAction(ui
->actionLoadTranslationFromFile
, currentLanguage
);
659 ui
->menuLanguage
->insertSeparator(ui
->actionLoadTranslationFromFile
);
660 connect(ui
->actionLoadTranslationFromFile
, SIGNAL(triggered(bool)), this, SLOT(languageFromFileActionActivated(bool)));
661 connect(m_languageActionGroup
, SIGNAL(triggered(QAction
*)), this, SLOT(languageActionActivated(QAction
*)));
662 ui
->actionLoadTranslationFromFile
->setChecked(false);
664 //Activate tools menu actions
665 ui
->actionDisableUpdateReminder
->setChecked(!m_settings
->autoUpdateEnabled());
666 ui
->actionDisableSounds
->setChecked(!m_settings
->soundsEnabled());
667 ui
->actionDisableNeroAacNotifications
->setChecked(!m_settings
->neroAacNotificationsEnabled());
668 ui
->actionDisableSlowStartupNotifications
->setChecked(!m_settings
->antivirNotificationsEnabled());
669 ui
->actionDisableShellIntegration
->setChecked(!m_settings
->shellIntegrationEnabled());
670 ui
->actionDisableShellIntegration
->setDisabled(lamexp_version_portable() && ui
->actionDisableShellIntegration
->isChecked());
671 ui
->actionCheckForBetaUpdates
->setChecked(m_settings
->autoUpdateCheckBeta() || lamexp_version_demo());
672 ui
->actionCheckForBetaUpdates
->setEnabled(!lamexp_version_demo());
673 ui
->actionHibernateComputer
->setChecked(m_settings
->hibernateComputer());
674 ui
->actionHibernateComputer
->setEnabled(MUtils::OS::is_hibernation_supported());
675 connect(ui
->actionDisableUpdateReminder
, SIGNAL(triggered(bool)), this, SLOT(disableUpdateReminderActionTriggered(bool)));
676 connect(ui
->actionDisableSounds
, SIGNAL(triggered(bool)), this, SLOT(disableSoundsActionTriggered(bool)));
677 connect(ui
->actionDisableNeroAacNotifications
, SIGNAL(triggered(bool)), this, SLOT(disableNeroAacNotificationsActionTriggered(bool)));
678 connect(ui
->actionDisableSlowStartupNotifications
, SIGNAL(triggered(bool)), this, SLOT(disableSlowStartupNotificationsActionTriggered(bool)));
679 connect(ui
->actionDisableShellIntegration
, SIGNAL(triggered(bool)), this, SLOT(disableShellIntegrationActionTriggered(bool)));
680 connect(ui
->actionShowDropBoxWidget
, SIGNAL(triggered(bool)), this, SLOT(showDropBoxWidgetActionTriggered(bool)));
681 connect(ui
->actionHibernateComputer
, SIGNAL(triggered(bool)), this, SLOT(hibernateComputerActionTriggered(bool)));
682 connect(ui
->actionCheckForBetaUpdates
, SIGNAL(triggered(bool)), this, SLOT(checkForBetaUpdatesActionTriggered(bool)));
683 connect(ui
->actionImportCueSheet
, SIGNAL(triggered(bool)), this, SLOT(importCueSheetActionTriggered(bool)));
685 //Activate help menu actions
686 ui
->actionVisitHomepage
->setData(QString::fromLatin1(lamexp_website_url()));
687 ui
->actionVisitSupport
->setData(QString::fromLatin1(lamexp_support_url()));
688 ui
->actionVisitMuldersSite
->setData(QString::fromLatin1(lamexp_mulders_url()));
689 ui
->actionVisitTracker
->setData(QString::fromLatin1(lamexp_tracker_url()));
690 ui
->actionVisitHAK
->setData(QString::fromLatin1(g_hydrogen_audio_url
));
691 ui
->actionDocumentManual
->setData(QString("%1/Manual.html") .arg(QApplication::applicationDirPath()));
692 ui
->actionDocumentChangelog
->setData(QString("%1/Changelog.html").arg(QApplication::applicationDirPath()));
693 ui
->actionDocumentTranslate
->setData(QString("%1/Translate.html").arg(QApplication::applicationDirPath()));
694 connect(ui
->actionCheckUpdates
, SIGNAL(triggered()), this, SLOT(checkUpdatesActionActivated()));
695 connect(ui
->actionVisitSupport
, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated()));
696 connect(ui
->actionVisitTracker
, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated()));
697 connect(ui
->actionVisitHomepage
, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated()));
698 connect(ui
->actionVisitMuldersSite
, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated()));
699 connect(ui
->actionVisitHAK
, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated()));
700 connect(ui
->actionDocumentManual
, SIGNAL(triggered()), this, SLOT(documentActionActivated()));
701 connect(ui
->actionDocumentChangelog
, SIGNAL(triggered()), this, SLOT(documentActionActivated()));
702 connect(ui
->actionDocumentTranslate
, SIGNAL(triggered()), this, SLOT(documentActionActivated()));
704 //--------------------------------
705 // Prepare to show window
706 //--------------------------------
708 //Center window in screen
709 QRect desktopRect
= QApplication::desktop()->screenGeometry();
710 QRect thisRect
= this->geometry();
711 move((desktopRect
.width() - thisRect
.width()) / 2, (desktopRect
.height() - thisRect
.height()) / 2);
712 setMinimumSize(thisRect
.width(), thisRect
.height());
714 //Create DropBox widget
715 m_dropBox
= new DropBox(this, m_fileListModel
, m_settings
);
716 connect(m_fileListModel
, SIGNAL(modelReset()), m_dropBox
, SLOT(modelChanged()));
717 connect(m_fileListModel
, SIGNAL(rowsInserted(QModelIndex
,int,int)), m_dropBox
, SLOT(modelChanged()));
718 connect(m_fileListModel
, SIGNAL(rowsRemoved(QModelIndex
,int,int)), m_dropBox
, SLOT(modelChanged()));
719 connect(m_fileListModel
, SIGNAL(rowAppended()), m_dropBox
, SLOT(modelChanged()));
721 //Create message handler thread
722 m_messageHandler
= new MessageHandlerThread(ipcChannel
);
723 connect(m_messageHandler
, SIGNAL(otherInstanceDetected()), this, SLOT(notifyOtherInstance()), Qt::QueuedConnection
);
724 connect(m_messageHandler
, SIGNAL(fileReceived(QString
)), this, SLOT(addFileDelayed(QString
)), Qt::QueuedConnection
);
725 connect(m_messageHandler
, SIGNAL(folderReceived(QString
, bool)), this, SLOT(addFolderDelayed(QString
, bool)), Qt::QueuedConnection
);
726 connect(m_messageHandler
, SIGNAL(killSignalReceived()), this, SLOT(close()), Qt::QueuedConnection
);
727 m_messageHandler
->start();
729 //Init delayed file handling
730 m_delayedFileList
= new QStringList();
731 m_delayedFileTimer
= new QTimer();
732 m_delayedFileTimer
->setSingleShot(true);
733 m_delayedFileTimer
->setInterval(5000);
734 connect(m_delayedFileTimer
, SIGNAL(timeout()), this, SLOT(handleDelayedFiles()));
737 initializeTranslation();
739 //Re-translate (make sure we translate once)
740 QEvent
languageChangeEvent(QEvent::LanguageChange
);
741 changeEvent(&languageChangeEvent
);
744 m_droppedFileList
= new QList
<QUrl
>();
745 this->setAcceptDrops(true);
748 ////////////////////////////////////////////////////////////
750 ////////////////////////////////////////////////////////////
752 MainWindow::~MainWindow(void)
754 //Stop message handler thread
755 if(m_messageHandler
&& m_messageHandler
->isRunning())
757 m_messageHandler
->stop();
758 if(!m_messageHandler
->wait(2500))
760 m_messageHandler
->terminate();
761 m_messageHandler
->wait();
766 SET_MODEL(ui
->sourceFileView
, NULL
);
767 SET_MODEL(ui
->outputFolderView
, NULL
);
768 SET_MODEL(ui
->metaDataView
, NULL
);
771 MUTILS_DELETE(m_tabActionGroup
);
772 MUTILS_DELETE(m_styleActionGroup
);
773 MUTILS_DELETE(m_languageActionGroup
);
774 MUTILS_DELETE(m_banner
);
775 MUTILS_DELETE(m_fileSystemModel
);
776 MUTILS_DELETE(m_messageHandler
);
777 MUTILS_DELETE(m_droppedFileList
);
778 MUTILS_DELETE(m_delayedFileList
);
779 MUTILS_DELETE(m_delayedFileTimer
);
780 MUTILS_DELETE(m_metaInfoModel
);
781 MUTILS_DELETE(m_encoderButtonGroup
);
782 MUTILS_DELETE(m_modeButtonGroup
);
783 MUTILS_DELETE(m_overwriteButtonGroup
);
784 MUTILS_DELETE(m_sourceFilesContextMenu
);
785 MUTILS_DELETE(m_outputFolderFavoritesMenu
);
786 MUTILS_DELETE(m_outputFolderContextMenu
);
787 MUTILS_DELETE(m_dropBox
);
788 MUTILS_DELETE(m_evenFilterCornerWidget
);
789 MUTILS_DELETE(m_evenFilterCustumParamsHelp
);
790 MUTILS_DELETE(m_evenFilterOutputFolderMouse
);
791 MUTILS_DELETE(m_evenFilterOutputFolderView
);
792 MUTILS_DELETE(m_evenFilterCompressionTab
);
794 //Un-initialize the dialog
798 ////////////////////////////////////////////////////////////
800 ////////////////////////////////////////////////////////////
803 * Add file to source list
805 void MainWindow::addFiles(const QStringList
&files
)
812 WITH_BLOCKED_SIGNALS(ui
->tabWidget
, setCurrentIndex
, 0);
813 tabPageChanged(ui
->tabWidget
->currentIndex(), true);
816 FileAnalyzer
*analyzer
= new FileAnalyzer(files
);
818 connect(analyzer
, SIGNAL(fileSelected(QString
)), m_banner
, SLOT(setText(QString
)), Qt::QueuedConnection
);
819 connect(analyzer
, SIGNAL(progressValChanged(unsigned int)), m_banner
, SLOT(setProgressVal(unsigned int)), Qt::QueuedConnection
);
820 connect(analyzer
, SIGNAL(progressMaxChanged(unsigned int)), m_banner
, SLOT(setProgressMax(unsigned int)), Qt::QueuedConnection
);
821 connect(analyzer
, SIGNAL(fileAnalyzed(AudioFileModel
)), m_fileListModel
, SLOT(addFile(AudioFileModel
)), Qt::QueuedConnection
);
822 connect(m_banner
, SIGNAL(userAbort()), analyzer
, SLOT(abortProcess()), Qt::DirectConnection
);
826 m_fileListModel
->setBlockUpdates(true);
827 QTime startTime
= QTime::currentTime();
828 m_banner
->show(tr("Adding file(s), please wait..."), analyzer
);
832 /* ignore any exceptions that may occur */
835 m_fileListModel
->setBlockUpdates(false);
836 qApp
->processEvents(QEventLoop::ExcludeUserInputEvents
);
837 ui
->sourceFileView
->update();
838 qApp
->processEvents(QEventLoop::ExcludeUserInputEvents
);
839 ui
->sourceFileView
->scrollToBottom();
840 qApp
->processEvents(QEventLoop::ExcludeUserInputEvents
);
842 if(analyzer
->filesDenied())
844 QMessageBox::warning(this, tr("Access Denied"), QString("%1<br>%2").arg(NOBR(tr("%n file(s) have been rejected, because read access was not granted!", "", analyzer
->filesDenied())), NOBR(tr("This usually means the file is locked by another process."))));
846 if(analyzer
->filesDummyCDDA())
848 QMessageBox::warning(this, tr("CDDA Files"), QString("%1<br><br>%2<br>%3").arg(NOBR(tr("%n file(s) have been rejected, because they are dummy CDDA files!", "", 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>"))));
850 if(analyzer
->filesCueSheet())
852 QMessageBox::warning(this, tr("Cue Sheet"), QString("%1<br>%2").arg(NOBR(tr("%n file(s) have been rejected, because they appear to be Cue Sheet images!", "",analyzer
->filesCueSheet())), NOBR(tr("Please use LameXP's Cue Sheet wizard for importing Cue Sheet files."))));
854 if(analyzer
->filesRejected())
856 QMessageBox::warning(this, tr("Files Rejected"), QString("%1<br>%2").arg(NOBR(tr("%n file(s) have been rejected, because the file format could not be recognized!", "", analyzer
->filesRejected())), NOBR(tr("This usually means the file is damaged or the file format is not supported."))));
859 MUTILS_DELETE(analyzer
);
864 * Add folder to source list
866 void MainWindow::addFolder(const QString
&path
, bool recursive
, bool delayed
, QString filter
)
868 QFileInfoList folderInfoList
;
869 folderInfoList
<< QFileInfo(path
);
870 QStringList fileList
;
872 SHOW_BANNER(tr("Scanning folder(s) for files, please wait..."));
874 QApplication::processEvents();
875 MUtils::OS::check_key_state_esc();
877 while(!folderInfoList
.isEmpty())
879 if(MUtils::OS::check_key_state_esc())
881 qWarning("Operation cancelled by user!");
882 MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
);
887 QDir
currentDir(folderInfoList
.takeFirst().canonicalFilePath());
888 QFileInfoList fileInfoList
= currentDir
.entryInfoList(QDir::Files
| QDir::NoSymLinks
);
890 for(QFileInfoList::ConstIterator iter
= fileInfoList
.constBegin(); iter
!= fileInfoList
.constEnd(); iter
++)
892 if(filter
.isEmpty() || (iter
->suffix().compare(filter
, Qt::CaseInsensitive
) == 0))
894 fileList
<< iter
->canonicalFilePath();
898 QApplication::processEvents(QEventLoop::ExcludeUserInputEvents
);
902 folderInfoList
.append(currentDir
.entryInfoList(QDir::Dirs
| QDir::NoDotAndDotDot
| QDir::NoSymLinks
));
903 QApplication::processEvents();
908 QApplication::processEvents();
910 if(!fileList
.isEmpty())
914 addFilesDelayed(fileList
);
926 bool MainWindow::checkForUpdates(void)
928 bool bReadyToInstall
= false;
930 UpdateDialog
*updateDialog
= new UpdateDialog(m_settings
, this);
931 updateDialog
->exec();
933 if(updateDialog
->getSuccess())
935 SHOW_CORNER_WIDGET(false);
936 m_settings
->autoUpdateLastCheck(QDate::currentDate().toString(Qt::ISODate
));
937 bReadyToInstall
= updateDialog
->updateReadyToInstall();
940 MUTILS_DELETE(updateDialog
);
941 return bReadyToInstall
;
945 * Refresh list of favorites
947 void MainWindow::refreshFavorites(void)
949 QList
<QAction
*> folderList
= m_outputFolderFavoritesMenu
->actions();
950 QStringList favorites
= m_settings
->favoriteOutputFolders().split("|", QString::SkipEmptyParts
);
951 while(favorites
.count() > 6) favorites
.removeFirst();
953 while(!folderList
.isEmpty())
955 QAction
*currentItem
= folderList
.takeFirst();
956 if(currentItem
->isSeparator()) break;
957 m_outputFolderFavoritesMenu
->removeAction(currentItem
);
958 MUTILS_DELETE(currentItem
);
961 QAction
*lastItem
= m_outputFolderFavoritesMenu
->actions().first();
963 while(!favorites
.isEmpty())
965 QString path
= favorites
.takeLast();
966 if(QDir(path
).exists())
968 QAction
*action
= new QAction(QIcon(":/icons/folder_go.png"), QDir::toNativeSeparators(path
), this);
969 action
->setData(path
);
970 m_outputFolderFavoritesMenu
->insertAction(lastItem
, action
);
971 connect(action
, SIGNAL(triggered(bool)), this, SLOT(gotoFavoriteFolder()));
978 * Initilaize translation
980 void MainWindow::initializeTranslation(void)
982 bool translationLoaded
= false;
984 //Try to load "external" translation file
985 if(!m_settings
->currentLanguageFile().isEmpty())
987 const QString qmFilePath
= QFileInfo(m_settings
->currentLanguageFile()).canonicalFilePath();
988 if((!qmFilePath
.isEmpty()) && QFileInfo(qmFilePath
).exists() && QFileInfo(qmFilePath
).isFile() && (QFileInfo(qmFilePath
).suffix().compare("qm", Qt::CaseInsensitive
) == 0))
990 if(MUtils::Translation::install_translator_from_file(qmFilePath
))
992 QList
<QAction
*> actions
= m_languageActionGroup
->actions();
993 while(!actions
.isEmpty()) actions
.takeFirst()->setChecked(false);
994 ui
->actionLoadTranslationFromFile
->setChecked(true);
995 translationLoaded
= true;
1000 //Try to load "built-in" translation file
1001 if(!translationLoaded
)
1003 QList
<QAction
*> languageActions
= m_languageActionGroup
->actions();
1004 while(!languageActions
.isEmpty())
1006 QAction
*currentLanguage
= languageActions
.takeFirst();
1007 if(currentLanguage
->data().toString().compare(m_settings
->currentLanguage(), Qt::CaseInsensitive
) == 0)
1009 currentLanguage
->setChecked(true);
1010 languageActionActivated(currentLanguage
);
1011 translationLoaded
= true;
1016 //Fallback to default translation
1017 if(!translationLoaded
)
1019 QList
<QAction
*> languageActions
= m_languageActionGroup
->actions();
1020 while(!languageActions
.isEmpty())
1022 QAction
*currentLanguage
= languageActions
.takeFirst();
1023 if(currentLanguage
->data().toString().compare(MUtils::Translation::DEFAULT_LANGID
, Qt::CaseInsensitive
) == 0)
1025 currentLanguage
->setChecked(true);
1026 languageActionActivated(currentLanguage
);
1027 translationLoaded
= true;
1032 //Make sure we loaded some translation
1033 if(!translationLoaded
)
1035 qFatal("Failed to load any translation, this is NOT supposed to happen!");
1040 * Open a document link
1042 void MainWindow::openDocumentLink(QAction
*const action
)
1044 if(!(action
->data().isValid() && (action
->data().type() == QVariant::String
)))
1046 qWarning("Cannot open document for this QAction!");
1050 //Try to open exitsing document file
1051 const QFileInfo
document(action
->data().toString());
1052 if(document
.exists() && document
.isFile() && (document
.size() >= 1024))
1054 QDesktopServices::openUrl(QUrl::fromLocalFile(document
.canonicalFilePath()));
1058 //Document not found -> fallback mode!
1059 qWarning("Document '%s' not found -> redirecting to the website!", MUTILS_UTF8(document
.fileName()));
1060 const QUrl
url(QString("%1/%2").arg(QString::fromLatin1(g_documents_base_url
), document
.fileName()));
1061 QDesktopServices::openUrl(url
);
1064 ////////////////////////////////////////////////////////////
1066 ////////////////////////////////////////////////////////////
1069 * Window is about to be shown
1071 void MainWindow::showEvent(QShowEvent
*event
)
1075 sourceModelChanged();
1077 if(!event
->spontaneous())
1079 WITH_BLOCKED_SIGNALS(ui
->tabWidget
, setCurrentIndex
, 0);
1080 tabPageChanged(ui
->tabWidget
->currentIndex(), true);
1083 if(m_firstTimeShown
)
1085 m_firstTimeShown
= false;
1086 QTimer::singleShot(0, this, SLOT(windowShown()));
1090 if(m_settings
->dropBoxWidgetEnabled())
1092 m_dropBox
->setVisible(true);
1098 * Re-translate the UI
1100 void MainWindow::changeEvent(QEvent
*e
)
1102 QMainWindow::changeEvent(e
);
1103 if(e
->type() != QEvent::LanguageChange
)
1108 int comboBoxIndex
[6];
1110 //Backup combobox indices, as retranslateUi() resets
1111 comboBoxIndex
[0] = ui
->comboBoxMP3ChannelMode
->currentIndex();
1112 comboBoxIndex
[1] = ui
->comboBoxSamplingRate
->currentIndex();
1113 comboBoxIndex
[2] = ui
->comboBoxAACProfile
->currentIndex();
1114 comboBoxIndex
[3] = ui
->comboBoxAftenCodingMode
->currentIndex();
1115 comboBoxIndex
[4] = ui
->comboBoxAftenDRCMode
->currentIndex();
1116 comboBoxIndex
[5] = ui
->comboBoxOpusFramesize
->currentIndex();
1118 //Re-translate from UIC
1119 ui
->retranslateUi(this);
1121 //Restore combobox indices
1122 ui
->comboBoxMP3ChannelMode
->setCurrentIndex(comboBoxIndex
[0]);
1123 ui
->comboBoxSamplingRate
->setCurrentIndex(comboBoxIndex
[1]);
1124 ui
->comboBoxAACProfile
->setCurrentIndex(comboBoxIndex
[2]);
1125 ui
->comboBoxAftenCodingMode
->setCurrentIndex(comboBoxIndex
[3]);
1126 ui
->comboBoxAftenDRCMode
->setCurrentIndex(comboBoxIndex
[4]);
1127 ui
->comboBoxOpusFramesize
->setCurrentIndex(comboBoxIndex
[5]);
1129 //Update the window title
1132 setWindowTitle(QString("%1 [!!! DEBUG BUILD !!!]").arg(windowTitle()));
1134 else if(lamexp_version_demo())
1136 setWindowTitle(QString("%1 [%2]").arg(windowTitle(), tr("DEMO VERSION")));
1139 //Manually re-translate widgets that UIC doesn't handle
1140 m_outputFolderNoteBox
->setText(tr("Initializing directory outline, please be patient..."));
1141 m_dropNoteLabel
->setText(QString("<br><img src=\":/images/DropZone.png\"><br><br>%1").arg(tr("You can drop in audio files here!")));
1142 if(QLabel
*cornerWidget
= dynamic_cast<QLabel
*>(ui
->menubar
->cornerWidget()))
1144 cornerWidget
->setText(QString("<nobr><img src=\":/icons/exclamation_small.png\"> <b style=\"color:darkred\">%1</b> </nobr>").arg(tr("Check for Updates")));
1146 m_showDetailsContextAction
->setText(tr("Show Details"));
1147 m_previewContextAction
->setText(tr("Open File in External Application"));
1148 m_findFileContextAction
->setText(tr("Browse File Location"));
1149 m_showFolderContextAction
->setText(tr("Browse Selected Folder"));
1150 m_refreshFolderContextAction
->setText(tr("Refresh Directory Outline"));
1151 m_goUpFolderContextAction
->setText(tr("Go To Parent Directory"));
1152 m_addFavoriteFolderAction
->setText(tr("Bookmark Current Output Folder"));
1153 m_exportCsvContextAction
->setText(tr("Export Meta Tags to CSV File"));
1154 m_importCsvContextAction
->setText(tr("Import Meta Tags from CSV File"));
1157 m_metaInfoModel
->clearData();
1158 m_metaInfoModel
->setData(m_metaInfoModel
->index(4, 1), m_settings
->metaInfoPosition());
1159 updateEncoder(m_settings
->compressionEncoder());
1160 updateLameAlgoQuality(ui
->sliderLameAlgoQuality
->value());
1161 updateMaximumInstances(ui
->sliderMaxInstances
->value());
1162 renameOutputPatternChanged(ui
->lineEditRenamePattern
->text(), true);
1163 renameRegExpSearchChanged (ui
->lineEditRenameRegExp_Search
->text(), true);
1164 renameRegExpReplaceChanged(ui
->lineEditRenameRegExp_Replace
->text(), true);
1166 //Re-install shell integration
1167 if(m_settings
->shellIntegrationEnabled())
1169 ShellIntegration::install();
1172 //Translate system menu
1173 MUtils::GUI::sysmenu_update(this, IDM_ABOUTBOX
, ui
->buttonAbout
->text());
1175 //Force resize event
1176 QApplication::postEvent(this, new QResizeEvent(this->size(), QSize()));
1177 for(QObjectList::ConstIterator iter
= this->children().constBegin(); iter
!= this->children().constEnd(); iter
++)
1179 if(QWidget
*child
= dynamic_cast<QWidget
*>(*iter
))
1181 QApplication::postEvent(child
, new QResizeEvent(child
->size(), QSize()));
1185 //Force tabe page change
1186 tabPageChanged(ui
->tabWidget
->currentIndex(), true);
1190 * File dragged over window
1192 void MainWindow::dragEnterEvent(QDragEnterEvent
*event
)
1194 QStringList formats
= event
->mimeData()->formats();
1196 if(formats
.contains("application/x-qt-windows-mime;value=\"FileNameW\"", Qt::CaseInsensitive
) && formats
.contains("text/uri-list", Qt::CaseInsensitive
))
1198 event
->acceptProposedAction();
1203 * File dropped onto window
1205 void MainWindow::dropEvent(QDropEvent
*event
)
1207 m_droppedFileList
->clear();
1208 (*m_droppedFileList
) << event
->mimeData()->urls();
1209 if(!m_droppedFileList
->isEmpty())
1211 PLAY_SOUND_OPTIONAL("drop", true);
1212 QTimer::singleShot(0, this, SLOT(handleDroppedFiles()));
1217 * Window tries to close
1219 void MainWindow::closeEvent(QCloseEvent
*event
)
1221 if(BANNER_VISIBLE
|| m_delayedFileTimer
->isActive())
1223 MUtils::Sound::beep(MUtils::Sound::BEEP_WRN
);
1234 * Window was resized
1236 void MainWindow::resizeEvent(QResizeEvent
*event
)
1238 if(event
) QMainWindow::resizeEvent(event
);
1240 if(QWidget
*port
= ui
->sourceFileView
->viewport())
1242 m_dropNoteLabel
->setGeometry(port
->geometry());
1245 if(QWidget
*port
= ui
->outputFolderView
->viewport())
1247 m_outputFolderNoteBox
->setGeometry(16, (port
->height() - 64) / 2, port
->width() - 32, 64);
1252 * Key press event filter
1254 void MainWindow::keyPressEvent(QKeyEvent
*e
)
1256 if(e
->key() == Qt::Key_Delete
)
1258 if(ui
->sourceFileView
->isVisible())
1260 QTimer::singleShot(0, this, SLOT(removeFileButtonClicked()));
1265 if(e
->modifiers().testFlag(Qt::ControlModifier
) && (e
->key() == Qt::Key_F5
))
1267 initializeTranslation();
1268 MUtils::Sound::beep(MUtils::Sound::BEEP_NFO
);
1272 if(e
->key() == Qt::Key_F5
)
1274 if(ui
->outputFolderView
->isVisible())
1276 QTimer::singleShot(0, this, SLOT(refreshFolderContextActionTriggered()));
1281 QMainWindow::keyPressEvent(e
);
1287 bool MainWindow::eventFilter(QObject
*obj
, QEvent
*event
)
1289 if(obj
== m_fileSystemModel
)
1291 if(QApplication::overrideCursor() == NULL
)
1293 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor
));
1294 QTimer::singleShot(250, this, SLOT(restoreCursor()));
1298 return QMainWindow::eventFilter(obj
, event
);
1301 bool MainWindow::event(QEvent
*e
)
1305 case MUtils::GUI::USER_EVENT_QUERYENDSESSION
:
1306 qWarning("System is shutting down, main window prepares to close...");
1307 if(BANNER_VISIBLE
) m_banner
->close();
1308 if(m_delayedFileTimer
->isActive()) m_delayedFileTimer
->stop();
1310 case MUtils::GUI::USER_EVENT_ENDSESSION
:
1311 qWarning("System is shutting down, main window will close now...");
1316 QApplication::processEvents(QEventLoop::WaitForMoreEvents
& QEventLoop::ExcludeUserInputEvents
);
1319 m_fileListModel
->clearFiles();
1321 case QEvent::MouseButtonPress
:
1322 if(ui
->outputFolderEdit
->isVisible())
1324 QTimer::singleShot(0, this, SLOT(outputFolderEditFinished()));
1327 return QMainWindow::event(e
);
1331 bool MainWindow::winEvent(MSG
*message
, long *result
)
1333 if(MUtils::GUI::sysmenu_check_msg(message
, IDM_ABOUTBOX
))
1335 QTimer::singleShot(0, ui
->buttonAbout
, SLOT(click()));
1342 ////////////////////////////////////////////////////////////
1344 ////////////////////////////////////////////////////////////
1346 // =========================================================
1347 // Show window slots
1348 // =========================================================
1353 void MainWindow::windowShown(void)
1355 const MUtils::OS::ArgumentMap
&arguments
= MUtils::OS::arguments(); //QApplication::arguments();
1357 //Force resize event
1361 const bool firstRun
= arguments
.contains("first-run");
1364 if((m_settings
->licenseAccepted() <= 0) || firstRun
)
1366 int iAccepted
= m_settings
->licenseAccepted();
1368 if((iAccepted
== 0) || firstRun
)
1370 AboutDialog
*about
= new AboutDialog(m_settings
, this, true);
1371 iAccepted
= about
->exec();
1372 if(iAccepted
<= 0) iAccepted
= -2;
1373 MUTILS_DELETE(about
);
1378 m_settings
->licenseAccepted(++iAccepted
);
1379 m_settings
->syncNow();
1380 QApplication::processEvents();
1381 MUtils::Sound::play_sound("whammy", false);
1382 QMessageBox::critical(this, tr("License Declined"), tr("You have declined the license. Consequently the application will exit now!"), tr("Goodbye!"));
1383 QFileInfo uninstallerInfo
= QFileInfo(QString("%1/Uninstall.exe").arg(QApplication::applicationDirPath()));
1384 if(uninstallerInfo
.exists())
1386 QString uninstallerDir
= uninstallerInfo
.canonicalPath();
1387 QString uninstallerPath
= uninstallerInfo
.canonicalFilePath();
1388 for(int i
= 0; i
< 3; i
++)
1390 if(MUtils::OS::shell_open(this, QDir::toNativeSeparators(uninstallerPath
), "/Force", QDir::toNativeSeparators(uninstallerDir
))) break;
1393 QApplication::quit();
1397 MUtils::Sound::play_sound("woohoo", false);
1398 m_settings
->licenseAccepted(1);
1399 m_settings
->syncNow();
1400 if(lamexp_version_demo()) showAnnounceBox();
1403 //Check for expiration
1404 if(lamexp_version_demo())
1406 if(MUtils::OS::current_date() >= lamexp_version_expires())
1408 qWarning("Binary has expired !!!");
1409 MUtils::Sound::play_sound("whammy", false);
1410 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)
1414 QApplication::quit();
1419 //Slow startup indicator
1420 if(m_settings
->slowStartup() && m_settings
->antivirNotificationsEnabled())
1423 message
+= NOBR(tr("It seems that a bogus anti-virus software is slowing down the startup of LameXP.")).append("<br>");
1424 message
+= NOBR(tr("Please refer to the %1 document for details and solutions!")).arg("<a href=\"http://lamexp.sourceforge.net/doc/FAQ.html#df406578\">F.A.Q.</a>").append("<br>");
1425 if(QMessageBox::warning(this, tr("Slow Startup"), message
, tr("Discard"), tr("Don't Show Again")) == 1)
1427 m_settings
->antivirNotificationsEnabled(false);
1428 ui
->actionDisableSlowStartupNotifications
->setChecked(!m_settings
->antivirNotificationsEnabled());
1433 if(MUtils::OS::current_date() >= MUtils::Version::app_build_date().addYears(1))
1435 qWarning("Binary is more than a year old, time to update!");
1436 SHOW_CORNER_WIDGET(true);
1437 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"));
1441 if(checkForUpdates())
1443 QApplication::quit();
1448 QApplication::quit();
1451 QEventLoop loop
; QTimer::singleShot(7000, &loop
, SLOT(quit()));
1452 MUtils::Sound::play_sound("waiting", true);
1453 SHOW_BANNER_ARG(tr("Skipping update check this time, please be patient..."), &loop
);
1459 QDate lastUpdateCheck
= QDate::fromString(m_settings
->autoUpdateLastCheck(), Qt::ISODate
);
1460 if((!firstRun
) && ((!lastUpdateCheck
.isValid()) || (MUtils::OS::current_date() >= lastUpdateCheck
.addDays(14))))
1462 SHOW_CORNER_WIDGET(true);
1463 if(m_settings
->autoUpdateEnabled())
1465 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)
1467 if(checkForUpdates())
1469 QApplication::quit();
1477 //Check for AAC support
1478 const int aacEncoder
= EncoderRegistry::getAacEncoder();
1479 if(aacEncoder
== SettingsModel::AAC_ENCODER_NERO
)
1481 if(m_settings
->neroAacNotificationsEnabled())
1483 if(lamexp_tools_version("neroAacEnc.exe") < lamexp_toolver_neroaac())
1485 QString messageText
;
1486 messageText
+= NOBR(tr("LameXP detected that your version of the Nero AAC encoder is outdated!")).append("<br>");
1487 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_tools_version("neroAacEnc.exe"), tr("n/a")))).append("<br><br>");
1488 messageText
+= NOBR(tr("You can download the latest version of the Nero AAC encoder from the Nero website at:")).append("<br>");
1489 messageText
+= "<nobr><tt>" + LINK(AboutDialog::neroAacUrl
) + "</tt></nobr><br><br>";
1490 messageText
+= NOBR(tr("(Hint: Please ignore the name of the downloaded ZIP file and check the included 'changelog.txt' instead!)")).append("<br>");
1491 QMessageBox::information(this, tr("AAC Encoder Outdated"), messageText
);
1497 if(m_settings
->neroAacNotificationsEnabled() && (aacEncoder
<= SettingsModel::AAC_ENCODER_NONE
))
1499 QString appPath
= QDir(QCoreApplication::applicationDirPath()).canonicalPath();
1500 if(appPath
.isEmpty()) appPath
= QCoreApplication::applicationDirPath();
1501 QString messageText
;
1502 messageText
+= NOBR(tr("The Nero AAC encoder could not be found. AAC encoding support will be disabled.")).append("<br>");
1503 messageText
+= NOBR(tr("Please put 'neroAacEnc.exe', 'neroAacDec.exe' and 'neroAacTag.exe' into the LameXP directory!")).append("<br><br>");
1504 messageText
+= NOBR(tr("Your LameXP directory is located here:")).append("<br>");
1505 messageText
+= QString("<nobr><tt>%1</tt></nobr><br><br>").arg(FSLINK(QDir::toNativeSeparators(appPath
)));
1506 messageText
+= NOBR(tr("You can download the Nero AAC encoder for free from the official Nero website at:")).append("<br>");
1507 messageText
+= "<nobr><tt>" + LINK(AboutDialog::neroAacUrl
) + "</tt></nobr><br>";
1508 if(QMessageBox::information(this, tr("AAC Support Disabled"), messageText
, tr("Discard"), tr("Don't Show Again")) == 1)
1510 m_settings
->neroAacNotificationsEnabled(false);
1511 ui
->actionDisableNeroAacNotifications
->setChecked(!m_settings
->neroAacNotificationsEnabled());
1516 //Add files from the command-line
1517 QStringList addedFiles
;
1518 foreach(const QString
&value
, arguments
.values("add"))
1520 if(!value
.isEmpty())
1522 QFileInfo
currentFile(value
);
1523 qDebug("Adding file from CLI: %s", MUTILS_UTF8(currentFile
.absoluteFilePath()));
1524 addedFiles
.append(currentFile
.absoluteFilePath());
1527 if(!addedFiles
.isEmpty())
1529 addFilesDelayed(addedFiles
);
1532 //Add folders from the command-line
1533 foreach(const QString
&value
, arguments
.values("add-folder"))
1535 if(!value
.isEmpty())
1537 const QFileInfo
currentFile(value
);
1538 qDebug("Adding folder from CLI: %s", MUTILS_UTF8(currentFile
.absoluteFilePath()));
1539 addFolder(currentFile
.absoluteFilePath(), false, true);
1542 foreach(const QString
&value
, arguments
.values("add-recursive"))
1544 if(!value
.isEmpty())
1546 const QFileInfo
currentFile(value
);
1547 qDebug("Adding folder recursively from CLI: %s", MUTILS_UTF8(currentFile
.absoluteFilePath()));
1548 addFolder(currentFile
.absoluteFilePath(), true, true);
1552 //Enable shell integration
1553 if(m_settings
->shellIntegrationEnabled())
1555 ShellIntegration::install();
1558 //Make DropBox visible
1559 if(m_settings
->dropBoxWidgetEnabled())
1561 m_dropBox
->setVisible(true);
1568 void MainWindow::showAnnounceBox(void)
1570 const unsigned int timeout
= 8U;
1572 const QString announceText
= QString("%1<br><br>%2<br><nobr><tt>%3</tt></nobr><br>").arg
1574 NOBR("We are still looking for LameXP translators!"),
1575 NOBR("If you are willing to translate LameXP to your language or to complete an existing translation, please refer to:"),
1576 LINK("http://lamexp.sourceforge.net/doc/Translate.html")
1579 QMessageBox
*announceBox
= new QMessageBox(QMessageBox::Warning
, "We want you!", announceText
, QMessageBox::NoButton
, this);
1580 announceBox
->setWindowFlags(Qt::Window
| Qt::WindowTitleHint
| Qt::CustomizeWindowHint
);
1581 announceBox
->setIconPixmap(QIcon(":/images/Announcement.png").pixmap(64,79));
1583 QTimer
*timers
[timeout
+1];
1584 QPushButton
*buttons
[timeout
+1];
1586 for(unsigned int i
= 0; i
<= timeout
; i
++)
1588 QString text
= (i
> 0) ? QString("%1 (%2)").arg(tr("Discard"), QString::number(i
)) : tr("Discard");
1589 buttons
[i
] = announceBox
->addButton(text
, (i
> 0) ? QMessageBox::NoRole
: QMessageBox::AcceptRole
);
1592 for(unsigned int i
= 0; i
<= timeout
; i
++)
1594 buttons
[i
]->setEnabled(i
== 0);
1595 buttons
[i
]->setVisible(i
== timeout
);
1598 for(unsigned int i
= 0; i
< timeout
; i
++)
1600 timers
[i
] = new QTimer(this);
1601 timers
[i
]->setSingleShot(true);
1602 timers
[i
]->setInterval(1000);
1603 connect(timers
[i
], SIGNAL(timeout()), buttons
[i
+1], SLOT(hide()));
1604 connect(timers
[i
], SIGNAL(timeout()), buttons
[i
], SLOT(show()));
1607 connect(timers
[i
], SIGNAL(timeout()), timers
[i
-1], SLOT(start()));
1611 timers
[timeout
-1]->start();
1612 announceBox
->exec();
1614 for(unsigned int i
= 0; i
< timeout
; i
++)
1617 MUTILS_DELETE(timers
[i
]);
1620 MUTILS_DELETE(announceBox
);
1623 // =========================================================
1624 // Main button solots
1625 // =========================================================
1630 void MainWindow::encodeButtonClicked(void)
1632 static const unsigned __int64 oneGigabyte
= 1073741824ui
64;
1633 static const unsigned __int64 minimumFreeDiskspaceMultiplier
= 2ui
64;
1634 static const char *writeTestBuffer
= "LAMEXP_WRITE_TEST";
1638 if(m_fileListModel
->rowCount() < 1)
1640 QMessageBox::warning(this, tr("LameXP"), NOBR(tr("You must add at least one file to the list before proceeding!")));
1641 ui
->tabWidget
->setCurrentIndex(0);
1645 QString tempFolder
= m_settings
->customTempPathEnabled() ? m_settings
->customTempPath() : MUtils::temp_folder();
1646 if(!QFileInfo(tempFolder
).exists() || !QFileInfo(tempFolder
).isDir())
1648 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)
1650 SET_CHECKBOX_STATE(ui
->checkBoxUseSystemTempFolder
, (!m_settings
->customTempPathEnabledDefault()));
1655 quint64 currentFreeDiskspace
= 0;
1656 if(MUtils::OS::free_diskspace(tempFolder
, currentFreeDiskspace
))
1658 if(currentFreeDiskspace
< (oneGigabyte
* minimumFreeDiskspaceMultiplier
))
1660 QStringList tempFolderParts
= tempFolder
.split("/", QString::SkipEmptyParts
, Qt::CaseInsensitive
);
1661 tempFolderParts
.takeLast();
1662 PLAY_SOUND_OPTIONAL("whammy", false);
1663 QString lowDiskspaceMsg
= QString("%1<br>%2<br><br>%3<br>%4<br>").arg
1665 NOBR(tr("There are less than %1 GB of free diskspace available on your system's TEMP folder.").arg(QString::number(minimumFreeDiskspaceMultiplier
))),
1666 NOBR(tr("It is highly recommend to free up more diskspace before proceeding with the encode!")),
1667 NOBR(tr("Your TEMP folder is located at:")),
1668 QString("<nobr><tt>%1</tt></nobr>").arg(FSLINK(tempFolderParts
.join("\\")))
1670 switch(QMessageBox::warning(this, tr("Low Diskspace Warning"), lowDiskspaceMsg
, tr("Abort Encoding Process"), tr("Clean Disk Now"), tr("Ignore")))
1673 QProcess::startDetached(QString("%1/cleanmgr.exe").arg(MUtils::OS::known_folder(MUtils::OS::FOLDER_SYSTEMFOLDER
)), QStringList() << "/D" << tempFolderParts
.first());
1678 QMessageBox::warning(this, tr("Low Diskspace"), NOBR(tr("You are proceeding with low diskspace. Problems might occur!")));
1684 switch(m_settings
->compressionEncoder())
1686 case SettingsModel::MP3Encoder
:
1687 case SettingsModel::VorbisEncoder
:
1688 case SettingsModel::AACEncoder
:
1689 case SettingsModel::AC3Encoder
:
1690 case SettingsModel::FLACEncoder
:
1691 case SettingsModel::OpusEncoder
:
1692 case SettingsModel::DCAEncoder
:
1693 case SettingsModel::MACEncoder
:
1694 case SettingsModel::PCMEncoder
:
1697 QMessageBox::warning(this, tr("LameXP"), tr("Sorry, an unsupported encoder has been chosen!"));
1698 ui
->tabWidget
->setCurrentIndex(3);
1702 if(!m_settings
->outputToSourceDir())
1704 QFile
writeTest(QString("%1/~%2.txt").arg(m_settings
->outputDir(), MUtils::rand_str()));
1705 if(!(writeTest
.open(QIODevice::ReadWrite
) && (writeTest
.write(writeTestBuffer
) == strlen(writeTestBuffer
))))
1707 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!")));
1708 ui
->tabWidget
->setCurrentIndex(1);
1725 void MainWindow::aboutButtonClicked(void)
1731 AboutDialog
*aboutBox
= new AboutDialog(m_settings
, this);
1733 MUTILS_DELETE(aboutBox
);
1740 void MainWindow::closeButtonClicked(void)
1746 // =========================================================
1748 // =========================================================
1753 void MainWindow::tabPageChanged(int idx
, const bool silent
)
1757 //Update "view" menu
1758 QList
<QAction
*> actions
= m_tabActionGroup
->actions();
1759 for(int i
= 0; i
< actions
.count(); i
++)
1762 int actionIndex
= actions
.at(i
)->data().toInt(&ok
);
1763 if(ok
&& actionIndex
== idx
)
1765 actions
.at(i
)->setChecked(true);
1772 PLAY_SOUND_OPTIONAL("tick", true);
1775 int initialWidth
= this->width();
1776 int maximumWidth
= QApplication::desktop()->availableGeometry().width();
1778 //Make sure all tab headers are fully visible
1779 if(this->isVisible())
1781 int delta
= ui
->tabWidget
->sizeHint().width() - ui
->tabWidget
->width();
1784 this->resize(qMin(this->width() + delta
, maximumWidth
), this->height());
1788 //Tab specific operations
1789 if(idx
== ui
->tabWidget
->indexOf(ui
->tabOptions
) && ui
->scrollArea
->widget() && this->isVisible())
1791 ui
->scrollArea
->widget()->updateGeometry();
1792 ui
->scrollArea
->viewport()->updateGeometry();
1793 qApp
->processEvents();
1794 int delta
= ui
->scrollArea
->widget()->width() - ui
->scrollArea
->viewport()->width();
1797 this->resize(qMin(this->width() + delta
, maximumWidth
), this->height());
1800 else if(idx
== ui
->tabWidget
->indexOf(ui
->tabSourceFiles
))
1802 m_dropNoteLabel
->setGeometry(0, 0, ui
->sourceFileView
->width(), ui
->sourceFileView
->height());
1804 else if(idx
== ui
->tabWidget
->indexOf(ui
->tabOutputDir
))
1806 if(!m_fileSystemModel
)
1808 QTimer::singleShot(125, this, SLOT(initOutputFolderModel()));
1812 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
1816 //Center window around previous position
1817 if(initialWidth
< this->width())
1819 QPoint prevPos
= this->pos();
1820 int delta
= (this->width() - initialWidth
) >> 2;
1821 move(prevPos
.x() - delta
, prevPos
.y());
1826 * Tab action triggered
1828 void MainWindow::tabActionActivated(QAction
*action
)
1830 if(action
&& action
->data().isValid())
1833 int index
= action
->data().toInt(&ok
);
1836 ui
->tabWidget
->setCurrentIndex(index
);
1841 // =========================================================
1843 // =========================================================
1846 * Handle corner widget Event
1848 void MainWindow::cornerWidgetEventOccurred(QWidget
*sender
, QEvent
*event
)
1850 if(event
->type() == QEvent::MouseButtonPress
)
1852 QTimer::singleShot(0, this, SLOT(checkUpdatesActionActivated()));
1856 // =========================================================
1858 // =========================================================
1861 * Style action triggered
1863 void MainWindow::styleActionActivated(QAction
*action
)
1865 //Change style setting
1866 if(action
&& action
->data().isValid())
1869 int actionIndex
= action
->data().toInt(&ok
);
1872 m_settings
->interfaceStyle(actionIndex
);
1876 //Set up the new style
1877 switch(m_settings
->interfaceStyle())
1880 if(ui
->actionStyleCleanlooks
->isEnabled())
1882 ui
->actionStyleCleanlooks
->setChecked(true);
1883 QApplication::setStyle(new QCleanlooksStyle());
1887 if(ui
->actionStyleWindowsVista
->isEnabled())
1889 ui
->actionStyleWindowsVista
->setChecked(true);
1890 QApplication::setStyle(new QWindowsVistaStyle());
1894 if(ui
->actionStyleWindowsXP
->isEnabled())
1896 ui
->actionStyleWindowsXP
->setChecked(true);
1897 QApplication::setStyle(new QWindowsXPStyle());
1901 if(ui
->actionStyleWindowsClassic
->isEnabled())
1903 ui
->actionStyleWindowsClassic
->setChecked(true);
1904 QApplication::setStyle(new QWindowsStyle());
1908 ui
->actionStylePlastique
->setChecked(true);
1909 QApplication::setStyle(new QPlastiqueStyle());
1913 //Force re-translate after style change
1914 if(QEvent
*e
= new QEvent(QEvent::LanguageChange
))
1921 const type_info
&styleType
= typeid(*qApp
->style());
1922 const bool bTransparent
= ((typeid(QWindowsVistaStyle
) == styleType
) || (typeid(QWindowsXPStyle
) == styleType
));
1923 MAKE_TRANSPARENT(ui
->scrollArea
, bTransparent
);
1925 //Also force a re-size event
1926 QApplication::processEvents(QEventLoop::ExcludeUserInputEvents
);
1931 * Language action triggered
1933 void MainWindow::languageActionActivated(QAction
*action
)
1935 if(action
->data().type() == QVariant::String
)
1937 QString langId
= action
->data().toString();
1939 if(MUtils::Translation::install_translator(langId
))
1941 action
->setChecked(true);
1942 ui
->actionLoadTranslationFromFile
->setChecked(false);
1943 m_settings
->currentLanguage(langId
);
1944 m_settings
->currentLanguageFile(QString());
1950 * Load language from file action triggered
1952 void MainWindow::languageFromFileActionActivated(bool checked
)
1954 QFileDialog
dialog(this, tr("Load Translation"));
1955 dialog
.setFileMode(QFileDialog::ExistingFile
);
1956 dialog
.setNameFilter(QString("%1 (*.qm)").arg(tr("Translation Files")));
1960 QStringList selectedFiles
= dialog
.selectedFiles();
1961 const QString qmFile
= QFileInfo(selectedFiles
.first()).canonicalFilePath();
1962 if(MUtils::Translation::install_translator_from_file(qmFile
))
1964 QList
<QAction
*> actions
= m_languageActionGroup
->actions();
1965 while(!actions
.isEmpty())
1967 actions
.takeFirst()->setChecked(false);
1969 ui
->actionLoadTranslationFromFile
->setChecked(true);
1970 m_settings
->currentLanguageFile(qmFile
);
1974 languageActionActivated(m_languageActionGroup
->actions().first());
1979 // =========================================================
1981 // =========================================================
1984 * Disable update reminder action
1986 void MainWindow::disableUpdateReminderActionTriggered(bool checked
)
1990 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))
1992 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!"))));
1993 m_settings
->autoUpdateEnabled(false);
1997 m_settings
->autoUpdateEnabled(true);
2002 QMessageBox::information(this, tr("Update Reminder"), NOBR(tr("The update reminder has been re-enabled.")));
2003 m_settings
->autoUpdateEnabled(true);
2006 ui
->actionDisableUpdateReminder
->setChecked(!m_settings
->autoUpdateEnabled());
2010 * Disable sound effects action
2012 void MainWindow::disableSoundsActionTriggered(bool checked
)
2016 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))
2018 QMessageBox::information(this, tr("Sound Effects"), NOBR(tr("All sound effects have been disabled.")));
2019 m_settings
->soundsEnabled(false);
2023 m_settings
->soundsEnabled(true);
2028 QMessageBox::information(this, tr("Sound Effects"), NOBR(tr("The sound effects have been re-enabled.")));
2029 m_settings
->soundsEnabled(true);
2032 ui
->actionDisableSounds
->setChecked(!m_settings
->soundsEnabled());
2036 * Disable Nero AAC encoder action
2038 void MainWindow::disableNeroAacNotificationsActionTriggered(bool checked
)
2042 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))
2044 QMessageBox::information(this, tr("Nero AAC Notifications"), NOBR(tr("All Nero AAC Encoder notifications have been disabled.")));
2045 m_settings
->neroAacNotificationsEnabled(false);
2049 m_settings
->neroAacNotificationsEnabled(true);
2054 QMessageBox::information(this, tr("Nero AAC Notifications"), NOBR(tr("The Nero AAC Encoder notifications have been re-enabled.")));
2055 m_settings
->neroAacNotificationsEnabled(true);
2058 ui
->actionDisableNeroAacNotifications
->setChecked(!m_settings
->neroAacNotificationsEnabled());
2062 * Disable slow startup action
2064 void MainWindow::disableSlowStartupNotificationsActionTriggered(bool checked
)
2068 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))
2070 QMessageBox::information(this, tr("Slow Startup Notifications"), NOBR(tr("The slow startup notifications have been disabled.")));
2071 m_settings
->antivirNotificationsEnabled(false);
2075 m_settings
->antivirNotificationsEnabled(true);
2080 QMessageBox::information(this, tr("Slow Startup Notifications"), NOBR(tr("The slow startup notifications have been re-enabled.")));
2081 m_settings
->antivirNotificationsEnabled(true);
2084 ui
->actionDisableSlowStartupNotifications
->setChecked(!m_settings
->antivirNotificationsEnabled());
2088 * Import a Cue Sheet file
2090 void MainWindow::importCueSheetActionTriggered(bool checked
)
2099 QString selectedCueFile
;
2101 if(MUtils::GUI::themes_enabled())
2103 selectedCueFile
= QFileDialog::getOpenFileName(this, tr("Open Cue Sheet"), m_settings
->mostRecentInputPath(), QString("%1 (*.cue)").arg(tr("Cue Sheet File")));
2107 QFileDialog
dialog(this, tr("Open Cue Sheet"));
2108 dialog
.setFileMode(QFileDialog::ExistingFile
);
2109 dialog
.setNameFilter(QString("%1 (*.cue)").arg(tr("Cue Sheet File")));
2110 dialog
.setDirectory(m_settings
->mostRecentInputPath());
2113 selectedCueFile
= dialog
.selectedFiles().first();
2117 if(!selectedCueFile
.isEmpty())
2119 m_settings
->mostRecentInputPath(QFileInfo(selectedCueFile
).canonicalPath());
2120 CueImportDialog
*cueImporter
= new CueImportDialog(this, m_fileListModel
, selectedCueFile
, m_settings
);
2121 result
= cueImporter
->exec();
2122 MUTILS_DELETE(cueImporter
);
2125 if(result
== QDialog::Accepted
)
2127 qApp
->processEvents(QEventLoop::ExcludeUserInputEvents
);
2128 ui
->sourceFileView
->update();
2129 qApp
->processEvents(QEventLoop::ExcludeUserInputEvents
);
2130 ui
->sourceFileView
->scrollToBottom();
2131 qApp
->processEvents(QEventLoop::ExcludeUserInputEvents
);
2134 if(result
!= (-1)) break;
2140 * Show the "drop box" widget
2142 void MainWindow::showDropBoxWidgetActionTriggered(bool checked
)
2144 m_settings
->dropBoxWidgetEnabled(true);
2146 if(!m_dropBox
->isVisible())
2149 QTimer::singleShot(2500, m_dropBox
, SLOT(showToolTip()));
2152 MUtils::GUI::blink_window(m_dropBox
);
2156 * Check for beta (pre-release) updates
2158 void MainWindow::checkForBetaUpdatesActionTriggered(bool checked
)
2160 bool checkUpdatesNow
= false;
2164 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))
2166 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")))
2168 checkUpdatesNow
= true;
2170 m_settings
->autoUpdateCheckBeta(true);
2174 m_settings
->autoUpdateCheckBeta(false);
2179 QMessageBox::information(this, tr("Beta Updates"), NOBR(tr("LameXP will <i>not</i> check for Beta (pre-release) updates from now on.")));
2180 m_settings
->autoUpdateCheckBeta(false);
2183 ui
->actionCheckForBetaUpdates
->setChecked(m_settings
->autoUpdateCheckBeta());
2187 if(checkForUpdates())
2189 QApplication::quit();
2195 * Hibernate computer action
2197 void MainWindow::hibernateComputerActionTriggered(bool checked
)
2201 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))
2203 QMessageBox::information(this, tr("Hibernate Computer"), NOBR(tr("LameXP will hibernate the computer on shutdown from now on.")));
2204 m_settings
->hibernateComputer(true);
2208 m_settings
->hibernateComputer(false);
2213 QMessageBox::information(this, tr("Hibernate Computer"), NOBR(tr("LameXP will <i>not</i> hibernate the computer on shutdown from now on.")));
2214 m_settings
->hibernateComputer(false);
2217 ui
->actionHibernateComputer
->setChecked(m_settings
->hibernateComputer());
2221 * Disable shell integration action
2223 void MainWindow::disableShellIntegrationActionTriggered(bool checked
)
2227 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))
2229 ShellIntegration::remove();
2230 QMessageBox::information(this, tr("Shell Integration"), NOBR(tr("The LameXP shell integration has been disabled.")));
2231 m_settings
->shellIntegrationEnabled(false);
2235 m_settings
->shellIntegrationEnabled(true);
2240 ShellIntegration::install();
2241 QMessageBox::information(this, tr("Shell Integration"), NOBR(tr("The LameXP shell integration has been re-enabled.")));
2242 m_settings
->shellIntegrationEnabled(true);
2245 ui
->actionDisableShellIntegration
->setChecked(!m_settings
->shellIntegrationEnabled());
2247 if(lamexp_version_portable() && ui
->actionDisableShellIntegration
->isChecked())
2249 ui
->actionDisableShellIntegration
->setEnabled(false);
2253 // =========================================================
2255 // =========================================================
2258 * Visit homepage action
2260 void MainWindow::visitHomepageActionActivated(void)
2262 if(QAction
*action
= dynamic_cast<QAction
*>(QObject::sender()))
2264 if(action
->data().isValid() && (action
->data().type() == QVariant::String
))
2266 QDesktopServices::openUrl(QUrl(action
->data().toString()));
2274 void MainWindow::documentActionActivated(void)
2276 if(QAction
*action
= dynamic_cast<QAction
*>(QObject::sender()))
2278 openDocumentLink(action
);
2283 * Check for updates action
2285 void MainWindow::checkUpdatesActionActivated(void)
2292 bFlag
= checkForUpdates();
2297 QApplication::quit();
2301 // =========================================================
2302 // Source file slots
2303 // =========================================================
2306 * Add file(s) button
2308 void MainWindow::addFilesButtonClicked(void)
2314 if(MUtils::GUI::themes_enabled())
2316 QStringList fileTypeFilters
= DecoderRegistry::getSupportedTypes();
2317 QStringList selectedFiles
= QFileDialog::getOpenFileNames(this, tr("Add file(s)"), m_settings
->mostRecentInputPath(), fileTypeFilters
.join(";;"));
2318 if(!selectedFiles
.isEmpty())
2320 m_settings
->mostRecentInputPath(QFileInfo(selectedFiles
.first()).canonicalPath());
2321 addFiles(selectedFiles
);
2326 QFileDialog
dialog(this, tr("Add file(s)"));
2327 QStringList fileTypeFilters
= DecoderRegistry::getSupportedTypes();
2328 dialog
.setFileMode(QFileDialog::ExistingFiles
);
2329 dialog
.setNameFilter(fileTypeFilters
.join(";;"));
2330 dialog
.setDirectory(m_settings
->mostRecentInputPath());
2333 QStringList selectedFiles
= dialog
.selectedFiles();
2334 if(!selectedFiles
.isEmpty())
2336 m_settings
->mostRecentInputPath(QFileInfo(selectedFiles
.first()).canonicalPath());
2337 addFiles(selectedFiles
);
2345 * Open folder action
2347 void MainWindow::openFolderActionActivated(void)
2350 QString selectedFolder
;
2352 if(QAction
*action
= dynamic_cast<QAction
*>(QObject::sender()))
2356 if(MUtils::GUI::themes_enabled())
2358 selectedFolder
= QFileDialog::getExistingDirectory(this, tr("Add Folder"), m_settings
->mostRecentInputPath());
2362 QFileDialog
dialog(this, tr("Add Folder"));
2363 dialog
.setFileMode(QFileDialog::DirectoryOnly
);
2364 dialog
.setDirectory(m_settings
->mostRecentInputPath());
2367 selectedFolder
= dialog
.selectedFiles().first();
2371 if(selectedFolder
.isEmpty())
2376 QRegExp
regExp("\\((.+)\\)", Qt::CaseInsensitive
);
2377 const QStringList supportedTypes
= DecoderRegistry::getSupportedTypes();
2378 QStringList
filterItems("*.*");
2379 for(QStringList::ConstIterator iter
= supportedTypes
.constBegin(); iter
!= supportedTypes
.constEnd(); iter
++)
2381 if(regExp
.lastIndexIn(*iter
) >= 0)
2383 const QStringList extensions
= regExp
.cap(1).split(' ', QString::SkipEmptyParts
);
2384 for(QStringList::ConstIterator iter2
= extensions
.constBegin(); iter2
!= extensions
.constEnd(); iter2
++)
2386 if(!filterItems
.contains((*iter2
), Qt::CaseInsensitive
)) filterItems
<< (*iter2
);
2392 QString filterStr
= QInputDialog::getItem(this, tr("Filter Files"), tr("Select filename filter:"), filterItems
, 0, false, &okay
).trimmed();
2398 QRegExp
regExp2("\\*\\.([A-Za-z0-9]+)", Qt::CaseInsensitive
);
2399 if(regExp2
.lastIndexIn(filterStr
) >= 0)
2401 filterStr
= regExp2
.cap(1).trimmed();
2408 m_settings
->mostRecentInputPath(QDir(selectedFolder
).canonicalPath());
2409 addFolder(selectedFolder
, action
->data().toBool(), false, filterStr
);
2415 * Remove file button
2417 void MainWindow::removeFileButtonClicked(void)
2419 if(ui
->sourceFileView
->currentIndex().isValid())
2421 int iRow
= ui
->sourceFileView
->currentIndex().row();
2422 m_fileListModel
->removeFile(ui
->sourceFileView
->currentIndex());
2423 ui
->sourceFileView
->selectRow(iRow
< m_fileListModel
->rowCount() ? iRow
: m_fileListModel
->rowCount()-1);
2428 * Clear files button
2430 void MainWindow::clearFilesButtonClicked(void)
2432 m_fileListModel
->clearFiles();
2436 * Move file up button
2438 void MainWindow::fileUpButtonClicked(void)
2440 if(ui
->sourceFileView
->currentIndex().isValid())
2442 int iRow
= ui
->sourceFileView
->currentIndex().row() - 1;
2443 m_fileListModel
->moveFile(ui
->sourceFileView
->currentIndex(), -1);
2444 ui
->sourceFileView
->selectRow(iRow
>= 0 ? iRow
: 0);
2449 * Move file down button
2451 void MainWindow::fileDownButtonClicked(void)
2453 if(ui
->sourceFileView
->currentIndex().isValid())
2455 int iRow
= ui
->sourceFileView
->currentIndex().row() + 1;
2456 m_fileListModel
->moveFile(ui
->sourceFileView
->currentIndex(), 1);
2457 ui
->sourceFileView
->selectRow(iRow
< m_fileListModel
->rowCount() ? iRow
: m_fileListModel
->rowCount()-1);
2462 * Show details button
2464 void MainWindow::showDetailsButtonClicked(void)
2469 MetaInfoDialog
*metaInfoDialog
= new MetaInfoDialog(this);
2470 QModelIndex index
= ui
->sourceFileView
->currentIndex();
2472 while(index
.isValid())
2476 index
= m_fileListModel
->index(index
.row() + 1, index
.column());
2477 ui
->sourceFileView
->selectRow(index
.row());
2481 index
= m_fileListModel
->index(index
.row() - 1, index
.column());
2482 ui
->sourceFileView
->selectRow(index
.row());
2485 AudioFileModel
&file
= (*m_fileListModel
)[index
];
2488 iResult
= metaInfoDialog
->exec(file
, index
.row() > 0, index
.row() < m_fileListModel
->rowCount() - 1);
2491 //Copy all info to Meta Info tab
2492 if(iResult
== INT_MAX
)
2494 m_metaInfoModel
->assignInfoFrom(file
);
2495 ui
->tabWidget
->setCurrentIndex(ui
->tabWidget
->indexOf(ui
->tabMetaData
));
2502 MUTILS_DELETE(metaInfoDialog
);
2503 QApplication::processEvents(QEventLoop::ExcludeUserInputEvents
);
2504 sourceFilesScrollbarMoved(0);
2508 * Show context menu for source files
2510 void MainWindow::sourceFilesContextMenu(const QPoint
&pos
)
2512 QAbstractScrollArea
*scrollArea
= dynamic_cast<QAbstractScrollArea
*>(QObject::sender());
2513 QWidget
*sender
= scrollArea
? scrollArea
->viewport() : dynamic_cast<QWidget
*>(QObject::sender());
2517 if(pos
.x() <= sender
->width() && pos
.y() <= sender
->height() && pos
.x() >= 0 && pos
.y() >= 0)
2519 m_sourceFilesContextMenu
->popup(sender
->mapToGlobal(pos
));
2525 * Scrollbar of source files moved
2527 void MainWindow::sourceFilesScrollbarMoved(int)
2529 ui
->sourceFileView
->resizeColumnToContents(0);
2533 * Open selected file in external player
2535 void MainWindow::previewContextActionTriggered(void)
2537 QModelIndex index
= ui
->sourceFileView
->currentIndex();
2538 if(!index
.isValid())
2543 if(!MUtils::OS::open_media_file(m_fileListModel
->getFile(index
).filePath()))
2545 qDebug("Player not found, falling back to default application...");
2546 QDesktopServices::openUrl(QString("file:///").append(m_fileListModel
->getFile(index
).filePath()));
2551 * Find selected file in explorer
2553 void MainWindow::findFileContextActionTriggered(void)
2555 QModelIndex index
= ui
->sourceFileView
->currentIndex();
2558 QString systemRootPath
;
2560 QDir
systemRoot(MUtils::OS::known_folder(MUtils::OS::FOLDER_SYSTEMFOLDER
));
2561 if(systemRoot
.exists() && systemRoot
.cdUp())
2563 systemRootPath
= systemRoot
.canonicalPath();
2566 if(!systemRootPath
.isEmpty())
2568 QFileInfo
explorer(QString("%1/explorer.exe").arg(systemRootPath
));
2569 if(explorer
.exists() && explorer
.isFile())
2571 QProcess::execute(explorer
.canonicalFilePath(), QStringList() << "/select," << QDir::toNativeSeparators(m_fileListModel
->getFile(index
).filePath()));
2577 qWarning("SystemRoot directory could not be detected!");
2583 * Add all dropped files
2585 void MainWindow::handleDroppedFiles(void)
2589 static const int MIN_COUNT
= 16;
2590 const QString bannerText
= tr("Loading dropped files or folders, please wait...");
2591 bool bUseBanner
= false;
2593 SHOW_BANNER_CONDITIONALLY(bUseBanner
, (m_droppedFileList
->count() >= MIN_COUNT
), bannerText
);
2595 QStringList droppedFiles
;
2596 while(!m_droppedFileList
->isEmpty())
2598 QFileInfo
file(m_droppedFileList
->takeFirst().toLocalFile());
2599 QApplication::processEvents(QEventLoop::ExcludeUserInputEvents
);
2608 qDebug("Dropped File: %s", MUTILS_UTF8(file
.canonicalFilePath()));
2609 droppedFiles
<< file
.canonicalFilePath();
2615 qDebug("Dropped Folder: %s", MUTILS_UTF8(file
.canonicalFilePath()));
2616 QFileInfoList list
= QDir(file
.canonicalFilePath()).entryInfoList(QDir::Files
| QDir::NoDotAndDotDot
| QDir::NoSymLinks
);
2617 if(list
.count() > 0)
2619 SHOW_BANNER_CONDITIONALLY(bUseBanner
, (list
.count() >= MIN_COUNT
), bannerText
);
2620 for(QFileInfoList::ConstIterator iter
= list
.constBegin(); iter
!= list
.constEnd(); iter
++)
2622 droppedFiles
<< (*iter
).canonicalFilePath();
2627 list
= QDir(file
.canonicalFilePath()).entryInfoList(QDir::Dirs
| QDir::NoDotAndDotDot
| QDir::NoSymLinks
);
2628 SHOW_BANNER_CONDITIONALLY(bUseBanner
, (list
.count() >= MIN_COUNT
), bannerText
);
2629 for(QFileInfoList::ConstIterator iter
= list
.constBegin(); iter
!= list
.constEnd(); iter
++)
2631 qDebug("Descending to Folder: %s", MUTILS_UTF8((*iter
).canonicalFilePath()));
2632 m_droppedFileList
->prepend(QUrl::fromLocalFile((*iter
).canonicalFilePath()));
2643 if(!droppedFiles
.isEmpty())
2645 addFiles(droppedFiles
);
2650 * Add all pending files
2652 void MainWindow::handleDelayedFiles(void)
2654 m_delayedFileTimer
->stop();
2656 if(m_delayedFileList
->isEmpty())
2663 m_delayedFileTimer
->start(5000);
2667 WITH_BLOCKED_SIGNALS(ui
->tabWidget
, setCurrentIndex
, 0);
2668 tabPageChanged(ui
->tabWidget
->currentIndex(), true);
2670 QStringList selectedFiles
;
2671 while(!m_delayedFileList
->isEmpty())
2673 QFileInfo currentFile
= QFileInfo(m_delayedFileList
->takeFirst());
2674 if(!currentFile
.exists() || !currentFile
.isFile())
2678 selectedFiles
<< currentFile
.canonicalFilePath();
2681 addFiles(selectedFiles
);
2685 * Export Meta tags to CSV file
2687 void MainWindow::exportCsvContextActionTriggered(void)
2691 QString selectedCsvFile
;
2693 if(MUtils::GUI::themes_enabled())
2695 selectedCsvFile
= QFileDialog::getSaveFileName(this, tr("Save CSV file"), m_settings
->mostRecentInputPath(), QString("%1 (*.csv)").arg(tr("CSV File")));
2699 QFileDialog
dialog(this, tr("Save CSV file"));
2700 dialog
.setFileMode(QFileDialog::AnyFile
);
2701 dialog
.setAcceptMode(QFileDialog::AcceptSave
);
2702 dialog
.setNameFilter(QString("%1 (*.csv)").arg(tr("CSV File")));
2703 dialog
.setDirectory(m_settings
->mostRecentInputPath());
2706 selectedCsvFile
= dialog
.selectedFiles().first();
2710 if(!selectedCsvFile
.isEmpty())
2712 m_settings
->mostRecentInputPath(QFileInfo(selectedCsvFile
).canonicalPath());
2713 switch(m_fileListModel
->exportToCsv(selectedCsvFile
))
2715 case FileListModel::CsvError_NoTags
:
2716 QMessageBox::critical(this, tr("CSV Export"), NOBR(tr("Sorry, there are no meta tags that can be exported!")));
2718 case FileListModel::CsvError_FileOpen
:
2719 QMessageBox::critical(this, tr("CSV Export"), NOBR(tr("Sorry, failed to open CSV file for writing!")));
2721 case FileListModel::CsvError_FileWrite
:
2722 QMessageBox::critical(this, tr("CSV Export"), NOBR(tr("Sorry, failed to write to the CSV file!")));
2724 case FileListModel::CsvError_OK
:
2725 QMessageBox::information(this, tr("CSV Export"), NOBR(tr("The CSV files was created successfully!")));
2728 qWarning("exportToCsv: Unknown return code!");
2736 * Import Meta tags from CSV file
2738 void MainWindow::importCsvContextActionTriggered(void)
2742 QString selectedCsvFile
;
2744 if(MUtils::GUI::themes_enabled())
2746 selectedCsvFile
= QFileDialog::getOpenFileName(this, tr("Open CSV file"), m_settings
->mostRecentInputPath(), QString("%1 (*.csv)").arg(tr("CSV File")));
2750 QFileDialog
dialog(this, tr("Open CSV file"));
2751 dialog
.setFileMode(QFileDialog::ExistingFile
);
2752 dialog
.setNameFilter(QString("%1 (*.csv)").arg(tr("CSV File")));
2753 dialog
.setDirectory(m_settings
->mostRecentInputPath());
2756 selectedCsvFile
= dialog
.selectedFiles().first();
2760 if(!selectedCsvFile
.isEmpty())
2762 m_settings
->mostRecentInputPath(QFileInfo(selectedCsvFile
).canonicalPath());
2763 switch(m_fileListModel
->importFromCsv(this, selectedCsvFile
))
2765 case FileListModel::CsvError_FileOpen
:
2766 QMessageBox::critical(this, tr("CSV Import"), NOBR(tr("Sorry, failed to open CSV file for reading!")));
2768 case FileListModel::CsvError_FileRead
:
2769 QMessageBox::critical(this, tr("CSV Import"), NOBR(tr("Sorry, failed to read from the CSV file!")));
2771 case FileListModel::CsvError_NoTags
:
2772 QMessageBox::critical(this, tr("CSV Import"), NOBR(tr("Sorry, the CSV file does not contain any known fields!")));
2774 case FileListModel::CsvError_Incomplete
:
2775 QMessageBox::warning(this, tr("CSV Import"), NOBR(tr("CSV file is incomplete. Not all files were updated!")));
2777 case FileListModel::CsvError_OK
:
2778 QMessageBox::information(this, tr("CSV Import"), NOBR(tr("The CSV files was imported successfully!")));
2780 case FileListModel::CsvError_Aborted
:
2781 /* User aborted, ignore! */
2784 qWarning("exportToCsv: Unknown return code!");
2791 * Show or hide Drag'n'Drop notice after model reset
2793 void MainWindow::sourceModelChanged(void)
2795 m_dropNoteLabel
->setVisible(m_fileListModel
->rowCount() <= 0);
2798 // =========================================================
2799 // Output folder slots
2800 // =========================================================
2803 * Output folder changed (mouse clicked)
2805 void MainWindow::outputFolderViewClicked(const QModelIndex
&index
)
2807 if(index
.isValid() && (ui
->outputFolderView
->currentIndex() != index
))
2809 ui
->outputFolderView
->setCurrentIndex(index
);
2812 if(m_fileSystemModel
&& index
.isValid())
2814 QString selectedDir
= m_fileSystemModel
->filePath(index
);
2815 if(selectedDir
.length() < 3) selectedDir
.append(QDir::separator());
2816 ui
->outputFolderLabel
->setText(QDir::toNativeSeparators(selectedDir
));
2817 ui
->outputFolderLabel
->setToolTip(ui
->outputFolderLabel
->text());
2818 m_settings
->outputDir(selectedDir
);
2822 ui
->outputFolderLabel
->setText(QDir::toNativeSeparators(m_settings
->outputDir()));
2823 ui
->outputFolderLabel
->setToolTip(ui
->outputFolderLabel
->text());
2828 * Output folder changed (mouse moved)
2830 void MainWindow::outputFolderViewMoved(const QModelIndex
&index
)
2832 if(QApplication::mouseButtons() & Qt::LeftButton
)
2834 outputFolderViewClicked(index
);
2839 * Goto desktop button
2841 void MainWindow::gotoDesktopButtonClicked(void)
2843 if(!m_fileSystemModel
)
2845 qWarning("File system model not initialized yet!");
2849 QString desktopPath
= QDesktopServices::storageLocation(QDesktopServices::DesktopLocation
);
2851 if(!desktopPath
.isEmpty() && QDir(desktopPath
).exists())
2853 ui
->outputFolderView
->setCurrentIndex(m_fileSystemModel
->index(desktopPath
));
2854 outputFolderViewClicked(ui
->outputFolderView
->currentIndex());
2855 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
2859 ui
->buttonGotoDesktop
->setEnabled(false);
2864 * Goto home folder button
2866 void MainWindow::gotoHomeFolderButtonClicked(void)
2868 if(!m_fileSystemModel
)
2870 qWarning("File system model not initialized yet!");
2874 QString homePath
= QDesktopServices::storageLocation(QDesktopServices::HomeLocation
);
2876 if(!homePath
.isEmpty() && QDir(homePath
).exists())
2878 ui
->outputFolderView
->setCurrentIndex(m_fileSystemModel
->index(homePath
));
2879 outputFolderViewClicked(ui
->outputFolderView
->currentIndex());
2880 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
2884 ui
->buttonGotoHome
->setEnabled(false);
2889 * Goto music folder button
2891 void MainWindow::gotoMusicFolderButtonClicked(void)
2893 if(!m_fileSystemModel
)
2895 qWarning("File system model not initialized yet!");
2899 QString musicPath
= QDesktopServices::storageLocation(QDesktopServices::MusicLocation
);
2901 if(!musicPath
.isEmpty() && QDir(musicPath
).exists())
2903 ui
->outputFolderView
->setCurrentIndex(m_fileSystemModel
->index(musicPath
));
2904 outputFolderViewClicked(ui
->outputFolderView
->currentIndex());
2905 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
2909 ui
->buttonGotoMusic
->setEnabled(false);
2914 * Goto music favorite output folder
2916 void MainWindow::gotoFavoriteFolder(void)
2918 if(!m_fileSystemModel
)
2920 qWarning("File system model not initialized yet!");
2924 QAction
*item
= dynamic_cast<QAction
*>(QObject::sender());
2928 QDir
path(item
->data().toString());
2931 ui
->outputFolderView
->setCurrentIndex(m_fileSystemModel
->index(path
.canonicalPath()));
2932 outputFolderViewClicked(ui
->outputFolderView
->currentIndex());
2933 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
2937 MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
);
2938 m_outputFolderFavoritesMenu
->removeAction(item
);
2939 item
->deleteLater();
2945 * Make folder button
2947 void MainWindow::makeFolderButtonClicked(void)
2951 if(!m_fileSystemModel
)
2953 qWarning("File system model not initialized yet!");
2957 QDir
basePath(m_fileSystemModel
->fileInfo(ui
->outputFolderView
->currentIndex()).absoluteFilePath());
2958 QString suggestedName
= tr("New Folder");
2960 if(!m_metaData
->artist().isEmpty() && !m_metaData
->album().isEmpty())
2962 suggestedName
= QString("%1 - %2").arg(m_metaData
->artist(),m_metaData
->album());
2964 else if(!m_metaData
->artist().isEmpty())
2966 suggestedName
= m_metaData
->artist();
2968 else if(!m_metaData
->album().isEmpty())
2970 suggestedName
=m_metaData
->album();
2974 for(int i
= 0; i
< m_fileListModel
->rowCount(); i
++)
2976 const AudioFileModel
&audioFile
= m_fileListModel
->getFile(m_fileListModel
->index(i
, 0));
2977 const AudioFileModel_MetaInfo
&fileMetaInfo
= audioFile
.metaInfo();
2979 if(!fileMetaInfo
.album().isEmpty() || !fileMetaInfo
.artist().isEmpty())
2981 if(!fileMetaInfo
.artist().isEmpty() && !fileMetaInfo
.album().isEmpty())
2983 suggestedName
= QString("%1 - %2").arg(fileMetaInfo
.artist(), fileMetaInfo
.album());
2985 else if(!fileMetaInfo
.artist().isEmpty())
2987 suggestedName
= fileMetaInfo
.artist();
2989 else if(!fileMetaInfo
.album().isEmpty())
2991 suggestedName
= fileMetaInfo
.album();
2998 suggestedName
= MUtils::clean_file_name(suggestedName
);
3002 bool bApplied
= false;
3003 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();
3007 folderName
= MUtils::clean_file_path(folderName
.simplified());
3009 if(folderName
.isEmpty())
3011 MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
);
3016 QString newFolder
= folderName
;
3018 while(basePath
.exists(newFolder
))
3020 newFolder
= QString(folderName
).append(QString().sprintf(" (%d)", ++i
));
3023 if(basePath
.mkpath(newFolder
))
3025 QDir createdDir
= basePath
;
3026 if(createdDir
.cd(newFolder
))
3028 QModelIndex newIndex
= m_fileSystemModel
->index(createdDir
.canonicalPath());
3029 ui
->outputFolderView
->setCurrentIndex(newIndex
);
3030 outputFolderViewClicked(newIndex
);
3031 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
3036 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!")));
3044 * Output to source dir changed
3046 void MainWindow::saveToSourceFolderChanged(void)
3048 m_settings
->outputToSourceDir(ui
->saveToSourceFolderCheckBox
->isChecked());
3052 * Prepend relative source file path to output file name changed
3054 void MainWindow::prependRelativePathChanged(void)
3056 m_settings
->prependRelativeSourcePath(ui
->prependRelativePathCheckBox
->isChecked());
3060 * Show context menu for output folder
3062 void MainWindow::outputFolderContextMenu(const QPoint
&pos
)
3064 QAbstractScrollArea
*scrollArea
= dynamic_cast<QAbstractScrollArea
*>(QObject::sender());
3065 QWidget
*sender
= scrollArea
? scrollArea
->viewport() : dynamic_cast<QWidget
*>(QObject::sender());
3067 if(pos
.x() <= sender
->width() && pos
.y() <= sender
->height() && pos
.x() >= 0 && pos
.y() >= 0)
3069 m_outputFolderContextMenu
->popup(sender
->mapToGlobal(pos
));
3074 * Show selected folder in explorer
3076 void MainWindow::showFolderContextActionTriggered(void)
3078 if(!m_fileSystemModel
)
3080 qWarning("File system model not initialized yet!");
3084 QString path
= QDir::toNativeSeparators(m_fileSystemModel
->filePath(ui
->outputFolderView
->currentIndex()));
3085 if(!path
.endsWith(QDir::separator())) path
.append(QDir::separator());
3086 MUtils::OS::shell_open(this, path
, true);
3090 * Refresh the directory outline
3092 void MainWindow::refreshFolderContextActionTriggered(void)
3094 //force re-initialization
3095 QTimer::singleShot(0, this, SLOT(initOutputFolderModel()));
3099 * Go one directory up
3101 void MainWindow::goUpFolderContextActionTriggered(void)
3103 QModelIndex current
= ui
->outputFolderView
->currentIndex();
3104 if(current
.isValid())
3106 QModelIndex parent
= current
.parent();
3107 if(parent
.isValid())
3110 ui
->outputFolderView
->setCurrentIndex(parent
);
3111 outputFolderViewClicked(parent
);
3115 MUtils::Sound::beep(MUtils::Sound::BEEP_WRN
);
3117 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
3122 * Add current folder to favorites
3124 void MainWindow::addFavoriteFolderActionTriggered(void)
3126 QString path
= m_fileSystemModel
->filePath(ui
->outputFolderView
->currentIndex());
3127 QStringList favorites
= m_settings
->favoriteOutputFolders().split("|", QString::SkipEmptyParts
);
3129 if(!favorites
.contains(path
, Qt::CaseInsensitive
))
3131 favorites
.append(path
);
3132 while(favorites
.count() > 6) favorites
.removeFirst();
3136 MUtils::Sound::beep(MUtils::Sound::BEEP_WRN
);
3139 m_settings
->favoriteOutputFolders(favorites
.join("|"));
3144 * Output folder edit finished
3146 void MainWindow::outputFolderEditFinished(void)
3148 if(ui
->outputFolderEdit
->isHidden())
3150 return; //Not currently in edit mode!
3155 QString text
= QDir::fromNativeSeparators(ui
->outputFolderEdit
->text().trimmed());
3156 while(text
.startsWith('"') || text
.startsWith('/')) text
= text
.right(text
.length() - 1).trimmed();
3157 while(text
.endsWith('"') || text
.endsWith('/')) text
= text
.left(text
.length() - 1).trimmed();
3159 static const char *str
= "?*<>|\"";
3160 for(size_t i
= 0; str
[i
]; i
++) text
.replace(str
[i
], "_");
3162 if(!((text
.length() >= 2) && text
.at(0).isLetter() && text
.at(1) == QChar(':')))
3164 text
= QString("%1/%2").arg(QDir::fromNativeSeparators(ui
->outputFolderLabel
->text()), text
);
3167 if(text
.length() == 2) text
+= "/"; /* "X:" => "X:/" */
3169 while(text
.length() > 2)
3171 QFileInfo
info(text
);
3172 if(info
.exists() && info
.isDir())
3174 QModelIndex index
= m_fileSystemModel
->index(QFileInfo(info
.canonicalFilePath()).absoluteFilePath());
3178 ui
->outputFolderView
->setCurrentIndex(index
);
3179 outputFolderViewClicked(index
);
3183 else if(info
.exists() && info
.isFile())
3185 QModelIndex index
= m_fileSystemModel
->index(QFileInfo(info
.canonicalPath()).absoluteFilePath());
3189 ui
->outputFolderView
->setCurrentIndex(index
);
3190 outputFolderViewClicked(index
);
3195 text
= text
.left(text
.length() - 1).trimmed();
3198 ui
->outputFolderEdit
->setVisible(false);
3199 ui
->outputFolderLabel
->setVisible(true);
3200 ui
->outputFolderView
->setEnabled(true);
3202 if(!ok
) MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
);
3203 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
3207 * Initialize file system model
3209 void MainWindow::initOutputFolderModel(void)
3211 if(m_outputFolderNoteBox
->isHidden())
3213 m_outputFolderNoteBox
->show();
3214 m_outputFolderNoteBox
->repaint();
3215 m_outputFolderViewInitCounter
= 4;
3217 if(m_fileSystemModel
)
3219 SET_MODEL(ui
->outputFolderView
, NULL
);
3220 MUTILS_DELETE(m_fileSystemModel
);
3221 ui
->outputFolderView
->repaint();
3224 if(m_fileSystemModel
= new QFileSystemModelEx())
3226 m_fileSystemModel
->installEventFilter(this);
3227 connect(m_fileSystemModel
, SIGNAL(directoryLoaded(QString
)), this, SLOT(outputFolderDirectoryLoaded(QString
)));
3228 connect(m_fileSystemModel
, SIGNAL(rowsInserted(QModelIndex
,int,int)), this, SLOT(outputFolderRowsInserted(QModelIndex
,int,int)));
3230 SET_MODEL(ui
->outputFolderView
, m_fileSystemModel
);
3231 ui
->outputFolderView
->header()->setStretchLastSection(true);
3232 ui
->outputFolderView
->header()->hideSection(1);
3233 ui
->outputFolderView
->header()->hideSection(2);
3234 ui
->outputFolderView
->header()->hideSection(3);
3236 m_fileSystemModel
->setRootPath("");
3237 QModelIndex index
= m_fileSystemModel
->index(m_settings
->outputDir());
3238 if(index
.isValid()) ui
->outputFolderView
->setCurrentIndex(index
);
3239 outputFolderViewClicked(ui
->outputFolderView
->currentIndex());
3242 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
3243 QTimer::singleShot(125, this, SLOT(initOutputFolderModel_doAsync()));
3248 * Initialize file system model (do NOT call this one directly!)
3250 void MainWindow::initOutputFolderModel_doAsync(void)
3252 if(m_outputFolderViewInitCounter
> 0)
3254 m_outputFolderViewInitCounter
--;
3255 QTimer::singleShot(125, this, SLOT(initOutputFolderModel_doAsync()));
3259 QTimer::singleShot(125, m_outputFolderNoteBox
, SLOT(hide()));
3260 ui
->outputFolderView
->setFocus();
3265 * Center current folder in view
3267 void MainWindow::centerOutputFolderModel(void)
3269 if(ui
->outputFolderView
->isVisible())
3271 centerOutputFolderModel_doAsync();
3272 QTimer::singleShot(125, this, SLOT(centerOutputFolderModel_doAsync()));
3277 * Center current folder in view (do NOT call this one directly!)
3279 void MainWindow::centerOutputFolderModel_doAsync(void)
3281 if(ui
->outputFolderView
->isVisible())
3283 m_outputFolderViewCentering
= true;
3284 const QModelIndex index
= ui
->outputFolderView
->currentIndex();
3285 ui
->outputFolderView
->scrollTo(index
, QAbstractItemView::PositionAtCenter
);
3286 ui
->outputFolderView
->setFocus();
3291 * File system model asynchronously loaded a dir
3293 void MainWindow::outputFolderDirectoryLoaded(const QString
&path
)
3295 if(m_outputFolderViewCentering
)
3297 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
3302 * File system model inserted new items
3304 void MainWindow::outputFolderRowsInserted(const QModelIndex
&parent
, int start
, int end
)
3306 if(m_outputFolderViewCentering
)
3308 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
3313 * Directory view item was expanded by user
3315 void MainWindow::outputFolderItemExpanded(const QModelIndex
&item
)
3317 //We need to stop centering as soon as the user has expanded an item manually!
3318 m_outputFolderViewCentering
= false;
3322 * View event for output folder control occurred
3324 void MainWindow::outputFolderViewEventOccurred(QWidget
*sender
, QEvent
*event
)
3326 switch(event
->type())
3330 case QEvent::KeyPress
:
3331 case QEvent::KeyRelease
:
3332 case QEvent::FocusIn
:
3333 case QEvent::FocusOut
:
3334 case QEvent::TouchEnd
:
3335 outputFolderViewClicked(ui
->outputFolderView
->currentIndex());
3341 * Mouse event for output folder control occurred
3343 void MainWindow::outputFolderMouseEventOccurred(QWidget
*sender
, QEvent
*event
)
3345 QMouseEvent
*mouseEvent
= dynamic_cast<QMouseEvent
*>(event
);
3346 QPoint pos
= (mouseEvent
) ? mouseEvent
->pos() : QPoint();
3348 if(sender
== ui
->outputFolderLabel
)
3350 switch(event
->type())
3352 case QEvent::MouseButtonPress
:
3353 if(mouseEvent
&& (mouseEvent
->button() == Qt::LeftButton
))
3355 QString path
= ui
->outputFolderLabel
->text();
3356 if(!path
.endsWith(QDir::separator())) path
.append(QDir::separator());
3357 MUtils::OS::shell_open(this, path
, true);
3361 ui
->outputFolderLabel
->setForegroundRole(QPalette::Link
);
3364 ui
->outputFolderLabel
->setForegroundRole(QPalette::WindowText
);
3369 if((sender
== ui
->outputFoldersFovoritesLabel
) || (sender
== ui
->outputFoldersEditorLabel
) || (sender
== ui
->outputFoldersGoUpLabel
))
3371 const type_info
&styleType
= typeid(*qApp
->style());
3372 if((typeid(QPlastiqueStyle
) == styleType
) || (typeid(QWindowsStyle
) == styleType
))
3374 switch(event
->type())
3377 dynamic_cast<QLabel
*>(sender
)->setFrameShadow(ui
->outputFolderView
->isEnabled() ? QFrame::Raised
: QFrame::Plain
);
3379 case QEvent::MouseButtonPress
:
3380 dynamic_cast<QLabel
*>(sender
)->setFrameShadow(ui
->outputFolderView
->isEnabled() ? QFrame::Sunken
: QFrame::Plain
);
3382 case QEvent::MouseButtonRelease
:
3383 dynamic_cast<QLabel
*>(sender
)->setFrameShadow(ui
->outputFolderView
->isEnabled() ? QFrame::Raised
: QFrame::Plain
);
3386 dynamic_cast<QLabel
*>(sender
)->setFrameShadow(ui
->outputFolderView
->isEnabled() ? QFrame::Plain
: QFrame::Plain
);
3392 dynamic_cast<QLabel
*>(sender
)->setFrameShadow(QFrame::Plain
);
3395 if((event
->type() == QEvent::MouseButtonRelease
) && ui
->outputFolderView
->isEnabled() && (mouseEvent
))
3397 if(pos
.x() <= sender
->width() && pos
.y() <= sender
->height() && pos
.x() >= 0 && pos
.y() >= 0 && mouseEvent
->button() != Qt::MidButton
)
3399 if(sender
== ui
->outputFoldersFovoritesLabel
)
3401 m_outputFolderFavoritesMenu
->popup(sender
->mapToGlobal(pos
));
3403 else if(sender
== ui
->outputFoldersEditorLabel
)
3405 ui
->outputFolderView
->setEnabled(false);
3406 ui
->outputFolderLabel
->setVisible(false);
3407 ui
->outputFolderEdit
->setVisible(true);
3408 ui
->outputFolderEdit
->setText(ui
->outputFolderLabel
->text());
3409 ui
->outputFolderEdit
->selectAll();
3410 ui
->outputFolderEdit
->setFocus();
3412 else if(sender
== ui
->outputFoldersGoUpLabel
)
3414 QTimer::singleShot(0, this, SLOT(goUpFolderContextActionTriggered()));
3418 MUTILS_THROW("Oups, this is not supposed to happen!");
3425 // =========================================================
3426 // Metadata tab slots
3427 // =========================================================
3430 * Edit meta button clicked
3432 void MainWindow::editMetaButtonClicked(void)
3436 const QModelIndex index
= ui
->metaDataView
->currentIndex();
3440 m_metaInfoModel
->editItem(index
, this);
3442 if(index
.row() == 4)
3444 m_settings
->metaInfoPosition(m_metaData
->position());
3450 * Reset meta button clicked
3452 void MainWindow::clearMetaButtonClicked(void)
3455 m_metaInfoModel
->clearData();
3459 * Meta tags enabled changed
3461 void MainWindow::metaTagsEnabledChanged(void)
3463 m_settings
->writeMetaTags(ui
->writeMetaDataCheckBox
->isChecked());
3467 * Playlist enabled changed
3469 void MainWindow::playlistEnabledChanged(void)
3471 m_settings
->createPlaylist(ui
->generatePlaylistCheckBox
->isChecked());
3474 // =========================================================
3475 // Compression tab slots
3476 // =========================================================
3481 void MainWindow::updateEncoder(int id
)
3483 /*qWarning("\nupdateEncoder(%d)", id);*/
3485 m_settings
->compressionEncoder(id
);
3486 const AbstractEncoderInfo
*info
= EncoderRegistry::getEncoderInfo(id
);
3488 //Update UI controls
3489 ui
->radioButtonModeQuality
->setEnabled(info
->isModeSupported(SettingsModel::VBRMode
));
3490 ui
->radioButtonModeAverageBitrate
->setEnabled(info
->isModeSupported(SettingsModel::ABRMode
));
3491 ui
->radioButtonConstBitrate
->setEnabled(info
->isModeSupported(SettingsModel::CBRMode
));
3493 //Initialize checkbox state
3494 if(ui
->radioButtonModeQuality
->isEnabled()) ui
->radioButtonModeQuality
->setChecked(true);
3495 else if(ui
->radioButtonModeAverageBitrate
->isEnabled()) ui
->radioButtonModeAverageBitrate
->setChecked(true);
3496 else if(ui
->radioButtonConstBitrate
->isEnabled()) ui
->radioButtonConstBitrate
->setChecked(true);
3497 else MUTILS_THROW("It appears that the encoder does not support *any* RC mode!");
3499 //Apply current RC mode
3500 const int currentRCMode
= EncoderRegistry::loadEncoderMode(m_settings
, id
);
3501 switch(currentRCMode
)
3503 case SettingsModel::VBRMode
: if(ui
->radioButtonModeQuality
->isEnabled()) ui
->radioButtonModeQuality
->setChecked(true); break;
3504 case SettingsModel::ABRMode
: if(ui
->radioButtonModeAverageBitrate
->isEnabled()) ui
->radioButtonModeAverageBitrate
->setChecked(true); break;
3505 case SettingsModel::CBRMode
: if(ui
->radioButtonConstBitrate
->isEnabled()) ui
->radioButtonConstBitrate
->setChecked(true); break;
3506 default: MUTILS_THROW("updateEncoder(): Unknown rc-mode encountered!");
3509 //Display encoder description
3510 if(const char* description
= info
->description())
3512 ui
->labelEncoderInfo
->setVisible(true);
3513 ui
->labelEncoderInfo
->setText(tr("Current Encoder: %1").arg(QString::fromUtf8(description
)));
3517 ui
->labelEncoderInfo
->setVisible(false);
3521 updateRCMode(m_modeButtonGroup
->checkedId());
3525 * Update rate-control mode
3527 void MainWindow::updateRCMode(int id
)
3529 /*qWarning("updateRCMode(%d)", id);*/
3532 const int currentEncoder
= m_encoderButtonGroup
->checkedId();
3533 EncoderRegistry::saveEncoderMode(m_settings
, currentEncoder
, id
);
3535 //Fetch encoder info
3536 const AbstractEncoderInfo
*info
= EncoderRegistry::getEncoderInfo(currentEncoder
);
3537 const int valueCount
= info
->valueCount(id
);
3540 if(!info
->isModeSupported(id
))
3542 qWarning("Attempting to use an unsupported RC mode (%d) with current encoder (%d)!", id
, currentEncoder
);
3543 ui
->labelBitrate
->setText("(ERROR)");
3547 //Update slider min/max values
3550 WITH_BLOCKED_SIGNALS(ui
->sliderBitrate
, setEnabled
, true);
3551 WITH_BLOCKED_SIGNALS(ui
->sliderBitrate
, setMinimum
, 0);
3552 WITH_BLOCKED_SIGNALS(ui
->sliderBitrate
, setMaximum
, valueCount
-1);
3556 WITH_BLOCKED_SIGNALS(ui
->sliderBitrate
, setEnabled
, false);
3557 WITH_BLOCKED_SIGNALS(ui
->sliderBitrate
, setMinimum
, 0);
3558 WITH_BLOCKED_SIGNALS(ui
->sliderBitrate
, setMaximum
, 2);
3561 //Now update bitrate/quality value!
3564 const int currentValue
= EncoderRegistry::loadEncoderValue(m_settings
, currentEncoder
, id
);
3565 ui
->sliderBitrate
->setValue(qBound(0, currentValue
, valueCount
-1));
3566 updateBitrate(qBound(0, currentValue
, valueCount
-1));
3570 ui
->sliderBitrate
->setValue(1);
3578 void MainWindow::updateBitrate(int value
)
3580 /*qWarning("updateBitrate(%d)", value);*/
3582 //Load current encoder and RC mode
3583 const int currentEncoder
= m_encoderButtonGroup
->checkedId();
3584 const int currentRCMode
= m_modeButtonGroup
->checkedId();
3586 //Fetch encoder info
3587 const AbstractEncoderInfo
*info
= EncoderRegistry::getEncoderInfo(currentEncoder
);
3588 const int valueCount
= info
->valueCount(currentRCMode
);
3591 if(!info
->isModeSupported(currentRCMode
))
3593 qWarning("Attempting to use an unsupported RC mode (%d) with current encoder (%d)!", currentRCMode
, currentEncoder
);
3594 ui
->labelBitrate
->setText("(ERROR)");
3598 //Store new bitrate value
3601 EncoderRegistry::saveEncoderValue(m_settings
, currentEncoder
, currentRCMode
, qBound(0, value
, valueCount
-1));
3604 //Update bitrate value
3605 const int displayValue
= (valueCount
> 0) ? info
->valueAt(currentRCMode
, qBound(0, value
, valueCount
-1)) : INT_MAX
;
3606 switch(info
->valueType(currentRCMode
))
3608 case AbstractEncoderInfo::TYPE_BITRATE
:
3609 ui
->labelBitrate
->setText(QString("%1 kbps").arg(QString::number(displayValue
)));
3611 case AbstractEncoderInfo::TYPE_APPROX_BITRATE
:
3612 ui
->labelBitrate
->setText(QString("≈ %1 kbps").arg(QString::number(displayValue
)));
3614 case AbstractEncoderInfo::TYPE_QUALITY_LEVEL_INT
:
3615 ui
->labelBitrate
->setText(tr("Quality Level %1").arg(QString::number(displayValue
)));
3617 case AbstractEncoderInfo::TYPE_QUALITY_LEVEL_FLT
:
3618 ui
->labelBitrate
->setText(tr("Quality Level %1").arg(QString().sprintf("%.2f", double(displayValue
)/100.0)));
3620 case AbstractEncoderInfo::TYPE_COMPRESSION_LEVEL
:
3621 ui
->labelBitrate
->setText(tr("Compression %1").arg(QString::number(displayValue
)));
3623 case AbstractEncoderInfo::TYPE_UNCOMPRESSED
:
3624 ui
->labelBitrate
->setText(tr("Uncompressed"));
3627 MUTILS_THROW("Unknown display value type encountered!");
3633 * Event for compression tab occurred
3635 void MainWindow::compressionTabEventOccurred(QWidget
*sender
, QEvent
*event
)
3637 static const QUrl
helpUrl("http://lamexp.sourceforge.net/doc/FAQ.html#054010d9");
3639 if((sender
== ui
->labelCompressionHelp
) && (event
->type() == QEvent::MouseButtonPress
))
3641 QDesktopServices::openUrl(helpUrl
);
3643 else if((sender
== ui
->labelResetEncoders
) && (event
->type() == QEvent::MouseButtonPress
))
3645 PLAY_SOUND_OPTIONAL("blast", true);
3646 EncoderRegistry::resetAllEncoders(m_settings
);
3647 m_settings
->compressionEncoder(SettingsModel::MP3Encoder
);
3648 ui
->radioButtonEncoderMP3
->setChecked(true);
3649 QTimer::singleShot(0, this, SLOT(updateEncoder()));
3653 // =========================================================
3654 // Advanced option slots
3655 // =========================================================
3658 * Lame algorithm quality changed
3660 void MainWindow::updateLameAlgoQuality(int value
)
3667 text
= tr("Best Quality (Slow)");
3670 text
= tr("High Quality (Recommended)");
3673 text
= tr("Acceptable Quality (Fast)");
3676 text
= tr("Poor Quality (Very Fast)");
3682 m_settings
->lameAlgoQuality(value
);
3683 ui
->labelLameAlgoQuality
->setText(text
);
3686 bool warning
= (value
== 0), notice
= (value
== 3);
3687 ui
->labelLameAlgoQualityWarning
->setVisible(warning
);
3688 ui
->labelLameAlgoQualityWarningIcon
->setVisible(warning
);
3689 ui
->labelLameAlgoQualityNotice
->setVisible(notice
);
3690 ui
->labelLameAlgoQualityNoticeIcon
->setVisible(notice
);
3691 ui
->labelLameAlgoQualitySpacer
->setVisible(warning
|| notice
);
3695 * Bitrate management endabled/disabled
3697 void MainWindow::bitrateManagementEnabledChanged(bool checked
)
3699 m_settings
->bitrateManagementEnabled(checked
);
3703 * Minimum bitrate has changed
3705 void MainWindow::bitrateManagementMinChanged(int value
)
3707 if(value
> ui
->spinBoxBitrateManagementMax
->value())
3709 ui
->spinBoxBitrateManagementMin
->setValue(ui
->spinBoxBitrateManagementMax
->value());
3710 m_settings
->bitrateManagementMinRate(ui
->spinBoxBitrateManagementMax
->value());
3714 m_settings
->bitrateManagementMinRate(value
);
3719 * Maximum bitrate has changed
3721 void MainWindow::bitrateManagementMaxChanged(int value
)
3723 if(value
< ui
->spinBoxBitrateManagementMin
->value())
3725 ui
->spinBoxBitrateManagementMax
->setValue(ui
->spinBoxBitrateManagementMin
->value());
3726 m_settings
->bitrateManagementMaxRate(ui
->spinBoxBitrateManagementMin
->value());
3730 m_settings
->bitrateManagementMaxRate(value
);
3735 * Channel mode has changed
3737 void MainWindow::channelModeChanged(int value
)
3739 if(value
>= 0) m_settings
->lameChannelMode(value
);
3743 * Sampling rate has changed
3745 void MainWindow::samplingRateChanged(int value
)
3747 if(value
>= 0) m_settings
->samplingRate(value
);
3751 * Nero AAC 2-Pass mode changed
3753 void MainWindow::neroAAC2PassChanged(bool checked
)
3755 m_settings
->neroAACEnable2Pass(checked
);
3759 * Nero AAC profile mode changed
3761 void MainWindow::neroAACProfileChanged(int value
)
3763 if(value
>= 0) m_settings
->aacEncProfile(value
);
3767 * Aften audio coding mode changed
3769 void MainWindow::aftenCodingModeChanged(int value
)
3771 if(value
>= 0) m_settings
->aftenAudioCodingMode(value
);
3775 * Aften DRC mode changed
3777 void MainWindow::aftenDRCModeChanged(int value
)
3779 if(value
>= 0) m_settings
->aftenDynamicRangeCompression(value
);
3783 * Aften exponent search size changed
3785 void MainWindow::aftenSearchSizeChanged(int value
)
3787 if(value
>= 0) m_settings
->aftenExponentSearchSize(value
);
3791 * Aften fast bit allocation changed
3793 void MainWindow::aftenFastAllocationChanged(bool checked
)
3795 m_settings
->aftenFastBitAllocation(checked
);
3800 * Opus encoder settings changed
3802 void MainWindow::opusSettingsChanged(void)
3804 m_settings
->opusFramesize(ui
->comboBoxOpusFramesize
->currentIndex());
3805 m_settings
->opusComplexity(ui
->spinBoxOpusComplexity
->value());
3806 m_settings
->opusDisableResample(ui
->checkBoxOpusDisableResample
->isChecked());
3810 * Normalization filter enabled changed
3812 void MainWindow::normalizationEnabledChanged(bool checked
)
3814 m_settings
->normalizationFilterEnabled(checked
);
3815 normalizationDynamicChanged(ui
->checkBoxNormalizationFilterDynamic
->isChecked());
3819 * Dynamic normalization enabled changed
3821 void MainWindow::normalizationDynamicChanged(bool checked
)
3823 ui
->spinBoxNormalizationFilterSize
->setEnabled(ui
->checkBoxNormalizationFilterEnabled
->isChecked() && checked
);
3824 m_settings
->normalizationFilterDynamic(checked
);
3828 * Normalization max. volume changed
3830 void MainWindow::normalizationMaxVolumeChanged(double value
)
3832 m_settings
->normalizationFilterMaxVolume(static_cast<int>(value
* 100.0));
3836 * Normalization equalization mode changed
3838 void MainWindow::normalizationCoupledChanged(bool checked
)
3840 m_settings
->normalizationFilterCoupled(checked
);
3844 * Normalization filter size changed
3846 void MainWindow::normalizationFilterSizeChanged(int value
)
3848 m_settings
->normalizationFilterSize(value
);
3852 * Normalization filter size editing finished
3854 void MainWindow::normalizationFilterSizeFinished(void)
3856 const int value
= ui
->spinBoxNormalizationFilterSize
->value();
3857 if((value
% 2) != 1)
3859 bool rnd
= MUtils::parity(MUtils::next_rand32());
3860 ui
->spinBoxNormalizationFilterSize
->setValue(rnd
? value
+1 : value
-1);
3865 * Tone adjustment has changed (Bass)
3867 void MainWindow::toneAdjustBassChanged(double value
)
3869 m_settings
->toneAdjustBass(static_cast<int>(value
* 100.0));
3870 ui
->spinBoxToneAdjustBass
->setPrefix((value
> 0) ? "+" : QString());
3874 * Tone adjustment has changed (Treble)
3876 void MainWindow::toneAdjustTrebleChanged(double value
)
3878 m_settings
->toneAdjustTreble(static_cast<int>(value
* 100.0));
3879 ui
->spinBoxToneAdjustTreble
->setPrefix((value
> 0) ? "+" : QString());
3883 * Tone adjustment has been reset
3885 void MainWindow::toneAdjustTrebleReset(void)
3887 ui
->spinBoxToneAdjustBass
->setValue(m_settings
->toneAdjustBassDefault());
3888 ui
->spinBoxToneAdjustTreble
->setValue(m_settings
->toneAdjustTrebleDefault());
3889 toneAdjustBassChanged(ui
->spinBoxToneAdjustBass
->value());
3890 toneAdjustTrebleChanged(ui
->spinBoxToneAdjustTreble
->value());
3894 * Custom encoder parameters changed
3896 void MainWindow::customParamsChanged(void)
3898 ui
->lineEditCustomParamLAME
->setText(ui
->lineEditCustomParamLAME
->text().simplified());
3899 ui
->lineEditCustomParamOggEnc
->setText(ui
->lineEditCustomParamOggEnc
->text().simplified());
3900 ui
->lineEditCustomParamNeroAAC
->setText(ui
->lineEditCustomParamNeroAAC
->text().simplified());
3901 ui
->lineEditCustomParamFLAC
->setText(ui
->lineEditCustomParamFLAC
->text().simplified());
3902 ui
->lineEditCustomParamAften
->setText(ui
->lineEditCustomParamAften
->text().simplified());
3903 ui
->lineEditCustomParamOpus
->setText(ui
->lineEditCustomParamOpus
->text().simplified());
3905 bool customParamsUsed
= false;
3906 if(!ui
->lineEditCustomParamLAME
->text().isEmpty()) customParamsUsed
= true;
3907 if(!ui
->lineEditCustomParamOggEnc
->text().isEmpty()) customParamsUsed
= true;
3908 if(!ui
->lineEditCustomParamNeroAAC
->text().isEmpty()) customParamsUsed
= true;
3909 if(!ui
->lineEditCustomParamFLAC
->text().isEmpty()) customParamsUsed
= true;
3910 if(!ui
->lineEditCustomParamAften
->text().isEmpty()) customParamsUsed
= true;
3911 if(!ui
->lineEditCustomParamOpus
->text().isEmpty()) customParamsUsed
= true;
3913 ui
->labelCustomParamsIcon
->setVisible(customParamsUsed
);
3914 ui
->labelCustomParamsText
->setVisible(customParamsUsed
);
3915 ui
->labelCustomParamsSpacer
->setVisible(customParamsUsed
);
3917 EncoderRegistry::saveEncoderCustomParams(m_settings
, SettingsModel::MP3Encoder
, ui
->lineEditCustomParamLAME
->text());
3918 EncoderRegistry::saveEncoderCustomParams(m_settings
, SettingsModel::VorbisEncoder
, ui
->lineEditCustomParamOggEnc
->text());
3919 EncoderRegistry::saveEncoderCustomParams(m_settings
, SettingsModel::AACEncoder
, ui
->lineEditCustomParamNeroAAC
->text());
3920 EncoderRegistry::saveEncoderCustomParams(m_settings
, SettingsModel::FLACEncoder
, ui
->lineEditCustomParamFLAC
->text());
3921 EncoderRegistry::saveEncoderCustomParams(m_settings
, SettingsModel::AC3Encoder
, ui
->lineEditCustomParamAften
->text());
3922 EncoderRegistry::saveEncoderCustomParams(m_settings
, SettingsModel::OpusEncoder
, ui
->lineEditCustomParamOpus
->text());
3926 * One of the rename buttons has been clicked
3928 void MainWindow::renameButtonClicked(bool checked
)
3930 if(QPushButton
*const button
= dynamic_cast<QPushButton
*>(QObject::sender()))
3932 QWidget
*pages
[] = { ui
->pageRename_Rename
, ui
->pageRename_RegExp
, ui
->pageRename_FileEx
};
3933 QPushButton
*buttons
[] = { ui
->buttonRename_Rename
, ui
->buttonRename_RegExp
, ui
->buttonRename_FileEx
};
3934 for(int i
= 0; i
< 3; i
++)
3936 const bool match
= (button
== buttons
[i
]);
3937 buttons
[i
]->setChecked(match
);
3938 if(match
&& checked
) ui
->stackedWidget
->setCurrentWidget(pages
[i
]);
3944 * Rename output files enabled changed
3946 void MainWindow::renameOutputEnabledChanged(const bool &checked
)
3948 m_settings
->renameFiles_renameEnabled(checked
);
3952 * Rename output files patterm changed
3954 void MainWindow::renameOutputPatternChanged(void)
3956 QString temp
= ui
->lineEditRenamePattern
->text().simplified();
3957 ui
->lineEditRenamePattern
->setText(temp
.isEmpty() ? m_settings
->renameFiles_renamePatternDefault() : temp
);
3958 m_settings
->renameFiles_renamePattern(ui
->lineEditRenamePattern
->text());
3962 * Rename output files patterm changed
3964 void MainWindow::renameOutputPatternChanged(const QString
&text
, const bool &silent
)
3966 QString
pattern(text
.simplified());
3968 pattern
.replace("<BaseName>", "The_White_Stripes_-_Fell_In_Love_With_A_Girl", Qt::CaseInsensitive
);
3969 pattern
.replace("<TrackNo>", "04", Qt::CaseInsensitive
);
3970 pattern
.replace("<Title>", "Fell In Love With A Girl", Qt::CaseInsensitive
);
3971 pattern
.replace("<Artist>", "The White Stripes", Qt::CaseInsensitive
);
3972 pattern
.replace("<Album>", "White Blood Cells", Qt::CaseInsensitive
);
3973 pattern
.replace("<Year>", "2001", Qt::CaseInsensitive
);
3974 pattern
.replace("<Comment>", "Encoded by LameXP", Qt::CaseInsensitive
);
3976 const QString patternClean
= MUtils::clean_file_name(pattern
);
3978 if(pattern
.compare(patternClean
))
3980 if(ui
->lineEditRenamePattern
->palette().color(QPalette::Text
) != Qt::red
)
3982 if(!silent
) MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
);
3983 SET_TEXT_COLOR(ui
->lineEditRenamePattern
, Qt::red
);
3988 if(ui
->lineEditRenamePattern
->palette() != QPalette())
3990 if(!silent
) MUtils::Sound::beep(MUtils::Sound::BEEP_NFO
);
3991 ui
->lineEditRenamePattern
->setPalette(QPalette());
3995 ui
->labelRanameExample
->setText(patternClean
);
3999 * Regular expression enabled changed
4001 void MainWindow::renameRegExpEnabledChanged(const bool &checked
)
4003 m_settings
->renameFiles_regExpEnabled(checked
);
4007 * Regular expression value has changed
4009 void MainWindow::renameRegExpValueChanged(void)
4011 const QString search
= ui
->lineEditRenameRegExp_Search
->text() .trimmed();
4012 const QString replace
= ui
->lineEditRenameRegExp_Replace
->text().simplified();
4013 ui
->lineEditRenameRegExp_Search
->setText(search
.isEmpty() ? m_settings
->renameFiles_regExpSearchDefault() : search
);
4014 ui
->lineEditRenameRegExp_Replace
->setText(replace
.isEmpty() ? m_settings
->renameFiles_regExpReplaceDefault() : replace
);
4015 m_settings
->renameFiles_regExpSearch (ui
->lineEditRenameRegExp_Search
->text());
4016 m_settings
->renameFiles_regExpReplace(ui
->lineEditRenameRegExp_Replace
->text());
4020 * Regular expression search pattern has changed
4022 void MainWindow::renameRegExpSearchChanged(const QString
&text
, const bool &silent
)
4024 const QString
pattern(text
.trimmed());
4026 if((!pattern
.isEmpty()) && (!QRegExp(pattern
.trimmed()).isValid()))
4028 if(ui
->lineEditRenameRegExp_Search
->palette().color(QPalette::Text
) != Qt::red
)
4030 if(!silent
) MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
);
4031 SET_TEXT_COLOR(ui
->lineEditRenameRegExp_Search
, Qt::red
);
4036 if(ui
->lineEditRenameRegExp_Search
->palette() != QPalette())
4038 if(!silent
) MUtils::Sound::beep(MUtils::Sound::BEEP_NFO
);
4039 ui
->lineEditRenameRegExp_Search
->setPalette(QPalette());
4043 renameRegExpReplaceChanged(ui
->lineEditRenameRegExp_Replace
->text(), silent
);
4047 * Regular expression replacement string changed
4049 void MainWindow::renameRegExpReplaceChanged(const QString
&text
, const bool &silent
)
4051 QString
replacement(text
.simplified());
4052 const QString
search(ui
->lineEditRenameRegExp_Search
->text().trimmed());
4054 if(!search
.isEmpty())
4056 const QRegExp
regexp(search
);
4057 if(regexp
.isValid())
4059 const int count
= regexp
.captureCount();
4060 const QString blank
;
4061 for(int i
= 0; i
< count
; i
++)
4063 replacement
.replace(QString("\\%0").arg(QString::number(i
+1)), blank
);
4068 if(replacement
.compare(MUtils::clean_file_name(replacement
)))
4070 if(ui
->lineEditRenameRegExp_Replace
->palette().color(QPalette::Text
) != Qt::red
)
4072 if(!silent
) MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
);
4073 SET_TEXT_COLOR(ui
->lineEditRenameRegExp_Replace
, Qt::red
);
4078 if(ui
->lineEditRenameRegExp_Replace
->palette() != QPalette())
4080 if(!silent
) MUtils::Sound::beep(MUtils::Sound::BEEP_NFO
);
4081 ui
->lineEditRenameRegExp_Replace
->setPalette(QPalette());
4087 * Show list of rename macros
4089 void MainWindow::showRenameMacros(const QString
&text
)
4091 if(text
.compare("reset", Qt::CaseInsensitive
) == 0)
4093 ui
->lineEditRenamePattern
->setText(m_settings
->renameFiles_renamePatternDefault());
4097 if(text
.compare("regexp", Qt::CaseInsensitive
) == 0)
4099 MUtils::OS::shell_open(this, "http://www.regular-expressions.info/quickstart.html");
4103 const QString format
= QString("<tr><td><tt><%1></tt></td><td> </td><td>%2</td></tr>");
4105 QString message
= QString("<table>");
4106 message
+= QString(format
).arg("BaseName", tr("File name without extension"));
4107 message
+= QString(format
).arg("TrackNo", tr("Track number with leading zero"));
4108 message
+= QString(format
).arg("Title", tr("Track title"));
4109 message
+= QString(format
).arg("Artist", tr("Artist name"));
4110 message
+= QString(format
).arg("Album", tr("Album name"));
4111 message
+= QString(format
).arg("Year", tr("Year with (at least) four digits"));
4112 message
+= QString(format
).arg("Comment", tr("Comment"));
4113 message
+= "</table><br><br>";
4114 message
+= QString("%1<br>").arg(tr("Characters forbidden in file names:"));
4115 message
+= "<b><tt>\\ / : * ? < > |<br>";
4117 QMessageBox::information(this, tr("Rename Macros"), message
, tr("Discard"));
4120 void MainWindow::fileExtAddButtonClicked(void)
4122 if(FileExtsModel
*const model
= dynamic_cast<FileExtsModel
*>(ui
->tableViewFileExts
->model()))
4124 model
->addOverwrite(this);
4128 void MainWindow::fileExtRemoveButtonClicked(void)
4130 if(FileExtsModel
*const model
= dynamic_cast<FileExtsModel
*>(ui
->tableViewFileExts
->model()))
4132 const QModelIndex selected
= ui
->tableViewFileExts
->currentIndex();
4133 if(selected
.isValid())
4135 model
->removeOverwrite(selected
);
4139 MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
);
4144 void MainWindow::fileExtModelChanged(void)
4146 if(FileExtsModel
*const model
= dynamic_cast<FileExtsModel
*>(ui
->tableViewFileExts
->model()))
4148 m_settings
->renameFiles_fileExtension(model
->exportItems());
4152 void MainWindow::forceStereoDownmixEnabledChanged(bool checked
)
4154 m_settings
->forceStereoDownmix(checked
);
4158 * Maximum number of instances changed
4160 void MainWindow::updateMaximumInstances(int value
)
4162 ui
->labelMaxInstances
->setText(tr("%n Instance(s)", "", value
));
4163 m_settings
->maximumInstances(ui
->checkBoxAutoDetectInstances
->isChecked() ? NULL
: value
);
4167 * Auto-detect number of instances
4169 void MainWindow::autoDetectInstancesChanged(bool checked
)
4171 m_settings
->maximumInstances(checked
? NULL
: ui
->sliderMaxInstances
->value());
4175 * Browse for custom TEMP folder button clicked
4177 void MainWindow::browseCustomTempFolderButtonClicked(void)
4179 QString newTempFolder
;
4181 if(MUtils::GUI::themes_enabled())
4183 newTempFolder
= QFileDialog::getExistingDirectory(this, QString(), m_settings
->customTempPath());
4187 QFileDialog
dialog(this);
4188 dialog
.setFileMode(QFileDialog::DirectoryOnly
);
4189 dialog
.setDirectory(m_settings
->customTempPath());
4192 newTempFolder
= dialog
.selectedFiles().first();
4196 if(!newTempFolder
.isEmpty())
4198 QFile
writeTest(QString("%1/~%2.tmp").arg(newTempFolder
, MUtils::rand_str()));
4199 if(writeTest
.open(QIODevice::ReadWrite
))
4202 ui
->lineEditCustomTempFolder
->setText(QDir::toNativeSeparators(newTempFolder
));
4206 QMessageBox::warning(this, tr("Access Denied"), tr("Cannot write to the selected directory. Please choose another directory!"));
4212 * Custom TEMP folder changed
4214 void MainWindow::customTempFolderChanged(const QString
&text
)
4216 m_settings
->customTempPath(QDir::fromNativeSeparators(text
));
4220 * Use custom TEMP folder option changed
4222 void MainWindow::useCustomTempFolderChanged(bool checked
)
4224 m_settings
->customTempPathEnabled(!checked
);
4228 * Help for custom parameters was requested
4230 void MainWindow::customParamsHelpRequested(QWidget
*obj
, QEvent
*event
)
4232 if(event
->type() != QEvent::MouseButtonRelease
)
4237 if(QMouseEvent
*mouseEvent
= dynamic_cast<QMouseEvent
*>(event
))
4239 QPoint pos
= mouseEvent
->pos();
4240 if(!(pos
.x() <= obj
->width() && pos
.y() <= obj
->height() && pos
.x() >= 0 && pos
.y() >= 0 && mouseEvent
->button() != Qt::MidButton
))
4246 if(obj
== ui
->helpCustomParamLAME
) showCustomParamsHelpScreen("lame.exe", "--longhelp");
4247 else if(obj
== ui
->helpCustomParamOggEnc
) showCustomParamsHelpScreen("oggenc2.exe", "--help");
4248 else if(obj
== ui
->helpCustomParamNeroAAC
)
4250 switch(EncoderRegistry::getAacEncoder())
4252 case SettingsModel::AAC_ENCODER_QAAC
: showCustomParamsHelpScreen("qaac64.exe|qaac.exe", "--help"); break;
4253 case SettingsModel::AAC_ENCODER_FHG
: showCustomParamsHelpScreen("fhgaacenc.exe", "" ); break;
4254 case SettingsModel::AAC_ENCODER_FDK
: showCustomParamsHelpScreen("fdkaac.exe", "--help"); break;
4255 case SettingsModel::AAC_ENCODER_NERO
: showCustomParamsHelpScreen("neroAacEnc.exe", "-help" ); break;
4256 default: MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
); break;
4259 else if(obj
== ui
->helpCustomParamFLAC
) showCustomParamsHelpScreen("flac.exe", "--help");
4260 else if(obj
== ui
->helpCustomParamAften
) showCustomParamsHelpScreen("aften.exe", "-h" );
4261 else if(obj
== ui
->helpCustomParamOpus
) showCustomParamsHelpScreen("opusenc.exe", "--help");
4262 else MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
);
4266 * Show help for custom parameters
4268 void MainWindow::showCustomParamsHelpScreen(const QString
&toolName
, const QString
&command
)
4270 const QStringList toolNames
= toolName
.split('|', QString::SkipEmptyParts
);
4272 for(QStringList::ConstIterator iter
= toolNames
.constBegin(); iter
!= toolNames
.constEnd(); iter
++)
4274 if(lamexp_tools_check(*iter
))
4276 binary
= lamexp_tools_lookup(*iter
);
4281 if(binary
.isEmpty())
4283 MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
);
4284 qWarning("customParamsHelpRequested: Binary could not be found!");
4289 MUtils::init_process(process
, QFileInfo(binary
).absolutePath());
4291 process
.start(binary
, command
.isEmpty() ? QStringList() : QStringList() << command
);
4293 qApp
->setOverrideCursor(QCursor(Qt::WaitCursor
));
4295 if(process
.waitForStarted(15000))
4297 qApp
->processEvents();
4298 process
.waitForFinished(15000);
4301 if(process
.state() != QProcess::NotRunning
)
4304 process
.waitForFinished(-1);
4307 qApp
->restoreOverrideCursor();
4308 QStringList output
; bool spaceFlag
= true;
4310 while(process
.canReadLine())
4312 QString temp
= QString::fromUtf8(process
.readLine());
4313 TRIM_STRING_RIGHT(temp
);
4316 if(!spaceFlag
) { output
<< temp
; spaceFlag
= true; }
4320 output
<< temp
; spaceFlag
= false;
4324 if(output
.count() < 1)
4326 qWarning("Empty output, cannot show help screen!");
4327 MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
);
4330 LogViewDialog
*dialog
= new LogViewDialog(this);
4331 TEMP_HIDE_DROPBOX( dialog
->exec(output
); );
4332 MUTILS_DELETE(dialog
);
4335 void MainWindow::overwriteModeChanged(int id
)
4337 if((id
== SettingsModel::Overwrite_Replaces
) && (m_settings
->overwriteMode() != SettingsModel::Overwrite_Replaces
))
4339 if(QMessageBox::warning(this, tr("Overwrite Mode"), tr("Warning: This mode may overwrite existing files with no way to revert!"), tr("Continue"), tr("Revert"), QString(), 1) != 0)
4341 ui
->radioButtonOverwriteModeKeepBoth
->setChecked(m_settings
->overwriteMode() == SettingsModel::Overwrite_KeepBoth
);
4342 ui
->radioButtonOverwriteModeSkipFile
->setChecked(m_settings
->overwriteMode() == SettingsModel::Overwrite_SkipFile
);
4347 m_settings
->overwriteMode(id
);
4351 * Reset all advanced options to their defaults
4353 void MainWindow::resetAdvancedOptionsButtonClicked(void)
4355 PLAY_SOUND_OPTIONAL("blast", true);
4357 ui
->sliderLameAlgoQuality
->setValue(m_settings
->lameAlgoQualityDefault());
4358 ui
->spinBoxBitrateManagementMin
->setValue(m_settings
->bitrateManagementMinRateDefault());
4359 ui
->spinBoxBitrateManagementMax
->setValue(m_settings
->bitrateManagementMaxRateDefault());
4360 ui
->spinBoxNormalizationFilterPeak
->setValue(static_cast<double>(m_settings
->normalizationFilterMaxVolumeDefault()) / 100.0);
4361 ui
->spinBoxNormalizationFilterSize
->setValue(m_settings
->normalizationFilterSizeDefault());
4362 ui
->spinBoxToneAdjustBass
->setValue(static_cast<double>(m_settings
->toneAdjustBassDefault()) / 100.0);
4363 ui
->spinBoxToneAdjustTreble
->setValue(static_cast<double>(m_settings
->toneAdjustTrebleDefault()) / 100.0);
4364 ui
->spinBoxAftenSearchSize
->setValue(m_settings
->aftenExponentSearchSizeDefault());
4365 ui
->spinBoxOpusComplexity
->setValue(m_settings
->opusComplexityDefault());
4366 ui
->comboBoxMP3ChannelMode
->setCurrentIndex(m_settings
->lameChannelModeDefault());
4367 ui
->comboBoxSamplingRate
->setCurrentIndex(m_settings
->samplingRateDefault());
4368 ui
->comboBoxAACProfile
->setCurrentIndex(m_settings
->aacEncProfileDefault());
4369 ui
->comboBoxAftenCodingMode
->setCurrentIndex(m_settings
->aftenAudioCodingModeDefault());
4370 ui
->comboBoxAftenDRCMode
->setCurrentIndex(m_settings
->aftenDynamicRangeCompressionDefault());
4371 ui
->comboBoxOpusFramesize
->setCurrentIndex(m_settings
->opusFramesizeDefault());
4373 SET_CHECKBOX_STATE(ui
->checkBoxBitrateManagement
, m_settings
->bitrateManagementEnabledDefault());
4374 SET_CHECKBOX_STATE(ui
->checkBoxNeroAAC2PassMode
, m_settings
->neroAACEnable2PassDefault());
4375 SET_CHECKBOX_STATE(ui
->checkBoxNormalizationFilterEnabled
, m_settings
->normalizationFilterEnabledDefault());
4376 SET_CHECKBOX_STATE(ui
->checkBoxNormalizationFilterDynamic
, m_settings
->normalizationFilterDynamicDefault());
4377 SET_CHECKBOX_STATE(ui
->checkBoxNormalizationFilterCoupled
, m_settings
->normalizationFilterCoupledDefault());
4378 SET_CHECKBOX_STATE(ui
->checkBoxAutoDetectInstances
, (m_settings
->maximumInstancesDefault() < 1));
4379 SET_CHECKBOX_STATE(ui
->checkBoxUseSystemTempFolder
, (!m_settings
->customTempPathEnabledDefault()));
4380 SET_CHECKBOX_STATE(ui
->checkBoxAftenFastAllocation
, m_settings
->aftenFastBitAllocationDefault());
4381 SET_CHECKBOX_STATE(ui
->checkBoxRename_Rename
, m_settings
->renameFiles_renameEnabledDefault());
4382 SET_CHECKBOX_STATE(ui
->checkBoxRename_RegExp
, m_settings
->renameFiles_regExpEnabledDefault());
4383 SET_CHECKBOX_STATE(ui
->checkBoxForceStereoDownmix
, m_settings
->forceStereoDownmixDefault());
4384 SET_CHECKBOX_STATE(ui
->checkBoxOpusDisableResample
, m_settings
->opusDisableResampleDefault());
4386 ui
->lineEditCustomParamLAME
->setText(m_settings
->customParametersLAMEDefault());
4387 ui
->lineEditCustomParamOggEnc
->setText(m_settings
->customParametersOggEncDefault());
4388 ui
->lineEditCustomParamNeroAAC
->setText(m_settings
->customParametersAacEncDefault());
4389 ui
->lineEditCustomParamFLAC
->setText(m_settings
->customParametersFLACDefault());
4390 ui
->lineEditCustomParamOpus
->setText(m_settings
->customParametersOpusEncDefault());
4391 ui
->lineEditCustomTempFolder
->setText(QDir::toNativeSeparators(m_settings
->customTempPathDefault()));
4392 ui
->lineEditRenamePattern
->setText(m_settings
->renameFiles_renamePatternDefault());
4393 ui
->lineEditRenameRegExp_Search
->setText(m_settings
->renameFiles_regExpSearchDefault());
4394 ui
->lineEditRenameRegExp_Replace
->setText(m_settings
->renameFiles_regExpReplaceDefault());
4396 if(m_settings
->overwriteModeDefault() == SettingsModel::Overwrite_KeepBoth
) ui
->radioButtonOverwriteModeKeepBoth
->click();
4397 if(m_settings
->overwriteModeDefault() == SettingsModel::Overwrite_SkipFile
) ui
->radioButtonOverwriteModeSkipFile
->click();
4398 if(m_settings
->overwriteModeDefault() == SettingsModel::Overwrite_Replaces
) ui
->radioButtonOverwriteModeReplaces
->click();
4400 if(FileExtsModel
*const model
= dynamic_cast<FileExtsModel
*>(ui
->tableViewFileExts
->model()))
4402 model
->importItems(m_settings
->renameFiles_fileExtensionDefault());
4405 ui
->scrollArea
->verticalScrollBar()->setValue(0);
4406 ui
->buttonRename_Rename
->click();
4407 customParamsChanged();
4408 renameOutputPatternChanged();
4409 renameRegExpValueChanged();
4412 // =========================================================
4413 // Multi-instance handling slots
4414 // =========================================================
4417 * Other instance detected
4419 void MainWindow::notifyOtherInstance(void)
4421 if(!(BANNER_VISIBLE
))
4423 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
);
4429 * Add file from another instance
4431 void MainWindow::addFileDelayed(const QString
&filePath
, bool tryASAP
)
4433 if(tryASAP
&& !m_delayedFileTimer
->isActive())
4435 qDebug("Received file: %s", MUTILS_UTF8(filePath
));
4436 m_delayedFileList
->append(filePath
);
4437 QTimer::singleShot(0, this, SLOT(handleDelayedFiles()));
4440 m_delayedFileTimer
->stop();
4441 qDebug("Received file: %s", MUTILS_UTF8(filePath
));
4442 m_delayedFileList
->append(filePath
);
4443 m_delayedFileTimer
->start(5000);
4447 * Add files from another instance
4449 void MainWindow::addFilesDelayed(const QStringList
&filePaths
, bool tryASAP
)
4451 if(tryASAP
&& (!m_delayedFileTimer
->isActive()))
4453 qDebug("Received %d file(s).", filePaths
.count());
4454 m_delayedFileList
->append(filePaths
);
4455 QTimer::singleShot(0, this, SLOT(handleDelayedFiles()));
4459 m_delayedFileTimer
->stop();
4460 qDebug("Received %d file(s).", filePaths
.count());
4461 m_delayedFileList
->append(filePaths
);
4462 m_delayedFileTimer
->start(5000);
4467 * Add folder from another instance
4469 void MainWindow::addFolderDelayed(const QString
&folderPath
, bool recursive
)
4471 if(!(BANNER_VISIBLE
))
4473 addFolder(folderPath
, recursive
, true);
4477 // =========================================================
4479 // =========================================================
4482 * Restore the override cursor
4484 void MainWindow::restoreCursor(void)
4486 QApplication::restoreOverrideCursor();