2010-11-06 23:04:47 +01:00
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
2015-01-01 18:06:21 +01:00
// Copyright (C) 2004-2015 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
2013-10-23 20:56:57 +02:00
// (at your option) any later version, but always including the *additional*
// restrictions defined in the "License.txt" file.
2010-11-06 23:04:47 +01:00
//
// 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"
2012-12-04 01:35:48 +01:00
//UIC includes
2014-11-24 18:28:53 +01:00
# include "UIC_MainWindow.h"
2012-12-04 01:35:48 +01:00
2010-11-06 23:04:47 +01:00
//LameXP includes
# include "Global.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"
2012-07-29 22:55:02 +02:00
# include "Dialog_LogView.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"
2013-10-02 16:39:26 +02:00
# include "Registry_Encoder.h"
2010-12-20 22:13:01 +01:00
# include "Registry_Decoder.h"
2013-10-02 16:39:26 +02:00
# include "Encoder_Abstract.h"
2011-01-27 22:10:51 +01:00
# include "ShellIntegration.h"
2012-07-29 22:55:02 +02:00
# include "CustomEventFilter.h"
2010-11-06 23:04:47 +01:00
2014-11-25 02:14:42 +01:00
//Mutils includes
# include <MUtils/Global.h>
# include <MUtils/OSSupport.h>
2014-11-29 01:25:18 +01:00
# include <MUtils/GUI.h>
2014-11-30 21:32:23 +01:00
# include <MUtils/Exception.h>
2014-12-05 21:08:26 +01:00
# include <MUtils/Sound.h>
2014-12-20 23:44:43 +01:00
# include <MUtils/Translation.h>
2014-11-25 02:14:42 +01:00
# include <MUtils/Version.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
2012-07-29 19:09:15 +02:00
////////////////////////////////////////////////////////////
2012-07-29 22:55:02 +02:00
// Helper macros
2012-07-29 19:09:15 +02:00
////////////////////////////////////////////////////////////
2013-11-26 23:01:37 +01:00
# define BANNER_VISIBLE ((m_banner != NULL) && m_banner->isVisible())
# define INIT_BANNER() do \
{ \
if ( m_banner = = NULL ) \
{ \
m_banner = new WorkingBanner ( this ) ; \
} \
} \
while ( 0 )
2013-11-29 01:20:59 +01:00
# define SHOW_BANNER(TXT) do \
{ \
INIT_BANNER ( ) ; \
m_banner - > show ( ( TXT ) ) ; \
} \
while ( 0 )
# define SHOW_BANNER_ARG(TXT, ARG) do \
{ \
INIT_BANNER ( ) ; \
m_banner - > show ( ( TXT ) , ( ARG ) ) ; \
} \
while ( 0 )
# define SHOW_BANNER_CONDITIONALLY(FLAG, TEST, TXT) do \
{ \
if ( ( ! ( FLAG ) ) & & ( ( TEST ) ) ) \
{ \
INIT_BANNER ( ) ; \
m_banner - > show ( ( TXT ) ) ; \
FLAG = true ; \
} \
} \
while ( 0 )
2012-07-29 19:09:15 +02:00
# define ABORT_IF_BUSY do \
{ \
2014-05-19 17:44:41 +02:00
if ( BANNER_VISIBLE | | m_delayedFileTimer - > isActive ( ) | | ( QApplication : : activeModalWidget ( ) ! = NULL ) ) \
2012-07-29 19:09:15 +02:00
{ \
2014-12-05 21:08:26 +01:00
MUtils : : Sound : : beep ( MUtils : : Sound : : BEEP_WRN ) ; \
2012-07-29 19:09:15 +02:00
return ; \
} \
} \
while ( 0 )
# define SET_TEXT_COLOR(WIDGET, COLOR) do \
{ \
QPalette _palette = WIDGET - > palette ( ) ; \
_palette . setColor ( QPalette : : WindowText , ( COLOR ) ) ; \
_palette . setColor ( QPalette : : Text , ( COLOR ) ) ; \
WIDGET - > setPalette ( _palette ) ; \
} \
while ( 0 )
# define SET_FONT_BOLD(WIDGET,BOLD) do \
{ \
QFont _font = WIDGET - > font ( ) ; \
_font . setBold ( BOLD ) ; \
WIDGET - > setFont ( _font ) ; \
} \
while ( 0 )
# define TEMP_HIDE_DROPBOX(CMD) do \
{ \
bool _dropBoxVisible = m_dropBox - > isVisible ( ) ; \
if ( _dropBoxVisible ) m_dropBox - > hide ( ) ; \
do { CMD } while ( 0 ) ; \
if ( _dropBoxVisible ) m_dropBox - > show ( ) ; \
} \
while ( 0 )
# define SET_MODEL(VIEW, MODEL) do \
{ \
QItemSelectionModel * _tmp = ( VIEW ) - > selectionModel ( ) ; \
( VIEW ) - > setModel ( MODEL ) ; \
2014-11-25 02:14:42 +01:00
MUTILS_DELETE ( _tmp ) ; \
2012-07-29 19:09:15 +02:00
} \
while ( 0 )
2012-07-29 22:55:02 +02:00
# define SET_CHECKBOX_STATE(CHCKBX, STATE) do \
{ \
2015-03-21 19:06:55 +01:00
const bool isDisabled = ( ! ( CHCKBX ) - > isEnabled ( ) ) ; \
if ( isDisabled ) \
{ \
( CHCKBX ) - > setEnabled ( true ) ; \
} \
2012-07-29 22:55:02 +02:00
if ( ( CHCKBX ) - > isChecked ( ) ! = ( STATE ) ) \
{ \
( CHCKBX ) - > click ( ) ; \
} \
if ( ( CHCKBX ) - > isChecked ( ) ! = ( STATE ) ) \
{ \
qWarning ( " Warning: Failed to set checkbox " # CHCKBX " state! " ) ; \
} \
2015-03-21 19:06:55 +01:00
if ( isDisabled ) \
{ \
( CHCKBX ) - > setEnabled ( false ) ; \
} \
2012-07-29 22:55:02 +02:00
} \
while ( 0 )
# define TRIM_STRING_RIGHT(STR) do \
{ \
while ( ( STR . length ( ) > 0 ) & & STR [ STR . length ( ) - 1 ] . isSpace ( ) ) STR . chop ( 1 ) ; \
} \
while ( 0 )
2012-12-19 23:43:27 +01:00
# define MAKE_TRANSPARENT(WIDGET, FLAG) do \
{ \
QPalette _p = ( WIDGET ) - > palette ( ) ; \
_p . setColor ( QPalette : : Background , Qt : : transparent ) ; \
( WIDGET ) - > setPalette ( FLAG ? _p : QPalette ( ) ) ; \
} \
while ( 0 )
2013-07-07 23:49:29 +02:00
# define WITH_BLOCKED_SIGNALS(WIDGET, CMD, ...) do \
{ \
2013-07-09 22:34:06 +02:00
const bool _flag = ( WIDGET ) - > blockSignals ( true ) ; \
2013-07-07 23:49:29 +02:00
( WIDGET ) - > CMD ( __VA_ARGS__ ) ; \
2013-07-09 22:34:06 +02:00
if ( ! ( _flag ) ) { ( WIDGET ) - > blockSignals ( false ) ; } \
2013-07-07 23:49:29 +02:00
} \
while ( 0 )
2013-12-03 22:19:11 +01:00
# define PLAY_SOUND_OPTIONAL(NAME, ASYNC) do \
{ \
2014-12-05 21:08:26 +01:00
if ( m_settings - > soundsEnabled ( ) ) MUtils : : Sound : : play_sound ( ( NAME ) , ( ASYNC ) ) ; \
2013-12-03 22:19:11 +01:00
} \
while ( 0 )
2014-05-04 16:59:06 +02:00
# define SHOW_CORNER_WIDGET(FLAG) do \
{ \
if ( QWidget * cornerWidget = ui - > menubar - > cornerWidget ( ) ) \
{ \
cornerWidget - > setVisible ( ( FLAG ) ) ; \
} \
} \
while ( 0 )
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("-", "−"))
2012-03-29 19:08:33 +02:00
# define CENTER_CURRENT_OUTPUT_FOLDER_DELAYED QTimer::singleShot(125, this, SLOT(centerOutputFolderModel()))
2010-11-11 19:37:16 +01:00
2013-10-07 00:01:15 +02:00
static const unsigned int IDM_ABOUTBOX = 0xEFF0 ;
2014-06-27 21:06:33 +02:00
static const char * g_hydrogen_audio_url = " http://wiki.hydrogenaud.io/index.php?title=Main_Page " ;
2014-12-26 00:42:53 +01:00
static const char * g_documents_base_url = " http://lamexp.sourceforge.net/doc " ;
2012-10-17 23:34:42 +02:00
2010-11-06 23:04:47 +01:00
////////////////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////////////////
2014-12-13 23:27:47 +01:00
MainWindow : : MainWindow ( MUtils : : IPCChannel * const ipcChannel , FileListModel * const fileListModel , AudioFileModel_MetaInfo * const metaInfo , SettingsModel * const settingsModel , QWidget * const parent )
2010-11-19 21:11:54 +01:00
:
QMainWindow ( parent ) ,
2012-12-04 01:35:48 +01:00
ui ( new Ui : : MainWindow ) ,
2010-11-19 21:11:54 +01:00
m_fileListModel ( fileListModel ) ,
m_metaData ( metaInfo ) ,
m_settings ( settingsModel ) ,
2012-04-05 15:24:45 +02:00
m_fileSystemModel ( NULL ) ,
2013-11-26 23:01:37 +01:00
m_banner ( NULL ) ,
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
2012-12-04 01:35:48 +01:00
ui - > setupUi ( this ) ;
2010-11-15 04:42:06 +01:00
setWindowFlags ( windowFlags ( ) ^ Qt : : WindowMaximizeButtonHint ) ;
2013-11-26 23:01:37 +01:00
//Create window icon
2014-12-04 22:59:30 +01:00
MUtils : : GUI : : set_window_icon ( this , lamexp_app_icon ( ) , true ) ;
2013-11-26 23:01:37 +01:00
2010-11-06 23:04:47 +01:00
//Register meta types
qRegisterMetaType < AudioFileModel > ( " AudioFileModel " ) ;
//Enabled main buttons
2012-12-04 01:35:48 +01:00
connect ( ui - > buttonAbout , SIGNAL ( clicked ( ) ) , this , SLOT ( aboutButtonClicked ( ) ) ) ;
connect ( ui - > buttonStart , SIGNAL ( clicked ( ) ) , this , SLOT ( encodeButtonClicked ( ) ) ) ;
2014-05-04 16:59:06 +02:00
connect ( ui - > buttonQuit , SIGNAL ( clicked ( ) ) , this , SLOT ( closeButtonClicked ( ) ) ) ;
2010-11-06 23:04:47 +01:00
//Setup tab widget
2012-12-04 01:35:48 +01:00
ui - > tabWidget - > setCurrentIndex ( 0 ) ;
connect ( ui - > tabWidget , SIGNAL ( currentChanged ( int ) ) , this , SLOT ( tabPageChanged ( int ) ) ) ;
2010-11-06 23:04:47 +01:00
2012-10-17 23:34:42 +02:00
//Add system menu
2014-12-08 22:06:01 +01:00
MUtils : : GUI : : sysmenu_append ( this , IDM_ABOUTBOX , " About... " ) ;
2012-10-17 23:34:42 +02:00
2014-05-04 16:59:06 +02:00
//Setup corner widget
QLabel * cornerWidget = new QLabel ( ui - > menubar ) ;
m_evenFilterCornerWidget = new CustomEventFilter ;
2014-05-04 21:00:59 +02:00
cornerWidget - > setText ( " N/A " ) ;
2014-05-04 16:59:06 +02:00
cornerWidget - > setFixedHeight ( ui - > menubar - > height ( ) ) ;
cornerWidget - > setCursor ( QCursor ( Qt : : PointingHandCursor ) ) ;
cornerWidget - > hide ( ) ;
cornerWidget - > installEventFilter ( m_evenFilterCornerWidget ) ;
connect ( m_evenFilterCornerWidget , SIGNAL ( eventOccurred ( QWidget * , QEvent * ) ) , this , SLOT ( cornerWidgetEventOccurred ( QWidget * , QEvent * ) ) ) ;
ui - > menubar - > setCornerWidget ( cornerWidget ) ;
2012-07-29 22:55:02 +02:00
//--------------------------------
// Setup "Source" tab
//--------------------------------
2012-12-04 01:35:48 +01:00
ui - > sourceFileView - > setModel ( m_fileListModel ) ;
ui - > sourceFileView - > verticalHeader ( ) - > setResizeMode ( QHeaderView : : ResizeToContents ) ;
ui - > sourceFileView - > horizontalHeader ( ) - > setResizeMode ( QHeaderView : : ResizeToContents ) ;
ui - > sourceFileView - > setContextMenuPolicy ( Qt : : CustomContextMenu ) ;
ui - > sourceFileView - > viewport ( ) - > installEventFilter ( this ) ;
m_dropNoteLabel = new QLabel ( ui - > sourceFileView ) ;
2010-11-20 02:14:22 +01:00
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 ) ;
2014-05-04 16:59:06 +02:00
connect ( ui - > buttonAddFiles , SIGNAL ( clicked ( ) ) , this , SLOT ( addFilesButtonClicked ( ) ) ) ;
connect ( ui - > buttonRemoveFile , SIGNAL ( clicked ( ) ) , this , SLOT ( removeFileButtonClicked ( ) ) ) ;
connect ( ui - > buttonClearFiles , SIGNAL ( clicked ( ) ) , this , SLOT ( clearFilesButtonClicked ( ) ) ) ;
connect ( ui - > buttonFileUp , SIGNAL ( clicked ( ) ) , this , SLOT ( fileUpButtonClicked ( ) ) ) ;
connect ( ui - > buttonFileDown , SIGNAL ( clicked ( ) ) , this , SLOT ( fileDownButtonClicked ( ) ) ) ;
connect ( ui - > buttonShowDetails , SIGNAL ( clicked ( ) ) , this , SLOT ( showDetailsButtonClicked ( ) ) ) ;
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 ( ) ) ) ;
connect ( ui - > sourceFileView , SIGNAL ( customContextMenuRequested ( QPoint ) ) , this , SLOT ( sourceFilesContextMenu ( QPoint ) ) ) ;
connect ( ui - > sourceFileView - > verticalScrollBar ( ) , SIGNAL ( sliderMoved ( int ) ) , this , SLOT ( sourceFilesScrollbarMoved ( int ) ) ) ;
connect ( ui - > sourceFileView - > verticalScrollBar ( ) , SIGNAL ( valueChanged ( int ) ) , this , SLOT ( sourceFilesScrollbarMoved ( int ) ) ) ;
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 ( ) ) ) ;
connect ( m_exportCsvContextAction , SIGNAL ( triggered ( bool ) ) , this , SLOT ( exportCsvContextActionTriggered ( ) ) ) ;
connect ( m_importCsvContextAction , SIGNAL ( triggered ( bool ) ) , this , SLOT ( importCsvContextActionTriggered ( ) ) ) ;
2010-11-25 20:41:59 +01:00
2012-07-29 22:55:02 +02:00
//--------------------------------
// Setup "Output" tab
//--------------------------------
2012-12-04 01:35:48 +01:00
ui - > outputFolderView - > setHeaderHidden ( true ) ;
ui - > outputFolderView - > setAnimated ( false ) ;
ui - > outputFolderView - > setMouseTracking ( false ) ;
ui - > outputFolderView - > setContextMenuPolicy ( Qt : : CustomContextMenu ) ;
ui - > outputFolderView - > setVerticalScrollBarPolicy ( Qt : : ScrollBarAlwaysOn ) ;
2012-07-30 21:44:44 +02:00
m_evenFilterOutputFolderMouse = new CustomEventFilter ;
2012-12-14 00:34:10 +01:00
ui - > outputFoldersGoUpLabel - > installEventFilter ( m_evenFilterOutputFolderMouse ) ;
2012-12-04 01:35:48 +01:00
ui - > outputFoldersEditorLabel - > installEventFilter ( m_evenFilterOutputFolderMouse ) ;
ui - > outputFoldersFovoritesLabel - > installEventFilter ( m_evenFilterOutputFolderMouse ) ;
ui - > outputFolderLabel - > installEventFilter ( m_evenFilterOutputFolderMouse ) ;
2012-07-30 21:44:44 +02:00
m_evenFilterOutputFolderView = new CustomEventFilter ;
2012-12-04 01:35:48 +01:00
ui - > outputFolderView - > installEventFilter ( m_evenFilterOutputFolderView ) ;
2012-07-30 21:44:44 +02:00
2012-12-04 01:35:48 +01:00
SET_CHECKBOX_STATE ( ui - > saveToSourceFolderCheckBox , m_settings - > outputToSourceDir ( ) ) ;
ui - > prependRelativePathCheckBox - > setChecked ( m_settings - > prependRelativeSourcePath ( ) ) ;
2012-07-30 21:44:44 +02:00
2012-12-04 01:35:48 +01:00
connect ( ui - > outputFolderView , SIGNAL ( clicked ( QModelIndex ) ) , this , SLOT ( outputFolderViewClicked ( QModelIndex ) ) ) ;
connect ( ui - > outputFolderView , SIGNAL ( activated ( QModelIndex ) ) , this , SLOT ( outputFolderViewClicked ( QModelIndex ) ) ) ;
connect ( ui - > outputFolderView , SIGNAL ( pressed ( QModelIndex ) ) , this , SLOT ( outputFolderViewClicked ( QModelIndex ) ) ) ;
connect ( ui - > outputFolderView , SIGNAL ( entered ( QModelIndex ) ) , this , SLOT ( outputFolderViewMoved ( QModelIndex ) ) ) ;
connect ( ui - > outputFolderView , SIGNAL ( expanded ( QModelIndex ) ) , this , SLOT ( outputFolderItemExpanded ( QModelIndex ) ) ) ;
connect ( ui - > buttonMakeFolder , SIGNAL ( clicked ( ) ) , this , SLOT ( makeFolderButtonClicked ( ) ) ) ;
connect ( ui - > buttonGotoHome , SIGNAL ( clicked ( ) ) , SLOT ( gotoHomeFolderButtonClicked ( ) ) ) ;
connect ( ui - > buttonGotoDesktop , SIGNAL ( clicked ( ) ) , this , SLOT ( gotoDesktopButtonClicked ( ) ) ) ;
connect ( ui - > buttonGotoMusic , SIGNAL ( clicked ( ) ) , this , SLOT ( gotoMusicFolderButtonClicked ( ) ) ) ;
connect ( ui - > saveToSourceFolderCheckBox , SIGNAL ( clicked ( ) ) , this , SLOT ( saveToSourceFolderChanged ( ) ) ) ;
connect ( ui - > prependRelativePathCheckBox , SIGNAL ( clicked ( ) ) , this , SLOT ( prependRelativePathChanged ( ) ) ) ;
connect ( ui - > outputFolderEdit , SIGNAL ( editingFinished ( ) ) , this , SLOT ( outputFolderEditFinished ( ) ) ) ;
2012-07-30 21:44:44 +02:00
connect ( m_evenFilterOutputFolderMouse , SIGNAL ( eventOccurred ( QWidget * , QEvent * ) ) , this , SLOT ( outputFolderMouseEventOccurred ( QWidget * , QEvent * ) ) ) ;
connect ( m_evenFilterOutputFolderView , SIGNAL ( eventOccurred ( QWidget * , QEvent * ) ) , this , SLOT ( outputFolderViewEventOccurred ( QWidget * , QEvent * ) ) ) ;
2012-04-05 15:24:45 +02:00
if ( m_outputFolderContextMenu = new QMenu ( ) )
{
m_showFolderContextAction = m_outputFolderContextMenu - > addAction ( QIcon ( " :/icons/zoom.png " ) , " N/A " ) ;
2012-12-14 23:50:56 +01:00
m_goUpFolderContextAction = m_outputFolderContextMenu - > addAction ( QIcon ( " :/icons/folder_up.png " ) , " N/A " ) ;
m_outputFolderContextMenu - > addSeparator ( ) ;
2012-04-05 15:24:45 +02:00
m_refreshFolderContextAction = m_outputFolderContextMenu - > addAction ( QIcon ( " :/icons/arrow_refresh.png " ) , " N/A " ) ;
m_outputFolderContextMenu - > setDefaultAction ( m_showFolderContextAction ) ;
2012-12-04 01:35:48 +01:00
connect ( ui - > outputFolderView , SIGNAL ( customContextMenuRequested ( QPoint ) ) , this , SLOT ( outputFolderContextMenu ( QPoint ) ) ) ;
2012-04-05 15:24:45 +02:00
connect ( m_showFolderContextAction , SIGNAL ( triggered ( bool ) ) , this , SLOT ( showFolderContextActionTriggered ( ) ) ) ;
connect ( m_refreshFolderContextAction , SIGNAL ( triggered ( bool ) ) , this , SLOT ( refreshFolderContextActionTriggered ( ) ) ) ;
2012-12-14 23:50:56 +01:00
connect ( m_goUpFolderContextAction , SIGNAL ( triggered ( bool ) ) , this , SLOT ( goUpFolderContextActionTriggered ( ) ) ) ;
2012-04-05 15:24:45 +02:00
}
2012-07-30 21:44:44 +02:00
2012-04-05 15:24:45 +02:00
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-07-30 21:44:44 +02:00
2012-12-04 01:35:48 +01:00
ui - > outputFolderEdit - > setVisible ( false ) ;
if ( m_outputFolderNoteBox = new QLabel ( ui - > outputFolderView ) )
2012-04-05 15:24:45 +02:00
{
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-07-30 21:44:44 +02:00
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
2012-07-29 22:55:02 +02:00
//--------------------------------
// Setup "Meta Data" tab
//--------------------------------
2013-10-13 00:21:37 +02:00
m_metaInfoModel = new MetaInfoModel ( m_metaData ) ;
2010-11-10 19:44:51 +01:00
m_metaInfoModel - > clearData ( ) ;
2011-02-10 16:08:03 +01:00
m_metaInfoModel - > setData ( m_metaInfoModel - > index ( 4 , 1 ) , m_settings - > metaInfoPosition ( ) ) ;
2012-12-04 01:35:48 +01:00
ui - > metaDataView - > setModel ( m_metaInfoModel ) ;
ui - > metaDataView - > verticalHeader ( ) - > setResizeMode ( QHeaderView : : ResizeToContents ) ;
ui - > metaDataView - > verticalHeader ( ) - > hide ( ) ;
ui - > metaDataView - > horizontalHeader ( ) - > setResizeMode ( QHeaderView : : ResizeToContents ) ;
SET_CHECKBOX_STATE ( ui - > writeMetaDataCheckBox , m_settings - > writeMetaTags ( ) ) ;
ui - > generatePlaylistCheckBox - > setChecked ( m_settings - > createPlaylist ( ) ) ;
connect ( ui - > buttonEditMeta , SIGNAL ( clicked ( ) ) , this , SLOT ( editMetaButtonClicked ( ) ) ) ;
connect ( ui - > buttonClearMeta , SIGNAL ( clicked ( ) ) , this , SLOT ( clearMetaButtonClicked ( ) ) ) ;
connect ( ui - > writeMetaDataCheckBox , SIGNAL ( clicked ( ) ) , this , SLOT ( metaTagsEnabledChanged ( ) ) ) ;
connect ( ui - > generatePlaylistCheckBox , SIGNAL ( clicked ( ) ) , this , SLOT ( playlistEnabledChanged ( ) ) ) ;
2010-11-20 22:14:10 +01:00
2012-07-29 22:55:02 +02:00
//--------------------------------
2010-11-11 22:58:02 +01:00
//Setup "Compression" tab
2012-07-29 22:55:02 +02:00
//--------------------------------
2010-11-15 04:42:06 +01:00
m_encoderButtonGroup = new QButtonGroup ( this ) ;
2012-12-04 01:35:48 +01:00
m_encoderButtonGroup - > addButton ( ui - > radioButtonEncoderMP3 , SettingsModel : : MP3Encoder ) ;
m_encoderButtonGroup - > addButton ( ui - > radioButtonEncoderVorbis , SettingsModel : : VorbisEncoder ) ;
m_encoderButtonGroup - > addButton ( ui - > radioButtonEncoderAAC , SettingsModel : : AACEncoder ) ;
m_encoderButtonGroup - > addButton ( ui - > radioButtonEncoderAC3 , SettingsModel : : AC3Encoder ) ;
m_encoderButtonGroup - > addButton ( ui - > radioButtonEncoderFLAC , SettingsModel : : FLACEncoder ) ;
2013-12-04 22:36:19 +01:00
m_encoderButtonGroup - > addButton ( ui - > radioButtonEncoderAPE , SettingsModel : : MACEncoder ) ;
2012-12-04 01:35:48 +01:00
m_encoderButtonGroup - > addButton ( ui - > radioButtonEncoderOpus , SettingsModel : : OpusEncoder ) ;
m_encoderButtonGroup - > addButton ( ui - > radioButtonEncoderDCA , SettingsModel : : DCAEncoder ) ;
m_encoderButtonGroup - > addButton ( ui - > radioButtonEncoderPCM , SettingsModel : : PCMEncoder ) ;
2012-08-02 23:32:21 +02:00
2013-10-02 19:17:33 +02:00
const int aacEncoder = EncoderRegistry : : getAacEncoder ( ) ;
ui - > radioButtonEncoderAAC - > setEnabled ( aacEncoder > SettingsModel : : AAC_ENCODER_NONE ) ;
2013-10-02 16:39:26 +02:00
2010-11-15 04:42:06 +01:00
m_modeButtonGroup = new QButtonGroup ( this ) ;
2012-12-04 01:35:48 +01:00
m_modeButtonGroup - > addButton ( ui - > radioButtonModeQuality , SettingsModel : : VBRMode ) ;
m_modeButtonGroup - > addButton ( ui - > radioButtonModeAverageBitrate , SettingsModel : : ABRMode ) ;
m_modeButtonGroup - > addButton ( ui - > radioButtonConstBitrate , SettingsModel : : CBRMode ) ;
2013-10-02 16:39:26 +02:00
ui - > radioButtonEncoderMP3 - > setChecked ( true ) ;
foreach ( QAbstractButton * currentButton , m_encoderButtonGroup - > buttons ( ) )
{
if ( currentButton - > isEnabled ( ) & & ( m_encoderButtonGroup - > id ( currentButton ) = = m_settings - > compressionEncoder ( ) ) )
{
currentButton - > setChecked ( true ) ;
break ;
}
}
2012-08-02 23:32:21 +02:00
m_evenFilterCompressionTab = new CustomEventFilter ( ) ;
2012-12-04 01:35:48 +01:00
ui - > labelCompressionHelp - > installEventFilter ( m_evenFilterCompressionTab ) ;
2013-07-14 18:14:26 +02:00
ui - > labelResetEncoders - > installEventFilter ( m_evenFilterCompressionTab ) ;
2012-08-02 23:32:21 +02:00
2010-11-15 04:42:06 +01:00
connect ( m_encoderButtonGroup , SIGNAL ( buttonClicked ( int ) ) , this , SLOT ( updateEncoder ( int ) ) ) ;
connect ( m_modeButtonGroup , SIGNAL ( buttonClicked ( int ) ) , this , SLOT ( updateRCMode ( int ) ) ) ;
2012-08-02 23:32:21 +02:00
connect ( m_evenFilterCompressionTab , SIGNAL ( eventOccurred ( QWidget * , QEvent * ) ) , this , SLOT ( compressionTabEventOccurred ( QWidget * , QEvent * ) ) ) ;
2012-12-04 01:35:48 +01:00
connect ( ui - > sliderBitrate , SIGNAL ( valueChanged ( int ) ) , this , SLOT ( updateBitrate ( int ) ) ) ;
2012-08-02 23:32:21 +02:00
2010-11-15 04:42:06 +01:00
updateEncoder ( m_encoderButtonGroup - > checkedId ( ) ) ;
2010-11-11 22:58:02 +01:00
2012-07-29 22:55:02 +02:00
//--------------------------------
2011-01-21 19:14:11 +01:00
//Setup "Advanced Options" tab
2012-07-29 22:55:02 +02:00
//--------------------------------
2012-12-04 01:35:48 +01:00
ui - > sliderLameAlgoQuality - > setValue ( m_settings - > lameAlgoQuality ( ) ) ;
if ( m_settings - > maximumInstances ( ) > 0 ) ui - > sliderMaxInstances - > setValue ( m_settings - > maximumInstances ( ) ) ;
2012-07-29 22:55:02 +02:00
2015-03-21 19:06:55 +01:00
ui - > spinBoxBitrateManagementMin - > setValue ( m_settings - > bitrateManagementMinRate ( ) ) ;
ui - > spinBoxBitrateManagementMax - > setValue ( m_settings - > bitrateManagementMaxRate ( ) ) ;
ui - > spinBoxNormalizationFilterPeak - > setValue ( static_cast < double > ( m_settings - > normalizationFilterMaxVolume ( ) ) / 100.0 ) ;
ui - > spinBoxNormalizationFilterSize - > setValue ( m_settings - > normalizationFilterSize ( ) ) ;
ui - > spinBoxToneAdjustBass - > setValue ( static_cast < double > ( m_settings - > toneAdjustBass ( ) ) / 100.0 ) ;
ui - > spinBoxToneAdjustTreble - > setValue ( static_cast < double > ( m_settings - > toneAdjustTreble ( ) ) / 100.0 ) ;
ui - > spinBoxAftenSearchSize - > setValue ( m_settings - > aftenExponentSearchSize ( ) ) ;
ui - > spinBoxOpusComplexity - > setValue ( m_settings - > opusComplexity ( ) ) ;
2012-07-29 22:55:02 +02:00
2015-03-21 19:06:55 +01:00
ui - > comboBoxMP3ChannelMode - > setCurrentIndex ( m_settings - > lameChannelMode ( ) ) ;
ui - > comboBoxSamplingRate - > setCurrentIndex ( m_settings - > samplingRate ( ) ) ;
ui - > comboBoxAACProfile - > setCurrentIndex ( m_settings - > aacEncProfile ( ) ) ;
ui - > comboBoxAftenCodingMode - > setCurrentIndex ( m_settings - > aftenAudioCodingMode ( ) ) ;
ui - > comboBoxAftenDRCMode - > setCurrentIndex ( m_settings - > aftenDynamicRangeCompression ( ) ) ;
ui - > comboBoxOpusFramesize - > setCurrentIndex ( m_settings - > opusFramesize ( ) ) ;
2012-07-29 22:55:02 +02:00
2015-03-21 19:06:55 +01:00
SET_CHECKBOX_STATE ( ui - > checkBoxBitrateManagement , m_settings - > bitrateManagementEnabled ( ) ) ;
SET_CHECKBOX_STATE ( ui - > checkBoxNeroAAC2PassMode , m_settings - > neroAACEnable2Pass ( ) ) ;
SET_CHECKBOX_STATE ( ui - > checkBoxAftenFastAllocation , m_settings - > aftenFastBitAllocation ( ) ) ;
SET_CHECKBOX_STATE ( ui - > checkBoxNormalizationFilterEnabled , m_settings - > normalizationFilterEnabled ( ) ) ;
SET_CHECKBOX_STATE ( ui - > checkBoxNormalizationFilterDynamic , m_settings - > normalizationFilterDynamic ( ) ) ;
SET_CHECKBOX_STATE ( ui - > checkBoxNormalizationFilterCoupled , m_settings - > normalizationFilterCoupled ( ) ) ;
SET_CHECKBOX_STATE ( ui - > checkBoxAutoDetectInstances , ( m_settings - > maximumInstances ( ) < 1 ) ) ;
SET_CHECKBOX_STATE ( ui - > checkBoxUseSystemTempFolder , ( ! m_settings - > customTempPathEnabled ( ) ) ) ;
SET_CHECKBOX_STATE ( ui - > checkBoxRenameOutput , m_settings - > renameOutputFilesEnabled ( ) ) ;
SET_CHECKBOX_STATE ( ui - > checkBoxForceStereoDownmix , m_settings - > forceStereoDownmix ( ) ) ;
SET_CHECKBOX_STATE ( ui - > checkBoxOpusDisableResample , m_settings - > opusDisableResample ( ) ) ;
2013-10-02 19:17:33 +02:00
ui - > checkBoxNeroAAC2PassMode - > setEnabled ( aacEncoder = = SettingsModel : : AAC_ENCODER_NERO ) ;
2012-07-29 22:55:02 +02:00
2013-10-03 17:01:37 +02:00
ui - > lineEditCustomParamLAME - > setText ( EncoderRegistry : : loadEncoderCustomParams ( m_settings , SettingsModel : : MP3Encoder ) ) ;
ui - > lineEditCustomParamOggEnc - > setText ( EncoderRegistry : : loadEncoderCustomParams ( m_settings , SettingsModel : : VorbisEncoder ) ) ;
ui - > lineEditCustomParamNeroAAC - > setText ( EncoderRegistry : : loadEncoderCustomParams ( m_settings , SettingsModel : : AACEncoder ) ) ;
ui - > lineEditCustomParamFLAC - > setText ( EncoderRegistry : : loadEncoderCustomParams ( m_settings , SettingsModel : : FLACEncoder ) ) ;
ui - > lineEditCustomParamAften - > setText ( EncoderRegistry : : loadEncoderCustomParams ( m_settings , SettingsModel : : AC3Encoder ) ) ;
ui - > lineEditCustomParamOpus - > setText ( EncoderRegistry : : loadEncoderCustomParams ( m_settings , SettingsModel : : OpusEncoder ) ) ;
ui - > lineEditCustomTempFolder - > setText ( QDir : : toNativeSeparators ( m_settings - > customTempPath ( ) ) ) ;
ui - > lineEditRenamePattern - > setText ( m_settings - > renameOutputFilesPattern ( ) ) ;
2012-07-29 22:55:02 +02:00
m_evenFilterCustumParamsHelp = new CustomEventFilter ( ) ;
2012-12-04 01:35:48 +01:00
ui - > helpCustomParamLAME - > installEventFilter ( m_evenFilterCustumParamsHelp ) ;
ui - > helpCustomParamOggEnc - > installEventFilter ( m_evenFilterCustumParamsHelp ) ;
ui - > helpCustomParamNeroAAC - > installEventFilter ( m_evenFilterCustumParamsHelp ) ;
ui - > helpCustomParamFLAC - > installEventFilter ( m_evenFilterCustumParamsHelp ) ;
ui - > helpCustomParamAften - > installEventFilter ( m_evenFilterCustumParamsHelp ) ;
ui - > helpCustomParamOpus - > installEventFilter ( m_evenFilterCustumParamsHelp ) ;
2012-07-29 22:55:02 +02:00
2012-11-08 00:42:55 +01:00
m_overwriteButtonGroup = new QButtonGroup ( this ) ;
2012-12-04 01:35:48 +01:00
m_overwriteButtonGroup - > addButton ( ui - > radioButtonOverwriteModeKeepBoth , SettingsModel : : Overwrite_KeepBoth ) ;
m_overwriteButtonGroup - > addButton ( ui - > radioButtonOverwriteModeSkipFile , SettingsModel : : Overwrite_SkipFile ) ;
m_overwriteButtonGroup - > addButton ( ui - > radioButtonOverwriteModeReplaces , SettingsModel : : Overwrite_Replaces ) ;
ui - > radioButtonOverwriteModeKeepBoth - > setChecked ( m_settings - > overwriteMode ( ) = = SettingsModel : : Overwrite_KeepBoth ) ;
ui - > radioButtonOverwriteModeSkipFile - > setChecked ( m_settings - > overwriteMode ( ) = = SettingsModel : : Overwrite_SkipFile ) ;
ui - > radioButtonOverwriteModeReplaces - > setChecked ( m_settings - > overwriteMode ( ) = = SettingsModel : : Overwrite_Replaces ) ;
2015-03-21 19:06:55 +01:00
connect ( ui - > sliderLameAlgoQuality , SIGNAL ( valueChanged ( int ) ) , this , SLOT ( updateLameAlgoQuality ( int ) ) ) ;
connect ( ui - > checkBoxBitrateManagement , SIGNAL ( clicked ( bool ) ) , this , SLOT ( bitrateManagementEnabledChanged ( bool ) ) ) ;
connect ( ui - > spinBoxBitrateManagementMin , SIGNAL ( valueChanged ( int ) ) , this , SLOT ( bitrateManagementMinChanged ( int ) ) ) ;
connect ( ui - > spinBoxBitrateManagementMax , SIGNAL ( valueChanged ( int ) ) , this , SLOT ( bitrateManagementMaxChanged ( int ) ) ) ;
connect ( ui - > comboBoxMP3ChannelMode , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( channelModeChanged ( int ) ) ) ;
connect ( ui - > comboBoxSamplingRate , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( samplingRateChanged ( int ) ) ) ;
connect ( ui - > checkBoxNeroAAC2PassMode , SIGNAL ( clicked ( bool ) ) , this , SLOT ( neroAAC2PassChanged ( bool ) ) ) ;
connect ( ui - > comboBoxAACProfile , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( neroAACProfileChanged ( int ) ) ) ;
connect ( ui - > checkBoxNormalizationFilterEnabled , SIGNAL ( clicked ( bool ) ) , this , SLOT ( normalizationEnabledChanged ( bool ) ) ) ;
connect ( ui - > checkBoxNormalizationFilterDynamic , SIGNAL ( clicked ( bool ) ) , this , SLOT ( normalizationDynamicChanged ( bool ) ) ) ;
connect ( ui - > checkBoxNormalizationFilterCoupled , SIGNAL ( clicked ( bool ) ) , this , SLOT ( normalizationCoupledChanged ( bool ) ) ) ;
connect ( ui - > comboBoxAftenCodingMode , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( aftenCodingModeChanged ( int ) ) ) ;
connect ( ui - > comboBoxAftenDRCMode , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( aftenDRCModeChanged ( int ) ) ) ;
connect ( ui - > spinBoxAftenSearchSize , SIGNAL ( valueChanged ( int ) ) , this , SLOT ( aftenSearchSizeChanged ( int ) ) ) ;
connect ( ui - > checkBoxAftenFastAllocation , SIGNAL ( clicked ( bool ) ) , this , SLOT ( aftenFastAllocationChanged ( bool ) ) ) ;
connect ( ui - > spinBoxNormalizationFilterPeak , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( normalizationMaxVolumeChanged ( double ) ) ) ;
connect ( ui - > spinBoxNormalizationFilterSize , SIGNAL ( valueChanged ( int ) ) , this , SLOT ( normalizationFilterSizeChanged ( int ) ) ) ;
connect ( ui - > spinBoxNormalizationFilterSize , SIGNAL ( editingFinished ( ) ) , this , SLOT ( normalizationFilterSizeFinished ( ) ) ) ;
connect ( ui - > spinBoxToneAdjustBass , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( toneAdjustBassChanged ( double ) ) ) ;
connect ( ui - > spinBoxToneAdjustTreble , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( toneAdjustTrebleChanged ( double ) ) ) ;
connect ( ui - > buttonToneAdjustReset , SIGNAL ( clicked ( ) ) , this , SLOT ( toneAdjustTrebleReset ( ) ) ) ;
connect ( ui - > lineEditCustomParamLAME , SIGNAL ( editingFinished ( ) ) , this , SLOT ( customParamsChanged ( ) ) ) ;
connect ( ui - > lineEditCustomParamOggEnc , SIGNAL ( editingFinished ( ) ) , this , SLOT ( customParamsChanged ( ) ) ) ;
connect ( ui - > lineEditCustomParamNeroAAC , SIGNAL ( editingFinished ( ) ) , this , SLOT ( customParamsChanged ( ) ) ) ;
connect ( ui - > lineEditCustomParamFLAC , SIGNAL ( editingFinished ( ) ) , this , SLOT ( customParamsChanged ( ) ) ) ;
connect ( ui - > lineEditCustomParamAften , SIGNAL ( editingFinished ( ) ) , this , SLOT ( customParamsChanged ( ) ) ) ;
connect ( ui - > lineEditCustomParamOpus , SIGNAL ( editingFinished ( ) ) , this , SLOT ( customParamsChanged ( ) ) ) ;
connect ( ui - > sliderMaxInstances , SIGNAL ( valueChanged ( int ) ) , this , SLOT ( updateMaximumInstances ( int ) ) ) ;
connect ( ui - > checkBoxAutoDetectInstances , SIGNAL ( clicked ( bool ) ) , this , SLOT ( autoDetectInstancesChanged ( bool ) ) ) ;
connect ( ui - > buttonBrowseCustomTempFolder , SIGNAL ( clicked ( ) ) , this , SLOT ( browseCustomTempFolderButtonClicked ( ) ) ) ;
connect ( ui - > lineEditCustomTempFolder , SIGNAL ( textChanged ( QString ) ) , this , SLOT ( customTempFolderChanged ( QString ) ) ) ;
connect ( ui - > checkBoxUseSystemTempFolder , SIGNAL ( clicked ( bool ) ) , this , SLOT ( useCustomTempFolderChanged ( bool ) ) ) ;
connect ( ui - > buttonResetAdvancedOptions , SIGNAL ( clicked ( ) ) , this , SLOT ( resetAdvancedOptionsButtonClicked ( ) ) ) ;
connect ( ui - > checkBoxRenameOutput , SIGNAL ( clicked ( bool ) ) , this , SLOT ( renameOutputEnabledChanged ( bool ) ) ) ;
connect ( ui - > lineEditRenamePattern , SIGNAL ( editingFinished ( ) ) , this , SLOT ( renameOutputPatternChanged ( ) ) ) ;
connect ( ui - > lineEditRenamePattern , SIGNAL ( textChanged ( QString ) ) , this , SLOT ( renameOutputPatternChanged ( QString ) ) ) ;
connect ( ui - > labelShowRenameMacros , SIGNAL ( linkActivated ( QString ) ) , this , SLOT ( showRenameMacros ( QString ) ) ) ;
connect ( ui - > checkBoxForceStereoDownmix , SIGNAL ( clicked ( bool ) ) , this , SLOT ( forceStereoDownmixEnabledChanged ( bool ) ) ) ;
connect ( ui - > comboBoxOpusFramesize , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( opusSettingsChanged ( ) ) ) ;
connect ( ui - > spinBoxOpusComplexity , SIGNAL ( valueChanged ( int ) ) , this , SLOT ( opusSettingsChanged ( ) ) ) ;
connect ( ui - > checkBoxOpusDisableResample , SIGNAL ( clicked ( bool ) ) , this , SLOT ( opusSettingsChanged ( ) ) ) ;
connect ( m_overwriteButtonGroup , SIGNAL ( buttonClicked ( int ) ) , this , SLOT ( overwriteModeChanged ( int ) ) ) ;
connect ( m_evenFilterCustumParamsHelp , SIGNAL ( eventOccurred ( QWidget * , QEvent * ) ) , this , SLOT ( customParamsHelpRequested ( QWidget * , QEvent * ) ) ) ;
2012-07-29 22:55:02 +02:00
//--------------------------------
// Force initial GUI update
//--------------------------------
2012-12-04 01:35:48 +01:00
updateLameAlgoQuality ( ui - > sliderLameAlgoQuality - > value ( ) ) ;
updateMaximumInstances ( ui - > sliderMaxInstances - > value ( ) ) ;
toneAdjustTrebleChanged ( ui - > spinBoxToneAdjustTreble - > value ( ) ) ;
toneAdjustBassChanged ( ui - > spinBoxToneAdjustBass - > value ( ) ) ;
2015-03-21 19:06:55 +01:00
normalizationEnabledChanged ( ui - > checkBoxNormalizationFilterEnabled - > isChecked ( ) ) ;
2011-02-09 23:36:17 +01:00
customParamsChanged ( ) ;
2011-01-21 19:14:11 +01:00
2012-07-29 22:55:02 +02:00
//--------------------------------
// Initialize actions
//--------------------------------
2010-11-06 23:04:47 +01:00
//Activate file menu actions
2012-12-04 01:35:48 +01:00
ui - > actionOpenFolder - > setData ( QVariant : : fromValue < bool > ( false ) ) ;
ui - > actionOpenFolderRecursively - > setData ( QVariant : : fromValue < bool > ( true ) ) ;
connect ( ui - > actionOpenFolder , SIGNAL ( triggered ( ) ) , this , SLOT ( openFolderActionActivated ( ) ) ) ;
connect ( ui - > actionOpenFolderRecursively , SIGNAL ( triggered ( ) ) , this , SLOT ( openFolderActionActivated ( ) ) ) ;
2010-11-06 23:04:47 +01:00
//Activate view menu actions
m_tabActionGroup = new QActionGroup ( this ) ;
2012-12-04 01:35:48 +01:00
m_tabActionGroup - > addAction ( ui - > actionSourceFiles ) ;
m_tabActionGroup - > addAction ( ui - > actionOutputDirectory ) ;
m_tabActionGroup - > addAction ( ui - > actionCompression ) ;
m_tabActionGroup - > addAction ( ui - > actionMetaData ) ;
m_tabActionGroup - > addAction ( ui - > actionAdvancedOptions ) ;
ui - > actionSourceFiles - > setData ( 0 ) ;
ui - > actionOutputDirectory - > setData ( 1 ) ;
ui - > actionMetaData - > setData ( 2 ) ;
ui - > actionCompression - > setData ( 3 ) ;
ui - > actionAdvancedOptions - > setData ( 4 ) ;
ui - > actionSourceFiles - > setChecked ( true ) ;
2010-11-06 23:04:47 +01:00
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 ) ;
2012-12-04 01:35:48 +01:00
m_styleActionGroup - > addAction ( ui - > actionStylePlastique ) ;
m_styleActionGroup - > addAction ( ui - > actionStyleCleanlooks ) ;
m_styleActionGroup - > addAction ( ui - > actionStyleWindowsVista ) ;
m_styleActionGroup - > addAction ( ui - > actionStyleWindowsXP ) ;
m_styleActionGroup - > addAction ( ui - > actionStyleWindowsClassic ) ;
ui - > actionStylePlastique - > setData ( 0 ) ;
ui - > actionStyleCleanlooks - > setData ( 1 ) ;
ui - > actionStyleWindowsVista - > setData ( 2 ) ;
ui - > actionStyleWindowsXP - > setData ( 3 ) ;
ui - > actionStyleWindowsClassic - > setData ( 4 ) ;
ui - > actionStylePlastique - > setChecked ( true ) ;
2014-12-08 22:06:01 +01:00
ui - > actionStyleWindowsXP - > setEnabled ( ( QSysInfo : : windowsVersion ( ) & QSysInfo : : WV_NT_based ) > = QSysInfo : : WV_XP & & MUtils : : GUI : : themes_enabled ( ) ) ;
ui - > actionStyleWindowsVista - > setEnabled ( ( QSysInfo : : windowsVersion ( ) & QSysInfo : : WV_NT_based ) > = QSysInfo : : WV_VISTA & & MUtils : : GUI : : 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 ) ;
2014-12-20 23:44:43 +01:00
QStringList translations ;
if ( MUtils : : Translation : : enumerate ( translations ) > 0 )
{
for ( QStringList : : ConstIterator iter = translations . constBegin ( ) ; iter ! = translations . constEnd ( ) ; iter + + )
{
QAction * currentLanguage = new QAction ( this ) ;
currentLanguage - > setData ( * iter ) ;
currentLanguage - > setText ( MUtils : : Translation : : get_name ( * iter ) ) ;
currentLanguage - > setIcon ( QIcon ( QString ( " :/flags/%1.png " ) . arg ( * iter ) ) ) ;
currentLanguage - > setCheckable ( true ) ;
currentLanguage - > setChecked ( false ) ;
m_languageActionGroup - > addAction ( currentLanguage ) ;
ui - > menuLanguage - > insertAction ( ui - > actionLoadTranslationFromFile , currentLanguage ) ;
}
2010-12-28 03:57:48 +01:00
}
2012-12-04 01:35:48 +01:00
ui - > menuLanguage - > insertSeparator ( ui - > actionLoadTranslationFromFile ) ;
connect ( ui - > actionLoadTranslationFromFile , SIGNAL ( triggered ( bool ) ) , this , SLOT ( languageFromFileActionActivated ( bool ) ) ) ;
2011-01-06 00:53:52 +01:00
connect ( m_languageActionGroup , SIGNAL ( triggered ( QAction * ) ) , this , SLOT ( languageActionActivated ( QAction * ) ) ) ;
2012-12-04 01:35:48 +01:00
ui - > actionLoadTranslationFromFile - > setChecked ( false ) ;
2010-12-30 16:12:21 +01:00
2010-11-29 20:36:27 +01:00
//Activate tools menu actions
2012-12-04 01:35:48 +01:00
ui - > actionDisableUpdateReminder - > setChecked ( ! m_settings - > autoUpdateEnabled ( ) ) ;
ui - > actionDisableSounds - > setChecked ( ! m_settings - > soundsEnabled ( ) ) ;
ui - > actionDisableNeroAacNotifications - > setChecked ( ! m_settings - > neroAacNotificationsEnabled ( ) ) ;
ui - > actionDisableSlowStartupNotifications - > setChecked ( ! m_settings - > antivirNotificationsEnabled ( ) ) ;
ui - > actionDisableShellIntegration - > setChecked ( ! m_settings - > shellIntegrationEnabled ( ) ) ;
2014-12-19 23:49:11 +01:00
ui - > actionDisableShellIntegration - > setDisabled ( lamexp_version_portable ( ) & & ui - > actionDisableShellIntegration - > isChecked ( ) ) ;
2012-12-04 01:35:48 +01:00
ui - > actionCheckForBetaUpdates - > setChecked ( m_settings - > autoUpdateCheckBeta ( ) | | lamexp_version_demo ( ) ) ;
ui - > actionCheckForBetaUpdates - > setEnabled ( ! lamexp_version_demo ( ) ) ;
ui - > actionHibernateComputer - > setChecked ( m_settings - > hibernateComputer ( ) ) ;
2014-12-04 00:02:42 +01:00
ui - > actionHibernateComputer - > setEnabled ( MUtils : : OS : : is_hibernation_supported ( ) ) ;
2012-12-04 01:35:48 +01:00
connect ( ui - > actionDisableUpdateReminder , SIGNAL ( triggered ( bool ) ) , this , SLOT ( disableUpdateReminderActionTriggered ( bool ) ) ) ;
connect ( ui - > actionDisableSounds , SIGNAL ( triggered ( bool ) ) , this , SLOT ( disableSoundsActionTriggered ( bool ) ) ) ;
connect ( ui - > actionDisableNeroAacNotifications , SIGNAL ( triggered ( bool ) ) , this , SLOT ( disableNeroAacNotificationsActionTriggered ( bool ) ) ) ;
connect ( ui - > actionDisableSlowStartupNotifications , SIGNAL ( triggered ( bool ) ) , this , SLOT ( disableSlowStartupNotificationsActionTriggered ( bool ) ) ) ;
connect ( ui - > actionDisableShellIntegration , SIGNAL ( triggered ( bool ) ) , this , SLOT ( disableShellIntegrationActionTriggered ( bool ) ) ) ;
connect ( ui - > actionShowDropBoxWidget , SIGNAL ( triggered ( bool ) ) , this , SLOT ( showDropBoxWidgetActionTriggered ( bool ) ) ) ;
connect ( ui - > actionHibernateComputer , SIGNAL ( triggered ( bool ) ) , this , SLOT ( hibernateComputerActionTriggered ( bool ) ) ) ;
connect ( ui - > actionCheckForBetaUpdates , SIGNAL ( triggered ( bool ) ) , this , SLOT ( checkForBetaUpdatesActionTriggered ( bool ) ) ) ;
connect ( ui - > 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
2014-06-27 21:06:33 +02:00
ui - > actionVisitHomepage - > setData ( QString : : fromLatin1 ( lamexp_website_url ( ) ) ) ;
ui - > actionVisitSupport - > setData ( QString : : fromLatin1 ( lamexp_support_url ( ) ) ) ;
ui - > actionVisitMuldersSite - > setData ( QString : : fromLatin1 ( lamexp_mulders_url ( ) ) ) ;
ui - > actionVisitTracker - > setData ( QString : : fromLatin1 ( lamexp_tracker_url ( ) ) ) ;
ui - > actionVisitHAK - > setData ( QString : : fromLatin1 ( g_hydrogen_audio_url ) ) ;
2014-12-26 00:42:53 +01:00
ui - > actionDocumentManual - > setData ( QString ( " %1/Manual.html " ) . arg ( QApplication : : applicationDirPath ( ) ) ) ;
2012-12-04 01:35:48 +01:00
ui - > actionDocumentChangelog - > setData ( QString ( " %1/Changelog.html " ) . arg ( QApplication : : applicationDirPath ( ) ) ) ;
ui - > actionDocumentTranslate - > setData ( QString ( " %1/Translate.html " ) . arg ( QApplication : : applicationDirPath ( ) ) ) ;
2014-06-27 21:06:33 +02:00
connect ( ui - > actionCheckUpdates , SIGNAL ( triggered ( ) ) , this , SLOT ( checkUpdatesActionActivated ( ) ) ) ;
connect ( ui - > actionVisitSupport , SIGNAL ( triggered ( ) ) , this , SLOT ( visitHomepageActionActivated ( ) ) ) ;
connect ( ui - > actionVisitTracker , SIGNAL ( triggered ( ) ) , this , SLOT ( visitHomepageActionActivated ( ) ) ) ;
connect ( ui - > actionVisitHomepage , SIGNAL ( triggered ( ) ) , this , SLOT ( visitHomepageActionActivated ( ) ) ) ;
connect ( ui - > actionVisitMuldersSite , SIGNAL ( triggered ( ) ) , this , SLOT ( visitHomepageActionActivated ( ) ) ) ;
connect ( ui - > actionVisitHAK , SIGNAL ( triggered ( ) ) , this , SLOT ( visitHomepageActionActivated ( ) ) ) ;
2014-12-26 00:42:53 +01:00
connect ( ui - > actionDocumentManual , SIGNAL ( triggered ( ) ) , this , SLOT ( documentActionActivated ( ) ) ) ;
2012-12-04 01:35:48 +01:00
connect ( ui - > actionDocumentChangelog , SIGNAL ( triggered ( ) ) , this , SLOT ( documentActionActivated ( ) ) ) ;
connect ( ui - > actionDocumentTranslate , SIGNAL ( triggered ( ) ) , this , SLOT ( documentActionActivated ( ) ) ) ;
2010-11-06 23:04:47 +01:00
2012-07-29 22:55:02 +02:00
//--------------------------------
// Prepare to show window
//--------------------------------
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 ( ) ) ;
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
2014-12-13 23:27:47 +01:00
m_messageHandler = new MessageHandlerThread ( ipcChannel ) ;
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 19:29:36 +01:00
m_messageHandler - > start ( ) ;
2010-11-12 23:31:04 +01:00
2013-11-29 01:20:59 +01:00
//Init delayed file handling
m_delayedFileList = new QStringList ( ) ;
m_delayedFileTimer = new QTimer ( ) ;
m_delayedFileTimer - > setSingleShot ( true ) ;
m_delayedFileTimer - > setInterval ( 5000 ) ;
connect ( m_delayedFileTimer , SIGNAL ( timeout ( ) ) , this , SLOT ( handleDelayedFiles ( ) ) ) ;
2012-10-14 22:21:57 +02:00
//Load translation
initializeTranslation ( ) ;
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
2013-11-29 01:20:59 +01:00
m_droppedFileList = new QList < QUrl > ( ) ;
2010-12-30 17:34:19 +01:00
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-12-04 01:35:48 +01:00
SET_MODEL ( ui - > sourceFileView , NULL ) ;
SET_MODEL ( ui - > outputFolderView , NULL ) ;
SET_MODEL ( ui - > metaDataView , NULL ) ;
2010-12-28 03:57:48 +01:00
2010-11-09 22:06:11 +01:00
//Free memory
2014-11-25 02:14:42 +01:00
MUTILS_DELETE ( m_tabActionGroup ) ;
MUTILS_DELETE ( m_styleActionGroup ) ;
MUTILS_DELETE ( m_languageActionGroup ) ;
MUTILS_DELETE ( m_banner ) ;
MUTILS_DELETE ( m_fileSystemModel ) ;
MUTILS_DELETE ( m_messageHandler ) ;
MUTILS_DELETE ( m_droppedFileList ) ;
MUTILS_DELETE ( m_delayedFileList ) ;
MUTILS_DELETE ( m_delayedFileTimer ) ;
MUTILS_DELETE ( m_metaInfoModel ) ;
MUTILS_DELETE ( m_encoderButtonGroup ) ;
MUTILS_DELETE ( m_modeButtonGroup ) ;
MUTILS_DELETE ( m_overwriteButtonGroup ) ;
MUTILS_DELETE ( m_sourceFilesContextMenu ) ;
MUTILS_DELETE ( m_outputFolderFavoritesMenu ) ;
MUTILS_DELETE ( m_outputFolderContextMenu ) ;
MUTILS_DELETE ( m_dropBox ) ;
MUTILS_DELETE ( m_evenFilterCornerWidget ) ;
MUTILS_DELETE ( m_evenFilterCustumParamsHelp ) ;
MUTILS_DELETE ( m_evenFilterOutputFolderMouse ) ;
MUTILS_DELETE ( m_evenFilterOutputFolderView ) ;
MUTILS_DELETE ( m_evenFilterCompressionTab ) ;
2013-11-26 23:01:37 +01:00
2012-12-04 01:35:48 +01:00
//Un-initialize the dialog
2014-11-25 02:14:42 +01:00
MUTILS_DELETE ( ui ) ;
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 ;
}
2013-11-29 01:20:59 +01:00
WITH_BLOCKED_SIGNALS ( ui - > tabWidget , setCurrentIndex , 0 ) ;
tabPageChanged ( ui - > tabWidget - > currentIndex ( ) , true ) ;
2010-11-11 19:37:16 +01:00
2013-11-26 23:01:37 +01:00
INIT_BANNER ( ) ;
2010-11-11 19:37:16 +01:00
FileAnalyzer * analyzer = new FileAnalyzer ( files ) ;
2013-11-26 23:01:37 +01:00
2010-11-11 19:37:16 +01:00
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 ) ;
2012-05-14 00:50:16 +02:00
QTime startTime = QTime : : currentTime ( ) ;
2012-05-05 21:56:14 +02:00
m_banner - > show ( tr ( " Adding file(s), please wait... " ) , analyzer ) ;
2012-05-14 00:50:16 +02:00
}
catch ( . . . )
{
/* ignore any exceptions that may occur */
}
2012-05-05 21:56:14 +02:00
m_fileListModel - > setBlockUpdates ( false ) ;
qApp - > processEvents ( QEventLoop : : ExcludeUserInputEvents ) ;
2012-12-04 01:35:48 +01:00
ui - > sourceFileView - > update ( ) ;
2012-05-05 21:56:14 +02:00
qApp - > processEvents ( QEventLoop : : ExcludeUserInputEvents ) ;
2012-12-04 01:35:48 +01:00
ui - > sourceFileView - > scrollToBottom ( ) ;
2012-05-05 21:56:14 +02:00
qApp - > processEvents ( QEventLoop : : ExcludeUserInputEvents ) ;
2010-11-11 19:37:16 +01:00
if ( analyzer - > filesDenied ( ) )
{
2013-01-23 23:25:31 +01:00
QMessageBox : : warning ( this , tr ( " Access Denied " ) , QString ( " %1<br>%2 " ) . arg ( NOBR ( tr ( " %n file(s) have been rejected, because read access was not granted! " , " " , analyzer - > filesDenied ( ) ) ) , NOBR ( tr ( " This usually means the file is locked by another process. " ) ) ) ) ;
2010-11-11 19:37:16 +01:00
}
2011-03-19 15:35:17 +01:00
if ( analyzer - > filesDummyCDDA ( ) )
{
2013-01-23 23:25:31 +01:00
QMessageBox : : warning ( this , tr ( " CDDA Files " ) , QString ( " %1<br><br>%2<br>%3 " ) . arg ( NOBR ( tr ( " %n file(s) have been rejected, because they are dummy CDDA files! " , " " , analyzer - > filesDummyCDDA ( ) ) ) , NOBR ( tr ( " Sorry, LameXP cannot extract audio tracks from an Audio-CD at present. " ) ) , NOBR ( tr ( " We recommend using %1 for that purpose. " ) . arg ( " <a href= \" http://www.exactaudiocopy.de/ \" >Exact Audio Copy</a> " ) ) ) ) ;
2011-05-17 01:14:50 +02:00
}
if ( analyzer - > filesCueSheet ( ) )
{
2013-01-23 23:25:31 +01:00
QMessageBox : : warning ( this , tr ( " Cue Sheet " ) , QString ( " %1<br>%2 " ) . arg ( NOBR ( tr ( " %n file(s) have been rejected, because they appear to be Cue Sheet images! " , " " , analyzer - > filesCueSheet ( ) ) ) , NOBR ( tr ( " Please use LameXP's Cue Sheet wizard for importing Cue Sheet files. " ) ) ) ) ;
2011-03-19 15:35:17 +01:00
}
2010-11-11 19:37:16 +01:00
if ( analyzer - > filesRejected ( ) )
{
2013-01-23 23:25:31 +01:00
QMessageBox : : warning ( this , tr ( " Files Rejected " ) , QString ( " %1<br>%2 " ) . arg ( NOBR ( tr ( " %n file(s) have been rejected, because the file format could not be recognized! " , " " , analyzer - > filesRejected ( ) ) ) , NOBR ( tr ( " This usually means the file is damaged or the file format is not supported. " ) ) ) ) ;
2010-11-11 19:37:16 +01:00
}
2014-11-25 02:14:42 +01:00
MUTILS_DELETE ( analyzer ) ;
2010-11-11 19:37:16 +01:00
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 ;
2013-11-29 01:20:59 +01:00
SHOW_BANNER ( 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 ( ) ;
2014-12-08 22:06:01 +01:00
MUtils : : OS : : check_key_state_esc ( ) ;
2011-03-23 23:19:31 +01:00
while ( ! folderInfoList . isEmpty ( ) )
{
2014-12-08 22:06:01 +01:00
if ( MUtils : : OS : : check_key_state_esc ( ) )
2011-04-11 21:57:16 +02:00
{
qWarning ( " Operation cancelled by user! " ) ;
2014-12-08 22:06:01 +01:00
MUtils : : Sound : : beep ( MUtils : : Sound : : BEEP_ERR ) ;
2011-04-11 21:57:16 +02:00
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 ( ) ;
}
2013-11-29 01:20:59 +01:00
QApplication : : processEvents ( QEventLoop : : ExcludeUserInputEvents ) ;
2011-03-23 23:19:31 +01:00
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 ( ) )
{
2014-05-04 16:59:06 +02:00
SHOW_CORNER_WIDGET ( false ) ;
2011-02-18 00:53:36 +01:00
m_settings - > autoUpdateLastCheck ( QDate : : currentDate ( ) . toString ( Qt : : ISODate ) ) ;
bReadyToInstall = updateDialog - > updateReadyToInstall ( ) ;
}
2014-11-25 02:14:42 +01:00
MUTILS_DELETE ( updateDialog ) ;
2011-02-18 00:53:36 +01:00
return bReadyToInstall ;
2011-01-29 00:40:29 +01:00
}
2012-10-14 22:21:57 +02:00
/*
* Refresh list of favorites
*/
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 ) ;
2014-11-25 02:14:42 +01:00
MUTILS_DELETE ( currentItem ) ;
2011-08-08 20:26:30 +02:00
}
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 ;
}
}
}
2012-10-14 22:21:57 +02:00
/*
* Initilaize translation
*/
void MainWindow : : initializeTranslation ( void )
{
bool translationLoaded = false ;
//Try to load "external" translation file
if ( ! m_settings - > currentLanguageFile ( ) . isEmpty ( ) )
{
const QString qmFilePath = QFileInfo ( m_settings - > currentLanguageFile ( ) ) . canonicalFilePath ( ) ;
2012-10-15 00:41:38 +02:00
if ( ( ! qmFilePath . isEmpty ( ) ) & & QFileInfo ( qmFilePath ) . exists ( ) & & QFileInfo ( qmFilePath ) . isFile ( ) & & ( QFileInfo ( qmFilePath ) . suffix ( ) . compare ( " qm " , Qt : : CaseInsensitive ) = = 0 ) )
2012-10-14 22:21:57 +02:00
{
2014-12-20 23:44:43 +01:00
if ( MUtils : : Translation : : install_translator_from_file ( qmFilePath ) )
2012-10-14 22:21:57 +02:00
{
QList < QAction * > actions = m_languageActionGroup - > actions ( ) ;
while ( ! actions . isEmpty ( ) ) actions . takeFirst ( ) - > setChecked ( false ) ;
2012-12-04 01:35:48 +01:00
ui - > actionLoadTranslationFromFile - > setChecked ( true ) ;
2012-10-14 22:21:57 +02:00
translationLoaded = true ;
}
}
}
//Try to load "built-in" translation file
if ( ! translationLoaded )
{
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 ) ;
translationLoaded = true ;
}
}
}
//Fallback to default translation
if ( ! translationLoaded )
{
QList < QAction * > languageActions = m_languageActionGroup - > actions ( ) ;
while ( ! languageActions . isEmpty ( ) )
{
QAction * currentLanguage = languageActions . takeFirst ( ) ;
2014-12-20 23:44:43 +01:00
if ( currentLanguage - > data ( ) . toString ( ) . compare ( MUtils : : Translation : : DEFAULT_LANGID , Qt : : CaseInsensitive ) = = 0 )
2012-10-14 22:21:57 +02:00
{
currentLanguage - > setChecked ( true ) ;
languageActionActivated ( currentLanguage ) ;
translationLoaded = true ;
}
}
}
//Make sure we loaded some translation
if ( ! translationLoaded )
{
qFatal ( " Failed to load any translation, this is NOT supposed to happen! " ) ;
}
}
2014-12-26 00:42:53 +01:00
/*
* Open a document link
*/
void MainWindow : : openDocumentLink ( QAction * const action )
{
if ( ! ( action - > data ( ) . isValid ( ) & & ( action - > data ( ) . type ( ) = = QVariant : : String ) ) )
{
qWarning ( " Cannot open document for this QAction! " ) ;
return ;
}
//Try to open exitsing document file
const QFileInfo document ( action - > data ( ) . toString ( ) ) ;
if ( document . exists ( ) & & document . isFile ( ) & & ( document . size ( ) > = 1024 ) )
{
QDesktopServices : : openUrl ( QUrl : : fromLocalFile ( document . canonicalFilePath ( ) ) ) ;
return ;
}
//Document not found -> fallback mode!
qWarning ( " Document '%s' not found -> redirecting to the website! " , MUTILS_UTF8 ( document . fileName ( ) ) ) ;
const QUrl url ( QString ( " %1/%2 " ) . arg ( QString : : fromLatin1 ( g_documents_base_url ) , document . fileName ( ) ) ) ;
QDesktopServices : : openUrl ( url ) ;
}
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 ;
2013-06-16 22:07:28 +02:00
resizeEvent ( NULL ) ;
2010-11-21 21:51:41 +01:00
sourceModelChanged ( ) ;
2013-11-25 18:34:59 +01:00
2011-05-31 19:04:45 +02:00
if ( ! event - > spontaneous ( ) )
{
2013-11-29 01:20:59 +01:00
WITH_BLOCKED_SIGNALS ( ui - > tabWidget , setCurrentIndex , 0 ) ;
tabPageChanged ( ui - > tabWidget - > currentIndex ( ) , true ) ;
2011-05-31 19:04:45 +02:00
}
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 )
{
2014-05-04 21:00:59 +02:00
QMainWindow : : changeEvent ( e ) ;
if ( e - > type ( ) ! = QEvent : : LanguageChange )
2010-12-30 17:34:19 +01:00
{
2014-05-04 21:00:59 +02:00
return ;
}
2013-10-02 19:17:33 +02:00
2015-03-21 19:06:55 +01:00
int comboBoxIndex [ 6 ] ;
2011-01-22 22:19:20 +01:00
2014-05-04 21:00:59 +02:00
//Backup combobox indices, as retranslateUi() resets
comboBoxIndex [ 0 ] = ui - > comboBoxMP3ChannelMode - > currentIndex ( ) ;
comboBoxIndex [ 1 ] = ui - > comboBoxSamplingRate - > currentIndex ( ) ;
comboBoxIndex [ 2 ] = ui - > comboBoxAACProfile - > currentIndex ( ) ;
comboBoxIndex [ 3 ] = ui - > comboBoxAftenCodingMode - > currentIndex ( ) ;
comboBoxIndex [ 4 ] = ui - > comboBoxAftenDRCMode - > currentIndex ( ) ;
2015-03-21 19:06:55 +01:00
comboBoxIndex [ 5 ] = ui - > comboBoxOpusFramesize - > currentIndex ( ) ;
2011-01-22 22:19:20 +01:00
2014-05-04 21:00:59 +02:00
//Re-translate from UIC
ui - > retranslateUi ( this ) ;
//Restore combobox indices
ui - > comboBoxMP3ChannelMode - > setCurrentIndex ( comboBoxIndex [ 0 ] ) ;
ui - > comboBoxSamplingRate - > setCurrentIndex ( comboBoxIndex [ 1 ] ) ;
ui - > comboBoxAACProfile - > setCurrentIndex ( comboBoxIndex [ 2 ] ) ;
ui - > comboBoxAftenCodingMode - > setCurrentIndex ( comboBoxIndex [ 3 ] ) ;
ui - > comboBoxAftenDRCMode - > setCurrentIndex ( comboBoxIndex [ 4 ] ) ;
2015-03-21 19:06:55 +01:00
ui - > comboBoxOpusFramesize - > setCurrentIndex ( comboBoxIndex [ 5 ] ) ;
2014-05-04 21:00:59 +02:00
//Update the window title
2014-11-25 02:14:42 +01:00
if ( MUTILS_DEBUG )
2014-05-04 21:00:59 +02:00
{
setWindowTitle ( QString ( " %1 [!!! DEBUG BUILD !!!] " ) . arg ( windowTitle ( ) ) ) ;
}
else if ( lamexp_version_demo ( ) )
{
setWindowTitle ( QString ( " %1 [%2] " ) . arg ( windowTitle ( ) , tr ( " DEMO VERSION " ) ) ) ;
}
//Manually re-translate widgets that UIC doesn't handle
m_outputFolderNoteBox - > setText ( tr ( " Initializing directory outline, please be patient... " ) ) ;
m_dropNoteLabel - > setText ( QString ( " <br><img src= \" :/images/DropZone.png \" ><br><br>%1 " ) . arg ( tr ( " You can drop in audio files here! " ) ) ) ;
if ( QLabel * cornerWidget = dynamic_cast < QLabel * > ( ui - > menubar - > cornerWidget ( ) ) )
{
cornerWidget - > setText ( QString ( " <nobr><img src= \" :/icons/exclamation_small.png \" > <b style= \" color:darkred \" >%1</b> </nobr> " ) . arg ( tr ( " Check for Updates " ) ) ) ;
}
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 " ) ) ;
m_refreshFolderContextAction - > setText ( tr ( " Refresh Directory Outline " ) ) ;
m_goUpFolderContextAction - > setText ( tr ( " Go To Parent Directory " ) ) ;
m_addFavoriteFolderAction - > setText ( tr ( " Bookmark Current Output Folder " ) ) ;
m_exportCsvContextAction - > setText ( tr ( " Export Meta Tags to CSV File " ) ) ;
m_importCsvContextAction - > setText ( tr ( " Import Meta Tags from CSV File " ) ) ;
//Force GUI update
m_metaInfoModel - > clearData ( ) ;
m_metaInfoModel - > setData ( m_metaInfoModel - > index ( 4 , 1 ) , m_settings - > metaInfoPosition ( ) ) ;
updateEncoder ( m_settings - > compressionEncoder ( ) ) ;
updateLameAlgoQuality ( ui - > sliderLameAlgoQuality - > value ( ) ) ;
updateMaximumInstances ( ui - > sliderMaxInstances - > value ( ) ) ;
renameOutputPatternChanged ( ui - > lineEditRenamePattern - > text ( ) , true ) ;
//Re-install shell integration
if ( m_settings - > shellIntegrationEnabled ( ) )
{
ShellIntegration : : install ( ) ;
}
2011-02-20 19:29:28 +01:00
2014-05-04 21:00:59 +02:00
//Translate system menu
2014-12-08 22:06:01 +01:00
MUtils : : GUI : : sysmenu_update ( this , IDM_ABOUTBOX , ui - > buttonAbout - > text ( ) ) ;
2014-05-04 21:00:59 +02:00
//Force resize event
QApplication : : postEvent ( this , new QResizeEvent ( this - > size ( ) , QSize ( ) ) ) ;
for ( QObjectList : : ConstIterator iter = this - > children ( ) . constBegin ( ) ; iter ! = this - > children ( ) . constEnd ( ) ; iter + + )
{
if ( QWidget * child = dynamic_cast < QWidget * > ( * iter ) )
2011-01-29 00:40:29 +01:00
{
2014-05-04 21:00:59 +02:00
QApplication : : postEvent ( child , new QResizeEvent ( child - > size ( ) , QSize ( ) ) ) ;
2011-01-29 00:40:29 +01:00
}
2010-12-30 17:34:19 +01:00
}
2014-05-04 21:00:59 +02:00
//Force tabe page change
tabPageChanged ( ui - > tabWidget - > currentIndex ( ) , true ) ;
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 )
{
2013-11-29 01:20:59 +01:00
m_droppedFileList - > clear ( ) ;
( * m_droppedFileList ) < < event - > mimeData ( ) - > urls ( ) ;
if ( ! m_droppedFileList - > isEmpty ( ) )
2011-05-27 11:29:40 +02:00
{
2013-12-03 22:19:11 +01:00
PLAY_SOUND_OPTIONAL ( " drop " , true ) ;
2013-11-29 01:20:59 +01:00
QTimer : : singleShot ( 0 , this , SLOT ( handleDroppedFiles ( ) ) ) ;
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 )
{
2013-11-26 23:01:37 +01:00
if ( BANNER_VISIBLE | | m_delayedFileTimer - > isActive ( ) )
2010-11-19 21:11:54 +01:00
{
2014-12-05 21:08:26 +01:00
MUtils : : Sound : : beep ( MUtils : : Sound : : BEEP_WRN ) ;
2010-11-19 21:11:54 +01:00
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 ) ;
2013-06-16 22:07:28 +02:00
if ( QWidget * port = ui - > sourceFileView - > viewport ( ) )
{
m_dropNoteLabel - > setGeometry ( port - > geometry ( ) ) ;
}
2012-03-30 03:35:43 +02:00
2014-05-04 21:00:59 +02:00
if ( QWidget * port = ui - > outputFolderView - > viewport ( ) )
2012-03-30 03:35:43 +02:00
{
2013-10-31 01:22:21 +01:00
m_outputFolderNoteBox - > setGeometry ( 16 , ( port - > height ( ) - 64 ) / 2 , port - > width ( ) - 32 , 64 ) ;
2012-03-30 03:35:43 +02:00
}
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 )
{
2012-10-14 22:21:57 +02:00
if ( e - > key ( ) = = Qt : : Key_Delete )
2012-04-05 15:24:45 +02:00
{
2012-12-04 01:35:48 +01:00
if ( ui - > sourceFileView - > isVisible ( ) )
2012-04-05 15:24:45 +02:00
{
2012-10-14 22:21:57 +02:00
QTimer : : singleShot ( 0 , this , SLOT ( removeFileButtonClicked ( ) ) ) ;
2012-04-05 15:24:45 +02:00
return ;
}
}
2012-10-14 22:21:57 +02:00
if ( e - > modifiers ( ) . testFlag ( Qt : : ControlModifier ) & & ( e - > key ( ) = = Qt : : Key_F5 ) )
2012-04-19 00:56:04 +02:00
{
2012-10-14 22:21:57 +02:00
initializeTranslation ( ) ;
2014-12-05 21:08:26 +01:00
MUtils : : Sound : : beep ( MUtils : : Sound : : BEEP_NFO ) ;
2012-10-14 22:21:57 +02:00
return ;
}
if ( e - > key ( ) = = Qt : : Key_F5 )
{
2012-12-04 01:35:48 +01:00
if ( ui - > outputFolderView - > isVisible ( ) )
2012-04-19 00:56:04 +02:00
{
2012-10-14 22:21:57 +02:00
QTimer : : singleShot ( 0 , this , SLOT ( refreshFolderContextActionTriggered ( ) ) ) ;
2012-04-19 00:56:04 +02:00
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 ( ) ) ) ;
}
}
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 ( ) )
{
2014-11-29 01:25:18 +01:00
case MUtils : : GUI : : USER_EVENT_QUERYENDSESSION :
2011-12-29 14:42:20 +01:00
qWarning ( " System is shutting down, main window prepares to close... " ) ;
2013-11-26 23:01:37 +01:00
if ( BANNER_VISIBLE ) m_banner - > close ( ) ;
2011-12-29 14:42:20 +01:00
if ( m_delayedFileTimer - > isActive ( ) ) m_delayedFileTimer - > stop ( ) ;
return true ;
2014-11-29 01:25:18 +01:00
case MUtils : : GUI : : USER_EVENT_ENDSESSION :
2011-12-29 14:42:20 +01:00
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 :
2012-12-04 01:35:48 +01:00
if ( ui - > outputFolderEdit - > isVisible ( ) )
2012-03-27 22:46:01 +02:00
{
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 )
{
2014-12-08 22:06:01 +01:00
if ( MUtils : : GUI : : sysmenu_check_msg ( message , IDM_ABOUTBOX ) )
2012-10-17 23:34:42 +02:00
{
2012-12-04 01:35:48 +01:00
QTimer : : singleShot ( 0 , ui - > buttonAbout , SLOT ( click ( ) ) ) ;
2012-10-19 21:05:33 +02:00
* result = 0 ;
2012-10-17 23:34:42 +02:00
return true ;
}
2014-12-18 22:49:37 +01:00
return false ;
2011-11-07 17:13:41 +01:00
}
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 )
{
2015-01-04 17:04:26 +01:00
const MUtils : : OS : : ArgumentMap & arguments = MUtils : : OS : : arguments ( ) ; //QApplication::arguments();
2010-11-08 19:29:36 +01:00
2013-06-16 22:07:28 +02:00
//Force resize event
resizeEvent ( NULL ) ;
2011-09-19 18:52:02 +02:00
//First run?
2015-01-04 17:04:26 +01:00
const bool firstRun = arguments . contains ( " first-run " ) ;
2011-09-19 18:52:02 +02:00
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
{
2012-10-10 23:01:58 +02:00
int iAccepted = m_settings - > licenseAccepted ( ) ;
2010-11-12 19:02:01 +01:00
2012-10-10 23:01:58 +02:00
if ( ( iAccepted = = 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 ( ) ;
2012-10-10 23:01:58 +02:00
if ( iAccepted < = 0 ) iAccepted = - 2 ;
2014-11-25 02:14:42 +01:00
MUTILS_DELETE ( about ) ;
2010-11-12 19:02:01 +01:00
}
if ( iAccepted < = 0 )
{
2012-10-10 23:01:58 +02:00
m_settings - > licenseAccepted ( + + iAccepted ) ;
m_settings - > syncNow ( ) ;
2010-12-22 01:01:01 +01:00
QApplication : : processEvents ( ) ;
2014-12-05 21:08:26 +01:00
MUtils : : Sound : : play_sound ( " whammy " , false ) ;
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 + + )
{
2014-12-04 00:02:42 +01:00
if ( MUtils : : OS : : shell_open ( this , QDir : : toNativeSeparators ( uninstallerPath ) , " /Force " , QDir : : toNativeSeparators ( uninstallerDir ) ) ) break ;
2011-10-06 14:35:13 +02:00
}
}
2010-11-12 19:02:01 +01:00
QApplication : : quit ( ) ;
return ;
}
2010-12-22 01:01:01 +01:00
2014-12-05 21:08:26 +01:00
MUtils : : Sound : : play_sound ( " woohoo " , false ) ;
2010-11-15 04:42:06 +01:00
m_settings - > licenseAccepted ( 1 ) ;
2012-10-10 23:01:58 +02:00
m_settings - > syncNow ( ) ;
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 ( ) )
{
2014-11-25 02:14:42 +01:00
if ( MUtils : : OS : : current_date ( ) > = lamexp_version_expires ( ) )
2010-11-29 20:36:27 +01:00
{
qWarning ( " Binary has expired !!! " ) ;
2014-12-05 21:08:26 +01:00
MUtils : : Sound : : play_sound ( " whammy " , false ) ;
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> " ) ;
2012-08-20 22:23:38 +02:00
message + = NOBR ( tr ( " Please refer to the %1 document for details and solutions! " ) ) . arg ( " <a href= \" http://lamexp.sourceforge.net/doc/FAQ.html#df406578 \" >F.A.Q.</a> " ) . append ( " <br> " ) ;
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 ) ;
2012-12-04 01:35:48 +01:00
ui - > actionDisableSlowStartupNotifications - > setChecked ( ! m_settings - > antivirNotificationsEnabled ( ) ) ;
2011-06-24 18:17:04 +02:00
}
}
2010-11-29 20:36:27 +01:00
//Update reminder
2014-11-25 22:34:20 +01:00
if ( MUtils : : OS : : current_date ( ) > = MUtils : : Version : : app_build_date ( ) . addYears ( 1 ) )
2010-11-29 20:36:27 +01:00
{
qWarning ( " Binary is more than a year old, time to update! " ) ;
2014-05-04 16:59:06 +02:00
SHOW_CORNER_WIDGET ( true ) ;
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 ( ) ) ) ;
2014-12-05 21:08:26 +01:00
MUtils : : Sound : : play_sound ( " waiting " , true ) ;
2013-11-29 01:20:59 +01:00
SHOW_BANNER_ARG ( tr ( " Skipping update check this time, please be patient... " ) , & loop ) ;
2011-12-18 18:19:14 +01:00
break ;
2010-11-29 20:36:27 +01:00
}
}
2014-05-04 16:59:06 +02:00
else
2010-11-29 20:36:27 +01:00
{
QDate lastUpdateCheck = QDate : : fromString ( m_settings - > autoUpdateLastCheck ( ) , Qt : : ISODate ) ;
2014-11-25 02:14:42 +01:00
if ( ( ! firstRun ) & & ( ( ! lastUpdateCheck . isValid ( ) ) | | ( MUtils : : OS : : current_date ( ) > = lastUpdateCheck . addDays ( 14 ) ) ) )
2010-11-29 20:36:27 +01:00
{
2014-05-04 16:59:06 +02:00
SHOW_CORNER_WIDGET ( true ) ;
if ( m_settings - > autoUpdateEnabled ( ) )
2010-11-29 20:36:27 +01:00
{
2014-05-04 16:59:06 +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 )
2011-02-18 00:53:36 +01:00
{
2014-05-04 16:59:06 +02:00
if ( checkForUpdates ( ) )
{
QApplication : : quit ( ) ;
return ;
}
2011-02-18 00:53:36 +01:00
}
2010-11-29 20:36:27 +01:00
}
}
}
2010-11-11 22:58:02 +01:00
//Check for AAC support
2013-10-02 19:17:33 +02:00
const int aacEncoder = EncoderRegistry : : getAacEncoder ( ) ;
if ( aacEncoder = = SettingsModel : : AAC_ENCODER_NERO )
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
{
2014-12-20 23:44:43 +01:00
if ( lamexp_tools_version ( " neroAacEnc.exe " ) < lamexp_toolver_neroaac ( ) )
2010-12-19 21:23:43 +01:00
{
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> " ) ;
2014-12-20 23:44:43 +01:00
messageText + = NOBR ( tr ( " The current version available is %1 (or later), but you still have version %2 installed. " ) . arg ( lamexp_version2string ( " ?.?.?.? " , lamexp_toolver_neroaac ( ) , tr ( " n/a " ) ) , lamexp_version2string ( " ?.?.?.? " , lamexp_tools_version ( " neroAacEnc.exe " ) , tr ( " n/a " ) ) ) ) . append ( " <br><br> " ) ;
2011-09-17 23:08:59 +02:00
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
{
2013-10-02 19:17:33 +02:00
if ( m_settings - > neroAacNotificationsEnabled ( ) & & ( aacEncoder < = SettingsModel : : AAC_ENCODER_NONE ) )
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 ) ;
2012-12-04 01:35:48 +01:00
ui - > actionDisableNeroAacNotifications - > setChecked ( ! m_settings - > neroAacNotificationsEnabled ( ) ) ;
2011-05-08 19:41:25 +02:00
}
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
2015-01-04 17:04:26 +01:00
QStringList addedFiles ;
foreach ( const QString & value , arguments . values ( " add " ) )
2010-11-08 19:29:36 +01:00
{
2015-01-04 17:04:26 +01:00
if ( ! value . isEmpty ( ) )
2010-11-08 19:29:36 +01:00
{
2015-01-04 17:04:26 +01:00
QFileInfo currentFile ( value ) ;
2014-11-25 02:14:42 +01:00
qDebug ( " Adding file from CLI: %s " , MUTILS_UTF8 ( currentFile . absoluteFilePath ( ) ) ) ;
2011-06-11 17:18:30 +02:00
addedFiles . append ( currentFile . absoluteFilePath ( ) ) ;
}
2015-01-04 17:04:26 +01:00
}
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
2015-01-04 17:04:26 +01:00
foreach ( const QString & value , arguments . values ( " add-folder " ) )
2010-11-08 19:29:36 +01:00
{
2015-01-04 17:04:26 +01:00
if ( ! value . isEmpty ( ) )
2011-06-11 17:18:30 +02:00
{
2015-01-04 17:04:26 +01:00
const QFileInfo currentFile ( value ) ;
2014-11-25 02:14:42 +01:00
qDebug ( " Adding folder from CLI: %s " , MUTILS_UTF8 ( currentFile . absoluteFilePath ( ) ) ) ;
2011-06-11 17:18:30 +02:00
addFolder ( currentFile . absoluteFilePath ( ) , false , true ) ;
}
2015-01-04 17:04:26 +01:00
}
foreach ( const QString & value , arguments . values ( " add-recursive " ) )
{
if ( ! value . isEmpty ( ) )
2011-06-11 17:18:30 +02:00
{
2015-01-04 17:04:26 +01:00
const QFileInfo currentFile ( value ) ;
2014-11-25 02:14:42 +01:00
qDebug ( " Adding folder recursively from CLI: %s " , MUTILS_UTF8 ( currentFile . absoluteFilePath ( ) ) ) ;
2011-06-11 17:18:30 +02:00
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: " ) ,
2012-08-20 22:23:38 +02:00
LINK ( " http://lamexp.sourceforge.net/doc/Translate.html " )
2011-10-16 16:38:01 +02:00
) ;
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 ( ) ;
2014-11-25 02:14:42 +01:00
MUTILS_DELETE ( timers [ i ] ) ;
2012-01-24 01:19:09 +01:00
}
2011-09-18 02:01:45 +02:00
2014-11-25 02:14:42 +01:00
MUTILS_DELETE ( announceBox ) ;
2011-09-18 02:01:45 +02:00
}
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! " ) ) ) ;
2012-12-04 01:35:48 +01:00
ui - > tabWidget - > setCurrentIndex ( 0 ) ;
2010-11-20 02:14:22 +01:00
return ;
}
2014-11-25 02:14:42 +01:00
QString tempFolder = m_settings - > customTempPathEnabled ( ) ? m_settings - > customTempPath ( ) : MUtils : : temp_folder ( ) ;
2011-02-25 22:03:39 +01:00
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
{
2015-05-04 22:45:06 +02:00
SET_CHECKBOX_STATE ( ui - > checkBoxUseSystemTempFolder , ( ! m_settings - > customTempPathEnabledDefault ( ) ) ) ;
2011-02-25 22:03:39 +01:00
}
return ;
}
2010-12-19 21:23:43 +01:00
2014-12-04 00:02:42 +01:00
quint64 currentFreeDiskspace = 0 ;
if ( MUtils : : OS : : free_diskspace ( tempFolder , currentFreeDiskspace ) )
2010-12-19 00:50:22 +01:00
{
2014-12-04 00:02:42 +01:00
if ( currentFreeDiskspace < ( oneGigabyte * minimumFreeDiskspaceMultiplier ) )
2010-12-19 00:50:22 +01:00
{
2014-12-04 00:02:42 +01:00
QStringList tempFolderParts = tempFolder . split ( " / " , QString : : SkipEmptyParts , Qt : : CaseInsensitive ) ;
tempFolderParts . takeLast ( ) ;
PLAY_SOUND_OPTIONAL ( " whammy " , false ) ;
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 " ) ) )
{
case 1 :
QProcess : : startDetached ( QString ( " %1/cleanmgr.exe " ) . arg ( MUtils : : OS : : known_folder ( MUtils : : OS : : FOLDER_SYSTEMFOLDER ) ) , QStringList ( ) < < " /D " < < tempFolderParts . first ( ) ) ;
case 0 :
return ;
break ;
default :
QMessageBox : : warning ( this , tr ( " Low Diskspace " ) , NOBR ( tr ( " You are proceeding with low diskspace. Problems might occur! " ) ) ) ;
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 :
2012-07-20 23:19:08 +02:00
case SettingsModel : : OpusEncoder :
2011-12-22 21:53:25 +01:00
case SettingsModel : : DCAEncoder :
2013-12-04 22:36:19 +01:00
case SettingsModel : : MACEncoder :
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! " ) ) ;
2012-12-04 01:35:48 +01:00
ui - > tabWidget - > setCurrentIndex ( 3 ) ;
2010-11-15 21:07:58 +01:00
return ;
}
2010-11-21 21:51:41 +01:00
if ( ! m_settings - > outputToSourceDir ( ) )
{
2014-11-25 02:14:42 +01:00
QFile writeTest ( QString ( " %1/~%2.txt " ) . arg ( m_settings - > outputDir ( ) , MUtils : : rand_str ( ) ) ) ;
2011-05-14 18:34:34 +02:00
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! " ) ) ) ;
2012-12-04 01:35:48 +01:00
ui - > tabWidget - > setCurrentIndex ( 1 ) ;
2010-11-21 21:51:41 +01:00
return ;
}
else
{
writeTest . close ( ) ;
writeTest . remove ( ) ;
}
}
2013-07-14 17:13:01 +02: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 ( ) ;
2014-11-25 02:14:42 +01:00
MUTILS_DELETE ( aboutBox ) ;
2012-07-29 19:09:15 +02: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
*/
2013-10-28 00:26:54 +01:00
void MainWindow : : tabPageChanged ( int idx , const bool silent )
2010-11-06 23:04:47 +01:00
{
2012-03-30 03:35:43 +02:00
resizeEvent ( NULL ) ;
2013-10-28 00:26:54 +01:00
//Update "view" menu
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
2013-10-28 00:26:54 +01:00
//Play tick sound
2013-12-03 22:19:11 +01:00
if ( ! silent )
2013-10-28 00:26:54 +01:00
{
2013-12-03 22:19:11 +01:00
PLAY_SOUND_OPTIONAL ( " tick " , true ) ;
2013-10-28 00:26:54 +01:00
}
2011-04-05 14:57:21 +02:00
int initialWidth = this - > width ( ) ;
2012-09-20 22:52:52 +02:00
int maximumWidth = QApplication : : desktop ( ) - > availableGeometry ( ) . width ( ) ;
2011-04-05 14:57:21 +02:00
2012-09-20 22:52:52 +02:00
//Make sure all tab headers are fully visible
2011-04-05 14:57:21 +02:00
if ( this - > isVisible ( ) )
{
2012-12-04 01:35:48 +01:00
int delta = ui - > tabWidget - > sizeHint ( ) . width ( ) - ui - > tabWidget - > width ( ) ;
2012-09-20 22:52:52 +02:00
if ( delta > 0 )
2011-04-05 14:57:21 +02:00
{
2012-09-20 22:52:52 +02:00
this - > resize ( qMin ( this - > width ( ) + delta , maximumWidth ) , this - > height ( ) ) ;
2011-04-05 14:57:21 +02:00
}
}
2012-09-20 22:52:52 +02:00
//Tab specific operations
2012-12-04 01:35:48 +01:00
if ( idx = = ui - > tabWidget - > indexOf ( ui - > tabOptions ) & & ui - > scrollArea - > widget ( ) & & this - > isVisible ( ) )
2011-04-05 14:57:21 +02:00
{
2012-12-04 01:35:48 +01:00
ui - > scrollArea - > widget ( ) - > updateGeometry ( ) ;
ui - > scrollArea - > viewport ( ) - > updateGeometry ( ) ;
2012-09-20 22:52:52 +02:00
qApp - > processEvents ( ) ;
2012-12-04 01:35:48 +01:00
int delta = ui - > scrollArea - > widget ( ) - > width ( ) - ui - > scrollArea - > viewport ( ) - > width ( ) ;
2012-09-20 22:52:52 +02:00
if ( delta > 0 )
2011-04-05 14:57:21 +02:00
{
2012-09-20 22:52:52 +02:00
this - > resize ( qMin ( this - > width ( ) + delta , maximumWidth ) , this - > height ( ) ) ;
2011-04-05 14:57:21 +02:00
}
}
2012-12-04 01:35:48 +01:00
else if ( idx = = ui - > tabWidget - > indexOf ( ui - > tabSourceFiles ) )
2011-03-28 04:26:47 +02:00
{
2012-12-04 01:35:48 +01:00
m_dropNoteLabel - > setGeometry ( 0 , 0 , ui - > sourceFileView - > width ( ) , ui - > sourceFileView - > height ( ) ) ;
2011-03-28 04:26:47 +02:00
}
2012-12-04 01:35:48 +01:00
else if ( idx = = ui - > tabWidget - > indexOf ( ui - > tabOutputDir ) )
2011-06-04 22:43:14 +02:00
{
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
2012-09-20 22:52:52 +02:00
//Center window around previous position
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 )
{
2012-12-04 01:35:48 +01:00
ui - > tabWidget - > setCurrentIndex ( index ) ;
2011-01-03 22:24:58 +01:00
}
2010-11-06 23:04:47 +01:00
}
}
2014-05-04 16:59:06 +02:00
// =========================================================
// Menubar slots
// =========================================================
/*
* Handle corner widget Event
*/
void MainWindow : : cornerWidgetEventOccurred ( QWidget * sender , QEvent * event )
{
if ( event - > type ( ) = = QEvent : : MouseButtonPress )
{
QTimer : : singleShot ( 0 , this , SLOT ( checkUpdatesActionActivated ( ) ) ) ;
}
}
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 :
2012-12-04 01:35:48 +01:00
if ( ui - > actionStyleCleanlooks - > isEnabled ( ) )
2011-01-02 20:47:26 +01:00
{
2012-12-04 01:35:48 +01:00
ui - > actionStyleCleanlooks - > setChecked ( true ) ;
2011-01-02 20:47:26 +01:00
QApplication : : setStyle ( new QCleanlooksStyle ( ) ) ;
break ;
}
2010-11-12 21:02:14 +01:00
case 2 :
2012-12-04 01:35:48 +01:00
if ( ui - > actionStyleWindowsVista - > isEnabled ( ) )
2011-01-02 20:47:26 +01:00
{
2012-12-04 01:35:48 +01:00
ui - > actionStyleWindowsVista - > setChecked ( true ) ;
2011-01-02 20:47:26 +01:00
QApplication : : setStyle ( new QWindowsVistaStyle ( ) ) ;
break ;
}
2010-11-12 21:02:14 +01:00
case 3 :
2012-12-04 01:35:48 +01:00
if ( ui - > actionStyleWindowsXP - > isEnabled ( ) )
2011-01-02 20:47:26 +01:00
{
2012-12-04 01:35:48 +01:00
ui - > actionStyleWindowsXP - > setChecked ( true ) ;
2011-01-02 20:47:26 +01:00
QApplication : : setStyle ( new QWindowsXPStyle ( ) ) ;
break ;
}
2010-11-12 21:02:14 +01:00
case 4 :
2012-12-04 01:35:48 +01:00
if ( ui - > actionStyleWindowsClassic - > isEnabled ( ) )
2011-01-02 20:47:26 +01:00
{
2012-12-04 01:35:48 +01:00
ui - > actionStyleWindowsClassic - > setChecked ( true ) ;
2011-01-02 20:47:26 +01:00
QApplication : : setStyle ( new QWindowsStyle ( ) ) ;
break ;
}
2010-11-12 21:02:14 +01:00
default :
2012-12-04 01:35:48 +01:00
ui - > actionStylePlastique - > setChecked ( true ) ;
2010-11-12 21:02:14 +01:00
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 ) ;
2014-11-25 02:14:42 +01:00
MUTILS_DELETE ( e ) ;
2012-04-06 23:15:58 +02:00
}
2012-12-19 23:43:27 +01:00
//Make transparent
const type_info & styleType = typeid ( * qApp - > style ( ) ) ;
const bool bTransparent = ( ( typeid ( QWindowsVistaStyle ) = = styleType ) | | ( typeid ( QWindowsXPStyle ) = = styleType ) ) ;
MAKE_TRANSPARENT ( ui - > scrollArea , bTransparent ) ;
2013-10-31 01:22:21 +01:00
//Also force a re-size event
QApplication : : processEvents ( QEventLoop : : ExcludeUserInputEvents ) ;
resizeEvent ( NULL ) ;
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 ( ) ;
2014-12-20 23:44:43 +01:00
if ( MUtils : : Translation : : install_translator ( langId ) )
2011-01-06 00:53:52 +01:00
{
action - > setChecked ( true ) ;
2012-12-04 01:35:48 +01:00
ui - > actionLoadTranslationFromFile - > setChecked ( false ) ;
2011-01-06 00:53:52 +01:00
m_settings - > currentLanguage ( langId ) ;
2012-10-14 22:21:57 +02:00
m_settings - > currentLanguageFile ( QString ( ) ) ;
2011-01-06 00:53:52 +01:00
}
}
}
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 ( ) ;
2012-10-14 22:21:57 +02:00
const QString qmFile = QFileInfo ( selectedFiles . first ( ) ) . canonicalFilePath ( ) ;
2014-12-20 23:44:43 +01:00
if ( MUtils : : Translation : : install_translator_from_file ( qmFile ) )
2011-01-06 00:53:52 +01:00
{
QList < QAction * > actions = m_languageActionGroup - > actions ( ) ;
while ( ! actions . isEmpty ( ) )
{
actions . takeFirst ( ) - > setChecked ( false ) ;
}
2012-12-04 01:35:48 +01:00
ui - > actionLoadTranslationFromFile - > setChecked ( true ) ;
2012-10-14 22:21:57 +02:00
m_settings - > currentLanguageFile ( qmFile ) ;
2011-01-06 00:53:52 +01:00
}
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
2012-12-04 01:35:48 +01:00
ui - > 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
2012-12-04 01:35:48 +01:00
ui - > 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
2012-12-04 01:35:48 +01:00
ui - > 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 ) ;
}
2012-12-04 01:35:48 +01:00
ui - > actionDisableSlowStartupNotifications - > setChecked ( ! m_settings - > antivirNotificationsEnabled ( ) ) ;
2011-06-26 15:33:44 +02:00
}
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 ;
2014-12-08 22:06:01 +01:00
if ( MUtils : : GUI : : themes_enabled ( ) )
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 ( ) ) ;
2013-01-18 02:42:37 +01:00
CueImportDialog * cueImporter = new CueImportDialog ( this , m_fileListModel , selectedCueFile , m_settings ) ;
2011-09-29 17:36:38 +02:00
result = cueImporter - > exec ( ) ;
2014-11-25 02:14:42 +01:00
MUTILS_DELETE ( cueImporter ) ;
2011-09-29 17:36:38 +02:00
}
2013-10-25 15:12:27 +02:00
if ( result = = QDialog : : Accepted )
{
qApp - > processEvents ( QEventLoop : : ExcludeUserInputEvents ) ;
ui - > sourceFileView - > update ( ) ;
qApp - > processEvents ( QEventLoop : : ExcludeUserInputEvents ) ;
ui - > sourceFileView - > scrollToBottom ( ) ;
qApp - > processEvents ( QEventLoop : : ExcludeUserInputEvents ) ;
}
2011-09-29 17:36:38 +02:00
if ( result ! = ( - 1 ) ) break ;
2011-05-21 13:07:17 +02:00
}
2012-07-29 19:09:15 +02:00
) ;
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 ( ) ;
2013-11-01 00:08:40 +01:00
QTimer : : singleShot ( 2500 , m_dropBox , SLOT ( showToolTip ( ) ) ) ;
2010-12-10 22:57:48 +01:00
}
2011-05-21 13:07:17 +02:00
2014-12-08 22:06:01 +01:00
MUtils : : GUI : : blink_window ( m_dropBox ) ;
2011-05-21 13:07:17 +02:00
}
/*
* 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
2012-12-04 01:35:48 +01:00
ui - > 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 ) ;
}
2012-12-04 01:35:48 +01:00
ui - > actionHibernateComputer - > setChecked ( m_settings - > hibernateComputer ( ) ) ;
2011-10-22 01:13:28 +02:00
}
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
2012-12-04 01:35:48 +01:00
ui - > actionDisableShellIntegration - > setChecked ( ! m_settings - > shellIntegrationEnabled ( ) ) ;
2011-05-21 13:07:17 +02:00
2014-12-19 23:49:11 +01:00
if ( lamexp_version_portable ( ) & & ui - > actionDisableShellIntegration - > isChecked ( ) )
2011-05-21 13:07:17 +02:00
{
2012-12-04 01:35:48 +01:00
ui - > actionDisableShellIntegration - > setEnabled ( false ) ;
2011-05-21 13:07:17 +02:00
}
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 ( ) ) )
{
2014-12-26 00:42:53 +01:00
openDocumentLink ( action ) ;
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 ( ) ;
2012-07-29 19:09:15 +02: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
(
2014-12-08 22:06:01 +01:00
if ( MUtils : : GUI : : themes_enabled ( ) )
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
}
}
2012-07-29 19:09:15 +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
(
2014-12-08 22:06:01 +01:00
if ( MUtils : : GUI : : themes_enabled ( ) )
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 ( ) ) ;
}
2012-07-29 19:09:15 +02:00
) ;
2011-05-21 13:07:17 +02:00
}
}
/*
* Remove file button
*/
void MainWindow : : removeFileButtonClicked ( void )
{
2012-12-04 01:35:48 +01:00
if ( ui - > sourceFileView - > currentIndex ( ) . isValid ( ) )
2011-05-21 13:07:17 +02:00
{
2012-12-04 01:35:48 +01:00
int iRow = ui - > sourceFileView - > currentIndex ( ) . row ( ) ;
m_fileListModel - > removeFile ( ui - > sourceFileView - > currentIndex ( ) ) ;
ui - > sourceFileView - > selectRow ( iRow < m_fileListModel - > rowCount ( ) ? iRow : m_fileListModel - > rowCount ( ) - 1 ) ;
2011-05-21 13:07:17 +02:00
}
}
/*
* Clear files button
*/
void MainWindow : : clearFilesButtonClicked ( void )
{
m_fileListModel - > clearFiles ( ) ;
}
/*
* Move file up button
*/
void MainWindow : : fileUpButtonClicked ( void )
{
2012-12-04 01:35:48 +01:00
if ( ui - > sourceFileView - > currentIndex ( ) . isValid ( ) )
2011-05-21 13:07:17 +02:00
{
2012-12-04 01:35:48 +01:00
int iRow = ui - > sourceFileView - > currentIndex ( ) . row ( ) - 1 ;
m_fileListModel - > moveFile ( ui - > sourceFileView - > currentIndex ( ) , - 1 ) ;
ui - > sourceFileView - > selectRow ( iRow > = 0 ? iRow : 0 ) ;
2011-05-21 13:07:17 +02:00
}
}
/*
* Move file down button
*/
void MainWindow : : fileDownButtonClicked ( void )
{
2012-12-04 01:35:48 +01:00
if ( ui - > sourceFileView - > currentIndex ( ) . isValid ( ) )
2011-05-21 13:07:17 +02:00
{
2012-12-04 01:35:48 +01:00
int iRow = ui - > sourceFileView - > currentIndex ( ) . row ( ) + 1 ;
m_fileListModel - > moveFile ( ui - > sourceFileView - > currentIndex ( ) , 1 ) ;
ui - > sourceFileView - > selectRow ( iRow < m_fileListModel - > rowCount ( ) ? iRow : m_fileListModel - > rowCount ( ) - 1 ) ;
2011-05-21 13:07:17 +02:00
}
}
/*
* Show details button
*/
void MainWindow : : showDetailsButtonClicked ( void )
{
ABORT_IF_BUSY ;
int iResult = 0 ;
MetaInfoDialog * metaInfoDialog = new MetaInfoDialog ( this ) ;
2012-12-04 01:35:48 +01:00
QModelIndex index = ui - > sourceFileView - > currentIndex ( ) ;
2011-05-21 13:07:17 +02:00
while ( index . isValid ( ) )
{
if ( iResult > 0 )
{
index = m_fileListModel - > index ( index . row ( ) + 1 , index . column ( ) ) ;
2012-12-04 01:35:48 +01:00
ui - > sourceFileView - > selectRow ( index . row ( ) ) ;
2011-05-21 13:07:17 +02:00
}
if ( iResult < 0 )
{
index = m_fileListModel - > index ( index . row ( ) - 1 , index . column ( ) ) ;
2012-12-04 01:35:48 +01:00
ui - > sourceFileView - > selectRow ( index . row ( ) ) ;
2011-05-21 13:07:17 +02:00
}
AudioFileModel & file = ( * m_fileListModel ) [ index ] ;
TEMP_HIDE_DROPBOX
(
iResult = metaInfoDialog - > exec ( file , index . row ( ) > 0 , index . row ( ) < m_fileListModel - > rowCount ( ) - 1 ) ;
2012-07-29 19:09:15 +02:00
) ;
2011-05-31 19:04:45 +02:00
2013-10-25 17:53:47 +02:00
//Copy all info to Meta Info tab
2011-05-31 19:04:45 +02:00
if ( iResult = = INT_MAX )
{
m_metaInfoModel - > assignInfoFrom ( file ) ;
2012-12-04 01:35:48 +01:00
ui - > tabWidget - > setCurrentIndex ( ui - > tabWidget - > indexOf ( ui - > tabMetaData ) ) ;
2011-05-31 19:04:45 +02:00
break ;
}
2011-05-21 13:07:17 +02:00
if ( ! iResult ) break ;
}
2014-11-25 02:14:42 +01:00
MUTILS_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 )
{
2012-12-04 01:35:48 +01:00
ui - > sourceFileView - > resizeColumnToContents ( 0 ) ;
2011-08-23 17:01:11 +02:00
}
2011-05-21 13:07:17 +02:00
/*
* Open selected file in external player
*/
void MainWindow : : previewContextActionTriggered ( void )
{
2012-12-04 01:35:48 +01:00
QModelIndex index = ui - > sourceFileView - > currentIndex ( ) ;
2011-05-21 13:07:17 +02:00
if ( ! index . isValid ( ) )
{
return ;
}
2014-12-04 00:02:42 +01:00
if ( ! MUtils : : OS : : open_media_file ( m_fileListModel - > getFile ( index ) . filePath ( ) ) )
2011-05-21 13:07:17 +02:00
{
2013-10-07 00:01:15 +02:00
qDebug ( " Player not found, falling back to default application... " ) ;
QDesktopServices : : openUrl ( QString ( " file:/// " ) . append ( m_fileListModel - > getFile ( index ) . filePath ( ) ) ) ;
2011-05-21 13:07:17 +02:00
}
}
/*
* Find selected file in explorer
*/
void MainWindow : : findFileContextActionTriggered ( void )
{
2012-12-04 01:35:48 +01:00
QModelIndex index = ui - > sourceFileView - > currentIndex ( ) ;
2011-05-21 13:07:17 +02:00
if ( index . isValid ( ) )
{
QString systemRootPath ;
2014-11-25 03:15:03 +01:00
QDir systemRoot ( MUtils : : OS : : known_folder ( MUtils : : OS : : FOLDER_SYSTEMFOLDER ) ) ;
2011-05-21 13:07:17 +02:00
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! " ) ;
}
}
}
2013-11-29 01:20:59 +01:00
/*
* Add all dropped files
*/
void MainWindow : : handleDroppedFiles ( void )
{
ABORT_IF_BUSY ;
static const int MIN_COUNT = 16 ;
const QString bannerText = tr ( " Loading dropped files or folders, please wait... " ) ;
bool bUseBanner = false ;
SHOW_BANNER_CONDITIONALLY ( bUseBanner , ( m_droppedFileList - > count ( ) > = MIN_COUNT ) , bannerText ) ;
QStringList droppedFiles ;
while ( ! m_droppedFileList - > isEmpty ( ) )
{
QFileInfo file ( m_droppedFileList - > takeFirst ( ) . toLocalFile ( ) ) ;
QApplication : : processEvents ( QEventLoop : : ExcludeUserInputEvents ) ;
if ( ! file . exists ( ) )
{
continue ;
}
if ( file . isFile ( ) )
{
2014-11-25 02:14:42 +01:00
qDebug ( " Dropped File: %s " , MUTILS_UTF8 ( file . canonicalFilePath ( ) ) ) ;
2013-11-29 01:20:59 +01:00
droppedFiles < < file . canonicalFilePath ( ) ;
continue ;
}
if ( file . isDir ( ) )
{
2014-11-25 02:14:42 +01:00
qDebug ( " Dropped Folder: %s " , MUTILS_UTF8 ( file . canonicalFilePath ( ) ) ) ;
2013-11-29 01:20:59 +01:00
QFileInfoList list = QDir ( file . canonicalFilePath ( ) ) . entryInfoList ( QDir : : Files | QDir : : NoDotAndDotDot | QDir : : NoSymLinks ) ;
if ( list . count ( ) > 0 )
{
SHOW_BANNER_CONDITIONALLY ( bUseBanner , ( list . count ( ) > = MIN_COUNT ) , bannerText ) ;
for ( QFileInfoList : : ConstIterator iter = list . constBegin ( ) ; iter ! = list . constEnd ( ) ; iter + + )
{
droppedFiles < < ( * iter ) . canonicalFilePath ( ) ;
}
}
else
{
list = QDir ( file . canonicalFilePath ( ) ) . entryInfoList ( QDir : : Dirs | QDir : : NoDotAndDotDot | QDir : : NoSymLinks ) ;
SHOW_BANNER_CONDITIONALLY ( bUseBanner , ( list . count ( ) > = MIN_COUNT ) , bannerText ) ;
for ( QFileInfoList : : ConstIterator iter = list . constBegin ( ) ; iter ! = list . constEnd ( ) ; iter + + )
{
2014-11-25 02:14:42 +01:00
qDebug ( " Descending to Folder: %s " , MUTILS_UTF8 ( ( * iter ) . canonicalFilePath ( ) ) ) ;
2013-11-29 01:20:59 +01:00
m_droppedFileList - > prepend ( QUrl : : fromLocalFile ( ( * iter ) . canonicalFilePath ( ) ) ) ;
}
}
}
}
if ( bUseBanner )
{
m_banner - > close ( ) ;
}
if ( ! droppedFiles . isEmpty ( ) )
{
addFiles ( droppedFiles ) ;
}
}
2011-05-21 13:07:17 +02:00
/*
* 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
2013-11-26 23:01:37 +01:00
if ( BANNER_VISIBLE )
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 ;
}
2013-11-29 01:20:59 +01:00
WITH_BLOCKED_SIGNALS ( ui - > tabWidget , setCurrentIndex , 0 ) ;
tabPageChanged ( ui - > tabWidget - > currentIndex ( ) , true ) ;
2010-11-08 21:47:35 +01:00
QStringList selectedFiles ;
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 ;
2014-12-08 22:06:01 +01:00
if ( MUtils : : GUI : : themes_enabled ( ) )
2012-01-04 03:23:07 +01:00
{
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! " ) ;
}
}
2012-07-29 19:09:15 +02:00
) ;
2012-01-04 21:10:33 +01:00
}
/*
* Import Meta tags from CSV file
*/
void MainWindow : : importCsvContextActionTriggered ( void )
{
TEMP_HIDE_DROPBOX
(
QString selectedCsvFile ;
2014-12-08 22:06:01 +01:00
if ( MUtils : : GUI : : themes_enabled ( ) )
2012-01-04 21:10:33 +01:00
{
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
}
}
2012-07-29 19:09:15 +02:00
) ;
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-12-04 01:35:48 +01:00
if ( index . isValid ( ) & & ( ui - > outputFolderView - > currentIndex ( ) ! = index ) )
2011-05-21 13:07:17 +02:00
{
2012-12-04 01:35:48 +01:00
ui - > outputFolderView - > setCurrentIndex ( index ) ;
2011-05-21 13:07:17 +02:00
}
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 ( ) ) ;
2012-12-04 01:35:48 +01:00
ui - > outputFolderLabel - > setText ( QDir : : toNativeSeparators ( selectedDir ) ) ;
2012-12-14 01:20:23 +01:00
ui - > outputFolderLabel - > setToolTip ( ui - > outputFolderLabel - > text ( ) ) ;
2012-04-05 15:24:45 +02:00
m_settings - > outputDir ( selectedDir ) ;
}
2012-04-05 16:24:33 +02:00
else
{
2012-12-04 01:35:48 +01:00
ui - > outputFolderLabel - > setText ( QDir : : toNativeSeparators ( m_settings - > outputDir ( ) ) ) ;
2012-12-14 01:20:23 +01:00
ui - > outputFolderLabel - > setToolTip ( ui - > outputFolderLabel - > text ( ) ) ;
2012-04-05 16:24:33 +02:00
}
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 ( ) )
{
2012-12-04 01:35:48 +01:00
ui - > outputFolderView - > setCurrentIndex ( m_fileSystemModel - > index ( desktopPath ) ) ;
outputFolderViewClicked ( ui - > outputFolderView - > currentIndex ( ) ) ;
2012-03-29 19:08:33 +02:00
CENTER_CURRENT_OUTPUT_FOLDER_DELAYED ;
2011-05-21 13:07:17 +02:00
}
else
{
2012-12-04 01:35:48 +01:00
ui - > buttonGotoDesktop - > setEnabled ( false ) ;
2011-05-21 13:07:17 +02:00
}
}
/*
* 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 ( ) )
{
2012-12-04 01:35:48 +01:00
ui - > outputFolderView - > setCurrentIndex ( m_fileSystemModel - > index ( homePath ) ) ;
outputFolderViewClicked ( ui - > outputFolderView - > currentIndex ( ) ) ;
2012-03-29 19:08:33 +02:00
CENTER_CURRENT_OUTPUT_FOLDER_DELAYED ;
2011-05-21 13:07:17 +02:00
}
else
{
2012-12-04 01:35:48 +01:00
ui - > buttonGotoHome - > setEnabled ( false ) ;
2011-05-21 13:07:17 +02:00
}
}
/*
* 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 ( ) )
{
2012-12-04 01:35:48 +01:00
ui - > outputFolderView - > setCurrentIndex ( m_fileSystemModel - > index ( musicPath ) ) ;
outputFolderViewClicked ( ui - > outputFolderView - > currentIndex ( ) ) ;
2012-03-29 19:08:33 +02:00
CENTER_CURRENT_OUTPUT_FOLDER_DELAYED ;
2011-05-21 13:07:17 +02:00
}
else
{
2012-12-04 01:35:48 +01:00
ui - > buttonGotoMusic - > setEnabled ( false ) ;
2011-05-21 13:07:17 +02:00
}
}
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 ( ) )
{
2012-12-04 01:35:48 +01:00
ui - > outputFolderView - > setCurrentIndex ( m_fileSystemModel - > index ( path . canonicalPath ( ) ) ) ;
outputFolderViewClicked ( ui - > outputFolderView - > currentIndex ( ) ) ;
2012-03-29 19:08:33 +02:00
CENTER_CURRENT_OUTPUT_FOLDER_DELAYED ;
2011-08-08 20:26:30 +02:00
}
else
{
2014-12-05 21:08:26 +01:00
MUtils : : Sound : : beep ( MUtils : : Sound : : BEEP_ERR ) ;
2011-08-08 20:26:30 +02:00
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 ;
}
2012-12-04 01:35:48 +01:00
QDir basePath ( m_fileSystemModel - > fileInfo ( ui - > outputFolderView - > currentIndex ( ) ) . absoluteFilePath ( ) ) ;
2011-05-21 13:07:17 +02:00
QString suggestedName = tr ( " New Folder " ) ;
2013-10-13 00:21:37 +02:00
if ( ! m_metaData - > artist ( ) . isEmpty ( ) & & ! m_metaData - > album ( ) . isEmpty ( ) )
2011-05-21 13:07:17 +02:00
{
2013-10-13 00:21:37 +02:00
suggestedName = QString ( " %1 - %2 " ) . arg ( m_metaData - > artist ( ) , m_metaData - > album ( ) ) ;
2011-05-21 13:07:17 +02:00
}
2013-10-13 00:21:37 +02:00
else if ( ! m_metaData - > artist ( ) . isEmpty ( ) )
2011-05-21 13:07:17 +02:00
{
2013-10-13 00:21:37 +02:00
suggestedName = m_metaData - > artist ( ) ;
2011-05-21 13:07:17 +02:00
}
2013-10-13 00:21:37 +02:00
else if ( ! m_metaData - > album ( ) . isEmpty ( ) )
2011-05-21 13:07:17 +02:00
{
2013-10-13 00:21:37 +02:00
suggestedName = m_metaData - > album ( ) ;
2011-05-21 13:07:17 +02:00
}
else
{
for ( int i = 0 ; i < m_fileListModel - > rowCount ( ) ; i + + )
{
2013-10-12 22:55:41 +02:00
const AudioFileModel & audioFile = m_fileListModel - > getFile ( m_fileListModel - > index ( i , 0 ) ) ;
2013-10-13 00:21:37 +02:00
const AudioFileModel_MetaInfo & fileMetaInfo = audioFile . metaInfo ( ) ;
2013-10-12 22:55:41 +02:00
if ( ! fileMetaInfo . album ( ) . isEmpty ( ) | | ! fileMetaInfo . artist ( ) . isEmpty ( ) )
2011-05-21 13:07:17 +02:00
{
2013-10-12 22:55:41 +02:00
if ( ! fileMetaInfo . artist ( ) . isEmpty ( ) & & ! fileMetaInfo . album ( ) . isEmpty ( ) )
2011-05-21 13:07:17 +02:00
{
2013-10-12 22:55:41 +02:00
suggestedName = QString ( " %1 - %2 " ) . arg ( fileMetaInfo . artist ( ) , fileMetaInfo . album ( ) ) ;
2011-05-21 13:07:17 +02:00
}
2013-10-12 22:55:41 +02:00
else if ( ! fileMetaInfo . artist ( ) . isEmpty ( ) )
2011-05-21 13:07:17 +02:00
{
2013-10-12 22:55:41 +02:00
suggestedName = fileMetaInfo . artist ( ) ;
2011-05-21 13:07:17 +02:00
}
2013-10-12 22:55:41 +02:00
else if ( ! fileMetaInfo . album ( ) . isEmpty ( ) )
2011-05-21 13:07:17 +02:00
{
2013-10-12 22:55:41 +02:00
suggestedName = fileMetaInfo . album ( ) ;
2011-05-21 13:07:17 +02:00
}
break ;
}
}
}
2014-12-05 21:08:26 +01:00
suggestedName = MUtils : : clean_file_name ( suggestedName ) ;
2011-08-08 20:26:30 +02:00
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 )
{
2014-12-05 21:08:26 +01:00
folderName = MUtils : : clean_file_path ( folderName . simplified ( ) ) ;
2011-05-21 13:07:17 +02:00
if ( folderName . isEmpty ( ) )
{
2014-12-05 21:08:26 +01:00
MUtils : : Sound : : beep ( MUtils : : Sound : : BEEP_ERR ) ;
2011-05-21 13:07:17 +02:00
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 ( ) ) ;
2012-12-04 01:35:48 +01:00
ui - > outputFolderView - > setCurrentIndex ( newIndex ) ;
2012-03-30 03:35:43 +02:00
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 )
{
2012-12-04 01:35:48 +01:00
m_settings - > outputToSourceDir ( ui - > saveToSourceFolderCheckBox - > isChecked ( ) ) ;
2011-05-21 13:07:17 +02:00
}
/*
* Prepend relative source file path to output file name changed
*/
void MainWindow : : prependRelativePathChanged ( void )
{
2012-12-04 01:35:48 +01:00
m_settings - > prependRelativeSourcePath ( ui - > prependRelativePathCheckBox - > isChecked ( ) ) ;
2011-05-21 13:07:17 +02:00
}
/*
* 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 ;
}
2012-12-04 01:35:48 +01:00
QString path = QDir : : toNativeSeparators ( m_fileSystemModel - > filePath ( ui - > outputFolderView - > currentIndex ( ) ) ) ;
2011-12-19 02:09:45 +01:00
if ( ! path . endsWith ( QDir : : separator ( ) ) ) path . append ( QDir : : separator ( ) ) ;
2014-12-04 00:02:42 +01:00
MUtils : : OS : : shell_open ( this , path , true ) ;
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 ( ) ) ) ;
}
2012-12-14 23:50:56 +01:00
/*
* Go one directory up
*/
void MainWindow : : goUpFolderContextActionTriggered ( void )
{
QModelIndex current = ui - > outputFolderView - > currentIndex ( ) ;
if ( current . isValid ( ) )
{
QModelIndex parent = current . parent ( ) ;
if ( parent . isValid ( ) )
{
ui - > outputFolderView - > setCurrentIndex ( parent ) ;
outputFolderViewClicked ( parent ) ;
}
else
{
2014-12-05 21:08:26 +01:00
MUtils : : Sound : : beep ( MUtils : : Sound : : BEEP_WRN ) ;
2012-12-14 23:50:56 +01:00
}
CENTER_CURRENT_OUTPUT_FOLDER_DELAYED ;
}
}
2011-08-08 20:26:30 +02:00
/*
* Add current folder to favorites
*/
void MainWindow : : addFavoriteFolderActionTriggered ( void )
{
2012-12-04 01:35:48 +01:00
QString path = m_fileSystemModel - > filePath ( ui - > outputFolderView - > currentIndex ( ) ) ;
2011-08-08 20:26:30 +02:00
QStringList favorites = m_settings - > favoriteOutputFolders ( ) . split ( " | " , QString : : SkipEmptyParts ) ;
if ( ! favorites . contains ( path , Qt : : CaseInsensitive ) )
{
favorites . append ( path ) ;
while ( favorites . count ( ) > 6 ) favorites . removeFirst ( ) ;
}
else
{
2014-12-05 21:08:26 +01:00
MUtils : : Sound : : beep ( MUtils : : Sound : : BEEP_WRN ) ;
2011-08-08 20:26:30 +02:00
}
m_settings - > favoriteOutputFolders ( favorites . join ( " | " ) ) ;
refreshFavorites ( ) ;
}
2012-03-26 22:02:11 +02:00
/*
* Output folder edit finished
*/
void MainWindow : : outputFolderEditFinished ( void )
{
2012-12-04 01:35:48 +01:00
if ( ui - > outputFolderEdit - > isHidden ( ) )
2012-03-27 22:46:01 +02:00
{
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 ;
2012-12-04 01:35:48 +01:00
QString text = QDir : : fromNativeSeparators ( ui - > outputFolderEdit - > text ( ) . trimmed ( ) ) ;
2012-03-27 22:46:01 +02:00
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-12-04 01:35:48 +01:00
text = QString ( " %1/%2 " ) . arg ( QDir : : fromNativeSeparators ( ui - > outputFolderLabel - > text ( ) ) , text ) ;
2012-03-27 22:46:01 +02:00
}
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-12-04 01:35:48 +01:00
ui - > 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-12-04 01:35:48 +01:00
ui - > 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-12-04 01:35:48 +01:00
ui - > outputFolderEdit - > setVisible ( false ) ;
ui - > outputFolderLabel - > setVisible ( true ) ;
ui - > outputFolderView - > setEnabled ( true ) ;
2012-03-29 19:08:33 +02:00
2014-12-05 21:08:26 +01:00
if ( ! ok ) MUtils : : Sound : : beep ( MUtils : : Sound : : BEEP_ERR ) ;
2012-03-29 19:08:33 +02:00
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-12-04 01:35:48 +01:00
SET_MODEL ( ui - > outputFolderView , NULL ) ;
2014-11-25 02:14:42 +01:00
MUTILS_DELETE ( m_fileSystemModel ) ;
2012-12-04 01:35:48 +01:00
ui - > 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-12-04 01:35:48 +01:00
SET_MODEL ( ui - > outputFolderView , m_fileSystemModel ) ;
ui - > outputFolderView - > header ( ) - > setStretchLastSection ( true ) ;
ui - > outputFolderView - > header ( ) - > hideSection ( 1 ) ;
ui - > outputFolderView - > header ( ) - > hideSection ( 2 ) ;
ui - > outputFolderView - > header ( ) - > hideSection ( 3 ) ;
2012-04-05 15:24:45 +02:00
m_fileSystemModel - > setRootPath ( " " ) ;
QModelIndex index = m_fileSystemModel - > index ( m_settings - > outputDir ( ) ) ;
2012-12-04 01:35:48 +01:00
if ( index . isValid ( ) ) ui - > outputFolderView - > setCurrentIndex ( index ) ;
outputFolderViewClicked ( ui - > outputFolderView - > currentIndex ( ) ) ;
2012-04-05 15:24:45 +02:00
}
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 ( ) ) ) ;
2012-12-04 01:35:48 +01:00
ui - > outputFolderView - > setFocus ( ) ;
2012-03-30 03:35:43 +02:00
}
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
{
2012-12-04 01:35:48 +01:00
if ( ui - > outputFolderView - > isVisible ( ) )
2012-03-29 03:22:24 +02:00
{
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-12-04 01:35:48 +01:00
if ( ui - > outputFolderView - > isVisible ( ) )
2012-03-29 01:32:47 +02:00
{
m_outputFolderViewCentering = true ;
2012-12-04 01:35:48 +01:00
const QModelIndex index = ui - > outputFolderView - > currentIndex ( ) ;
ui - > outputFolderView - > scrollTo ( index , QAbstractItemView : : PositionAtCenter ) ;
ui - > outputFolderView - > setFocus ( ) ;
2012-03-29 01:32:47 +02:00
}
}
/*
* 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
}
2012-07-30 21:44:44 +02:00
/*
* View event for output folder control occurred
*/
void MainWindow : : outputFolderViewEventOccurred ( QWidget * sender , QEvent * event )
{
switch ( event - > type ( ) )
{
case QEvent : : Enter :
case QEvent : : Leave :
case QEvent : : KeyPress :
case QEvent : : KeyRelease :
case QEvent : : FocusIn :
case QEvent : : FocusOut :
case QEvent : : TouchEnd :
2012-12-04 01:35:48 +01:00
outputFolderViewClicked ( ui - > outputFolderView - > currentIndex ( ) ) ;
2012-07-30 21:44:44 +02:00
break ;
}
}
/*
* Mouse event for output folder control occurred
*/
void MainWindow : : outputFolderMouseEventOccurred ( QWidget * sender , QEvent * event )
{
QMouseEvent * mouseEvent = dynamic_cast < QMouseEvent * > ( event ) ;
QPoint pos = ( mouseEvent ) ? mouseEvent - > pos ( ) : QPoint ( ) ;
2012-12-04 01:35:48 +01:00
if ( sender = = ui - > outputFolderLabel )
2012-07-30 21:44:44 +02:00
{
switch ( event - > type ( ) )
{
case QEvent : : MouseButtonPress :
if ( mouseEvent & & ( mouseEvent - > button ( ) = = Qt : : LeftButton ) )
{
2012-12-04 01:35:48 +01:00
QString path = ui - > outputFolderLabel - > text ( ) ;
2012-07-30 21:44:44 +02:00
if ( ! path . endsWith ( QDir : : separator ( ) ) ) path . append ( QDir : : separator ( ) ) ;
2014-12-04 00:02:42 +01:00
MUtils : : OS : : shell_open ( this , path , true ) ;
2012-07-30 21:44:44 +02:00
}
break ;
case QEvent : : Enter :
2012-12-04 01:35:48 +01:00
ui - > outputFolderLabel - > setForegroundRole ( QPalette : : Link ) ;
2012-07-30 21:44:44 +02:00
break ;
case QEvent : : Leave :
2012-12-04 01:35:48 +01:00
ui - > outputFolderLabel - > setForegroundRole ( QPalette : : WindowText ) ;
2012-07-30 21:44:44 +02:00
break ;
}
}
2012-12-14 00:34:10 +01:00
if ( ( sender = = ui - > outputFoldersFovoritesLabel ) | | ( sender = = ui - > outputFoldersEditorLabel ) | | ( sender = = ui - > outputFoldersGoUpLabel ) )
2012-07-30 21:44:44 +02:00
{
2012-12-19 23:43:27 +01:00
const type_info & styleType = typeid ( * qApp - > style ( ) ) ;
if ( ( typeid ( QPlastiqueStyle ) = = styleType ) | | ( typeid ( QWindowsStyle ) = = styleType ) )
2012-07-30 21:44:44 +02:00
{
2012-12-19 23:43:27 +01:00
switch ( event - > type ( ) )
{
case QEvent : : Enter :
dynamic_cast < QLabel * > ( sender ) - > setFrameShadow ( ui - > outputFolderView - > isEnabled ( ) ? QFrame : : Raised : QFrame : : Plain ) ;
break ;
case QEvent : : MouseButtonPress :
dynamic_cast < QLabel * > ( sender ) - > setFrameShadow ( ui - > outputFolderView - > isEnabled ( ) ? QFrame : : Sunken : QFrame : : Plain ) ;
break ;
case QEvent : : MouseButtonRelease :
dynamic_cast < QLabel * > ( sender ) - > setFrameShadow ( ui - > outputFolderView - > isEnabled ( ) ? QFrame : : Raised : QFrame : : Plain ) ;
break ;
case QEvent : : Leave :
dynamic_cast < QLabel * > ( sender ) - > setFrameShadow ( ui - > outputFolderView - > isEnabled ( ) ? QFrame : : Plain : QFrame : : Plain ) ;
break ;
}
}
else
{
dynamic_cast < QLabel * > ( sender ) - > setFrameShadow ( QFrame : : Plain ) ;
2012-07-30 21:44:44 +02:00
}
2012-12-14 00:34:10 +01:00
if ( ( event - > type ( ) = = QEvent : : MouseButtonRelease ) & & ui - > outputFolderView - > isEnabled ( ) & & ( mouseEvent ) )
2012-07-30 21:44:44 +02:00
{
2012-12-14 00:34:10 +01:00
if ( pos . x ( ) < = sender - > width ( ) & & pos . y ( ) < = sender - > height ( ) & & pos . x ( ) > = 0 & & pos . y ( ) > = 0 & & mouseEvent - > button ( ) ! = Qt : : MidButton )
2012-07-30 21:44:44 +02:00
{
2012-12-14 00:34:10 +01:00
if ( sender = = ui - > outputFoldersFovoritesLabel )
{
m_outputFolderFavoritesMenu - > popup ( sender - > mapToGlobal ( pos ) ) ;
}
else if ( sender = = ui - > outputFoldersEditorLabel )
2012-07-30 21:44:44 +02:00
{
2012-12-14 00:34:10 +01:00
ui - > outputFolderView - > setEnabled ( false ) ;
ui - > outputFolderLabel - > setVisible ( false ) ;
ui - > outputFolderEdit - > setVisible ( true ) ;
ui - > outputFolderEdit - > setText ( ui - > outputFolderLabel - > text ( ) ) ;
ui - > outputFolderEdit - > selectAll ( ) ;
ui - > outputFolderEdit - > setFocus ( ) ;
}
else if ( sender = = ui - > outputFoldersGoUpLabel )
{
2012-12-14 23:50:56 +01:00
QTimer : : singleShot ( 0 , this , SLOT ( goUpFolderContextActionTriggered ( ) ) ) ;
2012-12-14 00:34:10 +01:00
}
else
{
2014-11-30 21:32:23 +01:00
MUTILS_THROW ( " Oups, this is not supposed to happen! " ) ;
2012-07-30 21:44:44 +02:00
}
}
}
}
}
2011-05-21 13:07:17 +02:00
// =========================================================
// Metadata tab slots
// =========================================================
/*
* Edit meta button clicked
*/
void MainWindow : : editMetaButtonClicked ( void )
{
ABORT_IF_BUSY ;
2012-12-04 01:35:48 +01:00
const QModelIndex index = ui - > metaDataView - > currentIndex ( ) ;
2011-05-21 13:07:17 +02:00
if ( index . isValid ( ) )
{
m_metaInfoModel - > editItem ( index , this ) ;
if ( index . row ( ) = = 4 )
{
2013-10-13 00:21:37 +02:00
m_settings - > metaInfoPosition ( m_metaData - > position ( ) ) ;
2011-05-21 13:07:17 +02:00
}
}
}
/*
* Reset meta button clicked
*/
void MainWindow : : clearMetaButtonClicked ( void )
{
ABORT_IF_BUSY ;
m_metaInfoModel - > clearData ( ) ;
}
/*
* Meta tags enabled changed
*/
void MainWindow : : metaTagsEnabledChanged ( void )
{
2012-12-04 01:35:48 +01:00
m_settings - > writeMetaTags ( ui - > writeMetaDataCheckBox - > isChecked ( ) ) ;
2011-05-21 13:07:17 +02:00
}
/*
* Playlist enabled changed
*/
void MainWindow : : playlistEnabledChanged ( void )
{
2012-12-04 01:35:48 +01:00
m_settings - > createPlaylist ( ui - > generatePlaylistCheckBox - > isChecked ( ) ) ;
2011-05-21 13:07:17 +02:00
}
// =========================================================
// Compression tab slots
// =========================================================
2010-11-15 04:42:06 +01:00
/*
* Update encoder
*/
void MainWindow : : updateEncoder ( int id )
{
2013-10-03 18:48:07 +02:00
/*qWarning("\nupdateEncoder(%d)", id);*/
2013-10-02 19:17:33 +02:00
2010-11-15 04:42:06 +01:00
m_settings - > compressionEncoder ( id ) ;
2013-10-02 16:39:26 +02:00
const AbstractEncoderInfo * info = EncoderRegistry : : getEncoderInfo ( id ) ;
2010-11-15 04:42:06 +01:00
2013-10-02 16:39:26 +02:00
//Update UI controls
2013-10-03 18:48:07 +02:00
ui - > radioButtonModeQuality - > setEnabled ( info - > isModeSupported ( SettingsModel : : VBRMode ) ) ;
2013-10-02 16:39:26 +02:00
ui - > radioButtonModeAverageBitrate - > setEnabled ( info - > isModeSupported ( SettingsModel : : ABRMode ) ) ;
2013-10-03 18:48:07 +02:00
ui - > radioButtonConstBitrate - > setEnabled ( info - > isModeSupported ( SettingsModel : : CBRMode ) ) ;
2013-10-02 16:39:26 +02:00
//Initialize checkbox state
2013-10-03 18:48:07 +02:00
if ( ui - > radioButtonModeQuality - > isEnabled ( ) ) ui - > radioButtonModeQuality - > setChecked ( true ) ;
2013-10-02 19:17:33 +02:00
else if ( ui - > radioButtonModeAverageBitrate - > isEnabled ( ) ) ui - > radioButtonModeAverageBitrate - > setChecked ( true ) ;
2013-10-03 18:48:07 +02:00
else if ( ui - > radioButtonConstBitrate - > isEnabled ( ) ) ui - > radioButtonConstBitrate - > setChecked ( true ) ;
2014-11-30 21:32:23 +01:00
else MUTILS_THROW ( " It appears that the encoder does not support *any* RC mode! " ) ;
2013-07-07 23:49:29 +02:00
2013-10-02 16:39:26 +02:00
//Apply current RC mode
const int currentRCMode = EncoderRegistry : : loadEncoderMode ( m_settings , id ) ;
switch ( currentRCMode )
2010-11-15 04:42:06 +01:00
{
2013-10-03 18:48:07 +02:00
case SettingsModel : : VBRMode : if ( ui - > radioButtonModeQuality - > isEnabled ( ) ) ui - > radioButtonModeQuality - > setChecked ( true ) ; break ;
case SettingsModel : : ABRMode : if ( ui - > radioButtonModeAverageBitrate - > isEnabled ( ) ) ui - > radioButtonModeAverageBitrate - > setChecked ( true ) ; break ;
case SettingsModel : : CBRMode : if ( ui - > radioButtonConstBitrate - > isEnabled ( ) ) ui - > radioButtonConstBitrate - > setChecked ( true ) ; break ;
2014-11-30 21:32:23 +01:00
default : MUTILS_THROW ( " updateEncoder(): Unknown rc-mode encountered! " ) ;
2010-11-15 04:42:06 +01:00
}
2013-10-02 16:39:26 +02:00
//Display encoder description
if ( const char * description = info - > description ( ) )
2012-03-06 22:29:55 +01:00
{
2012-12-04 01:35:48 +01:00
ui - > labelEncoderInfo - > setVisible ( true ) ;
2013-10-02 16:39:26 +02:00
ui - > labelEncoderInfo - > setText ( tr ( " Current Encoder: %1 " ) . arg ( QString : : fromUtf8 ( description ) ) ) ;
2012-03-06 22:29:55 +01:00
}
else
{
2012-12-04 01:35:48 +01:00
ui - > labelEncoderInfo - > setVisible ( false ) ;
2012-03-06 22:29:55 +01:00
}
2013-07-07 23:49:29 +02:00
//Update RC mode!
2013-10-03 18:48:07 +02:00
updateRCMode ( m_modeButtonGroup - > checkedId ( ) ) ;
2010-11-15 04:42:06 +01:00
}
/*
* Update rate - control mode
*/
void MainWindow : : updateRCMode ( int id )
{
2013-10-03 18:48:07 +02:00
/*qWarning("updateRCMode(%d)", id);*/
2013-10-02 16:39:26 +02:00
//Store new RC mode
const int currentEncoder = m_encoderButtonGroup - > checkedId ( ) ;
EncoderRegistry : : saveEncoderMode ( m_settings , currentEncoder , id ) ;
//Fetch encoder info
const AbstractEncoderInfo * info = EncoderRegistry : : getEncoderInfo ( currentEncoder ) ;
const int valueCount = info - > valueCount ( id ) ;
2010-11-15 04:42:06 +01:00
2013-10-03 18:48:07 +02:00
//Sanity check
if ( ! info - > isModeSupported ( id ) )
{
qWarning ( " Attempting to use an unsupported RC mode (%d) with current encoder (%d)! " , id , currentEncoder ) ;
ui - > labelBitrate - > setText ( " (ERROR) " ) ;
return ;
}
2013-10-02 16:39:26 +02:00
//Update slider min/max values
if ( valueCount > 0 )
2010-11-15 04:42:06 +01:00
{
2013-10-02 16:39:26 +02:00
WITH_BLOCKED_SIGNALS ( ui - > sliderBitrate , setEnabled , true ) ;
WITH_BLOCKED_SIGNALS ( ui - > sliderBitrate , setMinimum , 0 ) ;
WITH_BLOCKED_SIGNALS ( ui - > sliderBitrate , setMaximum , valueCount - 1 ) ;
}
else
{
WITH_BLOCKED_SIGNALS ( ui - > sliderBitrate , setEnabled , false ) ;
WITH_BLOCKED_SIGNALS ( ui - > sliderBitrate , setMinimum , 0 ) ;
WITH_BLOCKED_SIGNALS ( ui - > sliderBitrate , setMaximum , 2 ) ;
2010-11-15 04:42:06 +01:00
}
2013-10-02 16:39:26 +02:00
//Now update bitrate/quality value!
if ( valueCount > 0 )
2013-07-07 23:49:29 +02:00
{
2013-10-03 18:48:07 +02:00
const int currentValue = EncoderRegistry : : loadEncoderValue ( m_settings , currentEncoder , id ) ;
ui - > sliderBitrate - > setValue ( qBound ( 0 , currentValue , valueCount - 1 ) ) ;
updateBitrate ( qBound ( 0 , currentValue , valueCount - 1 ) ) ;
2013-10-02 16:39:26 +02:00
}
else
{
ui - > sliderBitrate - > setValue ( 1 ) ;
updateBitrate ( 0 ) ;
2013-07-07 23:49:29 +02:00
}
2010-11-15 04:42:06 +01:00
}
2010-11-11 22:58:02 +01:00
/*
* Update bitrate
*/
void MainWindow : : updateBitrate ( int value )
{
2013-10-03 18:48:07 +02:00
/*qWarning("updateBitrate(%d)", value);*/
2013-10-02 16:39:26 +02:00
//Load current encoder and RC mode
const int currentEncoder = m_encoderButtonGroup - > checkedId ( ) ;
2013-10-03 18:48:07 +02:00
const int currentRCMode = m_modeButtonGroup - > checkedId ( ) ;
2013-07-07 23:49:29 +02:00
2013-10-02 16:39:26 +02:00
//Fetch encoder info
const AbstractEncoderInfo * info = EncoderRegistry : : getEncoderInfo ( currentEncoder ) ;
const int valueCount = info - > valueCount ( currentRCMode ) ;
2013-07-07 23:49:29 +02:00
2013-10-03 18:48:07 +02:00
//Sanity check
if ( ! info - > isModeSupported ( currentRCMode ) )
{
qWarning ( " Attempting to use an unsupported RC mode (%d) with current encoder (%d)! " , currentRCMode , currentEncoder ) ;
ui - > labelBitrate - > setText ( " (ERROR) " ) ;
return ;
}
//Store new bitrate value
2013-10-02 16:39:26 +02:00
if ( valueCount > 0 )
2010-11-15 04:42:06 +01:00
{
2013-10-02 16:39:26 +02:00
EncoderRegistry : : saveEncoderValue ( m_settings , currentEncoder , currentRCMode , qBound ( 0 , value , valueCount - 1 ) ) ;
}
//Update bitrate value
const int displayValue = ( valueCount > 0 ) ? info - > valueAt ( currentRCMode , qBound ( 0 , value , valueCount - 1 ) ) : INT_MAX ;
switch ( info - > valueType ( currentRCMode ) )
{
case AbstractEncoderInfo : : TYPE_BITRATE :
ui - > labelBitrate - > setText ( QString ( " %1 kbps " ) . arg ( QString : : number ( displayValue ) ) ) ;
2010-11-15 04:42:06 +01:00
break ;
2013-10-02 16:39:26 +02:00
case AbstractEncoderInfo : : TYPE_APPROX_BITRATE :
ui - > labelBitrate - > setText ( QString ( " ≈ %1 kbps " ) . arg ( QString : : number ( displayValue ) ) ) ;
2013-07-07 23:49:29 +02:00
break ;
2013-10-07 02:28:01 +02:00
case AbstractEncoderInfo : : TYPE_QUALITY_LEVEL_INT :
2013-10-02 16:39:26 +02:00
ui - > labelBitrate - > setText ( tr ( " Quality Level %1 " ) . arg ( QString : : number ( displayValue ) ) ) ;
2010-11-15 04:42:06 +01:00
break ;
2013-10-07 02:28:01 +02:00
case AbstractEncoderInfo : : TYPE_QUALITY_LEVEL_FLT :
ui - > labelBitrate - > setText ( tr ( " Quality Level %1 " ) . arg ( QString ( ) . sprintf ( " %.2f " , double ( displayValue ) / 100.0 ) ) ) ;
break ;
2013-10-02 16:39:26 +02:00
case AbstractEncoderInfo : : TYPE_COMPRESSION_LEVEL :
ui - > labelBitrate - > setText ( tr ( " Compression %1 " ) . arg ( QString : : number ( displayValue ) ) ) ;
2013-07-07 23:49:29 +02:00
break ;
2013-10-02 16:39:26 +02:00
case AbstractEncoderInfo : : TYPE_UNCOMPRESSED :
ui - > labelBitrate - > setText ( tr ( " Uncompressed " ) ) ;
2010-11-15 04:42:06 +01:00
break ;
2013-07-07 23:49:29 +02:00
default :
2014-11-30 21:32:23 +01:00
MUTILS_THROW ( " Unknown display value type encountered! " ) ;
2013-07-07 23:49:29 +02:00
break ;
2010-11-15 04:42:06 +01:00
}
2010-11-11 22:58:02 +01:00
}
2010-11-20 02:14:22 +01:00
2012-08-02 23:32:21 +02:00
/*
* Event for compression tab occurred
*/
void MainWindow : : compressionTabEventOccurred ( QWidget * sender , QEvent * event )
{
2012-08-20 22:23:38 +02:00
static const QUrl helpUrl ( " http://lamexp.sourceforge.net/doc/FAQ.html#054010d9 " ) ;
2012-12-04 01:35:48 +01:00
if ( ( sender = = ui - > labelCompressionHelp ) & & ( event - > type ( ) = = QEvent : : MouseButtonPress ) )
2012-08-02 23:32:21 +02:00
{
2012-08-20 22:23:38 +02:00
QDesktopServices : : openUrl ( helpUrl ) ;
2012-08-02 23:32:21 +02:00
}
2013-07-14 18:14:26 +02:00
else if ( ( sender = = ui - > labelResetEncoders ) & & ( event - > type ( ) = = QEvent : : MouseButtonPress ) )
{
2013-12-03 22:19:11 +01:00
PLAY_SOUND_OPTIONAL ( " blast " , true ) ;
2013-10-03 15:56:10 +02:00
EncoderRegistry : : resetAllEncoders ( m_settings ) ;
2013-07-14 18:14:26 +02:00
m_settings - > compressionEncoder ( SettingsModel : : MP3Encoder ) ;
ui - > radioButtonEncoderMP3 - > setChecked ( true ) ;
QTimer : : singleShot ( 0 , this , SLOT ( updateEncoder ( ) ) ) ;
}
2012-08-02 23:32:21 +02: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 3 :
2013-03-13 22:59:54 +01:00
text = tr ( " Best Quality (Slow) " ) ;
2011-01-21 19:14:11 +01:00
break ;
case 2 :
2013-03-13 22:59:54 +01:00
text = tr ( " High Quality (Recommended) " ) ;
2011-01-21 19:14:11 +01:00
break ;
case 1 :
2013-03-13 22:59:54 +01:00
text = tr ( " Acceptable Quality (Fast) " ) ;
2011-01-21 19:14:11 +01:00
break ;
case 0 :
text = tr ( " Poor Quality (Very Fast) " ) ;
break ;
}
if ( ! text . isEmpty ( ) )
{
m_settings - > lameAlgoQuality ( value ) ;
2012-12-04 01:35:48 +01:00
ui - > labelLameAlgoQuality - > setText ( text ) ;
2011-01-21 19:14:11 +01:00
}
2011-08-25 03:44:46 +02:00
2013-03-13 22:59:54 +01:00
bool warning = ( value = = 0 ) , notice = ( value = = 3 ) ;
2012-12-04 01:35:48 +01:00
ui - > labelLameAlgoQualityWarning - > setVisible ( warning ) ;
ui - > labelLameAlgoQualityWarningIcon - > setVisible ( warning ) ;
ui - > labelLameAlgoQualityNotice - > setVisible ( notice ) ;
ui - > labelLameAlgoQualityNoticeIcon - > setVisible ( notice ) ;
ui - > 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 )
{
2012-12-04 01:35:48 +01:00
if ( value > ui - > spinBoxBitrateManagementMax - > value ( ) )
2011-01-21 21:41:50 +01:00
{
2012-12-04 01:35:48 +01:00
ui - > spinBoxBitrateManagementMin - > setValue ( ui - > spinBoxBitrateManagementMax - > value ( ) ) ;
m_settings - > bitrateManagementMinRate ( ui - > spinBoxBitrateManagementMax - > value ( ) ) ;
2011-01-21 21:41:50 +01:00
}
else
{
m_settings - > bitrateManagementMinRate ( value ) ;
}
}
/*
* Maximum bitrate has changed
*/
void MainWindow : : bitrateManagementMaxChanged ( int value )
{
2012-12-04 01:35:48 +01:00
if ( value < ui - > spinBoxBitrateManagementMin - > value ( ) )
2011-01-21 21:41:50 +01:00
{
2012-12-04 01:35:48 +01:00
ui - > spinBoxBitrateManagementMax - > setValue ( ui - > spinBoxBitrateManagementMin - > value ( ) ) ;
m_settings - > bitrateManagementMaxRate ( ui - > spinBoxBitrateManagementMin - > value ( ) ) ;
2011-01-21 21:41:50 +01:00
}
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 ) ;
}
2012-07-21 19:16:12 +02:00
/*
* Opus encoder settings changed
*/
void MainWindow : : opusSettingsChanged ( void )
{
2012-12-04 01:35:48 +01:00
m_settings - > opusFramesize ( ui - > comboBoxOpusFramesize - > currentIndex ( ) ) ;
m_settings - > opusComplexity ( ui - > spinBoxOpusComplexity - > value ( ) ) ;
2013-01-18 02:42:37 +01:00
m_settings - > opusDisableResample ( ui - > checkBoxOpusDisableResample - > isChecked ( ) ) ;
2012-07-21 19:16:12 +02:00
}
2011-01-24 01:13:08 +01:00
/*
* Normalization filter enabled changed
*/
void MainWindow : : normalizationEnabledChanged ( bool checked )
{
m_settings - > normalizationFilterEnabled ( checked ) ;
2015-03-21 19:06:55 +01:00
normalizationDynamicChanged ( ui - > checkBoxNormalizationFilterDynamic - > isChecked ( ) ) ;
}
/*
* Dynamic normalization enabled changed
*/
void MainWindow : : normalizationDynamicChanged ( bool checked )
{
ui - > spinBoxNormalizationFilterSize - > setEnabled ( ui - > checkBoxNormalizationFilterEnabled - > isChecked ( ) & & checked ) ;
m_settings - > normalizationFilterDynamic ( checked ) ;
2011-01-24 01:13:08 +01:00
}
/*
* 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
*/
2015-03-21 19:06:55 +01:00
void MainWindow : : normalizationCoupledChanged ( bool checked )
{
m_settings - > normalizationFilterCoupled ( checked ) ;
}
/*
* Normalization filter size changed
*/
void MainWindow : : normalizationFilterSizeChanged ( int value )
2011-10-06 23:55:42 +02:00
{
2015-03-21 19:06:55 +01:00
m_settings - > normalizationFilterSize ( value ) ;
}
/*
* Normalization filter size editing finished
*/
void MainWindow : : normalizationFilterSizeFinished ( void )
{
const int value = ui - > spinBoxNormalizationFilterSize - > value ( ) ;
if ( ( value % 2 ) ! = 1 )
{
bool rnd = MUtils : : parity ( MUtils : : next_rand32 ( ) ) ;
ui - > spinBoxNormalizationFilterSize - > setValue ( rnd ? value + 1 : value - 1 ) ;
}
2011-10-06 23:55:42 +02:00
}
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 ) ) ;
2012-12-04 01:35:48 +01:00
ui - > spinBoxToneAdjustBass - > setPrefix ( ( value > 0 ) ? " + " : QString ( ) ) ;
2011-01-26 20:16:46 +01:00
}
/*
* Tone adjustment has changed ( Treble )
*/
void MainWindow : : toneAdjustTrebleChanged ( double value )
{
m_settings - > toneAdjustTreble ( static_cast < int > ( value * 100.0 ) ) ;
2012-12-04 01:35:48 +01:00
ui - > spinBoxToneAdjustTreble - > setPrefix ( ( value > 0 ) ? " + " : QString ( ) ) ;
2011-01-26 20:16:46 +01:00
}
/*
* 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
{
2012-12-04 01:35:48 +01:00
ui - > spinBoxToneAdjustBass - > setValue ( m_settings - > toneAdjustBassDefault ( ) ) ;
ui - > spinBoxToneAdjustTreble - > setValue ( m_settings - > toneAdjustTrebleDefault ( ) ) ;
toneAdjustBassChanged ( ui - > spinBoxToneAdjustBass - > value ( ) ) ;
toneAdjustTrebleChanged ( ui - > spinBoxToneAdjustTreble - > value ( ) ) ;
2011-01-26 20:16:46 +01:00
}
2011-02-09 23:36:17 +01:00
/*
* Custom encoder parameters changed
*/
void MainWindow : : customParamsChanged ( void )
{
2012-12-04 01:35:48 +01:00
ui - > lineEditCustomParamLAME - > setText ( ui - > lineEditCustomParamLAME - > text ( ) . simplified ( ) ) ;
ui - > lineEditCustomParamOggEnc - > setText ( ui - > lineEditCustomParamOggEnc - > text ( ) . simplified ( ) ) ;
ui - > lineEditCustomParamNeroAAC - > setText ( ui - > lineEditCustomParamNeroAAC - > text ( ) . simplified ( ) ) ;
ui - > lineEditCustomParamFLAC - > setText ( ui - > lineEditCustomParamFLAC - > text ( ) . simplified ( ) ) ;
ui - > lineEditCustomParamAften - > setText ( ui - > lineEditCustomParamAften - > text ( ) . simplified ( ) ) ;
ui - > lineEditCustomParamOpus - > setText ( ui - > lineEditCustomParamOpus - > text ( ) . simplified ( ) ) ;
2011-02-09 23:36:17 +01:00
bool customParamsUsed = false ;
2012-12-04 01:35:48 +01:00
if ( ! ui - > lineEditCustomParamLAME - > text ( ) . isEmpty ( ) ) customParamsUsed = true ;
if ( ! ui - > lineEditCustomParamOggEnc - > text ( ) . isEmpty ( ) ) customParamsUsed = true ;
if ( ! ui - > lineEditCustomParamNeroAAC - > text ( ) . isEmpty ( ) ) customParamsUsed = true ;
if ( ! ui - > lineEditCustomParamFLAC - > text ( ) . isEmpty ( ) ) customParamsUsed = true ;
if ( ! ui - > lineEditCustomParamAften - > text ( ) . isEmpty ( ) ) customParamsUsed = true ;
if ( ! ui - > lineEditCustomParamOpus - > text ( ) . isEmpty ( ) ) customParamsUsed = true ;
2011-02-09 23:36:17 +01:00
2012-12-04 01:35:48 +01:00
ui - > labelCustomParamsIcon - > setVisible ( customParamsUsed ) ;
ui - > labelCustomParamsText - > setVisible ( customParamsUsed ) ;
ui - > labelCustomParamsSpacer - > setVisible ( customParamsUsed ) ;
2011-02-14 19:03:36 +01:00
2013-10-03 17:01:37 +02:00
EncoderRegistry : : saveEncoderCustomParams ( m_settings , SettingsModel : : MP3Encoder , ui - > lineEditCustomParamLAME - > text ( ) ) ;
EncoderRegistry : : saveEncoderCustomParams ( m_settings , SettingsModel : : VorbisEncoder , ui - > lineEditCustomParamOggEnc - > text ( ) ) ;
EncoderRegistry : : saveEncoderCustomParams ( m_settings , SettingsModel : : AACEncoder , ui - > lineEditCustomParamNeroAAC - > text ( ) ) ;
EncoderRegistry : : saveEncoderCustomParams ( m_settings , SettingsModel : : FLACEncoder , ui - > lineEditCustomParamFLAC - > text ( ) ) ;
EncoderRegistry : : saveEncoderCustomParams ( m_settings , SettingsModel : : AC3Encoder , ui - > lineEditCustomParamAften - > text ( ) ) ;
EncoderRegistry : : saveEncoderCustomParams ( m_settings , SettingsModel : : OpusEncoder , ui - > lineEditCustomParamOpus - > 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 )
{
2012-12-04 01:35:48 +01:00
QString temp = ui - > lineEditRenamePattern - > text ( ) . simplified ( ) ;
ui - > lineEditRenamePattern - > setText ( temp . isEmpty ( ) ? m_settings - > renameOutputFilesPatternDefault ( ) : temp ) ;
m_settings - > renameOutputFilesPattern ( ui - > lineEditRenamePattern - > text ( ) ) ;
2011-08-04 23:26:38 +02:00
}
/*
* Rename output files patterm changed
*/
2013-05-02 23:02:02 +02:00
void MainWindow : : renameOutputPatternChanged ( const QString & text , bool silent )
2011-08-04 23:26:38 +02:00
{
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
2014-12-05 21:08:26 +01:00
const QString patternClean = MUtils : : clean_file_name ( pattern ) ;
2013-05-02 23:02:02 +02:00
if ( pattern . compare ( patternClean ) )
2011-08-04 23:26:38 +02:00
{
2012-12-04 01:35:48 +01:00
if ( ui - > lineEditRenamePattern - > palette ( ) . color ( QPalette : : Text ) ! = Qt : : red )
2011-08-04 23:26:38 +02:00
{
2014-12-05 21:08:26 +01:00
if ( ! silent ) MUtils : : Sound : : beep ( MUtils : : Sound : : BEEP_ERR ) ;
2012-12-04 01:35:48 +01:00
SET_TEXT_COLOR ( ui - > lineEditRenamePattern , Qt : : red ) ;
2011-08-04 23:26:38 +02:00
}
}
else
{
2013-05-02 23:02:02 +02:00
if ( ui - > lineEditRenamePattern - > palette ( ) ! = QPalette ( ) )
2011-08-04 23:26:38 +02:00
{
2014-12-05 21:08:26 +01:00
if ( ! silent ) MUtils : : Sound : : beep ( MUtils : : Sound : : BEEP_NFO ) ;
2013-05-02 23:02:02 +02:00
ui - > lineEditRenamePattern - > setPalette ( QPalette ( ) ) ;
2011-08-04 23:26:38 +02:00
}
}
2011-08-05 15:41:19 +02:00
2013-05-02 23:02:02 +02:00
ui - > labelRanameExample - > setText ( patternClean ) ;
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 )
{
2012-12-04 01:35:48 +01:00
ui - > lineEditRenamePattern - > setText ( m_settings - > renameOutputFilesPatternDefault ( ) ) ;
2011-08-05 02:33:32 +02:00
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
{
2013-01-23 23:25:31 +01:00
ui - > labelMaxInstances - > setText ( tr ( " %n Instance(s) " , " " , value ) ) ;
2012-12-04 01:35:48 +01:00
m_settings - > maximumInstances ( ui - > 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
{
2012-12-04 01:35:48 +01:00
m_settings - > maximumInstances ( checked ? NULL : ui - > 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 ;
2014-12-08 22:06:01 +01:00
if ( MUtils : : GUI : : themes_enabled ( ) )
2011-08-23 18:48:16 +02:00
{
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
{
2014-11-25 02:14:42 +01:00
QFile writeTest ( QString ( " %1/~%2.tmp " ) . arg ( newTempFolder , MUtils : : rand_str ( ) ) ) ;
2011-05-21 13:07:17 +02:00
if ( writeTest . open ( QIODevice : : ReadWrite ) )
2010-12-19 21:23:43 +01:00
{
2011-05-21 13:07:17 +02:00
writeTest . remove ( ) ;
2012-12-04 01:35:48 +01:00
ui - > 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
2012-07-29 22:55:02 +02:00
/*
2012-07-30 21:44:44 +02:00
* Help for custom parameters was requested
2012-07-29 22:55:02 +02:00
*/
2012-07-30 21:44:44 +02:00
void MainWindow : : customParamsHelpRequested ( QWidget * obj , QEvent * event )
2012-07-29 22:55:02 +02:00
{
2012-07-30 21:44:44 +02:00
if ( event - > type ( ) ! = QEvent : : MouseButtonRelease )
{
return ;
}
2012-07-29 22:55:02 +02:00
2012-07-30 21:44:44 +02:00
if ( QMouseEvent * mouseEvent = dynamic_cast < QMouseEvent * > ( event ) )
2012-07-29 22:55:02 +02:00
{
2012-07-30 21:44:44 +02:00
QPoint pos = mouseEvent - > pos ( ) ;
if ( ! ( pos . x ( ) < = obj - > width ( ) & & pos . y ( ) < = obj - > height ( ) & & pos . x ( ) > = 0 & & pos . y ( ) > = 0 & & mouseEvent - > button ( ) ! = Qt : : MidButton ) )
{
return ;
}
2012-07-29 22:55:02 +02:00
}
2012-12-04 01:35:48 +01:00
if ( obj = = ui - > helpCustomParamLAME ) showCustomParamsHelpScreen ( " lame.exe " , " --longhelp " ) ;
else if ( obj = = ui - > helpCustomParamOggEnc ) showCustomParamsHelpScreen ( " oggenc2.exe " , " --help " ) ;
else if ( obj = = ui - > helpCustomParamNeroAAC )
2012-07-31 21:03:43 +02:00
{
2013-10-02 19:17:33 +02:00
switch ( EncoderRegistry : : getAacEncoder ( ) )
2013-07-14 19:45:28 +02:00
{
2015-04-24 20:36:05 +02:00
case SettingsModel : : AAC_ENCODER_QAAC : showCustomParamsHelpScreen ( " qaac.exe " , " --help " ) ; break ;
case SettingsModel : : AAC_ENCODER_FHG : showCustomParamsHelpScreen ( " fhgaacenc.exe " , " " ) ; break ;
case SettingsModel : : AAC_ENCODER_FDK : showCustomParamsHelpScreen ( " fdkaac.exe " , " --help " ) ; break ;
case SettingsModel : : AAC_ENCODER_NERO : showCustomParamsHelpScreen ( " neroAacEnc.exe " , " -help " ) ; break ;
2014-12-05 21:08:26 +01:00
default : MUtils : : Sound : : beep ( MUtils : : Sound : : BEEP_ERR ) ; break ;
2013-07-14 19:45:28 +02:00
}
2012-07-31 21:03:43 +02:00
}
2015-04-24 20:36:05 +02:00
else if ( obj = = ui - > helpCustomParamFLAC ) showCustomParamsHelpScreen ( " flac.exe " , " --help " ) ;
else if ( obj = = ui - > helpCustomParamAften ) showCustomParamsHelpScreen ( " aften.exe " , " -h " ) ;
2013-01-14 00:36:54 +01:00
else if ( obj = = ui - > helpCustomParamOpus ) showCustomParamsHelpScreen ( " opusenc.exe " , " --help " ) ;
2014-12-05 21:08:26 +01:00
else MUtils : : Sound : : beep ( MUtils : : Sound : : BEEP_ERR ) ;
2012-07-30 21:44:44 +02:00
}
/*
* Show help for custom parameters
*/
void MainWindow : : showCustomParamsHelpScreen ( const QString & toolName , const QString & command )
{
2014-12-20 23:44:43 +01:00
const QString binary = lamexp_tools_lookup ( toolName ) ;
2012-07-29 22:55:02 +02:00
if ( binary . isEmpty ( ) )
{
2014-12-05 21:08:26 +01:00
MUtils : : Sound : : beep ( MUtils : : Sound : : BEEP_ERR ) ;
2012-07-29 22:55:02 +02:00
qWarning ( " customParamsHelpRequested: Binary could not be found! " ) ;
return ;
}
2013-10-29 02:05:43 +01:00
QProcess process ;
2014-11-25 02:14:42 +01:00
MUtils : : init_process ( process , QFileInfo ( binary ) . absolutePath ( ) ) ;
2013-10-29 02:05:43 +01:00
process . start ( binary , command . isEmpty ( ) ? QStringList ( ) : QStringList ( ) < < command ) ;
2012-07-30 21:44:44 +02:00
qApp - > setOverrideCursor ( QCursor ( Qt : : WaitCursor ) ) ;
2013-10-29 02:05:43 +01:00
if ( process . waitForStarted ( 15000 ) )
2012-07-29 22:55:02 +02:00
{
qApp - > processEvents ( ) ;
2013-10-29 02:05:43 +01:00
process . waitForFinished ( 15000 ) ;
2012-07-29 22:55:02 +02:00
}
2012-07-30 21:44:44 +02:00
2013-10-29 02:05:43 +01:00
if ( process . state ( ) ! = QProcess : : NotRunning )
2012-07-29 22:55:02 +02:00
{
2013-10-29 02:05:43 +01:00
process . kill ( ) ;
process . waitForFinished ( - 1 ) ;
2012-07-29 22:55:02 +02:00
}
2012-07-30 21:44:44 +02:00
qApp - > restoreOverrideCursor ( ) ;
2012-07-29 22:55:02 +02:00
QStringList output ; bool spaceFlag = true ;
2013-10-29 02:05:43 +01:00
while ( process . canReadLine ( ) )
2012-07-29 22:55:02 +02:00
{
2013-10-29 02:05:43 +01:00
QString temp = QString : : fromUtf8 ( process . readLine ( ) ) ;
2012-07-29 22:55:02 +02:00
TRIM_STRING_RIGHT ( temp ) ;
if ( temp . isEmpty ( ) )
{
if ( ! spaceFlag ) { output < < temp ; spaceFlag = true ; }
}
else
{
output < < temp ; spaceFlag = false ;
}
}
if ( output . count ( ) < 1 )
{
2012-07-30 21:44:44 +02:00
qWarning ( " Empty output, cannot show help screen! " ) ;
2014-12-05 21:08:26 +01:00
MUtils : : Sound : : beep ( MUtils : : Sound : : BEEP_ERR ) ;
2012-07-29 22:55:02 +02:00
}
LogViewDialog * dialog = new LogViewDialog ( this ) ;
TEMP_HIDE_DROPBOX ( dialog - > exec ( output ) ; ) ;
2014-11-25 02:14:42 +01:00
MUTILS_DELETE ( dialog ) ;
2012-07-29 22:55:02 +02:00
}
2012-11-08 00:42:55 +01:00
void MainWindow : : overwriteModeChanged ( int id )
{
if ( ( id = = SettingsModel : : Overwrite_Replaces ) & & ( m_settings - > overwriteMode ( ) ! = SettingsModel : : Overwrite_Replaces ) )
{
if ( QMessageBox : : warning ( this , tr ( " Overwrite Mode " ) , tr ( " Warning: This mode may overwrite existing files with no way to revert! " ) , tr ( " Continue " ) , tr ( " Revert " ) , QString ( ) , 1 ) ! = 0 )
{
2012-12-04 01:35:48 +01:00
ui - > radioButtonOverwriteModeKeepBoth - > setChecked ( m_settings - > overwriteMode ( ) = = SettingsModel : : Overwrite_KeepBoth ) ;
ui - > radioButtonOverwriteModeSkipFile - > setChecked ( m_settings - > overwriteMode ( ) = = SettingsModel : : Overwrite_SkipFile ) ;
2012-11-08 00:42:55 +01:00
return ;
}
}
m_settings - > overwriteMode ( id ) ;
}
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
{
2013-12-03 22:19:11 +01:00
PLAY_SOUND_OPTIONAL ( " blast " , true ) ;
2013-07-14 18:14:26 +02:00
2015-03-21 19:06:55 +01:00
ui - > sliderLameAlgoQuality - > setValue ( m_settings - > lameAlgoQualityDefault ( ) ) ;
ui - > spinBoxBitrateManagementMin - > setValue ( m_settings - > bitrateManagementMinRateDefault ( ) ) ;
ui - > spinBoxBitrateManagementMax - > setValue ( m_settings - > bitrateManagementMaxRateDefault ( ) ) ;
ui - > spinBoxNormalizationFilterPeak - > setValue ( static_cast < double > ( m_settings - > normalizationFilterMaxVolumeDefault ( ) ) / 100.0 ) ;
ui - > spinBoxNormalizationFilterSize - > setValue ( m_settings - > normalizationFilterSizeDefault ( ) ) ;
ui - > spinBoxToneAdjustBass - > setValue ( static_cast < double > ( m_settings - > toneAdjustBassDefault ( ) ) / 100.0 ) ;
ui - > spinBoxToneAdjustTreble - > setValue ( static_cast < double > ( m_settings - > toneAdjustTrebleDefault ( ) ) / 100.0 ) ;
ui - > spinBoxAftenSearchSize - > setValue ( m_settings - > aftenExponentSearchSizeDefault ( ) ) ;
ui - > spinBoxOpusComplexity - > setValue ( m_settings - > opusComplexityDefault ( ) ) ;
ui - > comboBoxMP3ChannelMode - > setCurrentIndex ( m_settings - > lameChannelModeDefault ( ) ) ;
ui - > comboBoxSamplingRate - > setCurrentIndex ( m_settings - > samplingRateDefault ( ) ) ;
ui - > comboBoxAACProfile - > setCurrentIndex ( m_settings - > aacEncProfileDefault ( ) ) ;
ui - > comboBoxAftenCodingMode - > setCurrentIndex ( m_settings - > aftenAudioCodingModeDefault ( ) ) ;
ui - > comboBoxAftenDRCMode - > setCurrentIndex ( m_settings - > aftenDynamicRangeCompressionDefault ( ) ) ;
ui - > comboBoxOpusFramesize - > setCurrentIndex ( m_settings - > opusFramesizeDefault ( ) ) ;
SET_CHECKBOX_STATE ( ui - > checkBoxBitrateManagement , m_settings - > bitrateManagementEnabledDefault ( ) ) ;
SET_CHECKBOX_STATE ( ui - > checkBoxNeroAAC2PassMode , m_settings - > neroAACEnable2PassDefault ( ) ) ;
SET_CHECKBOX_STATE ( ui - > checkBoxNormalizationFilterEnabled , m_settings - > normalizationFilterEnabledDefault ( ) ) ;
SET_CHECKBOX_STATE ( ui - > checkBoxNormalizationFilterDynamic , m_settings - > normalizationFilterDynamicDefault ( ) ) ;
SET_CHECKBOX_STATE ( ui - > checkBoxNormalizationFilterCoupled , m_settings - > normalizationFilterCoupledDefault ( ) ) ;
SET_CHECKBOX_STATE ( ui - > checkBoxAutoDetectInstances , ( m_settings - > maximumInstancesDefault ( ) < 1 ) ) ;
SET_CHECKBOX_STATE ( ui - > checkBoxUseSystemTempFolder , ( ! m_settings - > customTempPathEnabledDefault ( ) ) ) ;
SET_CHECKBOX_STATE ( ui - > checkBoxAftenFastAllocation , m_settings - > aftenFastBitAllocationDefault ( ) ) ;
SET_CHECKBOX_STATE ( ui - > checkBoxRenameOutput , m_settings - > renameOutputFilesEnabledDefault ( ) ) ;
SET_CHECKBOX_STATE ( ui - > checkBoxForceStereoDownmix , m_settings - > forceStereoDownmixDefault ( ) ) ;
SET_CHECKBOX_STATE ( ui - > checkBoxOpusDisableResample , m_settings - > opusDisableResampleDefault ( ) ) ;
2013-10-03 17:01:37 +02:00
ui - > lineEditCustomParamLAME - > setText ( m_settings - > customParametersLAMEDefault ( ) ) ;
ui - > lineEditCustomParamOggEnc - > setText ( m_settings - > customParametersOggEncDefault ( ) ) ;
2012-12-04 01:35:48 +01:00
ui - > lineEditCustomParamNeroAAC - > setText ( m_settings - > customParametersAacEncDefault ( ) ) ;
2013-10-03 17:01:37 +02:00
ui - > lineEditCustomParamFLAC - > setText ( m_settings - > customParametersFLACDefault ( ) ) ;
ui - > lineEditCustomParamOpus - > setText ( m_settings - > customParametersOpusEncDefault ( ) ) ;
ui - > lineEditCustomTempFolder - > setText ( QDir : : toNativeSeparators ( m_settings - > customTempPathDefault ( ) ) ) ;
ui - > lineEditRenamePattern - > setText ( m_settings - > renameOutputFilesPatternDefault ( ) ) ;
2013-07-14 18:14:26 +02:00
2012-12-04 01:35:48 +01:00
if ( m_settings - > overwriteModeDefault ( ) = = SettingsModel : : Overwrite_KeepBoth ) ui - > radioButtonOverwriteModeKeepBoth - > click ( ) ;
if ( m_settings - > overwriteModeDefault ( ) = = SettingsModel : : Overwrite_SkipFile ) ui - > radioButtonOverwriteModeSkipFile - > click ( ) ;
if ( m_settings - > overwriteModeDefault ( ) = = SettingsModel : : Overwrite_Replaces ) ui - > radioButtonOverwriteModeReplaces - > click ( ) ;
2013-07-14 18:14:26 +02:00
2011-05-21 13:07:17 +02:00
customParamsChanged ( ) ;
2012-12-04 01:35:48 +01:00
ui - > 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
{
2013-11-26 23:01:37 +01:00
if ( ! ( BANNER_VISIBLE ) )
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 ( ) )
{
2014-11-25 02:14:42 +01:00
qDebug ( " Received file: %s " , MUTILS_UTF8 ( filePath ) ) ;
2011-06-11 17:18:30 +02:00
m_delayedFileList - > append ( filePath ) ;
QTimer : : singleShot ( 0 , this , SLOT ( handleDelayedFiles ( ) ) ) ;
}
2011-05-21 13:07:17 +02:00
m_delayedFileTimer - > stop ( ) ;
2014-11-25 02:14:42 +01:00
qDebug ( " Received file: %s " , MUTILS_UTF8 ( filePath ) ) ;
2011-05-21 13:07:17 +02:00
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 )
{
2013-11-29 01:20:59 +01:00
if ( tryASAP & & ( ! m_delayedFileTimer - > isActive ( ) ) )
2011-06-11 17:18:30 +02:00
{
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 )
{
2013-11-26 23:01:37 +01:00
if ( ! ( BANNER_VISIBLE ) )
2011-06-11 17:18:30 +02:00
{
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
}