mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Fix QMediaPlayer usage in Qt6
This commit is contained in:
parent
75060d4f24
commit
e91481d0c3
@ -287,26 +287,14 @@ void YACReaderTranslator::populateCombos()
|
||||
|
||||
void YACReaderTranslator::play()
|
||||
{
|
||||
// QMessageBox::question(this,"xxx",ttsSource.toString());
|
||||
#if QT_VERSION >= 0x050000
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
player->setSource(ttsSource);
|
||||
#else
|
||||
player->setMedia(ttsSource);
|
||||
#endif
|
||||
|
||||
player->play();
|
||||
|
||||
#else
|
||||
MediaSource src(ttsSource);
|
||||
src.setAutoDelete(true);
|
||||
music->setCurrentSource(src);
|
||||
music->play();
|
||||
#endif
|
||||
}
|
||||
|
||||
YACReaderTranslator::~YACReaderTranslator()
|
||||
{
|
||||
#if QT_VERSION >= 0x050000
|
||||
#else
|
||||
delete music;
|
||||
#endif
|
||||
}
|
||||
|
||||
void YACReaderTranslator::mousePressEvent(QMouseEvent *event)
|
||||
|
@ -15,19 +15,13 @@ class YACReaderBusyWidget;
|
||||
#include <QUrl>
|
||||
#include "viewer.h"
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
class QMediaPlayer;
|
||||
#else
|
||||
#include <Phonon/MediaObject>
|
||||
using namespace Phonon;
|
||||
#endif
|
||||
|
||||
class YACReaderTranslator : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
YACReaderTranslator(Viewer *parent = nullptr);
|
||||
~YACReaderTranslator() override;
|
||||
|
||||
public slots:
|
||||
void play();
|
||||
@ -50,11 +44,7 @@ protected:
|
||||
QPoint click;
|
||||
|
||||
private:
|
||||
#if QT_VERSION >= 0x050000
|
||||
QMediaPlayer *player;
|
||||
#else
|
||||
MediaObject *music;
|
||||
#endif
|
||||
|
||||
QTextEdit *text;
|
||||
QComboBox *from;
|
||||
|
Loading…
Reference in New Issue
Block a user