X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2FDialog_MainWindow.cpp;h=27469bedf67ddd476c48d4ab19f40bfb62042953;hb=3073ceb312f3cc290655d20c2c82791592205985;hp=440c5ba82a2b6a322e804215a41359a23905f352;hpb=6f751b516c17e0073721e064249e5f6be628d118;p=lamexp%2FLameXP.git diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index 440c5ba8..27469bed 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -1,12 +1,12 @@ /////////////////////////////////////////////////////////////////////////////// // LameXP - Audio Encoder Front-End -// Copyright (C) 2004-2015 LoRd_MuldeR +// Copyright (C) 2004-2020 LoRd_MuldeR // // 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 +// 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, but always including the *additional* -// restrictions defined in the "License.txt" file. +// (at your option) any later version; always including the non-optional +// LAMEXP GNU GENERAL PUBLIC LICENSE ADDENDUM. See "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 @@ -129,9 +129,17 @@ while(0) } \ while(0) -#define LINK(URL) QString("%2").arg(URL).arg(QString(URL).replace("-", "−")) -#define FSLINK(PATH) QString("%2").arg(PATH).arg(QString(PATH).replace("-", "−")) -#define CENTER_CURRENT_OUTPUT_FOLDER_DELAYED QTimer::singleShot(125, this, SLOT(centerOutputFolderModel())) +#define LINK(URL) \ + (QString("%2").arg(URL).arg(QString(URL).replace("-", "−"))) + +#define LINK_EX(URL, NAME) \ + (QString("%2").arg(URL).arg(QString(NAME).replace("-", "−"))) + +#define FSLINK(PATH) \ + (QString("%2").arg(PATH).arg(QString(PATH).replace("-", "−"))) + +#define CENTER_CURRENT_OUTPUT_FOLDER_DELAYED() \ + QTimer::singleShot(125, this, SLOT(centerOutputFolderModel())) //////////////////////////////////////////////////////////// // Static Functions @@ -202,6 +210,43 @@ static inline void MAKE_TRANSPARENT(QWidget *const widget, const bool &flag) widget->setPalette(flag ? _p : QPalette()); } +template +static QList& INVERT_LIST(QList &list) +{ + if(!list.isEmpty()) + { + const int limit = list.size() / 2, maxIdx = list.size() - 1; + for(int k = 0; k < limit; k++) list.swap(k, maxIdx - k); + } + return list; +} + +static quint32 encodeInstances(quint32 instances) +{ + if (instances > 16U) + { + instances -= (instances - 16U) / 2U; + if (instances > 24U) + { + instances -= (instances - 24U) / 2U; + } + } + return instances; +} + +static quint32 decodeInstances(quint32 instances) +{ + if (instances > 16U) + { + instances += instances - 16U; + if (instances > 32U) + { + instances += instances - 32U; + } + } + return instances; +} + //////////////////////////////////////////////////////////// // Helper Classes //////////////////////////////////////////////////////////// @@ -254,6 +299,7 @@ MainWindow::MainWindow(MUtils::IPCChannel *const ipcChannel, FileListModel *cons //Init the dialog, from the .ui file ui->setupUi(this); setWindowFlags(windowFlags() ^ Qt::WindowMaximizeButtonHint); + setMinimumSize(this->size()); //Create window icon MUtils::GUI::set_window_icon(this, lamexp_app_icon(), true); @@ -455,7 +501,10 @@ MainWindow::MainWindow(MUtils::IPCChannel *const ipcChannel, FileListModel *cons //-------------------------------- ui->sliderLameAlgoQuality->setValue(m_settings->lameAlgoQuality()); - if(m_settings->maximumInstances() > 0) ui->sliderMaxInstances->setValue(m_settings->maximumInstances()); + if (m_settings->maximumInstances() > 0U) + { + ui->sliderMaxInstances->setValue(static_cast(encodeInstances(m_settings->maximumInstances()))); + } ui->spinBoxBitrateManagementMin ->setValue(m_settings->bitrateManagementMinRate()); ui->spinBoxBitrateManagementMax ->setValue(m_settings->bitrateManagementMaxRate()); @@ -485,6 +534,7 @@ MainWindow::MainWindow(MUtils::IPCChannel *const ipcChannel, FileListModel *cons SET_CHECKBOX_STATE(ui->checkBoxRename_RegExp, m_settings->renameFiles_regExpEnabled()); SET_CHECKBOX_STATE(ui->checkBoxForceStereoDownmix, m_settings->forceStereoDownmix()); SET_CHECKBOX_STATE(ui->checkBoxOpusDisableResample, m_settings->opusDisableResample()); + SET_CHECKBOX_STATE(ui->checkBoxKeepOriginalDateTime, m_settings->keepOriginalDataTime()); ui->checkBoxNeroAAC2PassMode->setEnabled(aacEncoder == SettingsModel::AAC_ENCODER_NERO); @@ -574,6 +624,7 @@ MainWindow::MainWindow(MUtils::IPCChannel *const ipcChannel, FileListModel *cons connect(ui->buttonRename_FileEx, SIGNAL(clicked(bool)), this, SLOT(renameButtonClicked(bool))); connect(ui->buttonFileExts_Add, SIGNAL(clicked()), this, SLOT(fileExtAddButtonClicked())); connect(ui->buttonFileExts_Remove, SIGNAL(clicked()), this, SLOT(fileExtRemoveButtonClicked())); + connect(ui->checkBoxKeepOriginalDateTime, SIGNAL(clicked(bool)), this, SLOT(keepOriginalDateTimeChanged(bool))); connect(m_overwriteButtonGroup.data(), SIGNAL(buttonClicked(int)), this, SLOT(overwriteModeChanged(int))); connect(m_evenFilterCustumParamsHelp.data(), SIGNAL(eventOccurred(QWidget*, QEvent*)), this, SLOT(customParamsHelpRequested(QWidget*, QEvent*))); connect(fileExtModel, SIGNAL(modelReset()), this, SLOT(fileExtModelChanged())); @@ -698,12 +749,9 @@ MainWindow::MainWindow(MUtils::IPCChannel *const ipcChannel, FileListModel *cons // Prepare to show window //-------------------------------- - //Center window in screen - QRect desktopRect = QApplication::desktop()->screenGeometry(); - QRect thisRect = this->geometry(); - move((desktopRect.width() - thisRect.width()) / 2, (desktopRect.height() - thisRect.height()) / 2); - setMinimumSize(thisRect.width(), thisRect.height()); - + //Adjust size to DPI settings and re-center + MUtils::GUI::scale_widget(this); + //Create DropBox widget m_dropBox.reset(new DropBox(this, m_fileListModel, m_settings)); connect(m_fileListModel, SIGNAL(modelReset()), m_dropBox.data(), SLOT(modelChanged())); @@ -808,19 +856,19 @@ void MainWindow::addFiles(const QStringList &files) if(analyzer->filesDenied()) { - QMessageBox::warning(this, tr("Access Denied"), QString("%1
%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.")))); + QMessageBox::warning(this, tr("Access Denied"), NOBREAK(QString("%1
%2").arg(tr("%n file(s) have been rejected, because read access was not granted!", "", analyzer->filesDenied()), 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(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("Exact Audio Copy")))); + QMessageBox::warning(this, tr("CDDA Files"), NOBREAK(QString("%1

%2
%3").arg(tr("%n file(s) have been rejected, because they are dummy CDDA files!", "", 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")))); } if(analyzer->filesCueSheet()) { - QMessageBox::warning(this, tr("Cue Sheet"), QString("%1
%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.")))); + QMessageBox::warning(this, tr("Cue Sheet"), NOBREAK(QString("%1
%2").arg(tr("%n file(s) have been rejected, because they appear to be Cue Sheet images!", "",analyzer->filesCueSheet()), 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(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.")))); + QMessageBox::warning(this, tr("Files Rejected"), NOBREAK(QString("%1
%2").arg(tr("%n file(s) have been rejected, because the file format could not be recognized!", "", analyzer->filesRejected()), tr("This usually means the file is damaged or the file format is not supported.")))); } m_banner->close(); @@ -889,8 +937,9 @@ void MainWindow::addFolder(const QString &path, bool recursive, bool delayed, QS /* * Check for updates */ -bool MainWindow::checkForUpdates(void) +bool MainWindow::checkForUpdates(bool &haveNewVersion) { + haveNewVersion = false; bool bReadyToInstall = false; UpdateDialog *updateDialog = new UpdateDialog(m_settings, this); @@ -900,6 +949,7 @@ bool MainWindow::checkForUpdates(void) { SHOW_CORNER_WIDGET(false); m_settings->autoUpdateLastCheck(QDate::currentDate().toString(Qt::ISODate)); + haveNewVersion = updateDialog->haveNewVersion(); bReadyToInstall = updateDialog->updateReadyToInstall(); } @@ -1028,6 +1078,44 @@ void MainWindow::openDocumentLink(QAction *const action) } /* + * Move selected files up/down + */ +void MainWindow::moveSelectedFiles(const bool &up) +{ + QItemSelectionModel *const selection = ui->sourceFileView->selectionModel(); + if(selection && selection->hasSelection()) + { + const QModelIndexList selectedRows = up ? selection->selectedRows() : INVERT_LIST(selection->selectedRows()); + if((up && (selectedRows.first().row() > 0)) || ((!up) && (selectedRows.first().row() < m_fileListModel->rowCount() - 1))) + { + const int delta = up ? (-1) : 1; + const int firstIndex = (up ? selectedRows.first() : selectedRows.last()).row() + delta; + const int selectionCount = selectedRows.count(); + if(abs(delta) > 0) + { + FileListBlockHelper fileListBlocker(m_fileListModel); + for(QModelIndexList::ConstIterator iter = selectedRows.constBegin(); iter != selectedRows.constEnd(); iter++) + { + if(!m_fileListModel->moveFile((*iter), delta)) + { + break; + } + } + } + selection->clearSelection(); + for(int i = 0; i < selectionCount; i++) + { + const QModelIndex item = m_fileListModel->index(firstIndex + i, 0); + selection->select(QItemSelection(item, item), QItemSelectionModel::Select | QItemSelectionModel::Rows); + } + ui->sourceFileView->scrollTo(m_fileListModel->index((up ? firstIndex : firstIndex + selectionCount - 1), 0), QAbstractItemView::PositionAtCenter); + return; + } + } + MUtils::Sound::beep(MUtils::Sound::BEEP_WRN); +} + +/* * Show banner popup dialog */ void MainWindow::showBanner(const QString &text) @@ -1366,45 +1454,60 @@ void MainWindow::windowShown(void) //First run? const bool firstRun = arguments.contains("first-run"); + if (firstRun) + { + m_settings->licenseAccepted(0); + m_settings->autoUpdateCheckBeta(false); + m_settings->syncNow(); + } //Check license - if((m_settings->licenseAccepted() <= 0) || firstRun) + if (m_settings->licenseAccepted() <= 0) { - int iAccepted = m_settings->licenseAccepted(); - - if((iAccepted == 0) || firstRun) + if (m_settings->licenseAccepted() == 0) + { + QScopedPointer about(new AboutDialog(m_settings, this, true)); + if (about->exec() > 0) + { + m_settings->licenseAccepted(1); + m_settings->syncNow(); + PLAY_SOUND_OPTIONAL("woohoo", false); + if (lamexp_version_demo()) + { + showAnnounceBox(); + } + } + else + { + m_settings->licenseAccepted(-1); + m_settings->syncNow(); + } + } + else { - AboutDialog *about = new AboutDialog(m_settings, this, true); - iAccepted = about->exec(); - if(iAccepted <= 0) iAccepted = -2; - MUTILS_DELETE(about); + m_settings->licenseAccepted(0); + m_settings->syncNow(); } + } - if(iAccepted <= 0) + //License declined? + if(m_settings->licenseAccepted() <= 0) + { + QApplication::processEvents(); + PLAY_SOUND_OPTIONAL("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()) { - m_settings->licenseAccepted(++iAccepted); - m_settings->syncNow(); - QApplication::processEvents(); - MUtils::Sound::play_sound("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 uninstallerDir = uninstallerInfo.canonicalPath(); + QString uninstallerPath = uninstallerInfo.canonicalFilePath(); + for(int i = 0; i < 3; i++) { - QString uninstallerDir = uninstallerInfo.canonicalPath(); - QString uninstallerPath = uninstallerInfo.canonicalFilePath(); - for(int i = 0; i < 3; i++) - { - if(MUtils::OS::shell_open(this, QDir::toNativeSeparators(uninstallerPath), "/Force", QDir::toNativeSeparators(uninstallerDir))) break; - } + if(MUtils::OS::shell_open(this, QDir::toNativeSeparators(uninstallerPath), "/Force", QDir::toNativeSeparators(uninstallerDir))) break; } - QApplication::quit(); - return; } - - MUtils::Sound::play_sound("woohoo", false); - m_settings->licenseAccepted(1); - m_settings->syncNow(); - if(lamexp_version_demo()) showAnnounceBox(); + QApplication::quit(); + return; } //Check for expiration @@ -1412,14 +1515,22 @@ void MainWindow::windowShown(void) { if(MUtils::OS::current_date() >= lamexp_version_expires()) { - qWarning("Binary has expired !!!"); - MUtils::Sound::play_sound("whammy", false); - 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) + qWarning("Binary expired !!!"); + PLAY_SOUND_OPTIONAL("whammy", false); + bool haveNewVersion = true; + if(QMessageBox::warning(this, tr("LameXP - Expired"), NOBREAK(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) { - checkForUpdates(); + if (checkForUpdates(haveNewVersion)) + { + QApplication::quit(); + return; + } + } + if(haveNewVersion) + { + QApplication::quit(); + return; } - QApplication::quit(); - return; } } @@ -1427,9 +1538,9 @@ void MainWindow::windowShown(void) if(m_settings->slowStartup() && m_settings->antivirNotificationsEnabled()) { QString message; - 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) + message += tr("It seems that a bogus anti-virus software is slowing down the startup of LameXP.").append("
"); + message += tr("Please refer to the %1 document for details and solutions!").arg(LINK_EX(QString("%1/Manual.html#performance-issues").arg(g_documents_base_url), tr("Manual"))).append("
"); + if(QMessageBox::warning(this, tr("Slow Startup"), NOBREAK(message), tr("Discard"), tr("Don't Show Again")) == 1) { m_settings->antivirNotificationsEnabled(false); ui->actionDisableSlowStartupNotifications->setChecked(!m_settings->antivirNotificationsEnabled()); @@ -1441,11 +1552,12 @@ void MainWindow::windowShown(void) { qWarning("Binary is more than a year old, time to update!"); SHOW_CORNER_WIDGET(true); - 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")); + int ret = QMessageBox::warning(this, tr("Urgent Update"), NOBREAK(tr("Your version of LameXP is more than a year old. Time for an update!")), tr("Check for Updates"), tr("Exit Program"), tr("Ignore")); switch(ret) { case 0: - if(checkForUpdates()) + bool haveNewVersion; + if(checkForUpdates(haveNewVersion)) { QApplication::quit(); return; @@ -1456,7 +1568,7 @@ void MainWindow::windowShown(void) return; default: QEventLoop loop; QTimer::singleShot(7000, &loop, SLOT(quit())); - MUtils::Sound::play_sound("waiting", true); + PLAY_SOUND_OPTIONAL("waiting", true); showBanner(tr("Skipping update check this time, please be patient..."), &loop); break; } @@ -1469,9 +1581,10 @@ void MainWindow::windowShown(void) SHOW_CORNER_WIDGET(true); if(m_settings->autoUpdateEnabled()) { - 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(QMessageBox::information(this, tr("Update Reminder"), NOBREAK(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()) + bool haveNewVersion; + if(checkForUpdates(haveNewVersion)) { QApplication::quit(); return; @@ -1482,41 +1595,22 @@ void MainWindow::windowShown(void) } //Check for AAC support - const int aacEncoder = EncoderRegistry::getAacEncoder(); - if(aacEncoder == SettingsModel::AAC_ENCODER_NERO) - { - if(m_settings->neroAacNotificationsEnabled()) + if(m_settings->neroAacNotificationsEnabled() && (EncoderRegistry::getAacEncoder() <= SettingsModel::AAC_ENCODER_NONE)) + { + QString appPath = QDir(QCoreApplication::applicationDirPath()).canonicalPath(); + if(appPath.isEmpty()) appPath = QCoreApplication::applicationDirPath(); + QString messageText; + messageText += tr("The Nero AAC encoder could not be found. AAC encoding support will be disabled.").append("
"); + messageText += tr("Please put 'neroAacEnc.exe', 'neroAacDec.exe' and 'neroAacTag.exe' into the LameXP directory!").append("

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

").arg(FSLINK(QDir::toNativeSeparators(appPath))); + messageText += QString("").append(tr("You can download the Nero AAC encoder for free from this website:")).append("
"); + messageText += QString("").append(LINK(AboutDialog::neroAacUrl)).append("

"); + messageText += QString("").append(tr("Note: Nero AAC encoder version %1 or newer is required to enable AAC encoding support!").arg(lamexp_version2string("v?.?.?.?", lamexp_toolver_neroaac(), "n/a"))).append("
"); + if(QMessageBox::information(this, tr("AAC Support Disabled"), NOBREAK(messageText), tr("Discard"), tr("Don't Show Again")) == 1) { - if(lamexp_tools_version("neroAacEnc.exe") < lamexp_toolver_neroaac()) - { - QString messageText; - 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_tools_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() && (aacEncoder <= SettingsModel::AAC_ENCODER_NONE)) - { - QString appPath = QDir(QCoreApplication::applicationDirPath()).canonicalPath(); - if(appPath.isEmpty()) appPath = QCoreApplication::applicationDirPath(); - QString messageText; - 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); - ui->actionDisableNeroAacNotifications->setChecked(!m_settings->neroAacNotificationsEnabled()); - } + m_settings->neroAacNotificationsEnabled(false); + ui->actionDisableNeroAacNotifications->setChecked(!m_settings->neroAacNotificationsEnabled()); } } @@ -1576,14 +1670,14 @@ void MainWindow::showAnnounceBox(void) { const unsigned int timeout = 8U; - const QString announceText = QString("%1

%2
%3
").arg + 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:"), + "We are still looking for LameXP translators!", + "If you are willing to translate LameXP to your language or to complete an existing translation, please refer to:", LINK("http://lamexp.sourceforge.net/doc/Translate.html") ); - QMessageBox *announceBox = new QMessageBox(QMessageBox::Warning, "We want you!", announceText, QMessageBox::NoButton, this); + QMessageBox *announceBox = new QMessageBox(QMessageBox::Warning, "We want you!", NOBREAK(announceText), QMessageBox::NoButton, this); announceBox->setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint); announceBox->setIconPixmap(QIcon(":/images/Announcement.png").pixmap(64,79)); @@ -1644,7 +1738,7 @@ void MainWindow::encodeButtonClicked(void) if(m_fileListModel->rowCount() < 1) { - QMessageBox::warning(this, tr("LameXP"), NOBR(tr("You must add at least one file to the list before proceeding!"))); + QMessageBox::warning(this, tr("LameXP"), NOBREAK(tr("You must add at least one file to the list before proceeding!"))); ui->tabWidget->setCurrentIndex(0); return; } @@ -1652,7 +1746,7 @@ void MainWindow::encodeButtonClicked(void) QString tempFolder = m_settings->customTempPathEnabled() ? m_settings->customTempPath() : MUtils::temp_folder(); if(!QFileInfo(tempFolder).exists() || !QFileInfo(tempFolder).isDir()) { - 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) + if(QMessageBox::warning(this, tr("Not Found"), NOBREAK(QString("%1
%2").arg(tr("Your currently selected TEMP folder does not exist anymore:"), QDir::toNativeSeparators(tempFolder))), tr("Restore Default"), tr("Cancel")) == 0) { SET_CHECKBOX_STATE(ui->checkBoxUseSystemTempFolder, (!m_settings->customTempPathEnabledDefault())); } @@ -1669,20 +1763,20 @@ void MainWindow::encodeButtonClicked(void) PLAY_SOUND_OPTIONAL("whammy", false); 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("\\"))) + 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:"), + 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"))) + switch(QMessageBox::warning(this, tr("Low Diskspace Warning"), NOBREAK(lowDiskspaceMsg), tr("Abort Encoding Process"), tr("Clean Disk Now"), tr("Ignore"))) { case 1: - QProcess::startDetached(QString("%1/cleanmgr.exe").arg(MUtils::OS::known_folder(MUtils::OS::FOLDER_SYSTEMFOLDER)), QStringList() << "/D" << tempFolderParts.first()); + QProcess::startDetached(QString("%1/cleanmgr.exe").arg(MUtils::OS::known_folder(MUtils::OS::FOLDER_SYSTEM_DEF)), QStringList() << "/D" << tempFolderParts.first()); case 0: return; break; default: - QMessageBox::warning(this, tr("Low Diskspace"), NOBR(tr("You are proceeding with low diskspace. Problems might occur!"))); + QMessageBox::warning(this, tr("Low Diskspace"), NOBREAK(tr("You are proceeding with low diskspace. Problems might occur!"))); break; } } @@ -1708,10 +1802,10 @@ void MainWindow::encodeButtonClicked(void) if(!m_settings->outputToSourceDir()) { - QFile writeTest(QString("%1/~%2.txt").arg(m_settings->outputDir(), MUtils::rand_str())); + QFile writeTest(QString("%1/~%2.txt").arg(m_settings->outputDir(), MUtils::next_rand_str())); if(!(writeTest.open(QIODevice::ReadWrite) && (writeTest.write(writeTestBuffer) == strlen(writeTestBuffer)))) { - QMessageBox::warning(this, tr("LameXP"), QString("%1
%2

%3").arg(tr("Cannot write to the selected output directory."), m_settings->outputDir(), tr("Please choose a different directory!"))); + QMessageBox::warning(this, tr("LameXP"), NOBREAK(QString("%1
%2

%3").arg(tr("Cannot write to the selected output directory."), m_settings->outputDir(), tr("Please choose a different directory!")))); ui->tabWidget->setCurrentIndex(1); return; } @@ -1812,7 +1906,7 @@ void MainWindow::tabPageChanged(int idx, const bool silent) } else { - CENTER_CURRENT_OUTPUT_FOLDER_DELAYED; + CENTER_CURRENT_OUTPUT_FOLDER_DELAYED(); } } @@ -1990,9 +2084,9 @@ void MainWindow::disableUpdateReminderActionTriggered(bool checked) { if(checked) { - 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)) + if(0 == QMessageBox::question(this, tr("Disable Update Reminder"), NOBREAK(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(NOBR(tr("The update reminder has been disabled.")), NOBR(tr("Please remember to check for updates at regular intervals!")))); + QMessageBox::information(this, tr("Update Reminder"), NOBREAK(QString("%1
%2").arg(tr("The update reminder has been disabled."), tr("Please remember to check for updates at regular intervals!")))); m_settings->autoUpdateEnabled(false); } else @@ -2002,7 +2096,7 @@ void MainWindow::disableUpdateReminderActionTriggered(bool checked) } else { - QMessageBox::information(this, tr("Update Reminder"), NOBR(tr("The update reminder has been re-enabled."))); + QMessageBox::information(this, tr("Update Reminder"), NOBREAK(tr("The update reminder has been re-enabled."))); m_settings->autoUpdateEnabled(true); } @@ -2016,9 +2110,9 @@ void MainWindow::disableSoundsActionTriggered(bool checked) { if(checked) { - 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)) + if(0 == QMessageBox::question(this, tr("Disable Sound Effects"), NOBREAK(tr("Do you really want to disable all sound effects?")), tr("Yes"), tr("No"), QString(), 1)) { - QMessageBox::information(this, tr("Sound Effects"), NOBR(tr("All sound effects have been disabled."))); + QMessageBox::information(this, tr("Sound Effects"), NOBREAK(tr("All sound effects have been disabled."))); m_settings->soundsEnabled(false); } else @@ -2028,7 +2122,7 @@ void MainWindow::disableSoundsActionTriggered(bool checked) } else { - QMessageBox::information(this, tr("Sound Effects"), NOBR(tr("The sound effects have been re-enabled."))); + QMessageBox::information(this, tr("Sound Effects"), NOBREAK(tr("The sound effects have been re-enabled."))); m_settings->soundsEnabled(true); } @@ -2042,9 +2136,9 @@ void MainWindow::disableNeroAacNotificationsActionTriggered(bool checked) { if(checked) { - 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)) + if(0 == QMessageBox::question(this, tr("Nero AAC Notifications"), NOBREAK(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"), NOBR(tr("All Nero AAC Encoder notifications have been disabled."))); + QMessageBox::information(this, tr("Nero AAC Notifications"), NOBREAK(tr("All Nero AAC Encoder notifications have been disabled."))); m_settings->neroAacNotificationsEnabled(false); } else @@ -2054,8 +2148,8 @@ void MainWindow::disableNeroAacNotificationsActionTriggered(bool checked) } else { - QMessageBox::information(this, tr("Nero AAC Notifications"), NOBR(tr("The Nero AAC Encoder notifications have been re-enabled."))); - m_settings->neroAacNotificationsEnabled(true); + QMessageBox::information(this, tr("Nero AAC Notifications"), NOBREAK(tr("The Nero AAC Encoder notifications have been re-enabled."))); + m_settings->neroAacNotificationsEnabled(true); } ui->actionDisableNeroAacNotifications->setChecked(!m_settings->neroAacNotificationsEnabled()); @@ -2068,9 +2162,9 @@ void MainWindow::disableSlowStartupNotificationsActionTriggered(bool checked) { if(checked) { - 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)) + if(0 == QMessageBox::question(this, tr("Slow Startup Notifications"), NOBREAK(tr("Do you really want to disable the slow startup notifications?")), tr("Yes"), tr("No"), QString(), 1)) { - QMessageBox::information(this, tr("Slow Startup Notifications"), NOBR(tr("The slow startup notifications have been disabled."))); + QMessageBox::information(this, tr("Slow Startup Notifications"), NOBREAK(tr("The slow startup notifications have been disabled."))); m_settings->antivirNotificationsEnabled(false); } else @@ -2080,7 +2174,7 @@ void MainWindow::disableSlowStartupNotificationsActionTriggered(bool checked) } else { - QMessageBox::information(this, tr("Slow Startup Notifications"), NOBR(tr("The slow startup notifications have been re-enabled."))); + QMessageBox::information(this, tr("Slow Startup Notifications"), NOBREAK(tr("The slow startup notifications have been re-enabled."))); m_settings->antivirNotificationsEnabled(true); } @@ -2161,9 +2255,9 @@ void MainWindow::checkForBetaUpdatesActionTriggered(bool checked) if(checked) { - 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::question(this, tr("Beta Updates"), NOBREAK(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"), NOBR(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"), NOBREAK(tr("LameXP will check for Beta (pre-release) updates from now on.")), tr("Check Now"), tr("Discard"))) { checkUpdatesNow = true; } @@ -2176,15 +2270,16 @@ void MainWindow::checkForBetaUpdatesActionTriggered(bool checked) } else { - QMessageBox::information(this, tr("Beta Updates"), NOBR(tr("LameXP will not check for Beta (pre-release) updates from now on."))); - m_settings->autoUpdateCheckBeta(false); + QMessageBox::information(this, tr("Beta Updates"), NOBREAK(tr("LameXP will not check for Beta (pre-release) updates from now on."))); + m_settings->autoUpdateCheckBeta(false); } ui->actionCheckForBetaUpdates->setChecked(m_settings->autoUpdateCheckBeta()); if(checkUpdatesNow) { - if(checkForUpdates()) + bool haveNewVersion; + if(checkForUpdates(haveNewVersion)) { QApplication::quit(); } @@ -2198,9 +2293,9 @@ 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)) + if(0 == QMessageBox::question(this, tr("Hibernate Computer"), NOBREAK(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."))); + QMessageBox::information(this, tr("Hibernate Computer"), NOBREAK(tr("LameXP will hibernate the computer on shutdown from now on."))); m_settings->hibernateComputer(true); } else @@ -2210,7 +2305,7 @@ void MainWindow::hibernateComputerActionTriggered(bool checked) } else { - QMessageBox::information(this, tr("Hibernate Computer"), NOBR(tr("LameXP will not hibernate the computer on shutdown from now on."))); + QMessageBox::information(this, tr("Hibernate Computer"), NOBREAK(tr("LameXP will not hibernate the computer on shutdown from now on."))); m_settings->hibernateComputer(false); } @@ -2224,10 +2319,10 @@ void MainWindow::disableShellIntegrationActionTriggered(bool checked) { if(checked) { - 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)) + if(0 == QMessageBox::question(this, tr("Shell Integration"), NOBREAK(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"), NOBR(tr("The LameXP shell integration has been disabled."))); + QMessageBox::information(this, tr("Shell Integration"), NOBREAK(tr("The LameXP shell integration has been disabled."))); m_settings->shellIntegrationEnabled(false); } else @@ -2238,7 +2333,7 @@ void MainWindow::disableShellIntegrationActionTriggered(bool checked) else { ShellIntegration::install(); - QMessageBox::information(this, tr("Shell Integration"), NOBR(tr("The LameXP shell integration has been re-enabled."))); + QMessageBox::information(this, tr("Shell Integration"), NOBREAK(tr("The LameXP shell integration has been re-enabled."))); m_settings->shellIntegrationEnabled(true); } @@ -2287,7 +2382,8 @@ void MainWindow::checkUpdatesActionActivated(void) ABORT_IF_BUSY; WidgetHideHelper hiderHelper(m_dropBox.data()); - if(checkForUpdates()) + bool haveNewVersion; + if(checkForUpdates(haveNewVersion)) { QApplication::quit(); } @@ -2305,7 +2401,7 @@ void MainWindow::addFilesButtonClicked(void) ABORT_IF_BUSY; WidgetHideHelper hiderHelper(m_dropBox.data()); - if(MUtils::GUI::themes_enabled()) + if(MUtils::GUI::themes_enabled() && (!MUTILS_DEBUG)) { QStringList fileTypeFilters = DecoderRegistry::getSupportedTypes(); QStringList selectedFiles = QFileDialog::getOpenFileNames(this, tr("Add file(s)"), m_settings->mostRecentInputPath(), fileTypeFilters.join(";;")); @@ -2395,11 +2491,33 @@ void MainWindow::openFolderActionActivated(void) */ void MainWindow::removeFileButtonClicked(void) { - if(ui->sourceFileView->currentIndex().isValid()) + const QItemSelectionModel *const selection = ui->sourceFileView->selectionModel(); + if(selection && selection->hasSelection()) + { + int firstRow = -1; + const QModelIndexList selectedRows = INVERT_LIST(selection->selectedRows()); + if(!selectedRows.isEmpty()) + { + FileListBlockHelper fileListBlocker(m_fileListModel); + firstRow = selectedRows.last().row(); + for(QModelIndexList::ConstIterator iter = selectedRows.constBegin(); iter != selectedRows.constEnd(); iter++) + { + if(!m_fileListModel->removeFile(*iter)) + { + break; + } + } + } + if(m_fileListModel->rowCount() > 0) + { + const QModelIndex position = m_fileListModel->index(((firstRow >= 0) && (firstRow < m_fileListModel->rowCount())) ? firstRow : (m_fileListModel->rowCount() - 1), 0); + ui->sourceFileView->selectRow(position.row()); + ui->sourceFileView->scrollTo(position, QAbstractItemView::PositionAtCenter); + } + } + else { - int iRow = ui->sourceFileView->currentIndex().row(); - m_fileListModel->removeFile(ui->sourceFileView->currentIndex()); - ui->sourceFileView->selectRow(iRow < m_fileListModel->rowCount() ? iRow : m_fileListModel->rowCount()-1); + MUtils::Sound::beep(MUtils::Sound::BEEP_WRN); } } @@ -2408,7 +2526,14 @@ void MainWindow::removeFileButtonClicked(void) */ void MainWindow::clearFilesButtonClicked(void) { - m_fileListModel->clearFiles(); + if(m_fileListModel->rowCount() > 0) + { + m_fileListModel->clearFiles(); + } + else + { + MUtils::Sound::beep(MUtils::Sound::BEEP_WRN); + } } /* @@ -2416,12 +2541,7 @@ void MainWindow::clearFilesButtonClicked(void) */ void MainWindow::fileUpButtonClicked(void) { - if(ui->sourceFileView->currentIndex().isValid()) - { - int iRow = ui->sourceFileView->currentIndex().row() - 1; - m_fileListModel->moveFile(ui->sourceFileView->currentIndex(), -1); - ui->sourceFileView->selectRow(iRow >= 0 ? iRow : 0); - } + moveSelectedFiles(true); } /* @@ -2429,12 +2549,7 @@ void MainWindow::fileUpButtonClicked(void) */ void MainWindow::fileDownButtonClicked(void) { - if(ui->sourceFileView->currentIndex().isValid()) - { - 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); - } + moveSelectedFiles(false); } /* @@ -2445,38 +2560,47 @@ void MainWindow::showDetailsButtonClicked(void) ABORT_IF_BUSY; int iResult = 0; - MetaInfoDialog *metaInfoDialog = new MetaInfoDialog(this); QModelIndex index = ui->sourceFileView->currentIndex(); - - while(index.isValid()) + + if(index.isValid()) { - if(iResult > 0) + ui->sourceFileView->selectRow(index.row()); + QScopedPointer metaInfoDialog(new MetaInfoDialog(this)); + forever { - index = m_fileListModel->index(index.row() + 1, index.column()); - ui->sourceFileView->selectRow(index.row()); - } - if(iResult < 0) - { - index = m_fileListModel->index(index.row() - 1, index.column()); - ui->sourceFileView->selectRow(index.row()); - } - - AudioFileModel &file = (*m_fileListModel)[index]; - WidgetHideHelper hiderHelper(m_dropBox.data()); - iResult = metaInfoDialog->exec(file, index.row() > 0, index.row() < m_fileListModel->rowCount() - 1); + AudioFileModel &file = (*m_fileListModel)[index]; + WidgetHideHelper hiderHelper(m_dropBox.data()); + 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); - ui->tabWidget->setCurrentIndex(ui->tabWidget->indexOf(ui->tabMetaData)); - break; - } + //Copy all info to Meta Info tab + if(iResult == INT_MAX) + { + m_metaInfoModel->assignInfoFrom(file); + ui->tabWidget->setCurrentIndex(ui->tabWidget->indexOf(ui->tabMetaData)); + break; + } - if(!iResult) break; + if(iResult > 0) + { + index = m_fileListModel->index(index.row() + 1, index.column()); + ui->sourceFileView->selectRow(index.row()); + continue; + } + else if(iResult < 0) + { + index = m_fileListModel->index(index.row() - 1, index.column()); + ui->sourceFileView->selectRow(index.row()); + continue; + } + + break; /*close dilalog now*/ + } + } + else + { + MUtils::Sound::beep(MUtils::Sound::BEEP_WRN); } - MUTILS_DELETE(metaInfoDialog); QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); sourceFilesScrollbarMoved(0); } @@ -2532,17 +2656,10 @@ void MainWindow::findFileContextActionTriggered(void) QModelIndex index = ui->sourceFileView->currentIndex(); if(index.isValid()) { - QString systemRootPath; - - QDir systemRoot(MUtils::OS::known_folder(MUtils::OS::FOLDER_SYSTEMFOLDER)); - if(systemRoot.exists() && systemRoot.cdUp()) + const QString systemToolsPath = MUtils::OS::known_folder(MUtils::OS::FOLDER_SYSROOT); + if(!systemToolsPath.isEmpty()) { - systemRootPath = systemRoot.canonicalPath(); - } - - if(!systemRootPath.isEmpty()) - { - QFileInfo explorer(QString("%1/explorer.exe").arg(systemRootPath)); + QFileInfo explorer(QString("%1/explorer.exe").arg(systemToolsPath)); if(explorer.exists() && explorer.isFile()) { QProcess::execute(explorer.canonicalFilePath(), QStringList() << "/select," << QDir::toNativeSeparators(m_fileListModel->getFile(index).filePath())); @@ -2551,7 +2668,7 @@ void MainWindow::findFileContextActionTriggered(void) } else { - qWarning("SystemRoot directory could not be detected!"); + qWarning("System tools directory could not be detected!"); } } } @@ -2575,38 +2692,25 @@ void MainWindow::handleDroppedFiles(void) QFileInfo file(m_droppedFileList->takeFirst().toLocalFile()); QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); - if(!file.exists()) - { - continue; - } - - if(file.isFile()) + if(file.exists()) { - qDebug("Dropped File: %s", MUTILS_UTF8(file.canonicalFilePath())); - droppedFiles << file.canonicalFilePath(); - continue; - } - - if(file.isDir()) - { - qDebug("Dropped Folder: %s", MUTILS_UTF8(file.canonicalFilePath())); - QFileInfoList list = QDir(file.canonicalFilePath()).entryInfoList(QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks); - if(list.count() > 0) + if(file.isFile()) { - showBanner(bannerText, bUseBanner, (list.count() >= MIN_COUNT)); - for(QFileInfoList::ConstIterator iter = list.constBegin(); iter != list.constEnd(); iter++) - { - droppedFiles << (*iter).canonicalFilePath(); - } + qDebug("Dropped File: %s", MUTILS_UTF8(file.canonicalFilePath())); + droppedFiles << file.canonicalFilePath(); + continue; } - else + else if(file.isDir()) { - list = QDir(file.canonicalFilePath()).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks); - showBanner(bannerText, bUseBanner, (list.count() >= MIN_COUNT)); - for(QFileInfoList::ConstIterator iter = list.constBegin(); iter != list.constEnd(); iter++) + qDebug("Dropped Folder: %s", MUTILS_UTF8(file.canonicalFilePath())); + QFileInfoList list = QDir(file.canonicalFilePath()).entryInfoList(QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks); + if(list.count() > 0) { - qDebug("Descending to Folder: %s", MUTILS_UTF8((*iter).canonicalFilePath())); - m_droppedFileList->prepend(QUrl::fromLocalFile((*iter).canonicalFilePath())); + showBanner(bannerText, bUseBanner, (list.count() >= MIN_COUNT)); + for(QFileInfoList::ConstIterator iter = list.constBegin(); iter != list.constEnd(); iter++) + { + droppedFiles << (*iter).canonicalFilePath(); + } } } } @@ -2694,16 +2798,16 @@ void MainWindow::exportCsvContextActionTriggered(void) switch(m_fileListModel->exportToCsv(selectedCsvFile)) { case FileListModel::CsvError_NoTags: - QMessageBox::critical(this, tr("CSV Export"), NOBR(tr("Sorry, there are no meta tags that can be exported!"))); + QMessageBox::critical(this, tr("CSV Export"), NOBREAK(tr("Sorry, there are no meta tags that can be exported!"))); break; case FileListModel::CsvError_FileOpen: - QMessageBox::critical(this, tr("CSV Export"), NOBR(tr("Sorry, failed to open CSV file for writing!"))); + QMessageBox::critical(this, tr("CSV Export"), NOBREAK(tr("Sorry, failed to open CSV file for writing!"))); break; case FileListModel::CsvError_FileWrite: - QMessageBox::critical(this, tr("CSV Export"), NOBR(tr("Sorry, failed to write to the CSV file!"))); + QMessageBox::critical(this, tr("CSV Export"), NOBREAK(tr("Sorry, failed to write to the CSV file!"))); break; case FileListModel::CsvError_OK: - QMessageBox::information(this, tr("CSV Export"), NOBR(tr("The CSV files was created successfully!"))); + QMessageBox::information(this, tr("CSV Export"), NOBREAK(tr("The CSV files was created successfully!"))); break; default: qWarning("exportToCsv: Unknown return code!"); @@ -2743,19 +2847,19 @@ void MainWindow::importCsvContextActionTriggered(void) switch(m_fileListModel->importFromCsv(this, selectedCsvFile)) { case FileListModel::CsvError_FileOpen: - QMessageBox::critical(this, tr("CSV Import"), NOBR(tr("Sorry, failed to open CSV file for reading!"))); + QMessageBox::critical(this, tr("CSV Import"), NOBREAK(tr("Sorry, failed to open CSV file for reading!"))); break; case FileListModel::CsvError_FileRead: - QMessageBox::critical(this, tr("CSV Import"), NOBR(tr("Sorry, failed to read from the CSV file!"))); + QMessageBox::critical(this, tr("CSV Import"), NOBREAK(tr("Sorry, failed to read from the CSV file!"))); break; case FileListModel::CsvError_NoTags: - QMessageBox::critical(this, tr("CSV Import"), NOBR(tr("Sorry, the CSV file does not contain any known fields!"))); + QMessageBox::critical(this, tr("CSV Import"), NOBREAK(tr("Sorry, the CSV file does not contain any known fields!"))); break; case FileListModel::CsvError_Incomplete: - QMessageBox::warning(this, tr("CSV Import"), NOBR(tr("CSV file is incomplete. Not all files were updated!"))); + QMessageBox::warning(this, tr("CSV Import"), NOBREAK(tr("CSV file is incomplete. Not all files were updated!"))); break; case FileListModel::CsvError_OK: - QMessageBox::information(this, tr("CSV Import"), NOBR(tr("The CSV files was imported successfully!"))); + QMessageBox::information(this, tr("CSV Import"), NOBREAK(tr("The CSV files was imported successfully!"))); break; case FileListModel::CsvError_Aborted: /* User aborted, ignore! */ @@ -2825,13 +2929,13 @@ void MainWindow::gotoDesktopButtonClicked(void) return; } - QString desktopPath = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation); + const QString desktopPath = MUtils::OS::known_folder(MUtils::OS::FOLDER_DESKTOP_USER); if(!desktopPath.isEmpty() && QDir(desktopPath).exists()) { ui->outputFolderView->setCurrentIndex(m_fileSystemModel->index(desktopPath)); outputFolderViewClicked(ui->outputFolderView->currentIndex()); - CENTER_CURRENT_OUTPUT_FOLDER_DELAYED; + CENTER_CURRENT_OUTPUT_FOLDER_DELAYED(); } else { @@ -2850,13 +2954,13 @@ void MainWindow::gotoHomeFolderButtonClicked(void) return; } - QString homePath = QDesktopServices::storageLocation(QDesktopServices::HomeLocation); - + const QString homePath = MUtils::OS::known_folder(MUtils::OS::FOLDER_PROFILE_USER); + if(!homePath.isEmpty() && QDir(homePath).exists()) { ui->outputFolderView->setCurrentIndex(m_fileSystemModel->index(homePath)); outputFolderViewClicked(ui->outputFolderView->currentIndex()); - CENTER_CURRENT_OUTPUT_FOLDER_DELAYED; + CENTER_CURRENT_OUTPUT_FOLDER_DELAYED(); } else { @@ -2875,13 +2979,13 @@ void MainWindow::gotoMusicFolderButtonClicked(void) return; } - QString musicPath = QDesktopServices::storageLocation(QDesktopServices::MusicLocation); + const QString musicPath = MUtils::OS::known_folder(MUtils::OS::FOLDER_MUSIC_USER); if(!musicPath.isEmpty() && QDir(musicPath).exists()) { ui->outputFolderView->setCurrentIndex(m_fileSystemModel->index(musicPath)); outputFolderViewClicked(ui->outputFolderView->currentIndex()); - CENTER_CURRENT_OUTPUT_FOLDER_DELAYED; + CENTER_CURRENT_OUTPUT_FOLDER_DELAYED(); } else { @@ -2909,7 +3013,7 @@ void MainWindow::gotoFavoriteFolder(void) { ui->outputFolderView->setCurrentIndex(m_fileSystemModel->index(path.canonicalPath())); outputFolderViewClicked(ui->outputFolderView->currentIndex()); - CENTER_CURRENT_OUTPUT_FOLDER_DELAYED; + CENTER_CURRENT_OUTPUT_FOLDER_DELAYED(); } else { @@ -2927,7 +3031,7 @@ void MainWindow::makeFolderButtonClicked(void) { ABORT_IF_BUSY; - if(!m_fileSystemModel) + if(m_fileSystemModel.isNull()) { qWarning("File system model not initialized yet!"); return; @@ -2946,7 +3050,7 @@ void MainWindow::makeFolderButtonClicked(void) } else if(!m_metaData->album().isEmpty()) { - suggestedName =m_metaData->album(); + suggestedName = m_metaData->album(); } else { @@ -2974,7 +3078,7 @@ void MainWindow::makeFolderButtonClicked(void) } } - suggestedName = MUtils::clean_file_name(suggestedName); + suggestedName = MUtils::clean_file_name(suggestedName, true); while(true) { @@ -2983,7 +3087,7 @@ void MainWindow::makeFolderButtonClicked(void) if(bApplied) { - folderName = MUtils::clean_file_path(folderName.simplified()); + folderName = MUtils::clean_file_path(folderName.simplified(), true); if(folderName.isEmpty()) { @@ -3007,12 +3111,12 @@ void MainWindow::makeFolderButtonClicked(void) QModelIndex newIndex = m_fileSystemModel->index(createdDir.canonicalPath()); ui->outputFolderView->setCurrentIndex(newIndex); outputFolderViewClicked(newIndex); - CENTER_CURRENT_OUTPUT_FOLDER_DELAYED; + CENTER_CURRENT_OUTPUT_FOLDER_DELAYED(); } } else { - QMessageBox::warning(this, tr("Failed to create folder"), QString("%1
%2

%3").arg(tr("The new folder could not be created:"), basePath.absoluteFilePath(newFolder), tr("Drive is read-only or insufficient access rights!"))); + QMessageBox::warning(this, tr("Failed to create folder"), NOBREAK(QString("%1
%2

%3").arg(tr("The new folder could not be created:"), basePath.absoluteFilePath(newFolder), tr("Drive is read-only or insufficient access rights!")))); } } break; @@ -3093,7 +3197,7 @@ void MainWindow::goUpFolderContextActionTriggered(void) { MUtils::Sound::beep(MUtils::Sound::BEEP_WRN); } - CENTER_CURRENT_OUTPUT_FOLDER_DELAYED; + CENTER_CURRENT_OUTPUT_FOLDER_DELAYED(); } } @@ -3179,7 +3283,7 @@ void MainWindow::outputFolderEditFinished(void) ui->outputFolderView->setEnabled(true); if(!ok) MUtils::Sound::beep(MUtils::Sound::BEEP_ERR); - CENTER_CURRENT_OUTPUT_FOLDER_DELAYED; + CENTER_CURRENT_OUTPUT_FOLDER_DELAYED(); } /* @@ -3218,7 +3322,7 @@ void MainWindow::initOutputFolderModel(void) outputFolderViewClicked(ui->outputFolderView->currentIndex()); } - CENTER_CURRENT_OUTPUT_FOLDER_DELAYED; + CENTER_CURRENT_OUTPUT_FOLDER_DELAYED(); QTimer::singleShot(125, this, SLOT(initOutputFolderModel_doAsync())); } } @@ -3273,7 +3377,7 @@ void MainWindow::outputFolderDirectoryLoaded(const QString &path) { if(m_outputFolderViewCentering) { - CENTER_CURRENT_OUTPUT_FOLDER_DELAYED; + CENTER_CURRENT_OUTPUT_FOLDER_DELAYED(); } } @@ -3284,7 +3388,7 @@ void MainWindow::outputFolderRowsInserted(const QModelIndex &parent, int start, { if(m_outputFolderViewCentering) { - CENTER_CURRENT_OUTPUT_FOLDER_DELAYED; + CENTER_CURRENT_OUTPUT_FOLDER_DELAYED(); } } @@ -3837,7 +3941,7 @@ void MainWindow::normalizationFilterSizeFinished(void) const int value = ui->spinBoxNormalizationFilterSize->value(); if((value % 2) != 1) { - bool rnd = MUtils::parity(MUtils::next_rand32()); + bool rnd = MUtils::parity(MUtils::next_rand_u32()); ui->spinBoxNormalizationFilterSize->setValue(rnd ? value+1 : value-1); } } @@ -3954,7 +4058,7 @@ void MainWindow::renameOutputPatternChanged(const QString &text, const bool &sil pattern.replace("", "2001", Qt::CaseInsensitive); pattern.replace("", "Encoded by LameXP", Qt::CaseInsensitive); - const QString patternClean = MUtils::clean_file_name(pattern); + const QString patternClean = MUtils::clean_file_name(pattern, false); if(pattern.compare(patternClean)) { @@ -4046,7 +4150,7 @@ void MainWindow::renameRegExpReplaceChanged(const QString &text, const bool &si } } - if(replacement.compare(MUtils::clean_file_name(replacement))) + if(replacement.compare(MUtils::clean_file_name(replacement, false))) { if(ui->lineEditRenameRegExp_Replace->palette().color(QPalette::Text) != Qt::red) { @@ -4138,18 +4242,19 @@ void MainWindow::forceStereoDownmixEnabledChanged(bool checked) /* * Maximum number of instances changed */ -void MainWindow::updateMaximumInstances(int value) +void MainWindow::updateMaximumInstances(const int value) { - ui->labelMaxInstances->setText(tr("%n Instance(s)", "", value)); - m_settings->maximumInstances(ui->checkBoxAutoDetectInstances->isChecked() ? NULL : value); + const quint32 instances = decodeInstances(qBound(1U, static_cast(value), 32U)); + m_settings->maximumInstances(ui->checkBoxAutoDetectInstances->isChecked() ? 0U : instances); + ui->labelMaxInstances->setText(tr("%n Instance(s)", "", static_cast(instances))); } /* * Auto-detect number of instances */ -void MainWindow::autoDetectInstancesChanged(bool checked) +void MainWindow::autoDetectInstancesChanged(const bool checked) { - m_settings->maximumInstances(checked ? NULL : ui->sliderMaxInstances->value()); + m_settings->maximumInstances(checked ? 0U : decodeInstances(qBound(1U, static_cast(ui->sliderMaxInstances->value()), 32U))); } /* @@ -4176,7 +4281,7 @@ void MainWindow::browseCustomTempFolderButtonClicked(void) if(!newTempFolder.isEmpty()) { - QFile writeTest(QString("%1/~%2.tmp").arg(newTempFolder, MUtils::rand_str())); + QFile writeTest(QString("%1/~%2.tmp").arg(newTempFolder, MUtils::next_rand_str())); if(writeTest.open(QIODevice::ReadWrite)) { writeTest.remove(); @@ -4313,6 +4418,10 @@ void MainWindow::showCustomParamsHelpScreen(const QString &toolName, const QStri dialog->exec(output); } +/* +* File overwrite mode has changed +*/ + void MainWindow::overwriteModeChanged(int id) { if((id == SettingsModel::Overwrite_Replaces) && (m_settings->overwriteMode() != SettingsModel::Overwrite_Replaces)) @@ -4329,6 +4438,14 @@ void MainWindow::overwriteModeChanged(int id) } /* +* Keep original date/time opertion changed +*/ +void MainWindow::keepOriginalDateTimeChanged(bool checked) +{ + m_settings->keepOriginalDataTime(checked); +} + +/* * Reset all advanced options to their defaults */ void MainWindow::resetAdvancedOptionsButtonClicked(void) @@ -4363,7 +4480,8 @@ void MainWindow::resetAdvancedOptionsButtonClicked(void) SET_CHECKBOX_STATE(ui->checkBoxRename_RegExp, m_settings->renameFiles_regExpEnabledDefault()); SET_CHECKBOX_STATE(ui->checkBoxForceStereoDownmix, m_settings->forceStereoDownmixDefault()); SET_CHECKBOX_STATE(ui->checkBoxOpusDisableResample, m_settings->opusDisableResampleDefault()); - + SET_CHECKBOX_STATE(ui->checkBoxKeepOriginalDateTime, m_settings->keepOriginalDataTimeDefault()); + ui->lineEditCustomParamLAME ->setText(m_settings->customParametersLAMEDefault()); ui->lineEditCustomParamOggEnc ->setText(m_settings->customParametersOggEncDefault()); ui->lineEditCustomParamNeroAAC ->setText(m_settings->customParametersAacEncDefault());