mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
+ Support for sound playback under Windows added (limited to .wavs though).
This commit is contained in:
parent
2fa0c3b57b
commit
c2977cf9a1
|
@ -8,6 +8,10 @@
|
|||
#include <QMenu>
|
||||
#include <QDesktopServices>
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h> // For PlaySound
|
||||
#endif
|
||||
|
||||
ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm,
|
||||
Instances::Groups const & groups_, bool popupView_ ):
|
||||
|
@ -37,6 +41,18 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm,
|
|||
this, SLOT( linkClicked( QUrl const & ) ) );
|
||||
}
|
||||
|
||||
ArticleView::~ArticleView()
|
||||
{
|
||||
#ifdef Q_OS_WIN32
|
||||
if ( winWavData.size() )
|
||||
{
|
||||
// If we were playing some sound some time ago, make sure it stopped
|
||||
// playing before freeing the waveform memory.
|
||||
PlaySoundA( 0, 0, 0 );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ArticleView::showDefinition( QString const & word, QString const & group )
|
||||
{
|
||||
QUrl req;
|
||||
|
@ -130,6 +146,21 @@ void ArticleView::linkClicked( QUrl const & url )
|
|||
|
||||
// Decide the viewer
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
// Windows-only: use system PlaySound function
|
||||
|
||||
if ( winWavData.size() )
|
||||
PlaySoundA( 0, 0, 0 ); // Stop any currently playing sound to make sure
|
||||
// previous data isn't used anymore
|
||||
//
|
||||
winWavData = data;
|
||||
|
||||
PlaySoundA( &winWavData.front(), 0,
|
||||
SND_ASYNC | SND_MEMORY | SND_NODEFAULT | SND_NOWAIT );
|
||||
|
||||
return;
|
||||
#endif
|
||||
|
||||
QString program, extension;
|
||||
|
||||
if ( url.scheme() == "gdau" )
|
||||
|
|
|
@ -22,6 +22,11 @@ class ArticleView: public QFrame
|
|||
|
||||
Ui::ArticleView ui;
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
// Used in Windows only
|
||||
vector< char > winWavData;
|
||||
#endif
|
||||
|
||||
public:
|
||||
/// The popupView flag influences contents of the context menus to be
|
||||
/// appropriate to the context of the view.
|
||||
|
@ -31,6 +36,8 @@ public:
|
|||
Instances::Groups const &,
|
||||
bool popupView );
|
||||
|
||||
~ArticleView();
|
||||
|
||||
/// Shows the definition of the given word with the given group
|
||||
void showDefinition( QString const & word, QString const & group );
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ RCC_DIR = build
|
|||
LIBS += -lvorbisfile -lvorbis -logg -lz
|
||||
|
||||
win32 {
|
||||
LIBS += -liconv -lwsock32
|
||||
LIBS += -liconv -lwsock32 -lwinmm
|
||||
RC_FILE = goldendict.rc
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue