X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2FDialog_MainWindow.cpp;h=cafecd92769321a83525e31256ab62bdffbe579c;hb=02b7cdc3e16050dc055cc3d50cb758c7c514e266;hp=efc3989aa0d78ecef49bee5d0c78723ffc1ab6ae;hpb=613c9721a7a998fd735ab982f24eea5142fc5372;p=lamexp%2FLameXP.git diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index efc3989a..cafecd92 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -67,13 +67,16 @@ //System includes #include +#include //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("%2").arg(URL).arg(URL) -#define TEMP_HIDE_DROPBOX(CMD) { bool __dropBoxVisible = m_dropBox->isVisible(); if(__dropBoxVisible) m_dropBox->hide(); CMD; if(__dropBoxVisible) m_dropBox->show(); } +#define LINK(URL) QString("%2").arg(URL).arg(QString(URL).replace("-", "−")) +#define FSLINK(PATH) QString("%2").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)) //////////////////////////////////////////////////////////// // Constructor @@ -86,6 +89,7 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S 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_accepted(false), m_firstTimeShown(true), m_OutputFolderViewInitialized(false) @@ -111,6 +115,7 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S sourceFileView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); sourceFileView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); sourceFileView->setContextMenuPolicy(Qt::CustomContextMenu); + sourceFileView->viewport()->installEventFilter(this); m_dropNoteLabel = new QLabel(sourceFileView); m_dropNoteLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); SET_FONT_BOLD(m_dropNoteLabel, true); @@ -130,6 +135,8 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S 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(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())); @@ -147,6 +154,7 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S 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))); @@ -161,11 +169,16 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S 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()); + refreshFavorites(); //Setup "Meta Data" tab m_metaInfoModel = new MetaInfoModel(m_metaData, 6); @@ -194,10 +207,10 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S m_modeButtonGroup->addButton(radioButtonModeQuality, SettingsModel::VBRMode); m_modeButtonGroup->addButton(radioButtonModeAverageBitrate, SettingsModel::ABRMode); m_modeButtonGroup->addButton(radioButtonConstBitrate, SettingsModel::CBRMode); - radioButtonEncoderAAC->setEnabled(m_neroEncoderAvailable); + radioButtonEncoderAAC->setEnabled(m_neroEncoderAvailable || m_fhgEncoderAvailable); radioButtonEncoderMP3->setChecked(m_settings->compressionEncoder() == SettingsModel::MP3Encoder); radioButtonEncoderVorbis->setChecked(m_settings->compressionEncoder() == SettingsModel::VorbisEncoder); - radioButtonEncoderAAC->setChecked((m_settings->compressionEncoder() == SettingsModel::AACEncoder) && m_neroEncoderAvailable); + radioButtonEncoderAAC->setChecked((m_settings->compressionEncoder() == SettingsModel::AACEncoder) && (m_neroEncoderAvailable || m_fhgEncoderAvailable)); radioButtonEncoderAC3->setChecked(m_settings->compressionEncoder() == SettingsModel::AC3Encoder); radioButtonEncoderFLAC->setChecked(m_settings->compressionEncoder() == SettingsModel::FLACEncoder); radioButtonEncoderPCM->setChecked(m_settings->compressionEncoder() == SettingsModel::PCMEncoder); @@ -221,22 +234,25 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S spinBoxAftenSearchSize->setValue(m_settings->aftenExponentSearchSize()); comboBoxMP3ChannelMode->setCurrentIndex(m_settings->lameChannelMode()); comboBoxSamplingRate->setCurrentIndex(m_settings->samplingRate()); - comboBoxNeroAACProfile->setCurrentIndex(m_settings->neroAACProfile()); + 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); lineEditCustomParamLAME->setText(m_settings->customParametersLAME()); lineEditCustomParamOggEnc->setText(m_settings->customParametersOggEnc()); - lineEditCustomParamNeroAAC->setText(m_settings->customParametersNeroAAC()); + lineEditCustomParamNeroAAC->setText(m_settings->customParametersAacEnc()); lineEditCustomParamFLAC->setText(m_settings->customParametersFLAC()); lineEditCustomParamAften->setText(m_settings->customParametersAften()); lineEditCustomTempFolder->setText(QDir::toNativeSeparators(m_settings->customTempPath())); - while(checkBoxRenameOutput->isChecked() != m_settings->renameOutputFilesEnabled()) checkBoxRenameOutput->click(); lineEditRenamePattern->setText(m_settings->renameOutputFilesPattern()); connect(sliderLameAlgoQuality, SIGNAL(valueChanged(int)), this, SLOT(updateLameAlgoQuality(int))); connect(checkBoxBitrateManagement, SIGNAL(clicked(bool)), this, SLOT(bitrateManagementEnabledChanged(bool))); @@ -245,13 +261,14 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S 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(comboBoxNeroAACProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(neroAACProfileChanged(int))); + 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())); @@ -270,6 +287,7 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S 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()); @@ -342,12 +360,15 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S 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))); @@ -446,6 +467,7 @@ MainWindow::~MainWindow(void) LAMEXP_DELETE(m_encoderButtonGroup); LAMEXP_DELETE(m_encoderButtonGroup); LAMEXP_DELETE(m_sourceFilesContextMenu); + LAMEXP_DELETE(m_outputFolderFavoritesMenu); LAMEXP_DELETE(m_dropBox); } @@ -474,19 +496,19 @@ void MainWindow::addFiles(const QStringList &files) if(analyzer->filesDenied()) { - QMessageBox::warning(this, tr("Access Denied"), QString("%1
%2
").arg(tr("%1 file(s) have been rejected, because read access was not granted!").arg(analyzer->filesDenied()), tr("This usually means the file is locked by another process."))); + QMessageBox::warning(this, tr("Access Denied"), QString("%1
%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.")))); } if(analyzer->filesDummyCDDA()) { - QMessageBox::warning(this, tr("CDDA Files"), QString("%1

%2
%3
").arg(tr("%1 file(s) have been rejected, because they are dummy CDDA files!").arg(analyzer->filesDummyCDDA()), tr("Sorry, LameXP cannot extract audio tracks from an Audio−CD at present."), tr("We recommend using %1 for that purpose.").arg("Exact Audio Copy"))); + QMessageBox::warning(this, tr("CDDA Files"), QString("%1

%2
%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("Exact Audio Copy")))); } if(analyzer->filesCueSheet()) { - QMessageBox::warning(this, tr("Cue Sheet"), QString("%1
%2
").arg(tr("%1 file(s) have been rejected, because they appear to be Cue Sheet images!").arg(analyzer->filesCueSheet()), tr("Please use LameXP's Cue Sheet wizard for importing Cue Sheet files."))); + QMessageBox::warning(this, tr("Cue Sheet"), QString("%1
%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.")))); } if(analyzer->filesRejected()) { - QMessageBox::warning(this, tr("Files Rejected"), QString("%1
%2
").arg(tr("%1 file(s) have been rejected, because the file format could not be recognized!").arg(analyzer->filesRejected()), tr("This usually means the file is damaged or the file format is not supported."))); + QMessageBox::warning(this, tr("Files Rejected"), QString("%1
%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.")))); } LAMEXP_DELETE(analyzer); @@ -519,7 +541,7 @@ void MainWindow::addFolder(const QString &path, bool recursive, bool delayed) } QDir currentDir(folderInfoList.takeFirst().canonicalFilePath()); - QFileInfoList fileInfoList = currentDir.entryInfoList(QDir::Files); + QFileInfoList fileInfoList = currentDir.entryInfoList(QDir::Files | QDir::NoSymLinks); while(!fileInfoList.isEmpty()) { @@ -552,85 +574,6 @@ void MainWindow::addFolder(const QString &path, bool recursive, bool delayed) } /* - * Download and install WMA Decoder component - */ -//bool MainWindow::installWMADecoder(void) -//{ -// static const char *download_url = "http://www.nch.com.au/components/wmawav.exe"; -// static const char *download_hash = "52a3b0e6690faf3f830c336d3c0eadfb7a4e9bc6"; -// -// bool bResult = false; -// -// QString binaryWGet = lamexp_lookup_tool("wget.exe"); -// QString binaryElevator = lamexp_lookup_tool("elevator.exe"); -// -// if(binaryWGet.isEmpty() || binaryElevator.isEmpty()) -// { -// throw "Required binary is not available!"; -// } -// -// while(true) -// { -// QString setupFile = QString("%1/%2.exe").arg(lamexp_temp_folder2(), lamexp_rand_str()); -// -// QProcess process; -// process.setWorkingDirectory(QFileInfo(setupFile).absolutePath()); -// -// QEventLoop loop; -// connect(&process, SIGNAL(error(QProcess::ProcessError)), &loop, SLOT(quit())); -// connect(&process, SIGNAL(finished(int, QProcess::ExitStatus)), &loop, SLOT(quit())); -// -// process.start(binaryWGet, QStringList() << "-O" << QFileInfo(setupFile).fileName() << download_url); -// m_banner->show(tr("Downloading WMA Decoder Setup, please wait..."), &loop); -// -// if(process.exitCode() != 0 || QFileInfo(setupFile).size() < 10240) -// { -// QFile::remove(setupFile); -// if(QMessageBox::critical(this, tr("Download Failed"), tr("Failed to download the WMA Decoder setup. Check your internet connection!"), tr("Try Again"), tr("Cancel")) == 0) -// { -// continue; -// } -// break; -// } -// -// QFile setupFileContent(setupFile); -// QCryptographicHash setupFileHash(QCryptographicHash::Sha1); -// -// setupFileContent.open(QIODevice::ReadOnly); -// if(setupFileContent.isOpen() && setupFileContent.isReadable()) -// { -// setupFileHash.addData(setupFileContent.readAll()); -// setupFileContent.close(); -// } -// -// if(_stricmp(setupFileHash.result().toHex().constData(), download_hash)) -// { -// qWarning("Hash miscompare:\n Expected %s\n Detected %s\n", download_hash, setupFileHash.result().toHex().constData()); -// QFile::remove(setupFile); -// if(QMessageBox::critical(this, tr("Download Failed"), tr("The download seems to be corrupted. Please try again!"), tr("Try Again"), tr("Cancel")) == 0) -// { -// continue; -// } -// break; -// } -// -// QApplication::setOverrideCursor(Qt::WaitCursor); -// process.start(binaryElevator, QStringList() << QString("/exec=%1").arg(setupFile)); -// loop.exec(QEventLoop::ExcludeUserInputEvents); -// QFile::remove(setupFile); -// QApplication::restoreOverrideCursor(); -// -// if(QMessageBox::information(this, tr("WMA Decoder"), tr("The WMA File Decoder has been installed. Please restart LameXP now!"), tr("Quit LameXP"), tr("Postpone")) == 0) -// { -// bResult = true; -// } -// break; -// } -// -// return bResult; -//} - -/* * Check for updates */ bool MainWindow::checkForUpdates(void) @@ -650,6 +593,36 @@ bool MainWindow::checkForUpdates(void) return bReadyToInstall; } +void MainWindow::refreshFavorites(void) +{ + QList folderList = m_outputFolderFavoritesMenu->actions(); + QStringList favorites = m_settings->favoriteOutputFolders().split("|", QString::SkipEmptyParts); + while(favorites.count() > 6) favorites.removeFirst(); + + while(!folderList.isEmpty()) + { + QAction *currentItem = folderList.takeFirst(); + if(currentItem->isSeparator()) break; + m_outputFolderFavoritesMenu->removeAction(currentItem); + LAMEXP_DELETE(currentItem); + } + + QAction *lastItem = m_outputFolderFavoritesMenu->actions().first(); + + while(!favorites.isEmpty()) + { + QString path = favorites.takeLast(); + if(QDir(path).exists()) + { + QAction *action = new QAction(QIcon(":/icons/folder_go.png"), QDir::toNativeSeparators(path), this); + action->setData(path); + m_outputFolderFavoritesMenu->insertAction(lastItem, action); + connect(action, SIGNAL(triggered(bool)), this, SLOT(gotoFavoriteFolder())); + lastItem = action; + } + } +} + //////////////////////////////////////////////////////////// // EVENTS //////////////////////////////////////////////////////////// @@ -689,14 +662,15 @@ void MainWindow::changeEvent(QEvent *e) { if(e->type() == QEvent::LanguageChange) { - int comboBoxIndex[5]; + int comboBoxIndex[6]; //Backup combobox indices, as retranslateUi() resets comboBoxIndex[0] = comboBoxMP3ChannelMode->currentIndex(); comboBoxIndex[1] = comboBoxSamplingRate->currentIndex(); - comboBoxIndex[2] = comboBoxNeroAACProfile->currentIndex(); + comboBoxIndex[2] = comboBoxAACProfile->currentIndex(); comboBoxIndex[3] = comboBoxAftenCodingMode->currentIndex(); comboBoxIndex[4] = comboBoxAftenDRCMode->currentIndex(); + comboBoxIndex[5] = comboBoxNormalizationMode->currentIndex(); //Re-translate from UIC Ui::MainWindow::retranslateUi(this); @@ -704,9 +678,10 @@ void MainWindow::changeEvent(QEvent *e) //Restore combobox indices comboBoxMP3ChannelMode->setCurrentIndex(comboBoxIndex[0]); comboBoxSamplingRate->setCurrentIndex(comboBoxIndex[1]); - comboBoxNeroAACProfile->setCurrentIndex(comboBoxIndex[2]); + comboBoxAACProfile->setCurrentIndex(comboBoxIndex[2]); comboBoxAftenCodingMode->setCurrentIndex(comboBoxIndex[3]); comboBoxAftenDRCMode->setCurrentIndex(comboBoxIndex[4]); + comboBoxNormalizationMode->setCurrentIndex(comboBoxIndex[5]); //Update the window title if(LAMEXP_DEBUG) @@ -724,6 +699,7 @@ void MainWindow::changeEvent(QEvent *e) m_previewContextAction->setText(tr("Open File in External Application")); m_findFileContextAction->setText(tr("Browse File Location")); m_showFolderContextAction->setText(tr("Browse Selected Folder")); + m_addFavoriteFolderAction->setText(tr("Bookmark Current Output Folder")); //Force GUI update m_metaInfoModel->clearData(); @@ -731,6 +707,7 @@ void MainWindow::changeEvent(QEvent *e) updateEncoder(m_settings->compressionEncoder()); updateLameAlgoQuality(sliderLameAlgoQuality->value()); updateMaximumInstances(sliderMaxInstances->value()); + renameOutputPatternChanged(lineEditRenamePattern->text()); //Re-install shell integration if(m_settings->shellIntegrationEnabled()) @@ -764,28 +741,41 @@ void MainWindow::dropEvent(QDropEvent *event) ABORT_IF_BUSY; QStringList droppedFiles; - const QList urls = event->mimeData()->urls(); + QList urls = event->mimeData()->urls(); - for(int i = 0; i < urls.count(); i++) + while(!urls.isEmpty()) { - QFileInfo file(urls.at(i).toLocalFile()); + QUrl currentUrl = urls.takeFirst(); + QFileInfo file(currentUrl.toLocalFile()); if(!file.exists()) { continue; } if(file.isFile()) { - qDebug64("Dropped File: %1", file.canonicalFilePath()); + qDebug("Dropped File: %s", file.canonicalFilePath().toUtf8().constData()); droppedFiles << file.canonicalFilePath(); continue; } - else if(file.isDir()) + if(file.isDir()) { - qDebug64("Dropped Folder: %1", file.canonicalFilePath()); - QList list = QDir(file.canonicalFilePath()).entryInfoList(QDir::Files); - for(int j = 0; j < list.count(); j++) + qDebug("Dropped Folder: %s", file.canonicalFilePath().toUtf8().constData()); + QList list = QDir(file.canonicalFilePath()).entryInfoList(QDir::Files | QDir::NoSymLinks); + if(list.count() > 0) { - droppedFiles << list.at(j).canonicalFilePath(); + for(int j = 0; j < list.count(); j++) + { + droppedFiles << list.at(j).canonicalFilePath(); + } + } + else + { + list = QDir(file.canonicalFilePath()).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks); + for(int j = 0; j < list.count(); j++) + { + qDebug("Descending to Folder: %s", list.at(j).canonicalFilePath().toUtf8().constData()); + urls.prepend(QUrl::fromLocalFile(list.at(j).canonicalFilePath())); + } } } } @@ -868,6 +858,36 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event) break; } } + else if(obj == outputFoldersFovoritesLabel) + { + QMouseEvent *mouseEvent = dynamic_cast(event); + QPoint pos = (mouseEvent != NULL) ? mouseEvent->pos() : QPoint(); + QWidget *sender = dynamic_cast(obj); + + switch(event->type()) + { + case QEvent::Enter: + outputFoldersFovoritesLabel->setFrameShadow(QFrame::Raised); + break; + case QEvent::MouseButtonPress: + outputFoldersFovoritesLabel->setFrameShadow(QFrame::Sunken); + break; + case QEvent::MouseButtonRelease: + outputFoldersFovoritesLabel->setFrameShadow(QFrame::Raised); + if(sender && mouseEvent) + { + if(pos.x() <= sender->width() && pos.y() <= sender->height() && pos.x() >= 0 && pos.y() >= 0 && mouseEvent->button() != Qt::MidButton) + { + m_outputFolderFavoritesMenu->popup(sender->mapToGlobal(pos)); + } + } + break; + case QEvent::Leave: + outputFoldersFovoritesLabel->setFrameShadow(QFrame::Plain); + break; + } + } + return false; } @@ -886,12 +906,19 @@ void MainWindow::windowShown(void) { QStringList arguments = QApplication::arguments(); + //First run? + bool firstRun = false; + for(int i = 0; i < arguments.count(); i++) + { + if(!arguments[i].compare("--first-run", Qt::CaseInsensitive)) firstRun = true; + } + //Check license - if(m_settings->licenseAccepted() <= 0) + if((m_settings->licenseAccepted() <= 0) || firstRun) { int iAccepted = -1; - if(m_settings->licenseAccepted() == 0) + if((m_settings->licenseAccepted() == 0) || firstRun) { AboutDialog *about = new AboutDialog(m_settings, this, true); iAccepted = about->exec(); @@ -904,7 +931,18 @@ void MainWindow::windowShown(void) QApplication::processEvents(); PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); QMessageBox::critical(this, tr("License Declined"), tr("You have declined the license. Consequently the application will exit now!"), tr("Goodbye!")); - if(!QProcess::startDetached(QString("%1/Uninstall.exe").arg(QApplication::applicationDirPath()), QStringList())) + QFileInfo uninstallerInfo = QFileInfo(QString("%1/Uninstall.exe").arg(QApplication::applicationDirPath())); + if(uninstallerInfo.exists()) + { + QString uninstallerDir = uninstallerInfo.canonicalPath(); + QString uninstallerPath = uninstallerInfo.canonicalFilePath(); + for(int i = 0; i < 3; i++) + { + HINSTANCE res = ShellExecuteW(this->winId(), L"open", QWCHAR(QDir::toNativeSeparators(uninstallerPath)), L"/Force", QWCHAR(QDir::toNativeSeparators(uninstallerDir)), SW_SHOWNORMAL); + if(reinterpret_cast(res) > 32) break; + } + } + else { MoveFileEx(QWCHAR(QDir::toNativeSeparators(QFileInfo(QApplication::applicationFilePath()).canonicalFilePath())), NULL, MOVEFILE_DELAY_UNTIL_REBOOT | MOVEFILE_REPLACE_EXISTING); } @@ -914,6 +952,7 @@ void MainWindow::windowShown(void) PlaySound(MAKEINTRESOURCE(IDR_WAVE_WOOHOO), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); m_settings->licenseAccepted(1); + if(lamexp_version_demo()) showAnnounceBox(); } //Check for expiration @@ -923,7 +962,7 @@ void MainWindow::windowShown(void) { qWarning("Binary has expired !!!"); PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); - if(QMessageBox::warning(this, tr("LameXP - Expired"), QString("%1
%2
").arg(tr("This demo (pre-release) version of LameXP has expired at %1.").arg(lamexp_version_expires().toString(Qt::ISODate)), tr("LameXP is free software and release versions won't expire.")), tr("Check for Updates"), tr("Exit Program")) == 0) + if(QMessageBox::warning(this, tr("LameXP - Expired"), QString("%1
%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(); } @@ -936,8 +975,8 @@ void MainWindow::windowShown(void) if(m_settings->slowStartup() && m_settings->antivirNotificationsEnabled()) { QString message; - message += QString("%1
").arg(tr("It seems that a bogus anti-virus software is slowing down the startup of LameXP.").replace("-", "−")); - message += QString("%1
").arg(tr("Please refer to the %1 document for details and solutions!").replace("-", "−").arg("F.A.Q.")); + message += NOBR(tr("It seems that a bogus anti-virus software is slowing down the startup of LameXP.")).append("
"); + message += NOBR(tr("Please refer to the %1 document for details and solutions!")).arg("F.A.Q.").append("
"); if(QMessageBox::warning(this, tr("Slow Startup"), message, tr("Discard"), tr("Don't Show Again")) == 1) { m_settings->antivirNotificationsEnabled(false); @@ -949,7 +988,7 @@ void MainWindow::windowShown(void) if(QDate::currentDate() >= lamexp_version_date().addYears(1)) { qWarning("Binary is more than a year old, time to update!"); - if(QMessageBox::warning(this, tr("Urgent Update"), QString("%1").arg(tr("Your version of LameXP is more than a year old. Time for an update!")), tr("Check for Updates"), tr("Exit Program")) == 0) + if(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")) == 0) { if(checkForUpdates()) { @@ -966,9 +1005,9 @@ void MainWindow::windowShown(void) else if(m_settings->autoUpdateEnabled()) { QDate lastUpdateCheck = QDate::fromString(m_settings->autoUpdateLastCheck(), Qt::ISODate); - if(!lastUpdateCheck.isValid() || QDate::currentDate() >= lastUpdateCheck.addDays(14)) + if(!firstRun && (!lastUpdateCheck.isValid() || QDate::currentDate() >= lastUpdateCheck.addDays(14))) { - if(QMessageBox::information(this, tr("Update Reminder"), QString("%1").arg(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) + 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) { if(checkForUpdates()) { @@ -987,27 +1026,28 @@ void MainWindow::windowShown(void) if(lamexp_tool_version("neroAacEnc.exe") < lamexp_toolver_neroaac()) { QString messageText; - messageText += QString("%1
").arg(tr("LameXP detected that your version of the Nero AAC encoder is outdated!")); - messageText += QString("%1

").arg(tr("The current version available is %1 (or later), but you still have version %2 installed.").arg(lamexp_version2string("?.?.?.?", lamexp_toolver_neroaac(), tr("n/a")), lamexp_version2string("?.?.?.?", lamexp_tool_version("neroAacEnc.exe"), tr("n/a")))); - messageText += QString("%1
").arg(tr("You can download the latest version of the Nero AAC encoder from the Nero website at:")); - messageText += "" + LINK(AboutDialog::neroAacUrl) + "
"; + messageText += NOBR(tr("LameXP detected that your version of the Nero AAC encoder is outdated!")).append("
"); + messageText += NOBR(tr("The current version available is %1 (or later), but you still have version %2 installed.").arg(lamexp_version2string("?.?.?.?", lamexp_toolver_neroaac(), tr("n/a")), lamexp_version2string("?.?.?.?", lamexp_tool_version("neroAacEnc.exe"), tr("n/a")))).append("

"); + messageText += NOBR(tr("You can download the latest version of the Nero AAC encoder from the Nero website at:")).append("
"); + messageText += "" + LINK(AboutDialog::neroAacUrl) + "

"; + messageText += NOBR(tr("(Hint: Please ignore the name of the downloaded ZIP file and check the included 'changelog.txt' instead!)")).append("
"); QMessageBox::information(this, tr("AAC Encoder Outdated"), messageText); } } } else { - if(m_settings->neroAacNotificationsEnabled()) + if(m_settings->neroAacNotificationsEnabled() && (!m_fhgEncoderAvailable)) { QString appPath = QDir(QCoreApplication::applicationDirPath()).canonicalPath(); if(appPath.isEmpty()) appPath = QCoreApplication::applicationDirPath(); QString messageText; - messageText += QString("%1
").arg(tr("The Nero AAC encoder could not be found. AAC encoding support will be disabled.").replace("-", "−")); - messageText += QString("%1

").arg(tr("Please put 'neroAacEnc.exe', 'neroAacDec.exe' and 'neroAacTag.exe' into the LameXP directory!").replace("-", "−")); - messageText += QString("%1
").arg(tr("Your LameXP directory is located here:").replace("-", "−")); - messageText += QString("%2

").arg(QDir::toNativeSeparators(appPath), QDir::toNativeSeparators(appPath).replace("-", "−")); - messageText += QString("%1
").arg(tr("You can download the Nero AAC encoder for free from the official Nero website at:").replace("-", "−")); - messageText += "" + LINK(AboutDialog::neroAacUrl) + "
"; + messageText += NOBR(tr("The Nero AAC encoder could not be found. AAC encoding support will be disabled.")).append("
"); + messageText += NOBR(tr("Please put 'neroAacEnc.exe', 'neroAacDec.exe' and 'neroAacTag.exe' into the LameXP directory!")).append("

"); + messageText += NOBR(tr("Your LameXP directory is located here:")).append("
"); + messageText += QString("%1

").arg(FSLINK(QDir::toNativeSeparators(appPath))); + messageText += NOBR(tr("You can download the Nero AAC encoder for free from the official Nero website at:")).append("
"); + messageText += "" + LINK(AboutDialog::neroAacUrl) + "
"; if(QMessageBox::information(this, tr("AAC Support Disabled"), messageText, tr("Discard"), tr("Don't Show Again")) == 1) { m_settings->neroAacNotificationsEnabled(false); @@ -1015,32 +1055,6 @@ void MainWindow::windowShown(void) } } } - - //Check for WMA support - //if(m_settings->wmaDecoderNotificationsEnabled()) - //{ - // if(!lamexp_check_tool("wmawav.exe")) - // { - // QString messageText; - // messageText += QString("%1
").arg(tr("LameXP has detected that the WMA File Decoder component is not currently installed on your system.").replace("-", "−")); - // messageText += QString("%1

").arg(tr("You won't be able to process WMA files as input unless the WMA File Decoder component is installed!").replace("-", "−")); - // messageText += QString("%1").arg(tr("Do you want to download and install the WMA File Decoder component now?").replace("-", "−")); - // int result = QMessageBox::information(this, tr("WMA Decoder Missing"), messageText, tr("Download && Install"), tr("Don't Show Again"), tr("Postpone")); - // if(result == 0) - // { - // if(installWMADecoder()) - // { - // QApplication::quit(); - // return; - // } - // } - // else if(result == 1) - // { - // m_settings->wmaDecoderNotificationsEnabled(false); - // actionDisableWmaDecoderNotifications->setChecked(!m_settings->wmaDecoderNotificationsEnabled()); - // } - // } - //} //Add files from the command-line for(int i = 0; i < arguments.count() - 1; i++) @@ -1088,6 +1102,40 @@ void MainWindow::windowShown(void) } } +/* + * Show announce box + */ +void MainWindow::showAnnounceBox(void) +{ + const QString announceText = QString("%1

%2
%3
").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") + ); + + 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(); + + LAMEXP_DELETE(announceTimer); + LAMEXP_DELETE(announceBox); +} + // ========================================================= // Main button solots // ========================================================= @@ -1097,15 +1145,15 @@ void MainWindow::windowShown(void) */ void MainWindow::encodeButtonClicked(void) { - static const __int64 oneGigabyte = 1073741824i64; - static const __int64 minimumFreeDiskspaceMultiplier = 2i64; + static const unsigned __int64 oneGigabyte = 1073741824ui64; + static const unsigned __int64 minimumFreeDiskspaceMultiplier = 2ui64; static const char *writeTestBuffer = "LAMEXP_WRITE_TEST"; ABORT_IF_BUSY; if(m_fileListModel->rowCount() < 1) { - QMessageBox::warning(this, tr("LameXP"), QString("%1").arg(tr("You must add at least one file to the list before proceeding!"))); + QMessageBox::warning(this, tr("LameXP"), NOBR(tr("You must add at least one file to the list before proceeding!"))); tabWidget->setCurrentIndex(0); return; } @@ -1113,20 +1161,29 @@ void MainWindow::encodeButtonClicked(void) QString tempFolder = m_settings->customTempPathEnabled() ? m_settings->customTempPath() : lamexp_temp_folder2(); if(!QFileInfo(tempFolder).exists() || !QFileInfo(tempFolder).isDir()) { - if(QMessageBox::warning(this, tr("Not Found"), QString("%1
%2").arg(tr("Your currently selected TEMP folder does not exist anymore:"), QDir::toNativeSeparators(tempFolder)), tr("Restore Default"), tr("Cancel")) == 0) + if(QMessageBox::warning(this, tr("Not Found"), QString("%1
%2").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(); } return; } - qint64 currentFreeDiskspace = lamexp_free_diskspace(tempFolder); - if(currentFreeDiskspace < (oneGigabyte * minimumFreeDiskspaceMultiplier)) + bool ok = false; + unsigned __int64 currentFreeDiskspace = lamexp_free_diskspace(tempFolder, &ok); + + if(ok && (currentFreeDiskspace < (oneGigabyte * minimumFreeDiskspaceMultiplier))) { 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); - switch(QMessageBox::warning(this, tr("Low Diskspace Warning"), QString("%1
%2

%3").arg(tr("There are less than %1 GB of free diskspace available on your system's TEMP folder.").arg(QString::number(minimumFreeDiskspaceMultiplier)), tr("It is highly recommend to free up more diskspace before proceeding with the encode!"), tr("Your TEMP folder is located at:")).append("
%3
").arg(tempFolderParts.join("\\")), tr("Abort Encoding Process"), tr("Clean Disk Now"), tr("Ignore"))) + QString lowDiskspaceMsg = QString("%1
%2

%3
%4
").arg + ( + NOBR(tr("There are less than %1 GB of free diskspace available on your system's TEMP folder.").arg(QString::number(minimumFreeDiskspaceMultiplier))), + NOBR(tr("It is highly recommend to free up more diskspace before proceeding with the encode!")), + NOBR(tr("Your TEMP folder is located at:")), + QString("%1").arg(FSLINK(tempFolderParts.join("\\"))) + ); + switch(QMessageBox::warning(this, tr("Low Diskspace Warning"), lowDiskspaceMsg, tr("Abort Encoding Process"), tr("Clean Disk Now"), tr("Ignore"))) { case 1: QProcess::startDetached(QString("%1/cleanmgr.exe").arg(lamexp_known_folder(lamexp_folder_systemfolder)), QStringList() << "/D" << tempFolderParts.first()); @@ -1398,9 +1455,9 @@ void MainWindow::disableUpdateReminderActionTriggered(bool checked) { if(checked) { - if(0 == QMessageBox::question(this, tr("Disable Update Reminder"), tr("Do you really want to disable the update reminder?"), tr("Yes"), tr("No"), QString(), 1)) + if(0 == QMessageBox::question(this, tr("Disable Update Reminder"), NOBR(tr("Do you really want to disable the update reminder?")), tr("Yes"), tr("No"), QString(), 1)) { - QMessageBox::information(this, tr("Update Reminder"), QString("%1
%2").arg(tr("The update reminder has been disabled."), tr("Please remember to check for updates at regular intervals!"))); + QMessageBox::information(this, tr("Update Reminder"), QString("%1
%2").arg(NOBR(tr("The update reminder has been disabled.")), NOBR(tr("Please remember to check for updates at regular intervals!")))); m_settings->autoUpdateEnabled(false); } else @@ -1410,7 +1467,7 @@ void MainWindow::disableUpdateReminderActionTriggered(bool checked) } else { - QMessageBox::information(this, tr("Update Reminder"), tr("The update reminder has been re-enabled.")); + QMessageBox::information(this, tr("Update Reminder"), NOBR(tr("The update reminder has been re-enabled."))); m_settings->autoUpdateEnabled(true); } @@ -1424,9 +1481,9 @@ void MainWindow::disableSoundsActionTriggered(bool checked) { if(checked) { - if(0 == QMessageBox::question(this, tr("Disable Sound Effects"), tr("Do you really want to disable all sound effects?"), tr("Yes"), tr("No"), QString(), 1)) + if(0 == QMessageBox::question(this, tr("Disable Sound Effects"), NOBR(tr("Do you really want to disable all sound effects?")), tr("Yes"), tr("No"), QString(), 1)) { - QMessageBox::information(this, tr("Sound Effects"), tr("All sound effects have been disabled.")); + QMessageBox::information(this, tr("Sound Effects"), NOBR(tr("All sound effects have been disabled."))); m_settings->soundsEnabled(false); } else @@ -1436,7 +1493,7 @@ void MainWindow::disableSoundsActionTriggered(bool checked) } else { - QMessageBox::information(this, tr("Sound Effects"), tr("The sound effects have been re-enabled.")); + QMessageBox::information(this, tr("Sound Effects"), NOBR(tr("The sound effects have been re-enabled."))); m_settings->soundsEnabled(true); } @@ -1450,9 +1507,9 @@ void MainWindow::disableNeroAacNotificationsActionTriggered(bool checked) { if(checked) { - if(0 == QMessageBox::question(this, tr("Nero AAC Notifications"), tr("Do you really want to disable all Nero AAC Encoder notifications?"), tr("Yes"), tr("No"), QString(), 1)) + if(0 == QMessageBox::question(this, tr("Nero AAC Notifications"), NOBR(tr("Do you really want to disable all Nero AAC Encoder notifications?")), tr("Yes"), tr("No"), QString(), 1)) { - QMessageBox::information(this, tr("Nero AAC Notifications"), tr("All Nero AAC Encoder notifications have been disabled.")); + QMessageBox::information(this, tr("Nero AAC Notifications"), NOBR(tr("All Nero AAC Encoder notifications have been disabled."))); m_settings->neroAacNotificationsEnabled(false); } else @@ -1462,7 +1519,7 @@ void MainWindow::disableNeroAacNotificationsActionTriggered(bool checked) } else { - QMessageBox::information(this, tr("Nero AAC Notifications"), tr("The Nero AAC Encoder notifications have been re-enabled.")); + QMessageBox::information(this, tr("Nero AAC Notifications"), NOBR(tr("The Nero AAC Encoder notifications have been re-enabled."))); m_settings->neroAacNotificationsEnabled(true); } @@ -1470,41 +1527,15 @@ void MainWindow::disableNeroAacNotificationsActionTriggered(bool checked) } /* - * Disable WMA Decoder component action - */ -//void MainWindow::disableWmaDecoderNotificationsActionTriggered(bool checked) -//{ -// if(checked) -// { -// if(0 == QMessageBox::question(this, tr("WMA Decoder Notifications"), tr("Do you really want to disable all WMA Decoder notifications?"), tr("Yes"), tr("No"), QString(), 1)) -// { -// QMessageBox::information(this, tr("WMA Decoder Notifications"), tr("All WMA Decoder notifications have been disabled.")); -// m_settings->wmaDecoderNotificationsEnabled(false); -// } -// else -// { -// m_settings->wmaDecoderNotificationsEnabled(true); -// } -// } -// else -// { -// QMessageBox::information(this, tr("WMA Decoder Notifications"), tr("The WMA Decoder notifications have been re-enabled.")); -// m_settings->wmaDecoderNotificationsEnabled(true); -// } -// -// actionDisableWmaDecoderNotifications->setChecked(!m_settings->wmaDecoderNotificationsEnabled()); -//} - -/* * Disable slow startup action */ void MainWindow::disableSlowStartupNotificationsActionTriggered(bool checked) { if(checked) { - if(0 == QMessageBox::question(this, tr("Slow Startup Notifications"), tr("Do you really want to disable the slow startup notifications?"), tr("Yes"), tr("No"), QString(), 1)) + if(0 == QMessageBox::question(this, tr("Slow Startup Notifications"), NOBR(tr("Do you really want to disable the slow startup notifications?")), tr("Yes"), tr("No"), QString(), 1)) { - QMessageBox::information(this, tr("Slow Startup Notifications"), tr("The slow startup notifications have been disabled.")); + QMessageBox::information(this, tr("Slow Startup Notifications"), NOBR(tr("The slow startup notifications have been disabled."))); m_settings->antivirNotificationsEnabled(false); } else @@ -1514,7 +1545,7 @@ void MainWindow::disableSlowStartupNotificationsActionTriggered(bool checked) } else { - QMessageBox::information(this, tr("Slow Startup Notifications"), tr("The slow startup notifications have been re-enabled.")); + QMessageBox::information(this, tr("Slow Startup Notifications"), NOBR(tr("The slow startup notifications have been re-enabled."))); m_settings->antivirNotificationsEnabled(true); } @@ -1522,21 +1553,6 @@ void MainWindow::disableSlowStartupNotificationsActionTriggered(bool checked) } /* - * Download and install WMA Decoder component - */ -//void MainWindow::installWMADecoderActionTriggered(bool checked) -//{ -// if(QMessageBox::question(this, tr("Install WMA Decoder"), tr("Do you want to download and install the WMA File Decoder component now?"), tr("Download && Install"), tr("Cancel")) == 0) -// { -// if(installWMADecoder()) -// { -// QApplication::quit(); -// return; -// } -// } -//} - -/* * Import a Cue Sheet file */ void MainWindow::importCueSheetActionTriggered(bool checked) @@ -1545,12 +1561,36 @@ void MainWindow::importCueSheetActionTriggered(bool checked) TEMP_HIDE_DROPBOX ( - QString selectedCueFile = QFileDialog::getOpenFileName(this, tr("Open Cue Sheet"), QString(), QString("%1 (*.cue)").arg(tr("Cue Sheet File"))); - if(!selectedCueFile.isEmpty()) + while(true) { - CueImportDialog *cueImporter = new CueImportDialog(this, m_fileListModel, selectedCueFile); - cueImporter->exec(); - LAMEXP_DELETE(cueImporter); + int result = 0; + QString selectedCueFile; + + if(USE_NATIVE_FILE_DIALOG) + { + selectedCueFile = QFileDialog::getOpenFileName(this, tr("Open Cue Sheet"), m_settings->mostRecentInputPath(), QString("%1 (*.cue)").arg(tr("Cue Sheet File"))); + } + else + { + QFileDialog dialog(this, tr("Open Cue Sheet")); + dialog.setFileMode(QFileDialog::ExistingFile); + dialog.setNameFilter(QString("%1 (*.cue)").arg(tr("Cue Sheet File"))); + dialog.setDirectory(m_settings->mostRecentInputPath()); + if(dialog.exec()) + { + selectedCueFile = dialog.selectedFiles().first(); + } + } + + if(!selectedCueFile.isEmpty()) + { + m_settings->mostRecentInputPath(QFileInfo(selectedCueFile).canonicalPath()); + CueImportDialog *cueImporter = new CueImportDialog(this, m_fileListModel, selectedCueFile); + result = cueImporter->exec(); + LAMEXP_DELETE(cueImporter); + } + + if(result != (-1)) break; } ) } @@ -1579,9 +1619,9 @@ void MainWindow::checkForBetaUpdatesActionTriggered(bool checked) if(checked) { - if(0 == QMessageBox::question(this, tr("Beta Updates"), tr("Do you really want LameXP to check for Beta (pre-release) updates?"), tr("Yes"), tr("No"), QString(), 1)) + if(0 == QMessageBox::question(this, tr("Beta Updates"), NOBR(tr("Do you really want LameXP to check for Beta (pre-release) updates?")), tr("Yes"), tr("No"), QString(), 1)) { - if(0 == QMessageBox::information(this, tr("Beta Updates"), tr("LameXP will check for Beta (pre-release) updates from now on."), tr("Check Now"), tr("Discard"))) + if(0 == QMessageBox::information(this, tr("Beta Updates"), NOBR(tr("LameXP will check for Beta (pre-release) updates from now on.")), tr("Check Now"), tr("Discard"))) { checkUpdatesNow = true; } @@ -1594,7 +1634,7 @@ void MainWindow::checkForBetaUpdatesActionTriggered(bool checked) } else { - QMessageBox::information(this, tr("Beta Updates"), tr("LameXP will not check for Beta (pre-release) updates from now on.")); + QMessageBox::information(this, tr("Beta Updates"), NOBR(tr("LameXP will not check for Beta (pre-release) updates from now on."))); m_settings->autoUpdateCheckBeta(false); } @@ -1610,16 +1650,42 @@ void MainWindow::checkForBetaUpdatesActionTriggered(bool checked) } /* + * Hibernate computer action + */ +void MainWindow::hibernateComputerActionTriggered(bool checked) +{ + if(checked) + { + if(0 == QMessageBox::question(this, tr("Hibernate Computer"), NOBR(tr("Do you really want the computer to be hibernated on shutdown?")), tr("Yes"), tr("No"), QString(), 1)) + { + QMessageBox::information(this, tr("Hibernate Computer"), NOBR(tr("LameXP will hibernate the computer on shutdown from now on."))); + m_settings->hibernateComputer(true); + } + else + { + m_settings->hibernateComputer(false); + } + } + else + { + QMessageBox::information(this, tr("Hibernate Computer"), NOBR(tr("LameXP will not hibernate the computer on shutdown from now on."))); + m_settings->hibernateComputer(false); + } + + actionHibernateComputer->setChecked(m_settings->hibernateComputer()); +} + +/* * Disable shell integration action */ void MainWindow::disableShellIntegrationActionTriggered(bool checked) { if(checked) { - if(0 == QMessageBox::question(this, tr("Shell Integration"), tr("Do you really want to disable the LameXP shell integration?"), tr("Yes"), tr("No"), QString(), 1)) + if(0 == QMessageBox::question(this, tr("Shell Integration"), NOBR(tr("Do you really want to disable the LameXP shell integration?")), tr("Yes"), tr("No"), QString(), 1)) { ShellIntegration::remove(); - QMessageBox::information(this, tr("Shell Integration"), tr("The LameXP shell integration has been disabled.")); + QMessageBox::information(this, tr("Shell Integration"), NOBR(tr("The LameXP shell integration has been disabled."))); m_settings->shellIntegrationEnabled(false); } else @@ -1630,7 +1696,7 @@ void MainWindow::disableShellIntegrationActionTriggered(bool checked) else { ShellIntegration::install(); - QMessageBox::information(this, tr("Shell Integration"), tr("The LameXP shell integration has been re-enabled.")); + QMessageBox::information(this, tr("Shell Integration"), NOBR(tr("The LameXP shell integration has been re-enabled."))); m_settings->shellIntegrationEnabled(true); } @@ -1724,12 +1790,13 @@ void MainWindow::addFilesButtonClicked(void) TEMP_HIDE_DROPBOX ( - if(lamexp_themes_enabled()) + if(USE_NATIVE_FILE_DIALOG) { QStringList fileTypeFilters = DecoderRegistry::getSupportedTypes(); - QStringList selectedFiles = QFileDialog::getOpenFileNames(this, tr("Add file(s)"), QString(), fileTypeFilters.join(";;")); + QStringList selectedFiles = QFileDialog::getOpenFileNames(this, tr("Add file(s)"), m_settings->mostRecentInputPath(), fileTypeFilters.join(";;")); if(!selectedFiles.isEmpty()) { + m_settings->mostRecentInputPath(QFileInfo(selectedFiles.first()).canonicalPath()); addFiles(selectedFiles); } } @@ -1739,10 +1806,15 @@ void MainWindow::addFilesButtonClicked(void) QStringList fileTypeFilters = DecoderRegistry::getSupportedTypes(); dialog.setFileMode(QFileDialog::ExistingFiles); dialog.setNameFilter(fileTypeFilters.join(";;")); + dialog.setDirectory(m_settings->mostRecentInputPath()); if(dialog.exec()) { QStringList selectedFiles = dialog.selectedFiles(); - addFiles(selectedFiles); + if(!selectedFiles.isEmpty()) + { + m_settings->mostRecentInputPath(QFileInfo(selectedFiles.first()).canonicalPath()); + addFiles(selectedFiles); + } } } ) @@ -1760,15 +1832,15 @@ void MainWindow::openFolderActionActivated(void) { TEMP_HIDE_DROPBOX ( - if(lamexp_themes_enabled()) + if(USE_NATIVE_FILE_DIALOG) { - selectedFolder = QFileDialog::getExistingDirectory(this, tr("Add Folder"), QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); + selectedFolder = QFileDialog::getExistingDirectory(this, tr("Add Folder"), m_settings->mostRecentInputPath()); } else { QFileDialog dialog(this, tr("Add Folder")); dialog.setFileMode(QFileDialog::DirectoryOnly); - dialog.setDirectory(QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); + dialog.setDirectory(m_settings->mostRecentInputPath()); if(dialog.exec()) { selectedFolder = dialog.selectedFiles().first(); @@ -1777,6 +1849,7 @@ void MainWindow::openFolderActionActivated(void) if(!selectedFolder.isEmpty()) { + m_settings->mostRecentInputPath(QDir(selectedFolder).canonicalPath()); addFolder(selectedFolder, action->data().toBool()); } ) @@ -1891,6 +1964,14 @@ void MainWindow::sourceFilesContextMenu(const QPoint &pos) } /* + * Scrollbar of source files moved + */ +void MainWindow::sourceFilesScrollbarMoved(int) +{ + sourceFileView->resizeColumnToContents(0); +} + +/* * Open selected file in external player */ void MainWindow::previewContextActionTriggered(void) @@ -2098,6 +2179,31 @@ void MainWindow::gotoMusicFolderButtonClicked(void) } /* + * Goto music favorite output folder + */ +void MainWindow::gotoFavoriteFolder(void) +{ + QAction *item = dynamic_cast(QObject::sender()); + + if(item) + { + QDir path(item->data().toString()); + if(path.exists()) + { + outputFolderView->setCurrentIndex(m_fileSystemModel->index(path.canonicalPath())); + outputFolderViewClicked(outputFolderView->currentIndex()); + outputFolderView->setFocus(); + } + else + { + MessageBeep(MB_ICONERROR); + m_outputFolderFavoritesMenu->removeAction(item); + item->deleteLater(); + } + } +} + +/* * Make folder button */ void MainWindow::makeFolderButtonClicked(void) @@ -2143,6 +2249,8 @@ void MainWindow::makeFolderButtonClicked(void) } } + suggestedName = lamexp_clean_filename(suggestedName); + while(true) { bool bApplied = false; @@ -2150,15 +2258,7 @@ void MainWindow::makeFolderButtonClicked(void) if(bApplied) { - folderName.remove(":", Qt::CaseInsensitive); - folderName.remove("/", Qt::CaseInsensitive); - folderName.remove("\\", Qt::CaseInsensitive); - folderName.remove("?", Qt::CaseInsensitive); - folderName.remove("*", Qt::CaseInsensitive); - folderName.remove("<", Qt::CaseInsensitive); - folderName.remove(">", Qt::CaseInsensitive); - - folderName = folderName.simplified(); + folderName = lamexp_clean_filepath(folderName.simplified()); if(folderName.isEmpty()) { @@ -2174,7 +2274,7 @@ void MainWindow::makeFolderButtonClicked(void) newFolder = QString(folderName).append(QString().sprintf(" (%d)", ++i)); } - if(basePath.mkdir(newFolder)) + if(basePath.mkpath(newFolder)) { QDir createdDir = basePath; if(createdDir.cd(newFolder)) @@ -2232,6 +2332,28 @@ void MainWindow::showFolderContextActionTriggered(void) } /* + * Add current folder to favorites + */ +void MainWindow::addFavoriteFolderActionTriggered(void) +{ + QString path = m_fileSystemModel->filePath(outputFolderView->currentIndex()); + QStringList favorites = m_settings->favoriteOutputFolders().split("|", QString::SkipEmptyParts); + + if(!favorites.contains(path, Qt::CaseInsensitive)) + { + favorites.append(path); + while(favorites.count() > 6) favorites.removeFirst(); + } + else + { + MessageBeep(MB_ICONWARNING); + } + + m_settings->favoriteOutputFolders(favorites.join("|")); + refreshFavorites(); +} + +/* * Initialize file system model */ void MainWindow::initOutputFolderModel(void) @@ -2334,6 +2456,13 @@ void MainWindow::updateEncoder(int id) 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; default: radioButtonModeQuality->setEnabled(true); radioButtonModeAverageBitrate->setEnabled(true); @@ -2537,6 +2666,13 @@ void MainWindow::updateLameAlgoQuality(int value) m_settings->lameAlgoQuality(value); 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); } /* @@ -2608,7 +2744,7 @@ void MainWindow::neroAAC2PassChanged(bool checked) */ void MainWindow::neroAACProfileChanged(int value) { - if(value >= 0) m_settings->neroAACProfile(value); + if(value >= 0) m_settings->aacEncProfile(value); } /* @@ -2660,6 +2796,14 @@ void MainWindow::normalizationMaxVolumeChanged(double value) } /* + * Normalization equalization mode changed + */ +void MainWindow::normalizationModeChanged(int mode) +{ + m_settings->normalizationFilterEqualizationMode(mode); +} + +/* * Tone adjustment has changed (Bass) */ void MainWindow::toneAdjustBassChanged(double value) @@ -2712,7 +2856,7 @@ void MainWindow::customParamsChanged(void) m_settings->customParametersLAME(lineEditCustomParamLAME->text()); m_settings->customParametersOggEnc(lineEditCustomParamOggEnc->text()); - m_settings->customParametersNeroAAC(lineEditCustomParamNeroAAC->text()); + m_settings->customParametersAacEnc(lineEditCustomParamNeroAAC->text()); m_settings->customParametersFLAC(lineEditCustomParamFLAC->text()); m_settings->customParametersAften(lineEditCustomParamAften->text()); } @@ -2741,15 +2885,15 @@ void MainWindow::renameOutputPatternChanged(void) */ void MainWindow::renameOutputPatternChanged(const QString &text) { - QString pattern(text); + QString pattern(text.simplified()); - pattern.remove("", Qt::CaseInsensitive); - pattern.remove("", Qt::CaseInsensitive); - pattern.remove("", Qt::CaseInsensitive); - pattern.remove("<Artist>", Qt::CaseInsensitive); - pattern.remove("<Album>", Qt::CaseInsensitive); - pattern.remove("<Year>", Qt::CaseInsensitive); - pattern.remove("<Comment>", Qt::CaseInsensitive); + pattern.replace("<BaseName>", "The_White_Stripes_-_Fell_In_Love_With_A_Girl", Qt::CaseInsensitive); + pattern.replace("<TrackNo>", "04", Qt::CaseInsensitive); + pattern.replace("<Title>", "Fell In Love With A Girl", Qt::CaseInsensitive); + pattern.replace("<Artist>", "The White Stripes", Qt::CaseInsensitive); + pattern.replace("<Album>", "White Blood Cells", Qt::CaseInsensitive); + pattern.replace("<Year>", "2001", Qt::CaseInsensitive); + pattern.replace("<Comment>", "Encoded by LameXP", Qt::CaseInsensitive); if(pattern.compare(lamexp_clean_filename(pattern))) { @@ -2767,6 +2911,8 @@ void MainWindow::renameOutputPatternChanged(const QString &text) SET_TEXT_COLOR(lineEditRenamePattern, Qt::black); } } + + labelRanameExample->setText(lamexp_clean_filename(pattern)); } /* @@ -2790,11 +2936,18 @@ void MainWindow::showRenameMacros(const QString &text) message += QString(format).arg("Album", tr("Album name")); message += QString(format).arg("Year", tr("Year with (at least) four digits")); message += QString(format).arg("Comment", tr("Comment")); - message += "</table><br>"; + message += "</table><br><br>"; + message += QString("%1<br>").arg(tr("Characters forbidden in file names:")); + message += "<b><tt>\\ / : * ? < > |<br>"; QMessageBox::information(this, tr("Rename Macros"), message, tr("Discard")); } +void MainWindow::forceStereoDownmixEnabledChanged(bool checked) +{ + m_settings->forceStereoDownmix(checked); +} + /* * Maximum number of instances changed */ @@ -2817,7 +2970,22 @@ void MainWindow::autoDetectInstancesChanged(bool checked) */ void MainWindow::browseCustomTempFolderButtonClicked(void) { - QString newTempFolder = QFileDialog::getExistingDirectory(this); + QString newTempFolder; + + if(USE_NATIVE_FILE_DIALOG) + { + newTempFolder = QFileDialog::getExistingDirectory(this, QString(), m_settings->customTempPath()); + } + else + { + QFileDialog dialog(this); + dialog.setFileMode(QFileDialog::DirectoryOnly); + dialog.setDirectory(m_settings->customTempPath()); + if(dialog.exec()) + { + newTempFolder = dialog.selectedFiles().first(); + } + } if(!newTempFolder.isEmpty()) { @@ -2864,9 +3032,10 @@ void MainWindow::resetAdvancedOptionsButtonClicked(void) spinBoxAftenSearchSize->setValue(m_settings->aftenExponentSearchSizeDefault()); comboBoxMP3ChannelMode->setCurrentIndex(m_settings->lameChannelModeDefault()); comboBoxSamplingRate->setCurrentIndex(m_settings->samplingRateDefault()); - comboBoxNeroAACProfile->setCurrentIndex(m_settings->neroAACProfileDefault()); + 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(); @@ -2874,9 +3043,10 @@ void MainWindow::resetAdvancedOptionsButtonClicked(void) 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->customParametersNeroAACDefault()); + lineEditCustomParamNeroAAC->setText(m_settings->customParametersAacEncDefault()); lineEditCustomParamFLAC->setText(m_settings->customParametersFLACDefault()); lineEditCustomTempFolder->setText(QDir::toNativeSeparators(m_settings->customTempPathDefault())); lineEditRenamePattern->setText(m_settings->renameOutputFilesPatternDefault());