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.isNull()) \
94 m_banner.reset(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 class FileListBlocker
231 FileListBlocker(FileListModel
*const fileList
) : m_fileList(fileList
) { m_fileList
->setBlockUpdates(true); }
232 ~FileListBlocker(void) { m_fileList
->setBlockUpdates(false); }
234 FileListModel
*const m_fileList
;
237 #define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(QString(URL).replace("-", "−"))
238 #define FSLINK(PATH) QString("<a href=\"file:///%1\">%2</a>").arg(PATH).arg(QString(PATH).replace("-", "−"))
239 #define CENTER_CURRENT_OUTPUT_FOLDER_DELAYED QTimer::singleShot(125, this, SLOT(centerOutputFolderModel()))
241 static const unsigned int IDM_ABOUTBOX
= 0xEFF0;
242 static const char *g_hydrogen_audio_url
= "http://wiki.hydrogenaud.io/index.php?title=Main_Page";
243 static const char *g_documents_base_url
= "http://lamexp.sourceforge.net/doc";
245 ////////////////////////////////////////////////////////////
247 ////////////////////////////////////////////////////////////
249 MainWindow::MainWindow(MUtils::IPCChannel
*const ipcChannel
, FileListModel
*const fileListModel
, AudioFileModel_MetaInfo
*const metaInfo
, SettingsModel
*const settingsModel
, QWidget
*const parent
)
252 ui(new Ui::MainWindow
),
253 m_fileListModel(fileListModel
),
254 m_metaData(metaInfo
),
255 m_settings(settingsModel
),
257 m_firstTimeShown(true),
258 m_outputFolderViewCentering(false),
259 m_outputFolderViewInitCounter(0)
261 //Init the dialog, from the .ui file
263 setWindowFlags(windowFlags() ^ Qt::WindowMaximizeButtonHint
);
266 MUtils::GUI::set_window_icon(this, lamexp_app_icon(), true);
268 //Register meta types
269 qRegisterMetaType
<AudioFileModel
>("AudioFileModel");
271 //Enabled main buttons
272 connect(ui
->buttonAbout
, SIGNAL(clicked()), this, SLOT(aboutButtonClicked()));
273 connect(ui
->buttonStart
, SIGNAL(clicked()), this, SLOT(encodeButtonClicked()));
274 connect(ui
->buttonQuit
, SIGNAL(clicked()), this, SLOT(closeButtonClicked()));
277 ui
->tabWidget
->setCurrentIndex(0);
278 connect(ui
->tabWidget
, SIGNAL(currentChanged(int)), this, SLOT(tabPageChanged(int)));
281 MUtils::GUI::sysmenu_append(this, IDM_ABOUTBOX
, "About...");
283 //Setup corner widget
284 QLabel
*cornerWidget
= new QLabel(ui
->menubar
);
285 m_evenFilterCornerWidget
.reset(new CustomEventFilter
);
286 cornerWidget
->setText("N/A");
287 cornerWidget
->setFixedHeight(ui
->menubar
->height());
288 cornerWidget
->setCursor(QCursor(Qt::PointingHandCursor
));
289 cornerWidget
->hide();
290 cornerWidget
->installEventFilter(m_evenFilterCornerWidget
.data());
291 connect(m_evenFilterCornerWidget
.data(), SIGNAL(eventOccurred(QWidget
*, QEvent
*)), this, SLOT(cornerWidgetEventOccurred(QWidget
*, QEvent
*)));
292 ui
->menubar
->setCornerWidget(cornerWidget
);
294 //--------------------------------
295 // Setup "Source" tab
296 //--------------------------------
298 ui
->sourceFileView
->setModel(m_fileListModel
);
299 ui
->sourceFileView
->verticalHeader() ->setResizeMode(QHeaderView::ResizeToContents
);
300 ui
->sourceFileView
->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents
);
301 ui
->sourceFileView
->setContextMenuPolicy(Qt::CustomContextMenu
);
302 ui
->sourceFileView
->viewport()->installEventFilter(this);
303 m_dropNoteLabel
= new QLabel(ui
->sourceFileView
);
304 m_dropNoteLabel
->setAlignment(Qt::AlignHCenter
| Qt::AlignVCenter
);
305 SET_FONT_BOLD(m_dropNoteLabel
, true);
306 SET_TEXT_COLOR(m_dropNoteLabel
, Qt::darkGray
);
307 m_sourceFilesContextMenu
= new QMenu();
308 m_showDetailsContextAction
= m_sourceFilesContextMenu
->addAction(QIcon(":/icons/zoom.png"), "N/A");
309 m_previewContextAction
= m_sourceFilesContextMenu
->addAction(QIcon(":/icons/sound.png"), "N/A");
310 m_findFileContextAction
= m_sourceFilesContextMenu
->addAction(QIcon(":/icons/folder_go.png"), "N/A");
311 m_sourceFilesContextMenu
->addSeparator();
312 m_exportCsvContextAction
= m_sourceFilesContextMenu
->addAction(QIcon(":/icons/table_save.png"), "N/A");
313 m_importCsvContextAction
= m_sourceFilesContextMenu
->addAction(QIcon(":/icons/folder_table.png"), "N/A");
314 SET_FONT_BOLD(m_showDetailsContextAction
, true);
316 connect(ui
->buttonAddFiles
, SIGNAL(clicked()), this, SLOT(addFilesButtonClicked()));
317 connect(ui
->buttonRemoveFile
, SIGNAL(clicked()), this, SLOT(removeFileButtonClicked()));
318 connect(ui
->buttonClearFiles
, SIGNAL(clicked()), this, SLOT(clearFilesButtonClicked()));
319 connect(ui
->buttonFileUp
, SIGNAL(clicked()), this, SLOT(fileUpButtonClicked()));
320 connect(ui
->buttonFileDown
, SIGNAL(clicked()), this, SLOT(fileDownButtonClicked()));
321 connect(ui
->buttonShowDetails
, SIGNAL(clicked()), this, SLOT(showDetailsButtonClicked()));
322 connect(m_fileListModel
, SIGNAL(rowsInserted(QModelIndex
,int,int)), this, SLOT(sourceModelChanged()));
323 connect(m_fileListModel
, SIGNAL(rowsRemoved(QModelIndex
,int,int)), this, SLOT(sourceModelChanged()));
324 connect(m_fileListModel
, SIGNAL(modelReset()), this, SLOT(sourceModelChanged()));
325 connect(ui
->sourceFileView
, SIGNAL(customContextMenuRequested(QPoint
)), this, SLOT(sourceFilesContextMenu(QPoint
)));
326 connect(ui
->sourceFileView
->verticalScrollBar(), SIGNAL(sliderMoved(int)), this, SLOT(sourceFilesScrollbarMoved(int)));
327 connect(ui
->sourceFileView
->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(sourceFilesScrollbarMoved(int)));
328 connect(m_showDetailsContextAction
, SIGNAL(triggered(bool)), this, SLOT(showDetailsButtonClicked()));
329 connect(m_previewContextAction
, SIGNAL(triggered(bool)), this, SLOT(previewContextActionTriggered()));
330 connect(m_findFileContextAction
, SIGNAL(triggered(bool)), this, SLOT(findFileContextActionTriggered()));
331 connect(m_exportCsvContextAction
, SIGNAL(triggered(bool)), this, SLOT(exportCsvContextActionTriggered()));
332 connect(m_importCsvContextAction
, SIGNAL(triggered(bool)), this, SLOT(importCsvContextActionTriggered()));
334 //--------------------------------
335 // Setup "Output" tab
336 //--------------------------------
338 ui
->outputFolderView
->setHeaderHidden(true);
339 ui
->outputFolderView
->setAnimated(false);
340 ui
->outputFolderView
->setMouseTracking(false);
341 ui
->outputFolderView
->setContextMenuPolicy(Qt::CustomContextMenu
);
342 ui
->outputFolderView
->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn
);
344 m_evenFilterOutputFolderMouse
.reset(new CustomEventFilter
);
345 ui
->outputFoldersGoUpLabel
->installEventFilter(m_evenFilterOutputFolderMouse
.data());
346 ui
->outputFoldersEditorLabel
->installEventFilter(m_evenFilterOutputFolderMouse
.data());
347 ui
->outputFoldersFovoritesLabel
->installEventFilter(m_evenFilterOutputFolderMouse
.data());
348 ui
->outputFolderLabel
->installEventFilter(m_evenFilterOutputFolderMouse
.data());
350 m_evenFilterOutputFolderView
.reset(new CustomEventFilter
);
351 ui
->outputFolderView
->installEventFilter(m_evenFilterOutputFolderView
.data());
353 SET_CHECKBOX_STATE(ui
->saveToSourceFolderCheckBox
, m_settings
->outputToSourceDir());
354 ui
->prependRelativePathCheckBox
->setChecked(m_settings
->prependRelativeSourcePath());
356 connect(ui
->outputFolderView
, SIGNAL(clicked(QModelIndex
)), this, SLOT(outputFolderViewClicked(QModelIndex
)));
357 connect(ui
->outputFolderView
, SIGNAL(activated(QModelIndex
)), this, SLOT(outputFolderViewClicked(QModelIndex
)));
358 connect(ui
->outputFolderView
, SIGNAL(pressed(QModelIndex
)), this, SLOT(outputFolderViewClicked(QModelIndex
)));
359 connect(ui
->outputFolderView
, SIGNAL(entered(QModelIndex
)), this, SLOT(outputFolderViewMoved(QModelIndex
)));
360 connect(ui
->outputFolderView
, SIGNAL(expanded(QModelIndex
)), this, SLOT(outputFolderItemExpanded(QModelIndex
)));
361 connect(ui
->buttonMakeFolder
, SIGNAL(clicked()), this, SLOT(makeFolderButtonClicked()));
362 connect(ui
->buttonGotoHome
, SIGNAL(clicked()), this, SLOT(gotoHomeFolderButtonClicked()));
363 connect(ui
->buttonGotoDesktop
, SIGNAL(clicked()), this, SLOT(gotoDesktopButtonClicked()));
364 connect(ui
->buttonGotoMusic
, SIGNAL(clicked()), this, SLOT(gotoMusicFolderButtonClicked()));
365 connect(ui
->saveToSourceFolderCheckBox
, SIGNAL(clicked()), this, SLOT(saveToSourceFolderChanged()));
366 connect(ui
->prependRelativePathCheckBox
, SIGNAL(clicked()), this, SLOT(prependRelativePathChanged()));
367 connect(ui
->outputFolderEdit
, SIGNAL(editingFinished()), this, SLOT(outputFolderEditFinished()));
368 connect(m_evenFilterOutputFolderMouse
.data(), SIGNAL(eventOccurred(QWidget
*, QEvent
*)), this, SLOT(outputFolderMouseEventOccurred(QWidget
*, QEvent
*)));
369 connect(m_evenFilterOutputFolderView
.data(), SIGNAL(eventOccurred(QWidget
*, QEvent
*)), this, SLOT(outputFolderViewEventOccurred(QWidget
*, QEvent
*)));
371 if(m_outputFolderContextMenu
= new QMenu())
373 m_showFolderContextAction
= m_outputFolderContextMenu
->addAction(QIcon(":/icons/zoom.png"), "N/A");
374 m_goUpFolderContextAction
= m_outputFolderContextMenu
->addAction(QIcon(":/icons/folder_up.png"), "N/A");
375 m_outputFolderContextMenu
->addSeparator();
376 m_refreshFolderContextAction
= m_outputFolderContextMenu
->addAction(QIcon(":/icons/arrow_refresh.png"), "N/A");
377 m_outputFolderContextMenu
->setDefaultAction(m_showFolderContextAction
);
378 connect(ui
->outputFolderView
, SIGNAL(customContextMenuRequested(QPoint
)), this, SLOT(outputFolderContextMenu(QPoint
)));
379 connect(m_showFolderContextAction
, SIGNAL(triggered(bool)), this, SLOT(showFolderContextActionTriggered()));
380 connect(m_refreshFolderContextAction
, SIGNAL(triggered(bool)), this, SLOT(refreshFolderContextActionTriggered()));
381 connect(m_goUpFolderContextAction
, SIGNAL(triggered(bool)), this, SLOT(goUpFolderContextActionTriggered()));
384 if(m_outputFolderFavoritesMenu
= new QMenu())
386 m_addFavoriteFolderAction
= m_outputFolderFavoritesMenu
->addAction(QIcon(":/icons/add.png"), "N/A");
387 m_outputFolderFavoritesMenu
->insertSeparator(m_addFavoriteFolderAction
);
388 connect(m_addFavoriteFolderAction
, SIGNAL(triggered(bool)), this, SLOT(addFavoriteFolderActionTriggered()));
391 ui
->outputFolderEdit
->setVisible(false);
392 if(m_outputFolderNoteBox
= new QLabel(ui
->outputFolderView
))
394 m_outputFolderNoteBox
->setAutoFillBackground(true);
395 m_outputFolderNoteBox
->setAlignment(Qt::AlignHCenter
| Qt::AlignVCenter
);
396 m_outputFolderNoteBox
->setFrameShape(QFrame::StyledPanel
);
397 SET_FONT_BOLD(m_outputFolderNoteBox
, true);
398 m_outputFolderNoteBox
->hide();
401 outputFolderViewClicked(QModelIndex());
404 //--------------------------------
405 // Setup "Meta Data" tab
406 //--------------------------------
408 m_metaInfoModel
.reset(new MetaInfoModel(m_metaData
));
409 m_metaInfoModel
->clearData();
410 m_metaInfoModel
->setData(m_metaInfoModel
->index(4, 1), m_settings
->metaInfoPosition());
411 ui
->metaDataView
->setModel(m_metaInfoModel
.data());
412 ui
->metaDataView
->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents
);
413 ui
->metaDataView
->verticalHeader()->hide();
414 ui
->metaDataView
->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents
);
415 SET_CHECKBOX_STATE(ui
->writeMetaDataCheckBox
, m_settings
->writeMetaTags());
416 ui
->generatePlaylistCheckBox
->setChecked(m_settings
->createPlaylist());
417 connect(ui
->buttonEditMeta
, SIGNAL(clicked()), this, SLOT(editMetaButtonClicked()));
418 connect(ui
->buttonClearMeta
, SIGNAL(clicked()), this, SLOT(clearMetaButtonClicked()));
419 connect(ui
->writeMetaDataCheckBox
, SIGNAL(clicked()), this, SLOT(metaTagsEnabledChanged()));
420 connect(ui
->generatePlaylistCheckBox
, SIGNAL(clicked()), this, SLOT(playlistEnabledChanged()));
422 //--------------------------------
423 //Setup "Compression" tab
424 //--------------------------------
426 m_encoderButtonGroup
.reset(new QButtonGroup(this));
427 m_encoderButtonGroup
->addButton(ui
->radioButtonEncoderMP3
, SettingsModel::MP3Encoder
);
428 m_encoderButtonGroup
->addButton(ui
->radioButtonEncoderVorbis
, SettingsModel::VorbisEncoder
);
429 m_encoderButtonGroup
->addButton(ui
->radioButtonEncoderAAC
, SettingsModel::AACEncoder
);
430 m_encoderButtonGroup
->addButton(ui
->radioButtonEncoderAC3
, SettingsModel::AC3Encoder
);
431 m_encoderButtonGroup
->addButton(ui
->radioButtonEncoderFLAC
, SettingsModel::FLACEncoder
);
432 m_encoderButtonGroup
->addButton(ui
->radioButtonEncoderAPE
, SettingsModel::MACEncoder
);
433 m_encoderButtonGroup
->addButton(ui
->radioButtonEncoderOpus
, SettingsModel::OpusEncoder
);
434 m_encoderButtonGroup
->addButton(ui
->radioButtonEncoderDCA
, SettingsModel::DCAEncoder
);
435 m_encoderButtonGroup
->addButton(ui
->radioButtonEncoderPCM
, SettingsModel::PCMEncoder
);
437 const int aacEncoder
= EncoderRegistry::getAacEncoder();
438 ui
->radioButtonEncoderAAC
->setEnabled(aacEncoder
> SettingsModel::AAC_ENCODER_NONE
);
440 m_modeButtonGroup
.reset(new QButtonGroup(this));
441 m_modeButtonGroup
->addButton(ui
->radioButtonModeQuality
, SettingsModel::VBRMode
);
442 m_modeButtonGroup
->addButton(ui
->radioButtonModeAverageBitrate
, SettingsModel::ABRMode
);
443 m_modeButtonGroup
->addButton(ui
->radioButtonConstBitrate
, SettingsModel::CBRMode
);
445 ui
->radioButtonEncoderMP3
->setChecked(true);
446 foreach(QAbstractButton
*currentButton
, m_encoderButtonGroup
->buttons())
448 if(currentButton
->isEnabled() && (m_encoderButtonGroup
->id(currentButton
) == m_settings
->compressionEncoder()))
450 currentButton
->setChecked(true);
455 m_evenFilterCompressionTab
.reset(new CustomEventFilter());
456 ui
->labelCompressionHelp
->installEventFilter(m_evenFilterCompressionTab
.data());
457 ui
->labelResetEncoders
->installEventFilter(m_evenFilterCompressionTab
.data());
459 connect(m_encoderButtonGroup
.data(), SIGNAL(buttonClicked(int)), this, SLOT(updateEncoder(int)));
460 connect(m_modeButtonGroup
.data(), SIGNAL(buttonClicked(int)), this, SLOT(updateRCMode(int)));
461 connect(m_evenFilterCompressionTab
.data(), SIGNAL(eventOccurred(QWidget
*, QEvent
*)), this, SLOT(compressionTabEventOccurred(QWidget
*, QEvent
*)));
462 connect(ui
->sliderBitrate
, SIGNAL(valueChanged(int)), this, SLOT(updateBitrate(int)));
464 updateEncoder(m_encoderButtonGroup
->checkedId());
466 //--------------------------------
467 //Setup "Advanced Options" tab
468 //--------------------------------
470 ui
->sliderLameAlgoQuality
->setValue(m_settings
->lameAlgoQuality());
471 if(m_settings
->maximumInstances() > 0) ui
->sliderMaxInstances
->setValue(m_settings
->maximumInstances());
473 ui
->spinBoxBitrateManagementMin
->setValue(m_settings
->bitrateManagementMinRate());
474 ui
->spinBoxBitrateManagementMax
->setValue(m_settings
->bitrateManagementMaxRate());
475 ui
->spinBoxNormalizationFilterPeak
->setValue(static_cast<double>(m_settings
->normalizationFilterMaxVolume()) / 100.0);
476 ui
->spinBoxNormalizationFilterSize
->setValue(m_settings
->normalizationFilterSize());
477 ui
->spinBoxToneAdjustBass
->setValue(static_cast<double>(m_settings
->toneAdjustBass()) / 100.0);
478 ui
->spinBoxToneAdjustTreble
->setValue(static_cast<double>(m_settings
->toneAdjustTreble()) / 100.0);
479 ui
->spinBoxAftenSearchSize
->setValue(m_settings
->aftenExponentSearchSize());
480 ui
->spinBoxOpusComplexity
->setValue(m_settings
->opusComplexity());
482 ui
->comboBoxMP3ChannelMode
->setCurrentIndex(m_settings
->lameChannelMode());
483 ui
->comboBoxSamplingRate
->setCurrentIndex(m_settings
->samplingRate());
484 ui
->comboBoxAACProfile
->setCurrentIndex(m_settings
->aacEncProfile());
485 ui
->comboBoxAftenCodingMode
->setCurrentIndex(m_settings
->aftenAudioCodingMode());
486 ui
->comboBoxAftenDRCMode
->setCurrentIndex(m_settings
->aftenDynamicRangeCompression());
487 ui
->comboBoxOpusFramesize
->setCurrentIndex(m_settings
->opusFramesize());
489 SET_CHECKBOX_STATE(ui
->checkBoxBitrateManagement
, m_settings
->bitrateManagementEnabled());
490 SET_CHECKBOX_STATE(ui
->checkBoxNeroAAC2PassMode
, m_settings
->neroAACEnable2Pass());
491 SET_CHECKBOX_STATE(ui
->checkBoxAftenFastAllocation
, m_settings
->aftenFastBitAllocation());
492 SET_CHECKBOX_STATE(ui
->checkBoxNormalizationFilterEnabled
, m_settings
->normalizationFilterEnabled());
493 SET_CHECKBOX_STATE(ui
->checkBoxNormalizationFilterDynamic
, m_settings
->normalizationFilterDynamic());
494 SET_CHECKBOX_STATE(ui
->checkBoxNormalizationFilterCoupled
, m_settings
->normalizationFilterCoupled());
495 SET_CHECKBOX_STATE(ui
->checkBoxAutoDetectInstances
, (m_settings
->maximumInstances() < 1));
496 SET_CHECKBOX_STATE(ui
->checkBoxUseSystemTempFolder
, (!m_settings
->customTempPathEnabled()));
497 SET_CHECKBOX_STATE(ui
->checkBoxRename_Rename
, m_settings
->renameFiles_renameEnabled());
498 SET_CHECKBOX_STATE(ui
->checkBoxRename_RegExp
, m_settings
->renameFiles_regExpEnabled());
499 SET_CHECKBOX_STATE(ui
->checkBoxForceStereoDownmix
, m_settings
->forceStereoDownmix());
500 SET_CHECKBOX_STATE(ui
->checkBoxOpusDisableResample
, m_settings
->opusDisableResample());
502 ui
->checkBoxNeroAAC2PassMode
->setEnabled(aacEncoder
== SettingsModel::AAC_ENCODER_NERO
);
504 ui
->lineEditCustomParamLAME
->setText(EncoderRegistry::loadEncoderCustomParams(m_settings
, SettingsModel::MP3Encoder
));
505 ui
->lineEditCustomParamOggEnc
->setText(EncoderRegistry::loadEncoderCustomParams(m_settings
, SettingsModel::VorbisEncoder
));
506 ui
->lineEditCustomParamNeroAAC
->setText(EncoderRegistry::loadEncoderCustomParams(m_settings
, SettingsModel::AACEncoder
));
507 ui
->lineEditCustomParamFLAC
->setText(EncoderRegistry::loadEncoderCustomParams(m_settings
, SettingsModel::FLACEncoder
));
508 ui
->lineEditCustomParamAften
->setText(EncoderRegistry::loadEncoderCustomParams(m_settings
, SettingsModel::AC3Encoder
));
509 ui
->lineEditCustomParamOpus
->setText(EncoderRegistry::loadEncoderCustomParams(m_settings
, SettingsModel::OpusEncoder
));
510 ui
->lineEditCustomTempFolder
->setText(QDir::toNativeSeparators(m_settings
->customTempPath()));
511 ui
->lineEditRenamePattern
->setText(m_settings
->renameFiles_renamePattern());
512 ui
->lineEditRenameRegExp_Search
->setText(m_settings
->renameFiles_regExpSearch ());
513 ui
->lineEditRenameRegExp_Replace
->setText(m_settings
->renameFiles_regExpReplace());
515 m_evenFilterCustumParamsHelp
.reset(new CustomEventFilter());
516 ui
->helpCustomParamLAME
->installEventFilter(m_evenFilterCustumParamsHelp
.data());
517 ui
->helpCustomParamOggEnc
->installEventFilter(m_evenFilterCustumParamsHelp
.data());
518 ui
->helpCustomParamNeroAAC
->installEventFilter(m_evenFilterCustumParamsHelp
.data());
519 ui
->helpCustomParamFLAC
->installEventFilter(m_evenFilterCustumParamsHelp
.data());
520 ui
->helpCustomParamAften
->installEventFilter(m_evenFilterCustumParamsHelp
.data());
521 ui
->helpCustomParamOpus
->installEventFilter(m_evenFilterCustumParamsHelp
.data());
523 m_overwriteButtonGroup
.reset(new QButtonGroup(this));
524 m_overwriteButtonGroup
->addButton(ui
->radioButtonOverwriteModeKeepBoth
, SettingsModel::Overwrite_KeepBoth
);
525 m_overwriteButtonGroup
->addButton(ui
->radioButtonOverwriteModeSkipFile
, SettingsModel::Overwrite_SkipFile
);
526 m_overwriteButtonGroup
->addButton(ui
->radioButtonOverwriteModeReplaces
, SettingsModel::Overwrite_Replaces
);
528 ui
->radioButtonOverwriteModeKeepBoth
->setChecked(m_settings
->overwriteMode() == SettingsModel::Overwrite_KeepBoth
);
529 ui
->radioButtonOverwriteModeSkipFile
->setChecked(m_settings
->overwriteMode() == SettingsModel::Overwrite_SkipFile
);
530 ui
->radioButtonOverwriteModeReplaces
->setChecked(m_settings
->overwriteMode() == SettingsModel::Overwrite_Replaces
);
532 FileExtsModel
*fileExtModel
= new FileExtsModel(this);
533 fileExtModel
->importItems(m_settings
->renameFiles_fileExtension());
534 ui
->tableViewFileExts
->setModel(fileExtModel
);
535 ui
->tableViewFileExts
->verticalHeader() ->setResizeMode(QHeaderView::ResizeToContents
);
536 ui
->tableViewFileExts
->horizontalHeader()->setResizeMode(QHeaderView::Stretch
);
538 connect(ui
->sliderLameAlgoQuality
, SIGNAL(valueChanged(int)), this, SLOT(updateLameAlgoQuality(int)));
539 connect(ui
->checkBoxBitrateManagement
, SIGNAL(clicked(bool)), this, SLOT(bitrateManagementEnabledChanged(bool)));
540 connect(ui
->spinBoxBitrateManagementMin
, SIGNAL(valueChanged(int)), this, SLOT(bitrateManagementMinChanged(int)));
541 connect(ui
->spinBoxBitrateManagementMax
, SIGNAL(valueChanged(int)), this, SLOT(bitrateManagementMaxChanged(int)));
542 connect(ui
->comboBoxMP3ChannelMode
, SIGNAL(currentIndexChanged(int)), this, SLOT(channelModeChanged(int)));
543 connect(ui
->comboBoxSamplingRate
, SIGNAL(currentIndexChanged(int)), this, SLOT(samplingRateChanged(int)));
544 connect(ui
->checkBoxNeroAAC2PassMode
, SIGNAL(clicked(bool)), this, SLOT(neroAAC2PassChanged(bool)));
545 connect(ui
->comboBoxAACProfile
, SIGNAL(currentIndexChanged(int)), this, SLOT(neroAACProfileChanged(int)));
546 connect(ui
->checkBoxNormalizationFilterEnabled
, SIGNAL(clicked(bool)), this, SLOT(normalizationEnabledChanged(bool)));
547 connect(ui
->checkBoxNormalizationFilterDynamic
, SIGNAL(clicked(bool)), this, SLOT(normalizationDynamicChanged(bool)));
548 connect(ui
->checkBoxNormalizationFilterCoupled
, SIGNAL(clicked(bool)), this, SLOT(normalizationCoupledChanged(bool)));
549 connect(ui
->comboBoxAftenCodingMode
, SIGNAL(currentIndexChanged(int)), this, SLOT(aftenCodingModeChanged(int)));
550 connect(ui
->comboBoxAftenDRCMode
, SIGNAL(currentIndexChanged(int)), this, SLOT(aftenDRCModeChanged(int)));
551 connect(ui
->spinBoxAftenSearchSize
, SIGNAL(valueChanged(int)), this, SLOT(aftenSearchSizeChanged(int)));
552 connect(ui
->checkBoxAftenFastAllocation
, SIGNAL(clicked(bool)), this, SLOT(aftenFastAllocationChanged(bool)));
553 connect(ui
->spinBoxNormalizationFilterPeak
, SIGNAL(valueChanged(double)), this, SLOT(normalizationMaxVolumeChanged(double)));
554 connect(ui
->spinBoxNormalizationFilterSize
, SIGNAL(valueChanged(int)), this, SLOT(normalizationFilterSizeChanged(int)));
555 connect(ui
->spinBoxNormalizationFilterSize
, SIGNAL(editingFinished()), this, SLOT(normalizationFilterSizeFinished()));
556 connect(ui
->spinBoxToneAdjustBass
, SIGNAL(valueChanged(double)), this, SLOT(toneAdjustBassChanged(double)));
557 connect(ui
->spinBoxToneAdjustTreble
, SIGNAL(valueChanged(double)), this, SLOT(toneAdjustTrebleChanged(double)));
558 connect(ui
->buttonToneAdjustReset
, SIGNAL(clicked()), this, SLOT(toneAdjustTrebleReset()));
559 connect(ui
->lineEditCustomParamLAME
, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
560 connect(ui
->lineEditCustomParamOggEnc
, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
561 connect(ui
->lineEditCustomParamNeroAAC
, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
562 connect(ui
->lineEditCustomParamFLAC
, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
563 connect(ui
->lineEditCustomParamAften
, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
564 connect(ui
->lineEditCustomParamOpus
, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
565 connect(ui
->sliderMaxInstances
, SIGNAL(valueChanged(int)), this, SLOT(updateMaximumInstances(int)));
566 connect(ui
->checkBoxAutoDetectInstances
, SIGNAL(clicked(bool)), this, SLOT(autoDetectInstancesChanged(bool)));
567 connect(ui
->buttonBrowseCustomTempFolder
, SIGNAL(clicked()), this, SLOT(browseCustomTempFolderButtonClicked()));
568 connect(ui
->lineEditCustomTempFolder
, SIGNAL(textChanged(QString
)), this, SLOT(customTempFolderChanged(QString
)));
569 connect(ui
->checkBoxUseSystemTempFolder
, SIGNAL(clicked(bool)), this, SLOT(useCustomTempFolderChanged(bool)));
570 connect(ui
->buttonResetAdvancedOptions
, SIGNAL(clicked()), this, SLOT(resetAdvancedOptionsButtonClicked()));
571 connect(ui
->checkBoxRename_Rename
, SIGNAL(clicked(bool)), this, SLOT(renameOutputEnabledChanged(bool)));
572 connect(ui
->checkBoxRename_RegExp
, SIGNAL(clicked(bool)), this, SLOT(renameRegExpEnabledChanged(bool)));
573 connect(ui
->lineEditRenamePattern
, SIGNAL(editingFinished()), this, SLOT(renameOutputPatternChanged()));
574 connect(ui
->lineEditRenamePattern
, SIGNAL(textChanged(QString
)), this, SLOT(renameOutputPatternChanged(QString
)));
575 connect(ui
->lineEditRenameRegExp_Search
, SIGNAL(editingFinished()), this, SLOT(renameRegExpValueChanged()));
576 connect(ui
->lineEditRenameRegExp_Search
, SIGNAL(textChanged(QString
)), this, SLOT(renameRegExpSearchChanged(QString
)));
577 connect(ui
->lineEditRenameRegExp_Replace
, SIGNAL(editingFinished()), this, SLOT(renameRegExpValueChanged()));
578 connect(ui
->lineEditRenameRegExp_Replace
, SIGNAL(textChanged(QString
)), this, SLOT(renameRegExpReplaceChanged(QString
)));
579 connect(ui
->labelShowRenameMacros
, SIGNAL(linkActivated(QString
)), this, SLOT(showRenameMacros(QString
)));
580 connect(ui
->labelShowRegExpHelp
, SIGNAL(linkActivated(QString
)), this, SLOT(showRenameMacros(QString
)));
581 connect(ui
->checkBoxForceStereoDownmix
, SIGNAL(clicked(bool)), this, SLOT(forceStereoDownmixEnabledChanged(bool)));
582 connect(ui
->comboBoxOpusFramesize
, SIGNAL(currentIndexChanged(int)), this, SLOT(opusSettingsChanged()));
583 connect(ui
->spinBoxOpusComplexity
, SIGNAL(valueChanged(int)), this, SLOT(opusSettingsChanged()));
584 connect(ui
->checkBoxOpusDisableResample
, SIGNAL(clicked(bool)), this, SLOT(opusSettingsChanged()));
585 connect(ui
->buttonRename_Rename
, SIGNAL(clicked(bool)), this, SLOT(renameButtonClicked(bool)));
586 connect(ui
->buttonRename_RegExp
, SIGNAL(clicked(bool)), this, SLOT(renameButtonClicked(bool)));
587 connect(ui
->buttonRename_FileEx
, SIGNAL(clicked(bool)), this, SLOT(renameButtonClicked(bool)));
588 connect(ui
->buttonFileExts_Add
, SIGNAL(clicked()), this, SLOT(fileExtAddButtonClicked()));
589 connect(ui
->buttonFileExts_Remove
, SIGNAL(clicked()), this, SLOT(fileExtRemoveButtonClicked()));
590 connect(m_overwriteButtonGroup
.data(), SIGNAL(buttonClicked(int)), this, SLOT(overwriteModeChanged(int)));
591 connect(m_evenFilterCustumParamsHelp
.data(), SIGNAL(eventOccurred(QWidget
*, QEvent
*)), this, SLOT(customParamsHelpRequested(QWidget
*, QEvent
*)));
592 connect(fileExtModel
, SIGNAL(modelReset()), this, SLOT(fileExtModelChanged()));
594 //--------------------------------
595 // Force initial GUI update
596 //--------------------------------
598 updateLameAlgoQuality(ui
->sliderLameAlgoQuality
->value());
599 updateMaximumInstances(ui
->sliderMaxInstances
->value());
600 toneAdjustTrebleChanged(ui
->spinBoxToneAdjustTreble
->value());
601 toneAdjustBassChanged(ui
->spinBoxToneAdjustBass
->value());
602 normalizationEnabledChanged(ui
->checkBoxNormalizationFilterEnabled
->isChecked());
603 customParamsChanged();
605 //--------------------------------
606 // Initialize actions
607 //--------------------------------
609 //Activate file menu actions
610 ui
->actionOpenFolder
->setData(QVariant::fromValue
<bool>(false));
611 ui
->actionOpenFolderRecursively
->setData(QVariant::fromValue
<bool>(true));
612 connect(ui
->actionOpenFolder
, SIGNAL(triggered()), this, SLOT(openFolderActionActivated()));
613 connect(ui
->actionOpenFolderRecursively
, SIGNAL(triggered()), this, SLOT(openFolderActionActivated()));
615 //Activate view menu actions
616 m_tabActionGroup
.reset(new QActionGroup(this));
617 m_tabActionGroup
->addAction(ui
->actionSourceFiles
);
618 m_tabActionGroup
->addAction(ui
->actionOutputDirectory
);
619 m_tabActionGroup
->addAction(ui
->actionCompression
);
620 m_tabActionGroup
->addAction(ui
->actionMetaData
);
621 m_tabActionGroup
->addAction(ui
->actionAdvancedOptions
);
622 ui
->actionSourceFiles
->setData(0);
623 ui
->actionOutputDirectory
->setData(1);
624 ui
->actionMetaData
->setData(2);
625 ui
->actionCompression
->setData(3);
626 ui
->actionAdvancedOptions
->setData(4);
627 ui
->actionSourceFiles
->setChecked(true);
628 connect(m_tabActionGroup
.data(), SIGNAL(triggered(QAction
*)), this, SLOT(tabActionActivated(QAction
*)));
630 //Activate style menu actions
631 m_styleActionGroup
.reset(new QActionGroup(this));
632 m_styleActionGroup
->addAction(ui
->actionStylePlastique
);
633 m_styleActionGroup
->addAction(ui
->actionStyleCleanlooks
);
634 m_styleActionGroup
->addAction(ui
->actionStyleWindowsVista
);
635 m_styleActionGroup
->addAction(ui
->actionStyleWindowsXP
);
636 m_styleActionGroup
->addAction(ui
->actionStyleWindowsClassic
);
637 ui
->actionStylePlastique
->setData(0);
638 ui
->actionStyleCleanlooks
->setData(1);
639 ui
->actionStyleWindowsVista
->setData(2);
640 ui
->actionStyleWindowsXP
->setData(3);
641 ui
->actionStyleWindowsClassic
->setData(4);
642 ui
->actionStylePlastique
->setChecked(true);
643 ui
->actionStyleWindowsXP
->setEnabled((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based
) >= QSysInfo::WV_XP
&& MUtils::GUI::themes_enabled());
644 ui
->actionStyleWindowsVista
->setEnabled((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based
) >= QSysInfo::WV_VISTA
&& MUtils::GUI::themes_enabled());
645 connect(m_styleActionGroup
.data(), SIGNAL(triggered(QAction
*)), this, SLOT(styleActionActivated(QAction
*)));
646 styleActionActivated(NULL
);
648 //Populate the language menu
649 m_languageActionGroup
.reset(new QActionGroup(this));
650 QStringList translations
;
651 if(MUtils::Translation::enumerate(translations
) > 0)
653 for(QStringList::ConstIterator iter
= translations
.constBegin(); iter
!= translations
.constEnd(); iter
++)
655 QAction
*currentLanguage
= new QAction(this);
656 currentLanguage
->setData(*iter
);
657 currentLanguage
->setText(MUtils::Translation::get_name(*iter
));
658 currentLanguage
->setIcon(QIcon(QString(":/flags/%1.png").arg(*iter
)));
659 currentLanguage
->setCheckable(true);
660 currentLanguage
->setChecked(false);
661 m_languageActionGroup
->addAction(currentLanguage
);
662 ui
->menuLanguage
->insertAction(ui
->actionLoadTranslationFromFile
, currentLanguage
);
665 ui
->menuLanguage
->insertSeparator(ui
->actionLoadTranslationFromFile
);
666 connect(ui
->actionLoadTranslationFromFile
, SIGNAL(triggered(bool)), this, SLOT(languageFromFileActionActivated(bool)));
667 connect(m_languageActionGroup
.data(), SIGNAL(triggered(QAction
*)), this, SLOT(languageActionActivated(QAction
*)));
668 ui
->actionLoadTranslationFromFile
->setChecked(false);
670 //Activate tools menu actions
671 ui
->actionDisableUpdateReminder
->setChecked(!m_settings
->autoUpdateEnabled());
672 ui
->actionDisableSounds
->setChecked(!m_settings
->soundsEnabled());
673 ui
->actionDisableNeroAacNotifications
->setChecked(!m_settings
->neroAacNotificationsEnabled());
674 ui
->actionDisableSlowStartupNotifications
->setChecked(!m_settings
->antivirNotificationsEnabled());
675 ui
->actionDisableShellIntegration
->setChecked(!m_settings
->shellIntegrationEnabled());
676 ui
->actionDisableShellIntegration
->setDisabled(lamexp_version_portable() && ui
->actionDisableShellIntegration
->isChecked());
677 ui
->actionCheckForBetaUpdates
->setChecked(m_settings
->autoUpdateCheckBeta() || lamexp_version_demo());
678 ui
->actionCheckForBetaUpdates
->setEnabled(!lamexp_version_demo());
679 ui
->actionHibernateComputer
->setChecked(m_settings
->hibernateComputer());
680 ui
->actionHibernateComputer
->setEnabled(MUtils::OS::is_hibernation_supported());
681 connect(ui
->actionDisableUpdateReminder
, SIGNAL(triggered(bool)), this, SLOT(disableUpdateReminderActionTriggered(bool)));
682 connect(ui
->actionDisableSounds
, SIGNAL(triggered(bool)), this, SLOT(disableSoundsActionTriggered(bool)));
683 connect(ui
->actionDisableNeroAacNotifications
, SIGNAL(triggered(bool)), this, SLOT(disableNeroAacNotificationsActionTriggered(bool)));
684 connect(ui
->actionDisableSlowStartupNotifications
, SIGNAL(triggered(bool)), this, SLOT(disableSlowStartupNotificationsActionTriggered(bool)));
685 connect(ui
->actionDisableShellIntegration
, SIGNAL(triggered(bool)), this, SLOT(disableShellIntegrationActionTriggered(bool)));
686 connect(ui
->actionShowDropBoxWidget
, SIGNAL(triggered(bool)), this, SLOT(showDropBoxWidgetActionTriggered(bool)));
687 connect(ui
->actionHibernateComputer
, SIGNAL(triggered(bool)), this, SLOT(hibernateComputerActionTriggered(bool)));
688 connect(ui
->actionCheckForBetaUpdates
, SIGNAL(triggered(bool)), this, SLOT(checkForBetaUpdatesActionTriggered(bool)));
689 connect(ui
->actionImportCueSheet
, SIGNAL(triggered(bool)), this, SLOT(importCueSheetActionTriggered(bool)));
691 //Activate help menu actions
692 ui
->actionVisitHomepage
->setData(QString::fromLatin1(lamexp_website_url()));
693 ui
->actionVisitSupport
->setData(QString::fromLatin1(lamexp_support_url()));
694 ui
->actionVisitMuldersSite
->setData(QString::fromLatin1(lamexp_mulders_url()));
695 ui
->actionVisitTracker
->setData(QString::fromLatin1(lamexp_tracker_url()));
696 ui
->actionVisitHAK
->setData(QString::fromLatin1(g_hydrogen_audio_url
));
697 ui
->actionDocumentManual
->setData(QString("%1/Manual.html") .arg(QApplication::applicationDirPath()));
698 ui
->actionDocumentChangelog
->setData(QString("%1/Changelog.html").arg(QApplication::applicationDirPath()));
699 ui
->actionDocumentTranslate
->setData(QString("%1/Translate.html").arg(QApplication::applicationDirPath()));
700 connect(ui
->actionCheckUpdates
, SIGNAL(triggered()), this, SLOT(checkUpdatesActionActivated()));
701 connect(ui
->actionVisitSupport
, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated()));
702 connect(ui
->actionVisitTracker
, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated()));
703 connect(ui
->actionVisitHomepage
, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated()));
704 connect(ui
->actionVisitMuldersSite
, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated()));
705 connect(ui
->actionVisitHAK
, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated()));
706 connect(ui
->actionDocumentManual
, SIGNAL(triggered()), this, SLOT(documentActionActivated()));
707 connect(ui
->actionDocumentChangelog
, SIGNAL(triggered()), this, SLOT(documentActionActivated()));
708 connect(ui
->actionDocumentTranslate
, SIGNAL(triggered()), this, SLOT(documentActionActivated()));
710 //--------------------------------
711 // Prepare to show window
712 //--------------------------------
714 //Center window in screen
715 QRect desktopRect
= QApplication::desktop()->screenGeometry();
716 QRect thisRect
= this->geometry();
717 move((desktopRect
.width() - thisRect
.width()) / 2, (desktopRect
.height() - thisRect
.height()) / 2);
718 setMinimumSize(thisRect
.width(), thisRect
.height());
720 //Create DropBox widget
721 m_dropBox
= new DropBox(this, m_fileListModel
, m_settings
);
722 connect(m_fileListModel
, SIGNAL(modelReset()), m_dropBox
, SLOT(modelChanged()));
723 connect(m_fileListModel
, SIGNAL(rowsInserted(QModelIndex
,int,int)), m_dropBox
, SLOT(modelChanged()));
724 connect(m_fileListModel
, SIGNAL(rowsRemoved(QModelIndex
,int,int)), m_dropBox
, SLOT(modelChanged()));
725 connect(m_fileListModel
, SIGNAL(rowAppended()), m_dropBox
, SLOT(modelChanged()));
727 //Create message handler thread
728 m_messageHandler
= new MessageHandlerThread(ipcChannel
);
729 connect(m_messageHandler
, SIGNAL(otherInstanceDetected()), this, SLOT(notifyOtherInstance()), Qt::QueuedConnection
);
730 connect(m_messageHandler
, SIGNAL(fileReceived(QString
)), this, SLOT(addFileDelayed(QString
)), Qt::QueuedConnection
);
731 connect(m_messageHandler
, SIGNAL(folderReceived(QString
, bool)), this, SLOT(addFolderDelayed(QString
, bool)), Qt::QueuedConnection
);
732 connect(m_messageHandler
, SIGNAL(killSignalReceived()), this, SLOT(close()), Qt::QueuedConnection
);
733 m_messageHandler
->start();
735 //Init delayed file handling
736 m_delayedFileList
= new QStringList();
737 m_delayedFileTimer
= new QTimer();
738 m_delayedFileTimer
->setSingleShot(true);
739 m_delayedFileTimer
->setInterval(5000);
740 connect(m_delayedFileTimer
, SIGNAL(timeout()), this, SLOT(handleDelayedFiles()));
743 initializeTranslation();
745 //Re-translate (make sure we translate once)
746 QEvent
languageChangeEvent(QEvent::LanguageChange
);
747 changeEvent(&languageChangeEvent
);
750 m_droppedFileList
= new QList
<QUrl
>();
751 this->setAcceptDrops(true);
754 ////////////////////////////////////////////////////////////
756 ////////////////////////////////////////////////////////////
758 MainWindow::~MainWindow(void)
760 //Stop message handler thread
761 if(m_messageHandler
&& m_messageHandler
->isRunning())
763 m_messageHandler
->stop();
764 if(!m_messageHandler
->wait(2500))
766 m_messageHandler
->terminate();
767 m_messageHandler
->wait();
772 SET_MODEL(ui
->sourceFileView
, NULL
);
773 SET_MODEL(ui
->outputFolderView
, NULL
);
774 SET_MODEL(ui
->metaDataView
, NULL
);
777 MUTILS_DELETE(m_messageHandler
);
778 MUTILS_DELETE(m_droppedFileList
);
779 MUTILS_DELETE(m_delayedFileList
);
780 MUTILS_DELETE(m_delayedFileTimer
);
781 MUTILS_DELETE(m_sourceFilesContextMenu
);
782 MUTILS_DELETE(m_outputFolderFavoritesMenu
);
783 MUTILS_DELETE(m_outputFolderContextMenu
);
784 MUTILS_DELETE(m_dropBox
);
786 //Un-initialize the dialog
790 ////////////////////////////////////////////////////////////
792 ////////////////////////////////////////////////////////////
795 * Add file to source list
797 void MainWindow::addFiles(const QStringList
&files
)
804 WITH_BLOCKED_SIGNALS(ui
->tabWidget
, setCurrentIndex
, 0);
805 tabPageChanged(ui
->tabWidget
->currentIndex(), true);
808 QScopedPointer
<FileAnalyzer
> analyzer(new FileAnalyzer(files
));
810 connect(analyzer
.data(), SIGNAL(fileSelected(QString
)), m_banner
.data(), SLOT(setText(QString
)), Qt::QueuedConnection
);
811 connect(analyzer
.data(), SIGNAL(progressValChanged(unsigned int)), m_banner
.data(), SLOT(setProgressVal(unsigned int)), Qt::QueuedConnection
);
812 connect(analyzer
.data(), SIGNAL(progressMaxChanged(unsigned int)), m_banner
.data(), SLOT(setProgressMax(unsigned int)), Qt::QueuedConnection
);
813 connect(analyzer
.data(), SIGNAL(fileAnalyzed(AudioFileModel
)), m_fileListModel
, SLOT(addFile(AudioFileModel
)), Qt::QueuedConnection
);
814 connect(m_banner
.data(), SIGNAL(userAbort()), analyzer
.data(), SLOT(abortProcess()), Qt::DirectConnection
);
816 if(!analyzer
.isNull())
818 FileListBlocker
fileListBlocker(m_fileListModel
);
819 m_banner
->show(tr("Adding file(s), please wait..."), analyzer
.data());
822 qApp
->processEvents(QEventLoop::ExcludeUserInputEvents
);
823 ui
->sourceFileView
->update();
824 qApp
->processEvents(QEventLoop::ExcludeUserInputEvents
);
825 ui
->sourceFileView
->scrollToBottom();
826 qApp
->processEvents(QEventLoop::ExcludeUserInputEvents
);
828 if(analyzer
->filesDenied())
830 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."))));
832 if(analyzer
->filesDummyCDDA())
834 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>"))));
836 if(analyzer
->filesCueSheet())
838 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."))));
840 if(analyzer
->filesRejected())
842 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."))));
849 * Add folder to source list
851 void MainWindow::addFolder(const QString
&path
, bool recursive
, bool delayed
, QString filter
)
853 QFileInfoList folderInfoList
;
854 folderInfoList
<< QFileInfo(path
);
855 QStringList fileList
;
857 SHOW_BANNER(tr("Scanning folder(s) for files, please wait..."));
859 QApplication::processEvents();
860 MUtils::OS::check_key_state_esc();
862 while(!folderInfoList
.isEmpty())
864 if(MUtils::OS::check_key_state_esc())
866 qWarning("Operation cancelled by user!");
867 MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
);
872 QDir
currentDir(folderInfoList
.takeFirst().canonicalFilePath());
873 QFileInfoList fileInfoList
= currentDir
.entryInfoList(QDir::Files
| QDir::NoSymLinks
);
875 for(QFileInfoList::ConstIterator iter
= fileInfoList
.constBegin(); iter
!= fileInfoList
.constEnd(); iter
++)
877 if(filter
.isEmpty() || (iter
->suffix().compare(filter
, Qt::CaseInsensitive
) == 0))
879 fileList
<< iter
->canonicalFilePath();
883 QApplication::processEvents(QEventLoop::ExcludeUserInputEvents
);
887 folderInfoList
.append(currentDir
.entryInfoList(QDir::Dirs
| QDir::NoDotAndDotDot
| QDir::NoSymLinks
));
888 QApplication::processEvents();
893 QApplication::processEvents();
895 if(!fileList
.isEmpty())
899 addFilesDelayed(fileList
);
911 bool MainWindow::checkForUpdates(void)
913 bool bReadyToInstall
= false;
915 UpdateDialog
*updateDialog
= new UpdateDialog(m_settings
, this);
916 updateDialog
->exec();
918 if(updateDialog
->getSuccess())
920 SHOW_CORNER_WIDGET(false);
921 m_settings
->autoUpdateLastCheck(QDate::currentDate().toString(Qt::ISODate
));
922 bReadyToInstall
= updateDialog
->updateReadyToInstall();
925 MUTILS_DELETE(updateDialog
);
926 return bReadyToInstall
;
930 * Refresh list of favorites
932 void MainWindow::refreshFavorites(void)
934 QList
<QAction
*> folderList
= m_outputFolderFavoritesMenu
->actions();
935 QStringList favorites
= m_settings
->favoriteOutputFolders().split("|", QString::SkipEmptyParts
);
936 while(favorites
.count() > 6) favorites
.removeFirst();
938 while(!folderList
.isEmpty())
940 QAction
*currentItem
= folderList
.takeFirst();
941 if(currentItem
->isSeparator()) break;
942 m_outputFolderFavoritesMenu
->removeAction(currentItem
);
943 MUTILS_DELETE(currentItem
);
946 QAction
*lastItem
= m_outputFolderFavoritesMenu
->actions().first();
948 while(!favorites
.isEmpty())
950 QString path
= favorites
.takeLast();
951 if(QDir(path
).exists())
953 QAction
*action
= new QAction(QIcon(":/icons/folder_go.png"), QDir::toNativeSeparators(path
), this);
954 action
->setData(path
);
955 m_outputFolderFavoritesMenu
->insertAction(lastItem
, action
);
956 connect(action
, SIGNAL(triggered(bool)), this, SLOT(gotoFavoriteFolder()));
963 * Initilaize translation
965 void MainWindow::initializeTranslation(void)
967 bool translationLoaded
= false;
969 //Try to load "external" translation file
970 if(!m_settings
->currentLanguageFile().isEmpty())
972 const QString qmFilePath
= QFileInfo(m_settings
->currentLanguageFile()).canonicalFilePath();
973 if((!qmFilePath
.isEmpty()) && QFileInfo(qmFilePath
).exists() && QFileInfo(qmFilePath
).isFile() && (QFileInfo(qmFilePath
).suffix().compare("qm", Qt::CaseInsensitive
) == 0))
975 if(MUtils::Translation::install_translator_from_file(qmFilePath
))
977 QList
<QAction
*> actions
= m_languageActionGroup
->actions();
978 while(!actions
.isEmpty()) actions
.takeFirst()->setChecked(false);
979 ui
->actionLoadTranslationFromFile
->setChecked(true);
980 translationLoaded
= true;
985 //Try to load "built-in" translation file
986 if(!translationLoaded
)
988 QList
<QAction
*> languageActions
= m_languageActionGroup
->actions();
989 while(!languageActions
.isEmpty())
991 QAction
*currentLanguage
= languageActions
.takeFirst();
992 if(currentLanguage
->data().toString().compare(m_settings
->currentLanguage(), Qt::CaseInsensitive
) == 0)
994 currentLanguage
->setChecked(true);
995 languageActionActivated(currentLanguage
);
996 translationLoaded
= true;
1001 //Fallback to default translation
1002 if(!translationLoaded
)
1004 QList
<QAction
*> languageActions
= m_languageActionGroup
->actions();
1005 while(!languageActions
.isEmpty())
1007 QAction
*currentLanguage
= languageActions
.takeFirst();
1008 if(currentLanguage
->data().toString().compare(MUtils::Translation::DEFAULT_LANGID
, Qt::CaseInsensitive
) == 0)
1010 currentLanguage
->setChecked(true);
1011 languageActionActivated(currentLanguage
);
1012 translationLoaded
= true;
1017 //Make sure we loaded some translation
1018 if(!translationLoaded
)
1020 qFatal("Failed to load any translation, this is NOT supposed to happen!");
1025 * Open a document link
1027 void MainWindow::openDocumentLink(QAction
*const action
)
1029 if(!(action
->data().isValid() && (action
->data().type() == QVariant::String
)))
1031 qWarning("Cannot open document for this QAction!");
1035 //Try to open exitsing document file
1036 const QFileInfo
document(action
->data().toString());
1037 if(document
.exists() && document
.isFile() && (document
.size() >= 1024))
1039 QDesktopServices::openUrl(QUrl::fromLocalFile(document
.canonicalFilePath()));
1043 //Document not found -> fallback mode!
1044 qWarning("Document '%s' not found -> redirecting to the website!", MUTILS_UTF8(document
.fileName()));
1045 const QUrl
url(QString("%1/%2").arg(QString::fromLatin1(g_documents_base_url
), document
.fileName()));
1046 QDesktopServices::openUrl(url
);
1049 ////////////////////////////////////////////////////////////
1051 ////////////////////////////////////////////////////////////
1054 * Window is about to be shown
1056 void MainWindow::showEvent(QShowEvent
*event
)
1060 sourceModelChanged();
1062 if(!event
->spontaneous())
1064 WITH_BLOCKED_SIGNALS(ui
->tabWidget
, setCurrentIndex
, 0);
1065 tabPageChanged(ui
->tabWidget
->currentIndex(), true);
1068 if(m_firstTimeShown
)
1070 m_firstTimeShown
= false;
1071 QTimer::singleShot(0, this, SLOT(windowShown()));
1075 if(m_settings
->dropBoxWidgetEnabled())
1077 m_dropBox
->setVisible(true);
1083 * Re-translate the UI
1085 void MainWindow::changeEvent(QEvent
*e
)
1087 QMainWindow::changeEvent(e
);
1088 if(e
->type() != QEvent::LanguageChange
)
1093 int comboBoxIndex
[6];
1095 //Backup combobox indices, as retranslateUi() resets
1096 comboBoxIndex
[0] = ui
->comboBoxMP3ChannelMode
->currentIndex();
1097 comboBoxIndex
[1] = ui
->comboBoxSamplingRate
->currentIndex();
1098 comboBoxIndex
[2] = ui
->comboBoxAACProfile
->currentIndex();
1099 comboBoxIndex
[3] = ui
->comboBoxAftenCodingMode
->currentIndex();
1100 comboBoxIndex
[4] = ui
->comboBoxAftenDRCMode
->currentIndex();
1101 comboBoxIndex
[5] = ui
->comboBoxOpusFramesize
->currentIndex();
1103 //Re-translate from UIC
1104 ui
->retranslateUi(this);
1106 //Restore combobox indices
1107 ui
->comboBoxMP3ChannelMode
->setCurrentIndex(comboBoxIndex
[0]);
1108 ui
->comboBoxSamplingRate
->setCurrentIndex(comboBoxIndex
[1]);
1109 ui
->comboBoxAACProfile
->setCurrentIndex(comboBoxIndex
[2]);
1110 ui
->comboBoxAftenCodingMode
->setCurrentIndex(comboBoxIndex
[3]);
1111 ui
->comboBoxAftenDRCMode
->setCurrentIndex(comboBoxIndex
[4]);
1112 ui
->comboBoxOpusFramesize
->setCurrentIndex(comboBoxIndex
[5]);
1114 //Update the window title
1117 setWindowTitle(QString("%1 [!!! DEBUG BUILD !!!]").arg(windowTitle()));
1119 else if(lamexp_version_demo())
1121 setWindowTitle(QString("%1 [%2]").arg(windowTitle(), tr("DEMO VERSION")));
1124 //Manually re-translate widgets that UIC doesn't handle
1125 m_outputFolderNoteBox
->setText(tr("Initializing directory outline, please be patient..."));
1126 m_dropNoteLabel
->setText(QString("<br><img src=\":/images/DropZone.png\"><br><br>%1").arg(tr("You can drop in audio files here!")));
1127 if(QLabel
*cornerWidget
= dynamic_cast<QLabel
*>(ui
->menubar
->cornerWidget()))
1129 cornerWidget
->setText(QString("<nobr><img src=\":/icons/exclamation_small.png\"> <b style=\"color:darkred\">%1</b> </nobr>").arg(tr("Check for Updates")));
1131 m_showDetailsContextAction
->setText(tr("Show Details"));
1132 m_previewContextAction
->setText(tr("Open File in External Application"));
1133 m_findFileContextAction
->setText(tr("Browse File Location"));
1134 m_showFolderContextAction
->setText(tr("Browse Selected Folder"));
1135 m_refreshFolderContextAction
->setText(tr("Refresh Directory Outline"));
1136 m_goUpFolderContextAction
->setText(tr("Go To Parent Directory"));
1137 m_addFavoriteFolderAction
->setText(tr("Bookmark Current Output Folder"));
1138 m_exportCsvContextAction
->setText(tr("Export Meta Tags to CSV File"));
1139 m_importCsvContextAction
->setText(tr("Import Meta Tags from CSV File"));
1142 m_metaInfoModel
->clearData();
1143 m_metaInfoModel
->setData(m_metaInfoModel
->index(4, 1), m_settings
->metaInfoPosition());
1144 updateEncoder(m_settings
->compressionEncoder());
1145 updateLameAlgoQuality(ui
->sliderLameAlgoQuality
->value());
1146 updateMaximumInstances(ui
->sliderMaxInstances
->value());
1147 renameOutputPatternChanged(ui
->lineEditRenamePattern
->text(), true);
1148 renameRegExpSearchChanged (ui
->lineEditRenameRegExp_Search
->text(), true);
1149 renameRegExpReplaceChanged(ui
->lineEditRenameRegExp_Replace
->text(), true);
1151 //Re-install shell integration
1152 if(m_settings
->shellIntegrationEnabled())
1154 ShellIntegration::install();
1157 //Translate system menu
1158 MUtils::GUI::sysmenu_update(this, IDM_ABOUTBOX
, ui
->buttonAbout
->text());
1160 //Force resize event
1161 QApplication::postEvent(this, new QResizeEvent(this->size(), QSize()));
1162 for(QObjectList::ConstIterator iter
= this->children().constBegin(); iter
!= this->children().constEnd(); iter
++)
1164 if(QWidget
*child
= dynamic_cast<QWidget
*>(*iter
))
1166 QApplication::postEvent(child
, new QResizeEvent(child
->size(), QSize()));
1170 //Force tabe page change
1171 tabPageChanged(ui
->tabWidget
->currentIndex(), true);
1175 * File dragged over window
1177 void MainWindow::dragEnterEvent(QDragEnterEvent
*event
)
1179 QStringList formats
= event
->mimeData()->formats();
1181 if(formats
.contains("application/x-qt-windows-mime;value=\"FileNameW\"", Qt::CaseInsensitive
) && formats
.contains("text/uri-list", Qt::CaseInsensitive
))
1183 event
->acceptProposedAction();
1188 * File dropped onto window
1190 void MainWindow::dropEvent(QDropEvent
*event
)
1192 m_droppedFileList
->clear();
1193 (*m_droppedFileList
) << event
->mimeData()->urls();
1194 if(!m_droppedFileList
->isEmpty())
1196 PLAY_SOUND_OPTIONAL("drop", true);
1197 QTimer::singleShot(0, this, SLOT(handleDroppedFiles()));
1202 * Window tries to close
1204 void MainWindow::closeEvent(QCloseEvent
*event
)
1206 if(BANNER_VISIBLE
|| m_delayedFileTimer
->isActive())
1208 MUtils::Sound::beep(MUtils::Sound::BEEP_WRN
);
1219 * Window was resized
1221 void MainWindow::resizeEvent(QResizeEvent
*event
)
1223 if(event
) QMainWindow::resizeEvent(event
);
1225 if(QWidget
*port
= ui
->sourceFileView
->viewport())
1227 m_dropNoteLabel
->setGeometry(port
->geometry());
1230 if(QWidget
*port
= ui
->outputFolderView
->viewport())
1232 m_outputFolderNoteBox
->setGeometry(16, (port
->height() - 64) / 2, port
->width() - 32, 64);
1237 * Key press event filter
1239 void MainWindow::keyPressEvent(QKeyEvent
*e
)
1241 if(e
->key() == Qt::Key_Delete
)
1243 if(ui
->sourceFileView
->isVisible())
1245 QTimer::singleShot(0, this, SLOT(removeFileButtonClicked()));
1250 if(e
->modifiers().testFlag(Qt::ControlModifier
) && (e
->key() == Qt::Key_F5
))
1252 initializeTranslation();
1253 MUtils::Sound::beep(MUtils::Sound::BEEP_NFO
);
1257 if(e
->key() == Qt::Key_F5
)
1259 if(ui
->outputFolderView
->isVisible())
1261 QTimer::singleShot(0, this, SLOT(refreshFolderContextActionTriggered()));
1266 QMainWindow::keyPressEvent(e
);
1272 bool MainWindow::eventFilter(QObject
*obj
, QEvent
*event
)
1274 if(obj
== m_fileSystemModel
.data())
1276 if(QApplication::overrideCursor() == NULL
)
1278 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor
));
1279 QTimer::singleShot(250, this, SLOT(restoreCursor()));
1283 return QMainWindow::eventFilter(obj
, event
);
1286 bool MainWindow::event(QEvent
*e
)
1290 case MUtils::GUI::USER_EVENT_QUERYENDSESSION
:
1291 qWarning("System is shutting down, main window prepares to close...");
1292 if(BANNER_VISIBLE
) m_banner
->close();
1293 if(m_delayedFileTimer
->isActive()) m_delayedFileTimer
->stop();
1295 case MUtils::GUI::USER_EVENT_ENDSESSION
:
1296 qWarning("System is shutting down, main window will close now...");
1301 QApplication::processEvents(QEventLoop::WaitForMoreEvents
& QEventLoop::ExcludeUserInputEvents
);
1304 m_fileListModel
->clearFiles();
1306 case QEvent::MouseButtonPress
:
1307 if(ui
->outputFolderEdit
->isVisible())
1309 QTimer::singleShot(0, this, SLOT(outputFolderEditFinished()));
1312 return QMainWindow::event(e
);
1316 bool MainWindow::winEvent(MSG
*message
, long *result
)
1318 if(MUtils::GUI::sysmenu_check_msg(message
, IDM_ABOUTBOX
))
1320 QTimer::singleShot(0, ui
->buttonAbout
, SLOT(click()));
1327 ////////////////////////////////////////////////////////////
1329 ////////////////////////////////////////////////////////////
1331 // =========================================================
1332 // Show window slots
1333 // =========================================================
1338 void MainWindow::windowShown(void)
1340 const MUtils::OS::ArgumentMap
&arguments
= MUtils::OS::arguments(); //QApplication::arguments();
1342 //Force resize event
1346 const bool firstRun
= arguments
.contains("first-run");
1349 if((m_settings
->licenseAccepted() <= 0) || firstRun
)
1351 int iAccepted
= m_settings
->licenseAccepted();
1353 if((iAccepted
== 0) || firstRun
)
1355 AboutDialog
*about
= new AboutDialog(m_settings
, this, true);
1356 iAccepted
= about
->exec();
1357 if(iAccepted
<= 0) iAccepted
= -2;
1358 MUTILS_DELETE(about
);
1363 m_settings
->licenseAccepted(++iAccepted
);
1364 m_settings
->syncNow();
1365 QApplication::processEvents();
1366 MUtils::Sound::play_sound("whammy", false);
1367 QMessageBox::critical(this, tr("License Declined"), tr("You have declined the license. Consequently the application will exit now!"), tr("Goodbye!"));
1368 QFileInfo uninstallerInfo
= QFileInfo(QString("%1/Uninstall.exe").arg(QApplication::applicationDirPath()));
1369 if(uninstallerInfo
.exists())
1371 QString uninstallerDir
= uninstallerInfo
.canonicalPath();
1372 QString uninstallerPath
= uninstallerInfo
.canonicalFilePath();
1373 for(int i
= 0; i
< 3; i
++)
1375 if(MUtils::OS::shell_open(this, QDir::toNativeSeparators(uninstallerPath
), "/Force", QDir::toNativeSeparators(uninstallerDir
))) break;
1378 QApplication::quit();
1382 MUtils::Sound::play_sound("woohoo", false);
1383 m_settings
->licenseAccepted(1);
1384 m_settings
->syncNow();
1385 if(lamexp_version_demo()) showAnnounceBox();
1388 //Check for expiration
1389 if(lamexp_version_demo())
1391 if(MUtils::OS::current_date() >= lamexp_version_expires())
1393 qWarning("Binary has expired !!!");
1394 MUtils::Sound::play_sound("whammy", false);
1395 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)
1399 QApplication::quit();
1404 //Slow startup indicator
1405 if(m_settings
->slowStartup() && m_settings
->antivirNotificationsEnabled())
1408 message
+= NOBR(tr("It seems that a bogus anti-virus software is slowing down the startup of LameXP.")).append("<br>");
1409 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>");
1410 if(QMessageBox::warning(this, tr("Slow Startup"), message
, tr("Discard"), tr("Don't Show Again")) == 1)
1412 m_settings
->antivirNotificationsEnabled(false);
1413 ui
->actionDisableSlowStartupNotifications
->setChecked(!m_settings
->antivirNotificationsEnabled());
1418 if(MUtils::OS::current_date() >= MUtils::Version::app_build_date().addYears(1))
1420 qWarning("Binary is more than a year old, time to update!");
1421 SHOW_CORNER_WIDGET(true);
1422 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"));
1426 if(checkForUpdates())
1428 QApplication::quit();
1433 QApplication::quit();
1436 QEventLoop loop
; QTimer::singleShot(7000, &loop
, SLOT(quit()));
1437 MUtils::Sound::play_sound("waiting", true);
1438 SHOW_BANNER_ARG(tr("Skipping update check this time, please be patient..."), &loop
);
1444 QDate lastUpdateCheck
= QDate::fromString(m_settings
->autoUpdateLastCheck(), Qt::ISODate
);
1445 if((!firstRun
) && ((!lastUpdateCheck
.isValid()) || (MUtils::OS::current_date() >= lastUpdateCheck
.addDays(14))))
1447 SHOW_CORNER_WIDGET(true);
1448 if(m_settings
->autoUpdateEnabled())
1450 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)
1452 if(checkForUpdates())
1454 QApplication::quit();
1462 //Check for AAC support
1463 const int aacEncoder
= EncoderRegistry::getAacEncoder();
1464 if(aacEncoder
== SettingsModel::AAC_ENCODER_NERO
)
1466 if(m_settings
->neroAacNotificationsEnabled())
1468 if(lamexp_tools_version("neroAacEnc.exe") < lamexp_toolver_neroaac())
1470 QString messageText
;
1471 messageText
+= NOBR(tr("LameXP detected that your version of the Nero AAC encoder is outdated!")).append("<br>");
1472 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>");
1473 messageText
+= NOBR(tr("You can download the latest version of the Nero AAC encoder from the Nero website at:")).append("<br>");
1474 messageText
+= "<nobr><tt>" + LINK(AboutDialog::neroAacUrl
) + "</tt></nobr><br><br>";
1475 messageText
+= NOBR(tr("(Hint: Please ignore the name of the downloaded ZIP file and check the included 'changelog.txt' instead!)")).append("<br>");
1476 QMessageBox::information(this, tr("AAC Encoder Outdated"), messageText
);
1482 if(m_settings
->neroAacNotificationsEnabled() && (aacEncoder
<= SettingsModel::AAC_ENCODER_NONE
))
1484 QString appPath
= QDir(QCoreApplication::applicationDirPath()).canonicalPath();
1485 if(appPath
.isEmpty()) appPath
= QCoreApplication::applicationDirPath();
1486 QString messageText
;
1487 messageText
+= NOBR(tr("The Nero AAC encoder could not be found. AAC encoding support will be disabled.")).append("<br>");
1488 messageText
+= NOBR(tr("Please put 'neroAacEnc.exe', 'neroAacDec.exe' and 'neroAacTag.exe' into the LameXP directory!")).append("<br><br>");
1489 messageText
+= NOBR(tr("Your LameXP directory is located here:")).append("<br>");
1490 messageText
+= QString("<nobr><tt>%1</tt></nobr><br><br>").arg(FSLINK(QDir::toNativeSeparators(appPath
)));
1491 messageText
+= NOBR(tr("You can download the Nero AAC encoder for free from the official Nero website at:")).append("<br>");
1492 messageText
+= "<nobr><tt>" + LINK(AboutDialog::neroAacUrl
) + "</tt></nobr><br>";
1493 if(QMessageBox::information(this, tr("AAC Support Disabled"), messageText
, tr("Discard"), tr("Don't Show Again")) == 1)
1495 m_settings
->neroAacNotificationsEnabled(false);
1496 ui
->actionDisableNeroAacNotifications
->setChecked(!m_settings
->neroAacNotificationsEnabled());
1501 //Add files from the command-line
1502 QStringList addedFiles
;
1503 foreach(const QString
&value
, arguments
.values("add"))
1505 if(!value
.isEmpty())
1507 QFileInfo
currentFile(value
);
1508 qDebug("Adding file from CLI: %s", MUTILS_UTF8(currentFile
.absoluteFilePath()));
1509 addedFiles
.append(currentFile
.absoluteFilePath());
1512 if(!addedFiles
.isEmpty())
1514 addFilesDelayed(addedFiles
);
1517 //Add folders from the command-line
1518 foreach(const QString
&value
, arguments
.values("add-folder"))
1520 if(!value
.isEmpty())
1522 const QFileInfo
currentFile(value
);
1523 qDebug("Adding folder from CLI: %s", MUTILS_UTF8(currentFile
.absoluteFilePath()));
1524 addFolder(currentFile
.absoluteFilePath(), false, true);
1527 foreach(const QString
&value
, arguments
.values("add-recursive"))
1529 if(!value
.isEmpty())
1531 const QFileInfo
currentFile(value
);
1532 qDebug("Adding folder recursively from CLI: %s", MUTILS_UTF8(currentFile
.absoluteFilePath()));
1533 addFolder(currentFile
.absoluteFilePath(), true, true);
1537 //Enable shell integration
1538 if(m_settings
->shellIntegrationEnabled())
1540 ShellIntegration::install();
1543 //Make DropBox visible
1544 if(m_settings
->dropBoxWidgetEnabled())
1546 m_dropBox
->setVisible(true);
1553 void MainWindow::showAnnounceBox(void)
1555 const unsigned int timeout
= 8U;
1557 const QString announceText
= QString("%1<br><br>%2<br><nobr><tt>%3</tt></nobr><br>").arg
1559 NOBR("We are still looking for LameXP translators!"),
1560 NOBR("If you are willing to translate LameXP to your language or to complete an existing translation, please refer to:"),
1561 LINK("http://lamexp.sourceforge.net/doc/Translate.html")
1564 QMessageBox
*announceBox
= new QMessageBox(QMessageBox::Warning
, "We want you!", announceText
, QMessageBox::NoButton
, this);
1565 announceBox
->setWindowFlags(Qt::Window
| Qt::WindowTitleHint
| Qt::CustomizeWindowHint
);
1566 announceBox
->setIconPixmap(QIcon(":/images/Announcement.png").pixmap(64,79));
1568 QTimer
*timers
[timeout
+1];
1569 QPushButton
*buttons
[timeout
+1];
1571 for(unsigned int i
= 0; i
<= timeout
; i
++)
1573 QString text
= (i
> 0) ? QString("%1 (%2)").arg(tr("Discard"), QString::number(i
)) : tr("Discard");
1574 buttons
[i
] = announceBox
->addButton(text
, (i
> 0) ? QMessageBox::NoRole
: QMessageBox::AcceptRole
);
1577 for(unsigned int i
= 0; i
<= timeout
; i
++)
1579 buttons
[i
]->setEnabled(i
== 0);
1580 buttons
[i
]->setVisible(i
== timeout
);
1583 for(unsigned int i
= 0; i
< timeout
; i
++)
1585 timers
[i
] = new QTimer(this);
1586 timers
[i
]->setSingleShot(true);
1587 timers
[i
]->setInterval(1000);
1588 connect(timers
[i
], SIGNAL(timeout()), buttons
[i
+1], SLOT(hide()));
1589 connect(timers
[i
], SIGNAL(timeout()), buttons
[i
], SLOT(show()));
1592 connect(timers
[i
], SIGNAL(timeout()), timers
[i
-1], SLOT(start()));
1596 timers
[timeout
-1]->start();
1597 announceBox
->exec();
1599 for(unsigned int i
= 0; i
< timeout
; i
++)
1602 MUTILS_DELETE(timers
[i
]);
1605 MUTILS_DELETE(announceBox
);
1608 // =========================================================
1609 // Main button solots
1610 // =========================================================
1615 void MainWindow::encodeButtonClicked(void)
1617 static const unsigned __int64 oneGigabyte
= 1073741824ui
64;
1618 static const unsigned __int64 minimumFreeDiskspaceMultiplier
= 2ui
64;
1619 static const char *writeTestBuffer
= "LAMEXP_WRITE_TEST";
1623 if(m_fileListModel
->rowCount() < 1)
1625 QMessageBox::warning(this, tr("LameXP"), NOBR(tr("You must add at least one file to the list before proceeding!")));
1626 ui
->tabWidget
->setCurrentIndex(0);
1630 QString tempFolder
= m_settings
->customTempPathEnabled() ? m_settings
->customTempPath() : MUtils::temp_folder();
1631 if(!QFileInfo(tempFolder
).exists() || !QFileInfo(tempFolder
).isDir())
1633 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)
1635 SET_CHECKBOX_STATE(ui
->checkBoxUseSystemTempFolder
, (!m_settings
->customTempPathEnabledDefault()));
1640 quint64 currentFreeDiskspace
= 0;
1641 if(MUtils::OS::free_diskspace(tempFolder
, currentFreeDiskspace
))
1643 if(currentFreeDiskspace
< (oneGigabyte
* minimumFreeDiskspaceMultiplier
))
1645 QStringList tempFolderParts
= tempFolder
.split("/", QString::SkipEmptyParts
, Qt::CaseInsensitive
);
1646 tempFolderParts
.takeLast();
1647 PLAY_SOUND_OPTIONAL("whammy", false);
1648 QString lowDiskspaceMsg
= QString("%1<br>%2<br><br>%3<br>%4<br>").arg
1650 NOBR(tr("There are less than %1 GB of free diskspace available on your system's TEMP folder.").arg(QString::number(minimumFreeDiskspaceMultiplier
))),
1651 NOBR(tr("It is highly recommend to free up more diskspace before proceeding with the encode!")),
1652 NOBR(tr("Your TEMP folder is located at:")),
1653 QString("<nobr><tt>%1</tt></nobr>").arg(FSLINK(tempFolderParts
.join("\\")))
1655 switch(QMessageBox::warning(this, tr("Low Diskspace Warning"), lowDiskspaceMsg
, tr("Abort Encoding Process"), tr("Clean Disk Now"), tr("Ignore")))
1658 QProcess::startDetached(QString("%1/cleanmgr.exe").arg(MUtils::OS::known_folder(MUtils::OS::FOLDER_SYSTEMFOLDER
)), QStringList() << "/D" << tempFolderParts
.first());
1663 QMessageBox::warning(this, tr("Low Diskspace"), NOBR(tr("You are proceeding with low diskspace. Problems might occur!")));
1669 switch(m_settings
->compressionEncoder())
1671 case SettingsModel::MP3Encoder
:
1672 case SettingsModel::VorbisEncoder
:
1673 case SettingsModel::AACEncoder
:
1674 case SettingsModel::AC3Encoder
:
1675 case SettingsModel::FLACEncoder
:
1676 case SettingsModel::OpusEncoder
:
1677 case SettingsModel::DCAEncoder
:
1678 case SettingsModel::MACEncoder
:
1679 case SettingsModel::PCMEncoder
:
1682 QMessageBox::warning(this, tr("LameXP"), tr("Sorry, an unsupported encoder has been chosen!"));
1683 ui
->tabWidget
->setCurrentIndex(3);
1687 if(!m_settings
->outputToSourceDir())
1689 QFile
writeTest(QString("%1/~%2.txt").arg(m_settings
->outputDir(), MUtils::rand_str()));
1690 if(!(writeTest
.open(QIODevice::ReadWrite
) && (writeTest
.write(writeTestBuffer
) == strlen(writeTestBuffer
))))
1692 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!")));
1693 ui
->tabWidget
->setCurrentIndex(1);
1710 void MainWindow::aboutButtonClicked(void)
1716 AboutDialog
*aboutBox
= new AboutDialog(m_settings
, this);
1718 MUTILS_DELETE(aboutBox
);
1725 void MainWindow::closeButtonClicked(void)
1731 // =========================================================
1733 // =========================================================
1738 void MainWindow::tabPageChanged(int idx
, const bool silent
)
1742 //Update "view" menu
1743 QList
<QAction
*> actions
= m_tabActionGroup
->actions();
1744 for(int i
= 0; i
< actions
.count(); i
++)
1747 int actionIndex
= actions
.at(i
)->data().toInt(&ok
);
1748 if(ok
&& actionIndex
== idx
)
1750 actions
.at(i
)->setChecked(true);
1757 PLAY_SOUND_OPTIONAL("tick", true);
1760 int initialWidth
= this->width();
1761 int maximumWidth
= QApplication::desktop()->availableGeometry().width();
1763 //Make sure all tab headers are fully visible
1764 if(this->isVisible())
1766 int delta
= ui
->tabWidget
->sizeHint().width() - ui
->tabWidget
->width();
1769 this->resize(qMin(this->width() + delta
, maximumWidth
), this->height());
1773 //Tab specific operations
1774 if(idx
== ui
->tabWidget
->indexOf(ui
->tabOptions
) && ui
->scrollArea
->widget() && this->isVisible())
1776 ui
->scrollArea
->widget()->updateGeometry();
1777 ui
->scrollArea
->viewport()->updateGeometry();
1778 qApp
->processEvents();
1779 int delta
= ui
->scrollArea
->widget()->width() - ui
->scrollArea
->viewport()->width();
1782 this->resize(qMin(this->width() + delta
, maximumWidth
), this->height());
1785 else if(idx
== ui
->tabWidget
->indexOf(ui
->tabSourceFiles
))
1787 m_dropNoteLabel
->setGeometry(0, 0, ui
->sourceFileView
->width(), ui
->sourceFileView
->height());
1789 else if(idx
== ui
->tabWidget
->indexOf(ui
->tabOutputDir
))
1791 if(!m_fileSystemModel
)
1793 QTimer::singleShot(125, this, SLOT(initOutputFolderModel()));
1797 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
1801 //Center window around previous position
1802 if(initialWidth
< this->width())
1804 QPoint prevPos
= this->pos();
1805 int delta
= (this->width() - initialWidth
) >> 2;
1806 move(prevPos
.x() - delta
, prevPos
.y());
1811 * Tab action triggered
1813 void MainWindow::tabActionActivated(QAction
*action
)
1815 if(action
&& action
->data().isValid())
1818 int index
= action
->data().toInt(&ok
);
1821 ui
->tabWidget
->setCurrentIndex(index
);
1826 // =========================================================
1828 // =========================================================
1831 * Handle corner widget Event
1833 void MainWindow::cornerWidgetEventOccurred(QWidget
*sender
, QEvent
*event
)
1835 if(event
->type() == QEvent::MouseButtonPress
)
1837 QTimer::singleShot(0, this, SLOT(checkUpdatesActionActivated()));
1841 // =========================================================
1843 // =========================================================
1846 * Style action triggered
1848 void MainWindow::styleActionActivated(QAction
*action
)
1850 //Change style setting
1851 if(action
&& action
->data().isValid())
1854 int actionIndex
= action
->data().toInt(&ok
);
1857 m_settings
->interfaceStyle(actionIndex
);
1861 //Set up the new style
1862 switch(m_settings
->interfaceStyle())
1865 if(ui
->actionStyleCleanlooks
->isEnabled())
1867 ui
->actionStyleCleanlooks
->setChecked(true);
1868 QApplication::setStyle(new QCleanlooksStyle());
1872 if(ui
->actionStyleWindowsVista
->isEnabled())
1874 ui
->actionStyleWindowsVista
->setChecked(true);
1875 QApplication::setStyle(new QWindowsVistaStyle());
1879 if(ui
->actionStyleWindowsXP
->isEnabled())
1881 ui
->actionStyleWindowsXP
->setChecked(true);
1882 QApplication::setStyle(new QWindowsXPStyle());
1886 if(ui
->actionStyleWindowsClassic
->isEnabled())
1888 ui
->actionStyleWindowsClassic
->setChecked(true);
1889 QApplication::setStyle(new QWindowsStyle());
1893 ui
->actionStylePlastique
->setChecked(true);
1894 QApplication::setStyle(new QPlastiqueStyle());
1898 //Force re-translate after style change
1899 if(QEvent
*e
= new QEvent(QEvent::LanguageChange
))
1906 const type_info
&styleType
= typeid(*qApp
->style());
1907 const bool bTransparent
= ((typeid(QWindowsVistaStyle
) == styleType
) || (typeid(QWindowsXPStyle
) == styleType
));
1908 MAKE_TRANSPARENT(ui
->scrollArea
, bTransparent
);
1910 //Also force a re-size event
1911 QApplication::processEvents(QEventLoop::ExcludeUserInputEvents
);
1916 * Language action triggered
1918 void MainWindow::languageActionActivated(QAction
*action
)
1920 if(action
->data().type() == QVariant::String
)
1922 QString langId
= action
->data().toString();
1924 if(MUtils::Translation::install_translator(langId
))
1926 action
->setChecked(true);
1927 ui
->actionLoadTranslationFromFile
->setChecked(false);
1928 m_settings
->currentLanguage(langId
);
1929 m_settings
->currentLanguageFile(QString());
1935 * Load language from file action triggered
1937 void MainWindow::languageFromFileActionActivated(bool checked
)
1939 QFileDialog
dialog(this, tr("Load Translation"));
1940 dialog
.setFileMode(QFileDialog::ExistingFile
);
1941 dialog
.setNameFilter(QString("%1 (*.qm)").arg(tr("Translation Files")));
1945 QStringList selectedFiles
= dialog
.selectedFiles();
1946 const QString qmFile
= QFileInfo(selectedFiles
.first()).canonicalFilePath();
1947 if(MUtils::Translation::install_translator_from_file(qmFile
))
1949 QList
<QAction
*> actions
= m_languageActionGroup
->actions();
1950 while(!actions
.isEmpty())
1952 actions
.takeFirst()->setChecked(false);
1954 ui
->actionLoadTranslationFromFile
->setChecked(true);
1955 m_settings
->currentLanguageFile(qmFile
);
1959 languageActionActivated(m_languageActionGroup
->actions().first());
1964 // =========================================================
1966 // =========================================================
1969 * Disable update reminder action
1971 void MainWindow::disableUpdateReminderActionTriggered(bool checked
)
1975 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))
1977 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!"))));
1978 m_settings
->autoUpdateEnabled(false);
1982 m_settings
->autoUpdateEnabled(true);
1987 QMessageBox::information(this, tr("Update Reminder"), NOBR(tr("The update reminder has been re-enabled.")));
1988 m_settings
->autoUpdateEnabled(true);
1991 ui
->actionDisableUpdateReminder
->setChecked(!m_settings
->autoUpdateEnabled());
1995 * Disable sound effects action
1997 void MainWindow::disableSoundsActionTriggered(bool checked
)
2001 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))
2003 QMessageBox::information(this, tr("Sound Effects"), NOBR(tr("All sound effects have been disabled.")));
2004 m_settings
->soundsEnabled(false);
2008 m_settings
->soundsEnabled(true);
2013 QMessageBox::information(this, tr("Sound Effects"), NOBR(tr("The sound effects have been re-enabled.")));
2014 m_settings
->soundsEnabled(true);
2017 ui
->actionDisableSounds
->setChecked(!m_settings
->soundsEnabled());
2021 * Disable Nero AAC encoder action
2023 void MainWindow::disableNeroAacNotificationsActionTriggered(bool checked
)
2027 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))
2029 QMessageBox::information(this, tr("Nero AAC Notifications"), NOBR(tr("All Nero AAC Encoder notifications have been disabled.")));
2030 m_settings
->neroAacNotificationsEnabled(false);
2034 m_settings
->neroAacNotificationsEnabled(true);
2039 QMessageBox::information(this, tr("Nero AAC Notifications"), NOBR(tr("The Nero AAC Encoder notifications have been re-enabled.")));
2040 m_settings
->neroAacNotificationsEnabled(true);
2043 ui
->actionDisableNeroAacNotifications
->setChecked(!m_settings
->neroAacNotificationsEnabled());
2047 * Disable slow startup action
2049 void MainWindow::disableSlowStartupNotificationsActionTriggered(bool checked
)
2053 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))
2055 QMessageBox::information(this, tr("Slow Startup Notifications"), NOBR(tr("The slow startup notifications have been disabled.")));
2056 m_settings
->antivirNotificationsEnabled(false);
2060 m_settings
->antivirNotificationsEnabled(true);
2065 QMessageBox::information(this, tr("Slow Startup Notifications"), NOBR(tr("The slow startup notifications have been re-enabled.")));
2066 m_settings
->antivirNotificationsEnabled(true);
2069 ui
->actionDisableSlowStartupNotifications
->setChecked(!m_settings
->antivirNotificationsEnabled());
2073 * Import a Cue Sheet file
2075 void MainWindow::importCueSheetActionTriggered(bool checked
)
2084 QString selectedCueFile
;
2086 if(MUtils::GUI::themes_enabled())
2088 selectedCueFile
= QFileDialog::getOpenFileName(this, tr("Open Cue Sheet"), m_settings
->mostRecentInputPath(), QString("%1 (*.cue)").arg(tr("Cue Sheet File")));
2092 QFileDialog
dialog(this, tr("Open Cue Sheet"));
2093 dialog
.setFileMode(QFileDialog::ExistingFile
);
2094 dialog
.setNameFilter(QString("%1 (*.cue)").arg(tr("Cue Sheet File")));
2095 dialog
.setDirectory(m_settings
->mostRecentInputPath());
2098 selectedCueFile
= dialog
.selectedFiles().first();
2102 if(!selectedCueFile
.isEmpty())
2104 m_settings
->mostRecentInputPath(QFileInfo(selectedCueFile
).canonicalPath());
2105 FileListBlocker
fileListBlocker(m_fileListModel
);
2106 QScopedPointer
<CueImportDialog
> cueImporter(new CueImportDialog(this, m_fileListModel
, selectedCueFile
, m_settings
));
2107 result
= cueImporter
->exec();
2110 if(result
!= QDialog::Rejected
)
2112 qApp
->processEvents(QEventLoop::ExcludeUserInputEvents
);
2113 ui
->sourceFileView
->update();
2114 qApp
->processEvents(QEventLoop::ExcludeUserInputEvents
);
2115 ui
->sourceFileView
->scrollToBottom();
2116 qApp
->processEvents(QEventLoop::ExcludeUserInputEvents
);
2120 qWarning("Whoops! (RESULT: %d)", result
);
2123 if(result
!= (-1)) break;
2129 * Show the "drop box" widget
2131 void MainWindow::showDropBoxWidgetActionTriggered(bool checked
)
2133 m_settings
->dropBoxWidgetEnabled(true);
2135 if(!m_dropBox
->isVisible())
2138 QTimer::singleShot(2500, m_dropBox
, SLOT(showToolTip()));
2141 MUtils::GUI::blink_window(m_dropBox
);
2145 * Check for beta (pre-release) updates
2147 void MainWindow::checkForBetaUpdatesActionTriggered(bool checked
)
2149 bool checkUpdatesNow
= false;
2153 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))
2155 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")))
2157 checkUpdatesNow
= true;
2159 m_settings
->autoUpdateCheckBeta(true);
2163 m_settings
->autoUpdateCheckBeta(false);
2168 QMessageBox::information(this, tr("Beta Updates"), NOBR(tr("LameXP will <i>not</i> check for Beta (pre-release) updates from now on.")));
2169 m_settings
->autoUpdateCheckBeta(false);
2172 ui
->actionCheckForBetaUpdates
->setChecked(m_settings
->autoUpdateCheckBeta());
2176 if(checkForUpdates())
2178 QApplication::quit();
2184 * Hibernate computer action
2186 void MainWindow::hibernateComputerActionTriggered(bool checked
)
2190 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))
2192 QMessageBox::information(this, tr("Hibernate Computer"), NOBR(tr("LameXP will hibernate the computer on shutdown from now on.")));
2193 m_settings
->hibernateComputer(true);
2197 m_settings
->hibernateComputer(false);
2202 QMessageBox::information(this, tr("Hibernate Computer"), NOBR(tr("LameXP will <i>not</i> hibernate the computer on shutdown from now on.")));
2203 m_settings
->hibernateComputer(false);
2206 ui
->actionHibernateComputer
->setChecked(m_settings
->hibernateComputer());
2210 * Disable shell integration action
2212 void MainWindow::disableShellIntegrationActionTriggered(bool checked
)
2216 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))
2218 ShellIntegration::remove();
2219 QMessageBox::information(this, tr("Shell Integration"), NOBR(tr("The LameXP shell integration has been disabled.")));
2220 m_settings
->shellIntegrationEnabled(false);
2224 m_settings
->shellIntegrationEnabled(true);
2229 ShellIntegration::install();
2230 QMessageBox::information(this, tr("Shell Integration"), NOBR(tr("The LameXP shell integration has been re-enabled.")));
2231 m_settings
->shellIntegrationEnabled(true);
2234 ui
->actionDisableShellIntegration
->setChecked(!m_settings
->shellIntegrationEnabled());
2236 if(lamexp_version_portable() && ui
->actionDisableShellIntegration
->isChecked())
2238 ui
->actionDisableShellIntegration
->setEnabled(false);
2242 // =========================================================
2244 // =========================================================
2247 * Visit homepage action
2249 void MainWindow::visitHomepageActionActivated(void)
2251 if(QAction
*action
= dynamic_cast<QAction
*>(QObject::sender()))
2253 if(action
->data().isValid() && (action
->data().type() == QVariant::String
))
2255 QDesktopServices::openUrl(QUrl(action
->data().toString()));
2263 void MainWindow::documentActionActivated(void)
2265 if(QAction
*action
= dynamic_cast<QAction
*>(QObject::sender()))
2267 openDocumentLink(action
);
2272 * Check for updates action
2274 void MainWindow::checkUpdatesActionActivated(void)
2281 bFlag
= checkForUpdates();
2286 QApplication::quit();
2290 // =========================================================
2291 // Source file slots
2292 // =========================================================
2295 * Add file(s) button
2297 void MainWindow::addFilesButtonClicked(void)
2303 if(MUtils::GUI::themes_enabled())
2305 QStringList fileTypeFilters
= DecoderRegistry::getSupportedTypes();
2306 QStringList selectedFiles
= QFileDialog::getOpenFileNames(this, tr("Add file(s)"), m_settings
->mostRecentInputPath(), fileTypeFilters
.join(";;"));
2307 if(!selectedFiles
.isEmpty())
2309 m_settings
->mostRecentInputPath(QFileInfo(selectedFiles
.first()).canonicalPath());
2310 addFiles(selectedFiles
);
2315 QFileDialog
dialog(this, tr("Add file(s)"));
2316 QStringList fileTypeFilters
= DecoderRegistry::getSupportedTypes();
2317 dialog
.setFileMode(QFileDialog::ExistingFiles
);
2318 dialog
.setNameFilter(fileTypeFilters
.join(";;"));
2319 dialog
.setDirectory(m_settings
->mostRecentInputPath());
2322 QStringList selectedFiles
= dialog
.selectedFiles();
2323 if(!selectedFiles
.isEmpty())
2325 m_settings
->mostRecentInputPath(QFileInfo(selectedFiles
.first()).canonicalPath());
2326 addFiles(selectedFiles
);
2334 * Open folder action
2336 void MainWindow::openFolderActionActivated(void)
2339 QString selectedFolder
;
2341 if(QAction
*action
= dynamic_cast<QAction
*>(QObject::sender()))
2345 if(MUtils::GUI::themes_enabled())
2347 selectedFolder
= QFileDialog::getExistingDirectory(this, tr("Add Folder"), m_settings
->mostRecentInputPath());
2351 QFileDialog
dialog(this, tr("Add Folder"));
2352 dialog
.setFileMode(QFileDialog::DirectoryOnly
);
2353 dialog
.setDirectory(m_settings
->mostRecentInputPath());
2356 selectedFolder
= dialog
.selectedFiles().first();
2360 if(selectedFolder
.isEmpty())
2365 QStringList filterItems
= DecoderRegistry::getSupportedExts();
2366 filterItems
.prepend("*.*");
2369 QString filterStr
= QInputDialog::getItem(this, tr("Filter Files"), tr("Select filename filter:"), filterItems
, 0, false, &okay
).trimmed();
2375 QRegExp
regExp("\\*\\.([A-Za-z0-9]+)", Qt::CaseInsensitive
);
2376 if(regExp
.lastIndexIn(filterStr
) >= 0)
2378 filterStr
= regExp
.cap(1).trimmed();
2385 m_settings
->mostRecentInputPath(QDir(selectedFolder
).canonicalPath());
2386 addFolder(selectedFolder
, action
->data().toBool(), false, filterStr
);
2392 * Remove file button
2394 void MainWindow::removeFileButtonClicked(void)
2396 if(ui
->sourceFileView
->currentIndex().isValid())
2398 int iRow
= ui
->sourceFileView
->currentIndex().row();
2399 m_fileListModel
->removeFile(ui
->sourceFileView
->currentIndex());
2400 ui
->sourceFileView
->selectRow(iRow
< m_fileListModel
->rowCount() ? iRow
: m_fileListModel
->rowCount()-1);
2405 * Clear files button
2407 void MainWindow::clearFilesButtonClicked(void)
2409 m_fileListModel
->clearFiles();
2413 * Move file up button
2415 void MainWindow::fileUpButtonClicked(void)
2417 if(ui
->sourceFileView
->currentIndex().isValid())
2419 int iRow
= ui
->sourceFileView
->currentIndex().row() - 1;
2420 m_fileListModel
->moveFile(ui
->sourceFileView
->currentIndex(), -1);
2421 ui
->sourceFileView
->selectRow(iRow
>= 0 ? iRow
: 0);
2426 * Move file down button
2428 void MainWindow::fileDownButtonClicked(void)
2430 if(ui
->sourceFileView
->currentIndex().isValid())
2432 int iRow
= ui
->sourceFileView
->currentIndex().row() + 1;
2433 m_fileListModel
->moveFile(ui
->sourceFileView
->currentIndex(), 1);
2434 ui
->sourceFileView
->selectRow(iRow
< m_fileListModel
->rowCount() ? iRow
: m_fileListModel
->rowCount()-1);
2439 * Show details button
2441 void MainWindow::showDetailsButtonClicked(void)
2446 MetaInfoDialog
*metaInfoDialog
= new MetaInfoDialog(this);
2447 QModelIndex index
= ui
->sourceFileView
->currentIndex();
2449 while(index
.isValid())
2453 index
= m_fileListModel
->index(index
.row() + 1, index
.column());
2454 ui
->sourceFileView
->selectRow(index
.row());
2458 index
= m_fileListModel
->index(index
.row() - 1, index
.column());
2459 ui
->sourceFileView
->selectRow(index
.row());
2462 AudioFileModel
&file
= (*m_fileListModel
)[index
];
2465 iResult
= metaInfoDialog
->exec(file
, index
.row() > 0, index
.row() < m_fileListModel
->rowCount() - 1);
2468 //Copy all info to Meta Info tab
2469 if(iResult
== INT_MAX
)
2471 m_metaInfoModel
->assignInfoFrom(file
);
2472 ui
->tabWidget
->setCurrentIndex(ui
->tabWidget
->indexOf(ui
->tabMetaData
));
2479 MUTILS_DELETE(metaInfoDialog
);
2480 QApplication::processEvents(QEventLoop::ExcludeUserInputEvents
);
2481 sourceFilesScrollbarMoved(0);
2485 * Show context menu for source files
2487 void MainWindow::sourceFilesContextMenu(const QPoint
&pos
)
2489 QAbstractScrollArea
*scrollArea
= dynamic_cast<QAbstractScrollArea
*>(QObject::sender());
2490 QWidget
*sender
= scrollArea
? scrollArea
->viewport() : dynamic_cast<QWidget
*>(QObject::sender());
2494 if(pos
.x() <= sender
->width() && pos
.y() <= sender
->height() && pos
.x() >= 0 && pos
.y() >= 0)
2496 m_sourceFilesContextMenu
->popup(sender
->mapToGlobal(pos
));
2502 * Scrollbar of source files moved
2504 void MainWindow::sourceFilesScrollbarMoved(int)
2506 ui
->sourceFileView
->resizeColumnToContents(0);
2510 * Open selected file in external player
2512 void MainWindow::previewContextActionTriggered(void)
2514 QModelIndex index
= ui
->sourceFileView
->currentIndex();
2515 if(!index
.isValid())
2520 if(!MUtils::OS::open_media_file(m_fileListModel
->getFile(index
).filePath()))
2522 qDebug("Player not found, falling back to default application...");
2523 QDesktopServices::openUrl(QString("file:///").append(m_fileListModel
->getFile(index
).filePath()));
2528 * Find selected file in explorer
2530 void MainWindow::findFileContextActionTriggered(void)
2532 QModelIndex index
= ui
->sourceFileView
->currentIndex();
2535 QString systemRootPath
;
2537 QDir
systemRoot(MUtils::OS::known_folder(MUtils::OS::FOLDER_SYSTEMFOLDER
));
2538 if(systemRoot
.exists() && systemRoot
.cdUp())
2540 systemRootPath
= systemRoot
.canonicalPath();
2543 if(!systemRootPath
.isEmpty())
2545 QFileInfo
explorer(QString("%1/explorer.exe").arg(systemRootPath
));
2546 if(explorer
.exists() && explorer
.isFile())
2548 QProcess::execute(explorer
.canonicalFilePath(), QStringList() << "/select," << QDir::toNativeSeparators(m_fileListModel
->getFile(index
).filePath()));
2554 qWarning("SystemRoot directory could not be detected!");
2560 * Add all dropped files
2562 void MainWindow::handleDroppedFiles(void)
2566 static const int MIN_COUNT
= 16;
2567 const QString bannerText
= tr("Loading dropped files or folders, please wait...");
2568 bool bUseBanner
= false;
2570 SHOW_BANNER_CONDITIONALLY(bUseBanner
, (m_droppedFileList
->count() >= MIN_COUNT
), bannerText
);
2572 QStringList droppedFiles
;
2573 while(!m_droppedFileList
->isEmpty())
2575 QFileInfo
file(m_droppedFileList
->takeFirst().toLocalFile());
2576 QApplication::processEvents(QEventLoop::ExcludeUserInputEvents
);
2585 qDebug("Dropped File: %s", MUTILS_UTF8(file
.canonicalFilePath()));
2586 droppedFiles
<< file
.canonicalFilePath();
2592 qDebug("Dropped Folder: %s", MUTILS_UTF8(file
.canonicalFilePath()));
2593 QFileInfoList list
= QDir(file
.canonicalFilePath()).entryInfoList(QDir::Files
| QDir::NoDotAndDotDot
| QDir::NoSymLinks
);
2594 if(list
.count() > 0)
2596 SHOW_BANNER_CONDITIONALLY(bUseBanner
, (list
.count() >= MIN_COUNT
), bannerText
);
2597 for(QFileInfoList::ConstIterator iter
= list
.constBegin(); iter
!= list
.constEnd(); iter
++)
2599 droppedFiles
<< (*iter
).canonicalFilePath();
2604 list
= QDir(file
.canonicalFilePath()).entryInfoList(QDir::Dirs
| QDir::NoDotAndDotDot
| QDir::NoSymLinks
);
2605 SHOW_BANNER_CONDITIONALLY(bUseBanner
, (list
.count() >= MIN_COUNT
), bannerText
);
2606 for(QFileInfoList::ConstIterator iter
= list
.constBegin(); iter
!= list
.constEnd(); iter
++)
2608 qDebug("Descending to Folder: %s", MUTILS_UTF8((*iter
).canonicalFilePath()));
2609 m_droppedFileList
->prepend(QUrl::fromLocalFile((*iter
).canonicalFilePath()));
2620 if(!droppedFiles
.isEmpty())
2622 addFiles(droppedFiles
);
2627 * Add all pending files
2629 void MainWindow::handleDelayedFiles(void)
2631 m_delayedFileTimer
->stop();
2633 if(m_delayedFileList
->isEmpty())
2640 m_delayedFileTimer
->start(5000);
2644 WITH_BLOCKED_SIGNALS(ui
->tabWidget
, setCurrentIndex
, 0);
2645 tabPageChanged(ui
->tabWidget
->currentIndex(), true);
2647 QStringList selectedFiles
;
2648 while(!m_delayedFileList
->isEmpty())
2650 QFileInfo currentFile
= QFileInfo(m_delayedFileList
->takeFirst());
2651 if(!currentFile
.exists() || !currentFile
.isFile())
2655 selectedFiles
<< currentFile
.canonicalFilePath();
2658 addFiles(selectedFiles
);
2662 * Export Meta tags to CSV file
2664 void MainWindow::exportCsvContextActionTriggered(void)
2668 QString selectedCsvFile
;
2670 if(MUtils::GUI::themes_enabled())
2672 selectedCsvFile
= QFileDialog::getSaveFileName(this, tr("Save CSV file"), m_settings
->mostRecentInputPath(), QString("%1 (*.csv)").arg(tr("CSV File")));
2676 QFileDialog
dialog(this, tr("Save CSV file"));
2677 dialog
.setFileMode(QFileDialog::AnyFile
);
2678 dialog
.setAcceptMode(QFileDialog::AcceptSave
);
2679 dialog
.setNameFilter(QString("%1 (*.csv)").arg(tr("CSV File")));
2680 dialog
.setDirectory(m_settings
->mostRecentInputPath());
2683 selectedCsvFile
= dialog
.selectedFiles().first();
2687 if(!selectedCsvFile
.isEmpty())
2689 m_settings
->mostRecentInputPath(QFileInfo(selectedCsvFile
).canonicalPath());
2690 switch(m_fileListModel
->exportToCsv(selectedCsvFile
))
2692 case FileListModel::CsvError_NoTags
:
2693 QMessageBox::critical(this, tr("CSV Export"), NOBR(tr("Sorry, there are no meta tags that can be exported!")));
2695 case FileListModel::CsvError_FileOpen
:
2696 QMessageBox::critical(this, tr("CSV Export"), NOBR(tr("Sorry, failed to open CSV file for writing!")));
2698 case FileListModel::CsvError_FileWrite
:
2699 QMessageBox::critical(this, tr("CSV Export"), NOBR(tr("Sorry, failed to write to the CSV file!")));
2701 case FileListModel::CsvError_OK
:
2702 QMessageBox::information(this, tr("CSV Export"), NOBR(tr("The CSV files was created successfully!")));
2705 qWarning("exportToCsv: Unknown return code!");
2713 * Import Meta tags from CSV file
2715 void MainWindow::importCsvContextActionTriggered(void)
2719 QString selectedCsvFile
;
2721 if(MUtils::GUI::themes_enabled())
2723 selectedCsvFile
= QFileDialog::getOpenFileName(this, tr("Open CSV file"), m_settings
->mostRecentInputPath(), QString("%1 (*.csv)").arg(tr("CSV File")));
2727 QFileDialog
dialog(this, tr("Open CSV file"));
2728 dialog
.setFileMode(QFileDialog::ExistingFile
);
2729 dialog
.setNameFilter(QString("%1 (*.csv)").arg(tr("CSV File")));
2730 dialog
.setDirectory(m_settings
->mostRecentInputPath());
2733 selectedCsvFile
= dialog
.selectedFiles().first();
2737 if(!selectedCsvFile
.isEmpty())
2739 m_settings
->mostRecentInputPath(QFileInfo(selectedCsvFile
).canonicalPath());
2740 switch(m_fileListModel
->importFromCsv(this, selectedCsvFile
))
2742 case FileListModel::CsvError_FileOpen
:
2743 QMessageBox::critical(this, tr("CSV Import"), NOBR(tr("Sorry, failed to open CSV file for reading!")));
2745 case FileListModel::CsvError_FileRead
:
2746 QMessageBox::critical(this, tr("CSV Import"), NOBR(tr("Sorry, failed to read from the CSV file!")));
2748 case FileListModel::CsvError_NoTags
:
2749 QMessageBox::critical(this, tr("CSV Import"), NOBR(tr("Sorry, the CSV file does not contain any known fields!")));
2751 case FileListModel::CsvError_Incomplete
:
2752 QMessageBox::warning(this, tr("CSV Import"), NOBR(tr("CSV file is incomplete. Not all files were updated!")));
2754 case FileListModel::CsvError_OK
:
2755 QMessageBox::information(this, tr("CSV Import"), NOBR(tr("The CSV files was imported successfully!")));
2757 case FileListModel::CsvError_Aborted
:
2758 /* User aborted, ignore! */
2761 qWarning("exportToCsv: Unknown return code!");
2768 * Show or hide Drag'n'Drop notice after model reset
2770 void MainWindow::sourceModelChanged(void)
2772 m_dropNoteLabel
->setVisible(m_fileListModel
->rowCount() <= 0);
2775 // =========================================================
2776 // Output folder slots
2777 // =========================================================
2780 * Output folder changed (mouse clicked)
2782 void MainWindow::outputFolderViewClicked(const QModelIndex
&index
)
2784 if(index
.isValid() && (ui
->outputFolderView
->currentIndex() != index
))
2786 ui
->outputFolderView
->setCurrentIndex(index
);
2789 if(m_fileSystemModel
&& index
.isValid())
2791 QString selectedDir
= m_fileSystemModel
->filePath(index
);
2792 if(selectedDir
.length() < 3) selectedDir
.append(QDir::separator());
2793 ui
->outputFolderLabel
->setText(QDir::toNativeSeparators(selectedDir
));
2794 ui
->outputFolderLabel
->setToolTip(ui
->outputFolderLabel
->text());
2795 m_settings
->outputDir(selectedDir
);
2799 ui
->outputFolderLabel
->setText(QDir::toNativeSeparators(m_settings
->outputDir()));
2800 ui
->outputFolderLabel
->setToolTip(ui
->outputFolderLabel
->text());
2805 * Output folder changed (mouse moved)
2807 void MainWindow::outputFolderViewMoved(const QModelIndex
&index
)
2809 if(QApplication::mouseButtons() & Qt::LeftButton
)
2811 outputFolderViewClicked(index
);
2816 * Goto desktop button
2818 void MainWindow::gotoDesktopButtonClicked(void)
2820 if(!m_fileSystemModel
)
2822 qWarning("File system model not initialized yet!");
2826 QString desktopPath
= QDesktopServices::storageLocation(QDesktopServices::DesktopLocation
);
2828 if(!desktopPath
.isEmpty() && QDir(desktopPath
).exists())
2830 ui
->outputFolderView
->setCurrentIndex(m_fileSystemModel
->index(desktopPath
));
2831 outputFolderViewClicked(ui
->outputFolderView
->currentIndex());
2832 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
2836 ui
->buttonGotoDesktop
->setEnabled(false);
2841 * Goto home folder button
2843 void MainWindow::gotoHomeFolderButtonClicked(void)
2845 if(!m_fileSystemModel
)
2847 qWarning("File system model not initialized yet!");
2851 QString homePath
= QDesktopServices::storageLocation(QDesktopServices::HomeLocation
);
2853 if(!homePath
.isEmpty() && QDir(homePath
).exists())
2855 ui
->outputFolderView
->setCurrentIndex(m_fileSystemModel
->index(homePath
));
2856 outputFolderViewClicked(ui
->outputFolderView
->currentIndex());
2857 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
2861 ui
->buttonGotoHome
->setEnabled(false);
2866 * Goto music folder button
2868 void MainWindow::gotoMusicFolderButtonClicked(void)
2870 if(!m_fileSystemModel
)
2872 qWarning("File system model not initialized yet!");
2876 QString musicPath
= QDesktopServices::storageLocation(QDesktopServices::MusicLocation
);
2878 if(!musicPath
.isEmpty() && QDir(musicPath
).exists())
2880 ui
->outputFolderView
->setCurrentIndex(m_fileSystemModel
->index(musicPath
));
2881 outputFolderViewClicked(ui
->outputFolderView
->currentIndex());
2882 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
2886 ui
->buttonGotoMusic
->setEnabled(false);
2891 * Goto music favorite output folder
2893 void MainWindow::gotoFavoriteFolder(void)
2895 if(!m_fileSystemModel
)
2897 qWarning("File system model not initialized yet!");
2901 QAction
*item
= dynamic_cast<QAction
*>(QObject::sender());
2905 QDir
path(item
->data().toString());
2908 ui
->outputFolderView
->setCurrentIndex(m_fileSystemModel
->index(path
.canonicalPath()));
2909 outputFolderViewClicked(ui
->outputFolderView
->currentIndex());
2910 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
2914 MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
);
2915 m_outputFolderFavoritesMenu
->removeAction(item
);
2916 item
->deleteLater();
2922 * Make folder button
2924 void MainWindow::makeFolderButtonClicked(void)
2928 if(!m_fileSystemModel
)
2930 qWarning("File system model not initialized yet!");
2934 QDir
basePath(m_fileSystemModel
->fileInfo(ui
->outputFolderView
->currentIndex()).absoluteFilePath());
2935 QString suggestedName
= tr("New Folder");
2937 if(!m_metaData
->artist().isEmpty() && !m_metaData
->album().isEmpty())
2939 suggestedName
= QString("%1 - %2").arg(m_metaData
->artist(),m_metaData
->album());
2941 else if(!m_metaData
->artist().isEmpty())
2943 suggestedName
= m_metaData
->artist();
2945 else if(!m_metaData
->album().isEmpty())
2947 suggestedName
=m_metaData
->album();
2951 for(int i
= 0; i
< m_fileListModel
->rowCount(); i
++)
2953 const AudioFileModel
&audioFile
= m_fileListModel
->getFile(m_fileListModel
->index(i
, 0));
2954 const AudioFileModel_MetaInfo
&fileMetaInfo
= audioFile
.metaInfo();
2956 if(!fileMetaInfo
.album().isEmpty() || !fileMetaInfo
.artist().isEmpty())
2958 if(!fileMetaInfo
.artist().isEmpty() && !fileMetaInfo
.album().isEmpty())
2960 suggestedName
= QString("%1 - %2").arg(fileMetaInfo
.artist(), fileMetaInfo
.album());
2962 else if(!fileMetaInfo
.artist().isEmpty())
2964 suggestedName
= fileMetaInfo
.artist();
2966 else if(!fileMetaInfo
.album().isEmpty())
2968 suggestedName
= fileMetaInfo
.album();
2975 suggestedName
= MUtils::clean_file_name(suggestedName
);
2979 bool bApplied
= false;
2980 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();
2984 folderName
= MUtils::clean_file_path(folderName
.simplified());
2986 if(folderName
.isEmpty())
2988 MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
);
2993 QString newFolder
= folderName
;
2995 while(basePath
.exists(newFolder
))
2997 newFolder
= QString(folderName
).append(QString().sprintf(" (%d)", ++i
));
3000 if(basePath
.mkpath(newFolder
))
3002 QDir createdDir
= basePath
;
3003 if(createdDir
.cd(newFolder
))
3005 QModelIndex newIndex
= m_fileSystemModel
->index(createdDir
.canonicalPath());
3006 ui
->outputFolderView
->setCurrentIndex(newIndex
);
3007 outputFolderViewClicked(newIndex
);
3008 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
3013 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!")));
3021 * Output to source dir changed
3023 void MainWindow::saveToSourceFolderChanged(void)
3025 m_settings
->outputToSourceDir(ui
->saveToSourceFolderCheckBox
->isChecked());
3029 * Prepend relative source file path to output file name changed
3031 void MainWindow::prependRelativePathChanged(void)
3033 m_settings
->prependRelativeSourcePath(ui
->prependRelativePathCheckBox
->isChecked());
3037 * Show context menu for output folder
3039 void MainWindow::outputFolderContextMenu(const QPoint
&pos
)
3041 QAbstractScrollArea
*scrollArea
= dynamic_cast<QAbstractScrollArea
*>(QObject::sender());
3042 QWidget
*sender
= scrollArea
? scrollArea
->viewport() : dynamic_cast<QWidget
*>(QObject::sender());
3044 if(pos
.x() <= sender
->width() && pos
.y() <= sender
->height() && pos
.x() >= 0 && pos
.y() >= 0)
3046 m_outputFolderContextMenu
->popup(sender
->mapToGlobal(pos
));
3051 * Show selected folder in explorer
3053 void MainWindow::showFolderContextActionTriggered(void)
3055 if(!m_fileSystemModel
)
3057 qWarning("File system model not initialized yet!");
3061 QString path
= QDir::toNativeSeparators(m_fileSystemModel
->filePath(ui
->outputFolderView
->currentIndex()));
3062 if(!path
.endsWith(QDir::separator())) path
.append(QDir::separator());
3063 MUtils::OS::shell_open(this, path
, true);
3067 * Refresh the directory outline
3069 void MainWindow::refreshFolderContextActionTriggered(void)
3071 //force re-initialization
3072 QTimer::singleShot(0, this, SLOT(initOutputFolderModel()));
3076 * Go one directory up
3078 void MainWindow::goUpFolderContextActionTriggered(void)
3080 QModelIndex current
= ui
->outputFolderView
->currentIndex();
3081 if(current
.isValid())
3083 QModelIndex parent
= current
.parent();
3084 if(parent
.isValid())
3087 ui
->outputFolderView
->setCurrentIndex(parent
);
3088 outputFolderViewClicked(parent
);
3092 MUtils::Sound::beep(MUtils::Sound::BEEP_WRN
);
3094 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
3099 * Add current folder to favorites
3101 void MainWindow::addFavoriteFolderActionTriggered(void)
3103 QString path
= m_fileSystemModel
->filePath(ui
->outputFolderView
->currentIndex());
3104 QStringList favorites
= m_settings
->favoriteOutputFolders().split("|", QString::SkipEmptyParts
);
3106 if(!favorites
.contains(path
, Qt::CaseInsensitive
))
3108 favorites
.append(path
);
3109 while(favorites
.count() > 6) favorites
.removeFirst();
3113 MUtils::Sound::beep(MUtils::Sound::BEEP_WRN
);
3116 m_settings
->favoriteOutputFolders(favorites
.join("|"));
3121 * Output folder edit finished
3123 void MainWindow::outputFolderEditFinished(void)
3125 if(ui
->outputFolderEdit
->isHidden())
3127 return; //Not currently in edit mode!
3132 QString text
= QDir::fromNativeSeparators(ui
->outputFolderEdit
->text().trimmed());
3133 while(text
.startsWith('"') || text
.startsWith('/')) text
= text
.right(text
.length() - 1).trimmed();
3134 while(text
.endsWith('"') || text
.endsWith('/')) text
= text
.left(text
.length() - 1).trimmed();
3136 static const char *str
= "?*<>|\"";
3137 for(size_t i
= 0; str
[i
]; i
++) text
.replace(str
[i
], "_");
3139 if(!((text
.length() >= 2) && text
.at(0).isLetter() && text
.at(1) == QChar(':')))
3141 text
= QString("%1/%2").arg(QDir::fromNativeSeparators(ui
->outputFolderLabel
->text()), text
);
3144 if(text
.length() == 2) text
+= "/"; /* "X:" => "X:/" */
3146 while(text
.length() > 2)
3148 QFileInfo
info(text
);
3149 if(info
.exists() && info
.isDir())
3151 QModelIndex index
= m_fileSystemModel
->index(QFileInfo(info
.canonicalFilePath()).absoluteFilePath());
3155 ui
->outputFolderView
->setCurrentIndex(index
);
3156 outputFolderViewClicked(index
);
3160 else if(info
.exists() && info
.isFile())
3162 QModelIndex index
= m_fileSystemModel
->index(QFileInfo(info
.canonicalPath()).absoluteFilePath());
3166 ui
->outputFolderView
->setCurrentIndex(index
);
3167 outputFolderViewClicked(index
);
3172 text
= text
.left(text
.length() - 1).trimmed();
3175 ui
->outputFolderEdit
->setVisible(false);
3176 ui
->outputFolderLabel
->setVisible(true);
3177 ui
->outputFolderView
->setEnabled(true);
3179 if(!ok
) MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
);
3180 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
3184 * Initialize file system model
3186 void MainWindow::initOutputFolderModel(void)
3188 if(m_outputFolderNoteBox
->isHidden())
3190 m_outputFolderNoteBox
->show();
3191 m_outputFolderNoteBox
->repaint();
3192 m_outputFolderViewInitCounter
= 4;
3194 if(m_fileSystemModel
)
3196 SET_MODEL(ui
->outputFolderView
, NULL
);
3197 ui
->outputFolderView
->repaint();
3200 m_fileSystemModel
.reset(new QFileSystemModelEx());
3201 if(!m_fileSystemModel
.isNull())
3203 m_fileSystemModel
->installEventFilter(this);
3204 connect(m_fileSystemModel
.data(), SIGNAL(directoryLoaded(QString
)), this, SLOT(outputFolderDirectoryLoaded(QString
)));
3205 connect(m_fileSystemModel
.data(), SIGNAL(rowsInserted(QModelIndex
,int,int)), this, SLOT(outputFolderRowsInserted(QModelIndex
,int,int)));
3207 SET_MODEL(ui
->outputFolderView
, m_fileSystemModel
.data());
3208 ui
->outputFolderView
->header()->setStretchLastSection(true);
3209 ui
->outputFolderView
->header()->hideSection(1);
3210 ui
->outputFolderView
->header()->hideSection(2);
3211 ui
->outputFolderView
->header()->hideSection(3);
3213 m_fileSystemModel
->setRootPath("");
3214 QModelIndex index
= m_fileSystemModel
->index(m_settings
->outputDir());
3215 if(index
.isValid()) ui
->outputFolderView
->setCurrentIndex(index
);
3216 outputFolderViewClicked(ui
->outputFolderView
->currentIndex());
3219 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
3220 QTimer::singleShot(125, this, SLOT(initOutputFolderModel_doAsync()));
3225 * Initialize file system model (do NOT call this one directly!)
3227 void MainWindow::initOutputFolderModel_doAsync(void)
3229 if(m_outputFolderViewInitCounter
> 0)
3231 m_outputFolderViewInitCounter
--;
3232 QTimer::singleShot(125, this, SLOT(initOutputFolderModel_doAsync()));
3236 QTimer::singleShot(125, m_outputFolderNoteBox
, SLOT(hide()));
3237 ui
->outputFolderView
->setFocus();
3242 * Center current folder in view
3244 void MainWindow::centerOutputFolderModel(void)
3246 if(ui
->outputFolderView
->isVisible())
3248 centerOutputFolderModel_doAsync();
3249 QTimer::singleShot(125, this, SLOT(centerOutputFolderModel_doAsync()));
3254 * Center current folder in view (do NOT call this one directly!)
3256 void MainWindow::centerOutputFolderModel_doAsync(void)
3258 if(ui
->outputFolderView
->isVisible())
3260 m_outputFolderViewCentering
= true;
3261 const QModelIndex index
= ui
->outputFolderView
->currentIndex();
3262 ui
->outputFolderView
->scrollTo(index
, QAbstractItemView::PositionAtCenter
);
3263 ui
->outputFolderView
->setFocus();
3268 * File system model asynchronously loaded a dir
3270 void MainWindow::outputFolderDirectoryLoaded(const QString
&path
)
3272 if(m_outputFolderViewCentering
)
3274 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
3279 * File system model inserted new items
3281 void MainWindow::outputFolderRowsInserted(const QModelIndex
&parent
, int start
, int end
)
3283 if(m_outputFolderViewCentering
)
3285 CENTER_CURRENT_OUTPUT_FOLDER_DELAYED
;
3290 * Directory view item was expanded by user
3292 void MainWindow::outputFolderItemExpanded(const QModelIndex
&item
)
3294 //We need to stop centering as soon as the user has expanded an item manually!
3295 m_outputFolderViewCentering
= false;
3299 * View event for output folder control occurred
3301 void MainWindow::outputFolderViewEventOccurred(QWidget
*sender
, QEvent
*event
)
3303 switch(event
->type())
3307 case QEvent::KeyPress
:
3308 case QEvent::KeyRelease
:
3309 case QEvent::FocusIn
:
3310 case QEvent::FocusOut
:
3311 case QEvent::TouchEnd
:
3312 outputFolderViewClicked(ui
->outputFolderView
->currentIndex());
3318 * Mouse event for output folder control occurred
3320 void MainWindow::outputFolderMouseEventOccurred(QWidget
*sender
, QEvent
*event
)
3322 QMouseEvent
*mouseEvent
= dynamic_cast<QMouseEvent
*>(event
);
3323 QPoint pos
= (mouseEvent
) ? mouseEvent
->pos() : QPoint();
3325 if(sender
== ui
->outputFolderLabel
)
3327 switch(event
->type())
3329 case QEvent::MouseButtonPress
:
3330 if(mouseEvent
&& (mouseEvent
->button() == Qt::LeftButton
))
3332 QString path
= ui
->outputFolderLabel
->text();
3333 if(!path
.endsWith(QDir::separator())) path
.append(QDir::separator());
3334 MUtils::OS::shell_open(this, path
, true);
3338 ui
->outputFolderLabel
->setForegroundRole(QPalette::Link
);
3341 ui
->outputFolderLabel
->setForegroundRole(QPalette::WindowText
);
3346 if((sender
== ui
->outputFoldersFovoritesLabel
) || (sender
== ui
->outputFoldersEditorLabel
) || (sender
== ui
->outputFoldersGoUpLabel
))
3348 const type_info
&styleType
= typeid(*qApp
->style());
3349 if((typeid(QPlastiqueStyle
) == styleType
) || (typeid(QWindowsStyle
) == styleType
))
3351 switch(event
->type())
3354 dynamic_cast<QLabel
*>(sender
)->setFrameShadow(ui
->outputFolderView
->isEnabled() ? QFrame::Raised
: QFrame::Plain
);
3356 case QEvent::MouseButtonPress
:
3357 dynamic_cast<QLabel
*>(sender
)->setFrameShadow(ui
->outputFolderView
->isEnabled() ? QFrame::Sunken
: QFrame::Plain
);
3359 case QEvent::MouseButtonRelease
:
3360 dynamic_cast<QLabel
*>(sender
)->setFrameShadow(ui
->outputFolderView
->isEnabled() ? QFrame::Raised
: QFrame::Plain
);
3363 dynamic_cast<QLabel
*>(sender
)->setFrameShadow(ui
->outputFolderView
->isEnabled() ? QFrame::Plain
: QFrame::Plain
);
3369 dynamic_cast<QLabel
*>(sender
)->setFrameShadow(QFrame::Plain
);
3372 if((event
->type() == QEvent::MouseButtonRelease
) && ui
->outputFolderView
->isEnabled() && (mouseEvent
))
3374 if(pos
.x() <= sender
->width() && pos
.y() <= sender
->height() && pos
.x() >= 0 && pos
.y() >= 0 && mouseEvent
->button() != Qt::MidButton
)
3376 if(sender
== ui
->outputFoldersFovoritesLabel
)
3378 m_outputFolderFavoritesMenu
->popup(sender
->mapToGlobal(pos
));
3380 else if(sender
== ui
->outputFoldersEditorLabel
)
3382 ui
->outputFolderView
->setEnabled(false);
3383 ui
->outputFolderLabel
->setVisible(false);
3384 ui
->outputFolderEdit
->setVisible(true);
3385 ui
->outputFolderEdit
->setText(ui
->outputFolderLabel
->text());
3386 ui
->outputFolderEdit
->selectAll();
3387 ui
->outputFolderEdit
->setFocus();
3389 else if(sender
== ui
->outputFoldersGoUpLabel
)
3391 QTimer::singleShot(0, this, SLOT(goUpFolderContextActionTriggered()));
3395 MUTILS_THROW("Oups, this is not supposed to happen!");
3402 // =========================================================
3403 // Metadata tab slots
3404 // =========================================================
3407 * Edit meta button clicked
3409 void MainWindow::editMetaButtonClicked(void)
3413 const QModelIndex index
= ui
->metaDataView
->currentIndex();
3417 m_metaInfoModel
->editItem(index
, this);
3419 if(index
.row() == 4)
3421 m_settings
->metaInfoPosition(m_metaData
->position());
3427 * Reset meta button clicked
3429 void MainWindow::clearMetaButtonClicked(void)
3432 m_metaInfoModel
->clearData();
3436 * Meta tags enabled changed
3438 void MainWindow::metaTagsEnabledChanged(void)
3440 m_settings
->writeMetaTags(ui
->writeMetaDataCheckBox
->isChecked());
3444 * Playlist enabled changed
3446 void MainWindow::playlistEnabledChanged(void)
3448 m_settings
->createPlaylist(ui
->generatePlaylistCheckBox
->isChecked());
3451 // =========================================================
3452 // Compression tab slots
3453 // =========================================================
3458 void MainWindow::updateEncoder(int id
)
3460 /*qWarning("\nupdateEncoder(%d)", id);*/
3462 m_settings
->compressionEncoder(id
);
3463 const AbstractEncoderInfo
*info
= EncoderRegistry::getEncoderInfo(id
);
3465 //Update UI controls
3466 ui
->radioButtonModeQuality
->setEnabled(info
->isModeSupported(SettingsModel::VBRMode
));
3467 ui
->radioButtonModeAverageBitrate
->setEnabled(info
->isModeSupported(SettingsModel::ABRMode
));
3468 ui
->radioButtonConstBitrate
->setEnabled(info
->isModeSupported(SettingsModel::CBRMode
));
3470 //Initialize checkbox state
3471 if(ui
->radioButtonModeQuality
->isEnabled()) ui
->radioButtonModeQuality
->setChecked(true);
3472 else if(ui
->radioButtonModeAverageBitrate
->isEnabled()) ui
->radioButtonModeAverageBitrate
->setChecked(true);
3473 else if(ui
->radioButtonConstBitrate
->isEnabled()) ui
->radioButtonConstBitrate
->setChecked(true);
3474 else MUTILS_THROW("It appears that the encoder does not support *any* RC mode!");
3476 //Apply current RC mode
3477 const int currentRCMode
= EncoderRegistry::loadEncoderMode(m_settings
, id
);
3478 switch(currentRCMode
)
3480 case SettingsModel::VBRMode
: if(ui
->radioButtonModeQuality
->isEnabled()) ui
->radioButtonModeQuality
->setChecked(true); break;
3481 case SettingsModel::ABRMode
: if(ui
->radioButtonModeAverageBitrate
->isEnabled()) ui
->radioButtonModeAverageBitrate
->setChecked(true); break;
3482 case SettingsModel::CBRMode
: if(ui
->radioButtonConstBitrate
->isEnabled()) ui
->radioButtonConstBitrate
->setChecked(true); break;
3483 default: MUTILS_THROW("updateEncoder(): Unknown rc-mode encountered!");
3486 //Display encoder description
3487 if(const char* description
= info
->description())
3489 ui
->labelEncoderInfo
->setVisible(true);
3490 ui
->labelEncoderInfo
->setText(tr("Current Encoder: %1").arg(QString::fromUtf8(description
)));
3494 ui
->labelEncoderInfo
->setVisible(false);
3498 updateRCMode(m_modeButtonGroup
->checkedId());
3502 * Update rate-control mode
3504 void MainWindow::updateRCMode(int id
)
3506 /*qWarning("updateRCMode(%d)", id);*/
3509 const int currentEncoder
= m_encoderButtonGroup
->checkedId();
3510 EncoderRegistry::saveEncoderMode(m_settings
, currentEncoder
, id
);
3512 //Fetch encoder info
3513 const AbstractEncoderInfo
*info
= EncoderRegistry::getEncoderInfo(currentEncoder
);
3514 const int valueCount
= info
->valueCount(id
);
3517 if(!info
->isModeSupported(id
))
3519 qWarning("Attempting to use an unsupported RC mode (%d) with current encoder (%d)!", id
, currentEncoder
);
3520 ui
->labelBitrate
->setText("(ERROR)");
3524 //Update slider min/max values
3527 WITH_BLOCKED_SIGNALS(ui
->sliderBitrate
, setEnabled
, true);
3528 WITH_BLOCKED_SIGNALS(ui
->sliderBitrate
, setMinimum
, 0);
3529 WITH_BLOCKED_SIGNALS(ui
->sliderBitrate
, setMaximum
, valueCount
-1);
3533 WITH_BLOCKED_SIGNALS(ui
->sliderBitrate
, setEnabled
, false);
3534 WITH_BLOCKED_SIGNALS(ui
->sliderBitrate
, setMinimum
, 0);
3535 WITH_BLOCKED_SIGNALS(ui
->sliderBitrate
, setMaximum
, 2);
3538 //Now update bitrate/quality value!
3541 const int currentValue
= EncoderRegistry::loadEncoderValue(m_settings
, currentEncoder
, id
);
3542 ui
->sliderBitrate
->setValue(qBound(0, currentValue
, valueCount
-1));
3543 updateBitrate(qBound(0, currentValue
, valueCount
-1));
3547 ui
->sliderBitrate
->setValue(1);
3555 void MainWindow::updateBitrate(int value
)
3557 /*qWarning("updateBitrate(%d)", value);*/
3559 //Load current encoder and RC mode
3560 const int currentEncoder
= m_encoderButtonGroup
->checkedId();
3561 const int currentRCMode
= m_modeButtonGroup
->checkedId();
3563 //Fetch encoder info
3564 const AbstractEncoderInfo
*info
= EncoderRegistry::getEncoderInfo(currentEncoder
);
3565 const int valueCount
= info
->valueCount(currentRCMode
);
3568 if(!info
->isModeSupported(currentRCMode
))
3570 qWarning("Attempting to use an unsupported RC mode (%d) with current encoder (%d)!", currentRCMode
, currentEncoder
);
3571 ui
->labelBitrate
->setText("(ERROR)");
3575 //Store new bitrate value
3578 EncoderRegistry::saveEncoderValue(m_settings
, currentEncoder
, currentRCMode
, qBound(0, value
, valueCount
-1));
3581 //Update bitrate value
3582 const int displayValue
= (valueCount
> 0) ? info
->valueAt(currentRCMode
, qBound(0, value
, valueCount
-1)) : INT_MAX
;
3583 switch(info
->valueType(currentRCMode
))
3585 case AbstractEncoderInfo::TYPE_BITRATE
:
3586 ui
->labelBitrate
->setText(QString("%1 kbps").arg(QString::number(displayValue
)));
3588 case AbstractEncoderInfo::TYPE_APPROX_BITRATE
:
3589 ui
->labelBitrate
->setText(QString("≈ %1 kbps").arg(QString::number(displayValue
)));
3591 case AbstractEncoderInfo::TYPE_QUALITY_LEVEL_INT
:
3592 ui
->labelBitrate
->setText(tr("Quality Level %1").arg(QString::number(displayValue
)));
3594 case AbstractEncoderInfo::TYPE_QUALITY_LEVEL_FLT
:
3595 ui
->labelBitrate
->setText(tr("Quality Level %1").arg(QString().sprintf("%.2f", double(displayValue
)/100.0)));
3597 case AbstractEncoderInfo::TYPE_COMPRESSION_LEVEL
:
3598 ui
->labelBitrate
->setText(tr("Compression %1").arg(QString::number(displayValue
)));
3600 case AbstractEncoderInfo::TYPE_UNCOMPRESSED
:
3601 ui
->labelBitrate
->setText(tr("Uncompressed"));
3604 MUTILS_THROW("Unknown display value type encountered!");
3610 * Event for compression tab occurred
3612 void MainWindow::compressionTabEventOccurred(QWidget
*sender
, QEvent
*event
)
3614 static const QUrl
helpUrl("http://lamexp.sourceforge.net/doc/FAQ.html#054010d9");
3616 if((sender
== ui
->labelCompressionHelp
) && (event
->type() == QEvent::MouseButtonPress
))
3618 QDesktopServices::openUrl(helpUrl
);
3620 else if((sender
== ui
->labelResetEncoders
) && (event
->type() == QEvent::MouseButtonPress
))
3622 PLAY_SOUND_OPTIONAL("blast", true);
3623 EncoderRegistry::resetAllEncoders(m_settings
);
3624 m_settings
->compressionEncoder(SettingsModel::MP3Encoder
);
3625 ui
->radioButtonEncoderMP3
->setChecked(true);
3626 QTimer::singleShot(0, this, SLOT(updateEncoder()));
3630 // =========================================================
3631 // Advanced option slots
3632 // =========================================================
3635 * Lame algorithm quality changed
3637 void MainWindow::updateLameAlgoQuality(int value
)
3644 text
= tr("Best Quality (Slow)");
3647 text
= tr("High Quality (Recommended)");
3650 text
= tr("Acceptable Quality (Fast)");
3653 text
= tr("Poor Quality (Very Fast)");
3659 m_settings
->lameAlgoQuality(value
);
3660 ui
->labelLameAlgoQuality
->setText(text
);
3663 bool warning
= (value
== 0), notice
= (value
== 3);
3664 ui
->labelLameAlgoQualityWarning
->setVisible(warning
);
3665 ui
->labelLameAlgoQualityWarningIcon
->setVisible(warning
);
3666 ui
->labelLameAlgoQualityNotice
->setVisible(notice
);
3667 ui
->labelLameAlgoQualityNoticeIcon
->setVisible(notice
);
3668 ui
->labelLameAlgoQualitySpacer
->setVisible(warning
|| notice
);
3672 * Bitrate management endabled/disabled
3674 void MainWindow::bitrateManagementEnabledChanged(bool checked
)
3676 m_settings
->bitrateManagementEnabled(checked
);
3680 * Minimum bitrate has changed
3682 void MainWindow::bitrateManagementMinChanged(int value
)
3684 if(value
> ui
->spinBoxBitrateManagementMax
->value())
3686 ui
->spinBoxBitrateManagementMin
->setValue(ui
->spinBoxBitrateManagementMax
->value());
3687 m_settings
->bitrateManagementMinRate(ui
->spinBoxBitrateManagementMax
->value());
3691 m_settings
->bitrateManagementMinRate(value
);
3696 * Maximum bitrate has changed
3698 void MainWindow::bitrateManagementMaxChanged(int value
)
3700 if(value
< ui
->spinBoxBitrateManagementMin
->value())
3702 ui
->spinBoxBitrateManagementMax
->setValue(ui
->spinBoxBitrateManagementMin
->value());
3703 m_settings
->bitrateManagementMaxRate(ui
->spinBoxBitrateManagementMin
->value());
3707 m_settings
->bitrateManagementMaxRate(value
);
3712 * Channel mode has changed
3714 void MainWindow::channelModeChanged(int value
)
3716 if(value
>= 0) m_settings
->lameChannelMode(value
);
3720 * Sampling rate has changed
3722 void MainWindow::samplingRateChanged(int value
)
3724 if(value
>= 0) m_settings
->samplingRate(value
);
3728 * Nero AAC 2-Pass mode changed
3730 void MainWindow::neroAAC2PassChanged(bool checked
)
3732 m_settings
->neroAACEnable2Pass(checked
);
3736 * Nero AAC profile mode changed
3738 void MainWindow::neroAACProfileChanged(int value
)
3740 if(value
>= 0) m_settings
->aacEncProfile(value
);
3744 * Aften audio coding mode changed
3746 void MainWindow::aftenCodingModeChanged(int value
)
3748 if(value
>= 0) m_settings
->aftenAudioCodingMode(value
);
3752 * Aften DRC mode changed
3754 void MainWindow::aftenDRCModeChanged(int value
)
3756 if(value
>= 0) m_settings
->aftenDynamicRangeCompression(value
);
3760 * Aften exponent search size changed
3762 void MainWindow::aftenSearchSizeChanged(int value
)
3764 if(value
>= 0) m_settings
->aftenExponentSearchSize(value
);
3768 * Aften fast bit allocation changed
3770 void MainWindow::aftenFastAllocationChanged(bool checked
)
3772 m_settings
->aftenFastBitAllocation(checked
);
3777 * Opus encoder settings changed
3779 void MainWindow::opusSettingsChanged(void)
3781 m_settings
->opusFramesize(ui
->comboBoxOpusFramesize
->currentIndex());
3782 m_settings
->opusComplexity(ui
->spinBoxOpusComplexity
->value());
3783 m_settings
->opusDisableResample(ui
->checkBoxOpusDisableResample
->isChecked());
3787 * Normalization filter enabled changed
3789 void MainWindow::normalizationEnabledChanged(bool checked
)
3791 m_settings
->normalizationFilterEnabled(checked
);
3792 normalizationDynamicChanged(ui
->checkBoxNormalizationFilterDynamic
->isChecked());
3796 * Dynamic normalization enabled changed
3798 void MainWindow::normalizationDynamicChanged(bool checked
)
3800 ui
->spinBoxNormalizationFilterSize
->setEnabled(ui
->checkBoxNormalizationFilterEnabled
->isChecked() && checked
);
3801 m_settings
->normalizationFilterDynamic(checked
);
3805 * Normalization max. volume changed
3807 void MainWindow::normalizationMaxVolumeChanged(double value
)
3809 m_settings
->normalizationFilterMaxVolume(static_cast<int>(value
* 100.0));
3813 * Normalization equalization mode changed
3815 void MainWindow::normalizationCoupledChanged(bool checked
)
3817 m_settings
->normalizationFilterCoupled(checked
);
3821 * Normalization filter size changed
3823 void MainWindow::normalizationFilterSizeChanged(int value
)
3825 m_settings
->normalizationFilterSize(value
);
3829 * Normalization filter size editing finished
3831 void MainWindow::normalizationFilterSizeFinished(void)
3833 const int value
= ui
->spinBoxNormalizationFilterSize
->value();
3834 if((value
% 2) != 1)
3836 bool rnd
= MUtils::parity(MUtils::next_rand32());
3837 ui
->spinBoxNormalizationFilterSize
->setValue(rnd
? value
+1 : value
-1);
3842 * Tone adjustment has changed (Bass)
3844 void MainWindow::toneAdjustBassChanged(double value
)
3846 m_settings
->toneAdjustBass(static_cast<int>(value
* 100.0));
3847 ui
->spinBoxToneAdjustBass
->setPrefix((value
> 0) ? "+" : QString());
3851 * Tone adjustment has changed (Treble)
3853 void MainWindow::toneAdjustTrebleChanged(double value
)
3855 m_settings
->toneAdjustTreble(static_cast<int>(value
* 100.0));
3856 ui
->spinBoxToneAdjustTreble
->setPrefix((value
> 0) ? "+" : QString());
3860 * Tone adjustment has been reset
3862 void MainWindow::toneAdjustTrebleReset(void)
3864 ui
->spinBoxToneAdjustBass
->setValue(m_settings
->toneAdjustBassDefault());
3865 ui
->spinBoxToneAdjustTreble
->setValue(m_settings
->toneAdjustTrebleDefault());
3866 toneAdjustBassChanged(ui
->spinBoxToneAdjustBass
->value());
3867 toneAdjustTrebleChanged(ui
->spinBoxToneAdjustTreble
->value());
3871 * Custom encoder parameters changed
3873 void MainWindow::customParamsChanged(void)
3875 ui
->lineEditCustomParamLAME
->setText(ui
->lineEditCustomParamLAME
->text().simplified());
3876 ui
->lineEditCustomParamOggEnc
->setText(ui
->lineEditCustomParamOggEnc
->text().simplified());
3877 ui
->lineEditCustomParamNeroAAC
->setText(ui
->lineEditCustomParamNeroAAC
->text().simplified());
3878 ui
->lineEditCustomParamFLAC
->setText(ui
->lineEditCustomParamFLAC
->text().simplified());
3879 ui
->lineEditCustomParamAften
->setText(ui
->lineEditCustomParamAften
->text().simplified());
3880 ui
->lineEditCustomParamOpus
->setText(ui
->lineEditCustomParamOpus
->text().simplified());
3882 bool customParamsUsed
= false;
3883 if(!ui
->lineEditCustomParamLAME
->text().isEmpty()) customParamsUsed
= true;
3884 if(!ui
->lineEditCustomParamOggEnc
->text().isEmpty()) customParamsUsed
= true;
3885 if(!ui
->lineEditCustomParamNeroAAC
->text().isEmpty()) customParamsUsed
= true;
3886 if(!ui
->lineEditCustomParamFLAC
->text().isEmpty()) customParamsUsed
= true;
3887 if(!ui
->lineEditCustomParamAften
->text().isEmpty()) customParamsUsed
= true;
3888 if(!ui
->lineEditCustomParamOpus
->text().isEmpty()) customParamsUsed
= true;
3890 ui
->labelCustomParamsIcon
->setVisible(customParamsUsed
);
3891 ui
->labelCustomParamsText
->setVisible(customParamsUsed
);
3892 ui
->labelCustomParamsSpacer
->setVisible(customParamsUsed
);
3894 EncoderRegistry::saveEncoderCustomParams(m_settings
, SettingsModel::MP3Encoder
, ui
->lineEditCustomParamLAME
->text());
3895 EncoderRegistry::saveEncoderCustomParams(m_settings
, SettingsModel::VorbisEncoder
, ui
->lineEditCustomParamOggEnc
->text());
3896 EncoderRegistry::saveEncoderCustomParams(m_settings
, SettingsModel::AACEncoder
, ui
->lineEditCustomParamNeroAAC
->text());
3897 EncoderRegistry::saveEncoderCustomParams(m_settings
, SettingsModel::FLACEncoder
, ui
->lineEditCustomParamFLAC
->text());
3898 EncoderRegistry::saveEncoderCustomParams(m_settings
, SettingsModel::AC3Encoder
, ui
->lineEditCustomParamAften
->text());
3899 EncoderRegistry::saveEncoderCustomParams(m_settings
, SettingsModel::OpusEncoder
, ui
->lineEditCustomParamOpus
->text());
3903 * One of the rename buttons has been clicked
3905 void MainWindow::renameButtonClicked(bool checked
)
3907 if(QPushButton
*const button
= dynamic_cast<QPushButton
*>(QObject::sender()))
3909 QWidget
*pages
[] = { ui
->pageRename_Rename
, ui
->pageRename_RegExp
, ui
->pageRename_FileEx
};
3910 QPushButton
*buttons
[] = { ui
->buttonRename_Rename
, ui
->buttonRename_RegExp
, ui
->buttonRename_FileEx
};
3911 for(int i
= 0; i
< 3; i
++)
3913 const bool match
= (button
== buttons
[i
]);
3914 buttons
[i
]->setChecked(match
);
3915 if(match
&& checked
) ui
->stackedWidget
->setCurrentWidget(pages
[i
]);
3921 * Rename output files enabled changed
3923 void MainWindow::renameOutputEnabledChanged(const bool &checked
)
3925 m_settings
->renameFiles_renameEnabled(checked
);
3929 * Rename output files patterm changed
3931 void MainWindow::renameOutputPatternChanged(void)
3933 QString temp
= ui
->lineEditRenamePattern
->text().simplified();
3934 ui
->lineEditRenamePattern
->setText(temp
.isEmpty() ? m_settings
->renameFiles_renamePatternDefault() : temp
);
3935 m_settings
->renameFiles_renamePattern(ui
->lineEditRenamePattern
->text());
3939 * Rename output files patterm changed
3941 void MainWindow::renameOutputPatternChanged(const QString
&text
, const bool &silent
)
3943 QString
pattern(text
.simplified());
3945 pattern
.replace("<BaseName>", "The_White_Stripes_-_Fell_In_Love_With_A_Girl", Qt::CaseInsensitive
);
3946 pattern
.replace("<TrackNo>", "04", Qt::CaseInsensitive
);
3947 pattern
.replace("<Title>", "Fell In Love With A Girl", Qt::CaseInsensitive
);
3948 pattern
.replace("<Artist>", "The White Stripes", Qt::CaseInsensitive
);
3949 pattern
.replace("<Album>", "White Blood Cells", Qt::CaseInsensitive
);
3950 pattern
.replace("<Year>", "2001", Qt::CaseInsensitive
);
3951 pattern
.replace("<Comment>", "Encoded by LameXP", Qt::CaseInsensitive
);
3953 const QString patternClean
= MUtils::clean_file_name(pattern
);
3955 if(pattern
.compare(patternClean
))
3957 if(ui
->lineEditRenamePattern
->palette().color(QPalette::Text
) != Qt::red
)
3959 if(!silent
) MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
);
3960 SET_TEXT_COLOR(ui
->lineEditRenamePattern
, Qt::red
);
3965 if(ui
->lineEditRenamePattern
->palette() != QPalette())
3967 if(!silent
) MUtils::Sound::beep(MUtils::Sound::BEEP_NFO
);
3968 ui
->lineEditRenamePattern
->setPalette(QPalette());
3972 ui
->labelRanameExample
->setText(patternClean
);
3976 * Regular expression enabled changed
3978 void MainWindow::renameRegExpEnabledChanged(const bool &checked
)
3980 m_settings
->renameFiles_regExpEnabled(checked
);
3984 * Regular expression value has changed
3986 void MainWindow::renameRegExpValueChanged(void)
3988 const QString search
= ui
->lineEditRenameRegExp_Search
->text() .trimmed();
3989 const QString replace
= ui
->lineEditRenameRegExp_Replace
->text().simplified();
3990 ui
->lineEditRenameRegExp_Search
->setText(search
.isEmpty() ? m_settings
->renameFiles_regExpSearchDefault() : search
);
3991 ui
->lineEditRenameRegExp_Replace
->setText(replace
.isEmpty() ? m_settings
->renameFiles_regExpReplaceDefault() : replace
);
3992 m_settings
->renameFiles_regExpSearch (ui
->lineEditRenameRegExp_Search
->text());
3993 m_settings
->renameFiles_regExpReplace(ui
->lineEditRenameRegExp_Replace
->text());
3997 * Regular expression search pattern has changed
3999 void MainWindow::renameRegExpSearchChanged(const QString
&text
, const bool &silent
)
4001 const QString
pattern(text
.trimmed());
4003 if((!pattern
.isEmpty()) && (!QRegExp(pattern
.trimmed()).isValid()))
4005 if(ui
->lineEditRenameRegExp_Search
->palette().color(QPalette::Text
) != Qt::red
)
4007 if(!silent
) MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
);
4008 SET_TEXT_COLOR(ui
->lineEditRenameRegExp_Search
, Qt::red
);
4013 if(ui
->lineEditRenameRegExp_Search
->palette() != QPalette())
4015 if(!silent
) MUtils::Sound::beep(MUtils::Sound::BEEP_NFO
);
4016 ui
->lineEditRenameRegExp_Search
->setPalette(QPalette());
4020 renameRegExpReplaceChanged(ui
->lineEditRenameRegExp_Replace
->text(), silent
);
4024 * Regular expression replacement string changed
4026 void MainWindow::renameRegExpReplaceChanged(const QString
&text
, const bool &silent
)
4028 QString
replacement(text
.simplified());
4029 const QString
search(ui
->lineEditRenameRegExp_Search
->text().trimmed());
4031 if(!search
.isEmpty())
4033 const QRegExp
regexp(search
);
4034 if(regexp
.isValid())
4036 const int count
= regexp
.captureCount();
4037 const QString blank
;
4038 for(int i
= 0; i
< count
; i
++)
4040 replacement
.replace(QString("\\%0").arg(QString::number(i
+1)), blank
);
4045 if(replacement
.compare(MUtils::clean_file_name(replacement
)))
4047 if(ui
->lineEditRenameRegExp_Replace
->palette().color(QPalette::Text
) != Qt::red
)
4049 if(!silent
) MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
);
4050 SET_TEXT_COLOR(ui
->lineEditRenameRegExp_Replace
, Qt::red
);
4055 if(ui
->lineEditRenameRegExp_Replace
->palette() != QPalette())
4057 if(!silent
) MUtils::Sound::beep(MUtils::Sound::BEEP_NFO
);
4058 ui
->lineEditRenameRegExp_Replace
->setPalette(QPalette());
4064 * Show list of rename macros
4066 void MainWindow::showRenameMacros(const QString
&text
)
4068 if(text
.compare("reset", Qt::CaseInsensitive
) == 0)
4070 ui
->lineEditRenamePattern
->setText(m_settings
->renameFiles_renamePatternDefault());
4074 if(text
.compare("regexp", Qt::CaseInsensitive
) == 0)
4076 MUtils::OS::shell_open(this, "http://www.regular-expressions.info/quickstart.html");
4080 const QString format
= QString("<tr><td><tt><%1></tt></td><td> </td><td>%2</td></tr>");
4082 QString message
= QString("<table>");
4083 message
+= QString(format
).arg("BaseName", tr("File name without extension"));
4084 message
+= QString(format
).arg("TrackNo", tr("Track number with leading zero"));
4085 message
+= QString(format
).arg("Title", tr("Track title"));
4086 message
+= QString(format
).arg("Artist", tr("Artist name"));
4087 message
+= QString(format
).arg("Album", tr("Album name"));
4088 message
+= QString(format
).arg("Year", tr("Year with (at least) four digits"));
4089 message
+= QString(format
).arg("Comment", tr("Comment"));
4090 message
+= "</table><br><br>";
4091 message
+= QString("%1<br>").arg(tr("Characters forbidden in file names:"));
4092 message
+= "<b><tt>\\ / : * ? < > |<br>";
4094 QMessageBox::information(this, tr("Rename Macros"), message
, tr("Discard"));
4097 void MainWindow::fileExtAddButtonClicked(void)
4099 if(FileExtsModel
*const model
= dynamic_cast<FileExtsModel
*>(ui
->tableViewFileExts
->model()))
4101 model
->addOverwrite(this);
4105 void MainWindow::fileExtRemoveButtonClicked(void)
4107 if(FileExtsModel
*const model
= dynamic_cast<FileExtsModel
*>(ui
->tableViewFileExts
->model()))
4109 const QModelIndex selected
= ui
->tableViewFileExts
->currentIndex();
4110 if(selected
.isValid())
4112 model
->removeOverwrite(selected
);
4116 MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
);
4121 void MainWindow::fileExtModelChanged(void)
4123 if(FileExtsModel
*const model
= dynamic_cast<FileExtsModel
*>(ui
->tableViewFileExts
->model()))
4125 m_settings
->renameFiles_fileExtension(model
->exportItems());
4129 void MainWindow::forceStereoDownmixEnabledChanged(bool checked
)
4131 m_settings
->forceStereoDownmix(checked
);
4135 * Maximum number of instances changed
4137 void MainWindow::updateMaximumInstances(int value
)
4139 ui
->labelMaxInstances
->setText(tr("%n Instance(s)", "", value
));
4140 m_settings
->maximumInstances(ui
->checkBoxAutoDetectInstances
->isChecked() ? NULL
: value
);
4144 * Auto-detect number of instances
4146 void MainWindow::autoDetectInstancesChanged(bool checked
)
4148 m_settings
->maximumInstances(checked
? NULL
: ui
->sliderMaxInstances
->value());
4152 * Browse for custom TEMP folder button clicked
4154 void MainWindow::browseCustomTempFolderButtonClicked(void)
4156 QString newTempFolder
;
4158 if(MUtils::GUI::themes_enabled())
4160 newTempFolder
= QFileDialog::getExistingDirectory(this, QString(), m_settings
->customTempPath());
4164 QFileDialog
dialog(this);
4165 dialog
.setFileMode(QFileDialog::DirectoryOnly
);
4166 dialog
.setDirectory(m_settings
->customTempPath());
4169 newTempFolder
= dialog
.selectedFiles().first();
4173 if(!newTempFolder
.isEmpty())
4175 QFile
writeTest(QString("%1/~%2.tmp").arg(newTempFolder
, MUtils::rand_str()));
4176 if(writeTest
.open(QIODevice::ReadWrite
))
4179 ui
->lineEditCustomTempFolder
->setText(QDir::toNativeSeparators(newTempFolder
));
4183 QMessageBox::warning(this, tr("Access Denied"), tr("Cannot write to the selected directory. Please choose another directory!"));
4189 * Custom TEMP folder changed
4191 void MainWindow::customTempFolderChanged(const QString
&text
)
4193 m_settings
->customTempPath(QDir::fromNativeSeparators(text
));
4197 * Use custom TEMP folder option changed
4199 void MainWindow::useCustomTempFolderChanged(bool checked
)
4201 m_settings
->customTempPathEnabled(!checked
);
4205 * Help for custom parameters was requested
4207 void MainWindow::customParamsHelpRequested(QWidget
*obj
, QEvent
*event
)
4209 if(event
->type() != QEvent::MouseButtonRelease
)
4214 if(QMouseEvent
*mouseEvent
= dynamic_cast<QMouseEvent
*>(event
))
4216 QPoint pos
= mouseEvent
->pos();
4217 if(!(pos
.x() <= obj
->width() && pos
.y() <= obj
->height() && pos
.x() >= 0 && pos
.y() >= 0 && mouseEvent
->button() != Qt::MidButton
))
4223 if(obj
== ui
->helpCustomParamLAME
) showCustomParamsHelpScreen("lame.exe", "--longhelp");
4224 else if(obj
== ui
->helpCustomParamOggEnc
) showCustomParamsHelpScreen("oggenc2.exe", "--help");
4225 else if(obj
== ui
->helpCustomParamNeroAAC
)
4227 switch(EncoderRegistry::getAacEncoder())
4229 case SettingsModel::AAC_ENCODER_QAAC
: showCustomParamsHelpScreen("qaac64.exe|qaac.exe", "--help"); break;
4230 case SettingsModel::AAC_ENCODER_FHG
: showCustomParamsHelpScreen("fhgaacenc.exe", "" ); break;
4231 case SettingsModel::AAC_ENCODER_FDK
: showCustomParamsHelpScreen("fdkaac.exe", "--help"); break;
4232 case SettingsModel::AAC_ENCODER_NERO
: showCustomParamsHelpScreen("neroAacEnc.exe", "-help" ); break;
4233 default: MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
); break;
4236 else if(obj
== ui
->helpCustomParamFLAC
) showCustomParamsHelpScreen("flac.exe", "--help");
4237 else if(obj
== ui
->helpCustomParamAften
) showCustomParamsHelpScreen("aften.exe", "-h" );
4238 else if(obj
== ui
->helpCustomParamOpus
) showCustomParamsHelpScreen("opusenc.exe", "--help");
4239 else MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
);
4243 * Show help for custom parameters
4245 void MainWindow::showCustomParamsHelpScreen(const QString
&toolName
, const QString
&command
)
4247 const QStringList toolNames
= toolName
.split('|', QString::SkipEmptyParts
);
4249 for(QStringList::ConstIterator iter
= toolNames
.constBegin(); iter
!= toolNames
.constEnd(); iter
++)
4251 if(lamexp_tools_check(*iter
))
4253 binary
= lamexp_tools_lookup(*iter
);
4258 if(binary
.isEmpty())
4260 MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
);
4261 qWarning("customParamsHelpRequested: Binary could not be found!");
4266 MUtils::init_process(process
, QFileInfo(binary
).absolutePath());
4268 process
.start(binary
, command
.isEmpty() ? QStringList() : QStringList() << command
);
4270 qApp
->setOverrideCursor(QCursor(Qt::WaitCursor
));
4272 if(process
.waitForStarted(15000))
4274 qApp
->processEvents();
4275 process
.waitForFinished(15000);
4278 if(process
.state() != QProcess::NotRunning
)
4281 process
.waitForFinished(-1);
4284 qApp
->restoreOverrideCursor();
4285 QStringList output
; bool spaceFlag
= true;
4287 while(process
.canReadLine())
4289 QString temp
= QString::fromUtf8(process
.readLine());
4290 TRIM_STRING_RIGHT(temp
);
4293 if(!spaceFlag
) { output
<< temp
; spaceFlag
= true; }
4297 output
<< temp
; spaceFlag
= false;
4301 if(output
.count() < 1)
4303 qWarning("Empty output, cannot show help screen!");
4304 MUtils::Sound::beep(MUtils::Sound::BEEP_ERR
);
4307 LogViewDialog
*dialog
= new LogViewDialog(this);
4308 TEMP_HIDE_DROPBOX( dialog
->exec(output
); );
4309 MUTILS_DELETE(dialog
);
4312 void MainWindow::overwriteModeChanged(int id
)
4314 if((id
== SettingsModel::Overwrite_Replaces
) && (m_settings
->overwriteMode() != SettingsModel::Overwrite_Replaces
))
4316 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)
4318 ui
->radioButtonOverwriteModeKeepBoth
->setChecked(m_settings
->overwriteMode() == SettingsModel::Overwrite_KeepBoth
);
4319 ui
->radioButtonOverwriteModeSkipFile
->setChecked(m_settings
->overwriteMode() == SettingsModel::Overwrite_SkipFile
);
4324 m_settings
->overwriteMode(id
);
4328 * Reset all advanced options to their defaults
4330 void MainWindow::resetAdvancedOptionsButtonClicked(void)
4332 PLAY_SOUND_OPTIONAL("blast", true);
4334 ui
->sliderLameAlgoQuality
->setValue(m_settings
->lameAlgoQualityDefault());
4335 ui
->spinBoxBitrateManagementMin
->setValue(m_settings
->bitrateManagementMinRateDefault());
4336 ui
->spinBoxBitrateManagementMax
->setValue(m_settings
->bitrateManagementMaxRateDefault());
4337 ui
->spinBoxNormalizationFilterPeak
->setValue(static_cast<double>(m_settings
->normalizationFilterMaxVolumeDefault()) / 100.0);
4338 ui
->spinBoxNormalizationFilterSize
->setValue(m_settings
->normalizationFilterSizeDefault());
4339 ui
->spinBoxToneAdjustBass
->setValue(static_cast<double>(m_settings
->toneAdjustBassDefault()) / 100.0);
4340 ui
->spinBoxToneAdjustTreble
->setValue(static_cast<double>(m_settings
->toneAdjustTrebleDefault()) / 100.0);
4341 ui
->spinBoxAftenSearchSize
->setValue(m_settings
->aftenExponentSearchSizeDefault());
4342 ui
->spinBoxOpusComplexity
->setValue(m_settings
->opusComplexityDefault());
4343 ui
->comboBoxMP3ChannelMode
->setCurrentIndex(m_settings
->lameChannelModeDefault());
4344 ui
->comboBoxSamplingRate
->setCurrentIndex(m_settings
->samplingRateDefault());
4345 ui
->comboBoxAACProfile
->setCurrentIndex(m_settings
->aacEncProfileDefault());
4346 ui
->comboBoxAftenCodingMode
->setCurrentIndex(m_settings
->aftenAudioCodingModeDefault());
4347 ui
->comboBoxAftenDRCMode
->setCurrentIndex(m_settings
->aftenDynamicRangeCompressionDefault());
4348 ui
->comboBoxOpusFramesize
->setCurrentIndex(m_settings
->opusFramesizeDefault());
4350 SET_CHECKBOX_STATE(ui
->checkBoxBitrateManagement
, m_settings
->bitrateManagementEnabledDefault());
4351 SET_CHECKBOX_STATE(ui
->checkBoxNeroAAC2PassMode
, m_settings
->neroAACEnable2PassDefault());
4352 SET_CHECKBOX_STATE(ui
->checkBoxNormalizationFilterEnabled
, m_settings
->normalizationFilterEnabledDefault());
4353 SET_CHECKBOX_STATE(ui
->checkBoxNormalizationFilterDynamic
, m_settings
->normalizationFilterDynamicDefault());
4354 SET_CHECKBOX_STATE(ui
->checkBoxNormalizationFilterCoupled
, m_settings
->normalizationFilterCoupledDefault());
4355 SET_CHECKBOX_STATE(ui
->checkBoxAutoDetectInstances
, (m_settings
->maximumInstancesDefault() < 1));
4356 SET_CHECKBOX_STATE(ui
->checkBoxUseSystemTempFolder
, (!m_settings
->customTempPathEnabledDefault()));
4357 SET_CHECKBOX_STATE(ui
->checkBoxAftenFastAllocation
, m_settings
->aftenFastBitAllocationDefault());
4358 SET_CHECKBOX_STATE(ui
->checkBoxRename_Rename
, m_settings
->renameFiles_renameEnabledDefault());
4359 SET_CHECKBOX_STATE(ui
->checkBoxRename_RegExp
, m_settings
->renameFiles_regExpEnabledDefault());
4360 SET_CHECKBOX_STATE(ui
->checkBoxForceStereoDownmix
, m_settings
->forceStereoDownmixDefault());
4361 SET_CHECKBOX_STATE(ui
->checkBoxOpusDisableResample
, m_settings
->opusDisableResampleDefault());
4363 ui
->lineEditCustomParamLAME
->setText(m_settings
->customParametersLAMEDefault());
4364 ui
->lineEditCustomParamOggEnc
->setText(m_settings
->customParametersOggEncDefault());
4365 ui
->lineEditCustomParamNeroAAC
->setText(m_settings
->customParametersAacEncDefault());
4366 ui
->lineEditCustomParamFLAC
->setText(m_settings
->customParametersFLACDefault());
4367 ui
->lineEditCustomParamOpus
->setText(m_settings
->customParametersOpusEncDefault());
4368 ui
->lineEditCustomTempFolder
->setText(QDir::toNativeSeparators(m_settings
->customTempPathDefault()));
4369 ui
->lineEditRenamePattern
->setText(m_settings
->renameFiles_renamePatternDefault());
4370 ui
->lineEditRenameRegExp_Search
->setText(m_settings
->renameFiles_regExpSearchDefault());
4371 ui
->lineEditRenameRegExp_Replace
->setText(m_settings
->renameFiles_regExpReplaceDefault());
4373 if(m_settings
->overwriteModeDefault() == SettingsModel::Overwrite_KeepBoth
) ui
->radioButtonOverwriteModeKeepBoth
->click();
4374 if(m_settings
->overwriteModeDefault() == SettingsModel::Overwrite_SkipFile
) ui
->radioButtonOverwriteModeSkipFile
->click();
4375 if(m_settings
->overwriteModeDefault() == SettingsModel::Overwrite_Replaces
) ui
->radioButtonOverwriteModeReplaces
->click();
4377 if(FileExtsModel
*const model
= dynamic_cast<FileExtsModel
*>(ui
->tableViewFileExts
->model()))
4379 model
->importItems(m_settings
->renameFiles_fileExtensionDefault());
4382 ui
->scrollArea
->verticalScrollBar()->setValue(0);
4383 ui
->buttonRename_Rename
->click();
4384 customParamsChanged();
4385 renameOutputPatternChanged();
4386 renameRegExpValueChanged();
4389 // =========================================================
4390 // Multi-instance handling slots
4391 // =========================================================
4394 * Other instance detected
4396 void MainWindow::notifyOtherInstance(void)
4398 if(!(BANNER_VISIBLE
))
4400 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
);
4406 * Add file from another instance
4408 void MainWindow::addFileDelayed(const QString
&filePath
, bool tryASAP
)
4410 if(tryASAP
&& !m_delayedFileTimer
->isActive())
4412 qDebug("Received file: %s", MUTILS_UTF8(filePath
));
4413 m_delayedFileList
->append(filePath
);
4414 QTimer::singleShot(0, this, SLOT(handleDelayedFiles()));
4417 m_delayedFileTimer
->stop();
4418 qDebug("Received file: %s", MUTILS_UTF8(filePath
));
4419 m_delayedFileList
->append(filePath
);
4420 m_delayedFileTimer
->start(5000);
4424 * Add files from another instance
4426 void MainWindow::addFilesDelayed(const QStringList
&filePaths
, bool tryASAP
)
4428 if(tryASAP
&& (!m_delayedFileTimer
->isActive()))
4430 qDebug("Received %d file(s).", filePaths
.count());
4431 m_delayedFileList
->append(filePaths
);
4432 QTimer::singleShot(0, this, SLOT(handleDelayedFiles()));
4436 m_delayedFileTimer
->stop();
4437 qDebug("Received %d file(s).", filePaths
.count());
4438 m_delayedFileList
->append(filePaths
);
4439 m_delayedFileTimer
->start(5000);
4444 * Add folder from another instance
4446 void MainWindow::addFolderDelayed(const QString
&folderPath
, bool recursive
)
4448 if(!(BANNER_VISIBLE
))
4450 addFolder(folderPath
, recursive
, true);
4454 // =========================================================
4456 // =========================================================
4459 * Restore the override cursor
4461 void MainWindow::restoreCursor(void)
4463 QApplication::restoreOverrideCursor();