Открыть боковую панель
Aurora OS
Demos
Call API C++
Коммиты
8d5b880a
Коммит
8d5b880a
создал
Ноя 19, 2024
по автору
Denis Grigorev
Просмотр файлов
[example] Show audio device type icon. OMP#OS-27766
владелец
aada8c45
Изменения
4
Скрыть пробелы
Построчно
Рядом
qml/pages/MainPage.qml
Просмотр файла @
8d5b880a
...
...
@@ -19,12 +19,31 @@ Page {
property
bool
soundActive
readonly
property
bool
_showMicrophoneDisableNotice
:
!
AccessPolicy
.
microphoneEnabled
readonly
property
var
deviceViewDescription
:
{
var
d
=
{}
d
[
AudioDevice
.
Bluetooth
]
=
{
label
:
"
Bluetooth
"
,
icon
:
"
image://theme/icon-m-bluetooth
"
}
d
[
AudioDevice
.
Earpiece
]
=
{
label
:
"
Earpiece
"
,
icon
:
"
image://theme/icon-m-call
"
}
d
[
AudioDevice
.
Speaker
]
=
{
label
:
"
Speaker
"
,
icon
:
"
image://theme/icon-m-browser-sound
"
}
d
[
AudioDevice
.
WiredHeadset
]
=
{
label
:
"
Wired Headset
"
,
icon
:
"
image://theme/icon-m-headphone
"
}
return
d
}
function
nextCallee
()
{
var
id
=
callId
;
callId
++
;
return
id
;
}
function
getAudioDeviceIcon
(
device
)
{
var
data
=
deviceViewDescription
[
device
.
type
]
return
data
?
data
.
icon
:
""
}
function
getAudioDeviceLabel
(
device
)
{
var
data
=
deviceViewDescription
[
device
.
type
]
return
device
.
name
?
device
.
name
:
(
data
?
data
.
label
:
device
.
id
)
}
on_ShowMicrophoneDisableNoticeChanged
:
_showMicrophoneDisableNotice
?
microphoneDisableNotice
.
show
()
:
Notices
.
_dismissCurrent
()
...
...
@@ -116,8 +135,9 @@ Page {
menu
:
ContextMenu
{
Repeater
{
model
:
callManager
.
audioManager
.
devices
MenuItem
{
text
:
modelData
.
name
?
modelData
.
name
:
modelData
.
id
IconMenuItem
{
text
:
getAudioDeviceLabel
(
modelData
)
icon.source
:
getAudioDeviceIcon
(
modelData
)
onClicked
:
callManager
.
audioManager
.
outputDeviceIndex
=
index
}
}
...
...
src/audiomanager.cpp
Просмотр файла @
8d5b880a
...
...
@@ -2,6 +2,8 @@
#include
"audiomanager.h"
#include
<QDebug>
using
ru
::
auroraos
::
call
::
AudioDevice
;
AudioManager
::
AudioManager
(
QObject
*
parent
)
:
QObject
(
parent
)
,
m_mute
(
false
)
...
...
src/audiomanager.h
Просмотр файла @
8d5b880a
...
...
@@ -5,8 +5,6 @@
#include
<audiocontrolinterface.h>
using
ru
::
auroraos
::
call
::
AudioDevice
;
class
AudioManager
:
public
QObject
,
public
ru
::
auroraos
::
call
::
AudioControlInterface
{
Q_OBJECT
...
...
@@ -29,12 +27,12 @@ public:
signals:
void
muteChanged
(
bool
mute
);
void
devicesChanged
(
const
QList
<
AudioDevice
>
&
devices
);
void
devicesChanged
(
const
QList
<
ru
::
auroraos
::
call
::
AudioDevice
>
&
devices
);
void
outputDeviceIndexChanged
(
int
index
);
private:
bool
m_mute
;
QList
<
AudioDevice
>
m_audioDevices
;
QList
<
ru
::
auroraos
::
call
::
AudioDevice
>
m_audioDevices
;
QString
m_inputDeviceId
;
QString
m_outputDeviceId
;
int
m_outputDeviceIndex
;
...
...
@@ -48,7 +46,7 @@ signals:
public
slots
:
void
UpdateAudioRouteState
(
const
QList
<
AudioDevice
>
&
devices
,
const
QList
<
ru
::
auroraos
::
call
::
AudioDevice
>
&
devices
,
bool
microphoneMuted
,
const
QString
&
activeInputDeviceId
,
const
QString
&
activeOutputDeviceId
)
override
;
...
...
src/main.cpp
Просмотр файла @
8d5b880a
...
...
@@ -42,24 +42,31 @@
#include
"audiocall.h"
#include
"audiocallmanager.h"
#include
"audiomanager.h"
#include
"urihandler.h"
int
main
(
int
argc
,
char
*
argv
[])
{
QScopedPointer
<
QGuiApplication
>
application
(
Aurora
::
Application
::
application
(
argc
,
argv
));
application
->
setOrganizationName
(
QStringLiteral
(
"ru.auroraos"
));
application
->
setApplicationName
(
QStringLiteral
(
"AudioCallExample"
));
namespace
{
void
registerQmlTypes
()
{
qRegisterMetaType
<
ru
::
auroraos
::
call
::
Call
*>
(
"Call*"
);
qmlRegisterUncreatableType
<
ru
::
auroraos
::
call
::
Call
>
(
"AudioCallExample"
,
1
,
0
,
"Call"
,
QStringLiteral
(
"Call"
));
qRegisterMetaType
<
AudioCall
*>
(
"AudioCall*"
);
qmlRegisterUncreatableType
<
AudioCall
>
(
"AudioCallExample"
,
1
,
0
,
"AudioCall"
,
QStringLiteral
(
"AudioCall"
));
qRegisterMetaType
<
ru
::
auroraos
::
call
::
AudioDevice
>
(
"AudioDevice"
);
qRegisterMetaType
<
ru
::
auroraos
::
call
::
AudioDevice
::
Type
>
(
"AudioDeviceType"
);
qRegisterMetaType
<
ru
::
auroraos
::
call
::
AudioDeviceList
>
(
"AudioDeviceList"
);
qmlRegisterUncreatableType
<
ru
::
auroraos
::
call
::
AudioDevice
>
(
"AudioCallExample"
,
1
,
0
,
"AudioDevice"
,
QStringLiteral
(
"AudioDevice"
));
}
}
Q_CONSTRUCTOR_FUNCTION
(
registerQmlTypes
)
int
main
(
int
argc
,
char
*
argv
[])
{
QScopedPointer
<
QGuiApplication
>
application
(
Aurora
::
Application
::
application
(
argc
,
argv
));
application
->
setOrganizationName
(
QStringLiteral
(
"ru.auroraos"
));
application
->
setApplicationName
(
QStringLiteral
(
"AudioCallExample"
));
AudioCallManager
callManager
(
QStringLiteral
(
"account0"
));
UriHandler
uriHandler
;
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать