2010-11-06 23:04:47 +01:00
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
2012-01-02 00:52:27 +01:00
// Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
2010-11-06 23:04:47 +01:00
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/licenses/gpl-2.0.txt
///////////////////////////////////////////////////////////////////////////////
# include "Dialog_MainWindow.h"
//LameXP includes
# include "Global.h"
# include "Resource.h"
# include "Dialog_WorkingBanner.h"
# include "Dialog_MetaInfo.h"
2010-11-11 19:37:16 +01:00
# include "Dialog_About.h"
2010-11-27 19:41:58 +01:00
# include "Dialog_Update.h"
2010-12-22 01:01:01 +01:00
# include "Dialog_DropBox.h"
2011-05-12 22:57:08 +02:00
# include "Dialog_CueImport.h"
2010-11-06 23:04:47 +01:00
# include "Thread_FileAnalyzer.h"
2010-11-08 19:29:36 +01:00
# include "Thread_MessageHandler.h"
2010-11-10 19:44:51 +01:00
# include "Model_MetaInfo.h"
2010-11-12 19:02:01 +01:00
# include "Model_Settings.h"
2010-11-19 21:11:54 +01:00
# include "Model_FileList.h"
2010-11-25 01:23:48 +01:00
# include "Model_FileSystem.h"
2010-12-05 23:11:03 +01:00
# include "WinSevenTaskbar.h"
2010-12-20 22:13:01 +01:00
# include "Registry_Decoder.h"
2011-01-27 22:10:51 +01:00
# include "ShellIntegration.h"
2010-11-06 23:04:47 +01:00
//Qt includes
# include <QMessageBox>
# include <QTimer>
# include <QDesktopWidget>
# include <QDate>
# include <QFileDialog>
# include <QInputDialog>
# include <QFileSystemModel>
# include <QDesktopServices>
# include <QUrl>
2010-11-08 00:24:54 +01:00
# include <QPlastiqueStyle>
# include <QCleanlooksStyle>
# include <QWindowsVistaStyle>
# include <QWindowsStyle>
2010-11-11 19:37:16 +01:00
# include <QSysInfo>
2010-11-12 23:31:04 +01:00
# include <QDragEnterEvent>
2012-05-06 23:58:18 +02:00
# include <QMimeData>
2010-11-15 21:07:58 +01:00
# include <QProcess>
2010-11-21 21:51:41 +01:00
# include <QUuid>
2010-11-25 20:41:59 +01:00
# include <QProcessEnvironment>
2010-12-12 13:44:11 +01:00
# include <QCryptographicHash>
2010-12-28 03:57:48 +01:00
# include <QTranslator>
# include <QResource>
2011-01-24 00:04:07 +01:00
# include <QScrollBar>
2010-11-06 23:04:47 +01:00
2011-04-11 21:57:16 +02:00
//System includes
# include <MMSystem.h>
2011-10-06 14:35:13 +02:00
# include <ShellAPI.h>
2010-11-06 23:04:47 +01:00
2010-11-10 19:44:51 +01:00
//Helper macros
2010-11-20 22:14:10 +01:00
# define ABORT_IF_BUSY if(m_banner->isVisible() || m_delayedFileTimer->isActive()) { MessageBeep(MB_ICONEXCLAMATION); return; }
2011-08-04 23:26:38 +02:00
# define SET_TEXT_COLOR(WIDGET,COLOR) { QPalette _palette = WIDGET->palette(); _palette.setColor(QPalette::WindowText, (COLOR)); _palette.setColor(QPalette::Text, (COLOR)); WIDGET->setPalette(_palette); }
2010-11-20 22:14:10 +01:00
# define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); }
2011-10-16 16:38:01 +02:00
# define LINK(URL) QString("<a href=\"%1\">%2< / a>").arg(URL).arg(QString(URL).replace("-", "−"))
# define FSLINK(PATH) QString("<a href=\"file: ///%1\">%2</a>").arg(PATH).arg(QString(PATH).replace("-", "−"))
2011-08-23 18:48:16 +02:00
# define TEMP_HIDE_DROPBOX(CMD) { bool __dropBoxVisible = m_dropBox->isVisible(); if(__dropBoxVisible) m_dropBox->hide(); {CMD}; if(__dropBoxVisible) m_dropBox->show(); }
# define USE_NATIVE_FILE_DIALOG (lamexp_themes_enabled() || ((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) < QSysInfo::WV_XP))
2012-03-29 19:08:33 +02:00
# define CENTER_CURRENT_OUTPUT_FOLDER_DELAYED QTimer::singleShot(125, this, SLOT(centerOutputFolderModel()))
2012-04-06 16:15:19 +02:00
# define SET_MODEL(VIEW, MODEL) { QItemSelectionModel *_tmp = (VIEW)->selectionModel(); (VIEW)->setModel(MODEL); LAMEXP_DELETE(_tmp); }
2010-11-11 19:37:16 +01:00
2010-11-06 23:04:47 +01:00
////////////////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////////////////
2010-11-19 21:11:54 +01:00
MainWindow : : MainWindow ( FileListModel * fileListModel , AudioFileModel * metaInfo , SettingsModel * settingsModel , QWidget * parent )
:
QMainWindow ( parent ) ,
m_fileListModel ( fileListModel ) ,
m_metaData ( metaInfo ) ,
m_settings ( settingsModel ) ,
2012-04-05 15:24:45 +02:00
m_fileSystemModel ( NULL ) ,
2011-05-21 13:07:17 +02:00
m_neroEncoderAvailable ( lamexp_check_tool ( " neroAacEnc.exe " ) & & lamexp_check_tool ( " neroAacDec.exe " ) & & lamexp_check_tool ( " neroAacTag.exe " ) ) ,
2011-08-19 15:27:58 +02:00
m_fhgEncoderAvailable ( lamexp_check_tool ( " fhgaacenc.exe " ) & & lamexp_check_tool ( " enc_fhgaac.dll " ) & & lamexp_check_tool ( " nsutil.dll " ) & & lamexp_check_tool ( " libmp4v2.dll " ) ) ,
2011-11-22 23:48:54 +01:00
m_qaacEncoderAvailable ( lamexp_check_tool ( " qaac.exe " ) & & lamexp_check_tool ( " libsoxrate.dll " ) ) ,
2010-11-20 22:14:10 +01:00
m_accepted ( false ) ,
2011-06-04 22:43:14 +02:00
m_firstTimeShown ( true ) ,
2012-04-05 15:24:45 +02:00
m_outputFolderViewCentering ( false ) ,
m_outputFolderViewInitCounter ( 0 )
2010-11-06 23:04:47 +01:00
{
//Init the dialog, from the .ui file
setupUi ( this ) ;
2010-11-15 04:42:06 +01:00
setWindowFlags ( windowFlags ( ) ^ Qt : : WindowMaximizeButtonHint ) ;
2010-11-06 23:04:47 +01:00
//Register meta types
qRegisterMetaType < AudioFileModel > ( " AudioFileModel " ) ;
//Enabled main buttons
connect ( buttonAbout , SIGNAL ( clicked ( ) ) , this , SLOT ( aboutButtonClicked ( ) ) ) ;
connect ( buttonStart , SIGNAL ( clicked ( ) ) , this , SLOT ( encodeButtonClicked ( ) ) ) ;
2010-11-19 21:11:54 +01:00
connect ( buttonQuit , SIGNAL ( clicked ( ) ) , this , SLOT ( closeButtonClicked ( ) ) ) ;
2010-11-06 23:04:47 +01:00
//Setup tab widget
tabWidget - > setCurrentIndex ( 0 ) ;
connect ( tabWidget , SIGNAL ( currentChanged ( int ) ) , this , SLOT ( tabPageChanged ( int ) ) ) ;
//Setup "Source" tab
sourceFileView - > setModel ( m_fileListModel ) ;
sourceFileView - > verticalHeader ( ) - > setResizeMode ( QHeaderView : : ResizeToContents ) ;
sourceFileView - > horizontalHeader ( ) - > setResizeMode ( QHeaderView : : ResizeToContents ) ;
2010-11-25 20:41:59 +01:00
sourceFileView - > setContextMenuPolicy ( Qt : : CustomContextMenu ) ;
2011-08-22 00:03:36 +02:00
sourceFileView - > viewport ( ) - > installEventFilter ( this ) ;
2010-11-20 02:14:22 +01:00
m_dropNoteLabel = new QLabel ( sourceFileView ) ;
m_dropNoteLabel - > setAlignment ( Qt : : AlignHCenter | Qt : : AlignVCenter ) ;
2010-11-20 22:14:10 +01:00
SET_FONT_BOLD ( m_dropNoteLabel , true ) ;
SET_TEXT_COLOR ( m_dropNoteLabel , Qt : : darkGray ) ;
2010-11-25 20:41:59 +01:00
m_sourceFilesContextMenu = new QMenu ( ) ;
2010-12-28 21:26:16 +01:00
m_showDetailsContextAction = m_sourceFilesContextMenu - > addAction ( QIcon ( " :/icons/zoom.png " ) , " N/A " ) ;
m_previewContextAction = m_sourceFilesContextMenu - > addAction ( QIcon ( " :/icons/sound.png " ) , " N/A " ) ;
m_findFileContextAction = m_sourceFilesContextMenu - > addAction ( QIcon ( " :/icons/folder_go.png " ) , " N/A " ) ;
2012-01-04 03:23:07 +01:00
m_sourceFilesContextMenu - > addSeparator ( ) ;
m_exportCsvContextAction = m_sourceFilesContextMenu - > addAction ( QIcon ( " :/icons/table_save.png " ) , " N/A " ) ;
2012-01-04 21:10:33 +01:00
m_importCsvContextAction = m_sourceFilesContextMenu - > addAction ( QIcon ( " :/icons/folder_table.png " ) , " N/A " ) ;
2010-12-28 21:26:16 +01:00
SET_FONT_BOLD ( m_showDetailsContextAction , true ) ;
2010-11-06 23:04:47 +01:00
connect ( buttonAddFiles , SIGNAL ( clicked ( ) ) , this , SLOT ( addFilesButtonClicked ( ) ) ) ;
connect ( buttonRemoveFile , SIGNAL ( clicked ( ) ) , this , SLOT ( removeFileButtonClicked ( ) ) ) ;
connect ( buttonClearFiles , SIGNAL ( clicked ( ) ) , this , SLOT ( clearFilesButtonClicked ( ) ) ) ;
connect ( buttonFileUp , SIGNAL ( clicked ( ) ) , this , SLOT ( fileUpButtonClicked ( ) ) ) ;
connect ( buttonFileDown , SIGNAL ( clicked ( ) ) , this , SLOT ( fileDownButtonClicked ( ) ) ) ;
2010-11-10 19:44:51 +01:00
connect ( buttonShowDetails , SIGNAL ( clicked ( ) ) , this , SLOT ( showDetailsButtonClicked ( ) ) ) ;
2010-11-21 21:51:41 +01:00
connect ( m_fileListModel , SIGNAL ( rowsInserted ( QModelIndex , int , int ) ) , this , SLOT ( sourceModelChanged ( ) ) ) ;
connect ( m_fileListModel , SIGNAL ( rowsRemoved ( QModelIndex , int , int ) ) , this , SLOT ( sourceModelChanged ( ) ) ) ;
connect ( m_fileListModel , SIGNAL ( modelReset ( ) ) , this , SLOT ( sourceModelChanged ( ) ) ) ;
2010-11-25 20:41:59 +01:00
connect ( sourceFileView , SIGNAL ( customContextMenuRequested ( QPoint ) ) , this , SLOT ( sourceFilesContextMenu ( QPoint ) ) ) ;
2011-08-23 17:01:11 +02:00
connect ( sourceFileView - > verticalScrollBar ( ) , SIGNAL ( sliderMoved ( int ) ) , this , SLOT ( sourceFilesScrollbarMoved ( int ) ) ) ;
connect ( sourceFileView - > verticalScrollBar ( ) , SIGNAL ( valueChanged ( int ) ) , this , SLOT ( sourceFilesScrollbarMoved ( int ) ) ) ;
2010-12-28 21:26:16 +01:00
connect ( m_showDetailsContextAction , SIGNAL ( triggered ( bool ) ) , this , SLOT ( showDetailsButtonClicked ( ) ) ) ;
connect ( m_previewContextAction , SIGNAL ( triggered ( bool ) ) , this , SLOT ( previewContextActionTriggered ( ) ) ) ;
connect ( m_findFileContextAction , SIGNAL ( triggered ( bool ) ) , this , SLOT ( findFileContextActionTriggered ( ) ) ) ;
2012-01-04 03:23:07 +01:00
connect ( m_exportCsvContextAction , SIGNAL ( triggered ( bool ) ) , this , SLOT ( exportCsvContextActionTriggered ( ) ) ) ;
2012-01-04 21:10:33 +01:00
connect ( m_importCsvContextAction , SIGNAL ( triggered ( bool ) ) , this , SLOT ( importCsvContextActionTriggered ( ) ) ) ;
2010-11-25 20:41:59 +01:00
2010-11-06 23:04:47 +01:00
//Setup "Output" tab
outputFolderView - > setHeaderHidden ( true ) ;
2011-06-04 22:43:14 +02:00
outputFolderView - > setAnimated ( false ) ;
2010-11-25 20:41:59 +01:00
outputFolderView - > setMouseTracking ( false ) ;
2010-12-05 23:11:03 +01:00
outputFolderView - > setContextMenuPolicy ( Qt : : CustomContextMenu ) ;
2012-03-30 03:35:43 +02:00
outputFolderView - > setVerticalScrollBarPolicy ( Qt : : ScrollBarAlwaysOn ) ;
2011-06-12 03:18:37 +02:00
outputFolderView - > installEventFilter ( this ) ;
2012-03-26 22:02:11 +02:00
outputFoldersEditorLabel - > installEventFilter ( this ) ;
2011-08-08 20:26:30 +02:00
outputFoldersFovoritesLabel - > installEventFilter ( this ) ;
2010-11-21 21:51:41 +01:00
while ( saveToSourceFolderCheckBox - > isChecked ( ) ! = m_settings - > outputToSourceDir ( ) ) saveToSourceFolderCheckBox - > click ( ) ;
2010-12-14 01:25:13 +01:00
prependRelativePathCheckBox - > setChecked ( m_settings - > prependRelativeSourcePath ( ) ) ;
2010-11-06 23:04:47 +01:00
connect ( outputFolderView , SIGNAL ( clicked ( QModelIndex ) ) , this , SLOT ( outputFolderViewClicked ( QModelIndex ) ) ) ;
2010-11-25 20:41:59 +01:00
connect ( outputFolderView , SIGNAL ( activated ( QModelIndex ) ) , this , SLOT ( outputFolderViewClicked ( QModelIndex ) ) ) ;
2010-12-27 18:31:21 +01:00
connect ( outputFolderView , SIGNAL ( pressed ( QModelIndex ) ) , this , SLOT ( outputFolderViewClicked ( QModelIndex ) ) ) ;
connect ( outputFolderView , SIGNAL ( entered ( QModelIndex ) ) , this , SLOT ( outputFolderViewMoved ( QModelIndex ) ) ) ;
2012-03-29 01:32:47 +02:00
connect ( outputFolderView , SIGNAL ( expanded ( QModelIndex ) ) , this , SLOT ( outputFolderItemExpanded ( QModelIndex ) ) ) ;
2010-11-06 23:04:47 +01:00
connect ( buttonMakeFolder , SIGNAL ( clicked ( ) ) , this , SLOT ( makeFolderButtonClicked ( ) ) ) ;
connect ( buttonGotoHome , SIGNAL ( clicked ( ) ) , SLOT ( gotoHomeFolderButtonClicked ( ) ) ) ;
connect ( buttonGotoDesktop , SIGNAL ( clicked ( ) ) , this , SLOT ( gotoDesktopButtonClicked ( ) ) ) ;
connect ( buttonGotoMusic , SIGNAL ( clicked ( ) ) , this , SLOT ( gotoMusicFolderButtonClicked ( ) ) ) ;
2010-11-21 21:51:41 +01:00
connect ( saveToSourceFolderCheckBox , SIGNAL ( clicked ( ) ) , this , SLOT ( saveToSourceFolderChanged ( ) ) ) ;
2010-12-14 01:25:13 +01:00
connect ( prependRelativePathCheckBox , SIGNAL ( clicked ( ) ) , this , SLOT ( prependRelativePathChanged ( ) ) ) ;
2012-03-26 22:02:11 +02:00
connect ( outputFolderEdit , SIGNAL ( editingFinished ( ) ) , this , SLOT ( outputFolderEditFinished ( ) ) ) ;
2012-04-05 15:24:45 +02:00
if ( m_outputFolderContextMenu = new QMenu ( ) )
{
m_showFolderContextAction = m_outputFolderContextMenu - > addAction ( QIcon ( " :/icons/zoom.png " ) , " N/A " ) ;
m_refreshFolderContextAction = m_outputFolderContextMenu - > addAction ( QIcon ( " :/icons/arrow_refresh.png " ) , " N/A " ) ;
m_outputFolderContextMenu - > setDefaultAction ( m_showFolderContextAction ) ;
connect ( outputFolderView , SIGNAL ( customContextMenuRequested ( QPoint ) ) , this , SLOT ( outputFolderContextMenu ( QPoint ) ) ) ;
connect ( m_showFolderContextAction , SIGNAL ( triggered ( bool ) ) , this , SLOT ( showFolderContextActionTriggered ( ) ) ) ;
connect ( m_refreshFolderContextAction , SIGNAL ( triggered ( bool ) ) , this , SLOT ( refreshFolderContextActionTriggered ( ) ) ) ;
}
if ( m_outputFolderFavoritesMenu = new QMenu ( ) )
{
m_addFavoriteFolderAction = m_outputFolderFavoritesMenu - > addAction ( QIcon ( " :/icons/add.png " ) , " N/A " ) ;
m_outputFolderFavoritesMenu - > insertSeparator ( m_addFavoriteFolderAction ) ;
connect ( m_addFavoriteFolderAction , SIGNAL ( triggered ( bool ) ) , this , SLOT ( addFavoriteFolderActionTriggered ( ) ) ) ;
}
2012-03-26 22:02:11 +02:00
outputFolderEdit - > setVisible ( false ) ;
2010-12-28 03:57:48 +01:00
outputFolderLabel - > installEventFilter ( this ) ;
2012-04-05 15:24:45 +02:00
if ( m_outputFolderNoteBox = new QLabel ( outputFolderView ) )
{
m_outputFolderNoteBox - > setAutoFillBackground ( true ) ;
m_outputFolderNoteBox - > setAlignment ( Qt : : AlignHCenter | Qt : : AlignVCenter ) ;
m_outputFolderNoteBox - > setFrameShape ( QFrame : : StyledPanel ) ;
SET_FONT_BOLD ( m_outputFolderNoteBox , true ) ;
m_outputFolderNoteBox - > hide ( ) ;
}
2012-04-05 16:24:33 +02:00
outputFolderViewClicked ( QModelIndex ( ) ) ;
2011-08-08 20:26:30 +02:00
refreshFavorites ( ) ;
2010-11-06 23:04:47 +01:00
2010-11-10 19:44:51 +01:00
//Setup "Meta Data" tab
m_metaInfoModel = new MetaInfoModel ( m_metaData , 6 ) ;
m_metaInfoModel - > clearData ( ) ;
2011-02-10 16:08:03 +01:00
m_metaInfoModel - > setData ( m_metaInfoModel - > index ( 4 , 1 ) , m_settings - > metaInfoPosition ( ) ) ;
2010-11-10 19:44:51 +01:00
metaDataView - > setModel ( m_metaInfoModel ) ;
metaDataView - > verticalHeader ( ) - > setResizeMode ( QHeaderView : : ResizeToContents ) ;
metaDataView - > verticalHeader ( ) - > hide ( ) ;
metaDataView - > horizontalHeader ( ) - > setResizeMode ( QHeaderView : : ResizeToContents ) ;
2010-11-20 19:16:04 +01:00
while ( writeMetaDataCheckBox - > isChecked ( ) ! = m_settings - > writeMetaTags ( ) ) writeMetaDataCheckBox - > click ( ) ;
2010-11-21 21:51:41 +01:00
generatePlaylistCheckBox - > setChecked ( m_settings - > createPlaylist ( ) ) ;
2010-11-10 19:44:51 +01:00
connect ( buttonEditMeta , SIGNAL ( clicked ( ) ) , this , SLOT ( editMetaButtonClicked ( ) ) ) ;
connect ( buttonClearMeta , SIGNAL ( clicked ( ) ) , this , SLOT ( clearMetaButtonClicked ( ) ) ) ;
2010-11-20 19:16:04 +01:00
connect ( writeMetaDataCheckBox , SIGNAL ( clicked ( ) ) , this , SLOT ( metaTagsEnabledChanged ( ) ) ) ;
2010-11-20 22:14:10 +01:00
connect ( generatePlaylistCheckBox , SIGNAL ( clicked ( ) ) , this , SLOT ( playlistEnabledChanged ( ) ) ) ;
2010-11-11 22:58:02 +01:00
//Setup "Compression" tab
2010-11-15 04:42:06 +01:00
m_encoderButtonGroup = new QButtonGroup ( this ) ;
m_encoderButtonGroup - > addButton ( radioButtonEncoderMP3 , SettingsModel : : MP3Encoder ) ;
m_encoderButtonGroup - > addButton ( radioButtonEncoderVorbis , SettingsModel : : VorbisEncoder ) ;
m_encoderButtonGroup - > addButton ( radioButtonEncoderAAC , SettingsModel : : AACEncoder ) ;
2011-05-04 01:15:05 +02:00
m_encoderButtonGroup - > addButton ( radioButtonEncoderAC3 , SettingsModel : : AC3Encoder ) ;
2010-11-15 04:42:06 +01:00
m_encoderButtonGroup - > addButton ( radioButtonEncoderFLAC , SettingsModel : : FLACEncoder ) ;
2011-12-22 21:53:25 +01:00
m_encoderButtonGroup - > addButton ( radioButtonEncoderDCA , SettingsModel : : DCAEncoder ) ;
2010-11-15 04:42:06 +01:00
m_encoderButtonGroup - > addButton ( radioButtonEncoderPCM , SettingsModel : : PCMEncoder ) ;
m_modeButtonGroup = new QButtonGroup ( this ) ;
m_modeButtonGroup - > addButton ( radioButtonModeQuality , SettingsModel : : VBRMode ) ;
m_modeButtonGroup - > addButton ( radioButtonModeAverageBitrate , SettingsModel : : ABRMode ) ;
m_modeButtonGroup - > addButton ( radioButtonConstBitrate , SettingsModel : : CBRMode ) ;
2011-11-21 01:22:41 +01:00
radioButtonEncoderAAC - > setEnabled ( m_neroEncoderAvailable | | m_fhgEncoderAvailable | | m_qaacEncoderAvailable ) ;
2010-11-15 04:42:06 +01:00
radioButtonEncoderMP3 - > setChecked ( m_settings - > compressionEncoder ( ) = = SettingsModel : : MP3Encoder ) ;
radioButtonEncoderVorbis - > setChecked ( m_settings - > compressionEncoder ( ) = = SettingsModel : : VorbisEncoder ) ;
2011-11-21 01:22:41 +01:00
radioButtonEncoderAAC - > setChecked ( ( m_settings - > compressionEncoder ( ) = = SettingsModel : : AACEncoder ) & & ( m_neroEncoderAvailable | | m_fhgEncoderAvailable | | m_qaacEncoderAvailable ) ) ;
2011-05-04 01:15:05 +02:00
radioButtonEncoderAC3 - > setChecked ( m_settings - > compressionEncoder ( ) = = SettingsModel : : AC3Encoder ) ;
2010-11-15 04:42:06 +01:00
radioButtonEncoderFLAC - > setChecked ( m_settings - > compressionEncoder ( ) = = SettingsModel : : FLACEncoder ) ;
2011-12-22 21:53:25 +01:00
radioButtonEncoderDCA - > setChecked ( m_settings - > compressionEncoder ( ) = = SettingsModel : : DCAEncoder ) ;
2010-11-15 04:42:06 +01:00
radioButtonEncoderPCM - > setChecked ( m_settings - > compressionEncoder ( ) = = SettingsModel : : PCMEncoder ) ;
radioButtonModeQuality - > setChecked ( m_settings - > compressionRCMode ( ) = = SettingsModel : : VBRMode ) ;
radioButtonModeAverageBitrate - > setChecked ( m_settings - > compressionRCMode ( ) = = SettingsModel : : ABRMode ) ;
radioButtonConstBitrate - > setChecked ( m_settings - > compressionRCMode ( ) = = SettingsModel : : CBRMode ) ;
sliderBitrate - > setValue ( m_settings - > compressionBitrate ( ) ) ;
connect ( m_encoderButtonGroup , SIGNAL ( buttonClicked ( int ) ) , this , SLOT ( updateEncoder ( int ) ) ) ;
connect ( m_modeButtonGroup , SIGNAL ( buttonClicked ( int ) ) , this , SLOT ( updateRCMode ( int ) ) ) ;
2010-11-11 22:58:02 +01:00
connect ( sliderBitrate , SIGNAL ( valueChanged ( int ) ) , this , SLOT ( updateBitrate ( int ) ) ) ;
2010-11-15 04:42:06 +01:00
updateEncoder ( m_encoderButtonGroup - > checkedId ( ) ) ;
2010-11-11 22:58:02 +01:00
2011-01-21 19:14:11 +01:00
//Setup "Advanced Options" tab
sliderLameAlgoQuality - > setValue ( m_settings - > lameAlgoQuality ( ) ) ;
2011-02-25 00:22:18 +01:00
if ( m_settings - > maximumInstances ( ) > 0 ) sliderMaxInstances - > setValue ( m_settings - > maximumInstances ( ) ) ;
2011-01-21 21:41:50 +01:00
spinBoxBitrateManagementMin - > setValue ( m_settings - > bitrateManagementMinRate ( ) ) ;
spinBoxBitrateManagementMax - > setValue ( m_settings - > bitrateManagementMaxRate ( ) ) ;
2011-01-24 01:13:08 +01:00
spinBoxNormalizationFilter - > setValue ( static_cast < double > ( m_settings - > normalizationFilterMaxVolume ( ) ) / 100.0 ) ;
2011-01-26 20:16:46 +01:00
spinBoxToneAdjustBass - > setValue ( static_cast < double > ( m_settings - > toneAdjustBass ( ) ) / 100.0 ) ;
spinBoxToneAdjustTreble - > setValue ( static_cast < double > ( m_settings - > toneAdjustTreble ( ) ) / 100.0 ) ;
2011-05-07 00:50:18 +02:00
spinBoxAftenSearchSize - > setValue ( m_settings - > aftenExponentSearchSize ( ) ) ;
2011-01-22 22:19:20 +01:00
comboBoxMP3ChannelMode - > setCurrentIndex ( m_settings - > lameChannelMode ( ) ) ;
comboBoxSamplingRate - > setCurrentIndex ( m_settings - > samplingRate ( ) ) ;
2011-08-21 14:43:18 +02:00
comboBoxAACProfile - > setCurrentIndex ( m_settings - > aacEncProfile ( ) ) ;
2011-05-07 00:50:18 +02:00
comboBoxAftenCodingMode - > setCurrentIndex ( m_settings - > aftenAudioCodingMode ( ) ) ;
comboBoxAftenDRCMode - > setCurrentIndex ( m_settings - > aftenDynamicRangeCompression ( ) ) ;
2011-10-06 23:55:42 +02:00
comboBoxNormalizationMode - > setCurrentIndex ( m_settings - > normalizationFilterEqualizationMode ( ) ) ;
2011-01-21 21:41:50 +01:00
while ( checkBoxBitrateManagement - > isChecked ( ) ! = m_settings - > bitrateManagementEnabled ( ) ) checkBoxBitrateManagement - > click ( ) ;
2011-01-22 22:19:20 +01:00
while ( checkBoxNeroAAC2PassMode - > isChecked ( ) ! = m_settings - > neroAACEnable2Pass ( ) ) checkBoxNeroAAC2PassMode - > click ( ) ;
2011-05-07 00:50:18 +02:00
while ( checkBoxAftenFastAllocation - > isChecked ( ) ! = m_settings - > aftenFastBitAllocation ( ) ) checkBoxAftenFastAllocation - > click ( ) ;
2011-01-24 01:13:08 +01:00
while ( checkBoxNormalizationFilter - > isChecked ( ) ! = m_settings - > normalizationFilterEnabled ( ) ) checkBoxNormalizationFilter - > click ( ) ;
2011-02-25 00:22:18 +01:00
while ( checkBoxAutoDetectInstances - > isChecked ( ) ! = ( m_settings - > maximumInstances ( ) < 1 ) ) checkBoxAutoDetectInstances - > click ( ) ;
2011-02-25 22:03:39 +01:00
while ( checkBoxUseSystemTempFolder - > isChecked ( ) = = m_settings - > customTempPathEnabled ( ) ) checkBoxUseSystemTempFolder - > click ( ) ;
2011-08-05 21:52:43 +02:00
while ( checkBoxRenameOutput - > isChecked ( ) ! = m_settings - > renameOutputFilesEnabled ( ) ) checkBoxRenameOutput - > click ( ) ;
while ( checkBoxForceStereoDownmix - > isChecked ( ) ! = m_settings - > forceStereoDownmix ( ) ) checkBoxForceStereoDownmix - > click ( ) ;
2011-11-21 01:22:41 +01:00
checkBoxNeroAAC2PassMode - > setEnabled ( ! ( m_fhgEncoderAvailable | | m_qaacEncoderAvailable ) ) ;
2011-02-09 23:36:17 +01:00
lineEditCustomParamLAME - > setText ( m_settings - > customParametersLAME ( ) ) ;
lineEditCustomParamOggEnc - > setText ( m_settings - > customParametersOggEnc ( ) ) ;
2011-08-21 14:43:18 +02:00
lineEditCustomParamNeroAAC - > setText ( m_settings - > customParametersAacEnc ( ) ) ;
2011-02-09 23:36:17 +01:00
lineEditCustomParamFLAC - > setText ( m_settings - > customParametersFLAC ( ) ) ;
2011-05-05 12:27:25 +02:00
lineEditCustomParamAften - > setText ( m_settings - > customParametersAften ( ) ) ;
2011-02-25 22:03:39 +01:00
lineEditCustomTempFolder - > setText ( QDir : : toNativeSeparators ( m_settings - > customTempPath ( ) ) ) ;
2011-08-04 23:26:38 +02:00
lineEditRenamePattern - > setText ( m_settings - > renameOutputFilesPattern ( ) ) ;
2011-01-21 19:14:11 +01:00
connect ( sliderLameAlgoQuality , SIGNAL ( valueChanged ( int ) ) , this , SLOT ( updateLameAlgoQuality ( int ) ) ) ;
2011-01-21 21:41:50 +01:00
connect ( checkBoxBitrateManagement , SIGNAL ( clicked ( bool ) ) , this , SLOT ( bitrateManagementEnabledChanged ( bool ) ) ) ;
connect ( spinBoxBitrateManagementMin , SIGNAL ( valueChanged ( int ) ) , this , SLOT ( bitrateManagementMinChanged ( int ) ) ) ;
connect ( spinBoxBitrateManagementMax , SIGNAL ( valueChanged ( int ) ) , this , SLOT ( bitrateManagementMaxChanged ( int ) ) ) ;
2011-01-22 22:19:20 +01:00
connect ( comboBoxMP3ChannelMode , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( channelModeChanged ( int ) ) ) ;
connect ( comboBoxSamplingRate , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( samplingRateChanged ( int ) ) ) ;
connect ( checkBoxNeroAAC2PassMode , SIGNAL ( clicked ( bool ) ) , this , SLOT ( neroAAC2PassChanged ( bool ) ) ) ;
2011-08-21 14:43:18 +02:00
connect ( comboBoxAACProfile , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( neroAACProfileChanged ( int ) ) ) ;
2011-01-24 01:13:08 +01:00
connect ( checkBoxNormalizationFilter , SIGNAL ( clicked ( bool ) ) , this , SLOT ( normalizationEnabledChanged ( bool ) ) ) ;
2011-05-07 00:50:18 +02:00
connect ( comboBoxAftenCodingMode , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( aftenCodingModeChanged ( int ) ) ) ;
connect ( comboBoxAftenDRCMode , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( aftenDRCModeChanged ( int ) ) ) ;
connect ( spinBoxAftenSearchSize , SIGNAL ( valueChanged ( int ) ) , this , SLOT ( aftenSearchSizeChanged ( int ) ) ) ;
connect ( checkBoxAftenFastAllocation , SIGNAL ( clicked ( bool ) ) , this , SLOT ( aftenFastAllocationChanged ( bool ) ) ) ;
2011-01-24 01:13:08 +01:00
connect ( spinBoxNormalizationFilter , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( normalizationMaxVolumeChanged ( double ) ) ) ;
2011-10-06 23:55:42 +02:00
connect ( comboBoxNormalizationMode , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( normalizationModeChanged ( int ) ) ) ;
2011-01-26 20:16:46 +01:00
connect ( spinBoxToneAdjustBass , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( toneAdjustBassChanged ( double ) ) ) ;
connect ( spinBoxToneAdjustTreble , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( toneAdjustTrebleChanged ( double ) ) ) ;
connect ( buttonToneAdjustReset , SIGNAL ( clicked ( ) ) , this , SLOT ( toneAdjustTrebleReset ( ) ) ) ;
2011-02-09 23:36:17 +01:00
connect ( lineEditCustomParamLAME , SIGNAL ( editingFinished ( ) ) , this , SLOT ( customParamsChanged ( ) ) ) ;
connect ( lineEditCustomParamOggEnc , SIGNAL ( editingFinished ( ) ) , this , SLOT ( customParamsChanged ( ) ) ) ;
connect ( lineEditCustomParamNeroAAC , SIGNAL ( editingFinished ( ) ) , this , SLOT ( customParamsChanged ( ) ) ) ;
connect ( lineEditCustomParamFLAC , SIGNAL ( editingFinished ( ) ) , this , SLOT ( customParamsChanged ( ) ) ) ;
2011-05-05 12:27:25 +02:00
connect ( lineEditCustomParamAften , SIGNAL ( editingFinished ( ) ) , this , SLOT ( customParamsChanged ( ) ) ) ;
2011-02-25 00:22:18 +01:00
connect ( sliderMaxInstances , SIGNAL ( valueChanged ( int ) ) , this , SLOT ( updateMaximumInstances ( int ) ) ) ;
connect ( checkBoxAutoDetectInstances , SIGNAL ( clicked ( bool ) ) , this , SLOT ( autoDetectInstancesChanged ( bool ) ) ) ;
2011-02-25 22:03:39 +01:00
connect ( buttonBrowseCustomTempFolder , SIGNAL ( clicked ( ) ) , this , SLOT ( browseCustomTempFolderButtonClicked ( ) ) ) ;
connect ( lineEditCustomTempFolder , SIGNAL ( textChanged ( QString ) ) , this , SLOT ( customTempFolderChanged ( QString ) ) ) ;
connect ( checkBoxUseSystemTempFolder , SIGNAL ( clicked ( bool ) ) , this , SLOT ( useCustomTempFolderChanged ( bool ) ) ) ;
2011-01-23 23:03:44 +01:00
connect ( buttonResetAdvancedOptions , SIGNAL ( clicked ( ) ) , this , SLOT ( resetAdvancedOptionsButtonClicked ( ) ) ) ;
2011-08-04 23:26:38 +02:00
connect ( checkBoxRenameOutput , SIGNAL ( clicked ( bool ) ) , this , SLOT ( renameOutputEnabledChanged ( bool ) ) ) ;
connect ( lineEditRenamePattern , SIGNAL ( editingFinished ( ) ) , this , SLOT ( renameOutputPatternChanged ( ) ) ) ;
connect ( lineEditRenamePattern , SIGNAL ( textChanged ( QString ) ) , this , SLOT ( renameOutputPatternChanged ( QString ) ) ) ;
2011-08-05 02:33:32 +02:00
connect ( labelShowRenameMacros , SIGNAL ( linkActivated ( QString ) ) , this , SLOT ( showRenameMacros ( QString ) ) ) ;
2011-08-05 21:52:43 +02:00
connect ( checkBoxForceStereoDownmix , SIGNAL ( clicked ( bool ) ) , this , SLOT ( forceStereoDownmixEnabledChanged ( bool ) ) ) ;
2011-01-21 19:14:11 +01:00
updateLameAlgoQuality ( sliderLameAlgoQuality - > value ( ) ) ;
2011-02-25 00:22:18 +01:00
updateMaximumInstances ( sliderMaxInstances - > value ( ) ) ;
2011-01-26 20:16:46 +01:00
toneAdjustTrebleChanged ( spinBoxToneAdjustTreble - > value ( ) ) ;
toneAdjustBassChanged ( spinBoxToneAdjustBass - > value ( ) ) ;
2011-02-09 23:36:17 +01:00
customParamsChanged ( ) ;
2011-01-21 19:14:11 +01:00
2010-11-06 23:04:47 +01:00
//Activate file menu actions
2011-03-23 23:19:31 +01:00
actionOpenFolder - > setData ( QVariant : : fromValue < bool > ( false ) ) ;
actionOpenFolderRecursively - > setData ( QVariant : : fromValue < bool > ( true ) ) ;
2010-11-06 23:04:47 +01:00
connect ( actionOpenFolder , SIGNAL ( triggered ( ) ) , this , SLOT ( openFolderActionActivated ( ) ) ) ;
2011-03-23 23:19:31 +01:00
connect ( actionOpenFolderRecursively , SIGNAL ( triggered ( ) ) , this , SLOT ( openFolderActionActivated ( ) ) ) ;
2010-11-06 23:04:47 +01:00
//Activate view menu actions
m_tabActionGroup = new QActionGroup ( this ) ;
m_tabActionGroup - > addAction ( actionSourceFiles ) ;
m_tabActionGroup - > addAction ( actionOutputDirectory ) ;
m_tabActionGroup - > addAction ( actionCompression ) ;
m_tabActionGroup - > addAction ( actionMetaData ) ;
m_tabActionGroup - > addAction ( actionAdvancedOptions ) ;
2011-01-03 22:24:58 +01:00
actionSourceFiles - > setData ( 0 ) ;
actionOutputDirectory - > setData ( 1 ) ;
actionMetaData - > setData ( 2 ) ;
actionCompression - > setData ( 3 ) ;
actionAdvancedOptions - > setData ( 4 ) ;
2010-11-06 23:04:47 +01:00
actionSourceFiles - > setChecked ( true ) ;
connect ( m_tabActionGroup , SIGNAL ( triggered ( QAction * ) ) , this , SLOT ( tabActionActivated ( QAction * ) ) ) ;
2010-11-08 00:24:54 +01:00
//Activate style menu actions
m_styleActionGroup = new QActionGroup ( this ) ;
m_styleActionGroup - > addAction ( actionStylePlastique ) ;
m_styleActionGroup - > addAction ( actionStyleCleanlooks ) ;
2010-11-08 21:47:35 +01:00
m_styleActionGroup - > addAction ( actionStyleWindowsVista ) ;
m_styleActionGroup - > addAction ( actionStyleWindowsXP ) ;
m_styleActionGroup - > addAction ( actionStyleWindowsClassic ) ;
2011-01-03 22:24:58 +01:00
actionStylePlastique - > setData ( 0 ) ;
actionStyleCleanlooks - > setData ( 1 ) ;
actionStyleWindowsVista - > setData ( 2 ) ;
actionStyleWindowsXP - > setData ( 3 ) ;
actionStyleWindowsClassic - > setData ( 4 ) ;
2010-11-08 00:24:54 +01:00
actionStylePlastique - > setChecked ( true ) ;
2011-01-02 20:47:26 +01:00
actionStyleWindowsXP - > setEnabled ( ( QSysInfo : : windowsVersion ( ) & QSysInfo : : WV_NT_based ) > = QSysInfo : : WV_XP & & lamexp_themes_enabled ( ) ) ;
actionStyleWindowsVista - > setEnabled ( ( QSysInfo : : windowsVersion ( ) & QSysInfo : : WV_NT_based ) > = QSysInfo : : WV_VISTA & & lamexp_themes_enabled ( ) ) ;
2010-11-08 00:24:54 +01:00
connect ( m_styleActionGroup , SIGNAL ( triggered ( QAction * ) ) , this , SLOT ( styleActionActivated ( QAction * ) ) ) ;
2010-11-12 21:02:14 +01:00
styleActionActivated ( NULL ) ;
2010-11-08 00:24:54 +01:00
2010-12-28 03:57:48 +01:00
//Populate the language menu
m_languageActionGroup = new QActionGroup ( this ) ;
2010-12-28 21:26:16 +01:00
QStringList translations = lamexp_query_translations ( ) ;
2010-12-30 16:12:21 +01:00
while ( ! translations . isEmpty ( ) )
2010-12-28 03:57:48 +01:00
{
2011-01-09 02:15:20 +01:00
QString langId = translations . takeFirst ( ) ;
2010-12-28 03:57:48 +01:00
QAction * currentLanguage = new QAction ( this ) ;
2010-12-30 16:12:21 +01:00
currentLanguage - > setData ( langId ) ;
currentLanguage - > setText ( lamexp_translation_name ( langId ) ) ;
currentLanguage - > setIcon ( QIcon ( QString ( " :/flags/%1.png " ) . arg ( langId ) ) ) ;
2010-12-28 03:57:48 +01:00
currentLanguage - > setCheckable ( true ) ;
m_languageActionGroup - > addAction ( currentLanguage ) ;
2011-01-06 00:53:52 +01:00
menuLanguage - > insertAction ( actionLoadTranslationFromFile , currentLanguage ) ;
2010-12-28 03:57:48 +01:00
}
2011-01-06 00:53:52 +01:00
menuLanguage - > insertSeparator ( actionLoadTranslationFromFile ) ;
connect ( actionLoadTranslationFromFile , SIGNAL ( triggered ( bool ) ) , this , SLOT ( languageFromFileActionActivated ( bool ) ) ) ;
connect ( m_languageActionGroup , SIGNAL ( triggered ( QAction * ) ) , this , SLOT ( languageActionActivated ( QAction * ) ) ) ;
2010-12-30 16:12:21 +01:00
2010-11-29 20:36:27 +01:00
//Activate tools menu actions
actionDisableUpdateReminder - > setChecked ( ! m_settings - > autoUpdateEnabled ( ) ) ;
actionDisableSounds - > setChecked ( ! m_settings - > soundsEnabled ( ) ) ;
2010-12-19 21:23:43 +01:00
actionDisableNeroAacNotifications - > setChecked ( ! m_settings - > neroAacNotificationsEnabled ( ) ) ;
2011-06-26 15:33:44 +02:00
actionDisableSlowStartupNotifications - > setChecked ( ! m_settings - > antivirNotificationsEnabled ( ) ) ;
2011-01-29 00:40:29 +01:00
actionDisableShellIntegration - > setChecked ( ! m_settings - > shellIntegrationEnabled ( ) ) ;
2011-01-29 21:57:53 +01:00
actionDisableShellIntegration - > setDisabled ( lamexp_portable_mode ( ) & & actionDisableShellIntegration - > isChecked ( ) ) ;
2011-05-03 14:28:06 +02:00
actionCheckForBetaUpdates - > setChecked ( m_settings - > autoUpdateCheckBeta ( ) | | lamexp_version_demo ( ) ) ;
actionCheckForBetaUpdates - > setEnabled ( ! lamexp_version_demo ( ) ) ;
2011-10-22 01:13:28 +02:00
actionHibernateComputer - > setChecked ( m_settings - > hibernateComputer ( ) ) ;
2011-10-22 01:34:24 +02:00
actionHibernateComputer - > setEnabled ( lamexp_is_hibernation_supported ( ) ) ;
2010-11-29 20:36:27 +01:00
connect ( actionDisableUpdateReminder , SIGNAL ( triggered ( bool ) ) , this , SLOT ( disableUpdateReminderActionTriggered ( bool ) ) ) ;
connect ( actionDisableSounds , SIGNAL ( triggered ( bool ) ) , this , SLOT ( disableSoundsActionTriggered ( bool ) ) ) ;
2010-12-19 21:23:43 +01:00
connect ( actionDisableNeroAacNotifications , SIGNAL ( triggered ( bool ) ) , this , SLOT ( disableNeroAacNotificationsActionTriggered ( bool ) ) ) ;
2011-06-26 15:33:44 +02:00
connect ( actionDisableSlowStartupNotifications , SIGNAL ( triggered ( bool ) ) , this , SLOT ( disableSlowStartupNotificationsActionTriggered ( bool ) ) ) ;
2011-01-29 00:40:29 +01:00
connect ( actionDisableShellIntegration , SIGNAL ( triggered ( bool ) ) , this , SLOT ( disableShellIntegrationActionTriggered ( bool ) ) ) ;
2010-12-22 01:01:01 +01:00
connect ( actionShowDropBoxWidget , SIGNAL ( triggered ( bool ) ) , this , SLOT ( showDropBoxWidgetActionTriggered ( bool ) ) ) ;
2011-10-22 01:13:28 +02:00
connect ( actionHibernateComputer , SIGNAL ( triggered ( bool ) ) , this , SLOT ( hibernateComputerActionTriggered ( bool ) ) ) ;
2011-05-03 14:28:06 +02:00
connect ( actionCheckForBetaUpdates , SIGNAL ( triggered ( bool ) ) , this , SLOT ( checkForBetaUpdatesActionTriggered ( bool ) ) ) ;
2011-05-12 22:57:08 +02:00
connect ( actionImportCueSheet , SIGNAL ( triggered ( bool ) ) , this , SLOT ( importCueSheetActionTriggered ( bool ) ) ) ;
2010-11-29 20:36:27 +01:00
2010-11-06 23:04:47 +01:00
//Activate help menu actions
2011-03-20 14:28:27 +01:00
actionVisitHomepage - > setData ( QString : : fromLatin1 ( lamexp_website_url ( ) ) ) ;
actionVisitSupport - > setData ( QString : : fromLatin1 ( lamexp_support_url ( ) ) ) ;
2011-03-19 18:16:23 +01:00
actionDocumentFAQ - > setData ( QString ( " %1/FAQ.html " ) . arg ( QApplication : : applicationDirPath ( ) ) ) ;
actionDocumentChangelog - > setData ( QString ( " %1/Changelog.html " ) . arg ( QApplication : : applicationDirPath ( ) ) ) ;
actionDocumentTranslate - > setData ( QString ( " %1/Translate.html " ) . arg ( QApplication : : applicationDirPath ( ) ) ) ;
2010-11-06 23:04:47 +01:00
connect ( actionCheckUpdates , SIGNAL ( triggered ( ) ) , this , SLOT ( checkUpdatesActionActivated ( ) ) ) ;
connect ( actionVisitHomepage , SIGNAL ( triggered ( ) ) , this , SLOT ( visitHomepageActionActivated ( ) ) ) ;
2011-03-20 14:28:27 +01:00
connect ( actionVisitSupport , SIGNAL ( triggered ( ) ) , this , SLOT ( visitHomepageActionActivated ( ) ) ) ;
2011-03-19 18:16:23 +01:00
connect ( actionDocumentFAQ , SIGNAL ( triggered ( ) ) , this , SLOT ( documentActionActivated ( ) ) ) ;
connect ( actionDocumentChangelog , SIGNAL ( triggered ( ) ) , this , SLOT ( documentActionActivated ( ) ) ) ;
connect ( actionDocumentTranslate , SIGNAL ( triggered ( ) ) , this , SLOT ( documentActionActivated ( ) ) ) ;
2010-11-06 23:04:47 +01:00
//Center window in screen
QRect desktopRect = QApplication : : desktop ( ) - > screenGeometry ( ) ;
QRect thisRect = this - > geometry ( ) ;
move ( ( desktopRect . width ( ) - thisRect . width ( ) ) / 2 , ( desktopRect . height ( ) - thisRect . height ( ) ) / 2 ) ;
setMinimumSize ( thisRect . width ( ) , thisRect . height ( ) ) ;
//Create banner
m_banner = new WorkingBanner ( this ) ;
2010-11-08 19:29:36 +01:00
2010-12-22 01:01:01 +01:00
//Create DropBox widget
m_dropBox = new DropBox ( this , m_fileListModel , m_settings ) ;
connect ( m_fileListModel , SIGNAL ( modelReset ( ) ) , m_dropBox , SLOT ( modelChanged ( ) ) ) ;
connect ( m_fileListModel , SIGNAL ( rowsInserted ( QModelIndex , int , int ) ) , m_dropBox , SLOT ( modelChanged ( ) ) ) ;
connect ( m_fileListModel , SIGNAL ( rowsRemoved ( QModelIndex , int , int ) ) , m_dropBox , SLOT ( modelChanged ( ) ) ) ;
2012-05-06 04:57:00 +02:00
connect ( m_fileListModel , SIGNAL ( rowAppended ( ) ) , m_dropBox , SLOT ( modelChanged ( ) ) ) ;
2010-12-30 17:34:19 +01:00
2010-11-08 19:29:36 +01:00
//Create message handler thread
m_messageHandler = new MessageHandlerThread ( ) ;
2010-11-08 21:47:35 +01:00
m_delayedFileList = new QStringList ( ) ;
m_delayedFileTimer = new QTimer ( ) ;
2011-05-27 11:29:40 +02:00
m_delayedFileTimer - > setSingleShot ( true ) ;
m_delayedFileTimer - > setInterval ( 5000 ) ;
2010-11-08 21:47:35 +01:00
connect ( m_messageHandler , SIGNAL ( otherInstanceDetected ( ) ) , this , SLOT ( notifyOtherInstance ( ) ) , Qt : : QueuedConnection ) ;
connect ( m_messageHandler , SIGNAL ( fileReceived ( QString ) ) , this , SLOT ( addFileDelayed ( QString ) ) , Qt : : QueuedConnection ) ;
2011-06-11 17:18:30 +02:00
connect ( m_messageHandler , SIGNAL ( folderReceived ( QString , bool ) ) , this , SLOT ( addFolderDelayed ( QString , bool ) ) , Qt : : QueuedConnection ) ;
2010-11-09 22:06:11 +01:00
connect ( m_messageHandler , SIGNAL ( killSignalReceived ( ) ) , this , SLOT ( close ( ) ) , Qt : : QueuedConnection ) ;
2010-11-08 21:47:35 +01:00
connect ( m_delayedFileTimer , SIGNAL ( timeout ( ) ) , this , SLOT ( handleDelayedFiles ( ) ) ) ;
2010-11-08 19:29:36 +01:00
m_messageHandler - > start ( ) ;
2010-11-12 23:31:04 +01:00
2010-12-31 01:52:16 +01:00
//Load translation file
2010-12-30 16:12:21 +01:00
QList < QAction * > languageActions = m_languageActionGroup - > actions ( ) ;
while ( ! languageActions . isEmpty ( ) )
{
QAction * currentLanguage = languageActions . takeFirst ( ) ;
if ( currentLanguage - > data ( ) . toString ( ) . compare ( m_settings - > currentLanguage ( ) , Qt : : CaseInsensitive ) = = 0 )
{
currentLanguage - > setChecked ( true ) ;
languageActionActivated ( currentLanguage ) ;
}
}
2010-12-30 17:34:19 +01:00
2011-01-01 19:28:19 +01:00
//Re-translate (make sure we translate once)
QEvent languageChangeEvent ( QEvent : : LanguageChange ) ;
changeEvent ( & languageChangeEvent ) ;
2010-12-30 17:34:19 +01:00
//Enable Drag & Drop
this - > setAcceptDrops ( true ) ;
2010-11-06 23:04:47 +01:00
}
////////////////////////////////////////////////////////////
// Destructor
////////////////////////////////////////////////////////////
MainWindow : : ~ MainWindow ( void )
{
2010-11-09 22:06:11 +01:00
//Stop message handler thread
if ( m_messageHandler & & m_messageHandler - > isRunning ( ) )
2010-11-08 21:47:35 +01:00
{
m_messageHandler - > stop ( ) ;
2011-12-29 14:42:20 +01:00
if ( ! m_messageHandler - > wait ( 2500 ) )
2010-11-09 22:06:11 +01:00
{
m_messageHandler - > terminate ( ) ;
m_messageHandler - > wait ( ) ;
}
2010-11-08 21:47:35 +01:00
}
2010-11-10 19:44:51 +01:00
//Unset models
2012-04-06 16:15:19 +02:00
SET_MODEL ( sourceFileView , NULL ) ;
SET_MODEL ( outputFolderView , NULL ) ;
SET_MODEL ( metaDataView , NULL ) ;
2010-12-28 03:57:48 +01:00
2010-11-09 22:06:11 +01:00
//Free memory
2010-11-06 23:04:47 +01:00
LAMEXP_DELETE ( m_tabActionGroup ) ;
2010-11-08 00:24:54 +01:00
LAMEXP_DELETE ( m_styleActionGroup ) ;
2010-12-28 03:57:48 +01:00
LAMEXP_DELETE ( m_languageActionGroup ) ;
2010-11-06 23:04:47 +01:00
LAMEXP_DELETE ( m_banner ) ;
2010-11-07 16:32:54 +01:00
LAMEXP_DELETE ( m_fileSystemModel ) ;
2010-11-08 21:47:35 +01:00
LAMEXP_DELETE ( m_messageHandler ) ;
LAMEXP_DELETE ( m_delayedFileList ) ;
LAMEXP_DELETE ( m_delayedFileTimer ) ;
2010-11-10 19:44:51 +01:00
LAMEXP_DELETE ( m_metaInfoModel ) ;
2010-11-15 04:42:06 +01:00
LAMEXP_DELETE ( m_encoderButtonGroup ) ;
2010-11-20 02:14:22 +01:00
LAMEXP_DELETE ( m_encoderButtonGroup ) ;
2010-11-25 20:41:59 +01:00
LAMEXP_DELETE ( m_sourceFilesContextMenu ) ;
2011-08-08 20:26:30 +02:00
LAMEXP_DELETE ( m_outputFolderFavoritesMenu ) ;
2012-04-06 23:15:58 +02:00
LAMEXP_DELETE ( m_outputFolderContextMenu ) ;
2010-12-22 01:01:01 +01:00
LAMEXP_DELETE ( m_dropBox ) ;
2010-11-06 23:04:47 +01:00
}
////////////////////////////////////////////////////////////
2010-11-11 19:37:16 +01:00
// PRIVATE FUNCTIONS
2010-11-06 23:04:47 +01:00
////////////////////////////////////////////////////////////
2010-12-28 03:57:48 +01:00
/*
* Add file to source list
*/
2010-11-11 19:37:16 +01:00
void MainWindow : : addFiles ( const QStringList & files )
{
if ( files . isEmpty ( ) )
{
return ;
}
tabWidget - > setCurrentIndex ( 0 ) ;
FileAnalyzer * analyzer = new FileAnalyzer ( files ) ;
connect ( analyzer , SIGNAL ( fileSelected ( QString ) ) , m_banner , SLOT ( setText ( QString ) ) , Qt : : QueuedConnection ) ;
2012-05-06 04:57:00 +02:00
connect ( analyzer , SIGNAL ( progressValChanged ( unsigned int ) ) , m_banner , SLOT ( setProgressVal ( unsigned int ) ) , Qt : : QueuedConnection ) ;
connect ( analyzer , SIGNAL ( progressMaxChanged ( unsigned int ) ) , m_banner , SLOT ( setProgressMax ( unsigned int ) ) , Qt : : QueuedConnection ) ;
2010-11-11 19:37:16 +01:00
connect ( analyzer , SIGNAL ( fileAnalyzed ( AudioFileModel ) ) , m_fileListModel , SLOT ( addFile ( AudioFileModel ) ) , Qt : : QueuedConnection ) ;
2011-05-16 21:02:24 +02:00
connect ( m_banner , SIGNAL ( userAbort ( ) ) , analyzer , SLOT ( abortProcess ( ) ) , Qt : : DirectConnection ) ;
2010-11-11 19:37:16 +01:00
2012-05-05 21:56:14 +02:00
try
{
m_fileListModel - > setBlockUpdates ( true ) ;
m_banner - > show ( tr ( " Adding file(s), please wait... " ) , analyzer ) ;
}
catch ( . . . )
{
/* ignore any exceptions that may occur */
}
m_fileListModel - > setBlockUpdates ( false ) ;
qApp - > processEvents ( QEventLoop : : ExcludeUserInputEvents ) ;
sourceFileView - > update ( ) ;
qApp - > processEvents ( QEventLoop : : ExcludeUserInputEvents ) ;
sourceFileView - > scrollToBottom ( ) ;
qApp - > processEvents ( QEventLoop : : ExcludeUserInputEvents ) ;
2010-11-11 19:37:16 +01:00
if ( analyzer - > filesDenied ( ) )
{
2011-10-16 16:38:01 +02:00
QMessageBox : : warning ( this , tr ( " Access Denied " ) , QString ( " %1<br>%2 " ) . arg ( NOBR ( tr ( " %1 file(s) have been rejected, because read access was not granted! " ) . arg ( analyzer - > filesDenied ( ) ) ) , NOBR ( tr ( " This usually means the file is locked by another process. " ) ) ) ) ;
2010-11-11 19:37:16 +01:00
}
2011-03-19 15:35:17 +01:00
if ( analyzer - > filesDummyCDDA ( ) )
{
2011-10-16 16:38:01 +02:00
QMessageBox : : warning ( this , tr ( " CDDA Files " ) , QString ( " %1<br><br>%2<br>%3 " ) . arg ( NOBR ( tr ( " %1 file(s) have been rejected, because they are dummy CDDA files! " ) . arg ( analyzer - > filesDummyCDDA ( ) ) ) , NOBR ( tr ( " Sorry, LameXP cannot extract audio tracks from an Audio-CD at present. " ) ) , NOBR ( tr ( " We recommend using %1 for that purpose. " ) . arg ( " <a href= \" http://www.exactaudiocopy.de/ \" >Exact Audio Copy</a> " ) ) ) ) ;
2011-05-17 01:14:50 +02:00
}
if ( analyzer - > filesCueSheet ( ) )
{
2011-10-16 16:38:01 +02:00
QMessageBox : : warning ( this , tr ( " Cue Sheet " ) , QString ( " %1<br>%2 " ) . arg ( NOBR ( tr ( " %1 file(s) have been rejected, because they appear to be Cue Sheet images! " ) . arg ( analyzer - > filesCueSheet ( ) ) ) , NOBR ( tr ( " Please use LameXP's Cue Sheet wizard for importing Cue Sheet files. " ) ) ) ) ;
2011-03-19 15:35:17 +01:00
}
2010-11-11 19:37:16 +01:00
if ( analyzer - > filesRejected ( ) )
{
2011-10-16 16:38:01 +02:00
QMessageBox : : warning ( this , tr ( " Files Rejected " ) , QString ( " %1<br>%2 " ) . arg ( NOBR ( tr ( " %1 file(s) have been rejected, because the file format could not be recognized! " ) . arg ( analyzer - > filesRejected ( ) ) ) , NOBR ( tr ( " This usually means the file is damaged or the file format is not supported. " ) ) ) ) ;
2010-11-11 19:37:16 +01:00
}
LAMEXP_DELETE ( analyzer ) ;
m_banner - > close ( ) ;
}
2010-11-06 23:04:47 +01:00
2011-03-23 23:19:31 +01:00
/*
* Add folder to source list
*/
2011-06-11 17:18:30 +02:00
void MainWindow : : addFolder ( const QString & path , bool recursive , bool delayed )
2011-03-23 23:19:31 +01:00
{
QFileInfoList folderInfoList ;
folderInfoList < < QFileInfo ( path ) ;
QStringList fileList ;
m_banner - > show ( tr ( " Scanning folder(s) for files, please wait... " ) ) ;
2011-04-11 21:57:16 +02:00
2011-03-23 23:19:31 +01:00
QApplication : : processEvents ( ) ;
2011-04-11 21:57:16 +02:00
GetAsyncKeyState ( VK_ESCAPE ) ;
2011-03-23 23:19:31 +01:00
while ( ! folderInfoList . isEmpty ( ) )
{
2011-04-11 21:57:16 +02:00
if ( GetAsyncKeyState ( VK_ESCAPE ) & 0x0001 )
{
MessageBeep ( MB_ICONERROR ) ;
qWarning ( " Operation cancelled by user! " ) ;
fileList . clear ( ) ;
break ;
}
2011-03-23 23:19:31 +01:00
QDir currentDir ( folderInfoList . takeFirst ( ) . canonicalFilePath ( ) ) ;
2011-09-05 15:36:58 +02:00
QFileInfoList fileInfoList = currentDir . entryInfoList ( QDir : : Files | QDir : : NoSymLinks ) ;
2011-03-23 23:19:31 +01:00
while ( ! fileInfoList . isEmpty ( ) )
{
fileList < < fileInfoList . takeFirst ( ) . canonicalFilePath ( ) ;
}
QApplication : : processEvents ( ) ;
if ( recursive )
{
folderInfoList . append ( currentDir . entryInfoList ( QDir : : Dirs | QDir : : NoDotAndDotDot | QDir : : NoSymLinks ) ) ;
QApplication : : processEvents ( ) ;
}
}
m_banner - > close ( ) ;
QApplication : : processEvents ( ) ;
if ( ! fileList . isEmpty ( ) )
{
2011-06-11 17:18:30 +02:00
if ( delayed )
{
addFilesDelayed ( fileList ) ;
}
else
{
addFiles ( fileList ) ;
}
2011-03-23 23:19:31 +01:00
}
}
2011-02-18 00:53:36 +01:00
/*
* Check for updates
*/
bool MainWindow : : checkForUpdates ( void )
{
bool bReadyToInstall = false ;
UpdateDialog * updateDialog = new UpdateDialog ( m_settings , this ) ;
updateDialog - > exec ( ) ;
if ( updateDialog - > getSuccess ( ) )
{
m_settings - > autoUpdateLastCheck ( QDate : : currentDate ( ) . toString ( Qt : : ISODate ) ) ;
bReadyToInstall = updateDialog - > updateReadyToInstall ( ) ;
}
LAMEXP_DELETE ( updateDialog ) ;
return bReadyToInstall ;
2011-01-29 00:40:29 +01:00
}
2011-08-08 20:26:30 +02:00
void MainWindow : : refreshFavorites ( void )
{
QList < QAction * > folderList = m_outputFolderFavoritesMenu - > actions ( ) ;
QStringList favorites = m_settings - > favoriteOutputFolders ( ) . split ( " | " , QString : : SkipEmptyParts ) ;
while ( favorites . count ( ) > 6 ) favorites . removeFirst ( ) ;
while ( ! folderList . isEmpty ( ) )
{
QAction * currentItem = folderList . takeFirst ( ) ;
if ( currentItem - > isSeparator ( ) ) break ;
m_outputFolderFavoritesMenu - > removeAction ( currentItem ) ;
LAMEXP_DELETE ( currentItem ) ;
}
QAction * lastItem = m_outputFolderFavoritesMenu - > actions ( ) . first ( ) ;
while ( ! favorites . isEmpty ( ) )
{
QString path = favorites . takeLast ( ) ;
if ( QDir ( path ) . exists ( ) )
{
QAction * action = new QAction ( QIcon ( " :/icons/folder_go.png " ) , QDir : : toNativeSeparators ( path ) , this ) ;
action - > setData ( path ) ;
m_outputFolderFavoritesMenu - > insertAction ( lastItem , action ) ;
connect ( action , SIGNAL ( triggered ( bool ) ) , this , SLOT ( gotoFavoriteFolder ( ) ) ) ;
lastItem = action ;
}
}
}
2010-11-08 19:29:36 +01:00
////////////////////////////////////////////////////////////
// EVENTS
////////////////////////////////////////////////////////////
2010-12-28 03:57:48 +01:00
/*
* Window is about to be shown
*/
2010-11-08 19:29:36 +01:00
void MainWindow : : showEvent ( QShowEvent * event )
{
2010-11-19 21:11:54 +01:00
m_accepted = false ;
2010-11-20 02:14:22 +01:00
m_dropNoteLabel - > setGeometry ( 0 , 0 , sourceFileView - > width ( ) , sourceFileView - > height ( ) ) ;
2010-11-21 21:51:41 +01:00
sourceModelChanged ( ) ;
2011-05-31 19:04:45 +02:00
if ( ! event - > spontaneous ( ) )
{
tabWidget - > setCurrentIndex ( 0 ) ;
}
2010-11-20 22:14:10 +01:00
if ( m_firstTimeShown )
{
m_firstTimeShown = false ;
QTimer : : singleShot ( 0 , this , SLOT ( windowShown ( ) ) ) ;
}
2010-12-22 22:59:00 +01:00
else
2010-12-22 01:01:01 +01:00
{
2010-12-22 22:59:00 +01:00
if ( m_settings - > dropBoxWidgetEnabled ( ) )
{
m_dropBox - > setVisible ( true ) ;
}
2010-12-22 01:01:01 +01:00
}
2010-11-08 19:29:36 +01:00
}
2010-12-30 17:34:19 +01:00
/*
* Re - translate the UI
*/
void MainWindow : : changeEvent ( QEvent * e )
{
if ( e - > type ( ) = = QEvent : : LanguageChange )
{
2011-10-06 23:55:42 +02:00
int comboBoxIndex [ 6 ] ;
2011-01-22 22:19:20 +01:00
2011-02-11 23:16:11 +01:00
//Backup combobox indices, as retranslateUi() resets
2011-01-22 22:19:20 +01:00
comboBoxIndex [ 0 ] = comboBoxMP3ChannelMode - > currentIndex ( ) ;
comboBoxIndex [ 1 ] = comboBoxSamplingRate - > currentIndex ( ) ;
2011-08-21 14:43:18 +02:00
comboBoxIndex [ 2 ] = comboBoxAACProfile - > currentIndex ( ) ;
2011-05-07 00:50:18 +02:00
comboBoxIndex [ 3 ] = comboBoxAftenCodingMode - > currentIndex ( ) ;
comboBoxIndex [ 4 ] = comboBoxAftenDRCMode - > currentIndex ( ) ;
2011-10-06 23:55:42 +02:00
comboBoxIndex [ 5 ] = comboBoxNormalizationMode - > currentIndex ( ) ;
2011-01-22 22:19:20 +01:00
2011-02-11 23:16:11 +01:00
//Re-translate from UIC
2010-12-30 17:34:19 +01:00
Ui : : MainWindow : : retranslateUi ( this ) ;
2011-01-22 22:19:20 +01:00
//Restore combobox indices
comboBoxMP3ChannelMode - > setCurrentIndex ( comboBoxIndex [ 0 ] ) ;
comboBoxSamplingRate - > setCurrentIndex ( comboBoxIndex [ 1 ] ) ;
2011-08-21 14:43:18 +02:00
comboBoxAACProfile - > setCurrentIndex ( comboBoxIndex [ 2 ] ) ;
2011-05-07 00:50:18 +02:00
comboBoxAftenCodingMode - > setCurrentIndex ( comboBoxIndex [ 3 ] ) ;
comboBoxAftenDRCMode - > setCurrentIndex ( comboBoxIndex [ 4 ] ) ;
2011-10-06 23:55:42 +02:00
comboBoxNormalizationMode - > setCurrentIndex ( comboBoxIndex [ 5 ] ) ;
2011-01-22 22:19:20 +01:00
2011-02-20 19:29:28 +01:00
//Update the window title
2011-04-11 21:57:16 +02:00
if ( LAMEXP_DEBUG )
{
setWindowTitle ( QString ( " %1 [!!! DEBUG BUILD !!!] " ) . arg ( windowTitle ( ) ) ) ;
}
else if ( lamexp_version_demo ( ) )
2010-12-30 17:34:19 +01:00
{
setWindowTitle ( QString ( " %1 [%2] " ) . arg ( windowTitle ( ) , tr ( " DEMO VERSION " ) ) ) ;
}
2011-02-20 19:29:28 +01:00
2011-02-11 23:16:11 +01:00
//Manually re-translate widgets that UIC doesn't handle
2010-12-30 17:34:19 +01:00
m_dropNoteLabel - > setText ( QString ( " <EFBFBD> %1 <20> " ) . arg ( tr ( " You can drop in audio files here! " ) ) ) ;
2012-03-30 03:35:43 +02:00
m_outputFolderNoteBox - > setText ( tr ( " Initializing directory outline, please be patient... " ) ) ;
2010-12-30 17:34:19 +01:00
m_showDetailsContextAction - > setText ( tr ( " Show Details " ) ) ;
m_previewContextAction - > setText ( tr ( " Open File in External Application " ) ) ;
m_findFileContextAction - > setText ( tr ( " Browse File Location " ) ) ;
m_showFolderContextAction - > setText ( tr ( " Browse Selected Folder " ) ) ;
2012-04-05 15:24:45 +02:00
m_refreshFolderContextAction - > setText ( tr ( " Refresh Directory Outline " ) ) ;
2011-08-08 20:26:30 +02:00
m_addFavoriteFolderAction - > setText ( tr ( " Bookmark Current Output Folder " ) ) ;
2012-01-04 03:23:07 +01:00
m_exportCsvContextAction - > setText ( tr ( " Export Meta Tags to CSV File " ) ) ;
2012-01-04 21:10:33 +01:00
m_importCsvContextAction - > setText ( tr ( " Import Meta Tags from CSV File " ) ) ;
2011-01-04 19:58:18 +01:00
2011-01-22 22:19:20 +01:00
//Force GUI update
2011-01-04 19:58:18 +01:00
m_metaInfoModel - > clearData ( ) ;
2011-02-10 16:08:03 +01:00
m_metaInfoModel - > setData ( m_metaInfoModel - > index ( 4 , 1 ) , m_settings - > metaInfoPosition ( ) ) ;
2011-01-14 23:34:31 +01:00
updateEncoder ( m_settings - > compressionEncoder ( ) ) ;
2011-01-21 19:14:11 +01:00
updateLameAlgoQuality ( sliderLameAlgoQuality - > value ( ) ) ;
2011-02-25 00:22:18 +01:00
updateMaximumInstances ( sliderMaxInstances - > value ( ) ) ;
2011-08-05 15:41:19 +02:00
renameOutputPatternChanged ( lineEditRenamePattern - > text ( ) ) ;
2011-01-29 00:40:29 +01:00
2011-02-11 23:16:11 +01:00
//Re-install shell integration
2011-01-29 00:40:29 +01:00
if ( m_settings - > shellIntegrationEnabled ( ) )
{
ShellIntegration : : install ( ) ;
}
2011-04-05 14:57:21 +02:00
//Force resize, if needed
tabPageChanged ( tabWidget - > currentIndex ( ) ) ;
2010-12-30 17:34:19 +01:00
}
}
2010-12-28 03:57:48 +01:00
/*
* File dragged over window
*/
2010-11-12 23:31:04 +01:00
void MainWindow : : dragEnterEvent ( QDragEnterEvent * event )
{
QStringList formats = event - > mimeData ( ) - > formats ( ) ;
2010-11-13 02:11:15 +01:00
if ( formats . contains ( " application/x-qt-windows-mime;value= \" FileNameW \" " , Qt : : CaseInsensitive ) & & formats . contains ( " text/uri-list " , Qt : : CaseInsensitive ) )
2010-11-12 23:31:04 +01:00
{
2010-11-13 02:11:15 +01:00
event - > acceptProposedAction ( ) ;
2010-11-12 23:31:04 +01:00
}
}
2010-12-28 03:57:48 +01:00
/*
* File dropped onto window
*/
2010-11-12 23:31:04 +01:00
void MainWindow : : dropEvent ( QDropEvent * event )
{
ABORT_IF_BUSY ;
QStringList droppedFiles ;
2011-09-05 15:36:58 +02:00
QList < QUrl > urls = event - > mimeData ( ) - > urls ( ) ;
2010-11-12 23:31:04 +01:00
2011-09-05 15:36:58 +02:00
while ( ! urls . isEmpty ( ) )
2010-11-12 23:31:04 +01:00
{
2011-09-05 15:36:58 +02:00
QUrl currentUrl = urls . takeFirst ( ) ;
QFileInfo file ( currentUrl . toLocalFile ( ) ) ;
2010-11-13 02:11:15 +01:00
if ( ! file . exists ( ) )
{
continue ;
}
if ( file . isFile ( ) )
{
2011-09-29 20:06:09 +02:00
qDebug ( " Dropped File: %s " , file . canonicalFilePath ( ) . toUtf8 ( ) . constData ( ) ) ;
2010-11-13 02:11:15 +01:00
droppedFiles < < file . canonicalFilePath ( ) ;
continue ;
}
2011-09-05 15:36:58 +02:00
if ( file . isDir ( ) )
2010-11-13 02:11:15 +01:00
{
2011-09-29 20:06:09 +02:00
qDebug ( " Dropped Folder: %s " , file . canonicalFilePath ( ) . toUtf8 ( ) . constData ( ) ) ;
2011-09-05 15:36:58 +02:00
QList < QFileInfo > list = QDir ( file . canonicalFilePath ( ) ) . entryInfoList ( QDir : : Files | QDir : : NoSymLinks ) ;
if ( list . count ( ) > 0 )
2010-11-13 02:11:15 +01:00
{
2011-09-05 15:36:58 +02:00
for ( int j = 0 ; j < list . count ( ) ; j + + )
{
droppedFiles < < list . at ( j ) . canonicalFilePath ( ) ;
}
}
else
{
list = QDir ( file . canonicalFilePath ( ) ) . entryInfoList ( QDir : : Dirs | QDir : : NoDotAndDotDot | QDir : : NoSymLinks ) ;
for ( int j = 0 ; j < list . count ( ) ; j + + )
{
2011-09-29 20:06:09 +02:00
qDebug ( " Descending to Folder: %s " , list . at ( j ) . canonicalFilePath ( ) . toUtf8 ( ) . constData ( ) ) ;
2011-09-05 15:36:58 +02:00
urls . prepend ( QUrl : : fromLocalFile ( list . at ( j ) . canonicalFilePath ( ) ) ) ;
}
2010-11-13 02:11:15 +01:00
}
}
2010-11-12 23:31:04 +01:00
}
2011-05-27 11:29:40 +02:00
if ( ! droppedFiles . isEmpty ( ) )
{
2011-06-11 17:18:30 +02:00
addFilesDelayed ( droppedFiles , true ) ;
2011-05-27 11:29:40 +02:00
}
2010-11-12 23:31:04 +01:00
}
2010-12-28 03:57:48 +01:00
/*
* Window tries to close
*/
2010-11-19 21:11:54 +01:00
void MainWindow : : closeEvent ( QCloseEvent * event )
{
2011-12-29 14:42:20 +01:00
if ( m_banner - > isVisible ( ) | | m_delayedFileTimer - > isActive ( ) )
2010-11-19 21:11:54 +01:00
{
MessageBeep ( MB_ICONEXCLAMATION ) ;
event - > ignore ( ) ;
}
2010-12-22 01:01:01 +01:00
if ( m_dropBox )
{
m_dropBox - > hide ( ) ;
}
2010-11-19 21:11:54 +01:00
}
2010-12-28 03:57:48 +01:00
/*
* Window was resized
*/
2010-11-20 02:14:22 +01:00
void MainWindow : : resizeEvent ( QResizeEvent * event )
{
2012-03-30 03:35:43 +02:00
if ( event ) QMainWindow : : resizeEvent ( event ) ;
2010-11-20 02:14:22 +01:00
m_dropNoteLabel - > setGeometry ( 0 , 0 , sourceFileView - > width ( ) , sourceFileView - > height ( ) ) ;
2012-03-30 03:35:43 +02:00
if ( QWidget * port = outputFolderView - > viewport ( ) )
{
m_outputFolderNoteBox - > setGeometry ( 16 , ( port - > height ( ) - 64 ) / 2 , port - > width ( ) - 32 , 64 ) ;
}
2010-11-20 02:14:22 +01:00
}
2012-04-05 15:24:45 +02:00
/*
* Key press event filter
*/
void MainWindow : : keyPressEvent ( QKeyEvent * e )
{
if ( e - > key ( ) = = Qt : : Key_F5 )
{
if ( outputFolderView - > isVisible ( ) )
{
QTimer : : singleShot ( 0 , this , SLOT ( refreshFolderContextActionTriggered ( ) ) ) ;
return ;
}
}
2012-04-19 00:56:04 +02:00
if ( e - > key ( ) = = Qt : : Key_Delete )
{
if ( sourceFileView - > isVisible ( ) )
{
QTimer : : singleShot ( 0 , this , SLOT ( removeFileButtonClicked ( ) ) ) ;
return ;
}
}
2012-04-05 15:24:45 +02:00
QMainWindow : : keyPressEvent ( e ) ;
}
2010-12-28 03:57:48 +01:00
/*
* Event filter
*/
2010-11-24 21:00:59 +01:00
bool MainWindow : : eventFilter ( QObject * obj , QEvent * event )
{
2011-06-12 03:18:37 +02:00
if ( obj = = m_fileSystemModel )
2010-11-24 21:00:59 +01:00
{
2011-06-12 03:18:37 +02:00
if ( QApplication : : overrideCursor ( ) = = NULL )
{
QApplication : : setOverrideCursor ( QCursor ( Qt : : WaitCursor ) ) ;
QTimer : : singleShot ( 250 , this , SLOT ( restoreCursor ( ) ) ) ;
}
}
else if ( obj = = outputFolderView )
{
switch ( event - > type ( ) )
{
case QEvent : : Enter :
case QEvent : : Leave :
case QEvent : : KeyPress :
case QEvent : : KeyRelease :
2011-06-12 14:43:07 +02:00
case QEvent : : FocusIn :
case QEvent : : FocusOut :
case QEvent : : TouchEnd :
2011-06-12 03:18:37 +02:00
outputFolderViewClicked ( outputFolderView - > currentIndex ( ) ) ;
break ;
}
2010-11-24 21:00:59 +01:00
}
2010-12-28 03:57:48 +01:00
else if ( obj = = outputFolderLabel )
{
switch ( event - > type ( ) )
{
case QEvent : : MouseButtonPress :
if ( dynamic_cast < QMouseEvent * > ( event ) - > button ( ) = = Qt : : LeftButton )
{
2011-12-19 02:09:45 +01:00
QString path = outputFolderLabel - > text ( ) ;
if ( ! path . endsWith ( QDir : : separator ( ) ) ) path . append ( QDir : : separator ( ) ) ;
2012-04-11 00:44:40 +02:00
ShellExecuteW ( reinterpret_cast < HWND > ( this - > winId ( ) ) , L " explore " , QWCHAR ( path ) , NULL , NULL , SW_SHOW ) ;
2010-12-28 03:57:48 +01:00
}
break ;
case QEvent : : Enter :
outputFolderLabel - > setForegroundRole ( QPalette : : Link ) ;
break ;
case QEvent : : Leave :
outputFolderLabel - > setForegroundRole ( QPalette : : WindowText ) ;
break ;
}
}
2011-08-08 20:26:30 +02:00
else if ( obj = = outputFoldersFovoritesLabel )
{
QMouseEvent * mouseEvent = dynamic_cast < QMouseEvent * > ( event ) ;
QPoint pos = ( mouseEvent ! = NULL ) ? mouseEvent - > pos ( ) : QPoint ( ) ;
QWidget * sender = dynamic_cast < QLabel * > ( obj ) ;
switch ( event - > type ( ) )
{
case QEvent : : Enter :
outputFoldersFovoritesLabel - > setFrameShadow ( QFrame : : Raised ) ;
break ;
case QEvent : : MouseButtonPress :
outputFoldersFovoritesLabel - > setFrameShadow ( QFrame : : Sunken ) ;
break ;
case QEvent : : MouseButtonRelease :
outputFoldersFovoritesLabel - > setFrameShadow ( QFrame : : Raised ) ;
if ( sender & & mouseEvent )
{
if ( pos . x ( ) < = sender - > width ( ) & & pos . y ( ) < = sender - > height ( ) & & pos . x ( ) > = 0 & & pos . y ( ) > = 0 & & mouseEvent - > button ( ) ! = Qt : : MidButton )
{
2012-03-27 22:46:01 +02:00
if ( outputFolderView - > isEnabled ( ) )
{
m_outputFolderFavoritesMenu - > popup ( sender - > mapToGlobal ( pos ) ) ;
}
2011-08-08 20:26:30 +02:00
}
}
break ;
case QEvent : : Leave :
outputFoldersFovoritesLabel - > setFrameShadow ( QFrame : : Plain ) ;
break ;
}
}
2012-03-26 22:02:11 +02:00
else if ( obj = = outputFoldersEditorLabel )
{
QMouseEvent * mouseEvent = dynamic_cast < QMouseEvent * > ( event ) ;
QPoint pos = ( mouseEvent ! = NULL ) ? mouseEvent - > pos ( ) : QPoint ( ) ;
QWidget * sender = dynamic_cast < QLabel * > ( obj ) ;
switch ( event - > type ( ) )
{
case QEvent : : Enter :
outputFoldersEditorLabel - > setFrameShadow ( QFrame : : Raised ) ;
break ;
case QEvent : : MouseButtonPress :
outputFoldersEditorLabel - > setFrameShadow ( QFrame : : Sunken ) ;
break ;
case QEvent : : MouseButtonRelease :
outputFoldersEditorLabel - > setFrameShadow ( QFrame : : Raised ) ;
if ( sender & & mouseEvent )
{
if ( pos . x ( ) < = sender - > width ( ) & & pos . y ( ) < = sender - > height ( ) & & pos . x ( ) > = 0 & & pos . y ( ) > = 0 & & mouseEvent - > button ( ) ! = Qt : : MidButton )
{
2012-03-27 22:46:01 +02:00
if ( outputFolderView - > isEnabled ( ) )
{
outputFolderView - > setEnabled ( false ) ;
outputFolderLabel - > setVisible ( false ) ;
outputFolderEdit - > setVisible ( true ) ;
outputFolderEdit - > setText ( outputFolderLabel - > text ( ) ) ;
outputFolderEdit - > selectAll ( ) ;
outputFolderEdit - > setFocus ( ) ;
}
2012-03-26 22:02:11 +02:00
}
}
break ;
case QEvent : : Leave :
outputFoldersEditorLabel - > setFrameShadow ( QFrame : : Plain ) ;
break ;
}
}
2011-08-22 00:03:36 +02:00
2011-12-18 15:19:28 +01:00
return QMainWindow : : eventFilter ( obj , event ) ;
2010-11-24 21:00:59 +01:00
}
2011-12-29 14:42:20 +01:00
bool MainWindow : : event ( QEvent * e )
{
switch ( e - > type ( ) )
{
case lamexp_event_queryendsession :
qWarning ( " System is shutting down, main window prepares to close... " ) ;
if ( m_banner - > isVisible ( ) ) m_banner - > close ( ) ;
if ( m_delayedFileTimer - > isActive ( ) ) m_delayedFileTimer - > stop ( ) ;
return true ;
case lamexp_event_endsession :
qWarning ( " System is shutting down, main window will close now... " ) ;
if ( isVisible ( ) )
{
while ( ! close ( ) )
{
QApplication : : processEvents ( QEventLoop : : WaitForMoreEvents & QEventLoop : : ExcludeUserInputEvents ) ;
}
}
m_fileListModel - > clearFiles ( ) ;
return true ;
2012-03-27 22:46:01 +02:00
case QEvent : : MouseButtonPress :
if ( outputFolderEdit - > isVisible ( ) )
{
QTimer : : singleShot ( 0 , this , SLOT ( outputFolderEditFinished ( ) ) ) ;
}
2011-12-29 14:42:20 +01:00
default :
return QMainWindow : : event ( e ) ;
}
}
2011-11-07 17:13:41 +01:00
bool MainWindow : : winEvent ( MSG * message , long * result )
{
return WinSevenTaskbar : : handleWinEvent ( message , result ) ;
}
2010-11-06 23:04:47 +01:00
////////////////////////////////////////////////////////////
// Slots
////////////////////////////////////////////////////////////
2011-05-21 13:07:17 +02:00
// =========================================================
// Show window slots
// =========================================================
2010-11-08 19:29:36 +01:00
/*
* Window shown
*/
void MainWindow : : windowShown ( void )
{
QStringList arguments = QApplication : : arguments ( ) ;
2011-09-19 18:52:02 +02:00
//First run?
bool firstRun = false ;
for ( int i = 0 ; i < arguments . count ( ) ; i + + )
{
if ( ! arguments [ i ] . compare ( " --first-run " , Qt : : CaseInsensitive ) ) firstRun = true ;
}
2010-11-29 20:36:27 +01:00
//Check license
2011-09-19 18:52:02 +02:00
if ( ( m_settings - > licenseAccepted ( ) < = 0 ) | | firstRun )
2010-11-12 15:58:53 +01:00
{
2010-11-12 19:02:01 +01:00
int iAccepted = - 1 ;
2011-09-19 18:52:02 +02:00
if ( ( m_settings - > licenseAccepted ( ) = = 0 ) | | firstRun )
2010-11-12 19:02:01 +01:00
{
2010-11-29 20:36:27 +01:00
AboutDialog * about = new AboutDialog ( m_settings , this , true ) ;
2010-11-12 19:02:01 +01:00
iAccepted = about - > exec ( ) ;
LAMEXP_DELETE ( about ) ;
}
if ( iAccepted < = 0 )
{
2010-11-15 04:42:06 +01:00
m_settings - > licenseAccepted ( - 1 ) ;
2010-12-22 01:01:01 +01:00
QApplication : : processEvents ( ) ;
2010-12-20 22:13:01 +01:00
PlaySound ( MAKEINTRESOURCE ( IDR_WAVE_WHAMMY ) , GetModuleHandle ( NULL ) , SND_RESOURCE | SND_SYNC ) ;
2010-12-28 21:26:16 +01:00
QMessageBox : : critical ( this , tr ( " License Declined " ) , tr ( " You have declined the license. Consequently the application will exit now! " ) , tr ( " Goodbye! " ) ) ;
2011-10-06 14:35:13 +02:00
QFileInfo uninstallerInfo = QFileInfo ( QString ( " %1/Uninstall.exe " ) . arg ( QApplication : : applicationDirPath ( ) ) ) ;
if ( uninstallerInfo . exists ( ) )
{
QString uninstallerDir = uninstallerInfo . canonicalPath ( ) ;
QString uninstallerPath = uninstallerInfo . canonicalFilePath ( ) ;
for ( int i = 0 ; i < 3 ; i + + )
{
2012-04-11 00:44:40 +02:00
HINSTANCE res = ShellExecuteW ( reinterpret_cast < HWND > ( this - > winId ( ) ) , L " open " , QWCHAR ( QDir : : toNativeSeparators ( uninstallerPath ) ) , L " /Force " , QWCHAR ( QDir : : toNativeSeparators ( uninstallerDir ) ) , SW_SHOWNORMAL ) ;
2011-10-06 14:35:13 +02:00
if ( reinterpret_cast < int > ( res ) > 32 ) break ;
}
}
else
2011-02-25 13:40:45 +01:00
{
MoveFileEx ( QWCHAR ( QDir : : toNativeSeparators ( QFileInfo ( QApplication : : applicationFilePath ( ) ) . canonicalFilePath ( ) ) ) , NULL , MOVEFILE_DELAY_UNTIL_REBOOT | MOVEFILE_REPLACE_EXISTING ) ;
}
2010-11-12 19:02:01 +01:00
QApplication : : quit ( ) ;
return ;
}
2010-12-22 01:01:01 +01:00
PlaySound ( MAKEINTRESOURCE ( IDR_WAVE_WOOHOO ) , GetModuleHandle ( NULL ) , SND_RESOURCE | SND_SYNC ) ;
2010-11-15 04:42:06 +01:00
m_settings - > licenseAccepted ( 1 ) ;
2011-09-19 18:52:02 +02:00
if ( lamexp_version_demo ( ) ) showAnnounceBox ( ) ;
2010-11-12 15:58:53 +01:00
}
2010-11-29 20:36:27 +01:00
//Check for expiration
if ( lamexp_version_demo ( ) )
{
2011-01-20 22:06:59 +01:00
if ( QDate : : currentDate ( ) > = lamexp_version_expires ( ) )
2010-11-29 20:36:27 +01:00
{
qWarning ( " Binary has expired !!! " ) ;
2010-12-20 22:13:01 +01:00
PlaySound ( MAKEINTRESOURCE ( IDR_WAVE_WHAMMY ) , GetModuleHandle ( NULL ) , SND_RESOURCE | SND_SYNC ) ;
2011-10-16 16:38:01 +02:00
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 )
2010-11-29 20:36:27 +01:00
{
2011-02-18 00:53:36 +01:00
checkForUpdates ( ) ;
2010-11-29 20:36:27 +01:00
}
QApplication : : quit ( ) ;
return ;
}
}
2011-06-24 18:17:04 +02:00
//Slow startup indicator
if ( m_settings - > slowStartup ( ) & & m_settings - > antivirNotificationsEnabled ( ) )
{
QString message ;
2011-09-20 00:29:01 +02:00
message + = NOBR ( tr ( " It seems that a bogus anti-virus software is slowing down the startup of LameXP. " ) ) . append ( " <br> " ) ;
message + = NOBR ( tr ( " Please refer to the %1 document for details and solutions! " ) ) . arg ( " <a href= \" http://lamexp.git.sourceforge.net/git/gitweb.cgi?p=lamexp/lamexp;a=blob_plain;f=doc/FAQ.html;hb=HEAD#df406578 \" >F.A.Q.</a> " ) . append ( " <br> " ) ;
2011-06-24 18:17:04 +02:00
if ( QMessageBox : : warning ( this , tr ( " Slow Startup " ) , message , tr ( " Discard " ) , tr ( " Don't Show Again " ) ) = = 1 )
{
m_settings - > antivirNotificationsEnabled ( false ) ;
2011-06-26 15:33:44 +02:00
actionDisableSlowStartupNotifications - > setChecked ( ! m_settings - > antivirNotificationsEnabled ( ) ) ;
2011-06-24 18:17:04 +02:00
}
}
2010-11-29 20:36:27 +01:00
//Update reminder
if ( QDate : : currentDate ( ) > = lamexp_version_date ( ) . addYears ( 1 ) )
{
qWarning ( " Binary is more than a year old, time to update! " ) ;
2011-12-18 18:19:14 +01:00
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 " ) ) ;
switch ( ret )
2010-11-29 20:36:27 +01:00
{
2011-12-18 18:19:14 +01:00
case 0 :
2011-02-18 00:53:36 +01:00
if ( checkForUpdates ( ) )
{
QApplication : : quit ( ) ;
return ;
}
2011-12-18 18:19:14 +01:00
break ;
case 1 :
2010-11-29 20:36:27 +01:00
QApplication : : quit ( ) ;
return ;
2011-12-18 18:19:14 +01:00
default :
QEventLoop loop ; QTimer : : singleShot ( 7000 , & loop , SLOT ( quit ( ) ) ) ;
PlaySound ( MAKEINTRESOURCE ( IDR_WAVE_WAITING ) , GetModuleHandle ( NULL ) , SND_RESOURCE | SND_ASYNC ) ;
m_banner - > show ( tr ( " Skipping update check this time, please be patient... " ) , & loop ) ;
break ;
2010-11-29 20:36:27 +01:00
}
}
else if ( m_settings - > autoUpdateEnabled ( ) )
{
QDate lastUpdateCheck = QDate : : fromString ( m_settings - > autoUpdateLastCheck ( ) , Qt : : ISODate ) ;
2011-09-19 18:52:02 +02:00
if ( ! firstRun & & ( ! lastUpdateCheck . isValid ( ) | | QDate : : currentDate ( ) > = lastUpdateCheck . addDays ( 14 ) ) )
2010-11-29 20:36:27 +01:00
{
2011-10-16 16:38:01 +02:00
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 )
2010-11-29 20:36:27 +01:00
{
2011-02-18 00:53:36 +01:00
if ( checkForUpdates ( ) )
{
QApplication : : quit ( ) ;
return ;
}
2010-11-29 20:36:27 +01:00
}
}
}
2010-11-11 22:58:02 +01:00
//Check for AAC support
2011-05-21 13:07:17 +02:00
if ( m_neroEncoderAvailable )
2010-11-11 22:58:02 +01:00
{
2011-05-20 19:21:09 +02:00
if ( m_settings - > neroAacNotificationsEnabled ( ) )
2010-11-12 15:58:53 +01:00
{
2010-12-19 21:23:43 +01:00
if ( lamexp_tool_version ( " neroAacEnc.exe " ) < lamexp_toolver_neroaac ( ) )
{
QString messageText ;
2011-09-17 23:08:59 +02:00
messageText + = NOBR ( tr ( " LameXP detected that your version of the Nero AAC encoder is outdated! " ) ) . append ( " <br> " ) ;
messageText + = NOBR ( tr ( " The current version available is %1 (or later), but you still have version %2 installed. " ) . arg ( lamexp_version2string ( " ?.?.?.? " , lamexp_toolver_neroaac ( ) , tr ( " n/a " ) ) , lamexp_version2string ( " ?.?.?.? " , lamexp_tool_version ( " neroAacEnc.exe " ) , tr ( " n/a " ) ) ) ) . append ( " <br><br> " ) ;
messageText + = NOBR ( tr ( " You can download the latest version of the Nero AAC encoder from the Nero website at: " ) ) . append ( " <br> " ) ;
2011-10-23 18:05:27 +02:00
messageText + = " <nobr><tt> " + LINK ( AboutDialog : : neroAacUrl ) + " </tt></nobr><br><br> " ;
messageText + = NOBR ( tr ( " (Hint: Please ignore the name of the downloaded ZIP file and check the included 'changelog.txt' instead!) " ) ) . append ( " <br> " ) ;
2010-12-28 21:26:16 +01:00
QMessageBox : : information ( this , tr ( " AAC Encoder Outdated " ) , messageText ) ;
2010-12-19 21:23:43 +01:00
}
}
2011-05-20 19:21:09 +02:00
}
else
{
2011-11-21 01:22:41 +01:00
if ( m_settings - > neroAacNotificationsEnabled ( ) & & ( ! ( m_fhgEncoderAvailable | | m_qaacEncoderAvailable ) ) )
2010-12-19 21:23:43 +01:00
{
2011-01-24 00:04:07 +01:00
QString appPath = QDir ( QCoreApplication : : applicationDirPath ( ) ) . canonicalPath ( ) ;
if ( appPath . isEmpty ( ) ) appPath = QCoreApplication : : applicationDirPath ( ) ;
2010-11-12 15:58:53 +01:00
QString messageText ;
2011-09-17 23:08:59 +02:00
messageText + = NOBR ( tr ( " The Nero AAC encoder could not be found. AAC encoding support will be disabled. " ) ) . append ( " <br> " ) ;
messageText + = NOBR ( tr ( " Please put 'neroAacEnc.exe', 'neroAacDec.exe' and 'neroAacTag.exe' into the LameXP directory! " ) ) . append ( " <br><br> " ) ;
messageText + = NOBR ( tr ( " Your LameXP directory is located here: " ) ) . append ( " <br> " ) ;
2011-10-16 16:38:01 +02:00
messageText + = QString ( " <nobr><tt>%1</tt></nobr><br><br> " ) . arg ( FSLINK ( QDir : : toNativeSeparators ( appPath ) ) ) ;
2011-09-17 23:08:59 +02:00
messageText + = NOBR ( tr ( " You can download the Nero AAC encoder for free from the official Nero website at: " ) ) . append ( " <br> " ) ;
messageText + = " <nobr><tt> " + LINK ( AboutDialog : : neroAacUrl ) + " </tt></nobr><br> " ;
2011-05-08 19:41:25 +02:00
if ( QMessageBox : : information ( this , tr ( " AAC Support Disabled " ) , messageText , tr ( " Discard " ) , tr ( " Don't Show Again " ) ) = = 1 )
{
m_settings - > neroAacNotificationsEnabled ( false ) ;
actionDisableNeroAacNotifications - > setChecked ( ! m_settings - > neroAacNotificationsEnabled ( ) ) ;
}
2010-11-12 15:58:53 +01:00
}
2010-11-11 22:58:02 +01:00
}
2010-12-12 13:44:11 +01:00
2010-11-11 22:58:02 +01:00
//Add files from the command-line
2010-11-08 19:29:36 +01:00
for ( int i = 0 ; i < arguments . count ( ) - 1 ; i + + )
{
2011-06-11 17:18:30 +02:00
QStringList addedFiles ;
2010-11-08 19:29:36 +01:00
if ( ! arguments [ i ] . compare ( " --add " , Qt : : CaseInsensitive ) )
{
QFileInfo currentFile ( arguments [ + + i ] . trimmed ( ) ) ;
2011-06-11 17:18:30 +02:00
qDebug ( " Adding file from CLI: %s " , currentFile . absoluteFilePath ( ) . toUtf8 ( ) . constData ( ) ) ;
addedFiles . append ( currentFile . absoluteFilePath ( ) ) ;
}
if ( ! addedFiles . isEmpty ( ) )
{
addFilesDelayed ( addedFiles ) ;
2010-11-08 19:29:36 +01:00
}
}
2011-06-11 17:18:30 +02:00
//Add folders from the command-line
for ( int i = 0 ; i < arguments . count ( ) - 1 ; i + + )
2010-11-08 19:29:36 +01:00
{
2011-06-11 17:18:30 +02:00
if ( ! arguments [ i ] . compare ( " --add-folder " , Qt : : CaseInsensitive ) )
{
QFileInfo currentFile ( arguments [ + + i ] . trimmed ( ) ) ;
qDebug ( " Adding folder from CLI: %s " , currentFile . absoluteFilePath ( ) . toUtf8 ( ) . constData ( ) ) ;
addFolder ( currentFile . absoluteFilePath ( ) , false , true ) ;
}
if ( ! arguments [ i ] . compare ( " --add-recursive " , Qt : : CaseInsensitive ) )
{
QFileInfo currentFile ( arguments [ + + i ] . trimmed ( ) ) ;
qDebug ( " Adding folder recursively from CLI: %s " , currentFile . absoluteFilePath ( ) . toUtf8 ( ) . constData ( ) ) ;
addFolder ( currentFile . absoluteFilePath ( ) , true , true ) ;
}
2010-11-08 19:29:36 +01:00
}
2010-12-22 22:59:00 +01:00
2011-01-29 00:40:29 +01:00
//Enable shell integration
if ( m_settings - > shellIntegrationEnabled ( ) )
{
ShellIntegration : : install ( ) ;
}
2010-12-22 22:59:00 +01:00
//Make DropBox visible
if ( m_settings - > dropBoxWidgetEnabled ( ) )
{
m_dropBox - > setVisible ( true ) ;
}
2010-11-08 19:29:36 +01:00
}
2011-09-18 02:01:45 +02:00
/*
* Show announce box
*/
void MainWindow : : showAnnounceBox ( void )
{
2012-01-24 01:19:09 +01:00
const unsigned int timeout = 8U ;
2011-10-16 16:38:01 +02:00
const QString announceText = QString ( " %1<br><br>%2<br><nobr><tt>%3</tt></nobr><br> " ) . arg
(
NOBR ( " We are still looking for LameXP translators! " ) ,
NOBR ( " If you are willing to translate LameXP to your language or to complete an existing translation, please refer to: " ) ,
LINK ( " http://mulder.brhack.net/public/doc/lamexp_translate.html " )
) ;
2012-01-24 01:19:09 +01:00
2011-09-19 18:52:02 +02:00
QMessageBox * announceBox = new QMessageBox ( QMessageBox : : Warning , " We want you! " , announceText , QMessageBox : : NoButton , this ) ;
2011-09-18 02:01:45 +02:00
announceBox - > setWindowFlags ( Qt : : Window | Qt : : WindowTitleHint | Qt : : CustomizeWindowHint ) ;
announceBox - > setIconPixmap ( QIcon ( " :/images/Announcement.png " ) . pixmap ( 64 , 79 ) ) ;
2012-01-24 01:19:09 +01:00
QTimer * timers [ timeout + 1 ] ;
QPushButton * buttons [ timeout + 1 ] ;
for ( unsigned int i = 0 ; i < = timeout ; i + + )
{
QString text = ( i > 0 ) ? QString ( " %1 (%2) " ) . arg ( tr ( " Discard " ) , QString : : number ( i ) ) : tr ( " Discard " ) ;
buttons [ i ] = announceBox - > addButton ( text , ( i > 0 ) ? QMessageBox : : NoRole : QMessageBox : : AcceptRole ) ;
}
for ( unsigned int i = 0 ; i < = timeout ; i + + )
{
buttons [ i ] - > setEnabled ( i = = 0 ) ;
buttons [ i ] - > setVisible ( i = = timeout ) ;
}
for ( unsigned int i = 0 ; i < timeout ; i + + )
{
timers [ i ] = new QTimer ( this ) ;
timers [ i ] - > setSingleShot ( true ) ;
timers [ i ] - > setInterval ( 1000 ) ;
connect ( timers [ i ] , SIGNAL ( timeout ( ) ) , buttons [ i + 1 ] , SLOT ( hide ( ) ) ) ;
connect ( timers [ i ] , SIGNAL ( timeout ( ) ) , buttons [ i ] , SLOT ( show ( ) ) ) ;
if ( i > 0 )
{
connect ( timers [ i ] , SIGNAL ( timeout ( ) ) , timers [ i - 1 ] , SLOT ( start ( ) ) ) ;
}
}
timers [ timeout - 1 ] - > start ( ) ;
announceBox - > exec ( ) ;
for ( unsigned int i = 0 ; i < timeout ; i + + )
{
timers [ i ] - > stop ( ) ;
LAMEXP_DELETE ( timers [ i ] ) ;
}
2011-09-18 02:01:45 +02:00
LAMEXP_DELETE ( announceBox ) ;
}
2011-05-21 13:07:17 +02:00
// =========================================================
// Main button solots
// =========================================================
2010-11-06 23:04:47 +01:00
/*
* Encode button
*/
void MainWindow : : encodeButtonClicked ( void )
{
2011-10-29 16:26:09 +02:00
static const unsigned __int64 oneGigabyte = 1073741824u i64 ;
static const unsigned __int64 minimumFreeDiskspaceMultiplier = 2u i64 ;
2011-05-14 18:34:34 +02:00
static const char * writeTestBuffer = " LAMEXP_WRITE_TEST " ;
2010-12-19 00:50:22 +01:00
2010-11-10 19:44:51 +01:00
ABORT_IF_BUSY ;
2010-12-28 03:57:48 +01:00
2010-11-20 02:14:22 +01:00
if ( m_fileListModel - > rowCount ( ) < 1 )
{
2011-10-16 16:38:01 +02:00
QMessageBox : : warning ( this , tr ( " LameXP " ) , NOBR ( tr ( " You must add at least one file to the list before proceeding! " ) ) ) ;
2010-11-20 02:14:22 +01:00
tabWidget - > setCurrentIndex ( 0 ) ;
return ;
}
2011-02-25 22:03:39 +01:00
QString tempFolder = m_settings - > customTempPathEnabled ( ) ? m_settings - > customTempPath ( ) : lamexp_temp_folder2 ( ) ;
if ( ! QFileInfo ( tempFolder ) . exists ( ) | | ! QFileInfo ( tempFolder ) . isDir ( ) )
{
2011-10-16 16:38:01 +02:00
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 )
2011-02-25 22:03:39 +01:00
{
while ( checkBoxUseSystemTempFolder - > isChecked ( ) = = m_settings - > customTempPathEnabledDefault ( ) ) checkBoxUseSystemTempFolder - > click ( ) ;
}
return ;
}
2010-12-19 21:23:43 +01:00
2011-10-29 16:26:09 +02:00
bool ok = false ;
unsigned __int64 currentFreeDiskspace = lamexp_free_diskspace ( tempFolder , & ok ) ;
if ( ok & & ( currentFreeDiskspace < ( oneGigabyte * minimumFreeDiskspaceMultiplier ) ) )
2010-12-19 00:50:22 +01:00
{
2011-02-25 22:03:39 +01:00
QStringList tempFolderParts = tempFolder . split ( " / " , QString : : SkipEmptyParts , Qt : : CaseInsensitive ) ;
2010-12-19 21:23:43 +01:00
tempFolderParts . takeLast ( ) ;
2010-12-20 22:13:01 +01:00
if ( m_settings - > soundsEnabled ( ) ) PlaySound ( MAKEINTRESOURCE ( IDR_WAVE_WHAMMY ) , GetModuleHandle ( NULL ) , SND_RESOURCE | SND_SYNC ) ;
2011-10-16 16:38:01 +02:00
QString lowDiskspaceMsg = QString ( " %1<br>%2<br><br>%3<br>%4<br> " ) . arg
(
NOBR ( tr ( " There are less than %1 GB of free diskspace available on your system's TEMP folder. " ) . arg ( QString : : number ( minimumFreeDiskspaceMultiplier ) ) ) ,
NOBR ( tr ( " It is highly recommend to free up more diskspace before proceeding with the encode! " ) ) ,
NOBR ( tr ( " Your TEMP folder is located at: " ) ) ,
QString ( " <nobr><tt>%1</tt></nobr> " ) . arg ( FSLINK ( tempFolderParts . join ( " \\ " ) ) )
) ;
switch ( QMessageBox : : warning ( this , tr ( " Low Diskspace Warning " ) , lowDiskspaceMsg , tr ( " Abort Encoding Process " ) , tr ( " Clean Disk Now " ) , tr ( " Ignore " ) ) )
2010-12-19 00:50:22 +01:00
{
2010-12-19 21:23:43 +01:00
case 1 :
QProcess : : startDetached ( QString ( " %1/cleanmgr.exe " ) . arg ( lamexp_known_folder ( lamexp_folder_systemfolder ) ) , QStringList ( ) < < " /D " < < tempFolderParts . first ( ) ) ;
case 0 :
2010-12-19 00:50:22 +01:00
return ;
2010-12-19 21:23:43 +01:00
break ;
default :
2012-04-16 18:52:45 +02:00
QMessageBox : : warning ( this , tr ( " Low Diskspace " ) , NOBR ( tr ( " You are proceeding with low diskspace. Problems might occur! " ) ) ) ;
2010-12-19 21:23:43 +01:00
break ;
2010-12-19 00:50:22 +01:00
}
}
2010-12-14 23:53:14 +01:00
switch ( m_settings - > compressionEncoder ( ) )
2010-11-15 21:07:58 +01:00
{
2010-12-14 23:53:14 +01:00
case SettingsModel : : MP3Encoder :
case SettingsModel : : VorbisEncoder :
case SettingsModel : : AACEncoder :
2011-05-04 01:15:05 +02:00
case SettingsModel : : AC3Encoder :
2010-12-14 23:53:14 +01:00
case SettingsModel : : FLACEncoder :
2011-12-22 21:53:25 +01:00
case SettingsModel : : DCAEncoder :
2010-12-17 01:12:12 +01:00
case SettingsModel : : PCMEncoder :
2010-12-14 23:53:14 +01:00
break ;
default :
2010-12-28 21:26:16 +01:00
QMessageBox : : warning ( this , tr ( " LameXP " ) , tr ( " Sorry, an unsupported encoder has been chosen! " ) ) ;
2010-11-15 21:07:58 +01:00
tabWidget - > setCurrentIndex ( 3 ) ;
return ;
}
2010-11-21 21:51:41 +01:00
if ( ! m_settings - > outputToSourceDir ( ) )
{
2011-05-14 18:34:34 +02:00
QFile writeTest ( QString ( " %1/~%2.txt " ) . arg ( m_settings - > outputDir ( ) , lamexp_rand_str ( ) ) ) ;
if ( ! ( writeTest . open ( QIODevice : : ReadWrite ) & & ( writeTest . write ( writeTestBuffer ) = = strlen ( writeTestBuffer ) ) ) )
2010-11-21 21:51:41 +01:00
{
2010-12-30 17:34:19 +01:00
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! " ) ) ) ;
2010-11-21 21:51:41 +01:00
tabWidget - > setCurrentIndex ( 1 ) ;
return ;
}
else
{
writeTest . close ( ) ;
writeTest . remove ( ) ;
}
}
2010-11-15 21:07:58 +01:00
2010-11-19 21:11:54 +01:00
m_accepted = true ;
close ( ) ;
}
2010-11-15 21:07:58 +01:00
2010-11-19 21:11:54 +01:00
/*
2011-05-21 13:07:17 +02:00
* About button
2010-11-06 23:04:47 +01:00
*/
2011-05-21 13:07:17 +02:00
void MainWindow : : aboutButtonClicked ( void )
2010-11-06 23:04:47 +01:00
{
2010-11-10 19:44:51 +01:00
ABORT_IF_BUSY ;
2011-04-17 15:53:28 +02:00
2011-01-02 21:46:36 +01:00
TEMP_HIDE_DROPBOX
(
2011-05-21 13:07:17 +02:00
AboutDialog * aboutBox = new AboutDialog ( m_settings , this ) ;
aboutBox - > exec ( ) ;
LAMEXP_DELETE ( aboutBox ) ;
2011-01-02 21:46:36 +01:00
)
2010-11-06 23:04:47 +01:00
}
/*
2011-05-21 13:07:17 +02:00
* Close button
2010-11-06 23:04:47 +01:00
*/
2011-05-21 13:07:17 +02:00
void MainWindow : : closeButtonClicked ( void )
2010-11-06 23:04:47 +01:00
{
2010-11-10 19:44:51 +01:00
ABORT_IF_BUSY ;
2011-05-21 13:07:17 +02:00
close ( ) ;
2010-11-06 23:04:47 +01:00
}
2011-05-21 13:07:17 +02:00
// =========================================================
// Tab widget slots
// =========================================================
2010-11-06 23:04:47 +01:00
/*
* Tab page changed
*/
void MainWindow : : tabPageChanged ( int idx )
{
2012-03-30 03:35:43 +02:00
resizeEvent ( NULL ) ;
2010-11-12 21:02:14 +01:00
QList < QAction * > actions = m_tabActionGroup - > actions ( ) ;
for ( int i = 0 ; i < actions . count ( ) ; i + + )
2010-11-06 23:04:47 +01:00
{
2011-01-03 22:24:58 +01:00
bool ok = false ;
int actionIndex = actions . at ( i ) - > data ( ) . toInt ( & ok ) ;
if ( ok & & actionIndex = = idx )
2010-11-12 21:02:14 +01:00
{
actions . at ( i ) - > setChecked ( true ) ;
}
2010-11-06 23:04:47 +01:00
}
2011-04-05 14:57:21 +02:00
int initialWidth = this - > width ( ) ;
int maximumWidth = QApplication : : desktop ( ) - > width ( ) ;
if ( this - > isVisible ( ) )
{
while ( tabWidget - > width ( ) < tabWidget - > sizeHint ( ) . width ( ) )
{
int previousWidth = this - > width ( ) ;
this - > resize ( this - > width ( ) + 1 , this - > height ( ) ) ;
if ( this - > frameGeometry ( ) . width ( ) > = maximumWidth ) break ;
if ( this - > width ( ) < = previousWidth ) break ;
}
}
if ( idx = = tabWidget - > indexOf ( tabOptions ) & & scrollArea - > widget ( ) & & this - > isVisible ( ) )
{
2011-04-08 14:05:50 +02:00
for ( int i = 0 ; i < 2 ; i + + )
2011-04-05 14:57:21 +02:00
{
2011-04-08 14:05:50 +02:00
QApplication : : processEvents ( ) ;
while ( scrollArea - > viewport ( ) - > width ( ) < scrollArea - > widget ( ) - > width ( ) )
{
int previousWidth = this - > width ( ) ;
this - > resize ( this - > width ( ) + 1 , this - > height ( ) ) ;
if ( this - > frameGeometry ( ) . width ( ) > = maximumWidth ) break ;
if ( this - > width ( ) < = previousWidth ) break ;
}
2011-04-05 14:57:21 +02:00
}
}
else if ( idx = = tabWidget - > indexOf ( tabSourceFiles ) )
2011-03-28 04:26:47 +02:00
{
m_dropNoteLabel - > setGeometry ( 0 , 0 , sourceFileView - > width ( ) , sourceFileView - > height ( ) ) ;
}
2011-06-04 22:43:14 +02:00
else if ( idx = = tabWidget - > indexOf ( tabOutputDir ) )
{
2012-04-05 15:24:45 +02:00
if ( ! m_fileSystemModel )
2011-06-04 22:43:14 +02:00
{
2012-03-29 01:32:47 +02:00
QTimer : : singleShot ( 125 , this , SLOT ( initOutputFolderModel ( ) ) ) ;
2011-06-04 22:43:14 +02:00
}
2012-03-28 02:21:34 +02:00
else
{
2012-03-29 19:08:33 +02:00
CENTER_CURRENT_OUTPUT_FOLDER_DELAYED ;
2012-03-28 02:21:34 +02:00
}
2011-06-04 22:43:14 +02:00
}
2011-04-05 14:57:21 +02:00
if ( initialWidth < this - > width ( ) )
{
QPoint prevPos = this - > pos ( ) ;
int delta = ( this - > width ( ) - initialWidth ) > > 2 ;
move ( prevPos . x ( ) - delta , prevPos . y ( ) ) ;
}
2010-11-06 23:04:47 +01:00
}
/*
* Tab action triggered
*/
void MainWindow : : tabActionActivated ( QAction * action )
{
2011-01-03 22:24:58 +01:00
if ( action & & action - > data ( ) . isValid ( ) )
2010-11-06 23:04:47 +01:00
{
2011-01-03 22:24:58 +01:00
bool ok = false ;
int index = action - > data ( ) . toInt ( & ok ) ;
if ( ok )
{
tabWidget - > setCurrentIndex ( index ) ;
}
2010-11-06 23:04:47 +01:00
}
}
2011-05-21 13:07:17 +02:00
// =========================================================
// View menu slots
// =========================================================
2010-11-08 00:24:54 +01:00
/*
* Style action triggered
*/
void MainWindow : : styleActionActivated ( QAction * action )
{
2011-02-11 23:16:11 +01:00
//Change style setting
2011-01-03 22:24:58 +01:00
if ( action & & action - > data ( ) . isValid ( ) )
2010-11-12 21:02:14 +01:00
{
2011-01-03 22:24:58 +01:00
bool ok = false ;
int actionIndex = action - > data ( ) . toInt ( & ok ) ;
2011-02-11 23:16:11 +01:00
if ( ok )
{
m_settings - > interfaceStyle ( actionIndex ) ;
}
2010-11-12 21:02:14 +01:00
}
2011-02-11 23:16:11 +01:00
//Set up the new style
2010-11-12 21:02:14 +01:00
switch ( m_settings - > interfaceStyle ( ) )
{
case 1 :
2011-01-02 20:47:26 +01:00
if ( actionStyleCleanlooks - > isEnabled ( ) )
{
actionStyleCleanlooks - > setChecked ( true ) ;
QApplication : : setStyle ( new QCleanlooksStyle ( ) ) ;
break ;
}
2010-11-12 21:02:14 +01:00
case 2 :
2011-01-02 20:47:26 +01:00
if ( actionStyleWindowsVista - > isEnabled ( ) )
{
actionStyleWindowsVista - > setChecked ( true ) ;
QApplication : : setStyle ( new QWindowsVistaStyle ( ) ) ;
break ;
}
2010-11-12 21:02:14 +01:00
case 3 :
2011-01-02 20:47:26 +01:00
if ( actionStyleWindowsXP - > isEnabled ( ) )
{
actionStyleWindowsXP - > setChecked ( true ) ;
QApplication : : setStyle ( new QWindowsXPStyle ( ) ) ;
break ;
}
2010-11-12 21:02:14 +01:00
case 4 :
2011-01-02 20:47:26 +01:00
if ( actionStyleWindowsClassic - > isEnabled ( ) )
{
actionStyleWindowsClassic - > setChecked ( true ) ;
QApplication : : setStyle ( new QWindowsStyle ( ) ) ;
break ;
}
2010-11-12 21:02:14 +01:00
default :
actionStylePlastique - > setChecked ( true ) ;
QApplication : : setStyle ( new QPlastiqueStyle ( ) ) ;
break ;
}
2011-02-11 23:16:11 +01:00
//Force re-translate after style change
2012-04-06 23:15:58 +02:00
if ( QEvent * e = new QEvent ( QEvent : : LanguageChange ) )
{
changeEvent ( e ) ;
LAMEXP_DELETE ( e ) ;
}
2010-11-08 00:24:54 +01:00
}
2010-12-28 03:57:48 +01:00
/*
* Language action triggered
*/
void MainWindow : : languageActionActivated ( QAction * action )
{
2011-01-06 00:53:52 +01:00
if ( action - > data ( ) . type ( ) = = QVariant : : String )
{
QString langId = action - > data ( ) . toString ( ) ;
if ( lamexp_install_translator ( langId ) )
{
action - > setChecked ( true ) ;
m_settings - > currentLanguage ( langId ) ;
}
}
}
2010-12-30 16:12:21 +01:00
2011-01-06 00:53:52 +01:00
/*
* Load language from file action triggered
*/
void MainWindow : : languageFromFileActionActivated ( bool checked )
{
QFileDialog dialog ( this , tr ( " Load Translation " ) ) ;
dialog . setFileMode ( QFileDialog : : ExistingFile ) ;
dialog . setNameFilter ( QString ( " %1 (*.qm) " ) . arg ( tr ( " Translation Files " ) ) ) ;
if ( dialog . exec ( ) )
2010-12-28 21:26:16 +01:00
{
2011-01-06 00:53:52 +01:00
QStringList selectedFiles = dialog . selectedFiles ( ) ;
if ( lamexp_install_translator_from_file ( selectedFiles . first ( ) ) )
{
QList < QAction * > actions = m_languageActionGroup - > actions ( ) ;
while ( ! actions . isEmpty ( ) )
{
actions . takeFirst ( ) - > setChecked ( false ) ;
}
}
else
{
languageActionActivated ( m_languageActionGroup - > actions ( ) . first ( ) ) ;
}
2010-12-28 21:26:16 +01:00
}
2010-12-28 03:57:48 +01:00
}
2011-05-21 13:07:17 +02:00
// =========================================================
// Tools menu slots
// =========================================================
2010-11-06 23:04:47 +01:00
/*
2011-05-21 13:07:17 +02:00
* Disable update reminder action
2010-11-06 23:04:47 +01:00
*/
2011-05-21 13:07:17 +02:00
void MainWindow : : disableUpdateReminderActionTriggered ( bool checked )
2010-11-06 23:04:47 +01:00
{
2011-05-21 13:07:17 +02:00
if ( checked )
2010-12-17 01:12:12 +01:00
{
2011-10-22 01:13:28 +02:00
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 ) )
2011-05-21 13:07:17 +02:00
{
2011-10-22 01:13:28 +02:00
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! " ) ) ) ) ;
2011-05-21 13:07:17 +02:00
m_settings - > autoUpdateEnabled ( false ) ;
}
else
{
m_settings - > autoUpdateEnabled ( true ) ;
}
2010-12-17 01:12:12 +01:00
}
2011-05-21 13:07:17 +02:00
else
2010-12-27 18:31:21 +01:00
{
2011-10-22 01:13:28 +02:00
QMessageBox : : information ( this , tr ( " Update Reminder " ) , NOBR ( tr ( " The update reminder has been re-enabled. " ) ) ) ;
2011-05-21 13:07:17 +02:00
m_settings - > autoUpdateEnabled ( true ) ;
2010-12-27 18:31:21 +01:00
}
2011-05-21 13:07:17 +02:00
actionDisableUpdateReminder - > setChecked ( ! m_settings - > autoUpdateEnabled ( ) ) ;
2010-12-27 18:31:21 +01:00
}
2010-11-06 23:04:47 +01:00
/*
2011-05-21 13:07:17 +02:00
* Disable sound effects action
2010-11-06 23:04:47 +01:00
*/
2011-05-21 13:07:17 +02:00
void MainWindow : : disableSoundsActionTriggered ( bool checked )
2010-11-06 23:04:47 +01:00
{
2011-05-21 13:07:17 +02:00
if ( checked )
2010-12-28 03:57:48 +01:00
{
2011-10-22 01:13:28 +02:00
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 ) )
2011-05-21 13:07:17 +02:00
{
2011-10-22 01:13:28 +02:00
QMessageBox : : information ( this , tr ( " Sound Effects " ) , NOBR ( tr ( " All sound effects have been disabled. " ) ) ) ;
2011-05-21 13:07:17 +02:00
m_settings - > soundsEnabled ( false ) ;
}
else
{
m_settings - > soundsEnabled ( true ) ;
}
2010-12-28 03:57:48 +01:00
}
else
{
2011-10-22 01:13:28 +02:00
QMessageBox : : information ( this , tr ( " Sound Effects " ) , NOBR ( tr ( " The sound effects have been re-enabled. " ) ) ) ;
2011-05-21 13:07:17 +02:00
m_settings - > soundsEnabled ( true ) ;
2010-12-28 03:57:48 +01:00
}
2011-05-21 13:07:17 +02:00
actionDisableSounds - > setChecked ( ! m_settings - > soundsEnabled ( ) ) ;
2010-11-06 23:04:47 +01:00
}
/*
2011-05-21 13:07:17 +02:00
* Disable Nero AAC encoder action
2010-11-06 23:04:47 +01:00
*/
2011-05-21 13:07:17 +02:00
void MainWindow : : disableNeroAacNotificationsActionTriggered ( bool checked )
2010-11-06 23:04:47 +01:00
{
2011-05-21 13:07:17 +02:00
if ( checked )
2010-12-28 03:57:48 +01:00
{
2011-10-22 01:13:28 +02:00
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 ) )
2011-05-21 13:07:17 +02:00
{
2011-10-22 01:13:28 +02:00
QMessageBox : : information ( this , tr ( " Nero AAC Notifications " ) , NOBR ( tr ( " All Nero AAC Encoder notifications have been disabled. " ) ) ) ;
2011-05-21 13:07:17 +02:00
m_settings - > neroAacNotificationsEnabled ( false ) ;
}
else
{
m_settings - > neroAacNotificationsEnabled ( true ) ;
}
2010-12-28 03:57:48 +01:00
}
else
{
2011-10-22 01:13:28 +02:00
QMessageBox : : information ( this , tr ( " Nero AAC Notifications " ) , NOBR ( tr ( " The Nero AAC Encoder notifications have been re-enabled. " ) ) ) ;
2011-05-21 13:07:17 +02:00
m_settings - > neroAacNotificationsEnabled ( true ) ;
2010-12-28 03:57:48 +01:00
}
2011-05-21 13:07:17 +02:00
actionDisableNeroAacNotifications - > setChecked ( ! m_settings - > neroAacNotificationsEnabled ( ) ) ;
2010-11-06 23:04:47 +01:00
}
2011-06-26 15:33:44 +02:00
/*
* Disable slow startup action
*/
void MainWindow : : disableSlowStartupNotificationsActionTriggered ( bool checked )
{
if ( checked )
{
2011-10-22 01:13:28 +02:00
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 ) )
2011-06-26 15:33:44 +02:00
{
2011-10-22 01:13:28 +02:00
QMessageBox : : information ( this , tr ( " Slow Startup Notifications " ) , NOBR ( tr ( " The slow startup notifications have been disabled. " ) ) ) ;
2011-06-26 15:33:44 +02:00
m_settings - > antivirNotificationsEnabled ( false ) ;
}
else
{
m_settings - > antivirNotificationsEnabled ( true ) ;
}
}
else
{
2011-10-22 01:13:28 +02:00
QMessageBox : : information ( this , tr ( " Slow Startup Notifications " ) , NOBR ( tr ( " The slow startup notifications have been re-enabled. " ) ) ) ;
2011-06-26 15:33:44 +02:00
m_settings - > antivirNotificationsEnabled ( true ) ;
}
actionDisableSlowStartupNotifications - > setChecked ( ! m_settings - > antivirNotificationsEnabled ( ) ) ;
}
2011-05-21 13:07:17 +02:00
/*
* Import a Cue Sheet file
*/
void MainWindow : : importCueSheetActionTriggered ( bool checked )
{
ABORT_IF_BUSY ;
TEMP_HIDE_DROPBOX
(
2011-09-29 17:36:38 +02:00
while ( true )
2011-08-23 18:48:16 +02:00
{
2011-09-29 17:36:38 +02:00
int result = 0 ;
QString selectedCueFile ;
if ( USE_NATIVE_FILE_DIALOG )
2011-08-23 18:48:16 +02:00
{
2011-09-29 17:36:38 +02:00
selectedCueFile = QFileDialog : : getOpenFileName ( this , tr ( " Open Cue Sheet " ) , m_settings - > mostRecentInputPath ( ) , QString ( " %1 (*.cue) " ) . arg ( tr ( " Cue Sheet File " ) ) ) ;
}
else
{
QFileDialog dialog ( this , tr ( " Open Cue Sheet " ) ) ;
dialog . setFileMode ( QFileDialog : : ExistingFile ) ;
dialog . setNameFilter ( QString ( " %1 (*.cue) " ) . arg ( tr ( " Cue Sheet File " ) ) ) ;
dialog . setDirectory ( m_settings - > mostRecentInputPath ( ) ) ;
if ( dialog . exec ( ) )
{
selectedCueFile = dialog . selectedFiles ( ) . first ( ) ;
}
2011-08-23 18:48:16 +02:00
}
2011-09-29 17:36:38 +02:00
if ( ! selectedCueFile . isEmpty ( ) )
{
m_settings - > mostRecentInputPath ( QFileInfo ( selectedCueFile ) . canonicalPath ( ) ) ;
CueImportDialog * cueImporter = new CueImportDialog ( this , m_fileListModel , selectedCueFile ) ;
result = cueImporter - > exec ( ) ;
LAMEXP_DELETE ( cueImporter ) ;
}
if ( result ! = ( - 1 ) ) break ;
2011-05-21 13:07:17 +02:00
}
)
}
/*
* Show the " drop box " widget
*/
void MainWindow : : showDropBoxWidgetActionTriggered ( bool checked )
{
m_settings - > dropBoxWidgetEnabled ( true ) ;
if ( ! m_dropBox - > isVisible ( ) )
2010-12-10 22:57:48 +01:00
{
2011-05-21 13:07:17 +02:00
m_dropBox - > show ( ) ;
2010-12-10 22:57:48 +01:00
}
2011-05-21 13:07:17 +02:00
lamexp_blink_window ( m_dropBox ) ;
}
/*
* Check for beta ( pre - release ) updates
*/
void MainWindow : : checkForBetaUpdatesActionTriggered ( bool checked )
{
bool checkUpdatesNow = false ;
if ( checked )
2010-12-10 22:57:48 +01:00
{
2011-10-22 01:13:28 +02:00
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 ) )
2010-11-06 23:04:47 +01:00
{
2011-10-22 01:13:28 +02:00
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 " ) ) )
2010-11-06 23:04:47 +01:00
{
2011-05-21 13:07:17 +02:00
checkUpdatesNow = true ;
2010-11-06 23:04:47 +01:00
}
2011-05-21 13:07:17 +02:00
m_settings - > autoUpdateCheckBeta ( true ) ;
}
else
{
m_settings - > autoUpdateCheckBeta ( false ) ;
2010-11-06 23:04:47 +01:00
}
2010-12-10 22:57:48 +01:00
}
2011-05-21 13:07:17 +02:00
else
2010-12-10 22:57:48 +01:00
{
2011-10-22 01:13:28 +02:00
QMessageBox : : information ( this , tr ( " Beta Updates " ) , NOBR ( tr ( " LameXP will <i>not</i> check for Beta (pre-release) updates from now on. " ) ) ) ;
2011-05-21 13:07:17 +02:00
m_settings - > autoUpdateCheckBeta ( false ) ;
}
2010-12-10 22:57:48 +01:00
2011-05-21 13:07:17 +02:00
actionCheckForBetaUpdates - > setChecked ( m_settings - > autoUpdateCheckBeta ( ) ) ;
2010-12-10 22:57:48 +01:00
2011-05-21 13:07:17 +02:00
if ( checkUpdatesNow )
{
if ( checkForUpdates ( ) )
{
QApplication : : quit ( ) ;
2010-11-06 23:04:47 +01:00
}
}
}
2011-10-22 01:13:28 +02:00
/*
* Hibernate computer action
*/
void MainWindow : : hibernateComputerActionTriggered ( bool checked )
{
if ( checked )
{
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 ) )
{
QMessageBox : : information ( this , tr ( " Hibernate Computer " ) , NOBR ( tr ( " LameXP will hibernate the computer on shutdown from now on. " ) ) ) ;
m_settings - > hibernateComputer ( true ) ;
}
else
{
m_settings - > hibernateComputer ( false ) ;
}
}
else
{
QMessageBox : : information ( this , tr ( " Hibernate Computer " ) , NOBR ( tr ( " LameXP will <i>not</i> hibernate the computer on shutdown from now on. " ) ) ) ;
m_settings - > hibernateComputer ( false ) ;
}
actionHibernateComputer - > setChecked ( m_settings - > hibernateComputer ( ) ) ;
}
2010-11-10 19:44:51 +01:00
/*
2011-05-21 13:07:17 +02:00
* Disable shell integration action
2010-11-10 19:44:51 +01:00
*/
2011-05-21 13:07:17 +02:00
void MainWindow : : disableShellIntegrationActionTriggered ( bool checked )
2010-11-10 19:44:51 +01:00
{
2011-05-21 13:07:17 +02:00
if ( checked )
2011-02-10 16:08:03 +01:00
{
2011-10-22 01:13:28 +02:00
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 ) )
2011-05-20 18:13:08 +02:00
{
2011-05-21 13:07:17 +02:00
ShellIntegration : : remove ( ) ;
2011-10-22 01:13:28 +02:00
QMessageBox : : information ( this , tr ( " Shell Integration " ) , NOBR ( tr ( " The LameXP shell integration has been disabled. " ) ) ) ;
2011-05-21 13:07:17 +02:00
m_settings - > shellIntegrationEnabled ( false ) ;
}
else
{
m_settings - > shellIntegrationEnabled ( true ) ;
2011-05-20 18:13:08 +02:00
}
2011-02-10 16:08:03 +01:00
}
2011-05-21 13:07:17 +02:00
else
{
ShellIntegration : : install ( ) ;
2011-10-22 01:13:28 +02:00
QMessageBox : : information ( this , tr ( " Shell Integration " ) , NOBR ( tr ( " The LameXP shell integration has been re-enabled. " ) ) ) ;
2011-05-21 13:07:17 +02:00
m_settings - > shellIntegrationEnabled ( true ) ;
}
2010-11-10 19:44:51 +01:00
2011-05-21 13:07:17 +02:00
actionDisableShellIntegration - > setChecked ( ! m_settings - > shellIntegrationEnabled ( ) ) ;
if ( lamexp_portable_mode ( ) & & actionDisableShellIntegration - > isChecked ( ) )
{
actionDisableShellIntegration - > setEnabled ( false ) ;
}
2010-11-10 19:44:51 +01:00
}
2010-11-06 23:04:47 +01:00
2011-05-21 13:07:17 +02:00
// =========================================================
// Help menu slots
// =========================================================
2010-11-06 23:04:47 +01:00
/*
* Visit homepage action
*/
void MainWindow : : visitHomepageActionActivated ( void )
{
2011-03-20 14:28:27 +01:00
if ( QAction * action = dynamic_cast < QAction * > ( QObject : : sender ( ) ) )
{
if ( action - > data ( ) . isValid ( ) & & ( action - > data ( ) . type ( ) = = QVariant : : String ) )
{
QDesktopServices : : openUrl ( QUrl ( action - > data ( ) . toString ( ) ) ) ;
}
}
2010-11-06 23:04:47 +01:00
}
2011-03-19 18:16:23 +01:00
/*
* Show document
*/
void MainWindow : : documentActionActivated ( void )
{
if ( QAction * action = dynamic_cast < QAction * > ( QObject : : sender ( ) ) )
{
if ( action - > data ( ) . isValid ( ) & & ( action - > data ( ) . type ( ) = = QVariant : : String ) )
{
QFileInfo document ( action - > data ( ) . toString ( ) ) ;
QFileInfo resource ( QString ( " :/doc/%1.html " ) . arg ( document . baseName ( ) ) ) ;
if ( document . exists ( ) & & document . isFile ( ) & & ( document . size ( ) = = resource . size ( ) ) )
{
2011-03-20 14:28:27 +01:00
QDesktopServices : : openUrl ( QUrl : : fromLocalFile ( document . canonicalFilePath ( ) ) ) ;
2011-03-19 18:16:23 +01:00
}
else
{
QFile source ( resource . filePath ( ) ) ;
QFile output ( QString ( " %1/%2.%3.html " ) . arg ( lamexp_temp_folder2 ( ) , document . baseName ( ) , lamexp_rand_str ( ) . left ( 8 ) ) ) ;
if ( source . open ( QIODevice : : ReadOnly ) & & output . open ( QIODevice : : ReadWrite ) )
{
output . write ( source . readAll ( ) ) ;
action - > setData ( output . fileName ( ) ) ;
source . close ( ) ;
output . close ( ) ;
2011-03-20 14:28:27 +01:00
QDesktopServices : : openUrl ( QUrl : : fromLocalFile ( output . fileName ( ) ) ) ;
2011-03-19 18:16:23 +01:00
}
}
}
}
}
2010-11-06 23:04:47 +01:00
/*
* Check for updates action
*/
void MainWindow : : checkUpdatesActionActivated ( void )
{
2010-11-10 19:44:51 +01:00
ABORT_IF_BUSY ;
2011-02-18 16:29:26 +01:00
bool bFlag = false ;
2011-01-02 21:46:36 +01:00
TEMP_HIDE_DROPBOX
(
2011-02-18 16:29:26 +01:00
bFlag = checkForUpdates ( ) ;
2011-01-02 21:46:36 +01:00
)
2011-02-18 16:29:26 +01:00
if ( bFlag )
{
QApplication : : quit ( ) ;
}
2010-11-06 23:04:47 +01:00
}
2011-05-21 13:07:17 +02:00
// =========================================================
// Source file slots
// =========================================================
2010-11-08 21:47:35 +01:00
/*
2011-05-21 13:07:17 +02:00
* Add file ( s ) button
2010-11-08 21:47:35 +01:00
*/
2011-05-21 13:07:17 +02:00
void MainWindow : : addFilesButtonClicked ( void )
2010-11-08 21:47:35 +01:00
{
2011-05-21 13:07:17 +02:00
ABORT_IF_BUSY ;
TEMP_HIDE_DROPBOX
(
2011-08-23 18:48:16 +02:00
if ( USE_NATIVE_FILE_DIALOG )
2011-05-21 13:07:17 +02:00
{
QStringList fileTypeFilters = DecoderRegistry : : getSupportedTypes ( ) ;
2011-08-23 18:48:16 +02:00
QStringList selectedFiles = QFileDialog : : getOpenFileNames ( this , tr ( " Add file(s) " ) , m_settings - > mostRecentInputPath ( ) , fileTypeFilters . join ( " ;; " ) ) ;
2011-05-21 13:07:17 +02:00
if ( ! selectedFiles . isEmpty ( ) )
{
2011-08-23 18:48:16 +02:00
m_settings - > mostRecentInputPath ( QFileInfo ( selectedFiles . first ( ) ) . canonicalPath ( ) ) ;
2011-05-21 13:07:17 +02:00
addFiles ( selectedFiles ) ;
}
}
else
{
QFileDialog dialog ( this , tr ( " Add file(s) " )) ;
QStringList fileTypeFilters = DecoderRegistry : : getSupportedTypes ( ) ;
dialog . setFileMode ( QFileDialog : : ExistingFiles ) ;
dialog . setNameFilter ( fileTypeFilters . join ( " ;; " ) ) ;
2011-08-23 18:48:16 +02:00
dialog . setDirectory ( m_settings - > mostRecentInputPath ( ) ) ;
2011-05-21 13:07:17 +02:00
if ( dialog . exec ( ) )
{
QStringList selectedFiles = dialog . selectedFiles ( ) ;
2011-08-23 18:48:16 +02:00
if ( ! selectedFiles . isEmpty ( ) )
{
m_settings - > mostRecentInputPath ( QFileInfo ( selectedFiles . first ( ) ) . canonicalPath ( ) ) ;
addFiles ( selectedFiles ) ;
}
2011-05-21 13:07:17 +02:00
}
}
)
2010-11-08 21:47:35 +01:00
}
/*
2011-05-21 13:07:17 +02:00
* Open folder action
2010-11-08 21:47:35 +01:00
*/
2011-05-21 13:07:17 +02:00
void MainWindow : : openFolderActionActivated ( void )
{
ABORT_IF_BUSY ;
QString selectedFolder ;
if ( QAction * action = dynamic_cast < QAction * > ( QObject : : sender ( ) ) )
{
TEMP_HIDE_DROPBOX
(
2011-08-23 18:48:16 +02:00
if ( USE_NATIVE_FILE_DIALOG )
2011-05-21 13:07:17 +02:00
{
2011-08-23 18:48:16 +02:00
selectedFolder = QFileDialog : : getExistingDirectory ( this , tr ( " Add Folder " ) , m_settings - > mostRecentInputPath ( ) ) ;
2011-05-21 13:07:17 +02:00
}
else
{
QFileDialog dialog ( this , tr ( " Add Folder " ) ) ;
dialog . setFileMode ( QFileDialog : : DirectoryOnly ) ;
2011-08-23 18:48:16 +02:00
dialog . setDirectory ( m_settings - > mostRecentInputPath ( ) ) ;
2011-05-21 13:07:17 +02:00
if ( dialog . exec ( ) )
{
selectedFolder = dialog . selectedFiles ( ) . first ( ) ;
}
}
if ( ! selectedFolder . isEmpty ( ) )
{
2011-08-23 18:48:16 +02:00
m_settings - > mostRecentInputPath ( QDir ( selectedFolder ) . canonicalPath ( ) ) ;
2011-05-21 13:07:17 +02:00
addFolder ( selectedFolder , action - > data ( ) . toBool ( ) ) ;
}
)
}
}
/*
* Remove file button
*/
void MainWindow : : removeFileButtonClicked ( void )
{
if ( sourceFileView - > currentIndex ( ) . isValid ( ) )
{
int iRow = sourceFileView - > currentIndex ( ) . row ( ) ;
m_fileListModel - > removeFile ( sourceFileView - > currentIndex ( ) ) ;
sourceFileView - > selectRow ( iRow < m_fileListModel - > rowCount ( ) ? iRow : m_fileListModel - > rowCount ( ) - 1 ) ;
}
}
/*
* Clear files button
*/
void MainWindow : : clearFilesButtonClicked ( void )
{
m_fileListModel - > clearFiles ( ) ;
}
/*
* Move file up button
*/
void MainWindow : : fileUpButtonClicked ( void )
{
if ( sourceFileView - > currentIndex ( ) . isValid ( ) )
{
int iRow = sourceFileView - > currentIndex ( ) . row ( ) - 1 ;
m_fileListModel - > moveFile ( sourceFileView - > currentIndex ( ) , - 1 ) ;
sourceFileView - > selectRow ( iRow > = 0 ? iRow : 0 ) ;
}
}
/*
* Move file down button
*/
void MainWindow : : fileDownButtonClicked ( void )
{
if ( sourceFileView - > currentIndex ( ) . isValid ( ) )
{
int iRow = sourceFileView - > currentIndex ( ) . row ( ) + 1 ;
m_fileListModel - > moveFile ( sourceFileView - > currentIndex ( ) , 1 ) ;
sourceFileView - > selectRow ( iRow < m_fileListModel - > rowCount ( ) ? iRow : m_fileListModel - > rowCount ( ) - 1 ) ;
}
}
/*
* Show details button
*/
void MainWindow : : showDetailsButtonClicked ( void )
{
ABORT_IF_BUSY ;
int iResult = 0 ;
MetaInfoDialog * metaInfoDialog = new MetaInfoDialog ( this ) ;
QModelIndex index = sourceFileView - > currentIndex ( ) ;
while ( index . isValid ( ) )
{
if ( iResult > 0 )
{
index = m_fileListModel - > index ( index . row ( ) + 1 , index . column ( ) ) ;
sourceFileView - > selectRow ( index . row ( ) ) ;
}
if ( iResult < 0 )
{
index = m_fileListModel - > index ( index . row ( ) - 1 , index . column ( ) ) ;
sourceFileView - > selectRow ( index . row ( ) ) ;
}
AudioFileModel & file = ( * m_fileListModel ) [ index ] ;
TEMP_HIDE_DROPBOX
(
iResult = metaInfoDialog - > exec ( file , index . row ( ) > 0 , index . row ( ) < m_fileListModel - > rowCount ( ) - 1 ) ;
)
2011-05-31 19:04:45 +02:00
if ( iResult = = INT_MAX )
{
m_metaInfoModel - > assignInfoFrom ( file ) ;
tabWidget - > setCurrentIndex ( tabWidget - > indexOf ( tabMetaData ) ) ;
break ;
}
2011-05-21 13:07:17 +02:00
if ( ! iResult ) break ;
}
LAMEXP_DELETE ( metaInfoDialog ) ;
2011-12-17 22:01:42 +01:00
QApplication : : processEvents ( QEventLoop : : ExcludeUserInputEvents ) ;
sourceFilesScrollbarMoved ( 0 ) ;
2011-05-21 13:07:17 +02:00
}
/*
* Show context menu for source files
*/
void MainWindow : : sourceFilesContextMenu ( const QPoint & pos )
{
QAbstractScrollArea * scrollArea = dynamic_cast < QAbstractScrollArea * > ( QObject : : sender ( ) ) ;
QWidget * sender = scrollArea ? scrollArea - > viewport ( ) : dynamic_cast < QWidget * > ( QObject : : sender ( ) ) ;
if ( sender )
{
if ( pos . x ( ) < = sender - > width ( ) & & pos . y ( ) < = sender - > height ( ) & & pos . x ( ) > = 0 & & pos . y ( ) > = 0 )
{
m_sourceFilesContextMenu - > popup ( sender - > mapToGlobal ( pos ) ) ;
}
}
}
2011-08-23 17:01:11 +02:00
/*
* Scrollbar of source files moved
*/
void MainWindow : : sourceFilesScrollbarMoved ( int )
{
sourceFileView - > resizeColumnToContents ( 0 ) ;
}
2011-05-21 13:07:17 +02:00
/*
* Open selected file in external player
*/
void MainWindow : : previewContextActionTriggered ( void )
{
const static char * appNames [ 3 ] = { " smplayer_portable.exe " , " smplayer.exe " , " mplayer.exe " } ;
const static wchar_t * registryKey = L " SOFTWARE \\ Wow6432Node \\ Microsoft \\ Windows \\ CurrentVersion \\ Uninstall \\ {DB9E4EAB-2717-499F-8D56-4CC8A644AB60} " ;
QModelIndex index = sourceFileView - > currentIndex ( ) ;
if ( ! index . isValid ( ) )
{
return ;
}
QString mplayerPath ;
HKEY registryKeyHandle ;
if ( RegOpenKeyExW ( HKEY_LOCAL_MACHINE , registryKey , 0 , KEY_READ , & registryKeyHandle ) = = ERROR_SUCCESS )
{
wchar_t Buffer [ 4096 ] ;
DWORD BuffSize = sizeof ( wchar_t * ) * 4096 ;
if ( RegQueryValueExW ( registryKeyHandle , L " InstallLocation " , 0 , 0 , reinterpret_cast < BYTE * > ( Buffer ) , & BuffSize ) = = ERROR_SUCCESS )
{
mplayerPath = QString : : fromUtf16 ( reinterpret_cast < const unsigned short * > ( Buffer ) ) ;
}
}
if ( ! mplayerPath . isEmpty ( ) )
{
QDir mplayerDir ( mplayerPath ) ;
if ( mplayerDir . exists ( ) )
{
for ( int i = 0 ; i < 3 ; i + + )
{
if ( mplayerDir . exists ( appNames [ i ] ) )
{
QProcess : : startDetached ( mplayerDir . absoluteFilePath ( appNames [ i ] ) , QStringList ( ) < < QDir : : toNativeSeparators ( m_fileListModel - > getFile ( index ) . filePath ( ) ) ) ;
return ;
}
}
}
}
QDesktopServices : : openUrl ( QString ( " file:/// " ) . append ( m_fileListModel - > getFile ( index ) . filePath ( ) ) ) ;
}
/*
* Find selected file in explorer
*/
void MainWindow : : findFileContextActionTriggered ( void )
{
QModelIndex index = sourceFileView - > currentIndex ( ) ;
if ( index . isValid ( ) )
{
QString systemRootPath ;
QDir systemRoot ( lamexp_known_folder ( lamexp_folder_systemfolder ) ) ;
if ( systemRoot . exists ( ) & & systemRoot . cdUp ( ) )
{
systemRootPath = systemRoot . canonicalPath ( ) ;
}
if ( ! systemRootPath . isEmpty ( ) )
{
QFileInfo explorer ( QString ( " %1/explorer.exe " ) . arg ( systemRootPath ) ) ;
if ( explorer . exists ( ) & & explorer . isFile ( ) )
{
QProcess : : execute ( explorer . canonicalFilePath ( ) , QStringList ( ) < < " /select, " < < QDir : : toNativeSeparators ( m_fileListModel - > getFile ( index ) . filePath ( ) ) ) ;
return ;
}
}
else
{
qWarning ( " SystemRoot directory could not be detected! " ) ;
}
}
}
/*
* Add all pending files
*/
void MainWindow : : handleDelayedFiles ( void )
2010-11-08 21:47:35 +01:00
{
2011-06-11 17:18:30 +02:00
m_delayedFileTimer - > stop ( ) ;
if ( m_delayedFileList - > isEmpty ( ) )
2010-11-08 21:47:35 +01:00
{
return ;
}
2011-06-11 17:18:30 +02:00
if ( m_banner - > isVisible ( ) )
2010-11-08 21:47:35 +01:00
{
2011-06-11 17:18:30 +02:00
m_delayedFileTimer - > start ( 5000 ) ;
2010-11-08 21:47:35 +01:00
return ;
}
QStringList selectedFiles ;
2010-11-10 00:59:50 +01:00
tabWidget - > setCurrentIndex ( 0 ) ;
2010-11-08 21:47:35 +01:00
while ( ! m_delayedFileList - > isEmpty ( ) )
{
2010-11-13 02:11:15 +01:00
QFileInfo currentFile = QFileInfo ( m_delayedFileList - > takeFirst ( ) ) ;
2011-06-11 17:18:30 +02:00
if ( ! currentFile . exists ( ) | | ! currentFile . isFile ( ) )
2010-11-13 02:11:15 +01:00
{
continue ;
}
2011-06-11 17:18:30 +02:00
selectedFiles < < currentFile . canonicalFilePath ( ) ;
2010-11-08 21:47:35 +01:00
}
2010-11-11 19:37:16 +01:00
addFiles ( selectedFiles ) ;
2010-11-08 21:47:35 +01:00
}
2010-11-11 22:58:02 +01:00
2012-01-04 21:10:33 +01:00
/*
* Export Meta tags to CSV file
*/
2012-01-04 03:23:07 +01:00
void MainWindow : : exportCsvContextActionTriggered ( void )
{
TEMP_HIDE_DROPBOX
(
QString selectedCsvFile ;
if ( USE_NATIVE_FILE_DIALOG )
{
selectedCsvFile = QFileDialog : : getSaveFileName ( this , tr ( " Save CSV file " ) , m_settings - > mostRecentInputPath ( ) , QString ( " %1 (*.csv) " ) . arg ( tr ( " CSV File " ) ) ) ;
}
else
{
QFileDialog dialog ( this , tr ( " Save CSV file " ) ) ;
dialog . setFileMode ( QFileDialog : : AnyFile ) ;
dialog . setAcceptMode ( QFileDialog : : AcceptSave ) ;
dialog . setNameFilter ( QString ( " %1 (*.csv) " ) . arg ( tr ( " CSV File " ) ) ) ;
dialog . setDirectory ( m_settings - > mostRecentInputPath ( ) ) ;
if ( dialog . exec ( ) )
{
selectedCsvFile = dialog . selectedFiles ( ) . first ( ) ;
}
}
if ( ! selectedCsvFile . isEmpty ( ) )
{
m_settings - > mostRecentInputPath ( QFileInfo ( selectedCsvFile ) . canonicalPath ( ) ) ;
switch ( m_fileListModel - > exportToCsv ( selectedCsvFile ) )
{
2012-01-04 21:10:33 +01:00
case FileListModel : : CsvError_NoTags :
QMessageBox : : critical ( this , tr ( " CSV Export " ) , NOBR ( tr ( " Sorry, there are no meta tags that can be exported! " ) ) ) ;
2012-01-04 03:23:07 +01:00
break ;
2012-01-04 21:10:33 +01:00
case FileListModel : : CsvError_FileOpen :
2012-01-04 03:23:07 +01:00
QMessageBox : : critical ( this , tr ( " CSV Export " ) , NOBR ( tr ( " Sorry, failed to open CSV file for writing! " ) ) ) ;
break ;
2012-01-04 21:10:33 +01:00
case FileListModel : : CsvError_FileWrite :
2012-01-04 03:23:07 +01:00
QMessageBox : : critical ( this , tr ( " CSV Export " ) , NOBR ( tr ( " Sorry, failed to write to the CSV file! " ) ) ) ;
break ;
2012-01-04 21:10:33 +01:00
case FileListModel : : CsvError_OK :
2012-01-04 03:23:07 +01:00
QMessageBox : : information ( this , tr ( " CSV Export " ) , NOBR ( tr ( " The CSV files was created successfully! " ) ) ) ;
break ;
2012-01-04 21:10:33 +01:00
default :
qWarning ( " exportToCsv: Unknown return code! " ) ;
}
}
)
}
/*
* Import Meta tags from CSV file
*/
void MainWindow : : importCsvContextActionTriggered ( void )
{
TEMP_HIDE_DROPBOX
(
QString selectedCsvFile ;
if ( USE_NATIVE_FILE_DIALOG )
{
selectedCsvFile = QFileDialog : : getOpenFileName ( this , tr ( " Open CSV file " ) , m_settings - > mostRecentInputPath ( ) , QString ( " %1 (*.csv) " ) . arg ( tr ( " CSV File " ) ) ) ;
}
else
{
QFileDialog dialog ( this , tr ( " Open CSV file " ) ) ;
dialog . setFileMode ( QFileDialog : : ExistingFile ) ;
dialog . setNameFilter ( QString ( " %1 (*.csv) " ) . arg ( tr ( " CSV File " ) ) ) ;
dialog . setDirectory ( m_settings - > mostRecentInputPath ( ) ) ;
if ( dialog . exec ( ) )
{
selectedCsvFile = dialog . selectedFiles ( ) . first ( ) ;
}
}
if ( ! selectedCsvFile . isEmpty ( ) )
{
m_settings - > mostRecentInputPath ( QFileInfo ( selectedCsvFile ) . canonicalPath ( ) ) ;
switch ( m_fileListModel - > importFromCsv ( this , selectedCsvFile ) )
{
case FileListModel : : CsvError_FileOpen :
QMessageBox : : critical ( this , tr ( " CSV Import " ) , NOBR ( tr ( " Sorry, failed to open CSV file for reading! " ) ) ) ;
break ;
case FileListModel : : CsvError_FileRead :
QMessageBox : : critical ( this , tr ( " CSV Import " ) , NOBR ( tr ( " Sorry, failed to read from the CSV file! " ) ) ) ;
break ;
case FileListModel : : CsvError_NoTags :
QMessageBox : : critical ( this , tr ( " CSV Import " ) , NOBR ( tr ( " Sorry, the CSV file does not contain any known fields! " ) ) ) ;
break ;
case FileListModel : : CsvError_Incomplete :
QMessageBox : : warning ( this , tr ( " CSV Import " ) , NOBR ( tr ( " CSV file is incomplete. Not all files were updated! " ) ) ) ;
break ;
case FileListModel : : CsvError_OK :
QMessageBox : : information ( this , tr ( " CSV Import " ) , NOBR ( tr ( " The CSV files was imported successfully! " ) ) ) ;
break ;
case FileListModel : : CsvError_Aborted :
/* User aborted, ignore! */
break ;
default :
qWarning ( " exportToCsv: Unknown return code! " ) ;
2012-01-04 03:23:07 +01:00
}
}
)
}
2011-05-21 13:07:17 +02:00
/*
* Show or hide Drag ' n ' Drop notice after model reset
*/
void MainWindow : : sourceModelChanged ( void )
{
m_dropNoteLabel - > setVisible ( m_fileListModel - > rowCount ( ) < = 0 ) ;
}
// =========================================================
// Output folder slots
// =========================================================
/*
* Output folder changed ( mouse clicked )
*/
void MainWindow : : outputFolderViewClicked ( const QModelIndex & index )
{
2012-04-06 16:15:19 +02:00
if ( index . isValid ( ) & & ( outputFolderView - > currentIndex ( ) ! = index ) )
2011-05-21 13:07:17 +02:00
{
outputFolderView - > setCurrentIndex ( index ) ;
}
2012-04-05 15:24:45 +02:00
2012-04-05 16:24:33 +02:00
if ( m_fileSystemModel & & index . isValid ( ) )
2012-04-05 15:24:45 +02:00
{
QString selectedDir = m_fileSystemModel - > filePath ( index ) ;
if ( selectedDir . length ( ) < 3 ) selectedDir . append ( QDir : : separator ( ) ) ;
outputFolderLabel - > setText ( QDir : : toNativeSeparators ( selectedDir ) ) ;
m_settings - > outputDir ( selectedDir ) ;
}
2012-04-05 16:24:33 +02:00
else
{
outputFolderLabel - > setText ( QDir : : toNativeSeparators ( m_settings - > outputDir ( ) ) ) ;
}
2011-05-21 13:07:17 +02:00
}
/*
* Output folder changed ( mouse moved )
*/
void MainWindow : : outputFolderViewMoved ( const QModelIndex & index )
{
if ( QApplication : : mouseButtons ( ) & Qt : : LeftButton )
{
outputFolderViewClicked ( index ) ;
}
}
/*
* Goto desktop button
*/
void MainWindow : : gotoDesktopButtonClicked ( void )
{
2012-04-05 15:24:45 +02:00
if ( ! m_fileSystemModel )
{
qWarning ( " File system model not initialized yet! " ) ;
return ;
}
2011-05-21 13:07:17 +02:00
QString desktopPath = QDesktopServices : : storageLocation ( QDesktopServices : : DesktopLocation ) ;
if ( ! desktopPath . isEmpty ( ) & & QDir ( desktopPath ) . exists ( ) )
{
outputFolderView - > setCurrentIndex ( m_fileSystemModel - > index ( desktopPath ) ) ;
outputFolderViewClicked ( outputFolderView - > currentIndex ( ) ) ;
2012-03-29 19:08:33 +02:00
CENTER_CURRENT_OUTPUT_FOLDER_DELAYED ;
2011-05-21 13:07:17 +02:00
}
else
{
buttonGotoDesktop - > setEnabled ( false ) ;
}
}
/*
* Goto home folder button
*/
void MainWindow : : gotoHomeFolderButtonClicked ( void )
{
2012-04-05 15:24:45 +02:00
if ( ! m_fileSystemModel )
{
qWarning ( " File system model not initialized yet! " ) ;
return ;
}
2011-05-21 13:07:17 +02:00
QString homePath = QDesktopServices : : storageLocation ( QDesktopServices : : HomeLocation ) ;
if ( ! homePath . isEmpty ( ) & & QDir ( homePath ) . exists ( ) )
{
outputFolderView - > setCurrentIndex ( m_fileSystemModel - > index ( homePath ) ) ;
outputFolderViewClicked ( outputFolderView - > currentIndex ( ) ) ;
2012-03-29 19:08:33 +02:00
CENTER_CURRENT_OUTPUT_FOLDER_DELAYED ;
2011-05-21 13:07:17 +02:00
}
else
{
buttonGotoHome - > setEnabled ( false ) ;
}
}
/*
* Goto music folder button
*/
void MainWindow : : gotoMusicFolderButtonClicked ( void )
{
2012-04-05 15:24:45 +02:00
if ( ! m_fileSystemModel )
{
qWarning ( " File system model not initialized yet! " ) ;
return ;
}
2011-05-21 13:07:17 +02:00
QString musicPath = QDesktopServices : : storageLocation ( QDesktopServices : : MusicLocation ) ;
if ( ! musicPath . isEmpty ( ) & & QDir ( musicPath ) . exists ( ) )
{
outputFolderView - > setCurrentIndex ( m_fileSystemModel - > index ( musicPath ) ) ;
outputFolderViewClicked ( outputFolderView - > currentIndex ( ) ) ;
2012-03-29 19:08:33 +02:00
CENTER_CURRENT_OUTPUT_FOLDER_DELAYED ;
2011-05-21 13:07:17 +02:00
}
else
{
buttonGotoMusic - > setEnabled ( false ) ;
}
}
2011-08-08 20:26:30 +02:00
/*
* Goto music favorite output folder
*/
void MainWindow : : gotoFavoriteFolder ( void )
{
2012-04-05 15:24:45 +02:00
if ( ! m_fileSystemModel )
{
qWarning ( " File system model not initialized yet! " ) ;
return ;
}
2011-08-08 20:26:30 +02:00
QAction * item = dynamic_cast < QAction * > ( QObject : : sender ( ) ) ;
if ( item )
{
QDir path ( item - > data ( ) . toString ( ) ) ;
if ( path . exists ( ) )
{
outputFolderView - > setCurrentIndex ( m_fileSystemModel - > index ( path . canonicalPath ( ) ) ) ;
outputFolderViewClicked ( outputFolderView - > currentIndex ( ) ) ;
2012-03-29 19:08:33 +02:00
CENTER_CURRENT_OUTPUT_FOLDER_DELAYED ;
2011-08-08 20:26:30 +02:00
}
else
{
MessageBeep ( MB_ICONERROR ) ;
m_outputFolderFavoritesMenu - > removeAction ( item ) ;
item - > deleteLater ( ) ;
}
}
}
2011-05-21 13:07:17 +02:00
/*
* Make folder button
*/
void MainWindow : : makeFolderButtonClicked ( void )
{
ABORT_IF_BUSY ;
2012-04-05 15:24:45 +02:00
if ( ! m_fileSystemModel )
{
qWarning ( " File system model not initialized yet! " ) ;
return ;
}
2011-05-21 13:07:17 +02:00
QDir basePath ( m_fileSystemModel - > fileInfo ( outputFolderView - > currentIndex ( ) ) . absoluteFilePath ( ) ) ;
QString suggestedName = tr ( " New Folder " ) ;
if ( ! m_metaData - > fileArtist ( ) . isEmpty ( ) & & ! m_metaData - > fileAlbum ( ) . isEmpty ( ) )
{
suggestedName = QString ( " %1 - %2 " ) . arg ( m_metaData - > fileArtist ( ) , m_metaData - > fileAlbum ( ) ) ;
}
else if ( ! m_metaData - > fileArtist ( ) . isEmpty ( ) )
{
suggestedName = m_metaData - > fileArtist ( ) ;
}
else if ( ! m_metaData - > fileAlbum ( ) . isEmpty ( ) )
{
suggestedName = m_metaData - > fileAlbum ( ) ;
}
else
{
for ( int i = 0 ; i < m_fileListModel - > rowCount ( ) ; i + + )
{
AudioFileModel audioFile = m_fileListModel - > getFile ( m_fileListModel - > index ( i , 0 ) ) ;
if ( ! audioFile . fileAlbum ( ) . isEmpty ( ) | | ! audioFile . fileArtist ( ) . isEmpty ( ) )
{
if ( ! audioFile . fileArtist ( ) . isEmpty ( ) & & ! audioFile . fileAlbum ( ) . isEmpty ( ) )
{
suggestedName = QString ( " %1 - %2 " ) . arg ( audioFile . fileArtist ( ) , audioFile . fileAlbum ( ) ) ;
}
else if ( ! audioFile . fileArtist ( ) . isEmpty ( ) )
{
suggestedName = audioFile . fileArtist ( ) ;
}
else if ( ! audioFile . fileAlbum ( ) . isEmpty ( ) )
{
suggestedName = audioFile . fileAlbum ( ) ;
}
break ;
}
}
}
2011-08-08 20:26:30 +02:00
suggestedName = lamexp_clean_filename ( suggestedName ) ;
2011-05-21 13:07:17 +02:00
while ( true )
{
bool bApplied = false ;
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 ( ) ;
if ( bApplied )
{
2011-08-08 20:26:30 +02:00
folderName = lamexp_clean_filepath ( folderName . simplified ( ) ) ;
2011-05-21 13:07:17 +02:00
if ( folderName . isEmpty ( ) )
{
MessageBeep ( MB_ICONERROR ) ;
continue ;
}
int i = 1 ;
QString newFolder = folderName ;
while ( basePath . exists ( newFolder ) )
{
newFolder = QString ( folderName ) . append ( QString ( ) . sprintf ( " (%d) " , + + i ) ) ;
}
2011-08-08 20:26:30 +02:00
if ( basePath . mkpath ( newFolder ) )
2011-05-21 13:07:17 +02:00
{
QDir createdDir = basePath ;
if ( createdDir . cd ( newFolder ) )
{
2012-03-30 03:35:43 +02:00
QModelIndex newIndex = m_fileSystemModel - > index ( createdDir . canonicalPath ( ) ) ;
outputFolderView - > setCurrentIndex ( newIndex ) ;
outputFolderViewClicked ( newIndex ) ;
2012-03-29 19:08:33 +02:00
CENTER_CURRENT_OUTPUT_FOLDER_DELAYED ;
2011-05-21 13:07:17 +02:00
}
}
else
{
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! " ) ) ) ;
}
}
break ;
}
}
/*
* Output to source dir changed
*/
void MainWindow : : saveToSourceFolderChanged ( void )
{
m_settings - > outputToSourceDir ( saveToSourceFolderCheckBox - > isChecked ( ) ) ;
}
/*
* Prepend relative source file path to output file name changed
*/
void MainWindow : : prependRelativePathChanged ( void )
{
m_settings - > prependRelativeSourcePath ( prependRelativePathCheckBox - > isChecked ( ) ) ;
}
/*
* Show context menu for output folder
*/
void MainWindow : : outputFolderContextMenu ( const QPoint & pos )
{
QAbstractScrollArea * scrollArea = dynamic_cast < QAbstractScrollArea * > ( QObject : : sender ( ) ) ;
QWidget * sender = scrollArea ? scrollArea - > viewport ( ) : dynamic_cast < QWidget * > ( QObject : : sender ( ) ) ;
if ( pos . x ( ) < = sender - > width ( ) & & pos . y ( ) < = sender - > height ( ) & & pos . x ( ) > = 0 & & pos . y ( ) > = 0 )
{
m_outputFolderContextMenu - > popup ( sender - > mapToGlobal ( pos ) ) ;
}
}
/*
* Show selected folder in explorer
*/
void MainWindow : : showFolderContextActionTriggered ( void )
{
2012-04-05 15:24:45 +02:00
if ( ! m_fileSystemModel )
{
qWarning ( " File system model not initialized yet! " ) ;
return ;
}
2011-12-19 02:09:45 +01:00
QString path = QDir : : toNativeSeparators ( m_fileSystemModel - > filePath ( outputFolderView - > currentIndex ( ) ) ) ;
if ( ! path . endsWith ( QDir : : separator ( ) ) ) path . append ( QDir : : separator ( ) ) ;
2012-04-11 00:44:40 +02:00
ShellExecuteW ( reinterpret_cast < HWND > ( this - > winId ( ) ) , L " explore " , QWCHAR ( path ) , NULL , NULL , SW_SHOW ) ;
2011-05-21 13:07:17 +02:00
}
2012-04-05 15:24:45 +02:00
/*
* Refresh the directory outline
*/
void MainWindow : : refreshFolderContextActionTriggered ( void )
{
2012-04-06 16:15:19 +02:00
//force re-initialization
2012-04-05 15:24:45 +02:00
QTimer : : singleShot ( 0 , this , SLOT ( initOutputFolderModel ( ) ) ) ;
}
2011-08-08 20:26:30 +02:00
/*
* Add current folder to favorites
*/
void MainWindow : : addFavoriteFolderActionTriggered ( void )
{
QString path = m_fileSystemModel - > filePath ( outputFolderView - > currentIndex ( ) ) ;
QStringList favorites = m_settings - > favoriteOutputFolders ( ) . split ( " | " , QString : : SkipEmptyParts ) ;
if ( ! favorites . contains ( path , Qt : : CaseInsensitive ) )
{
favorites . append ( path ) ;
while ( favorites . count ( ) > 6 ) favorites . removeFirst ( ) ;
}
else
{
MessageBeep ( MB_ICONWARNING ) ;
}
m_settings - > favoriteOutputFolders ( favorites . join ( " | " ) ) ;
refreshFavorites ( ) ;
}
2012-03-26 22:02:11 +02:00
/*
* Output folder edit finished
*/
void MainWindow : : outputFolderEditFinished ( void )
{
2012-03-27 22:46:01 +02:00
if ( outputFolderEdit - > isHidden ( ) )
{
return ; //Not currently in edit mode!
}
2012-03-26 22:02:11 +02:00
2012-03-27 22:46:01 +02:00
bool ok = false ;
QString text = QDir : : fromNativeSeparators ( outputFolderEdit - > text ( ) . trimmed ( ) ) ;
while ( text . startsWith ( ' " ' ) | | text . startsWith ( ' / ' ) ) text = text . right ( text . length ( ) - 1 ) . trimmed ( ) ;
while ( text . endsWith ( ' " ' ) | | text . endsWith ( ' / ' ) ) text = text . left ( text . length ( ) - 1 ) . trimmed ( ) ;
2012-03-26 22:02:11 +02:00
2012-03-27 22:46:01 +02:00
static const char * str = " ?*<>| \" " ;
for ( size_t i = 0 ; str [ i ] ; i + + ) text . replace ( str [ i ] , " _ " ) ;
if ( ! ( ( text . length ( ) > = 2 ) & & text . at ( 0 ) . isLetter ( ) & & text . at ( 1 ) = = QChar ( ' : ' ) ) )
2012-03-26 22:02:11 +02:00
{
2012-03-27 22:46:01 +02:00
text = QString ( " %1/%2 " ) . arg ( QDir : : fromNativeSeparators ( outputFolderLabel - > text ( ) ) , text ) ;
}
if ( text . length ( ) = = 2 ) text + = " / " ; /* "X:" => "X:/" */
2012-03-26 22:02:11 +02:00
2012-03-27 22:46:01 +02:00
while ( text . length ( ) > 2 )
{
2012-03-26 22:02:11 +02:00
QFileInfo info ( text ) ;
if ( info . exists ( ) & & info . isDir ( ) )
{
2012-03-28 02:21:34 +02:00
QModelIndex index = m_fileSystemModel - > index ( QFileInfo ( info . canonicalFilePath ( ) ) . absoluteFilePath ( ) ) ;
2012-03-26 22:02:11 +02:00
if ( index . isValid ( ) )
{
2012-03-27 22:46:01 +02:00
ok = true ;
2012-03-26 22:02:11 +02:00
outputFolderView - > setCurrentIndex ( index ) ;
2012-03-29 01:32:47 +02:00
outputFolderViewClicked ( index ) ;
2012-03-27 22:46:01 +02:00
break ;
2012-03-26 22:02:11 +02:00
}
}
else if ( info . exists ( ) & & info . isFile ( ) )
{
2012-03-29 01:32:47 +02:00
QModelIndex index = m_fileSystemModel - > index ( QFileInfo ( info . canonicalPath ( ) ) . absoluteFilePath ( ) ) ;
2012-03-26 22:02:11 +02:00
if ( index . isValid ( ) )
{
2012-03-27 22:46:01 +02:00
ok = true ;
2012-03-26 22:02:11 +02:00
outputFolderView - > setCurrentIndex ( index ) ;
2012-03-29 01:32:47 +02:00
outputFolderViewClicked ( index ) ;
2012-03-27 22:46:01 +02:00
break ;
2012-03-26 22:02:11 +02:00
}
}
text = text . left ( text . length ( ) - 1 ) . trimmed ( ) ;
}
2012-03-27 22:46:01 +02:00
outputFolderEdit - > setVisible ( false ) ;
outputFolderLabel - > setVisible ( true ) ;
outputFolderView - > setEnabled ( true ) ;
2012-03-29 19:08:33 +02:00
if ( ! ok ) MessageBeep ( MB_ICONERROR ) ;
CENTER_CURRENT_OUTPUT_FOLDER_DELAYED ;
2012-03-26 22:02:11 +02:00
}
2011-06-04 22:43:14 +02:00
/*
* Initialize file system model
*/
void MainWindow : : initOutputFolderModel ( void )
{
2012-04-05 15:24:45 +02:00
if ( m_outputFolderNoteBox - > isHidden ( ) )
{
m_outputFolderNoteBox - > show ( ) ;
2012-04-06 16:15:19 +02:00
m_outputFolderNoteBox - > repaint ( ) ;
2012-04-05 15:24:45 +02:00
m_outputFolderViewInitCounter = 4 ;
if ( m_fileSystemModel )
{
2012-04-06 16:15:19 +02:00
SET_MODEL ( outputFolderView , NULL ) ;
2012-04-05 15:24:45 +02:00
LAMEXP_DELETE ( m_fileSystemModel ) ;
2012-04-06 16:15:19 +02:00
outputFolderView - > repaint ( ) ;
2012-04-05 15:24:45 +02:00
}
if ( m_fileSystemModel = new QFileSystemModelEx ( ) )
{
m_fileSystemModel - > installEventFilter ( this ) ;
connect ( m_fileSystemModel , SIGNAL ( directoryLoaded ( QString ) ) , this , SLOT ( outputFolderDirectoryLoaded ( QString ) ) ) ;
connect ( m_fileSystemModel , SIGNAL ( rowsInserted ( QModelIndex , int , int ) ) , this , SLOT ( outputFolderRowsInserted ( QModelIndex , int , int ) ) ) ;
2012-04-06 16:15:19 +02:00
SET_MODEL ( outputFolderView , m_fileSystemModel ) ;
2012-04-05 15:24:45 +02:00
outputFolderView - > header ( ) - > setStretchLastSection ( true ) ;
outputFolderView - > header ( ) - > hideSection ( 1 ) ;
outputFolderView - > header ( ) - > hideSection ( 2 ) ;
outputFolderView - > header ( ) - > hideSection ( 3 ) ;
m_fileSystemModel - > setRootPath ( " " ) ;
QModelIndex index = m_fileSystemModel - > index ( m_settings - > outputDir ( ) ) ;
if ( index . isValid ( ) ) outputFolderView - > setCurrentIndex ( index ) ;
outputFolderViewClicked ( outputFolderView - > currentIndex ( ) ) ;
}
2012-04-06 16:15:19 +02:00
2012-04-05 15:24:45 +02:00
CENTER_CURRENT_OUTPUT_FOLDER_DELAYED ;
QTimer : : singleShot ( 125 , this , SLOT ( initOutputFolderModel_doAsync ( ) ) ) ;
}
2012-03-30 03:35:43 +02:00
}
/*
* Initialize file system model ( do NOT call this one directly ! )
*/
void MainWindow : : initOutputFolderModel_doAsync ( void )
{
2012-04-05 15:24:45 +02:00
if ( m_outputFolderViewInitCounter > 0 )
2012-03-30 03:35:43 +02:00
{
2012-04-05 15:24:45 +02:00
m_outputFolderViewInitCounter - - ;
2012-03-30 03:35:43 +02:00
QTimer : : singleShot ( 125 , this , SLOT ( initOutputFolderModel_doAsync ( ) ) ) ;
}
else
{
QTimer : : singleShot ( 125 , m_outputFolderNoteBox , SLOT ( hide ( ) ) ) ;
outputFolderView - > setFocus ( ) ;
}
2011-06-04 22:43:14 +02:00
}
2012-03-29 01:32:47 +02:00
/*
* Center current folder in view
*/
2012-03-28 02:21:34 +02:00
void MainWindow : : centerOutputFolderModel ( void )
2012-03-29 03:22:24 +02:00
{
if ( outputFolderView - > isVisible ( ) )
{
2012-03-29 19:08:33 +02:00
centerOutputFolderModel_doAsync ( ) ;
QTimer : : singleShot ( 125 , this , SLOT ( centerOutputFolderModel_doAsync ( ) ) ) ;
2012-03-29 03:22:24 +02:00
}
}
/*
* Center current folder in view ( do NOT call this one directly ! )
*/
2012-03-29 19:08:33 +02:00
void MainWindow : : centerOutputFolderModel_doAsync ( void )
2012-03-28 02:21:34 +02:00
{
2012-03-29 01:32:47 +02:00
if ( outputFolderView - > isVisible ( ) )
{
m_outputFolderViewCentering = true ;
const QModelIndex index = outputFolderView - > currentIndex ( ) ;
outputFolderView - > scrollTo ( index , QAbstractItemView : : PositionAtCenter ) ;
outputFolderView - > setFocus ( ) ;
}
}
/*
* File system model asynchronously loaded a dir
*/
void MainWindow : : outputFolderDirectoryLoaded ( const QString & path )
{
2012-03-29 03:22:24 +02:00
if ( m_outputFolderViewCentering )
{
2012-03-29 19:08:33 +02:00
CENTER_CURRENT_OUTPUT_FOLDER_DELAYED ;
2012-03-29 03:22:24 +02:00
}
}
/*
* File system model inserted new items
*/
void MainWindow : : outputFolderRowsInserted ( const QModelIndex & parent , int start , int end )
{
2012-03-29 01:32:47 +02:00
if ( m_outputFolderViewCentering )
{
2012-03-29 19:08:33 +02:00
CENTER_CURRENT_OUTPUT_FOLDER_DELAYED ;
2012-03-29 01:32:47 +02:00
}
}
/*
* Directory view item was expanded by user
*/
void MainWindow : : outputFolderItemExpanded ( const QModelIndex & item )
{
//We need to stop centering as soon as the user has expanded an item manually!
m_outputFolderViewCentering = false ;
2012-03-28 02:21:34 +02:00
}
2011-05-21 13:07:17 +02:00
// =========================================================
// Metadata tab slots
// =========================================================
/*
* Edit meta button clicked
*/
void MainWindow : : editMetaButtonClicked ( void )
{
ABORT_IF_BUSY ;
const QModelIndex index = metaDataView - > currentIndex ( ) ;
if ( index . isValid ( ) )
{
m_metaInfoModel - > editItem ( index , this ) ;
if ( index . row ( ) = = 4 )
{
m_settings - > metaInfoPosition ( m_metaData - > filePosition ( ) ) ;
}
}
}
/*
* Reset meta button clicked
*/
void MainWindow : : clearMetaButtonClicked ( void )
{
ABORT_IF_BUSY ;
m_metaInfoModel - > clearData ( ) ;
}
/*
* Meta tags enabled changed
*/
void MainWindow : : metaTagsEnabledChanged ( void )
{
m_settings - > writeMetaTags ( writeMetaDataCheckBox - > isChecked ( ) ) ;
}
/*
* Playlist enabled changed
*/
void MainWindow : : playlistEnabledChanged ( void )
{
m_settings - > createPlaylist ( generatePlaylistCheckBox - > isChecked ( ) ) ;
}
// =========================================================
// Compression tab slots
// =========================================================
2010-11-15 04:42:06 +01:00
/*
* Update encoder
*/
void MainWindow : : updateEncoder ( int id )
{
m_settings - > compressionEncoder ( id ) ;
switch ( m_settings - > compressionEncoder ( ) )
{
case SettingsModel : : VorbisEncoder :
radioButtonModeQuality - > setEnabled ( true ) ;
radioButtonModeAverageBitrate - > setEnabled ( true ) ;
radioButtonConstBitrate - > setEnabled ( false ) ;
if ( radioButtonConstBitrate - > isChecked ( ) ) radioButtonModeQuality - > setChecked ( true ) ;
sliderBitrate - > setEnabled ( true ) ;
break ;
2011-05-05 12:27:25 +02:00
case SettingsModel : : AC3Encoder :
radioButtonModeQuality - > setEnabled ( true ) ;
radioButtonModeQuality - > setChecked ( true ) ;
radioButtonModeAverageBitrate - > setEnabled ( false ) ;
radioButtonConstBitrate - > setEnabled ( true ) ;
sliderBitrate - > setEnabled ( true ) ;
break ;
2010-11-15 04:42:06 +01:00
case SettingsModel : : FLACEncoder :
radioButtonModeQuality - > setEnabled ( false ) ;
radioButtonModeQuality - > setChecked ( true ) ;
radioButtonModeAverageBitrate - > setEnabled ( false ) ;
radioButtonConstBitrate - > setEnabled ( false ) ;
sliderBitrate - > setEnabled ( true ) ;
break ;
case SettingsModel : : PCMEncoder :
radioButtonModeQuality - > setEnabled ( false ) ;
radioButtonModeQuality - > setChecked ( true ) ;
radioButtonModeAverageBitrate - > setEnabled ( false ) ;
radioButtonConstBitrate - > setEnabled ( false ) ;
sliderBitrate - > setEnabled ( false ) ;
break ;
2011-08-19 19:25:01 +02:00
case SettingsModel : : AACEncoder :
radioButtonModeQuality - > setEnabled ( true ) ;
radioButtonModeAverageBitrate - > setEnabled ( ! m_fhgEncoderAvailable ) ;
if ( m_fhgEncoderAvailable & & radioButtonModeAverageBitrate - > isChecked ( ) ) radioButtonConstBitrate - > setChecked ( true ) ;
radioButtonConstBitrate - > setEnabled ( true ) ;
sliderBitrate - > setEnabled ( true ) ;
break ;
2011-12-22 21:53:25 +01:00
case SettingsModel : : DCAEncoder :
radioButtonModeQuality - > setEnabled ( false ) ;
radioButtonModeAverageBitrate - > setEnabled ( false ) ;
radioButtonConstBitrate - > setEnabled ( true ) ;
radioButtonConstBitrate - > setChecked ( true ) ;
sliderBitrate - > setEnabled ( true ) ;
break ;
2010-11-15 04:42:06 +01:00
default :
radioButtonModeQuality - > setEnabled ( true ) ;
radioButtonModeAverageBitrate - > setEnabled ( true ) ;
radioButtonConstBitrate - > setEnabled ( true ) ;
sliderBitrate - > setEnabled ( true ) ;
break ;
}
2012-03-06 22:29:55 +01:00
if ( m_settings - > compressionEncoder ( ) = = SettingsModel : : AACEncoder )
{
const QString encoderName = m_qaacEncoderAvailable ? tr ( " QAAC (Apple) " ) : ( m_fhgEncoderAvailable ? tr ( " FHG AAC (Winamp) " ) : ( m_neroEncoderAvailable ? tr ( " Nero AAC " ) : tr ( " Not available! " ) ) ) ;
labelEncoderInfo - > setVisible ( true ) ;
labelEncoderInfo - > setText ( tr ( " Current AAC Encoder: %1 " ) . arg ( encoderName ) ) ;
}
else
{
labelEncoderInfo - > setVisible ( false ) ;
}
2010-11-15 04:42:06 +01:00
updateRCMode ( m_modeButtonGroup - > checkedId ( ) ) ;
}
/*
* Update rate - control mode
*/
void MainWindow : : updateRCMode ( int id )
{
m_settings - > compressionRCMode ( id ) ;
switch ( m_settings - > compressionEncoder ( ) )
{
case SettingsModel : : MP3Encoder :
switch ( m_settings - > compressionRCMode ( ) )
{
case SettingsModel : : VBRMode :
sliderBitrate - > setMinimum ( 0 ) ;
sliderBitrate - > setMaximum ( 9 ) ;
break ;
default :
2010-11-15 21:07:58 +01:00
sliderBitrate - > setMinimum ( 0 ) ;
sliderBitrate - > setMaximum ( 13 ) ;
2010-11-15 04:42:06 +01:00
break ;
}
break ;
case SettingsModel : : VorbisEncoder :
switch ( m_settings - > compressionRCMode ( ) )
{
case SettingsModel : : VBRMode :
sliderBitrate - > setMinimum ( - 2 ) ;
sliderBitrate - > setMaximum ( 10 ) ;
break ;
default :
sliderBitrate - > setMinimum ( 4 ) ;
sliderBitrate - > setMaximum ( 63 ) ;
break ;
}
break ;
2011-05-05 12:27:25 +02:00
case SettingsModel : : AC3Encoder :
switch ( m_settings - > compressionRCMode ( ) )
{
case SettingsModel : : VBRMode :
sliderBitrate - > setMinimum ( 0 ) ;
sliderBitrate - > setMaximum ( 16 ) ;
break ;
default :
sliderBitrate - > setMinimum ( 0 ) ;
sliderBitrate - > setMaximum ( 18 ) ;
break ;
}
break ;
2010-11-15 04:42:06 +01:00
case SettingsModel : : AACEncoder :
switch ( m_settings - > compressionRCMode ( ) )
{
case SettingsModel : : VBRMode :
sliderBitrate - > setMinimum ( 0 ) ;
sliderBitrate - > setMaximum ( 20 ) ;
break ;
default :
sliderBitrate - > setMinimum ( 4 ) ;
sliderBitrate - > setMaximum ( 63 ) ;
break ;
}
break ;
case SettingsModel : : FLACEncoder :
sliderBitrate - > setMinimum ( 0 ) ;
sliderBitrate - > setMaximum ( 8 ) ;
break ;
2011-12-22 21:53:25 +01:00
case SettingsModel : : DCAEncoder :
sliderBitrate - > setMinimum ( 1 ) ;
2011-12-23 02:29:06 +01:00
sliderBitrate - > setMaximum ( 128 ) ;
2011-12-22 21:53:25 +01:00
break ;
2010-11-15 04:42:06 +01:00
case SettingsModel : : PCMEncoder :
sliderBitrate - > setMinimum ( 0 ) ;
sliderBitrate - > setMaximum ( 2 ) ;
sliderBitrate - > setValue ( 1 ) ;
break ;
default :
sliderBitrate - > setMinimum ( 0 ) ;
sliderBitrate - > setMaximum ( 0 ) ;
break ;
}
updateBitrate ( sliderBitrate - > value ( ) ) ;
}
2010-11-11 22:58:02 +01:00
/*
* Update bitrate
*/
void MainWindow : : updateBitrate ( int value )
{
2010-11-15 04:42:06 +01:00
m_settings - > compressionBitrate ( value ) ;
switch ( m_settings - > compressionRCMode ( ) )
{
case SettingsModel : : VBRMode :
switch ( m_settings - > compressionEncoder ( ) )
{
case SettingsModel : : MP3Encoder :
2010-12-28 21:26:16 +01:00
labelBitrate - > setText ( tr ( " Quality Level %1 " ) . arg ( 9 - value ) ) ;
2010-11-15 04:42:06 +01:00
break ;
case SettingsModel : : VorbisEncoder :
2010-12-28 21:26:16 +01:00
labelBitrate - > setText ( tr ( " Quality Level %1 " ) . arg ( value ) ) ;
2010-11-15 04:42:06 +01:00
break ;
case SettingsModel : : AACEncoder :
2010-12-28 21:26:16 +01:00
labelBitrate - > setText ( tr ( " Quality Level %1 " ) . arg ( QString ( ) . sprintf ( " %.2f " , static_cast < double > ( value * 5 ) / 100.0 ) ) ) ;
2010-11-15 04:42:06 +01:00
break ;
case SettingsModel : : FLACEncoder :
2010-12-28 21:26:16 +01:00
labelBitrate - > setText ( tr ( " Compression %1 " ) . arg ( value ) ) ;
2010-11-15 04:42:06 +01:00
break ;
2011-05-05 12:27:25 +02:00
case SettingsModel : : AC3Encoder :
2011-11-08 15:12:31 +01:00
labelBitrate - > setText ( tr ( " Quality Level %1 " ) . arg ( qMin ( 1024 , qMax ( 0 , value * 64 ) ) ) ) ;
2011-05-05 12:27:25 +02:00
break ;
2010-11-15 04:42:06 +01:00
case SettingsModel : : PCMEncoder :
2010-12-28 21:26:16 +01:00
labelBitrate - > setText ( tr ( " Uncompressed " ) ) ;
2010-11-15 04:42:06 +01:00
break ;
default :
labelBitrate - > setText ( QString : : number ( value ) ) ;
break ;
}
break ;
case SettingsModel : : ABRMode :
switch ( m_settings - > compressionEncoder ( ) )
{
case SettingsModel : : MP3Encoder :
2010-11-15 21:07:58 +01:00
labelBitrate - > setText ( QString ( " ≈ %1 kbps " ) . arg ( SettingsModel : : mp3Bitrates [ value ] ) ) ;
2010-11-15 04:42:06 +01:00
break ;
case SettingsModel : : FLACEncoder :
2010-12-28 21:26:16 +01:00
labelBitrate - > setText ( tr ( " Compression %1 " ) . arg ( value ) ) ;
2010-11-15 04:42:06 +01:00
break ;
2011-05-05 12:27:25 +02:00
case SettingsModel : : AC3Encoder :
labelBitrate - > setText ( QString ( " ≈ %1 kbps " ) . arg ( SettingsModel : : ac3Bitrates [ value ] ) ) ;
break ;
2010-11-15 04:42:06 +01:00
case SettingsModel : : PCMEncoder :
2010-12-28 21:26:16 +01:00
labelBitrate - > setText ( tr ( " Uncompressed " ) ) ;
2010-11-15 04:42:06 +01:00
break ;
default :
2011-11-08 15:12:31 +01:00
labelBitrate - > setText ( QString ( " ≈ %1 kbps " ) . arg ( qMin ( 500 , value * 8 ) ) ) ;
2010-11-15 04:42:06 +01:00
break ;
}
break ;
default :
switch ( m_settings - > compressionEncoder ( ) )
{
case SettingsModel : : MP3Encoder :
2010-11-15 21:07:58 +01:00
labelBitrate - > setText ( QString ( " %1 kbps " ) . arg ( SettingsModel : : mp3Bitrates [ value ] ) ) ;
2010-11-15 04:42:06 +01:00
break ;
case SettingsModel : : FLACEncoder :
2010-12-28 21:26:16 +01:00
labelBitrate - > setText ( tr ( " Compression %1 " ) . arg ( value ) ) ;
2010-11-15 04:42:06 +01:00
break ;
2011-05-05 12:27:25 +02:00
case SettingsModel : : AC3Encoder :
2011-05-07 00:50:18 +02:00
labelBitrate - > setText ( QString ( " %1 kbps " ) . arg ( SettingsModel : : ac3Bitrates [ value ] ) ) ;
2011-05-05 12:27:25 +02:00
break ;
2011-12-22 21:53:25 +01:00
case SettingsModel : : DCAEncoder :
labelBitrate - > setText ( QString ( " %1 kbps " ) . arg ( value * 32 ) ) ;
break ;
2010-11-15 04:42:06 +01:00
case SettingsModel : : PCMEncoder :
2010-12-28 21:26:16 +01:00
labelBitrate - > setText ( tr ( " Uncompressed " ) ) ;
2010-11-15 04:42:06 +01:00
break ;
default :
2011-11-08 15:12:31 +01:00
labelBitrate - > setText ( QString ( " %1 kbps " ) . arg ( qMin ( 500 , value * 8 ) ) ) ;
2010-11-15 04:42:06 +01:00
break ;
}
break ;
}
2010-11-11 22:58:02 +01:00
}
2010-11-20 02:14:22 +01:00
2011-05-21 13:07:17 +02:00
// =========================================================
// Advanced option slots
// =========================================================
2011-01-21 19:14:11 +01:00
/*
* Lame algorithm quality changed
*/
void MainWindow : : updateLameAlgoQuality ( int value )
{
QString text ;
switch ( value )
{
case 4 :
text = tr ( " Best Quality (Very Slow) " ) ;
break ;
case 3 :
text = tr ( " High Quality (Recommended) " ) ;
break ;
case 2 :
text = tr ( " Average Quality (Default) " ) ;
break ;
case 1 :
text = tr ( " Low Quality (Fast) " ) ;
break ;
case 0 :
text = tr ( " Poor Quality (Very Fast) " ) ;
break ;
}
if ( ! text . isEmpty ( ) )
{
m_settings - > lameAlgoQuality ( value ) ;
labelLameAlgoQuality - > setText ( text ) ;
}
2011-08-25 03:44:46 +02:00
bool warning = ( value = = 0 ) , notice = ( value = = 4 ) ;
labelLameAlgoQualityWarning - > setVisible ( warning ) ;
labelLameAlgoQualityWarningIcon - > setVisible ( warning ) ;
labelLameAlgoQualityNotice - > setVisible ( notice ) ;
labelLameAlgoQualityNoticeIcon - > setVisible ( notice ) ;
labelLameAlgoQualitySpacer - > setVisible ( warning | | notice ) ;
2011-01-21 19:14:11 +01:00
}
2011-01-21 21:41:50 +01:00
/*
* Bitrate management endabled / disabled
*/
void MainWindow : : bitrateManagementEnabledChanged ( bool checked )
{
m_settings - > bitrateManagementEnabled ( checked ) ;
}
/*
* Minimum bitrate has changed
*/
void MainWindow : : bitrateManagementMinChanged ( int value )
{
if ( value > spinBoxBitrateManagementMax - > value ( ) )
{
spinBoxBitrateManagementMin - > setValue ( spinBoxBitrateManagementMax - > value ( ) ) ;
m_settings - > bitrateManagementMinRate ( spinBoxBitrateManagementMax - > value ( ) ) ;
}
else
{
m_settings - > bitrateManagementMinRate ( value ) ;
}
}
/*
* Maximum bitrate has changed
*/
void MainWindow : : bitrateManagementMaxChanged ( int value )
{
if ( value < spinBoxBitrateManagementMin - > value ( ) )
{
spinBoxBitrateManagementMax - > setValue ( spinBoxBitrateManagementMin - > value ( ) ) ;
m_settings - > bitrateManagementMaxRate ( spinBoxBitrateManagementMin - > value ( ) ) ;
}
else
{
m_settings - > bitrateManagementMaxRate ( value ) ;
}
}
2011-01-22 22:19:20 +01:00
/*
* Channel mode has changed
*/
void MainWindow : : channelModeChanged ( int value )
{
if ( value > = 0 ) m_settings - > lameChannelMode ( value ) ;
}
/*
* Sampling rate has changed
*/
void MainWindow : : samplingRateChanged ( int value )
{
if ( value > = 0 ) m_settings - > samplingRate ( value ) ;
}
/*
* Nero AAC 2 - Pass mode changed
*/
void MainWindow : : neroAAC2PassChanged ( bool checked )
{
m_settings - > neroAACEnable2Pass ( checked ) ;
}
/*
* Nero AAC profile mode changed
*/
void MainWindow : : neroAACProfileChanged ( int value )
{
2011-08-21 14:43:18 +02:00
if ( value > = 0 ) m_settings - > aacEncProfile ( value ) ;
2011-01-22 22:19:20 +01:00
}
2011-01-21 21:41:50 +01:00
2011-05-07 00:50:18 +02:00
/*
* Aften audio coding mode changed
*/
void MainWindow : : aftenCodingModeChanged ( int value )
{
if ( value > = 0 ) m_settings - > aftenAudioCodingMode ( value ) ;
}
/*
* Aften DRC mode changed
*/
void MainWindow : : aftenDRCModeChanged ( int value )
{
if ( value > = 0 ) m_settings - > aftenDynamicRangeCompression ( value ) ;
}
/*
* Aften exponent search size changed
*/
void MainWindow : : aftenSearchSizeChanged ( int value )
{
if ( value > = 0 ) m_settings - > aftenExponentSearchSize ( value ) ;
}
/*
* Aften fast bit allocation changed
*/
void MainWindow : : aftenFastAllocationChanged ( bool checked )
{
m_settings - > aftenFastBitAllocation ( checked ) ;
}
2011-01-24 01:13:08 +01:00
/*
* Normalization filter enabled changed
*/
void MainWindow : : normalizationEnabledChanged ( bool checked )
{
m_settings - > normalizationFilterEnabled ( checked ) ;
}
/*
* Normalization max . volume changed
*/
void MainWindow : : normalizationMaxVolumeChanged ( double value )
{
m_settings - > normalizationFilterMaxVolume ( static_cast < int > ( value * 100.0 ) ) ;
}
2011-10-06 23:55:42 +02:00
/*
* Normalization equalization mode changed
*/
void MainWindow : : normalizationModeChanged ( int mode )
{
m_settings - > normalizationFilterEqualizationMode ( mode ) ;
}
2011-01-26 20:16:46 +01:00
/*
* Tone adjustment has changed ( Bass )
*/
void MainWindow : : toneAdjustBassChanged ( double value )
{
m_settings - > toneAdjustBass ( static_cast < int > ( value * 100.0 ) ) ;
spinBoxToneAdjustBass - > setPrefix ( ( value > 0 ) ? " + " : QString ( ) ) ;
}
/*
* Tone adjustment has changed ( Treble )
*/
void MainWindow : : toneAdjustTrebleChanged ( double value )
{
m_settings - > toneAdjustTreble ( static_cast < int > ( value * 100.0 ) ) ;
spinBoxToneAdjustTreble - > setPrefix ( ( value > 0 ) ? " + " : QString ( ) ) ;
}
/*
* Tone adjustment has been reset
*/
2011-02-09 23:36:17 +01:00
void MainWindow : : toneAdjustTrebleReset ( void )
2011-01-26 20:16:46 +01:00
{
spinBoxToneAdjustBass - > setValue ( m_settings - > toneAdjustBassDefault ( ) ) ;
spinBoxToneAdjustTreble - > setValue ( m_settings - > toneAdjustTrebleDefault ( ) ) ;
toneAdjustBassChanged ( spinBoxToneAdjustBass - > value ( ) ) ;
toneAdjustTrebleChanged ( spinBoxToneAdjustTreble - > value ( ) ) ;
}
2011-02-09 23:36:17 +01:00
/*
* Custom encoder parameters changed
*/
void MainWindow : : customParamsChanged ( void )
{
lineEditCustomParamLAME - > setText ( lineEditCustomParamLAME - > text ( ) . simplified ( ) ) ;
lineEditCustomParamOggEnc - > setText ( lineEditCustomParamOggEnc - > text ( ) . simplified ( ) ) ;
lineEditCustomParamNeroAAC - > setText ( lineEditCustomParamNeroAAC - > text ( ) . simplified ( ) ) ;
lineEditCustomParamFLAC - > setText ( lineEditCustomParamFLAC - > text ( ) . simplified ( ) ) ;
2011-05-05 12:27:25 +02:00
lineEditCustomParamAften - > setText ( lineEditCustomParamAften - > text ( ) . simplified ( ) ) ;
2011-02-09 23:36:17 +01:00
bool customParamsUsed = false ;
if ( ! lineEditCustomParamLAME - > text ( ) . isEmpty ( ) ) customParamsUsed = true ;
if ( ! lineEditCustomParamOggEnc - > text ( ) . isEmpty ( ) ) customParamsUsed = true ;
if ( ! lineEditCustomParamNeroAAC - > text ( ) . isEmpty ( ) ) customParamsUsed = true ;
if ( ! lineEditCustomParamFLAC - > text ( ) . isEmpty ( ) ) customParamsUsed = true ;
2011-05-05 12:27:25 +02:00
if ( ! lineEditCustomParamAften - > text ( ) . isEmpty ( ) ) customParamsUsed = true ;
2011-02-09 23:36:17 +01:00
labelCustomParamsIcon - > setVisible ( customParamsUsed ) ;
2011-05-21 13:07:17 +02:00
labelCustomParamsText - > setVisible ( customParamsUsed ) ;
labelCustomParamsSpacer - > setVisible ( customParamsUsed ) ;
2011-02-14 19:03:36 +01:00
2011-05-21 13:07:17 +02:00
m_settings - > customParametersLAME ( lineEditCustomParamLAME - > text ( ) ) ;
m_settings - > customParametersOggEnc ( lineEditCustomParamOggEnc - > text ( ) ) ;
2011-08-21 14:43:18 +02:00
m_settings - > customParametersAacEnc ( lineEditCustomParamNeroAAC - > text ( ) ) ;
2011-05-21 13:07:17 +02:00
m_settings - > customParametersFLAC ( lineEditCustomParamFLAC - > text ( ) ) ;
m_settings - > customParametersAften ( lineEditCustomParamAften - > text ( ) ) ;
2010-12-05 23:11:03 +01:00
}
2011-08-04 23:26:38 +02:00
/*
* Rename output files enabled changed
*/
void MainWindow : : renameOutputEnabledChanged ( bool checked )
{
m_settings - > renameOutputFilesEnabled ( checked ) ;
}
/*
* Rename output files patterm changed
*/
void MainWindow : : renameOutputPatternChanged ( void )
{
2011-08-05 02:33:32 +02:00
QString temp = lineEditRenamePattern - > text ( ) . simplified ( ) ;
lineEditRenamePattern - > setText ( temp . isEmpty ( ) ? m_settings - > renameOutputFilesPatternDefault ( ) : temp ) ;
2011-08-04 23:26:38 +02:00
m_settings - > renameOutputFilesPattern ( lineEditRenamePattern - > text ( ) ) ;
}
/*
* Rename output files patterm changed
*/
void MainWindow : : renameOutputPatternChanged ( const QString & text )
{
2011-08-05 15:41:19 +02:00
QString pattern ( text . simplified ( ) ) ;
2011-08-04 23:26:38 +02:00
2011-08-05 15:41:19 +02:00
pattern . replace ( " <BaseName> " , " The_White_Stripes_-_Fell_In_Love_With_A_Girl " , Qt : : CaseInsensitive ) ;
pattern . replace ( " <TrackNo> " , " 04 " , Qt : : CaseInsensitive ) ;
pattern . replace ( " <Title> " , " Fell In Love With A Girl " , Qt : : CaseInsensitive ) ;
pattern . replace ( " <Artist> " , " The White Stripes " , Qt : : CaseInsensitive ) ;
pattern . replace ( " <Album> " , " White Blood Cells " , Qt : : CaseInsensitive ) ;
pattern . replace ( " <Year> " , " 2001 " , Qt : : CaseInsensitive ) ;
pattern . replace ( " <Comment> " , " Encoded by LameXP " , Qt : : CaseInsensitive ) ;
2011-08-04 23:26:38 +02:00
if ( pattern . compare ( lamexp_clean_filename ( pattern ) ) )
{
if ( lineEditRenamePattern - > palette ( ) . color ( QPalette : : Text ) ! = Qt : : red )
{
MessageBeep ( MB_ICONERROR ) ;
SET_TEXT_COLOR ( lineEditRenamePattern , Qt : : red ) ;
}
}
else
{
if ( lineEditRenamePattern - > palette ( ) . color ( QPalette : : Text ) ! = Qt : : black )
{
MessageBeep ( MB_ICONINFORMATION ) ;
SET_TEXT_COLOR ( lineEditRenamePattern , Qt : : black ) ;
}
}
2011-08-05 15:41:19 +02:00
labelRanameExample - > setText ( lamexp_clean_filename ( pattern ) ) ;
2011-08-04 23:26:38 +02:00
}
/*
* Show list of rename macros
*/
2011-08-05 02:33:32 +02:00
void MainWindow : : showRenameMacros ( const QString & text )
2011-08-04 23:26:38 +02:00
{
2011-08-05 02:33:32 +02:00
if ( text . compare ( " reset " , Qt : : CaseInsensitive ) = = 0 )
{
lineEditRenamePattern - > setText ( m_settings - > renameOutputFilesPatternDefault ( ) ) ;
return ;
}
2011-08-04 23:26:38 +02:00
const QString format = QString ( " <tr><td><tt><%1></tt></td><td> </td><td>%2</td></tr> " ) ;
2011-08-05 02:33:32 +02:00
QString message = QString ( " <table> " ) ;
message + = QString ( format ) . arg ( " BaseName " , tr ( " File name without extension " ) ) ;
message + = QString ( format ) . arg ( " TrackNo " , tr ( " Track number with leading zero " ) ) ;
message + = QString ( format ) . arg ( " Title " , tr ( " Track title " ) ) ;
message + = QString ( format ) . arg ( " Artist " , tr ( " Artist name " ) ) ;
message + = QString ( format ) . arg ( " Album " , tr ( " Album name " ) ) ;
message + = QString ( format ) . arg ( " Year " , tr ( " Year with (at least) four digits " ) ) ;
message + = QString ( format ) . arg ( " Comment " , tr ( " Comment " ) ) ;
2011-08-05 15:41:19 +02:00
message + = " </table><br><br> " ;
message + = QString ( " %1<br> " ) . arg ( tr ( " Characters forbidden in file names: " ) ) ;
message + = " <b><tt> \\ / : * ? < > |<br> " ;
2011-08-04 23:26:38 +02:00
2011-08-05 02:33:32 +02:00
QMessageBox : : information ( this , tr ( " Rename Macros " ) , message , tr ( " Discard " ) ) ;
2011-08-04 23:26:38 +02:00
}
2011-08-05 21:52:43 +02:00
void MainWindow : : forceStereoDownmixEnabledChanged ( bool checked )
{
m_settings - > forceStereoDownmix ( checked ) ;
}
2010-12-05 23:11:03 +01:00
/*
2011-05-21 13:07:17 +02:00
* Maximum number of instances changed
2010-12-05 23:11:03 +01:00
*/
2011-05-21 13:07:17 +02:00
void MainWindow : : updateMaximumInstances ( int value )
2010-12-05 23:11:03 +01:00
{
2011-05-21 13:07:17 +02:00
labelMaxInstances - > setText ( tr ( " %1 Instance(s) " ) . arg ( QString : : number ( value ) ) ) ;
m_settings - > maximumInstances ( checkBoxAutoDetectInstances - > isChecked ( ) ? NULL : value ) ;
2010-12-05 23:11:03 +01:00
}
2010-11-29 20:36:27 +01:00
/*
2011-05-21 13:07:17 +02:00
* Auto - detect number of instances
2010-11-29 20:36:27 +01:00
*/
2011-05-21 13:07:17 +02:00
void MainWindow : : autoDetectInstancesChanged ( bool checked )
2010-11-29 20:36:27 +01:00
{
2011-05-21 13:07:17 +02:00
m_settings - > maximumInstances ( checked ? NULL : sliderMaxInstances - > value ( ) ) ;
2010-11-29 20:36:27 +01:00
}
/*
2011-05-21 13:07:17 +02:00
* Browse for custom TEMP folder button clicked
2010-11-29 20:36:27 +01:00
*/
2011-05-21 13:07:17 +02:00
void MainWindow : : browseCustomTempFolderButtonClicked ( void )
2010-11-29 20:36:27 +01:00
{
2011-08-23 18:48:16 +02:00
QString newTempFolder ;
if ( USE_NATIVE_FILE_DIALOG )
{
newTempFolder = QFileDialog : : getExistingDirectory ( this , QString ( ) , m_settings - > customTempPath ( ) ) ;
}
else
{
QFileDialog dialog ( this ) ;
dialog . setFileMode ( QFileDialog : : DirectoryOnly ) ;
dialog . setDirectory ( m_settings - > customTempPath ( ) ) ;
if ( dialog . exec ( ) )
{
newTempFolder = dialog . selectedFiles ( ) . first ( ) ;
}
}
2010-12-12 01:49:07 +01:00
2011-05-21 13:07:17 +02:00
if ( ! newTempFolder . isEmpty ( ) )
2010-12-19 21:23:43 +01:00
{
2011-05-21 13:07:17 +02:00
QFile writeTest ( QString ( " %1/~%2.tmp " ) . arg ( newTempFolder , lamexp_rand_str ( ) ) ) ;
if ( writeTest . open ( QIODevice : : ReadWrite ) )
2010-12-19 21:23:43 +01:00
{
2011-05-21 13:07:17 +02:00
writeTest . remove ( ) ;
lineEditCustomTempFolder - > setText ( QDir : : toNativeSeparators ( newTempFolder ) ) ;
2010-12-19 21:23:43 +01:00
}
else
{
2011-05-21 13:07:17 +02:00
QMessageBox : : warning ( this , tr ( " Access Denied " ) , tr ( " Cannot write to the selected directory. Please choose another directory! " ) ) ;
2010-12-19 21:23:43 +01:00
}
}
}
/*
2011-05-21 13:07:17 +02:00
* Custom TEMP folder changed
2010-12-19 21:23:43 +01:00
*/
2011-05-21 13:07:17 +02:00
void MainWindow : : customTempFolderChanged ( const QString & text )
2010-12-19 21:23:43 +01:00
{
2011-05-21 13:07:17 +02:00
m_settings - > customTempPath ( QDir : : fromNativeSeparators ( text ) ) ;
2010-12-19 21:23:43 +01:00
}
/*
2011-05-21 13:07:17 +02:00
* Use custom TEMP folder option changed
2010-12-19 21:23:43 +01:00
*/
2011-05-21 13:07:17 +02:00
void MainWindow : : useCustomTempFolderChanged ( bool checked )
2010-12-12 01:49:07 +01:00
{
2011-05-21 13:07:17 +02:00
m_settings - > customTempPathEnabled ( ! checked ) ;
2011-01-29 00:40:29 +01:00
}
2010-12-12 01:49:07 +01:00
2011-05-12 22:57:08 +02:00
/*
2011-05-21 13:07:17 +02:00
* Reset all advanced options to their defaults
2011-05-12 22:57:08 +02:00
*/
2011-05-21 13:07:17 +02:00
void MainWindow : : resetAdvancedOptionsButtonClicked ( void )
2011-05-12 22:57:08 +02:00
{
2011-05-21 13:07:17 +02:00
sliderLameAlgoQuality - > setValue ( m_settings - > lameAlgoQualityDefault ( ) ) ;
spinBoxBitrateManagementMin - > setValue ( m_settings - > bitrateManagementMinRateDefault ( ) ) ;
spinBoxBitrateManagementMax - > setValue ( m_settings - > bitrateManagementMaxRateDefault ( ) ) ;
spinBoxNormalizationFilter - > setValue ( static_cast < double > ( m_settings - > normalizationFilterMaxVolumeDefault ( ) ) / 100.0 ) ;
spinBoxToneAdjustBass - > setValue ( static_cast < double > ( m_settings - > toneAdjustBassDefault ( ) ) / 100.0 ) ;
spinBoxToneAdjustTreble - > setValue ( static_cast < double > ( m_settings - > toneAdjustTrebleDefault ( ) ) / 100.0 ) ;
spinBoxAftenSearchSize - > setValue ( m_settings - > aftenExponentSearchSizeDefault ( ) ) ;
comboBoxMP3ChannelMode - > setCurrentIndex ( m_settings - > lameChannelModeDefault ( ) ) ;
comboBoxSamplingRate - > setCurrentIndex ( m_settings - > samplingRateDefault ( ) ) ;
2011-08-21 14:43:18 +02:00
comboBoxAACProfile - > setCurrentIndex ( m_settings - > aacEncProfileDefault ( ) ) ;
2011-05-21 13:07:17 +02:00
comboBoxAftenCodingMode - > setCurrentIndex ( m_settings - > aftenAudioCodingModeDefault ( ) ) ;
comboBoxAftenDRCMode - > setCurrentIndex ( m_settings - > aftenDynamicRangeCompressionDefault ( ) ) ;
2011-10-06 23:55:42 +02:00
comboBoxNormalizationMode - > setCurrentIndex ( m_settings - > normalizationFilterEqualizationModeDefault ( ) ) ;
2011-05-21 13:07:17 +02:00
while ( checkBoxBitrateManagement - > isChecked ( ) ! = m_settings - > bitrateManagementEnabledDefault ( ) ) checkBoxBitrateManagement - > click ( ) ;
while ( checkBoxNeroAAC2PassMode - > isChecked ( ) ! = m_settings - > neroAACEnable2PassDefault ( ) ) checkBoxNeroAAC2PassMode - > click ( ) ;
while ( checkBoxNormalizationFilter - > isChecked ( ) ! = m_settings - > normalizationFilterEnabledDefault ( ) ) checkBoxNormalizationFilter - > click ( ) ;
while ( checkBoxAutoDetectInstances - > isChecked ( ) ! = ( m_settings - > maximumInstancesDefault ( ) < 1 ) ) checkBoxAutoDetectInstances - > click ( ) ;
while ( checkBoxUseSystemTempFolder - > isChecked ( ) = = m_settings - > customTempPathEnabledDefault ( ) ) checkBoxUseSystemTempFolder - > click ( ) ;
while ( checkBoxAftenFastAllocation - > isChecked ( ) ! = m_settings - > aftenFastBitAllocationDefault ( ) ) checkBoxAftenFastAllocation - > click ( ) ;
2011-08-04 23:26:38 +02:00
while ( checkBoxRenameOutput - > isChecked ( ) ! = m_settings - > renameOutputFilesEnabledDefault ( ) ) checkBoxRenameOutput - > click ( ) ;
2011-08-05 21:52:43 +02:00
while ( checkBoxForceStereoDownmix - > isChecked ( ) ! = m_settings - > forceStereoDownmixDefault ( ) ) checkBoxForceStereoDownmix - > click ( ) ;
2011-05-21 13:07:17 +02:00
lineEditCustomParamLAME - > setText ( m_settings - > customParametersLAMEDefault ( ) ) ;
lineEditCustomParamOggEnc - > setText ( m_settings - > customParametersOggEncDefault ( ) ) ;
2011-08-21 14:43:18 +02:00
lineEditCustomParamNeroAAC - > setText ( m_settings - > customParametersAacEncDefault ( ) ) ;
2011-05-21 13:07:17 +02:00
lineEditCustomParamFLAC - > setText ( m_settings - > customParametersFLACDefault ( ) ) ;
lineEditCustomTempFolder - > setText ( QDir : : toNativeSeparators ( m_settings - > customTempPathDefault ( ) ) ) ;
2011-08-04 23:26:38 +02:00
lineEditRenamePattern - > setText ( m_settings - > renameOutputFilesPatternDefault ( ) ) ;
2011-05-21 13:07:17 +02:00
customParamsChanged ( ) ;
scrollArea - > verticalScrollBar ( ) - > setValue ( 0 ) ;
2011-05-12 22:57:08 +02:00
}
2011-05-21 13:07:17 +02:00
// =========================================================
// Multi-instance handling slots
// =========================================================
2011-01-29 00:40:29 +01:00
/*
2011-05-21 13:07:17 +02:00
* Other instance detected
2011-01-29 00:40:29 +01:00
*/
2011-05-21 13:07:17 +02:00
void MainWindow : : notifyOtherInstance ( void )
2011-01-29 00:40:29 +01:00
{
2011-05-21 13:07:17 +02:00
if ( ! m_banner - > isVisible ( ) )
2010-12-12 01:49:07 +01:00
{
2011-05-21 13:07:17 +02:00
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 ) ;
msgBox . exec ( ) ;
2010-12-12 01:49:07 +01:00
}
2011-01-29 00:40:29 +01:00
}
2010-12-12 01:49:07 +01:00
2011-05-03 14:28:06 +02:00
/*
2011-05-21 13:07:17 +02:00
* Add file from another instance
2011-05-03 14:28:06 +02:00
*/
2011-06-11 17:18:30 +02:00
void MainWindow : : addFileDelayed ( const QString & filePath , bool tryASAP )
2011-05-21 13:07:17 +02:00
{
2011-06-11 17:18:30 +02:00
if ( tryASAP & & ! m_delayedFileTimer - > isActive ( ) )
{
qDebug ( " Received file: %s " , filePath . toUtf8 ( ) . constData ( ) ) ;
m_delayedFileList - > append ( filePath ) ;
QTimer : : singleShot ( 0 , this , SLOT ( handleDelayedFiles ( ) ) ) ;
}
2011-05-21 13:07:17 +02:00
m_delayedFileTimer - > stop ( ) ;
qDebug ( " Received file: %s " , filePath . toUtf8 ( ) . constData ( ) ) ;
m_delayedFileList - > append ( filePath ) ;
m_delayedFileTimer - > start ( 5000 ) ;
2011-05-03 14:28:06 +02:00
}
2011-06-11 17:18:30 +02:00
/*
* Add files from another instance
*/
void MainWindow : : addFilesDelayed ( const QStringList & filePaths , bool tryASAP )
{
if ( tryASAP & & ! m_delayedFileTimer - > isActive ( ) )
{
2011-07-28 13:37:00 +02:00
qDebug ( " Received %d file(s). " , filePaths . count ( ) ) ;
2011-06-11 17:18:30 +02:00
m_delayedFileList - > append ( filePaths ) ;
QTimer : : singleShot ( 0 , this , SLOT ( handleDelayedFiles ( ) ) ) ;
}
2011-07-28 13:37:00 +02:00
else
{
m_delayedFileTimer - > stop ( ) ;
qDebug ( " Received %d file(s). " , filePaths . count ( ) ) ;
m_delayedFileList - > append ( filePaths ) ;
m_delayedFileTimer - > start ( 5000 ) ;
}
2011-06-11 17:18:30 +02:00
}
/*
* Add folder from another instance
*/
void MainWindow : : addFolderDelayed ( const QString & folderPath , bool recursive )
{
if ( ! m_banner - > isVisible ( ) )
{
addFolder ( folderPath , recursive , true ) ;
}
}
2011-05-21 13:07:17 +02:00
// =========================================================
// Misc slots
// =========================================================
2011-01-29 00:40:29 +01:00
/*
2011-05-21 13:07:17 +02:00
* Restore the override cursor
2011-01-29 00:40:29 +01:00
*/
2011-05-21 13:07:17 +02:00
void MainWindow : : restoreCursor ( void )
2011-01-29 00:40:29 +01:00
{
2011-05-21 13:07:17 +02:00
QApplication : : restoreOverrideCursor ( ) ;
2010-12-22 01:01:01 +01:00
}