///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
-// Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2013 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
+// (at your option) any later version, but always including the *additional*
+// restrictions defined in the "License.txt" file.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "Dialog_MainWindow.h"
+//UIC includes
+#include "../tmp/UIC_MainWindow.h"
+
//LameXP includes
#include "Global.h"
#include "Resource.h"
#include "Dialog_Update.h"
#include "Dialog_DropBox.h"
#include "Dialog_CueImport.h"
+#include "Dialog_LogView.h"
#include "Thread_FileAnalyzer.h"
#include "Thread_MessageHandler.h"
#include "Model_MetaInfo.h"
#include "Model_FileList.h"
#include "Model_FileSystem.h"
#include "WinSevenTaskbar.h"
+#include "Registry_Encoder.h"
#include "Registry_Decoder.h"
+#include "Encoder_Abstract.h"
#include "ShellIntegration.h"
+#include "CustomEventFilter.h"
//Qt includes
#include <QMessageBox>
#include <QWindowsStyle>
#include <QSysInfo>
#include <QDragEnterEvent>
-#include <QWindowsMime>
+#include <QMimeData>
#include <QProcess>
#include <QUuid>
#include <QProcessEnvironment>
#include <QResource>
#include <QScrollBar>
-//System includes
-#include <MMSystem.h>
-#include <ShellAPI.h>
+////////////////////////////////////////////////////////////
+// Helper macros
+////////////////////////////////////////////////////////////
+
+#define ABORT_IF_BUSY do \
+{ \
+ if(m_banner->isVisible() || m_delayedFileTimer->isActive()) \
+ { \
+ lamexp_beep(lamexp_beep_warning); \
+ 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); \
+ LAMEXP_DELETE(_tmp); \
+} \
+while(0)
+
+#define SET_CHECKBOX_STATE(CHCKBX, STATE) do \
+{ \
+ if((CHCKBX)->isChecked() != (STATE)) \
+ { \
+ (CHCKBX)->click(); \
+ } \
+ if((CHCKBX)->isChecked() != (STATE)) \
+ { \
+ qWarning("Warning: Failed to set checkbox " #CHCKBX " state!"); \
+ } \
+} \
+while(0)
+
+#define TRIM_STRING_RIGHT(STR) do \
+{ \
+ while((STR.length() > 0) && STR[STR.length()-1].isSpace()) STR.chop(1); \
+} \
+while(0)
+
+#define MAKE_TRANSPARENT(WIDGET, FLAG) do \
+{ \
+ QPalette _p = (WIDGET)->palette(); \
+ _p.setColor(QPalette::Background, Qt::transparent); \
+ (WIDGET)->setPalette(FLAG ? _p : QPalette()); \
+} \
+while(0)
+
+#define WITH_BLOCKED_SIGNALS(WIDGET, CMD, ...) do \
+{ \
+ const bool _flag = (WIDGET)->blockSignals(true); \
+ (WIDGET)->CMD(__VA_ARGS__); \
+ if(!(_flag)) { (WIDGET)->blockSignals(false); } \
+} \
+while(0)
-//Helper macros
-#define ABORT_IF_BUSY if(m_banner->isVisible() || m_delayedFileTimer->isActive()) { MessageBeep(MB_ICONEXCLAMATION); return; }
-#define SET_TEXT_COLOR(WIDGET,COLOR) { QPalette _palette = WIDGET->palette(); _palette.setColor(QPalette::WindowText, (COLOR)); _palette.setColor(QPalette::Text, (COLOR)); WIDGET->setPalette(_palette); }
-#define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); }
#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("-", "−"))
-#define TEMP_HIDE_DROPBOX(CMD) { bool __dropBoxVisible = m_dropBox->isVisible(); if(__dropBoxVisible) m_dropBox->hide(); {CMD}; if(__dropBoxVisible) m_dropBox->show(); }
-#define USE_NATIVE_FILE_DIALOG (lamexp_themes_enabled() || ((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) < QSysInfo::WV_XP))
+//#define USE_NATIVE_FILE_DIALOG (lamexp_themes_enabled() || ((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) < QSysInfo::WV_XP))
+#define CENTER_CURRENT_OUTPUT_FOLDER_DELAYED QTimer::singleShot(125, this, SLOT(centerOutputFolderModel()))
+
+static const unsigned int IDM_ABOUTBOX = 0xEFF0;
////////////////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////////////////
-MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, SettingsModel *settingsModel, QWidget *parent)
+MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel_MetaInfo *metaInfo, SettingsModel *settingsModel, QWidget *parent)
:
QMainWindow(parent),
+ ui(new Ui::MainWindow),
m_fileListModel(fileListModel),
m_metaData(metaInfo),
m_settings(settingsModel),
- m_neroEncoderAvailable(lamexp_check_tool("neroAacEnc.exe") && lamexp_check_tool("neroAacDec.exe") && lamexp_check_tool("neroAacTag.exe")),
- m_fhgEncoderAvailable(lamexp_check_tool("fhgaacenc.exe") && lamexp_check_tool("enc_fhgaac.dll") && lamexp_check_tool("nsutil.dll") && lamexp_check_tool("libmp4v2.dll")),
- m_qaacEncoderAvailable(lamexp_check_tool("qaac.exe") && lamexp_check_tool("libsoxrate.dll")),
+ m_fileSystemModel(NULL),
m_accepted(false),
m_firstTimeShown(true),
- m_OutputFolderViewInitialized(false)
+ m_outputFolderViewCentering(false),
+ m_outputFolderViewInitCounter(0)
{
//Init the dialog, from the .ui file
- setupUi(this);
+ ui->setupUi(this);
setWindowFlags(windowFlags() ^ Qt::WindowMaximizeButtonHint);
//Register meta types
qRegisterMetaType<AudioFileModel>("AudioFileModel");
//Enabled main buttons
- connect(buttonAbout, SIGNAL(clicked()), this, SLOT(aboutButtonClicked()));
- connect(buttonStart, SIGNAL(clicked()), this, SLOT(encodeButtonClicked()));
- connect(buttonQuit, SIGNAL(clicked()), this, SLOT(closeButtonClicked()));
+ connect(ui->buttonAbout, SIGNAL(clicked()), this, SLOT(aboutButtonClicked()));
+ connect(ui->buttonStart, SIGNAL(clicked()), this, SLOT(encodeButtonClicked()));
+ connect(ui->buttonQuit, SIGNAL(clicked()), this, SLOT(closeButtonClicked()));
//Setup tab widget
- tabWidget->setCurrentIndex(0);
- connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabPageChanged(int)));
-
- //Setup "Source" tab
- sourceFileView->setModel(m_fileListModel);
- sourceFileView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
- sourceFileView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
- sourceFileView->setContextMenuPolicy(Qt::CustomContextMenu);
- sourceFileView->viewport()->installEventFilter(this);
- m_dropNoteLabel = new QLabel(sourceFileView);
+ ui->tabWidget->setCurrentIndex(0);
+ connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabPageChanged(int)));
+
+ //Add system menu
+ lamexp_append_sysmenu(this, IDM_ABOUTBOX, "About...");
+
+ //--------------------------------
+ // Setup "Source" tab
+ //--------------------------------
+
+ 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);
m_dropNoteLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
SET_FONT_BOLD(m_dropNoteLabel, true);
SET_TEXT_COLOR(m_dropNoteLabel, Qt::darkGray);
m_exportCsvContextAction = m_sourceFilesContextMenu->addAction(QIcon(":/icons/table_save.png"), "N/A");
m_importCsvContextAction = m_sourceFilesContextMenu->addAction(QIcon(":/icons/folder_table.png"), "N/A");
SET_FONT_BOLD(m_showDetailsContextAction, true);
- connect(buttonAddFiles, SIGNAL(clicked()), this, SLOT(addFilesButtonClicked()));
- connect(buttonRemoveFile, SIGNAL(clicked()), this, SLOT(removeFileButtonClicked()));
- connect(buttonClearFiles, SIGNAL(clicked()), this, SLOT(clearFilesButtonClicked()));
- connect(buttonFileUp, SIGNAL(clicked()), this, SLOT(fileUpButtonClicked()));
- connect(buttonFileDown, SIGNAL(clicked()), this, SLOT(fileDownButtonClicked()));
- connect(buttonShowDetails, SIGNAL(clicked()), this, SLOT(showDetailsButtonClicked()));
+ 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(sourceFileView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(sourceFilesContextMenu(QPoint)));
- connect(sourceFileView->verticalScrollBar(), SIGNAL(sliderMoved(int)), this, SLOT(sourceFilesScrollbarMoved(int)));
- connect(sourceFileView->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(sourceFilesScrollbarMoved(int)));
+ 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()));
+
+ //--------------------------------
+ // Setup "Output" tab
+ //--------------------------------
+
+ ui->outputFolderView->setHeaderHidden(true);
+ ui->outputFolderView->setAnimated(false);
+ ui->outputFolderView->setMouseTracking(false);
+ ui->outputFolderView->setContextMenuPolicy(Qt::CustomContextMenu);
+ ui->outputFolderView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
+
+ m_evenFilterOutputFolderMouse = new CustomEventFilter;
+ ui->outputFoldersGoUpLabel->installEventFilter(m_evenFilterOutputFolderMouse);
+ ui->outputFoldersEditorLabel->installEventFilter(m_evenFilterOutputFolderMouse);
+ ui->outputFoldersFovoritesLabel->installEventFilter(m_evenFilterOutputFolderMouse);
+ ui->outputFolderLabel->installEventFilter(m_evenFilterOutputFolderMouse);
+
+ m_evenFilterOutputFolderView = new CustomEventFilter;
+ ui->outputFolderView->installEventFilter(m_evenFilterOutputFolderView);
+
+ SET_CHECKBOX_STATE(ui->saveToSourceFolderCheckBox, m_settings->outputToSourceDir());
+ ui->prependRelativePathCheckBox->setChecked(m_settings->prependRelativeSourcePath());
+ 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()));
+ connect(m_evenFilterOutputFolderMouse, SIGNAL(eventOccurred(QWidget*, QEvent*)), this, SLOT(outputFolderMouseEventOccurred(QWidget*, QEvent*)));
+ connect(m_evenFilterOutputFolderView, SIGNAL(eventOccurred(QWidget*, QEvent*)), this, SLOT(outputFolderViewEventOccurred(QWidget*, QEvent*)));
+
+ if(m_outputFolderContextMenu = new QMenu())
+ {
+ m_showFolderContextAction = m_outputFolderContextMenu->addAction(QIcon(":/icons/zoom.png"), "N/A");
+ m_goUpFolderContextAction = m_outputFolderContextMenu->addAction(QIcon(":/icons/folder_up.png"), "N/A");
+ m_outputFolderContextMenu->addSeparator();
+ m_refreshFolderContextAction = m_outputFolderContextMenu->addAction(QIcon(":/icons/arrow_refresh.png"), "N/A");
+ m_outputFolderContextMenu->setDefaultAction(m_showFolderContextAction);
+ connect(ui->outputFolderView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(outputFolderContextMenu(QPoint)));
+ connect(m_showFolderContextAction, SIGNAL(triggered(bool)), this, SLOT(showFolderContextActionTriggered()));
+ connect(m_refreshFolderContextAction, SIGNAL(triggered(bool)), this, SLOT(refreshFolderContextActionTriggered()));
+ connect(m_goUpFolderContextAction, SIGNAL(triggered(bool)), this, SLOT(goUpFolderContextActionTriggered()));
+ }
+
+ 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()));
+ }
- //Setup "Output" tab
- m_fileSystemModel = new QFileSystemModelEx();
- m_fileSystemModel->installEventFilter(this);
- outputFolderView->setModel(m_fileSystemModel);
- outputFolderView->header()->setStretchLastSection(true);
- outputFolderView->header()->hideSection(1);
- outputFolderView->header()->hideSection(2);
- outputFolderView->header()->hideSection(3);
- outputFolderView->setHeaderHidden(true);
- outputFolderView->setAnimated(false);
- outputFolderView->setMouseTracking(false);
- outputFolderView->setContextMenuPolicy(Qt::CustomContextMenu);
- outputFolderView->installEventFilter(this);
- outputFoldersFovoritesLabel->installEventFilter(this);
- while(saveToSourceFolderCheckBox->isChecked() != m_settings->outputToSourceDir()) saveToSourceFolderCheckBox->click();
- prependRelativePathCheckBox->setChecked(m_settings->prependRelativeSourcePath());
- connect(outputFolderView, SIGNAL(clicked(QModelIndex)), this, SLOT(outputFolderViewClicked(QModelIndex)));
- connect(outputFolderView, SIGNAL(activated(QModelIndex)), this, SLOT(outputFolderViewClicked(QModelIndex)));
- connect(outputFolderView, SIGNAL(pressed(QModelIndex)), this, SLOT(outputFolderViewClicked(QModelIndex)));
- connect(outputFolderView, SIGNAL(entered(QModelIndex)), this, SLOT(outputFolderViewMoved(QModelIndex)));
- connect(buttonMakeFolder, SIGNAL(clicked()), this, SLOT(makeFolderButtonClicked()));
- connect(buttonGotoHome, SIGNAL(clicked()), SLOT(gotoHomeFolderButtonClicked()));
- connect(buttonGotoDesktop, SIGNAL(clicked()), this, SLOT(gotoDesktopButtonClicked()));
- connect(buttonGotoMusic, SIGNAL(clicked()), this, SLOT(gotoMusicFolderButtonClicked()));
- connect(saveToSourceFolderCheckBox, SIGNAL(clicked()), this, SLOT(saveToSourceFolderChanged()));
- connect(prependRelativePathCheckBox, SIGNAL(clicked()), this, SLOT(prependRelativePathChanged()));
- m_outputFolderContextMenu = new QMenu();
- m_showFolderContextAction = m_outputFolderContextMenu->addAction(QIcon(":/icons/zoom.png"), "N/A");
- m_outputFolderFavoritesMenu = new QMenu();
- m_addFavoriteFolderAction = m_outputFolderFavoritesMenu->addAction(QIcon(":/icons/add.png"), "N/A");
- m_outputFolderFavoritesMenu->insertSeparator(m_addFavoriteFolderAction);
- connect(outputFolderView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(outputFolderContextMenu(QPoint)));
- connect(m_showFolderContextAction, SIGNAL(triggered(bool)), this, SLOT(showFolderContextActionTriggered()));
- connect(m_addFavoriteFolderAction, SIGNAL(triggered(bool)), this, SLOT(addFavoriteFolderActionTriggered()));
- outputFolderLabel->installEventFilter(this);
- outputFolderView->setCurrentIndex(m_fileSystemModel->index(m_settings->outputDir()));
- outputFolderViewClicked(outputFolderView->currentIndex());
+ ui->outputFolderEdit->setVisible(false);
+ if(m_outputFolderNoteBox = new QLabel(ui->outputFolderView))
+ {
+ m_outputFolderNoteBox->setAutoFillBackground(true);
+ m_outputFolderNoteBox->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
+ m_outputFolderNoteBox->setFrameShape(QFrame::StyledPanel);
+ SET_FONT_BOLD(m_outputFolderNoteBox, true);
+ m_outputFolderNoteBox->hide();
+
+ }
+
+ outputFolderViewClicked(QModelIndex());
refreshFavorites();
- //Setup "Meta Data" tab
- m_metaInfoModel = new MetaInfoModel(m_metaData, 6);
+ //--------------------------------
+ // Setup "Meta Data" tab
+ //--------------------------------
+
+ m_metaInfoModel = new MetaInfoModel(m_metaData);
m_metaInfoModel->clearData();
m_metaInfoModel->setData(m_metaInfoModel->index(4, 1), m_settings->metaInfoPosition());
- metaDataView->setModel(m_metaInfoModel);
- metaDataView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
- metaDataView->verticalHeader()->hide();
- metaDataView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
- while(writeMetaDataCheckBox->isChecked() != m_settings->writeMetaTags()) writeMetaDataCheckBox->click();
- generatePlaylistCheckBox->setChecked(m_settings->createPlaylist());
- connect(buttonEditMeta, SIGNAL(clicked()), this, SLOT(editMetaButtonClicked()));
- connect(buttonClearMeta, SIGNAL(clicked()), this, SLOT(clearMetaButtonClicked()));
- connect(writeMetaDataCheckBox, SIGNAL(clicked()), this, SLOT(metaTagsEnabledChanged()));
- connect(generatePlaylistCheckBox, SIGNAL(clicked()), this, SLOT(playlistEnabledChanged()));
-
+ 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()));
+
+ //--------------------------------
//Setup "Compression" tab
+ //--------------------------------
+
m_encoderButtonGroup = new QButtonGroup(this);
- m_encoderButtonGroup->addButton(radioButtonEncoderMP3, SettingsModel::MP3Encoder);
- m_encoderButtonGroup->addButton(radioButtonEncoderVorbis, SettingsModel::VorbisEncoder);
- m_encoderButtonGroup->addButton(radioButtonEncoderAAC, SettingsModel::AACEncoder);
- m_encoderButtonGroup->addButton(radioButtonEncoderAC3, SettingsModel::AC3Encoder);
- m_encoderButtonGroup->addButton(radioButtonEncoderFLAC, SettingsModel::FLACEncoder);
- m_encoderButtonGroup->addButton(radioButtonEncoderDCA, SettingsModel::DCAEncoder);
- m_encoderButtonGroup->addButton(radioButtonEncoderPCM, SettingsModel::PCMEncoder);
+ 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);
+ m_encoderButtonGroup->addButton(ui->radioButtonEncoderOpus, SettingsModel::OpusEncoder);
+ m_encoderButtonGroup->addButton(ui->radioButtonEncoderDCA, SettingsModel::DCAEncoder);
+ m_encoderButtonGroup->addButton(ui->radioButtonEncoderPCM, SettingsModel::PCMEncoder);
+
+ const int aacEncoder = EncoderRegistry::getAacEncoder();
+ ui->radioButtonEncoderAAC->setEnabled(aacEncoder > SettingsModel::AAC_ENCODER_NONE);
+
m_modeButtonGroup = new QButtonGroup(this);
- m_modeButtonGroup->addButton(radioButtonModeQuality, SettingsModel::VBRMode);
- m_modeButtonGroup->addButton(radioButtonModeAverageBitrate, SettingsModel::ABRMode);
- m_modeButtonGroup->addButton(radioButtonConstBitrate, SettingsModel::CBRMode);
- radioButtonEncoderAAC->setEnabled(m_neroEncoderAvailable || m_fhgEncoderAvailable || m_qaacEncoderAvailable);
- radioButtonEncoderMP3->setChecked(m_settings->compressionEncoder() == SettingsModel::MP3Encoder);
- radioButtonEncoderVorbis->setChecked(m_settings->compressionEncoder() == SettingsModel::VorbisEncoder);
- radioButtonEncoderAAC->setChecked((m_settings->compressionEncoder() == SettingsModel::AACEncoder) && (m_neroEncoderAvailable || m_fhgEncoderAvailable || m_qaacEncoderAvailable));
- radioButtonEncoderAC3->setChecked(m_settings->compressionEncoder() == SettingsModel::AC3Encoder);
- radioButtonEncoderFLAC->setChecked(m_settings->compressionEncoder() == SettingsModel::FLACEncoder);
- radioButtonEncoderDCA->setChecked(m_settings->compressionEncoder() == SettingsModel::DCAEncoder);
- radioButtonEncoderPCM->setChecked(m_settings->compressionEncoder() == SettingsModel::PCMEncoder);
- radioButtonModeQuality->setChecked(m_settings->compressionRCMode() == SettingsModel::VBRMode);
- radioButtonModeAverageBitrate->setChecked(m_settings->compressionRCMode() == SettingsModel::ABRMode);
- radioButtonConstBitrate->setChecked(m_settings->compressionRCMode() == SettingsModel::CBRMode);
- sliderBitrate->setValue(m_settings->compressionBitrate());
+ m_modeButtonGroup->addButton(ui->radioButtonModeQuality, SettingsModel::VBRMode);
+ m_modeButtonGroup->addButton(ui->radioButtonModeAverageBitrate, SettingsModel::ABRMode);
+ m_modeButtonGroup->addButton(ui->radioButtonConstBitrate, SettingsModel::CBRMode);
+
+ ui->radioButtonEncoderMP3->setChecked(true);
+ foreach(QAbstractButton *currentButton, m_encoderButtonGroup->buttons())
+ {
+ if(currentButton->isEnabled() && (m_encoderButtonGroup->id(currentButton) == m_settings->compressionEncoder()))
+ {
+ currentButton->setChecked(true);
+ break;
+ }
+ }
+
+ m_evenFilterCompressionTab = new CustomEventFilter();
+ ui->labelCompressionHelp->installEventFilter(m_evenFilterCompressionTab);
+ ui->labelResetEncoders ->installEventFilter(m_evenFilterCompressionTab);
+
connect(m_encoderButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(updateEncoder(int)));
connect(m_modeButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(updateRCMode(int)));
- connect(sliderBitrate, SIGNAL(valueChanged(int)), this, SLOT(updateBitrate(int)));
+ connect(m_evenFilterCompressionTab, SIGNAL(eventOccurred(QWidget*, QEvent*)), this, SLOT(compressionTabEventOccurred(QWidget*, QEvent*)));
+ connect(ui->sliderBitrate, SIGNAL(valueChanged(int)), this, SLOT(updateBitrate(int)));
+
updateEncoder(m_encoderButtonGroup->checkedId());
+ //--------------------------------
//Setup "Advanced Options" tab
- sliderLameAlgoQuality->setValue(m_settings->lameAlgoQuality());
- if(m_settings->maximumInstances() > 0) sliderMaxInstances->setValue(m_settings->maximumInstances());
- spinBoxBitrateManagementMin->setValue(m_settings->bitrateManagementMinRate());
- spinBoxBitrateManagementMax->setValue(m_settings->bitrateManagementMaxRate());
- spinBoxNormalizationFilter->setValue(static_cast<double>(m_settings->normalizationFilterMaxVolume()) / 100.0);
- spinBoxToneAdjustBass->setValue(static_cast<double>(m_settings->toneAdjustBass()) / 100.0);
- spinBoxToneAdjustTreble->setValue(static_cast<double>(m_settings->toneAdjustTreble()) / 100.0);
- spinBoxAftenSearchSize->setValue(m_settings->aftenExponentSearchSize());
- comboBoxMP3ChannelMode->setCurrentIndex(m_settings->lameChannelMode());
- comboBoxSamplingRate->setCurrentIndex(m_settings->samplingRate());
- comboBoxAACProfile->setCurrentIndex(m_settings->aacEncProfile());
- comboBoxAftenCodingMode->setCurrentIndex(m_settings->aftenAudioCodingMode());
- comboBoxAftenDRCMode->setCurrentIndex(m_settings->aftenDynamicRangeCompression());
- comboBoxNormalizationMode->setCurrentIndex(m_settings->normalizationFilterEqualizationMode());
- while(checkBoxBitrateManagement->isChecked() != m_settings->bitrateManagementEnabled()) checkBoxBitrateManagement->click();
- while(checkBoxNeroAAC2PassMode->isChecked() != m_settings->neroAACEnable2Pass()) checkBoxNeroAAC2PassMode->click();
- while(checkBoxAftenFastAllocation->isChecked() != m_settings->aftenFastBitAllocation()) checkBoxAftenFastAllocation->click();
- while(checkBoxNormalizationFilter->isChecked() != m_settings->normalizationFilterEnabled()) checkBoxNormalizationFilter->click();
- while(checkBoxAutoDetectInstances->isChecked() != (m_settings->maximumInstances() < 1)) checkBoxAutoDetectInstances->click();
- while(checkBoxUseSystemTempFolder->isChecked() == m_settings->customTempPathEnabled()) checkBoxUseSystemTempFolder->click();
- while(checkBoxRenameOutput->isChecked() != m_settings->renameOutputFilesEnabled()) checkBoxRenameOutput->click();
- while(checkBoxForceStereoDownmix->isChecked() != m_settings->forceStereoDownmix()) checkBoxForceStereoDownmix->click();
- checkBoxNeroAAC2PassMode->setEnabled(!(m_fhgEncoderAvailable || m_qaacEncoderAvailable));
- lineEditCustomParamLAME->setText(m_settings->customParametersLAME());
- lineEditCustomParamOggEnc->setText(m_settings->customParametersOggEnc());
- lineEditCustomParamNeroAAC->setText(m_settings->customParametersAacEnc());
- lineEditCustomParamFLAC->setText(m_settings->customParametersFLAC());
- lineEditCustomParamAften->setText(m_settings->customParametersAften());
- lineEditCustomTempFolder->setText(QDir::toNativeSeparators(m_settings->customTempPath()));
- lineEditRenamePattern->setText(m_settings->renameOutputFilesPattern());
- connect(sliderLameAlgoQuality, SIGNAL(valueChanged(int)), this, SLOT(updateLameAlgoQuality(int)));
- connect(checkBoxBitrateManagement, SIGNAL(clicked(bool)), this, SLOT(bitrateManagementEnabledChanged(bool)));
- connect(spinBoxBitrateManagementMin, SIGNAL(valueChanged(int)), this, SLOT(bitrateManagementMinChanged(int)));
- connect(spinBoxBitrateManagementMax, SIGNAL(valueChanged(int)), this, SLOT(bitrateManagementMaxChanged(int)));
- connect(comboBoxMP3ChannelMode, SIGNAL(currentIndexChanged(int)), this, SLOT(channelModeChanged(int)));
- connect(comboBoxSamplingRate, SIGNAL(currentIndexChanged(int)), this, SLOT(samplingRateChanged(int)));
- connect(checkBoxNeroAAC2PassMode, SIGNAL(clicked(bool)), this, SLOT(neroAAC2PassChanged(bool)));
- connect(comboBoxAACProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(neroAACProfileChanged(int)));
- connect(checkBoxNormalizationFilter, SIGNAL(clicked(bool)), this, SLOT(normalizationEnabledChanged(bool)));
- connect(comboBoxAftenCodingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(aftenCodingModeChanged(int)));
- connect(comboBoxAftenDRCMode, SIGNAL(currentIndexChanged(int)), this, SLOT(aftenDRCModeChanged(int)));
- connect(spinBoxAftenSearchSize, SIGNAL(valueChanged(int)), this, SLOT(aftenSearchSizeChanged(int)));
- connect(checkBoxAftenFastAllocation, SIGNAL(clicked(bool)), this, SLOT(aftenFastAllocationChanged(bool)));
- connect(spinBoxNormalizationFilter, SIGNAL(valueChanged(double)), this, SLOT(normalizationMaxVolumeChanged(double)));
- connect(comboBoxNormalizationMode, SIGNAL(currentIndexChanged(int)), this, SLOT(normalizationModeChanged(int)));
- connect(spinBoxToneAdjustBass, SIGNAL(valueChanged(double)), this, SLOT(toneAdjustBassChanged(double)));
- connect(spinBoxToneAdjustTreble, SIGNAL(valueChanged(double)), this, SLOT(toneAdjustTrebleChanged(double)));
- connect(buttonToneAdjustReset, SIGNAL(clicked()), this, SLOT(toneAdjustTrebleReset()));
- connect(lineEditCustomParamLAME, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
- connect(lineEditCustomParamOggEnc, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
- connect(lineEditCustomParamNeroAAC, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
- connect(lineEditCustomParamFLAC, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
- connect(lineEditCustomParamAften, SIGNAL(editingFinished()), this, SLOT(customParamsChanged()));
- connect(sliderMaxInstances, SIGNAL(valueChanged(int)), this, SLOT(updateMaximumInstances(int)));
- connect(checkBoxAutoDetectInstances, SIGNAL(clicked(bool)), this, SLOT(autoDetectInstancesChanged(bool)));
- connect(buttonBrowseCustomTempFolder, SIGNAL(clicked()), this, SLOT(browseCustomTempFolderButtonClicked()));
- connect(lineEditCustomTempFolder, SIGNAL(textChanged(QString)), this, SLOT(customTempFolderChanged(QString)));
- connect(checkBoxUseSystemTempFolder, SIGNAL(clicked(bool)), this, SLOT(useCustomTempFolderChanged(bool)));
- connect(buttonResetAdvancedOptions, SIGNAL(clicked()), this, SLOT(resetAdvancedOptionsButtonClicked()));
- connect(checkBoxRenameOutput, SIGNAL(clicked(bool)), this, SLOT(renameOutputEnabledChanged(bool)));
- connect(lineEditRenamePattern, SIGNAL(editingFinished()), this, SLOT(renameOutputPatternChanged()));
- connect(lineEditRenamePattern, SIGNAL(textChanged(QString)), this, SLOT(renameOutputPatternChanged(QString)));
- connect(labelShowRenameMacros, SIGNAL(linkActivated(QString)), this, SLOT(showRenameMacros(QString)));
- connect(checkBoxForceStereoDownmix, SIGNAL(clicked(bool)), this, SLOT(forceStereoDownmixEnabledChanged(bool)));
- updateLameAlgoQuality(sliderLameAlgoQuality->value());
- updateMaximumInstances(sliderMaxInstances->value());
- toneAdjustTrebleChanged(spinBoxToneAdjustTreble->value());
- toneAdjustBassChanged(spinBoxToneAdjustBass->value());
+ //--------------------------------
+
+ ui->sliderLameAlgoQuality->setValue(m_settings->lameAlgoQuality());
+ if(m_settings->maximumInstances() > 0) ui->sliderMaxInstances->setValue(m_settings->maximumInstances());
+
+ ui->spinBoxBitrateManagementMin->setValue(m_settings->bitrateManagementMinRate());
+ ui->spinBoxBitrateManagementMax->setValue(m_settings->bitrateManagementMaxRate());
+ ui->spinBoxNormalizationFilter->setValue(static_cast<double>(m_settings->normalizationFilterMaxVolume()) / 100.0);
+ 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());
+
+ 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->comboBoxNormalizationMode->setCurrentIndex(m_settings->normalizationFilterEQMode());
+ //comboBoxOpusOptimize->setCurrentIndex(m_settings->opusOptimizeFor());
+ ui->comboBoxOpusFramesize->setCurrentIndex(m_settings->opusFramesize());
+
+ 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->checkBoxNormalizationFilter, m_settings->normalizationFilterEnabled());
+ 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());
+ ui->checkBoxNeroAAC2PassMode->setEnabled(aacEncoder == SettingsModel::AAC_ENCODER_NERO);
+
+ 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());
+
+ m_evenFilterCustumParamsHelp = new CustomEventFilter();
+ 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);
+
+ m_overwriteButtonGroup = new QButtonGroup(this);
+ 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);
+
+ 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->checkBoxNormalizationFilter, SIGNAL(clicked(bool)), this, SLOT(normalizationEnabledChanged(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->spinBoxNormalizationFilter, SIGNAL(valueChanged(double)), this, SLOT(normalizationMaxVolumeChanged(double)));
+ connect(ui->comboBoxNormalizationMode, SIGNAL(currentIndexChanged(int)), this, SLOT(normalizationModeChanged(int)));
+ 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)), SLOT(opusSettingsChanged()));
+ connect(m_overwriteButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(overwriteModeChanged(int)));
+ connect(m_evenFilterCustumParamsHelp, SIGNAL(eventOccurred(QWidget*, QEvent*)), this, SLOT(customParamsHelpRequested(QWidget*, QEvent*)));
+
+ //--------------------------------
+ // Force initial GUI update
+ //--------------------------------
+
+ updateLameAlgoQuality(ui->sliderLameAlgoQuality->value());
+ updateMaximumInstances(ui->sliderMaxInstances->value());
+ toneAdjustTrebleChanged(ui->spinBoxToneAdjustTreble->value());
+ toneAdjustBassChanged(ui->spinBoxToneAdjustBass->value());
customParamsChanged();
+ //--------------------------------
+ // Initialize actions
+ //--------------------------------
+
//Activate file menu actions
- actionOpenFolder->setData(QVariant::fromValue<bool>(false));
- actionOpenFolderRecursively->setData(QVariant::fromValue<bool>(true));
- connect(actionOpenFolder, SIGNAL(triggered()), this, SLOT(openFolderActionActivated()));
- connect(actionOpenFolderRecursively, SIGNAL(triggered()), this, SLOT(openFolderActionActivated()));
+ 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()));
//Activate view menu actions
m_tabActionGroup = new QActionGroup(this);
- m_tabActionGroup->addAction(actionSourceFiles);
- m_tabActionGroup->addAction(actionOutputDirectory);
- m_tabActionGroup->addAction(actionCompression);
- m_tabActionGroup->addAction(actionMetaData);
- m_tabActionGroup->addAction(actionAdvancedOptions);
- actionSourceFiles->setData(0);
- actionOutputDirectory->setData(1);
- actionMetaData->setData(2);
- actionCompression->setData(3);
- actionAdvancedOptions->setData(4);
- actionSourceFiles->setChecked(true);
+ 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);
connect(m_tabActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(tabActionActivated(QAction*)));
//Activate style menu actions
m_styleActionGroup = new QActionGroup(this);
- m_styleActionGroup->addAction(actionStylePlastique);
- m_styleActionGroup->addAction(actionStyleCleanlooks);
- m_styleActionGroup->addAction(actionStyleWindowsVista);
- m_styleActionGroup->addAction(actionStyleWindowsXP);
- m_styleActionGroup->addAction(actionStyleWindowsClassic);
- actionStylePlastique->setData(0);
- actionStyleCleanlooks->setData(1);
- actionStyleWindowsVista->setData(2);
- actionStyleWindowsXP->setData(3);
- actionStyleWindowsClassic->setData(4);
- actionStylePlastique->setChecked(true);
- actionStyleWindowsXP->setEnabled((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) >= QSysInfo::WV_XP && lamexp_themes_enabled());
- actionStyleWindowsVista->setEnabled((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) >= QSysInfo::WV_VISTA && lamexp_themes_enabled());
+ 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);
+ ui->actionStyleWindowsXP->setEnabled((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) >= QSysInfo::WV_XP && lamexp_themes_enabled());
+ ui->actionStyleWindowsVista->setEnabled((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) >= QSysInfo::WV_VISTA && lamexp_themes_enabled());
connect(m_styleActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(styleActionActivated(QAction*)));
styleActionActivated(NULL);
currentLanguage->setText(lamexp_translation_name(langId));
currentLanguage->setIcon(QIcon(QString(":/flags/%1.png").arg(langId)));
currentLanguage->setCheckable(true);
+ currentLanguage->setChecked(false);
m_languageActionGroup->addAction(currentLanguage);
- menuLanguage->insertAction(actionLoadTranslationFromFile, currentLanguage);
+ ui->menuLanguage->insertAction(ui->actionLoadTranslationFromFile, currentLanguage);
}
- menuLanguage->insertSeparator(actionLoadTranslationFromFile);
- connect(actionLoadTranslationFromFile, SIGNAL(triggered(bool)), this, SLOT(languageFromFileActionActivated(bool)));
+ ui->menuLanguage->insertSeparator(ui->actionLoadTranslationFromFile);
+ connect(ui->actionLoadTranslationFromFile, SIGNAL(triggered(bool)), this, SLOT(languageFromFileActionActivated(bool)));
connect(m_languageActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(languageActionActivated(QAction*)));
+ ui->actionLoadTranslationFromFile->setChecked(false);
//Activate tools menu actions
- actionDisableUpdateReminder->setChecked(!m_settings->autoUpdateEnabled());
- actionDisableSounds->setChecked(!m_settings->soundsEnabled());
- actionDisableNeroAacNotifications->setChecked(!m_settings->neroAacNotificationsEnabled());
- actionDisableSlowStartupNotifications->setChecked(!m_settings->antivirNotificationsEnabled());
- actionDisableShellIntegration->setChecked(!m_settings->shellIntegrationEnabled());
- actionDisableShellIntegration->setDisabled(lamexp_portable_mode() && actionDisableShellIntegration->isChecked());
- actionCheckForBetaUpdates->setChecked(m_settings->autoUpdateCheckBeta() || lamexp_version_demo());
- actionCheckForBetaUpdates->setEnabled(!lamexp_version_demo());
- actionHibernateComputer->setChecked(m_settings->hibernateComputer());
- actionHibernateComputer->setEnabled(lamexp_is_hibernation_supported());
- connect(actionDisableUpdateReminder, SIGNAL(triggered(bool)), this, SLOT(disableUpdateReminderActionTriggered(bool)));
- connect(actionDisableSounds, SIGNAL(triggered(bool)), this, SLOT(disableSoundsActionTriggered(bool)));
- connect(actionDisableNeroAacNotifications, SIGNAL(triggered(bool)), this, SLOT(disableNeroAacNotificationsActionTriggered(bool)));
- connect(actionDisableSlowStartupNotifications, SIGNAL(triggered(bool)), this, SLOT(disableSlowStartupNotificationsActionTriggered(bool)));
- connect(actionDisableShellIntegration, SIGNAL(triggered(bool)), this, SLOT(disableShellIntegrationActionTriggered(bool)));
- connect(actionShowDropBoxWidget, SIGNAL(triggered(bool)), this, SLOT(showDropBoxWidgetActionTriggered(bool)));
- connect(actionHibernateComputer, SIGNAL(triggered(bool)), this, SLOT(hibernateComputerActionTriggered(bool)));
- connect(actionCheckForBetaUpdates, SIGNAL(triggered(bool)), this, SLOT(checkForBetaUpdatesActionTriggered(bool)));
- connect(actionImportCueSheet, SIGNAL(triggered(bool)), this, SLOT(importCueSheetActionTriggered(bool)));
+ 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());
+ ui->actionDisableShellIntegration->setDisabled(lamexp_portable_mode() && ui->actionDisableShellIntegration->isChecked());
+ ui->actionCheckForBetaUpdates->setChecked(m_settings->autoUpdateCheckBeta() || lamexp_version_demo());
+ ui->actionCheckForBetaUpdates->setEnabled(!lamexp_version_demo());
+ ui->actionHibernateComputer->setChecked(m_settings->hibernateComputer());
+ ui->actionHibernateComputer->setEnabled(lamexp_is_hibernation_supported());
+ 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)));
//Activate help menu actions
- actionVisitHomepage->setData(QString::fromLatin1(lamexp_website_url()));
- actionVisitSupport->setData(QString::fromLatin1(lamexp_support_url()));
- actionDocumentFAQ->setData(QString("%1/FAQ.html").arg(QApplication::applicationDirPath()));
- actionDocumentChangelog->setData(QString("%1/Changelog.html").arg(QApplication::applicationDirPath()));
- actionDocumentTranslate->setData(QString("%1/Translate.html").arg(QApplication::applicationDirPath()));
- connect(actionCheckUpdates, SIGNAL(triggered()), this, SLOT(checkUpdatesActionActivated()));
- connect(actionVisitHomepage, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated()));
- connect(actionVisitSupport, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated()));
- connect(actionDocumentFAQ, SIGNAL(triggered()), this, SLOT(documentActionActivated()));
- connect(actionDocumentChangelog, SIGNAL(triggered()), this, SLOT(documentActionActivated()));
- connect(actionDocumentTranslate, SIGNAL(triggered()), this, SLOT(documentActionActivated()));
+ 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->actionDocumentFAQ->setData(QString("%1/FAQ.html").arg(QApplication::applicationDirPath()));
+ ui->actionDocumentChangelog->setData(QString("%1/Changelog.html").arg(QApplication::applicationDirPath()));
+ ui->actionDocumentTranslate->setData(QString("%1/Translate.html").arg(QApplication::applicationDirPath()));
+ connect(ui->actionCheckUpdates, SIGNAL(triggered()), this, SLOT(checkUpdatesActionActivated()));
+ connect(ui->actionVisitHomepage, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated()));
+ connect(ui->actionVisitMuldersSite, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated()));
+ connect(ui->actionVisitSupport, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated()));
+ connect(ui->actionDocumentFAQ, SIGNAL(triggered()), this, SLOT(documentActionActivated()));
+ connect(ui->actionDocumentChangelog, SIGNAL(triggered()), this, SLOT(documentActionActivated()));
+ connect(ui->actionDocumentTranslate, SIGNAL(triggered()), this, SLOT(documentActionActivated()));
+ //--------------------------------
+ // Prepare to show window
+ //--------------------------------
+
//Center window in screen
QRect desktopRect = QApplication::desktop()->screenGeometry();
QRect thisRect = this->geometry();
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()));
+ connect(m_fileListModel, SIGNAL(rowAppended()), m_dropBox, SLOT(modelChanged()));
//Create message handler thread
m_messageHandler = new MessageHandlerThread();
connect(m_delayedFileTimer, SIGNAL(timeout()), this, SLOT(handleDelayedFiles()));
m_messageHandler->start();
- //Load translation file
- 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);
- }
- }
+ //Load translation
+ initializeTranslation();
//Re-translate (make sure we translate once)
QEvent languageChangeEvent(QEvent::LanguageChange);
}
//Unset models
- sourceFileView->setModel(NULL);
- metaDataView->setModel(NULL);
+ SET_MODEL(ui->sourceFileView, NULL);
+ SET_MODEL(ui->outputFolderView, NULL);
+ SET_MODEL(ui->metaDataView, NULL);
//Free memory
LAMEXP_DELETE(m_tabActionGroup);
LAMEXP_DELETE(m_delayedFileTimer);
LAMEXP_DELETE(m_metaInfoModel);
LAMEXP_DELETE(m_encoderButtonGroup);
- LAMEXP_DELETE(m_encoderButtonGroup);
+ LAMEXP_DELETE(m_modeButtonGroup);
+ LAMEXP_DELETE(m_overwriteButtonGroup);
LAMEXP_DELETE(m_sourceFilesContextMenu);
LAMEXP_DELETE(m_outputFolderFavoritesMenu);
+ LAMEXP_DELETE(m_outputFolderContextMenu);
LAMEXP_DELETE(m_dropBox);
+ LAMEXP_DELETE(m_evenFilterCustumParamsHelp);
+ LAMEXP_DELETE(m_evenFilterOutputFolderMouse);
+ LAMEXP_DELETE(m_evenFilterOutputFolderView);
+ LAMEXP_DELETE(m_evenFilterCompressionTab);
+
+ //Un-initialize the dialog
+ LAMEXP_DELETE(ui);
}
////////////////////////////////////////////////////////////
return;
}
- tabWidget->setCurrentIndex(0);
+ ui->tabWidget->setCurrentIndex(0);
FileAnalyzer *analyzer = new FileAnalyzer(files);
connect(analyzer, SIGNAL(fileSelected(QString)), m_banner, SLOT(setText(QString)), Qt::QueuedConnection);
+ 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);
connect(analyzer, SIGNAL(fileAnalyzed(AudioFileModel)), m_fileListModel, SLOT(addFile(AudioFileModel)), Qt::QueuedConnection);
connect(m_banner, SIGNAL(userAbort()), analyzer, SLOT(abortProcess()), Qt::DirectConnection);
- m_banner->show(tr("Adding file(s), please wait..."), analyzer);
+ try
+ {
+ m_fileListModel->setBlockUpdates(true);
+ QTime startTime = QTime::currentTime();
+ m_banner->show(tr("Adding file(s), please wait..."), analyzer);
+ }
+ catch(...)
+ {
+ /* ignore any exceptions that may occur */
+ }
+
+ m_fileListModel->setBlockUpdates(false);
+ qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
+ ui->sourceFileView->update();
+ qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
+ ui->sourceFileView->scrollToBottom();
+ qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
if(analyzer->filesDenied())
{
- QMessageBox::warning(this, tr("Access Denied"), QString("%1<br>%2").arg(NOBR(tr("%1 file(s) have been rejected, because read access was not granted!").arg(analyzer->filesDenied())), NOBR(tr("This usually means the file is locked by another process."))));
+ 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."))));
}
if(analyzer->filesDummyCDDA())
{
- QMessageBox::warning(this, tr("CDDA Files"), QString("%1<br><br>%2<br>%3").arg(NOBR(tr("%1 file(s) have been rejected, because they are dummy CDDA files!").arg(analyzer->filesDummyCDDA())), NOBR(tr("Sorry, LameXP cannot extract audio tracks from an Audio-CD at present.")), NOBR(tr("We recommend using %1 for that purpose.").arg("<a href=\"http://www.exactaudiocopy.de/\">Exact Audio Copy</a>"))));
+ 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>"))));
}
if(analyzer->filesCueSheet())
{
- QMessageBox::warning(this, tr("Cue Sheet"), QString("%1<br>%2").arg(NOBR(tr("%1 file(s) have been rejected, because they appear to be Cue Sheet images!").arg(analyzer->filesCueSheet())), NOBR(tr("Please use LameXP's Cue Sheet wizard for importing Cue Sheet files."))));
+ 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."))));
}
if(analyzer->filesRejected())
{
- QMessageBox::warning(this, tr("Files Rejected"), QString("%1<br>%2").arg(NOBR(tr("%1 file(s) have been rejected, because the file format could not be recognized!").arg(analyzer->filesRejected())), NOBR(tr("This usually means the file is damaged or the file format is not supported."))));
+ 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."))));
}
LAMEXP_DELETE(analyzer);
- sourceFileView->scrollToBottom();
m_banner->close();
}
m_banner->show(tr("Scanning folder(s) for files, please wait..."));
QApplication::processEvents();
- GetAsyncKeyState(VK_ESCAPE);
+ lamexp_check_escape_state();
while(!folderInfoList.isEmpty())
{
- if(GetAsyncKeyState(VK_ESCAPE) & 0x0001)
+ if(lamexp_check_escape_state())
{
- MessageBeep(MB_ICONERROR);
+ lamexp_beep(lamexp_beep_error);
qWarning("Operation cancelled by user!");
fileList.clear();
break;
return bReadyToInstall;
}
+/*
+ * Refresh list of favorites
+ */
void MainWindow::refreshFavorites(void)
{
QList<QAction*> folderList = m_outputFolderFavoritesMenu->actions();
}
}
+/*
+ * 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();
+ if((!qmFilePath.isEmpty()) && QFileInfo(qmFilePath).exists() && QFileInfo(qmFilePath).isFile() && (QFileInfo(qmFilePath).suffix().compare("qm", Qt::CaseInsensitive) == 0))
+ {
+ if(lamexp_install_translator_from_file(qmFilePath))
+ {
+ QList<QAction*> actions = m_languageActionGroup->actions();
+ while(!actions.isEmpty()) actions.takeFirst()->setChecked(false);
+ ui->actionLoadTranslationFromFile->setChecked(true);
+ 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();
+ if(currentLanguage->data().toString().compare(LAMEXP_DEFAULT_LANGID, Qt::CaseInsensitive) == 0)
+ {
+ 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!");
+ }
+}
+
////////////////////////////////////////////////////////////
// EVENTS
////////////////////////////////////////////////////////////
void MainWindow::showEvent(QShowEvent *event)
{
m_accepted = false;
- m_dropNoteLabel->setGeometry(0, 0, sourceFileView->width(), sourceFileView->height());
+ resizeEvent(NULL);
sourceModelChanged();
-
+
if(!event->spontaneous())
{
- tabWidget->setCurrentIndex(0);
+ ui->tabWidget->setCurrentIndex(0);
}
if(m_firstTimeShown)
{
m_firstTimeShown = false;
+ lamexp_set_window_icon(this, lamexp_app_icon(), true);
QTimer::singleShot(0, this, SLOT(windowShown()));
}
else
{
if(e->type() == QEvent::LanguageChange)
{
- int comboBoxIndex[6];
+ /*qWarning("\nMainWindow::changeEvent()\n");*/
+
+ int comboBoxIndex[8];
//Backup combobox indices, as retranslateUi() resets
- comboBoxIndex[0] = comboBoxMP3ChannelMode->currentIndex();
- comboBoxIndex[1] = comboBoxSamplingRate->currentIndex();
- comboBoxIndex[2] = comboBoxAACProfile->currentIndex();
- comboBoxIndex[3] = comboBoxAftenCodingMode->currentIndex();
- comboBoxIndex[4] = comboBoxAftenDRCMode->currentIndex();
- comboBoxIndex[5] = comboBoxNormalizationMode->currentIndex();
+ 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();
+ comboBoxIndex[5] = ui->comboBoxNormalizationMode->currentIndex();
+ comboBoxIndex[6] = 0; //comboBoxOpusOptimize->currentIndex();
+ comboBoxIndex[7] = ui->comboBoxOpusFramesize->currentIndex();
//Re-translate from UIC
- Ui::MainWindow::retranslateUi(this);
+ ui->retranslateUi(this);
//Restore combobox indices
- comboBoxMP3ChannelMode->setCurrentIndex(comboBoxIndex[0]);
- comboBoxSamplingRate->setCurrentIndex(comboBoxIndex[1]);
- comboBoxAACProfile->setCurrentIndex(comboBoxIndex[2]);
- comboBoxAftenCodingMode->setCurrentIndex(comboBoxIndex[3]);
- comboBoxAftenDRCMode->setCurrentIndex(comboBoxIndex[4]);
- comboBoxNormalizationMode->setCurrentIndex(comboBoxIndex[5]);
+ 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]);
+ ui->comboBoxNormalizationMode->setCurrentIndex(comboBoxIndex[5]);
+ //comboBoxOpusOptimize->setCurrentIndex(comboBoxIndex[6]);
+ ui->comboBoxOpusFramesize->setCurrentIndex(comboBoxIndex[7]);
//Update the window title
if(LAMEXP_DEBUG)
}
//Manually re-translate widgets that UIC doesn't handle
- m_dropNoteLabel->setText(QString("» %1 «").arg(tr("You can drop in audio files here!")));
+ 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!")));
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"));
m_metaInfoModel->clearData();
m_metaInfoModel->setData(m_metaInfoModel->index(4, 1), m_settings->metaInfoPosition());
updateEncoder(m_settings->compressionEncoder());
- updateLameAlgoQuality(sliderLameAlgoQuality->value());
- updateMaximumInstances(sliderMaxInstances->value());
- renameOutputPatternChanged(lineEditRenamePattern->text());
+ updateLameAlgoQuality(ui->sliderLameAlgoQuality->value());
+ updateMaximumInstances(ui->sliderMaxInstances->value());
+ renameOutputPatternChanged(ui->lineEditRenamePattern->text(), true);
//Re-install shell integration
if(m_settings->shellIntegrationEnabled())
ShellIntegration::install();
}
+ //Translate system menu
+ lamexp_update_sysmenu(this, IDM_ABOUTBOX, ui->buttonAbout->text());
+
//Force resize, if needed
- tabPageChanged(tabWidget->currentIndex());
+ tabPageChanged(ui->tabWidget->currentIndex(), true);
}
}
{
ABORT_IF_BUSY;
+ if(m_settings->soundsEnabled()) lamexp_play_sound(IDR_WAVE_DROP, true);
+
QStringList droppedFiles;
QList<QUrl> urls = event->mimeData()->urls();
}
if(file.isFile())
{
- qDebug("Dropped File: %s", file.canonicalFilePath().toUtf8().constData());
+ qDebug("Dropped File: %s", QUTF8(file.canonicalFilePath()));
droppedFiles << file.canonicalFilePath();
continue;
}
if(file.isDir())
{
- qDebug("Dropped Folder: %s", file.canonicalFilePath().toUtf8().constData());
+ qDebug("Dropped Folder: %s", QUTF8(file.canonicalFilePath()));
QList<QFileInfo> list = QDir(file.canonicalFilePath()).entryInfoList(QDir::Files | QDir::NoSymLinks);
if(list.count() > 0)
{
list = QDir(file.canonicalFilePath()).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
for(int j = 0; j < list.count(); j++)
{
- qDebug("Descending to Folder: %s", list.at(j).canonicalFilePath().toUtf8().constData());
+ qDebug("Descending to Folder: %s", QUTF8(list.at(j).canonicalFilePath()));
urls.prepend(QUrl::fromLocalFile(list.at(j).canonicalFilePath()));
}
}
{
if(m_banner->isVisible() || m_delayedFileTimer->isActive())
{
- MessageBeep(MB_ICONEXCLAMATION);
+ lamexp_beep(lamexp_beep_warning);
event->ignore();
}
*/
void MainWindow::resizeEvent(QResizeEvent *event)
{
- QMainWindow::resizeEvent(event);
- m_dropNoteLabel->setGeometry(0, 0, sourceFileView->width(), sourceFileView->height());
+ if(event) QMainWindow::resizeEvent(event);
+
+ if(QWidget *port = ui->sourceFileView->viewport())
+ {
+ m_dropNoteLabel->setGeometry(port->geometry());
+ }
+
+ if (QWidget *port = ui->outputFolderView->viewport())
+ {
+ m_outputFolderNoteBox->setGeometry(16, (port->height() - 64) / 2, port->width() - 32, 64);
+ }
}
/*
- * Event filter
+ * Key press event filter
*/
-bool MainWindow::eventFilter(QObject *obj, QEvent *event)
+void MainWindow::keyPressEvent(QKeyEvent *e)
{
- if(obj == m_fileSystemModel)
+ if(e->key() == Qt::Key_Delete)
{
- if(QApplication::overrideCursor() == NULL)
+ if(ui->sourceFileView->isVisible())
{
- QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
- QTimer::singleShot(250, this, SLOT(restoreCursor()));
+ QTimer::singleShot(0, this, SLOT(removeFileButtonClicked()));
+ return;
}
}
- else if(obj == outputFolderView)
+
+ if(e->modifiers().testFlag(Qt::ControlModifier) && (e->key() == Qt::Key_F5))
{
- switch(event->type())
- {
- case QEvent::Enter:
- case QEvent::Leave:
- case QEvent::KeyPress:
- case QEvent::KeyRelease:
- case QEvent::FocusIn:
- case QEvent::FocusOut:
- case QEvent::TouchEnd:
- outputFolderViewClicked(outputFolderView->currentIndex());
- break;
- }
+ initializeTranslation();
+ lamexp_beep(lamexp_beep_info);
+ return;
}
- else if(obj == outputFolderLabel)
+
+ if(e->key() == Qt::Key_F5)
{
- switch(event->type())
+ if(ui->outputFolderView->isVisible())
{
- case QEvent::MouseButtonPress:
- if(dynamic_cast<QMouseEvent*>(event)->button() == Qt::LeftButton)
- {
- QString path = outputFolderLabel->text();
- if(!path.endsWith(QDir::separator())) path.append(QDir::separator());
- ShellExecuteW(this->winId(), L"explore", QWCHAR(path), NULL, NULL, SW_SHOW);
- }
- break;
- case QEvent::Enter:
- outputFolderLabel->setForegroundRole(QPalette::Link);
- break;
- case QEvent::Leave:
- outputFolderLabel->setForegroundRole(QPalette::WindowText);
- break;
+ QTimer::singleShot(0, this, SLOT(refreshFolderContextActionTriggered()));
+ return;
}
}
- else if(obj == outputFoldersFovoritesLabel)
- {
- QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(event);
- QPoint pos = (mouseEvent != NULL) ? mouseEvent->pos() : QPoint();
- QWidget *sender = dynamic_cast<QLabel*>(obj);
- switch(event->type())
+ QMainWindow::keyPressEvent(e);
+}
+
+/*
+ * Event filter
+ */
+bool MainWindow::eventFilter(QObject *obj, QEvent *event)
+{
+ if(obj == m_fileSystemModel)
+ {
+ if(QApplication::overrideCursor() == NULL)
{
- case QEvent::Enter:
- outputFoldersFovoritesLabel->setFrameShadow(QFrame::Raised);
- break;
- case QEvent::MouseButtonPress:
- outputFoldersFovoritesLabel->setFrameShadow(QFrame::Sunken);
- break;
- case QEvent::MouseButtonRelease:
- outputFoldersFovoritesLabel->setFrameShadow(QFrame::Raised);
- if(sender && mouseEvent)
- {
- if(pos.x() <= sender->width() && pos.y() <= sender->height() && pos.x() >= 0 && pos.y() >= 0 && mouseEvent->button() != Qt::MidButton)
- {
- m_outputFolderFavoritesMenu->popup(sender->mapToGlobal(pos));
- }
- }
- break;
- case QEvent::Leave:
- outputFoldersFovoritesLabel->setFrameShadow(QFrame::Plain);
- break;
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+ QTimer::singleShot(250, this, SLOT(restoreCursor()));
}
}
}
m_fileListModel->clearFiles();
return true;
+ case QEvent::MouseButtonPress:
+ if(ui->outputFolderEdit->isVisible())
+ {
+ QTimer::singleShot(0, this, SLOT(outputFolderEditFinished()));
+ }
default:
return QMainWindow::event(e);
}
bool MainWindow::winEvent(MSG *message, long *result)
{
+ if(lamexp_check_sysmenu_msg(message, IDM_ABOUTBOX))
+ {
+ QTimer::singleShot(0, ui->buttonAbout, SLOT(click()));
+ *result = 0;
+ return true;
+ }
return WinSevenTaskbar::handleWinEvent(message, result);
}
*/
void MainWindow::windowShown(void)
{
- QStringList arguments = QApplication::arguments();
+ const QStringList &arguments = lamexp_arguments(); //QApplication::arguments();
+
+ //Force resize event
+ resizeEvent(NULL);
//First run?
bool firstRun = false;
for(int i = 0; i < arguments.count(); i++)
{
+ /*QMessageBox::information(this, QString::number(i), arguments[i]);*/
if(!arguments[i].compare("--first-run", Qt::CaseInsensitive)) firstRun = true;
}
//Check license
if((m_settings->licenseAccepted() <= 0) || firstRun)
{
- int iAccepted = -1;
+ int iAccepted = m_settings->licenseAccepted();
- if((m_settings->licenseAccepted() == 0) || firstRun)
+ if((iAccepted == 0) || firstRun)
{
AboutDialog *about = new AboutDialog(m_settings, this, true);
iAccepted = about->exec();
+ if(iAccepted <= 0) iAccepted = -2;
LAMEXP_DELETE(about);
}
if(iAccepted <= 0)
{
- m_settings->licenseAccepted(-1);
+ m_settings->licenseAccepted(++iAccepted);
+ m_settings->syncNow();
QApplication::processEvents();
- PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
+ lamexp_play_sound(IDR_WAVE_WHAMMY, false);
QMessageBox::critical(this, tr("License Declined"), tr("You have declined the license. Consequently the application will exit now!"), tr("Goodbye!"));
QFileInfo uninstallerInfo = QFileInfo(QString("%1/Uninstall.exe").arg(QApplication::applicationDirPath()));
if(uninstallerInfo.exists())
QString uninstallerPath = uninstallerInfo.canonicalFilePath();
for(int i = 0; i < 3; i++)
{
- HINSTANCE res = ShellExecuteW(this->winId(), L"open", QWCHAR(QDir::toNativeSeparators(uninstallerPath)), L"/Force", QWCHAR(QDir::toNativeSeparators(uninstallerDir)), SW_SHOWNORMAL);
- if(reinterpret_cast<int>(res) > 32) break;
+ if(lamexp_exec_shell(this, QDir::toNativeSeparators(uninstallerPath), "/Force", QDir::toNativeSeparators(uninstallerDir))) break;
}
}
- else
- {
- MoveFileEx(QWCHAR(QDir::toNativeSeparators(QFileInfo(QApplication::applicationFilePath()).canonicalFilePath())), NULL, MOVEFILE_DELAY_UNTIL_REBOOT | MOVEFILE_REPLACE_EXISTING);
- }
QApplication::quit();
return;
}
- PlaySound(MAKEINTRESOURCE(IDR_WAVE_WOOHOO), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
+ lamexp_play_sound(IDR_WAVE_WOOHOO, false);
m_settings->licenseAccepted(1);
+ m_settings->syncNow();
if(lamexp_version_demo()) showAnnounceBox();
}
//Check for expiration
if(lamexp_version_demo())
{
- if(QDate::currentDate() >= lamexp_version_expires())
+ if(lamexp_current_date_safe() >= lamexp_version_expires())
{
qWarning("Binary has expired !!!");
- PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
+ lamexp_play_sound(IDR_WAVE_WHAMMY, false);
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)
{
checkForUpdates();
{
QString message;
message += NOBR(tr("It seems that a bogus anti-virus software is slowing down the startup of LameXP.")).append("<br>");
- message += NOBR(tr("Please refer to the %1 document for details and solutions!")).arg("<a href=\"http://lamexp.git.sourceforge.net/git/gitweb.cgi?p=lamexp/lamexp;a=blob_plain;f=doc/FAQ.html;hb=HEAD#df406578\">F.A.Q.</a>").append("<br>");
+ 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>");
if(QMessageBox::warning(this, tr("Slow Startup"), message, tr("Discard"), tr("Don't Show Again")) == 1)
{
m_settings->antivirNotificationsEnabled(false);
- actionDisableSlowStartupNotifications->setChecked(!m_settings->antivirNotificationsEnabled());
+ ui->actionDisableSlowStartupNotifications->setChecked(!m_settings->antivirNotificationsEnabled());
}
}
//Update reminder
- if(QDate::currentDate() >= lamexp_version_date().addYears(1))
+ if(lamexp_current_date_safe() >= lamexp_version_date().addYears(1))
{
qWarning("Binary is more than a year old, time to update!");
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"));
return;
default:
QEventLoop loop; QTimer::singleShot(7000, &loop, SLOT(quit()));
- PlaySound(MAKEINTRESOURCE(IDR_WAVE_WAITING), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
+ lamexp_play_sound(IDR_WAVE_WAITING, true);
m_banner->show(tr("Skipping update check this time, please be patient..."), &loop);
break;
}
else if(m_settings->autoUpdateEnabled())
{
QDate lastUpdateCheck = QDate::fromString(m_settings->autoUpdateLastCheck(), Qt::ISODate);
- if(!firstRun && (!lastUpdateCheck.isValid() || QDate::currentDate() >= lastUpdateCheck.addDays(14)))
+ if(!firstRun && (!lastUpdateCheck.isValid() || lamexp_current_date_safe() >= lastUpdateCheck.addDays(14)))
{
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)
{
}
//Check for AAC support
- if(m_neroEncoderAvailable)
+ const int aacEncoder = EncoderRegistry::getAacEncoder();
+ if(aacEncoder == SettingsModel::AAC_ENCODER_NERO)
{
if(m_settings->neroAacNotificationsEnabled())
{
}
else
{
- if(m_settings->neroAacNotificationsEnabled() && (!(m_fhgEncoderAvailable || m_qaacEncoderAvailable)))
+ if(m_settings->neroAacNotificationsEnabled() && (aacEncoder <= SettingsModel::AAC_ENCODER_NONE))
{
QString appPath = QDir(QCoreApplication::applicationDirPath()).canonicalPath();
if(appPath.isEmpty()) appPath = QCoreApplication::applicationDirPath();
if(QMessageBox::information(this, tr("AAC Support Disabled"), messageText, tr("Discard"), tr("Don't Show Again")) == 1)
{
m_settings->neroAacNotificationsEnabled(false);
- actionDisableNeroAacNotifications->setChecked(!m_settings->neroAacNotificationsEnabled());
+ ui->actionDisableNeroAacNotifications->setChecked(!m_settings->neroAacNotificationsEnabled());
}
}
}
if(!arguments[i].compare("--add", Qt::CaseInsensitive))
{
QFileInfo currentFile(arguments[++i].trimmed());
- qDebug("Adding file from CLI: %s", currentFile.absoluteFilePath().toUtf8().constData());
+ qDebug("Adding file from CLI: %s", QUTF8(currentFile.absoluteFilePath()));
addedFiles.append(currentFile.absoluteFilePath());
}
if(!addedFiles.isEmpty())
if(!arguments[i].compare("--add-folder", Qt::CaseInsensitive))
{
QFileInfo currentFile(arguments[++i].trimmed());
- qDebug("Adding folder from CLI: %s", currentFile.absoluteFilePath().toUtf8().constData());
+ qDebug("Adding folder from CLI: %s", QUTF8(currentFile.absoluteFilePath()));
addFolder(currentFile.absoluteFilePath(), false, true);
}
if(!arguments[i].compare("--add-recursive", Qt::CaseInsensitive))
{
QFileInfo currentFile(arguments[++i].trimmed());
- qDebug("Adding folder recursively from CLI: %s", currentFile.absoluteFilePath().toUtf8().constData());
+ qDebug("Adding folder recursively from CLI: %s", QUTF8(currentFile.absoluteFilePath()));
addFolder(currentFile.absoluteFilePath(), true, true);
}
}
*/
void MainWindow::showAnnounceBox(void)
{
+ const unsigned int timeout = 8U;
+
const QString announceText = QString("%1<br><br>%2<br><nobr><tt>%3</tt></nobr><br>").arg
(
NOBR("We are still looking for LameXP translators!"),
NOBR("If you are willing to translate LameXP to your language or to complete an existing translation, please refer to:"),
- LINK("http://mulder.brhack.net/public/doc/lamexp_translate.html")
+ LINK("http://lamexp.sourceforge.net/doc/Translate.html")
);
-
+
QMessageBox *announceBox = new QMessageBox(QMessageBox::Warning, "We want you!", announceText, QMessageBox::NoButton, this);
announceBox->setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
announceBox->setIconPixmap(QIcon(":/images/Announcement.png").pixmap(64,79));
- QPushButton *button1 = announceBox->addButton(tr("Discard"), QMessageBox::AcceptRole);
- QPushButton *button2 = announceBox->addButton(tr("Discard"), QMessageBox::NoRole);
- button1->setVisible(false);
- button2->setEnabled(false);
-
- QTimer *announceTimer = new QTimer(this);
- announceTimer->setSingleShot(true);
- announceTimer->setInterval(8000);
- connect(announceTimer, SIGNAL(timeout()), button1, SLOT(show()));
- connect(announceTimer, SIGNAL(timeout()), button2, SLOT(hide()));
- announceTimer->start();
- while(announceTimer->isActive()) announceBox->exec();
- announceTimer->stop();
+ QTimer *timers[timeout+1];
+ QPushButton *buttons[timeout+1];
+
+ for(unsigned int i = 0; i <= timeout; i++)
+ {
+ QString text = (i > 0) ? QString("%1 (%2)").arg(tr("Discard"), QString::number(i)) : tr("Discard");
+ buttons[i] = announceBox->addButton(text, (i > 0) ? QMessageBox::NoRole : QMessageBox::AcceptRole);
+ }
+
+ for(unsigned int i = 0; i <= timeout; i++)
+ {
+ buttons[i]->setEnabled(i == 0);
+ buttons[i]->setVisible(i == timeout);
+ }
+
+ for(unsigned int i = 0; i < timeout; i++)
+ {
+ timers[i] = new QTimer(this);
+ timers[i]->setSingleShot(true);
+ timers[i]->setInterval(1000);
+ connect(timers[i], SIGNAL(timeout()), buttons[i+1], SLOT(hide()));
+ connect(timers[i], SIGNAL(timeout()), buttons[i], SLOT(show()));
+ if(i > 0)
+ {
+ connect(timers[i], SIGNAL(timeout()), timers[i-1], SLOT(start()));
+ }
+ }
+
+ timers[timeout-1]->start();
+ announceBox->exec();
+
+ for(unsigned int i = 0; i < timeout; i++)
+ {
+ timers[i]->stop();
+ LAMEXP_DELETE(timers[i]);
+ }
- LAMEXP_DELETE(announceTimer);
LAMEXP_DELETE(announceBox);
}
if(m_fileListModel->rowCount() < 1)
{
QMessageBox::warning(this, tr("LameXP"), NOBR(tr("You must add at least one file to the list before proceeding!")));
- tabWidget->setCurrentIndex(0);
+ ui->tabWidget->setCurrentIndex(0);
return;
}
{
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)
{
- while(checkBoxUseSystemTempFolder->isChecked() == m_settings->customTempPathEnabledDefault()) checkBoxUseSystemTempFolder->click();
+ SET_CHECKBOX_STATE(ui->checkBoxUseSystemTempFolder, m_settings->customTempPathEnabledDefault());
}
return;
}
{
QStringList tempFolderParts = tempFolder.split("/", QString::SkipEmptyParts, Qt::CaseInsensitive);
tempFolderParts.takeLast();
- if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
+ if(m_settings->soundsEnabled()) lamexp_play_sound(IDR_WAVE_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))),
return;
break;
default:
- QMessageBox::warning(this, tr("Low Diskspace"), tr("You are proceeding with low diskspace. Problems might occur!"));
+ QMessageBox::warning(this, tr("Low Diskspace"), NOBR(tr("You are proceeding with low diskspace. Problems might occur!")));
break;
}
}
case SettingsModel::AACEncoder:
case SettingsModel::AC3Encoder:
case SettingsModel::FLACEncoder:
+ case SettingsModel::OpusEncoder:
case SettingsModel::DCAEncoder:
case SettingsModel::PCMEncoder:
break;
default:
QMessageBox::warning(this, tr("LameXP"), tr("Sorry, an unsupported encoder has been chosen!"));
- tabWidget->setCurrentIndex(3);
+ ui->tabWidget->setCurrentIndex(3);
return;
}
if(!(writeTest.open(QIODevice::ReadWrite) && (writeTest.write(writeTestBuffer) == strlen(writeTestBuffer))))
{
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!")));
- tabWidget->setCurrentIndex(1);
+ ui->tabWidget->setCurrentIndex(1);
return;
}
else
writeTest.remove();
}
}
-
+
m_accepted = true;
close();
}
AboutDialog *aboutBox = new AboutDialog(m_settings, this);
aboutBox->exec();
LAMEXP_DELETE(aboutBox);
- )
+ );
}
/*
/*
* Tab page changed
*/
-void MainWindow::tabPageChanged(int idx)
+void MainWindow::tabPageChanged(int idx, const bool silent)
{
+ resizeEvent(NULL);
+
+ //Update "view" menu
QList<QAction*> actions = m_tabActionGroup->actions();
for(int i = 0; i < actions.count(); i++)
{
}
}
+ //Play tick sound
+ if(m_settings->soundsEnabled() && (!silent))
+ {
+ lamexp_play_sound(IDR_WAVE_TICK, true);
+ }
+
int initialWidth = this->width();
- int maximumWidth = QApplication::desktop()->width();
+ int maximumWidth = QApplication::desktop()->availableGeometry().width();
+ //Make sure all tab headers are fully visible
if(this->isVisible())
{
- while(tabWidget->width() < tabWidget->sizeHint().width())
+ int delta = ui->tabWidget->sizeHint().width() - ui->tabWidget->width();
+ if(delta > 0)
{
- int previousWidth = this->width();
- this->resize(this->width() + 1, this->height());
- if(this->frameGeometry().width() >= maximumWidth) break;
- if(this->width() <= previousWidth) break;
+ this->resize(qMin(this->width() + delta, maximumWidth), this->height());
}
}
- if(idx == tabWidget->indexOf(tabOptions) && scrollArea->widget() && this->isVisible())
+ //Tab specific operations
+ if(idx == ui->tabWidget->indexOf(ui->tabOptions) && ui->scrollArea->widget() && this->isVisible())
{
- for(int i = 0; i < 2; i++)
+ ui->scrollArea->widget()->updateGeometry();
+ ui->scrollArea->viewport()->updateGeometry();
+ qApp->processEvents();
+ int delta = ui->scrollArea->widget()->width() - ui->scrollArea->viewport()->width();
+ if(delta > 0)
{
- QApplication::processEvents();
- while(scrollArea->viewport()->width() < scrollArea->widget()->width())
- {
- int previousWidth = this->width();
- this->resize(this->width() + 1, this->height());
- if(this->frameGeometry().width() >= maximumWidth) break;
- if(this->width() <= previousWidth) break;
- }
+ this->resize(qMin(this->width() + delta, maximumWidth), this->height());
}
}
- else if(idx == tabWidget->indexOf(tabSourceFiles))
+ else if(idx == ui->tabWidget->indexOf(ui->tabSourceFiles))
{
- m_dropNoteLabel->setGeometry(0, 0, sourceFileView->width(), sourceFileView->height());
+ m_dropNoteLabel->setGeometry(0, 0, ui->sourceFileView->width(), ui->sourceFileView->height());
}
- else if(idx == tabWidget->indexOf(tabOutputDir))
+ else if(idx == ui->tabWidget->indexOf(ui->tabOutputDir))
{
- if(!m_OutputFolderViewInitialized)
+ if(!m_fileSystemModel)
+ {
+ QTimer::singleShot(125, this, SLOT(initOutputFolderModel()));
+ }
+ else
{
- QTimer::singleShot(0, this, SLOT(initOutputFolderModel()));
+ CENTER_CURRENT_OUTPUT_FOLDER_DELAYED;
}
}
+ //Center window around previous position
if(initialWidth < this->width())
{
QPoint prevPos = this->pos();
int index = action->data().toInt(&ok);
if(ok)
{
- tabWidget->setCurrentIndex(index);
+ ui->tabWidget->setCurrentIndex(index);
}
}
}
switch(m_settings->interfaceStyle())
{
case 1:
- if(actionStyleCleanlooks->isEnabled())
+ if(ui->actionStyleCleanlooks->isEnabled())
{
- actionStyleCleanlooks->setChecked(true);
+ ui->actionStyleCleanlooks->setChecked(true);
QApplication::setStyle(new QCleanlooksStyle());
break;
}
case 2:
- if(actionStyleWindowsVista->isEnabled())
+ if(ui->actionStyleWindowsVista->isEnabled())
{
- actionStyleWindowsVista->setChecked(true);
+ ui->actionStyleWindowsVista->setChecked(true);
QApplication::setStyle(new QWindowsVistaStyle());
break;
}
case 3:
- if(actionStyleWindowsXP->isEnabled())
+ if(ui->actionStyleWindowsXP->isEnabled())
{
- actionStyleWindowsXP->setChecked(true);
+ ui->actionStyleWindowsXP->setChecked(true);
QApplication::setStyle(new QWindowsXPStyle());
break;
}
case 4:
- if(actionStyleWindowsClassic->isEnabled())
+ if(ui->actionStyleWindowsClassic->isEnabled())
{
- actionStyleWindowsClassic->setChecked(true);
+ ui->actionStyleWindowsClassic->setChecked(true);
QApplication::setStyle(new QWindowsStyle());
break;
}
default:
- actionStylePlastique->setChecked(true);
+ ui->actionStylePlastique->setChecked(true);
QApplication::setStyle(new QPlastiqueStyle());
break;
}
//Force re-translate after style change
- changeEvent(new QEvent(QEvent::LanguageChange));
+ if(QEvent *e = new QEvent(QEvent::LanguageChange))
+ {
+ changeEvent(e);
+ LAMEXP_DELETE(e);
+ }
+
+ //Make transparent
+ const type_info &styleType = typeid(*qApp->style());
+ const bool bTransparent = ((typeid(QWindowsVistaStyle) == styleType) || (typeid(QWindowsXPStyle) == styleType));
+ MAKE_TRANSPARENT(ui->scrollArea, bTransparent);
+
+ //Also force a re-size event
+ QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
+ resizeEvent(NULL);
}
/*
if(lamexp_install_translator(langId))
{
action->setChecked(true);
+ ui->actionLoadTranslationFromFile->setChecked(false);
m_settings->currentLanguage(langId);
+ m_settings->currentLanguageFile(QString());
}
}
}
if(dialog.exec())
{
QStringList selectedFiles = dialog.selectedFiles();
- if(lamexp_install_translator_from_file(selectedFiles.first()))
+ const QString qmFile = QFileInfo(selectedFiles.first()).canonicalFilePath();
+ if(lamexp_install_translator_from_file(qmFile))
{
QList<QAction*> actions = m_languageActionGroup->actions();
while(!actions.isEmpty())
{
actions.takeFirst()->setChecked(false);
}
+ ui->actionLoadTranslationFromFile->setChecked(true);
+ m_settings->currentLanguageFile(qmFile);
}
else
{
m_settings->autoUpdateEnabled(true);
}
- actionDisableUpdateReminder->setChecked(!m_settings->autoUpdateEnabled());
+ ui->actionDisableUpdateReminder->setChecked(!m_settings->autoUpdateEnabled());
}
/*
m_settings->soundsEnabled(true);
}
- actionDisableSounds->setChecked(!m_settings->soundsEnabled());
+ ui->actionDisableSounds->setChecked(!m_settings->soundsEnabled());
}
/*
m_settings->neroAacNotificationsEnabled(true);
}
- actionDisableNeroAacNotifications->setChecked(!m_settings->neroAacNotificationsEnabled());
+ ui->actionDisableNeroAacNotifications->setChecked(!m_settings->neroAacNotificationsEnabled());
}
/*
m_settings->antivirNotificationsEnabled(true);
}
- actionDisableSlowStartupNotifications->setChecked(!m_settings->antivirNotificationsEnabled());
+ ui->actionDisableSlowStartupNotifications->setChecked(!m_settings->antivirNotificationsEnabled());
}
/*
int result = 0;
QString selectedCueFile;
- if(USE_NATIVE_FILE_DIALOG)
+ if(lamexp_themes_enabled())
{
selectedCueFile = QFileDialog::getOpenFileName(this, tr("Open Cue Sheet"), m_settings->mostRecentInputPath(), QString("%1 (*.cue)").arg(tr("Cue Sheet File")));
}
if(!selectedCueFile.isEmpty())
{
m_settings->mostRecentInputPath(QFileInfo(selectedCueFile).canonicalPath());
- CueImportDialog *cueImporter = new CueImportDialog(this, m_fileListModel, selectedCueFile);
+ CueImportDialog *cueImporter = new CueImportDialog(this, m_fileListModel, selectedCueFile, m_settings);
result = cueImporter->exec();
LAMEXP_DELETE(cueImporter);
}
+ if(result == QDialog::Accepted)
+ {
+ qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
+ ui->sourceFileView->update();
+ qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
+ ui->sourceFileView->scrollToBottom();
+ qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
+ }
+
if(result != (-1)) break;
}
- )
+ );
}
/*
if(!m_dropBox->isVisible())
{
m_dropBox->show();
+ QTimer::singleShot(2500, m_dropBox, SLOT(showToolTip()));
}
lamexp_blink_window(m_dropBox);
m_settings->autoUpdateCheckBeta(false);
}
- actionCheckForBetaUpdates->setChecked(m_settings->autoUpdateCheckBeta());
+ ui->actionCheckForBetaUpdates->setChecked(m_settings->autoUpdateCheckBeta());
if(checkUpdatesNow)
{
m_settings->hibernateComputer(false);
}
- actionHibernateComputer->setChecked(m_settings->hibernateComputer());
+ ui->actionHibernateComputer->setChecked(m_settings->hibernateComputer());
}
/*
m_settings->shellIntegrationEnabled(true);
}
- actionDisableShellIntegration->setChecked(!m_settings->shellIntegrationEnabled());
+ ui->actionDisableShellIntegration->setChecked(!m_settings->shellIntegrationEnabled());
- if(lamexp_portable_mode() && actionDisableShellIntegration->isChecked())
+ if(lamexp_portable_mode() && ui->actionDisableShellIntegration->isChecked())
{
- actionDisableShellIntegration->setEnabled(false);
+ ui->actionDisableShellIntegration->setEnabled(false);
}
}
TEMP_HIDE_DROPBOX
(
bFlag = checkForUpdates();
- )
+ );
if(bFlag)
{
TEMP_HIDE_DROPBOX
(
- if(USE_NATIVE_FILE_DIALOG)
+ if(lamexp_themes_enabled())
{
QStringList fileTypeFilters = DecoderRegistry::getSupportedTypes();
QStringList selectedFiles = QFileDialog::getOpenFileNames(this, tr("Add file(s)"), m_settings->mostRecentInputPath(), fileTypeFilters.join(";;"));
}
}
}
- )
+ );
}
/*
{
TEMP_HIDE_DROPBOX
(
- if(USE_NATIVE_FILE_DIALOG)
+ if(lamexp_themes_enabled())
{
selectedFolder = QFileDialog::getExistingDirectory(this, tr("Add Folder"), m_settings->mostRecentInputPath());
}
m_settings->mostRecentInputPath(QDir(selectedFolder).canonicalPath());
addFolder(selectedFolder, action->data().toBool());
}
- )
+ );
}
}
*/
void MainWindow::removeFileButtonClicked(void)
{
- if(sourceFileView->currentIndex().isValid())
+ if(ui->sourceFileView->currentIndex().isValid())
{
- int iRow = sourceFileView->currentIndex().row();
- m_fileListModel->removeFile(sourceFileView->currentIndex());
- sourceFileView->selectRow(iRow < m_fileListModel->rowCount() ? iRow : m_fileListModel->rowCount()-1);
+ int iRow = ui->sourceFileView->currentIndex().row();
+ m_fileListModel->removeFile(ui->sourceFileView->currentIndex());
+ ui->sourceFileView->selectRow(iRow < m_fileListModel->rowCount() ? iRow : m_fileListModel->rowCount()-1);
}
}
*/
void MainWindow::fileUpButtonClicked(void)
{
- if(sourceFileView->currentIndex().isValid())
+ if(ui->sourceFileView->currentIndex().isValid())
{
- int iRow = sourceFileView->currentIndex().row() - 1;
- m_fileListModel->moveFile(sourceFileView->currentIndex(), -1);
- sourceFileView->selectRow(iRow >= 0 ? iRow : 0);
+ int iRow = ui->sourceFileView->currentIndex().row() - 1;
+ m_fileListModel->moveFile(ui->sourceFileView->currentIndex(), -1);
+ ui->sourceFileView->selectRow(iRow >= 0 ? iRow : 0);
}
}
*/
void MainWindow::fileDownButtonClicked(void)
{
- if(sourceFileView->currentIndex().isValid())
+ if(ui->sourceFileView->currentIndex().isValid())
{
- int iRow = sourceFileView->currentIndex().row() + 1;
- m_fileListModel->moveFile(sourceFileView->currentIndex(), 1);
- sourceFileView->selectRow(iRow < m_fileListModel->rowCount() ? iRow : m_fileListModel->rowCount()-1);
+ 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);
}
}
int iResult = 0;
MetaInfoDialog *metaInfoDialog = new MetaInfoDialog(this);
- QModelIndex index = sourceFileView->currentIndex();
+ QModelIndex index = ui->sourceFileView->currentIndex();
while(index.isValid())
{
if(iResult > 0)
{
index = m_fileListModel->index(index.row() + 1, index.column());
- sourceFileView->selectRow(index.row());
+ ui->sourceFileView->selectRow(index.row());
}
if(iResult < 0)
{
index = m_fileListModel->index(index.row() - 1, index.column());
- sourceFileView->selectRow(index.row());
+ ui->sourceFileView->selectRow(index.row());
}
AudioFileModel &file = (*m_fileListModel)[index];
TEMP_HIDE_DROPBOX
(
iResult = metaInfoDialog->exec(file, index.row() > 0, index.row() < m_fileListModel->rowCount() - 1);
- )
+ );
+ //Copy all info to Meta Info tab
if(iResult == INT_MAX)
{
m_metaInfoModel->assignInfoFrom(file);
- tabWidget->setCurrentIndex(tabWidget->indexOf(tabMetaData));
+ ui->tabWidget->setCurrentIndex(ui->tabWidget->indexOf(ui->tabMetaData));
break;
}
*/
void MainWindow::sourceFilesScrollbarMoved(int)
{
- sourceFileView->resizeColumnToContents(0);
+ ui->sourceFileView->resizeColumnToContents(0);
}
/*
*/
void MainWindow::previewContextActionTriggered(void)
{
- const static char *appNames[3] = {"smplayer_portable.exe", "smplayer.exe", "mplayer.exe"};
- const static wchar_t *registryKey = L"SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{DB9E4EAB-2717-499F-8D56-4CC8A644AB60}";
-
- QModelIndex index = sourceFileView->currentIndex();
+ QModelIndex index = ui->sourceFileView->currentIndex();
if(!index.isValid())
{
return;
}
- QString mplayerPath;
- HKEY registryKeyHandle;
-
- if(RegOpenKeyExW(HKEY_LOCAL_MACHINE, registryKey, 0, KEY_READ, ®istryKeyHandle) == ERROR_SUCCESS)
- {
- wchar_t Buffer[4096];
- DWORD BuffSize = sizeof(wchar_t*) * 4096;
- if(RegQueryValueExW(registryKeyHandle, L"InstallLocation", 0, 0, reinterpret_cast<BYTE*>(Buffer), &BuffSize) == ERROR_SUCCESS)
- {
- mplayerPath = QString::fromUtf16(reinterpret_cast<const unsigned short*>(Buffer));
- }
- }
-
- if(!mplayerPath.isEmpty())
+ if(!lamexp_open_media_file(m_fileListModel->getFile(index).filePath()))
{
- QDir mplayerDir(mplayerPath);
- if(mplayerDir.exists())
- {
- for(int i = 0; i < 3; i++)
- {
- if(mplayerDir.exists(appNames[i]))
- {
- QProcess::startDetached(mplayerDir.absoluteFilePath(appNames[i]), QStringList() << QDir::toNativeSeparators(m_fileListModel->getFile(index).filePath()));
- return;
- }
- }
- }
+ qDebug("Player not found, falling back to default application...");
+ QDesktopServices::openUrl(QString("file:///").append(m_fileListModel->getFile(index).filePath()));
}
-
- QDesktopServices::openUrl(QString("file:///").append(m_fileListModel->getFile(index).filePath()));
}
/*
*/
void MainWindow::findFileContextActionTriggered(void)
{
- QModelIndex index = sourceFileView->currentIndex();
+ QModelIndex index = ui->sourceFileView->currentIndex();
if(index.isValid())
{
QString systemRootPath;
}
QStringList selectedFiles;
- tabWidget->setCurrentIndex(0);
+ ui->tabWidget->setCurrentIndex(0);
while(!m_delayedFileList->isEmpty())
{
(
QString selectedCsvFile;
- if(USE_NATIVE_FILE_DIALOG)
+ if(lamexp_themes_enabled())
{
selectedCsvFile = QFileDialog::getSaveFileName(this, tr("Save CSV file"), m_settings->mostRecentInputPath(), QString("%1 (*.csv)").arg(tr("CSV File")));
}
qWarning("exportToCsv: Unknown return code!");
}
}
- )
+ );
}
(
QString selectedCsvFile;
- if(USE_NATIVE_FILE_DIALOG)
+ if(lamexp_themes_enabled())
{
selectedCsvFile = QFileDialog::getOpenFileName(this, tr("Open CSV file"), m_settings->mostRecentInputPath(), QString("%1 (*.csv)").arg(tr("CSV File")));
}
qWarning("exportToCsv: Unknown return code!");
}
}
- )
+ );
}
/*
*/
void MainWindow::outputFolderViewClicked(const QModelIndex &index)
{
- if(outputFolderView->currentIndex() != index)
+ if(index.isValid() && (ui->outputFolderView->currentIndex() != index))
{
- outputFolderView->setCurrentIndex(index);
+ ui->outputFolderView->setCurrentIndex(index);
+ }
+
+ if(m_fileSystemModel && index.isValid())
+ {
+ QString selectedDir = m_fileSystemModel->filePath(index);
+ if(selectedDir.length() < 3) selectedDir.append(QDir::separator());
+ ui->outputFolderLabel->setText(QDir::toNativeSeparators(selectedDir));
+ ui->outputFolderLabel->setToolTip(ui->outputFolderLabel->text());
+ m_settings->outputDir(selectedDir);
+ }
+ else
+ {
+ ui->outputFolderLabel->setText(QDir::toNativeSeparators(m_settings->outputDir()));
+ ui->outputFolderLabel->setToolTip(ui->outputFolderLabel->text());
}
- QString selectedDir = m_fileSystemModel->filePath(index);
- if(selectedDir.length() < 3) selectedDir.append(QDir::separator());
- outputFolderLabel->setText(QDir::toNativeSeparators(selectedDir));
- m_settings->outputDir(selectedDir);
}
/*
*/
void MainWindow::gotoDesktopButtonClicked(void)
{
+ if(!m_fileSystemModel)
+ {
+ qWarning("File system model not initialized yet!");
+ return;
+ }
+
QString desktopPath = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation);
if(!desktopPath.isEmpty() && QDir(desktopPath).exists())
{
- outputFolderView->setCurrentIndex(m_fileSystemModel->index(desktopPath));
- outputFolderViewClicked(outputFolderView->currentIndex());
- outputFolderView->setFocus();
+ ui->outputFolderView->setCurrentIndex(m_fileSystemModel->index(desktopPath));
+ outputFolderViewClicked(ui->outputFolderView->currentIndex());
+ CENTER_CURRENT_OUTPUT_FOLDER_DELAYED;
}
else
{
- buttonGotoDesktop->setEnabled(false);
+ ui->buttonGotoDesktop->setEnabled(false);
}
}
*/
void MainWindow::gotoHomeFolderButtonClicked(void)
{
+ if(!m_fileSystemModel)
+ {
+ qWarning("File system model not initialized yet!");
+ return;
+ }
+
QString homePath = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
if(!homePath.isEmpty() && QDir(homePath).exists())
{
- outputFolderView->setCurrentIndex(m_fileSystemModel->index(homePath));
- outputFolderViewClicked(outputFolderView->currentIndex());
- outputFolderView->setFocus();
+ ui->outputFolderView->setCurrentIndex(m_fileSystemModel->index(homePath));
+ outputFolderViewClicked(ui->outputFolderView->currentIndex());
+ CENTER_CURRENT_OUTPUT_FOLDER_DELAYED;
}
else
{
- buttonGotoHome->setEnabled(false);
+ ui->buttonGotoHome->setEnabled(false);
}
}
*/
void MainWindow::gotoMusicFolderButtonClicked(void)
{
+ if(!m_fileSystemModel)
+ {
+ qWarning("File system model not initialized yet!");
+ return;
+ }
+
QString musicPath = QDesktopServices::storageLocation(QDesktopServices::MusicLocation);
if(!musicPath.isEmpty() && QDir(musicPath).exists())
{
- outputFolderView->setCurrentIndex(m_fileSystemModel->index(musicPath));
- outputFolderViewClicked(outputFolderView->currentIndex());
- outputFolderView->setFocus();
+ ui->outputFolderView->setCurrentIndex(m_fileSystemModel->index(musicPath));
+ outputFolderViewClicked(ui->outputFolderView->currentIndex());
+ CENTER_CURRENT_OUTPUT_FOLDER_DELAYED;
}
else
{
- buttonGotoMusic->setEnabled(false);
+ ui->buttonGotoMusic->setEnabled(false);
}
}
*/
void MainWindow::gotoFavoriteFolder(void)
{
+ if(!m_fileSystemModel)
+ {
+ qWarning("File system model not initialized yet!");
+ return;
+ }
+
QAction *item = dynamic_cast<QAction*>(QObject::sender());
if(item)
QDir path(item->data().toString());
if(path.exists())
{
- outputFolderView->setCurrentIndex(m_fileSystemModel->index(path.canonicalPath()));
- outputFolderViewClicked(outputFolderView->currentIndex());
- outputFolderView->setFocus();
+ ui->outputFolderView->setCurrentIndex(m_fileSystemModel->index(path.canonicalPath()));
+ outputFolderViewClicked(ui->outputFolderView->currentIndex());
+ CENTER_CURRENT_OUTPUT_FOLDER_DELAYED;
}
else
{
- MessageBeep(MB_ICONERROR);
+ lamexp_beep(lamexp_beep_error);
m_outputFolderFavoritesMenu->removeAction(item);
item->deleteLater();
}
{
ABORT_IF_BUSY;
- QDir basePath(m_fileSystemModel->fileInfo(outputFolderView->currentIndex()).absoluteFilePath());
+ if(!m_fileSystemModel)
+ {
+ qWarning("File system model not initialized yet!");
+ return;
+ }
+
+ QDir basePath(m_fileSystemModel->fileInfo(ui->outputFolderView->currentIndex()).absoluteFilePath());
QString suggestedName = tr("New Folder");
- if(!m_metaData->fileArtist().isEmpty() && !m_metaData->fileAlbum().isEmpty())
+ if(!m_metaData->artist().isEmpty() && !m_metaData->album().isEmpty())
{
- suggestedName = QString("%1 - %2").arg(m_metaData->fileArtist(), m_metaData->fileAlbum());
+ suggestedName = QString("%1 - %2").arg(m_metaData->artist(),m_metaData->album());
}
- else if(!m_metaData->fileArtist().isEmpty())
+ else if(!m_metaData->artist().isEmpty())
{
- suggestedName = m_metaData->fileArtist();
+ suggestedName = m_metaData->artist();
}
- else if(!m_metaData->fileAlbum().isEmpty())
+ else if(!m_metaData->album().isEmpty())
{
- suggestedName = m_metaData->fileAlbum();
+ suggestedName =m_metaData->album();
}
else
{
for(int i = 0; i < m_fileListModel->rowCount(); i++)
{
- AudioFileModel audioFile = m_fileListModel->getFile(m_fileListModel->index(i, 0));
- if(!audioFile.fileAlbum().isEmpty() || !audioFile.fileArtist().isEmpty())
+ const AudioFileModel &audioFile = m_fileListModel->getFile(m_fileListModel->index(i, 0));
+ const AudioFileModel_MetaInfo &fileMetaInfo = audioFile.metaInfo();
+
+ if(!fileMetaInfo.album().isEmpty() || !fileMetaInfo.artist().isEmpty())
{
- if(!audioFile.fileArtist().isEmpty() && !audioFile.fileAlbum().isEmpty())
+ if(!fileMetaInfo.artist().isEmpty() && !fileMetaInfo.album().isEmpty())
{
- suggestedName = QString("%1 - %2").arg(audioFile.fileArtist(), audioFile.fileAlbum());
+ suggestedName = QString("%1 - %2").arg(fileMetaInfo.artist(), fileMetaInfo.album());
}
- else if(!audioFile.fileArtist().isEmpty())
+ else if(!fileMetaInfo.artist().isEmpty())
{
- suggestedName = audioFile.fileArtist();
+ suggestedName = fileMetaInfo.artist();
}
- else if(!audioFile.fileAlbum().isEmpty())
+ else if(!fileMetaInfo.album().isEmpty())
{
- suggestedName = audioFile.fileAlbum();
+ suggestedName = fileMetaInfo.album();
}
break;
}
if(folderName.isEmpty())
{
- MessageBeep(MB_ICONERROR);
+ lamexp_beep(lamexp_beep_error);
continue;
}
QDir createdDir = basePath;
if(createdDir.cd(newFolder))
{
- outputFolderView->setCurrentIndex(m_fileSystemModel->index(createdDir.canonicalPath()));
- outputFolderViewClicked(outputFolderView->currentIndex());
- outputFolderView->setFocus();
+ QModelIndex newIndex = m_fileSystemModel->index(createdDir.canonicalPath());
+ ui->outputFolderView->setCurrentIndex(newIndex);
+ outputFolderViewClicked(newIndex);
+ CENTER_CURRENT_OUTPUT_FOLDER_DELAYED;
}
}
else
*/
void MainWindow::saveToSourceFolderChanged(void)
{
- m_settings->outputToSourceDir(saveToSourceFolderCheckBox->isChecked());
+ m_settings->outputToSourceDir(ui->saveToSourceFolderCheckBox->isChecked());
}
/*
*/
void MainWindow::prependRelativePathChanged(void)
{
- m_settings->prependRelativeSourcePath(prependRelativePathCheckBox->isChecked());
+ m_settings->prependRelativeSourcePath(ui->prependRelativePathCheckBox->isChecked());
}
/*
*/
void MainWindow::showFolderContextActionTriggered(void)
{
- QString path = QDir::toNativeSeparators(m_fileSystemModel->filePath(outputFolderView->currentIndex()));
+ if(!m_fileSystemModel)
+ {
+ qWarning("File system model not initialized yet!");
+ return;
+ }
+
+ QString path = QDir::toNativeSeparators(m_fileSystemModel->filePath(ui->outputFolderView->currentIndex()));
if(!path.endsWith(QDir::separator())) path.append(QDir::separator());
- ShellExecuteW(this->winId(), L"explore", QWCHAR(path), NULL, NULL, SW_SHOW);
+ lamexp_exec_shell(this, path, true);
}
/*
- * Add current folder to favorites
+ * Refresh the directory outline
*/
-void MainWindow::addFavoriteFolderActionTriggered(void)
+void MainWindow::refreshFolderContextActionTriggered(void)
{
- QString path = m_fileSystemModel->filePath(outputFolderView->currentIndex());
- QStringList favorites = m_settings->favoriteOutputFolders().split("|", QString::SkipEmptyParts);
+ //force re-initialization
+ QTimer::singleShot(0, this, SLOT(initOutputFolderModel()));
+}
- if(!favorites.contains(path, Qt::CaseInsensitive))
+/*
+ * Go one directory up
+ */
+void MainWindow::goUpFolderContextActionTriggered(void)
+{
+ QModelIndex current = ui->outputFolderView->currentIndex();
+ if(current.isValid())
{
- favorites.append(path);
+ QModelIndex parent = current.parent();
+ if(parent.isValid())
+ {
+
+ ui->outputFolderView->setCurrentIndex(parent);
+ outputFolderViewClicked(parent);
+ }
+ else
+ {
+ lamexp_beep(lamexp_beep_warning);
+ }
+ CENTER_CURRENT_OUTPUT_FOLDER_DELAYED;
+ }
+}
+
+/*
+ * Add current folder to favorites
+ */
+void MainWindow::addFavoriteFolderActionTriggered(void)
+{
+ QString path = m_fileSystemModel->filePath(ui->outputFolderView->currentIndex());
+ QStringList favorites = m_settings->favoriteOutputFolders().split("|", QString::SkipEmptyParts);
+
+ if(!favorites.contains(path, Qt::CaseInsensitive))
+ {
+ favorites.append(path);
while(favorites.count() > 6) favorites.removeFirst();
}
else
{
- MessageBeep(MB_ICONWARNING);
+ lamexp_beep(lamexp_beep_warning);
}
m_settings->favoriteOutputFolders(favorites.join("|"));
}
/*
+ * Output folder edit finished
+ */
+void MainWindow::outputFolderEditFinished(void)
+{
+ if(ui->outputFolderEdit->isHidden())
+ {
+ return; //Not currently in edit mode!
+ }
+
+ bool ok = false;
+
+ QString text = QDir::fromNativeSeparators(ui->outputFolderEdit->text().trimmed());
+ while(text.startsWith('"') || text.startsWith('/')) text = text.right(text.length() - 1).trimmed();
+ while(text.endsWith('"') || text.endsWith('/')) text = text.left(text.length() - 1).trimmed();
+
+ 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(':')))
+ {
+ text = QString("%1/%2").arg(QDir::fromNativeSeparators(ui->outputFolderLabel->text()), text);
+ }
+
+ if(text.length() == 2) text += "/"; /* "X:" => "X:/" */
+
+ while(text.length() > 2)
+ {
+ QFileInfo info(text);
+ if(info.exists() && info.isDir())
+ {
+ QModelIndex index = m_fileSystemModel->index(QFileInfo(info.canonicalFilePath()).absoluteFilePath());
+ if(index.isValid())
+ {
+ ok = true;
+ ui->outputFolderView->setCurrentIndex(index);
+ outputFolderViewClicked(index);
+ break;
+ }
+ }
+ else if(info.exists() && info.isFile())
+ {
+ QModelIndex index = m_fileSystemModel->index(QFileInfo(info.canonicalPath()).absoluteFilePath());
+ if(index.isValid())
+ {
+ ok = true;
+ ui->outputFolderView->setCurrentIndex(index);
+ outputFolderViewClicked(index);
+ break;
+ }
+ }
+
+ text = text.left(text.length() - 1).trimmed();
+ }
+
+ ui->outputFolderEdit->setVisible(false);
+ ui->outputFolderLabel->setVisible(true);
+ ui->outputFolderView->setEnabled(true);
+
+ if(!ok) lamexp_beep(lamexp_beep_error);
+ CENTER_CURRENT_OUTPUT_FOLDER_DELAYED;
+}
+
+/*
* Initialize file system model
*/
void MainWindow::initOutputFolderModel(void)
{
- QModelIndex previousIndex = outputFolderView->currentIndex();
- m_fileSystemModel->setRootPath(m_fileSystemModel->rootPath());
- QApplication::processEvents();
- outputFolderView->reset();
- outputFolderView->setCurrentIndex(previousIndex);
- m_OutputFolderViewInitialized = true;
+ if(m_outputFolderNoteBox->isHidden())
+ {
+ m_outputFolderNoteBox->show();
+ m_outputFolderNoteBox->repaint();
+ m_outputFolderViewInitCounter = 4;
+
+ if(m_fileSystemModel)
+ {
+ SET_MODEL(ui->outputFolderView, NULL);
+ LAMEXP_DELETE(m_fileSystemModel);
+ ui->outputFolderView->repaint();
+ }
+
+ 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)));
+
+ 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);
+
+ m_fileSystemModel->setRootPath("");
+ QModelIndex index = m_fileSystemModel->index(m_settings->outputDir());
+ if(index.isValid()) ui->outputFolderView->setCurrentIndex(index);
+ outputFolderViewClicked(ui->outputFolderView->currentIndex());
+ }
+
+ CENTER_CURRENT_OUTPUT_FOLDER_DELAYED;
+ QTimer::singleShot(125, this, SLOT(initOutputFolderModel_doAsync()));
+ }
+}
+
+/*
+ * Initialize file system model (do NOT call this one directly!)
+ */
+void MainWindow::initOutputFolderModel_doAsync(void)
+{
+ if(m_outputFolderViewInitCounter > 0)
+ {
+ m_outputFolderViewInitCounter--;
+ QTimer::singleShot(125, this, SLOT(initOutputFolderModel_doAsync()));
+ }
+ else
+ {
+ QTimer::singleShot(125, m_outputFolderNoteBox, SLOT(hide()));
+ ui->outputFolderView->setFocus();
+ }
+}
+
+/*
+ * Center current folder in view
+ */
+void MainWindow::centerOutputFolderModel(void)
+{
+ if(ui->outputFolderView->isVisible())
+ {
+ centerOutputFolderModel_doAsync();
+ QTimer::singleShot(125, this, SLOT(centerOutputFolderModel_doAsync()));
+ }
+}
+
+/*
+ * Center current folder in view (do NOT call this one directly!)
+ */
+void MainWindow::centerOutputFolderModel_doAsync(void)
+{
+ if(ui->outputFolderView->isVisible())
+ {
+ m_outputFolderViewCentering = true;
+ const QModelIndex index = ui->outputFolderView->currentIndex();
+ ui->outputFolderView->scrollTo(index, QAbstractItemView::PositionAtCenter);
+ ui->outputFolderView->setFocus();
+ }
+}
+
+/*
+ * File system model asynchronously loaded a dir
+ */
+void MainWindow::outputFolderDirectoryLoaded(const QString &path)
+{
+ if(m_outputFolderViewCentering)
+ {
+ CENTER_CURRENT_OUTPUT_FOLDER_DELAYED;
+ }
+}
+
+/*
+ * File system model inserted new items
+ */
+void MainWindow::outputFolderRowsInserted(const QModelIndex &parent, int start, int end)
+{
+ if(m_outputFolderViewCentering)
+ {
+ CENTER_CURRENT_OUTPUT_FOLDER_DELAYED;
+ }
+}
+
+/*
+ * 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;
+}
+
+/*
+ * 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:
+ outputFolderViewClicked(ui->outputFolderView->currentIndex());
+ 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();
+
+ if(sender == ui->outputFolderLabel)
+ {
+ switch(event->type())
+ {
+ case QEvent::MouseButtonPress:
+ if(mouseEvent && (mouseEvent->button() == Qt::LeftButton))
+ {
+ QString path = ui->outputFolderLabel->text();
+ if(!path.endsWith(QDir::separator())) path.append(QDir::separator());
+ lamexp_exec_shell(this, path, true);
+ }
+ break;
+ case QEvent::Enter:
+ ui->outputFolderLabel->setForegroundRole(QPalette::Link);
+ break;
+ case QEvent::Leave:
+ ui->outputFolderLabel->setForegroundRole(QPalette::WindowText);
+ break;
+ }
+ }
+
+ if((sender == ui->outputFoldersFovoritesLabel) || (sender == ui->outputFoldersEditorLabel) || (sender == ui->outputFoldersGoUpLabel))
+ {
+ const type_info &styleType = typeid(*qApp->style());
+ if((typeid(QPlastiqueStyle) == styleType) || (typeid(QWindowsStyle) == styleType))
+ {
+ 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);
+ }
+
+ if((event->type() == QEvent::MouseButtonRelease) && ui->outputFolderView->isEnabled() && (mouseEvent))
+ {
+ if(pos.x() <= sender->width() && pos.y() <= sender->height() && pos.x() >= 0 && pos.y() >= 0 && mouseEvent->button() != Qt::MidButton)
+ {
+ if(sender == ui->outputFoldersFovoritesLabel)
+ {
+ m_outputFolderFavoritesMenu->popup(sender->mapToGlobal(pos));
+ }
+ else if(sender == ui->outputFoldersEditorLabel)
+ {
+ 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)
+ {
+ QTimer::singleShot(0, this, SLOT(goUpFolderContextActionTriggered()));
+ }
+ else
+ {
+ THROW("Oups, this is not supposed to happen!");
+ }
+ }
+ }
+ }
}
// =========================================================
{
ABORT_IF_BUSY;
- const QModelIndex index = metaDataView->currentIndex();
+ const QModelIndex index = ui->metaDataView->currentIndex();
if(index.isValid())
{
if(index.row() == 4)
{
- m_settings->metaInfoPosition(m_metaData->filePosition());
+ m_settings->metaInfoPosition(m_metaData->position());
}
}
}
*/
void MainWindow::metaTagsEnabledChanged(void)
{
- m_settings->writeMetaTags(writeMetaDataCheckBox->isChecked());
+ m_settings->writeMetaTags(ui->writeMetaDataCheckBox->isChecked());
}
/*
*/
void MainWindow::playlistEnabledChanged(void)
{
- m_settings->createPlaylist(generatePlaylistCheckBox->isChecked());
+ m_settings->createPlaylist(ui->generatePlaylistCheckBox->isChecked());
}
// =========================================================
*/
void MainWindow::updateEncoder(int id)
{
+ /*qWarning("\nupdateEncoder(%d)", id);*/
+
m_settings->compressionEncoder(id);
+ const AbstractEncoderInfo *info = EncoderRegistry::getEncoderInfo(id);
- switch(m_settings->compressionEncoder())
+ //Update UI controls
+ ui->radioButtonModeQuality ->setEnabled(info->isModeSupported(SettingsModel::VBRMode));
+ ui->radioButtonModeAverageBitrate->setEnabled(info->isModeSupported(SettingsModel::ABRMode));
+ ui->radioButtonConstBitrate ->setEnabled(info->isModeSupported(SettingsModel::CBRMode));
+
+ //Initialize checkbox state
+ if(ui->radioButtonModeQuality->isEnabled()) ui->radioButtonModeQuality->setChecked(true);
+ else if(ui->radioButtonModeAverageBitrate->isEnabled()) ui->radioButtonModeAverageBitrate->setChecked(true);
+ else if(ui->radioButtonConstBitrate->isEnabled()) ui->radioButtonConstBitrate->setChecked(true);
+ else THROW("It appears that the encoder does not support *any* RC mode!");
+
+ //Apply current RC mode
+ const int currentRCMode = EncoderRegistry::loadEncoderMode(m_settings, id);
+ switch(currentRCMode)
{
- case SettingsModel::VorbisEncoder:
- radioButtonModeQuality->setEnabled(true);
- radioButtonModeAverageBitrate->setEnabled(true);
- radioButtonConstBitrate->setEnabled(false);
- if(radioButtonConstBitrate->isChecked()) radioButtonModeQuality->setChecked(true);
- sliderBitrate->setEnabled(true);
- break;
- case SettingsModel::AC3Encoder:
- radioButtonModeQuality->setEnabled(true);
- radioButtonModeQuality->setChecked(true);
- radioButtonModeAverageBitrate->setEnabled(false);
- radioButtonConstBitrate->setEnabled(true);
- sliderBitrate->setEnabled(true);
- break;
- case SettingsModel::FLACEncoder:
- radioButtonModeQuality->setEnabled(false);
- radioButtonModeQuality->setChecked(true);
- radioButtonModeAverageBitrate->setEnabled(false);
- radioButtonConstBitrate->setEnabled(false);
- sliderBitrate->setEnabled(true);
- break;
- case SettingsModel::PCMEncoder:
- radioButtonModeQuality->setEnabled(false);
- radioButtonModeQuality->setChecked(true);
- radioButtonModeAverageBitrate->setEnabled(false);
- radioButtonConstBitrate->setEnabled(false);
- sliderBitrate->setEnabled(false);
- break;
- case SettingsModel::AACEncoder:
- radioButtonModeQuality->setEnabled(true);
- radioButtonModeAverageBitrate->setEnabled(!m_fhgEncoderAvailable);
- if(m_fhgEncoderAvailable && radioButtonModeAverageBitrate->isChecked()) radioButtonConstBitrate->setChecked(true);
- radioButtonConstBitrate->setEnabled(true);
- sliderBitrate->setEnabled(true);
- break;
- case SettingsModel::DCAEncoder:
- radioButtonModeQuality->setEnabled(false);
- radioButtonModeAverageBitrate->setEnabled(false);
- radioButtonConstBitrate->setEnabled(true);
- radioButtonConstBitrate->setChecked(true);
- sliderBitrate->setEnabled(true);
- break;
- default:
- radioButtonModeQuality->setEnabled(true);
- radioButtonModeAverageBitrate->setEnabled(true);
- radioButtonConstBitrate->setEnabled(true);
- sliderBitrate->setEnabled(true);
- break;
+ 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;
+ default: THROW("updateEncoder(): Unknown rc-mode encountered!");
+ }
+
+ //Display encoder description
+ if(const char* description = info->description())
+ {
+ ui->labelEncoderInfo->setVisible(true);
+ ui->labelEncoderInfo->setText(tr("Current Encoder: %1").arg(QString::fromUtf8(description)));
+ }
+ else
+ {
+ ui->labelEncoderInfo->setVisible(false);
}
+ //Update RC mode!
updateRCMode(m_modeButtonGroup->checkedId());
}
*/
void MainWindow::updateRCMode(int id)
{
- m_settings->compressionRCMode(id);
+ /*qWarning("updateRCMode(%d)", id);*/
- switch(m_settings->compressionEncoder())
+ //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);
+
+ //Sanity check
+ if(!info->isModeSupported(id))
{
- case SettingsModel::MP3Encoder:
- switch(m_settings->compressionRCMode())
- {
- case SettingsModel::VBRMode:
- sliderBitrate->setMinimum(0);
- sliderBitrate->setMaximum(9);
- break;
- default:
- sliderBitrate->setMinimum(0);
- sliderBitrate->setMaximum(13);
- break;
- }
- break;
- case SettingsModel::VorbisEncoder:
- switch(m_settings->compressionRCMode())
- {
- case SettingsModel::VBRMode:
- sliderBitrate->setMinimum(-2);
- sliderBitrate->setMaximum(10);
- break;
- default:
- sliderBitrate->setMinimum(4);
- sliderBitrate->setMaximum(63);
- break;
- }
+ qWarning("Attempting to use an unsupported RC mode (%d) with current encoder (%d)!", id, currentEncoder);
+ ui->labelBitrate->setText("(ERROR)");
+ return;
+ }
+
+ //Update slider min/max values
+ if(valueCount > 0)
+ {
+ 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);
+ }
+
+ //Now update bitrate/quality value!
+ if(valueCount > 0)
+ {
+ const int currentValue = EncoderRegistry::loadEncoderValue(m_settings, currentEncoder, id);
+ ui->sliderBitrate->setValue(qBound(0, currentValue, valueCount-1));
+ updateBitrate(qBound(0, currentValue, valueCount-1));
+ }
+ else
+ {
+ ui->sliderBitrate->setValue(1);
+ updateBitrate(0);
+ }
+}
+
+/*
+ * Update bitrate
+ */
+void MainWindow::updateBitrate(int value)
+{
+ /*qWarning("updateBitrate(%d)", value);*/
+
+ //Load current encoder and RC mode
+ const int currentEncoder = m_encoderButtonGroup->checkedId();
+ const int currentRCMode = m_modeButtonGroup->checkedId();
+
+ //Fetch encoder info
+ const AbstractEncoderInfo *info = EncoderRegistry::getEncoderInfo(currentEncoder);
+ const int valueCount = info->valueCount(currentRCMode);
+
+ //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
+ if(valueCount > 0)
+ {
+ 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)));
break;
- case SettingsModel::AC3Encoder:
- switch(m_settings->compressionRCMode())
- {
- case SettingsModel::VBRMode:
- sliderBitrate->setMinimum(0);
- sliderBitrate->setMaximum(16);
- break;
- default:
- sliderBitrate->setMinimum(0);
- sliderBitrate->setMaximum(18);
- break;
- }
+ case AbstractEncoderInfo::TYPE_APPROX_BITRATE:
+ ui->labelBitrate->setText(QString("≈ %1 kbps").arg(QString::number(displayValue)));
break;
- case SettingsModel::AACEncoder:
- switch(m_settings->compressionRCMode())
- {
- case SettingsModel::VBRMode:
- sliderBitrate->setMinimum(0);
- sliderBitrate->setMaximum(20);
- break;
- default:
- sliderBitrate->setMinimum(4);
- sliderBitrate->setMaximum(63);
- break;
- }
+ case AbstractEncoderInfo::TYPE_QUALITY_LEVEL_INT:
+ ui->labelBitrate->setText(tr("Quality Level %1").arg(QString::number(displayValue)));
break;
- case SettingsModel::FLACEncoder:
- sliderBitrate->setMinimum(0);
- sliderBitrate->setMaximum(8);
+ case AbstractEncoderInfo::TYPE_QUALITY_LEVEL_FLT:
+ ui->labelBitrate->setText(tr("Quality Level %1").arg(QString().sprintf("%.2f", double(displayValue)/100.0)));
break;
- case SettingsModel::DCAEncoder:
- sliderBitrate->setMinimum(1);
- sliderBitrate->setMaximum(128);
+ case AbstractEncoderInfo::TYPE_COMPRESSION_LEVEL:
+ ui->labelBitrate->setText(tr("Compression %1").arg(QString::number(displayValue)));
break;
- case SettingsModel::PCMEncoder:
- sliderBitrate->setMinimum(0);
- sliderBitrate->setMaximum(2);
- sliderBitrate->setValue(1);
+ case AbstractEncoderInfo::TYPE_UNCOMPRESSED:
+ ui->labelBitrate->setText(tr("Uncompressed"));
break;
default:
- sliderBitrate->setMinimum(0);
- sliderBitrate->setMaximum(0);
+ THROW("Unknown display value type encountered!");
break;
}
-
- updateBitrate(sliderBitrate->value());
}
/*
- * Update bitrate
+ * Event for compression tab occurred
*/
-void MainWindow::updateBitrate(int value)
+void MainWindow::compressionTabEventOccurred(QWidget *sender, QEvent *event)
{
- m_settings->compressionBitrate(value);
+ static const QUrl helpUrl("http://lamexp.sourceforge.net/doc/FAQ.html#054010d9");
- switch(m_settings->compressionRCMode())
+ if((sender == ui->labelCompressionHelp) && (event->type() == QEvent::MouseButtonPress))
{
- case SettingsModel::VBRMode:
- switch(m_settings->compressionEncoder())
- {
- case SettingsModel::MP3Encoder:
- labelBitrate->setText(tr("Quality Level %1").arg(9 - value));
- break;
- case SettingsModel::VorbisEncoder:
- labelBitrate->setText(tr("Quality Level %1").arg(value));
- break;
- case SettingsModel::AACEncoder:
- labelBitrate->setText(tr("Quality Level %1").arg(QString().sprintf("%.2f", static_cast<double>(value * 5) / 100.0)));
- break;
- case SettingsModel::FLACEncoder:
- labelBitrate->setText(tr("Compression %1").arg(value));
- break;
- case SettingsModel::AC3Encoder:
- labelBitrate->setText(tr("Quality Level %1").arg(qMin(1024, qMax(0, value * 64))));
- break;
- case SettingsModel::PCMEncoder:
- labelBitrate->setText(tr("Uncompressed"));
- break;
- default:
- labelBitrate->setText(QString::number(value));
- break;
- }
- break;
- case SettingsModel::ABRMode:
- switch(m_settings->compressionEncoder())
- {
- case SettingsModel::MP3Encoder:
- labelBitrate->setText(QString("≈ %1 kbps").arg(SettingsModel::mp3Bitrates[value]));
- break;
- case SettingsModel::FLACEncoder:
- labelBitrate->setText(tr("Compression %1").arg(value));
- break;
- case SettingsModel::AC3Encoder:
- labelBitrate->setText(QString("≈ %1 kbps").arg(SettingsModel::ac3Bitrates[value]));
- break;
- case SettingsModel::PCMEncoder:
- labelBitrate->setText(tr("Uncompressed"));
- break;
- default:
- labelBitrate->setText(QString("≈ %1 kbps").arg(qMin(500, value * 8)));
- break;
- }
- break;
- default:
- switch(m_settings->compressionEncoder())
+ QDesktopServices::openUrl(helpUrl);
+ }
+ else if((sender == ui->labelResetEncoders) && (event->type() == QEvent::MouseButtonPress))
+ {
+ if(m_settings->soundsEnabled())
{
- case SettingsModel::MP3Encoder:
- labelBitrate->setText(QString("%1 kbps").arg(SettingsModel::mp3Bitrates[value]));
- break;
- case SettingsModel::FLACEncoder:
- labelBitrate->setText(tr("Compression %1").arg(value));
- break;
- case SettingsModel::AC3Encoder:
- labelBitrate->setText(QString("%1 kbps").arg(SettingsModel::ac3Bitrates[value]));
- break;
- case SettingsModel::DCAEncoder:
- labelBitrate->setText(QString("%1 kbps").arg(value * 32));
- break;
- case SettingsModel::PCMEncoder:
- labelBitrate->setText(tr("Uncompressed"));
- break;
- default:
- labelBitrate->setText(QString("%1 kbps").arg(qMin(500, value * 8)));
- break;
+ lamexp_play_sound(IDR_WAVE_BLAST, true);
}
- break;
+
+ EncoderRegistry::resetAllEncoders(m_settings);
+ m_settings->compressionEncoder(SettingsModel::MP3Encoder);
+ ui->radioButtonEncoderMP3->setChecked(true);
+ QTimer::singleShot(0, this, SLOT(updateEncoder()));
}
}
switch(value)
{
- case 4:
- text = tr("Best Quality (Very Slow)");
- break;
case 3:
- text = tr("High Quality (Recommended)");
+ text = tr("Best Quality (Slow)");
break;
case 2:
- text = tr("Average Quality (Default)");
+ text = tr("High Quality (Recommended)");
break;
case 1:
- text = tr("Low Quality (Fast)");
+ text = tr("Acceptable Quality (Fast)");
break;
case 0:
text = tr("Poor Quality (Very Fast)");
if(!text.isEmpty())
{
m_settings->lameAlgoQuality(value);
- labelLameAlgoQuality->setText(text);
+ ui->labelLameAlgoQuality->setText(text);
}
- bool warning = (value == 0), notice = (value == 4);
- labelLameAlgoQualityWarning->setVisible(warning);
- labelLameAlgoQualityWarningIcon->setVisible(warning);
- labelLameAlgoQualityNotice->setVisible(notice);
- labelLameAlgoQualityNoticeIcon->setVisible(notice);
- labelLameAlgoQualitySpacer->setVisible(warning || notice);
+ bool warning = (value == 0), notice = (value == 3);
+ ui->labelLameAlgoQualityWarning->setVisible(warning);
+ ui->labelLameAlgoQualityWarningIcon->setVisible(warning);
+ ui->labelLameAlgoQualityNotice->setVisible(notice);
+ ui->labelLameAlgoQualityNoticeIcon->setVisible(notice);
+ ui->labelLameAlgoQualitySpacer->setVisible(warning || notice);
}
/*
*/
void MainWindow::bitrateManagementMinChanged(int value)
{
- if(value > spinBoxBitrateManagementMax->value())
+ if(value > ui->spinBoxBitrateManagementMax->value())
{
- spinBoxBitrateManagementMin->setValue(spinBoxBitrateManagementMax->value());
- m_settings->bitrateManagementMinRate(spinBoxBitrateManagementMax->value());
+ ui->spinBoxBitrateManagementMin->setValue(ui->spinBoxBitrateManagementMax->value());
+ m_settings->bitrateManagementMinRate(ui->spinBoxBitrateManagementMax->value());
}
else
{
*/
void MainWindow::bitrateManagementMaxChanged(int value)
{
- if(value < spinBoxBitrateManagementMin->value())
+ if(value < ui->spinBoxBitrateManagementMin->value())
{
- spinBoxBitrateManagementMax->setValue(spinBoxBitrateManagementMin->value());
- m_settings->bitrateManagementMaxRate(spinBoxBitrateManagementMin->value());
+ ui->spinBoxBitrateManagementMax->setValue(ui->spinBoxBitrateManagementMin->value());
+ m_settings->bitrateManagementMaxRate(ui->spinBoxBitrateManagementMin->value());
}
else
{
m_settings->aftenFastBitAllocation(checked);
}
+
+/*
+ * Opus encoder settings changed
+ */
+void MainWindow::opusSettingsChanged(void)
+{
+ m_settings->opusFramesize(ui->comboBoxOpusFramesize->currentIndex());
+ m_settings->opusComplexity(ui->spinBoxOpusComplexity->value());
+ m_settings->opusDisableResample(ui->checkBoxOpusDisableResample->isChecked());
+}
+
/*
* Normalization filter enabled changed
*/
*/
void MainWindow::normalizationModeChanged(int mode)
{
- m_settings->normalizationFilterEqualizationMode(mode);
+ m_settings->normalizationFilterEQMode(mode);
}
/*
void MainWindow::toneAdjustBassChanged(double value)
{
m_settings->toneAdjustBass(static_cast<int>(value * 100.0));
- spinBoxToneAdjustBass->setPrefix((value > 0) ? "+" : QString());
+ ui->spinBoxToneAdjustBass->setPrefix((value > 0) ? "+" : QString());
}
/*
void MainWindow::toneAdjustTrebleChanged(double value)
{
m_settings->toneAdjustTreble(static_cast<int>(value * 100.0));
- spinBoxToneAdjustTreble->setPrefix((value > 0) ? "+" : QString());
+ ui->spinBoxToneAdjustTreble->setPrefix((value > 0) ? "+" : QString());
}
/*
*/
void MainWindow::toneAdjustTrebleReset(void)
{
- spinBoxToneAdjustBass->setValue(m_settings->toneAdjustBassDefault());
- spinBoxToneAdjustTreble->setValue(m_settings->toneAdjustTrebleDefault());
- toneAdjustBassChanged(spinBoxToneAdjustBass->value());
- toneAdjustTrebleChanged(spinBoxToneAdjustTreble->value());
+ ui->spinBoxToneAdjustBass->setValue(m_settings->toneAdjustBassDefault());
+ ui->spinBoxToneAdjustTreble->setValue(m_settings->toneAdjustTrebleDefault());
+ toneAdjustBassChanged(ui->spinBoxToneAdjustBass->value());
+ toneAdjustTrebleChanged(ui->spinBoxToneAdjustTreble->value());
}
/*
*/
void MainWindow::customParamsChanged(void)
{
- lineEditCustomParamLAME->setText(lineEditCustomParamLAME->text().simplified());
- lineEditCustomParamOggEnc->setText(lineEditCustomParamOggEnc->text().simplified());
- lineEditCustomParamNeroAAC->setText(lineEditCustomParamNeroAAC->text().simplified());
- lineEditCustomParamFLAC->setText(lineEditCustomParamFLAC->text().simplified());
- lineEditCustomParamAften->setText(lineEditCustomParamAften->text().simplified());
+ 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());
bool customParamsUsed = false;
- if(!lineEditCustomParamLAME->text().isEmpty()) customParamsUsed = true;
- if(!lineEditCustomParamOggEnc->text().isEmpty()) customParamsUsed = true;
- if(!lineEditCustomParamNeroAAC->text().isEmpty()) customParamsUsed = true;
- if(!lineEditCustomParamFLAC->text().isEmpty()) customParamsUsed = true;
- if(!lineEditCustomParamAften->text().isEmpty()) customParamsUsed = true;
+ 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;
- labelCustomParamsIcon->setVisible(customParamsUsed);
- labelCustomParamsText->setVisible(customParamsUsed);
- labelCustomParamsSpacer->setVisible(customParamsUsed);
+ ui->labelCustomParamsIcon->setVisible(customParamsUsed);
+ ui->labelCustomParamsText->setVisible(customParamsUsed);
+ ui->labelCustomParamsSpacer->setVisible(customParamsUsed);
- m_settings->customParametersLAME(lineEditCustomParamLAME->text());
- m_settings->customParametersOggEnc(lineEditCustomParamOggEnc->text());
- m_settings->customParametersAacEnc(lineEditCustomParamNeroAAC->text());
- m_settings->customParametersFLAC(lineEditCustomParamFLAC->text());
- m_settings->customParametersAften(lineEditCustomParamAften->text());
+ 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());
}
-
/*
* Rename output files enabled changed
*/
*/
void MainWindow::renameOutputPatternChanged(void)
{
- QString temp = lineEditRenamePattern->text().simplified();
- lineEditRenamePattern->setText(temp.isEmpty() ? m_settings->renameOutputFilesPatternDefault() : temp);
- m_settings->renameOutputFilesPattern(lineEditRenamePattern->text());
+ QString temp = ui->lineEditRenamePattern->text().simplified();
+ ui->lineEditRenamePattern->setText(temp.isEmpty() ? m_settings->renameOutputFilesPatternDefault() : temp);
+ m_settings->renameOutputFilesPattern(ui->lineEditRenamePattern->text());
}
/*
* Rename output files patterm changed
*/
-void MainWindow::renameOutputPatternChanged(const QString &text)
+void MainWindow::renameOutputPatternChanged(const QString &text, bool silent)
{
QString pattern(text.simplified());
pattern.replace("<Year>", "2001", Qt::CaseInsensitive);
pattern.replace("<Comment>", "Encoded by LameXP", Qt::CaseInsensitive);
- if(pattern.compare(lamexp_clean_filename(pattern)))
+ const QString patternClean = lamexp_clean_filename(pattern);
+
+ if(pattern.compare(patternClean))
{
- if(lineEditRenamePattern->palette().color(QPalette::Text) != Qt::red)
+ if(ui->lineEditRenamePattern->palette().color(QPalette::Text) != Qt::red)
{
- MessageBeep(MB_ICONERROR);
- SET_TEXT_COLOR(lineEditRenamePattern, Qt::red);
+ if(!silent) lamexp_beep(lamexp_beep_error);
+ SET_TEXT_COLOR(ui->lineEditRenamePattern, Qt::red);
}
}
else
{
- if(lineEditRenamePattern->palette().color(QPalette::Text) != Qt::black)
+ if(ui->lineEditRenamePattern->palette() != QPalette())
{
- MessageBeep(MB_ICONINFORMATION);
- SET_TEXT_COLOR(lineEditRenamePattern, Qt::black);
+ if(!silent) lamexp_beep(lamexp_beep_info);
+ ui->lineEditRenamePattern->setPalette(QPalette());
}
}
- labelRanameExample->setText(lamexp_clean_filename(pattern));
+ ui->labelRanameExample->setText(patternClean);
}
/*
{
if(text.compare("reset", Qt::CaseInsensitive) == 0)
{
- lineEditRenamePattern->setText(m_settings->renameOutputFilesPatternDefault());
+ ui->lineEditRenamePattern->setText(m_settings->renameOutputFilesPatternDefault());
return;
}
*/
void MainWindow::updateMaximumInstances(int value)
{
- labelMaxInstances->setText(tr("%1 Instance(s)").arg(QString::number(value)));
- m_settings->maximumInstances(checkBoxAutoDetectInstances->isChecked() ? NULL : value);
+ ui->labelMaxInstances->setText(tr("%n Instance(s)", "", value));
+ m_settings->maximumInstances(ui->checkBoxAutoDetectInstances->isChecked() ? NULL : value);
}
/*
*/
void MainWindow::autoDetectInstancesChanged(bool checked)
{
- m_settings->maximumInstances(checked ? NULL : sliderMaxInstances->value());
+ m_settings->maximumInstances(checked ? NULL : ui->sliderMaxInstances->value());
}
/*
{
QString newTempFolder;
- if(USE_NATIVE_FILE_DIALOG)
+ if(lamexp_themes_enabled())
{
newTempFolder = QFileDialog::getExistingDirectory(this, QString(), m_settings->customTempPath());
}
if(writeTest.open(QIODevice::ReadWrite))
{
writeTest.remove();
- lineEditCustomTempFolder->setText(QDir::toNativeSeparators(newTempFolder));
+ ui->lineEditCustomTempFolder->setText(QDir::toNativeSeparators(newTempFolder));
}
else
{
}
/*
+ * Help for custom parameters was requested
+ */
+void MainWindow::customParamsHelpRequested(QWidget *obj, QEvent *event)
+{
+ if(event->type() != QEvent::MouseButtonRelease)
+ {
+ return;
+ }
+
+ if(QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(event))
+ {
+ QPoint pos = mouseEvent->pos();
+ if(!(pos.x() <= obj->width() && pos.y() <= obj->height() && pos.x() >= 0 && pos.y() >= 0 && mouseEvent->button() != Qt::MidButton))
+ {
+ return;
+ }
+ }
+
+ if(obj == ui->helpCustomParamLAME) showCustomParamsHelpScreen("lame.exe", "--longhelp");
+ else if(obj == ui->helpCustomParamOggEnc) showCustomParamsHelpScreen("oggenc2.exe", "--help");
+ else if(obj == ui->helpCustomParamNeroAAC)
+ {
+ switch(EncoderRegistry::getAacEncoder())
+ {
+ case SettingsModel::AAC_ENCODER_QAAC: showCustomParamsHelpScreen("qaac.exe", "--help"); break;
+ case SettingsModel::AAC_ENCODER_FHG : showCustomParamsHelpScreen("fhgaacenc.exe", ""); break;
+ case SettingsModel::AAC_ENCODER_NERO: showCustomParamsHelpScreen("neroAacEnc.exe", "-help"); break;
+ default: lamexp_beep(lamexp_beep_error); break;
+ }
+ }
+ else if(obj == ui->helpCustomParamFLAC) showCustomParamsHelpScreen("flac.exe", "--help");
+ else if(obj == ui->helpCustomParamAften) showCustomParamsHelpScreen("aften.exe", "-h");
+ else if(obj == ui->helpCustomParamOpus) showCustomParamsHelpScreen("opusenc.exe", "--help");
+ else lamexp_beep(lamexp_beep_error);
+}
+
+/*
+ * Show help for custom parameters
+ */
+void MainWindow::showCustomParamsHelpScreen(const QString &toolName, const QString &command)
+{
+ const QString binary = lamexp_lookup_tool(toolName);
+ if(binary.isEmpty())
+ {
+ lamexp_beep(lamexp_beep_error);
+ qWarning("customParamsHelpRequested: Binary could not be found!");
+ return;
+ }
+
+ QProcess process;
+ lamexp_init_process(process, QFileInfo(binary).absolutePath());
+
+ process.start(binary, command.isEmpty() ? QStringList() : QStringList() << command);
+
+ qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
+
+ if(process.waitForStarted(15000))
+ {
+ qApp->processEvents();
+ process.waitForFinished(15000);
+ }
+
+ if(process.state() != QProcess::NotRunning)
+ {
+ process.kill();
+ process.waitForFinished(-1);
+ }
+
+ qApp->restoreOverrideCursor();
+ QStringList output; bool spaceFlag = true;
+
+ while(process.canReadLine())
+ {
+ QString temp = QString::fromUtf8(process.readLine());
+ TRIM_STRING_RIGHT(temp);
+ if(temp.isEmpty())
+ {
+ if(!spaceFlag) { output << temp; spaceFlag = true; }
+ }
+ else
+ {
+ output << temp; spaceFlag = false;
+ }
+ }
+
+ if(output.count() < 1)
+ {
+ qWarning("Empty output, cannot show help screen!");
+ lamexp_beep(lamexp_beep_error);
+ }
+
+ LogViewDialog *dialog = new LogViewDialog(this);
+ TEMP_HIDE_DROPBOX( dialog->exec(output); );
+ LAMEXP_DELETE(dialog);
+}
+
+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)
+ {
+ ui->radioButtonOverwriteModeKeepBoth->setChecked(m_settings->overwriteMode() == SettingsModel::Overwrite_KeepBoth);
+ ui->radioButtonOverwriteModeSkipFile->setChecked(m_settings->overwriteMode() == SettingsModel::Overwrite_SkipFile);
+ return;
+ }
+ }
+
+ m_settings->overwriteMode(id);
+}
+
+/*
* Reset all advanced options to their defaults
*/
void MainWindow::resetAdvancedOptionsButtonClicked(void)
{
- sliderLameAlgoQuality->setValue(m_settings->lameAlgoQualityDefault());
- spinBoxBitrateManagementMin->setValue(m_settings->bitrateManagementMinRateDefault());
- spinBoxBitrateManagementMax->setValue(m_settings->bitrateManagementMaxRateDefault());
- spinBoxNormalizationFilter->setValue(static_cast<double>(m_settings->normalizationFilterMaxVolumeDefault()) / 100.0);
- spinBoxToneAdjustBass->setValue(static_cast<double>(m_settings->toneAdjustBassDefault()) / 100.0);
- spinBoxToneAdjustTreble->setValue(static_cast<double>(m_settings->toneAdjustTrebleDefault()) / 100.0);
- spinBoxAftenSearchSize->setValue(m_settings->aftenExponentSearchSizeDefault());
- comboBoxMP3ChannelMode->setCurrentIndex(m_settings->lameChannelModeDefault());
- comboBoxSamplingRate->setCurrentIndex(m_settings->samplingRateDefault());
- comboBoxAACProfile->setCurrentIndex(m_settings->aacEncProfileDefault());
- comboBoxAftenCodingMode->setCurrentIndex(m_settings->aftenAudioCodingModeDefault());
- comboBoxAftenDRCMode->setCurrentIndex(m_settings->aftenDynamicRangeCompressionDefault());
- comboBoxNormalizationMode->setCurrentIndex(m_settings->normalizationFilterEqualizationModeDefault());
- while(checkBoxBitrateManagement->isChecked() != m_settings->bitrateManagementEnabledDefault()) checkBoxBitrateManagement->click();
- while(checkBoxNeroAAC2PassMode->isChecked() != m_settings->neroAACEnable2PassDefault()) checkBoxNeroAAC2PassMode->click();
- while(checkBoxNormalizationFilter->isChecked() != m_settings->normalizationFilterEnabledDefault()) checkBoxNormalizationFilter->click();
- while(checkBoxAutoDetectInstances->isChecked() != (m_settings->maximumInstancesDefault() < 1)) checkBoxAutoDetectInstances->click();
- while(checkBoxUseSystemTempFolder->isChecked() == m_settings->customTempPathEnabledDefault()) checkBoxUseSystemTempFolder->click();
- while(checkBoxAftenFastAllocation->isChecked() != m_settings->aftenFastBitAllocationDefault()) checkBoxAftenFastAllocation->click();
- while(checkBoxRenameOutput->isChecked() != m_settings->renameOutputFilesEnabledDefault()) checkBoxRenameOutput->click();
- while(checkBoxForceStereoDownmix->isChecked() != m_settings->forceStereoDownmixDefault()) checkBoxForceStereoDownmix->click();
- lineEditCustomParamLAME->setText(m_settings->customParametersLAMEDefault());
- lineEditCustomParamOggEnc->setText(m_settings->customParametersOggEncDefault());
- lineEditCustomParamNeroAAC->setText(m_settings->customParametersAacEncDefault());
- lineEditCustomParamFLAC->setText(m_settings->customParametersFLACDefault());
- lineEditCustomTempFolder->setText(QDir::toNativeSeparators(m_settings->customTempPathDefault()));
- lineEditRenamePattern->setText(m_settings->renameOutputFilesPatternDefault());
+ if(m_settings->soundsEnabled())
+ {
+ lamexp_play_sound(IDR_WAVE_BLAST, true);
+ }
+
+ ui->sliderLameAlgoQuality->setValue(m_settings->lameAlgoQualityDefault());
+ ui->spinBoxBitrateManagementMin->setValue(m_settings->bitrateManagementMinRateDefault());
+ ui->spinBoxBitrateManagementMax->setValue(m_settings->bitrateManagementMaxRateDefault());
+ ui->spinBoxNormalizationFilter->setValue(static_cast<double>(m_settings->normalizationFilterMaxVolumeDefault()) / 100.0);
+ 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->comboBoxNormalizationMode->setCurrentIndex(m_settings->normalizationFilterEQModeDefault());
+ 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->checkBoxNormalizationFilter, m_settings->normalizationFilterEnabledDefault());
+ 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());
+
+ ui->lineEditCustomParamLAME ->setText(m_settings->customParametersLAMEDefault());
+ ui->lineEditCustomParamOggEnc ->setText(m_settings->customParametersOggEncDefault());
+ ui->lineEditCustomParamNeroAAC->setText(m_settings->customParametersAacEncDefault());
+ 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());
+
+ 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();
+
customParamsChanged();
- scrollArea->verticalScrollBar()->setValue(0);
+ ui->scrollArea->verticalScrollBar()->setValue(0);
}
// =========================================================
{
if(tryASAP && !m_delayedFileTimer->isActive())
{
- qDebug("Received file: %s", filePath.toUtf8().constData());
+ qDebug("Received file: %s", QUTF8(filePath));
m_delayedFileList->append(filePath);
QTimer::singleShot(0, this, SLOT(handleDelayedFiles()));
}
m_delayedFileTimer->stop();
- qDebug("Received file: %s", filePath.toUtf8().constData());
+ qDebug("Received file: %s", QUTF8(filePath));
m_delayedFileList->append(filePath);
m_delayedFileTimer->start(5000);
}