Moved all the Sound-specific functions into MUtilities library.
This commit is contained in:
parent
187f1bbfb8
commit
8211b417d6
@ -35,7 +35,7 @@
|
||||
#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
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -31,6 +31,7 @@
|
||||
//MUtils
|
||||
#include <MUtils/Global.h>
|
||||
#include <MUtils/OSSupport.h>
|
||||
#include <MUtils/Sound.h>
|
||||
#include <MUtils/Version.h>
|
||||
|
||||
//Qt
|
||||
@ -259,14 +260,14 @@ int AboutDialog::exec()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,7 +339,7 @@ void AboutDialog::tabChanged(int index, const bool silent)
|
||||
//Play tick sound
|
||||
if(m_settings->soundsEnabled() && (!silent))
|
||||
{
|
||||
lamexp_play_sound("tick", true);
|
||||
MUtils::Sound::play_sound("tick", true);
|
||||
}
|
||||
|
||||
//Scroll to the top
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
//MUtils
|
||||
#include <MUtils/Global.h>
|
||||
#include <MUtils/Sound.h>
|
||||
|
||||
//Qt includes
|
||||
#include <QClipboard>
|
||||
@ -90,7 +91,7 @@ void LogViewDialog::copyButtonClicked(void)
|
||||
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)
|
||||
|
@ -52,6 +52,7 @@
|
||||
#include <MUtils/OSSupport.h>
|
||||
#include <MUtils/GUI.h>
|
||||
#include <MUtils/Exception.h>
|
||||
#include <MUtils/Sound.h>
|
||||
#include <MUtils/Version.h>
|
||||
|
||||
//Qt includes
|
||||
@ -124,7 +125,7 @@ while(0)
|
||||
{ \
|
||||
if(BANNER_VISIBLE || m_delayedFileTimer->isActive() || (QApplication::activeModalWidget() != NULL)) \
|
||||
{ \
|
||||
lamexp_beep(lamexp_beep_warning); \
|
||||
MUtils::Sound::beep(MUtils::Sound::BEEP_WRN); \
|
||||
return; \
|
||||
} \
|
||||
} \
|
||||
@ -201,7 +202,7 @@ while(0)
|
||||
|
||||
#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)
|
||||
|
||||
@ -836,7 +837,7 @@ void MainWindow::addFolder(const QString &path, bool recursive, bool delayed)
|
||||
{
|
||||
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;
|
||||
@ -1152,7 +1153,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if(BANNER_VISIBLE || m_delayedFileTimer->isActive())
|
||||
{
|
||||
lamexp_beep(lamexp_beep_warning);
|
||||
MUtils::Sound::beep(MUtils::Sound::BEEP_WRN);
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
@ -1197,7 +1198,7 @@ void MainWindow::keyPressEvent(QKeyEvent *e)
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1315,7 +1316,7 @@ void MainWindow::windowShown(void)
|
||||
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())
|
||||
@ -1331,7 +1332,7 @@ void MainWindow::windowShown(void)
|
||||
return;
|
||||
}
|
||||
|
||||
lamexp_play_sound("woohoo", false);
|
||||
MUtils::Sound::play_sound("woohoo", false);
|
||||
m_settings->licenseAccepted(1);
|
||||
m_settings->syncNow();
|
||||
if(lamexp_version_demo()) showAnnounceBox();
|
||||
@ -1343,7 +1344,7 @@ void MainWindow::windowShown(void)
|
||||
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();
|
||||
@ -1386,7 +1387,7 @@ void MainWindow::windowShown(void)
|
||||
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;
|
||||
}
|
||||
@ -2855,7 +2856,7 @@ void MainWindow::gotoFavoriteFolder(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
lamexp_beep(lamexp_beep_error);
|
||||
MUtils::Sound::beep(MUtils::Sound::BEEP_ERR);
|
||||
m_outputFolderFavoritesMenu->removeAction(item);
|
||||
item->deleteLater();
|
||||
}
|
||||
@ -2916,7 +2917,7 @@ void MainWindow::makeFolderButtonClicked(void)
|
||||
}
|
||||
}
|
||||
|
||||
suggestedName = lamexp_clean_filename(suggestedName);
|
||||
suggestedName = MUtils::clean_file_name(suggestedName);
|
||||
|
||||
while(true)
|
||||
{
|
||||
@ -2925,11 +2926,11 @@ void MainWindow::makeFolderButtonClicked(void)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -3033,7 +3034,7 @@ void MainWindow::goUpFolderContextActionTriggered(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
lamexp_beep(lamexp_beep_warning);
|
||||
MUtils::Sound::beep(MUtils::Sound::BEEP_WRN);
|
||||
}
|
||||
CENTER_CURRENT_OUTPUT_FOLDER_DELAYED;
|
||||
}
|
||||
@ -3054,7 +3055,7 @@ void MainWindow::addFavoriteFolderActionTriggered(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
lamexp_beep(lamexp_beep_warning);
|
||||
MUtils::Sound::beep(MUtils::Sound::BEEP_WRN);
|
||||
}
|
||||
|
||||
m_settings->favoriteOutputFolders(favorites.join("|"));
|
||||
@ -3120,7 +3121,7 @@ void MainWindow::outputFolderEditFinished(void)
|
||||
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;
|
||||
}
|
||||
|
||||
@ -3845,13 +3846,13 @@ void MainWindow::renameOutputPatternChanged(const QString &text, bool silent)
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -3859,7 +3860,7 @@ void MainWindow::renameOutputPatternChanged(const QString &text, bool silent)
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
@ -3998,13 +3999,13 @@ void MainWindow::customParamsHelpRequested(QWidget *obj, QEvent *event)
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4015,7 +4016,7 @@ void MainWindow::showCustomParamsHelpScreen(const QString &toolName, const QStri
|
||||
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;
|
||||
}
|
||||
@ -4059,7 +4060,7 @@ void MainWindow::showCustomParamsHelpScreen(const QString &toolName, const QStri
|
||||
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);
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include <MUtils/OSSupport.h>
|
||||
#include <MUtils/GUI.h>
|
||||
#include <MUtils/CPUFeatures.h>
|
||||
#include <MUtils/Sound.h>
|
||||
|
||||
//Qt
|
||||
#include <QApplication>
|
||||
@ -122,7 +123,7 @@ while(0)
|
||||
|
||||
#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)
|
||||
|
||||
@ -831,7 +832,7 @@ void ProcessingDialog::logViewDoubleClicked(const QModelIndex &index)
|
||||
}
|
||||
else
|
||||
{
|
||||
lamexp_beep(lamexp_beep_warning);
|
||||
MUtils::Sound::beep(MUtils::Sound::BEEP_WRN);
|
||||
}
|
||||
}
|
||||
|
||||
@ -871,7 +872,7 @@ void ProcessingDialog::contextMenuShowFileActionTriggered(void)
|
||||
|
||||
if(filePath.isEmpty())
|
||||
{
|
||||
lamexp_beep(lamexp_beep_warning);
|
||||
MUtils::Sound::beep(MUtils::Sound::BEEP_WRN);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -902,7 +903,7 @@ void ProcessingDialog::contextMenuShowFileActionTriggered(void)
|
||||
else
|
||||
{
|
||||
qWarning("File not found: %s", filePath.toLatin1().constData());
|
||||
lamexp_beep(lamexp_beep_error);
|
||||
MUtils::Sound::beep(MUtils::Sound::BEEP_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -983,7 +984,7 @@ void ProcessingDialog::writePlayList(void)
|
||||
}
|
||||
|
||||
//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++)
|
||||
|
@ -35,8 +35,10 @@
|
||||
#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>
|
||||
@ -343,13 +345,13 @@ void UpdateDialog::threadFinished(void)
|
||||
|
||||
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())
|
||||
{
|
||||
@ -485,5 +487,5 @@ void UpdateDialog::testKnownHosts(void)
|
||||
}
|
||||
|
||||
ui->statusLabel->setText("Test completed.");
|
||||
lamexp_beep(lamexp_beep_info);
|
||||
MUtils::Sound::beep(MUtils::Sound::BEEP_NFO);
|
||||
}
|
||||
|
25
src/Global.h
25
src/Global.h
@ -45,24 +45,6 @@ extern const char* LAMEXP_DEFAULT_TRANSLATION;
|
||||
// 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
|
||||
{
|
||||
@ -79,7 +61,6 @@ lamexp_syscolor_t;
|
||||
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);
|
||||
@ -87,9 +68,6 @@ bool lamexp_bring_to_front(const QWidget *win);
|
||||
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);
|
||||
@ -99,9 +77,6 @@ void lamexp_ipc_read(unsigned int *command, char* message, size_t buffSize);
|
||||
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);
|
||||
|
@ -58,45 +58,6 @@ g_lamexp_app_icon;
|
||||
// GLOBAL FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
@ -155,22 +155,6 @@ const char* LAMEXP_DEFAULT_TRANSLATION = "LameXP_EN.qm";
|
||||
// GLOBAL FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* 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)
|
||||
*/
|
||||
@ -214,123 +198,6 @@ bool lamexp_themes_enabled(void)
|
||||
return g_lamexp_themes_enabled.bThemesEnabled;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
@ -208,10 +208,10 @@ void CueSplitter::run()
|
||||
|
||||
//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
|
||||
|
@ -500,7 +500,7 @@ QString ProcessThread::applyRenamePattern(const QString &baseName, const AudioFi
|
||||
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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user