Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Network
Konversation
Commits
b9f61d00
Verified
Commit
b9f61d00
authored
Feb 16, 2022
by
Fushan Wen
Browse files
sound: Port away from Phonon
Use QMediaPlayer instead.
parent
bfc78404
Pipeline
#139116
passed with stage
in 3 minutes and 45 seconds
Changes
8
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
b9f61d00
...
...
@@ -28,7 +28,7 @@ include(ECMSetupVersion)
include
(
ECMGenerateDBusServiceFile
)
include
(
FeatureSummary
)
find_package
(
Qt5
${
QT_MIN_VERSION
}
CONFIG REQUIRED Core Network Widgets
)
find_package
(
Qt5
${
QT_MIN_VERSION
}
CONFIG REQUIRED Core
Multimedia
Network Widgets
)
find_package
(
KF5
${
KF5_MIN_VERSION
}
REQUIRED
Archive
...
...
@@ -63,8 +63,6 @@ elseif(KF5_MIN_VERSION VERSION_GREATER 5.90)
message
(
AUTHOR_WARNING
"Please remove usage of Qt5X11Extras and HAVE_X11, no longer needed."
)
endif
()
find_package
(
Phonon4Qt5 4.6.60 REQUIRED
)
find_package
(
Qca-qt5 2.2.0
)
set_package_properties
(
Qca-qt5 PROPERTIES DESCRIPTION
"Support for encryption"
URL
"https://download.kde.org/stable/qca/"
...
...
src/CMakeLists.txt
View file @
b9f61d00
include
(
ECMAddAppIcon
)
include
(
ECMQtDeclareLoggingCategory
)
include_directories
(
SYSTEM
${
PHONON_INCLUDES
}
)
include_directories
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/config
)
include_directories
(
config dcc irc viewer upnp
)
...
...
@@ -236,6 +235,7 @@ ecm_add_app_icon(konversation_SRCS ICONS ${ICONS_SRCS})
add_executable
(
konversation
${
konversation_SRCS
}
)
target_link_libraries
(
konversation
Qt::Multimedia
Qt5::Network
Qt5::Widgets
KF5::Archive
...
...
@@ -257,7 +257,7 @@ target_link_libraries(konversation
KF5::WindowSystem
KF5::ItemViews
KF5::NewStuff
Phonon::phonon4qt5
)
)
if
(
TARGET Qt5::X11Extras
)
target_link_libraries
(
konversation Qt5::X11Extras
)
...
...
src/config/highlight_config.cpp
View file @
b9f61d00
...
...
@@ -177,13 +177,13 @@ void Highlight_Config::colorChanged(const QColor& newColor)
}
}
void
Highlight_Config
::
soundURLChanged
(
const
QString
&
newURL
)
void
Highlight_Config
::
soundURLChanged
()
{
auto
*
item
=
dynamic_cast
<
HighlightViewItem
*>
(
highlightListView
->
currentItem
());
if
(
!
newItemSelected
&&
item
)
{
item
->
setSoundURL
(
QUrl
(
newURL
));
item
->
setSoundURL
(
soundURL
->
url
(
));
Q_EMIT
modified
();
}
}
...
...
src/config/highlight_config.h
View file @
b9f61d00
...
...
@@ -37,7 +37,7 @@ class Highlight_Config : public QWidget, public KonviSettingsPage, private Ui::H
void
patternChanged
(
const
QString
&
newPattern
);
void
notifyModeChanged
(
bool
);
void
colorChanged
(
const
QColor
&
newColor
);
void
soundURLChanged
(
const
QString
&
newURL
);
void
soundURLChanged
();
void
autoTextChanged
(
const
QString
&
newText
);
void
chatWindowsChanged
(
const
QString
&
newChatWindows
);
void
addHighlight
();
...
...
src/sound.cpp
View file @
b9f61d00
...
...
@@ -6,24 +6,17 @@
#include
"sound.h"
#include
<QUrl>
#include
<Phonon/AudioOutput>
namespace
Konversation
{
Sound
::
Sound
(
QObject
*
parent
,
const
QString
&
name
)
:
QObject
(
parent
)
,
m_mediaObject
(
new
QMediaPlayer
(
this
,
QMediaPlayer
::
LowLatency
))
,
m_played
(
false
)
{
setObjectName
(
name
);
m_mediaObject
=
new
Phonon
::
MediaObject
(
this
);
m_audioOutput
=
new
Phonon
::
AudioOutput
(
Phonon
::
NotificationCategory
,
this
);
Phonon
::
createPath
(
m_mediaObject
,
m_audioOutput
);
connect
(
m_mediaObject
,
&
Phonon
::
MediaObject
::
stateChanged
,
this
,
&
Sound
::
tryPlayNext
);
m_played
=
false
;
m_mediaObject
->
setAudioRole
(
QAudio
::
NotificationRole
);
connect
(
m_mediaObject
,
&
QMediaPlayer
::
stateChanged
,
this
,
&
Sound
::
tryPlayNext
);
}
Sound
::~
Sound
()
...
...
@@ -31,10 +24,8 @@ namespace Konversation
void
Sound
::
play
(
const
QUrl
&
url
)
{
if
(
m_played
&&
((
m_mediaObject
->
state
()
!=
Phonon
::
PausedState
&&
m_mediaObject
->
state
()
!=
Phonon
::
StoppedState
)
||
!
m_playQueue
.
isEmpty
()))
{
if
(
m_mediaObject
->
currentSource
().
url
()
!=
url
)
{
if
(
m_played
&&
(
m_mediaObject
->
state
()
==
QMediaPlayer
::
PlayingState
||
!
m_playQueue
.
isEmpty
()))
{
if
(
m_currentUrl
!=
url
)
{
m_playQueue
.
enqueue
(
url
);
}
...
...
@@ -45,19 +36,17 @@ namespace Konversation
playSound
(
url
);
}
void
Sound
::
tryPlayNext
(
Phonon
::
State
newState
,
Phonon
::
State
old
State
)
void
Sound
::
tryPlayNext
(
QMediaPlayer
::
State
new
State
)
{
Q_UNUSED
(
oldState
)
if
(
newState
==
Phonon
::
PausedState
&&
!
m_playQueue
.
isEmpty
())
{
if
(
newState
==
QMediaPlayer
::
StoppedState
&&
!
m_playQueue
.
isEmpty
())
{
playSound
(
m_playQueue
.
dequeue
());
}
}
void
Sound
::
playSound
(
const
QUrl
&
url
)
{
m_mediaObject
->
setCurrentSource
(
Phonon
::
MediaSource
(
url
));
m_currentUrl
=
url
;
m_mediaObject
->
setMedia
(
url
);
m_mediaObject
->
play
();
}
}
...
...
src/sound.h
View file @
b9f61d00
...
...
@@ -7,17 +7,10 @@
#ifndef KONVERSATIONKONVERSATIONSOUND_H
#define KONVERSATIONKONVERSATIONSOUND_H
#include
<QMediaPlayer>
#include
<QObject>
#include
<QQueue>
#include
<Phonon/MediaObject>
class
QUrl
;
namespace
Phonon
{
class
AudioOutput
;
}
#include
<QUrl>
namespace
Konversation
{
...
...
@@ -37,16 +30,16 @@ namespace Konversation
void
play
(
const
QUrl
&
url
);
private
Q_SLOTS
:
void
tryPlayNext
(
Phonon
::
State
newState
,
Phonon
::
State
old
State
);
void
tryPlayNext
(
QMediaPlayer
::
State
new
State
);
private:
void
playSound
(
const
QUrl
&
url
);
private:
Phonon
::
MediaObject
*
m_mediaObject
;
Phonon
::
AudioOutput
*
m_audioOutput
;
QMediaPlayer
*
const
m_mediaObject
;
QQueue
<
QUrl
>
m_playQueue
;
QUrl
m_currentUrl
;
bool
m_played
;
Q_DISABLE_COPY
(
Sound
)
...
...
src/viewer/highlight.cpp
View file @
b9f61d00
...
...
@@ -72,7 +72,12 @@ QString Highlight::getAutoText() const
void
Highlight
::
setSoundURL
(
const
QUrl
&
url
)
{
m_soundURL
=
url
;
if
(
url
.
isLocalFile
())
{
m_soundURL
=
url
;
}
else
{
// A highlight entry in an old config doesn't have a "file://" prefix
m_soundURL
=
QUrl
::
fromLocalFile
(
url
.
toString
());
}
}
QUrl
Highlight
::
getSoundURL
()
const
...
...
src/viewer/highlightviewitem.cpp
View file @
b9f61d00
...
...
@@ -76,7 +76,7 @@ QColor HighlightViewItem::getColor() const
void
HighlightViewItem
::
setSoundURL
(
const
QUrl
&
soundURL
)
{
m_soundURL
=
soundURL
;
setText
(
2
,
m_soundURL
.
url
());
setText
(
2
,
m_soundURL
.
toLocalFile
());
}
QUrl
HighlightViewItem
::
getSoundURL
()
const
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment