Re-enabled 'async' mode for play_sound_file() function + fixed possible handle leak in setOverlayIcon() function.
This commit is contained in:
parent
77219cf7d4
commit
00013f50f0
@ -38,16 +38,16 @@ namespace MUtils
|
|||||||
};
|
};
|
||||||
|
|
||||||
//Simple beep
|
//Simple beep
|
||||||
MUTILS_API bool beep(beep_t beepType);
|
MUTILS_API bool beep(const beep_t &beepType);
|
||||||
|
|
||||||
//Play built-in sound by name
|
//Play built-in sound by name
|
||||||
MUTILS_API bool play_sound(const QString &name, const bool bAsync);
|
MUTILS_API bool play_sound(const QString &name, const bool &bAsync);
|
||||||
|
|
||||||
//Play system sound by name
|
//Play system sound by name
|
||||||
MUTILS_API bool play_system_sound(const QString &alias, const bool bAsync);
|
MUTILS_API bool play_system_sound(const QString &alias, const bool &bAsync);
|
||||||
|
|
||||||
//Play sound from file
|
//Play sound from file
|
||||||
MUTILS_API bool play_sound_file(const QString &library, const unsigned short uiSoundIdx);
|
MUTILS_API bool play_sound_file(const QString &library, const unsigned short uiSoundIdx, const bool &bAsync);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
// BEEP
|
// BEEP
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool MUtils::Sound::beep(MUtils::Sound::beep_t beepType)
|
bool MUtils::Sound::beep(const MUtils::Sound::beep_t &beepType)
|
||||||
{
|
{
|
||||||
switch(beepType)
|
switch(beepType)
|
||||||
{
|
{
|
||||||
@ -97,7 +97,7 @@ static const unsigned char *get_sound_from_cache(const QString &name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MUtils::Sound::play_sound(const QString &name, const bool bAsync)
|
bool MUtils::Sound::play_sound(const QString &name, const bool &bAsync)
|
||||||
{
|
{
|
||||||
if(!name.isEmpty())
|
if(!name.isEmpty())
|
||||||
{
|
{
|
||||||
@ -110,12 +110,12 @@ bool MUtils::Sound::play_sound(const QString &name, const bool bAsync)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MUtils::Sound::play_system_sound(const QString &alias, const bool bAsync)
|
bool MUtils::Sound::play_system_sound(const QString &alias, const bool &bAsync)
|
||||||
{
|
{
|
||||||
return PlaySound(MUTILS_WCHR(alias), GetModuleHandle(NULL), (SND_ALIAS | (bAsync ? SND_ASYNC : SND_SYNC))) != FALSE;
|
return PlaySound(MUTILS_WCHR(alias), GetModuleHandle(NULL), (SND_ALIAS | (bAsync ? SND_ASYNC : SND_SYNC))) != FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MUtils::Sound::play_sound_file(const QString &library, const unsigned short uiSoundIdx)
|
bool MUtils::Sound::play_sound_file(const QString &library, const unsigned short uiSoundIdx, const bool &bAsync)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
@ -131,9 +131,13 @@ bool MUtils::Sound::play_sound_file(const QString &library, const unsigned short
|
|||||||
|
|
||||||
if(libraryFile.exists() && libraryFile.isFile())
|
if(libraryFile.exists() && libraryFile.isFile())
|
||||||
{
|
{
|
||||||
if(const HMODULE module = LoadLibraryW(MUTILS_WCHR(QDir::toNativeSeparators(libraryFile.canonicalFilePath()))))
|
if(const HMODULE module = GetModuleHandleW(MUTILS_WCHR(QDir::toNativeSeparators(libraryFile.canonicalFilePath()))))
|
||||||
{
|
{
|
||||||
result = (PlaySound(MAKEINTRESOURCE(uiSoundIdx), module, (SND_RESOURCE | SND_SYNC)) != FALSE);
|
result = (PlaySound(MAKEINTRESOURCE(uiSoundIdx), module, (SND_RESOURCE | (bAsync ? SND_ASYNC : SND_SYNC))) != FALSE);
|
||||||
|
}
|
||||||
|
else if(const HMODULE module = LoadLibraryW(MUTILS_WCHR(QDir::toNativeSeparators(libraryFile.canonicalFilePath()))))
|
||||||
|
{
|
||||||
|
result = (PlaySound(MAKEINTRESOURCE(uiSoundIdx), module, (SND_RESOURCE | (bAsync ? SND_ASYNC : SND_SYNC))) != FALSE);
|
||||||
FreeLibrary(module);
|
FreeLibrary(module);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,19 @@ bool MUtils::Taskbar7::setTaskbarProgress(const quint64 ¤tValue, const qui
|
|||||||
bool MUtils::Taskbar7::setOverlayIcon(const QIcon *const icon, const QString &info)
|
bool MUtils::Taskbar7::setOverlayIcon(const QIcon *const icon, const QString &info)
|
||||||
{
|
{
|
||||||
INITIALIZE_TASKBAR();
|
INITIALIZE_TASKBAR();
|
||||||
const HRESULT result = p->taskbarList->SetOverlayIcon(m_window->winId(), (icon ? icon->pixmap(16,16).toWinHICON() : NULL), MUTILS_WCHR(info));
|
HRESULT result = HRESULT(-1);
|
||||||
|
if(icon)
|
||||||
|
{
|
||||||
|
if(const HICON hIcon = icon->pixmap(16,16).toWinHICON())
|
||||||
|
{
|
||||||
|
result = p->taskbarList->SetOverlayIcon(m_window->winId(), hIcon, MUTILS_WCHR(info));
|
||||||
|
DestroyIcon(hIcon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = p->taskbarList->SetOverlayIcon(m_window->winId(), NULL, MUTILS_WCHR(info));
|
||||||
|
}
|
||||||
return SUCCEEDED(result);
|
return SUCCEEDED(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user