#define VER_LAMEXP_MINOR_LO 1
#define VER_LAMEXP_TYPE Beta
#define VER_LAMEXP_PATCH 4
-#define VER_LAMEXP_BUILD 1613
+#define VER_LAMEXP_BUILD 1615
#define VER_LAMEXP_CONFG 1558
///////////////////////////////////////////////////////////////////////////////
//MUtils
#include <MUtils/Global.h>
#include <MUtils/OSSupport.h>
+#include <MUtils/Sound.h>
#include <MUtils/Version.h>
//Qt
{
if(m_firstShow)
{
- if(!lamexp_play_sound_file("imageres.dll", 5080, true))
+ if(!MUtils::Sound::play_sound_file("imageres.dll", 5080))
{
- lamexp_play_sound_alias("SystemStart", true);
+ MUtils::Sound::play_system_sound("SystemStart", true);
}
}
else
{
- lamexp_play_sound("uuaarrgh", true);
+ MUtils::Sound::play_sound("uuaarrgh", true);
}
}
//Play tick sound
if(m_settings->soundsEnabled() && (!silent))
{
- lamexp_play_sound("tick", true);
+ MUtils::Sound::play_sound("tick", true);
}
//Scroll to the top
//MUtils
#include <MUtils/Global.h>
+#include <MUtils/Sound.h>
//Qt includes
#include <QClipboard>
ui->buttonCopy->setIcon(*m_acceptIcon);
ui->buttonCopy->blockSignals(true);
QTimer::singleShot(1250, this, SLOT(restoreIcon()));
- lamexp_beep(lamexp_beep_info);
+ MUtils::Sound::beep(MUtils::Sound::BEEP_NFO);
}
void LogViewDialog::saveButtonClicked(void)
#include <MUtils/OSSupport.h>
#include <MUtils/GUI.h>
#include <MUtils/Exception.h>
+#include <MUtils/Sound.h>
#include <MUtils/Version.h>
//Qt includes
{ \
if(BANNER_VISIBLE || m_delayedFileTimer->isActive() || (QApplication::activeModalWidget() != NULL)) \
{ \
- lamexp_beep(lamexp_beep_warning); \
+ MUtils::Sound::beep(MUtils::Sound::BEEP_WRN); \
return; \
} \
} \
#define PLAY_SOUND_OPTIONAL(NAME, ASYNC) do \
{ \
- if(m_settings->soundsEnabled()) lamexp_play_sound((NAME), (ASYNC)); \
+ if(m_settings->soundsEnabled()) MUtils::Sound::play_sound((NAME), (ASYNC)); \
} \
while(0)
{
if(lamexp_check_escape_state())
{
- lamexp_beep(lamexp_beep_error);
+ MUtils::Sound::beep(MUtils::Sound::BEEP_ERR);
qWarning("Operation cancelled by user!");
fileList.clear();
break;
{
if(BANNER_VISIBLE || m_delayedFileTimer->isActive())
{
- lamexp_beep(lamexp_beep_warning);
+ MUtils::Sound::beep(MUtils::Sound::BEEP_WRN);
event->ignore();
}
if(e->modifiers().testFlag(Qt::ControlModifier) && (e->key() == Qt::Key_F5))
{
initializeTranslation();
- lamexp_beep(lamexp_beep_info);
+ MUtils::Sound::beep(MUtils::Sound::BEEP_NFO);
return;
}
m_settings->licenseAccepted(++iAccepted);
m_settings->syncNow();
QApplication::processEvents();
- lamexp_play_sound("whammy", false);
+ 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())
return;
}
- lamexp_play_sound("woohoo", false);
+ MUtils::Sound::play_sound("woohoo", false);
m_settings->licenseAccepted(1);
m_settings->syncNow();
if(lamexp_version_demo()) showAnnounceBox();
if(MUtils::OS::current_date() >= lamexp_version_expires())
{
qWarning("Binary has expired !!!");
- lamexp_play_sound("whammy", false);
+ MUtils::Sound::play_sound("whammy", false);
if(QMessageBox::warning(this, tr("LameXP - Expired"), QString("%1<br>%2").arg(NOBR(tr("This demo (pre-release) version of LameXP has expired at %1.").arg(lamexp_version_expires().toString(Qt::ISODate))), NOBR(tr("LameXP is free software and release versions won't expire."))), tr("Check for Updates"), tr("Exit Program")) == 0)
{
checkForUpdates();
return;
default:
QEventLoop loop; QTimer::singleShot(7000, &loop, SLOT(quit()));
- lamexp_play_sound("waiting", true);
+ MUtils::Sound::play_sound("waiting", true);
SHOW_BANNER_ARG(tr("Skipping update check this time, please be patient..."), &loop);
break;
}
}
else
{
- lamexp_beep(lamexp_beep_error);
+ MUtils::Sound::beep(MUtils::Sound::BEEP_ERR);
m_outputFolderFavoritesMenu->removeAction(item);
item->deleteLater();
}
}
}
- suggestedName = lamexp_clean_filename(suggestedName);
+ suggestedName = MUtils::clean_file_name(suggestedName);
while(true)
{
if(bApplied)
{
- folderName = lamexp_clean_filepath(folderName.simplified());
+ folderName = MUtils::clean_file_path(folderName.simplified());
if(folderName.isEmpty())
{
- lamexp_beep(lamexp_beep_error);
+ MUtils::Sound::beep(MUtils::Sound::BEEP_ERR);
continue;
}
}
else
{
- lamexp_beep(lamexp_beep_warning);
+ MUtils::Sound::beep(MUtils::Sound::BEEP_WRN);
}
CENTER_CURRENT_OUTPUT_FOLDER_DELAYED;
}
}
else
{
- lamexp_beep(lamexp_beep_warning);
+ MUtils::Sound::beep(MUtils::Sound::BEEP_WRN);
}
m_settings->favoriteOutputFolders(favorites.join("|"));
ui->outputFolderLabel->setVisible(true);
ui->outputFolderView->setEnabled(true);
- if(!ok) lamexp_beep(lamexp_beep_error);
+ if(!ok) MUtils::Sound::beep(MUtils::Sound::BEEP_ERR);
CENTER_CURRENT_OUTPUT_FOLDER_DELAYED;
}
pattern.replace("<Year>", "2001", Qt::CaseInsensitive);
pattern.replace("<Comment>", "Encoded by LameXP", Qt::CaseInsensitive);
- const QString patternClean = lamexp_clean_filename(pattern);
+ const QString patternClean = MUtils::clean_file_name(pattern);
if(pattern.compare(patternClean))
{
if(ui->lineEditRenamePattern->palette().color(QPalette::Text) != Qt::red)
{
- if(!silent) lamexp_beep(lamexp_beep_error);
+ if(!silent) MUtils::Sound::beep(MUtils::Sound::BEEP_ERR);
SET_TEXT_COLOR(ui->lineEditRenamePattern, Qt::red);
}
}
{
if(ui->lineEditRenamePattern->palette() != QPalette())
{
- if(!silent) lamexp_beep(lamexp_beep_info);
+ if(!silent) MUtils::Sound::beep(MUtils::Sound::BEEP_NFO);
ui->lineEditRenamePattern->setPalette(QPalette());
}
}
case SettingsModel::AAC_ENCODER_QAAC: showCustomParamsHelpScreen("qaac.exe", "--help"); break;
case SettingsModel::AAC_ENCODER_FHG : showCustomParamsHelpScreen("fhgaacenc.exe", ""); break;
case SettingsModel::AAC_ENCODER_NERO: showCustomParamsHelpScreen("neroAacEnc.exe", "-help"); break;
- default: lamexp_beep(lamexp_beep_error); break;
+ default: MUtils::Sound::beep(MUtils::Sound::BEEP_ERR); break;
}
}
else if(obj == ui->helpCustomParamFLAC) showCustomParamsHelpScreen("flac.exe", "--help");
else if(obj == ui->helpCustomParamAften) showCustomParamsHelpScreen("aften.exe", "-h");
else if(obj == ui->helpCustomParamOpus) showCustomParamsHelpScreen("opusenc.exe", "--help");
- else lamexp_beep(lamexp_beep_error);
+ else MUtils::Sound::beep(MUtils::Sound::BEEP_ERR);
}
/*
const QString binary = lamexp_lookup_tool(toolName);
if(binary.isEmpty())
{
- lamexp_beep(lamexp_beep_error);
+ MUtils::Sound::beep(MUtils::Sound::BEEP_ERR);
qWarning("customParamsHelpRequested: Binary could not be found!");
return;
}
if(output.count() < 1)
{
qWarning("Empty output, cannot show help screen!");
- lamexp_beep(lamexp_beep_error);
+ MUtils::Sound::beep(MUtils::Sound::BEEP_ERR);
}
LogViewDialog *dialog = new LogViewDialog(this);
#include <MUtils/OSSupport.h>
#include <MUtils/GUI.h>
#include <MUtils/CPUFeatures.h>
+#include <MUtils/Sound.h>
//Qt
#include <QApplication>
#define PLAY_SOUND_OPTIONAL(NAME, ASYNC) do \
{ \
- if(m_settings->soundsEnabled()) lamexp_play_sound((NAME), (ASYNC)); \
+ if(m_settings->soundsEnabled()) MUtils::Sound::play_sound((NAME), (ASYNC)); \
} \
while(0)
}
else
{
- lamexp_beep(lamexp_beep_warning);
+ MUtils::Sound::beep(MUtils::Sound::BEEP_WRN);
}
}
if(filePath.isEmpty())
{
- lamexp_beep(lamexp_beep_warning);
+ MUtils::Sound::beep(MUtils::Sound::BEEP_WRN);
return;
}
else
{
qWarning("File not found: %s", filePath.toLatin1().constData());
- lamexp_beep(lamexp_beep_error);
+ MUtils::Sound::beep(MUtils::Sound::BEEP_ERR);
}
}
}
//Clean playlist name
- playListName = lamexp_clean_filename(playListName);
+ playListName = MUtils::clean_file_name(playListName);
//Create list of audio files
for(int i = 0; i < m_allJobs.count(); i++)
#include <MUtils/UpdateChecker.h>
#include <MUtils/Version.h>
#include <MUtils/Exception.h>
+#include <MUtils/Sound.h>
#include <MUtils/OSSupport.h>
+
//Qt includes
#include <QClipboard>
#include <QFileDialog>
if(!bSuccess)
{
- if(m_settings->soundsEnabled()) lamexp_play_sound("error", true);
+ if(m_settings->soundsEnabled()) MUtils::Sound::play_sound("error", true);
}
else
{
const bool bHaveUpdate = (m_thread->getUpdateStatus() == MUtils::UpdateChecker::UpdateStatus_CompletedUpdateAvailable);
ui->installButton->setEnabled(bHaveUpdate);
- lamexp_beep(bHaveUpdate ? lamexp_beep_info : lamexp_beep_warning);
+ MUtils::Sound::beep(bHaveUpdate ? MUtils::Sound::BEEP_NFO : MUtils::Sound::BEEP_WRN);
if(const MUtils::UpdateCheckerInfo *const updateInfo = m_thread->getUpdateInfo())
{
}
ui->statusLabel->setText("Test completed.");
- lamexp_beep(lamexp_beep_info);
+ MUtils::Sound::beep(MUtils::Sound::BEEP_NFO);
}
// TYPE DEFINITIONS
///////////////////////////////////////////////////////////////////////////////
-//Beep types
-typedef enum
-{
- lamexp_beep_info = 0,
- lamexp_beep_warning = 1,
- lamexp_beep_error = 2
-}
-lamexp_beep_t;
-
-//Network connection types
-typedef enum
-{
- lamexp_network_err = 0, /*unknown*/
- lamexp_network_non = 1, /*not connected*/
- lamexp_network_yes = 2 /*connected*/
-}
-lamexp_network_t;
-
//System color types
typedef enum
{
const QIcon &lamexp_app_icon(void);
bool lamexp_append_sysmenu(const QWidget *win, const unsigned int identifier, const QString &text);
QStringList lamexp_available_codepages(bool noAliases = true);
-bool lamexp_beep(int beepType);
void lamexp_blink_window(QWidget *poWindow, unsigned int count = 10, unsigned int delay = 150);
bool lamexp_block_window_move(void *message);
bool lamexp_bring_process_to_front(const unsigned long pid);
bool lamexp_check_escape_state(void);
bool lamexp_check_sysmenu_msg(void *message, const unsigned int identifier);
bool lamexp_check_tool(const QString &toolName);
-const QString lamexp_clean_filename(const QString &str);
-const QString lamexp_clean_filepath(const QString &str);
-unsigned long lamexp_dbg_private_bytes(void);
bool lamexp_enable_close_button(const QWidget *win, const bool bEnable = true);
void lamexp_finalization(void);
int lamexp_init_ipc(void);
void lamexp_ipc_send(unsigned int command, const char* message);
const QString lamexp_lookup_tool(const QString &toolName);
const char *lamexp_mulders_url(void);
-bool lamexp_play_sound(const QString &name, const bool bAsync);
-bool lamexp_play_sound_file(const QString &library, const unsigned short uiSoundIdx, const bool bAsync);
-bool lamexp_play_sound_alias(const QString &alias, const bool bAsync);
bool lamexp_portable_mode(void);
QStringList lamexp_query_translations(void);
void lamexp_register_tool(const QString &toolName, LockedFile *file, unsigned int version = 0, const QString *tag = NULL);
///////////////////////////////////////////////////////////////////////////////
/*
- * Remove forbidden characters from a filename
- */
-const QString lamexp_clean_filename(const QString &str)
-{
- QString newStr(str);
- QRegExp rx("\"(.+)\"");
- rx.setMinimal(true);
-
- newStr.replace("\\", "-");
- newStr.replace(" / ", ", ");
- newStr.replace("/", ",");
- newStr.replace(":", "-");
- newStr.replace("*", "x");
- newStr.replace("?", "");
- newStr.replace("<", "[");
- newStr.replace(">", "]");
- newStr.replace("|", "!");
- newStr.replace(rx, "`\\1ยด");
- newStr.replace("\"", "'");
-
- return newStr.simplified();
-}
-
-/*
- * Remove forbidden characters from a file path
- */
-const QString lamexp_clean_filepath(const QString &str)
-{
- QStringList parts = QString(str).replace("\\", "/").split("/");
-
- for(int i = 0; i < parts.count(); i++)
- {
- parts[i] = lamexp_clean_filename(parts[i]);
- }
-
- return parts.join("/");
-}
-
-/*
* Get a list of all available Qt Text Codecs
*/
QStringList lamexp_available_codepages(bool noAliases)
///////////////////////////////////////////////////////////////////////////////
/*
- * Convert QIcon to HICON -> caller is responsible for destroying the HICON!
- */
-static HICON lamexp_qicon2hicon(const QIcon &icon, const int w, const int h)
-{
- if(!icon.isNull())
- {
- QPixmap pixmap = icon.pixmap(w, h);
- if(!pixmap.isNull())
- {
- return pixmap.toWinHICON();
- }
- }
- return NULL;
-}
-
-/*
* Check if visual themes are enabled (WinXP and later)
*/
bool lamexp_themes_enabled(void)
}
/*
- * Block window "move" message
- */
-bool lamexp_block_window_move(void *message)
-{
- if(message)
- {
- MSG *msg = reinterpret_cast<MSG*>(message);
- if((msg->message == WM_SYSCOMMAND) && (msg->wParam == SC_MOVE))
- {
- return true;
- }
- if((msg->message == WM_NCLBUTTONDOWN) && (msg->wParam == HTCAPTION))
- {
- return true;
- }
- }
- return false;
-}
-
-bool lamexp_beep(int beepType)
-{
- switch(beepType)
- {
- case lamexp_beep_info: return MessageBeep(MB_ICONASTERISK) == TRUE; break;
- case lamexp_beep_warning: return MessageBeep(MB_ICONEXCLAMATION) == TRUE; break;
- case lamexp_beep_error: return MessageBeep(MB_ICONHAND) == TRUE; break;
- default: return false;
- }
-}
-
-/*
- * Play a sound (from resources)
- */
-bool lamexp_play_sound(const QString &name, const bool bAsync)
-{
- const unsigned char *data = NULL;
-
- //Try to look-up the sound in the cache first
- if(!name.isEmpty())
- {
- QReadLocker readLock(&g_lamexp_sounds.lock);
- if(g_lamexp_sounds.sound_db && g_lamexp_sounds.sound_db->contains(name))
- {
- data = g_lamexp_sounds.sound_db->value(name);
- }
- }
-
- //If data not found in cache, try to load from resource!
- if((!data) && (!name.isEmpty()))
- {
- QResource resource(QString(":/sounds/%1.wav").arg(name));
- if(resource.isValid() && (data = resource.data()))
- {
- QWriteLocker writeLock(&g_lamexp_sounds.lock);
- if(!g_lamexp_sounds.sound_db)
- {
- g_lamexp_sounds.sound_db = new QHash<const QString, const unsigned char*>();
- }
- g_lamexp_sounds.sound_db->insert(name, data);
- }
- else
- {
- qWarning("Sound effect \"%s\" not found!", MUTILS_UTF8(name));
- }
- }
-
- //Play the sound, if availbale
- if(data)
- {
- return PlaySound(LPCWSTR(data), NULL, (SND_MEMORY | (bAsync ? SND_ASYNC : SND_SYNC))) != FALSE;
- }
-
- return false;
-}
-
-/*
- * Play a sound (system alias)
- */
-bool lamexp_play_sound_alias(const QString &alias, const bool bAsync)
-{
- return PlaySound(MUTILS_WCHR(alias), GetModuleHandle(NULL), (SND_ALIAS | (bAsync ? SND_ASYNC : SND_SYNC))) != FALSE;
-}
-
-/*
- * Play a sound (from external DLL)
- */
-bool lamexp_play_sound_file(const QString &library, const unsigned short uiSoundIdx, const bool bAsync)
-{
- bool result = false;
-
- QFileInfo libraryFile(library);
- if(!libraryFile.isAbsolute())
- {
- const QString &systemDir = MUtils::OS::known_folder(MUtils::OS::FOLDER_SYSTEMFOLDER);
- if(!systemDir.isEmpty())
- {
- libraryFile.setFile(QDir(systemDir), libraryFile.fileName());
- }
- }
-
- if(libraryFile.exists() && libraryFile.isFile())
- {
- if(HMODULE module = LoadLibraryW(MUTILS_WCHR(QDir::toNativeSeparators(libraryFile.canonicalFilePath()))))
- {
- result = (PlaySound(MAKEINTRESOURCE(uiSoundIdx), module, (SND_RESOURCE | (bAsync ? SND_ASYNC : SND_SYNC))) != FALSE);
- FreeLibrary(module);
- }
- }
- else
- {
- qWarning("PlaySound: File \"%s\" could not be found!", MUTILS_UTF8(libraryFile.absoluteFilePath()));
- }
-
- return result;
-}
-
-/*
* Insert entry to the window's system menu
*/
bool lamexp_append_sysmenu(const QWidget *win, const unsigned int identifier, const QString &text)
//Generate output file name
QString trackTitle = trackMetaInfo.title().isEmpty() ? QString().sprintf("Track %02d", trackNo) : trackMetaInfo.title();
- QString outputFile = QString("%1/[%2] %3 - %4.wav").arg(m_outputDir, QString().sprintf("%02d", trackNo), lamexp_clean_filename(m_baseName), lamexp_clean_filename(trackTitle));
+ QString outputFile = QString("%1/[%2] %3 - %4.wav").arg(m_outputDir, QString().sprintf("%02d", trackNo), MUtils::clean_file_name(m_baseName), MUtils::clean_file_name(trackTitle));
for(int n = 2; QFileInfo(outputFile).exists(); n++)
{
- outputFile = QString("%1/[%2] %3 - %4 (%5).wav").arg(m_outputDir, QString().sprintf("%02d", trackNo), lamexp_clean_filename(m_baseName), lamexp_clean_filename(trackTitle), QString::number(n));
+ outputFile = QString("%1/[%2] %3 - %4 (%5).wav").arg(m_outputDir, QString().sprintf("%02d", trackNo), MUtils::clean_file_name(m_baseName), MUtils::clean_file_name(trackTitle), QString::number(n));
}
//Call split function
fileName.replace("<Album>", STRDEF(metaInfo.album(), tr("Unknown Album")), Qt::CaseInsensitive);
fileName.replace("<Year>", QString().sprintf("%04d", metaInfo.year()), Qt::CaseInsensitive);
fileName.replace("<Comment>", STRDEF(metaInfo.comment(), tr("Unknown Comment")), Qt::CaseInsensitive);
- fileName = lamexp_clean_filename(fileName).simplified();
+ fileName = MUtils::clean_file_name(fileName);
return fileName;
}