Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vmj-qt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
vmj-qt
Commits
e5c0383c
Commit
e5c0383c
authored
Sep 13, 2016
by
Dan Pascu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplified action management for device menus
parent
549046e1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
52 deletions
+72
-52
mainwindow.py
blink/mainwindow.py
+72
-52
No files found.
blink/mainwindow.py
View file @
e5c0383c
...
...
@@ -263,72 +263,100 @@ class MainWindow(base_class, ui_class):
def
load_audio_devices
(
self
):
settings
=
SIPSimpleSettings
()
action
=
QAction
(
u'System default'
,
self
.
output_devices_group
)
action_map
=
{}
action
=
action_map
[
u'system_default'
]
=
self
.
output_device_menu
.
addAction
(
u'System default'
)
action
.
setData
(
u'system_default'
)
self
.
output_device_menu
.
addAction
(
action
)
action
.
setCheckable
(
True
)
self
.
output_devices_group
.
addAction
(
action
)
self
.
output_device_menu
.
addSeparator
()
for
device
in
SIPApplication
.
engine
.
output_devices
:
action
=
QAction
(
device
,
self
.
output_devices_group
)
action
=
action_map
[
device
]
=
self
.
output_device_menu
.
addAction
(
device
)
action
.
setData
(
device
)
self
.
output_device_menu
.
addAction
(
action
)
action
=
QAction
(
u'None'
,
self
.
output_devices_group
)
action
.
setData
(
None
)
self
.
output_device_menu
.
addAction
(
action
)
for
action
in
self
.
output_devices_group
.
actions
():
action
.
setCheckable
(
True
)
if
settings
.
audio
.
output_device
==
action
.
data
():
action
.
setChecked
(
True
)
self
.
output_devices_group
.
addAction
(
action
)
action
=
action_map
[
None
]
=
self
.
output_device_menu
.
addAction
(
u'None'
)
action
.
setData
(
None
)
action
.
setCheckable
(
True
)
self
.
output_devices_group
.
addAction
(
action
)
active_action
=
action_map
.
get
(
settings
.
audio
.
output_device
,
Null
)
active_action
.
setChecked
(
True
)
action
=
QAction
(
u'System default'
,
self
.
input_devices_group
)
action_map
=
{}
action
=
action_map
[
u'system_default'
]
=
self
.
input_device_menu
.
addAction
(
u'System default'
)
action
.
setData
(
u'system_default'
)
self
.
input_device_menu
.
addAction
(
action
)
action
.
setCheckable
(
True
)
self
.
input_devices_group
.
addAction
(
action
)
self
.
input_device_menu
.
addSeparator
()
for
device
in
SIPApplication
.
engine
.
input_devices
:
action
=
QAction
(
device
,
self
.
input_devices_group
)
action
=
action_map
[
device
]
=
self
.
input_device_menu
.
addAction
(
device
)
action
.
setData
(
device
)
self
.
input_device_menu
.
addAction
(
action
)
action
=
QAction
(
u'None'
,
self
.
input_devices_group
)
action
.
setData
(
None
)
self
.
input_device_menu
.
addAction
(
action
)
for
action
in
self
.
input_devices_group
.
actions
():
action
.
setCheckable
(
True
)
if
settings
.
audio
.
input_device
==
action
.
data
():
action
.
setChecked
(
True
)
self
.
input_devices_group
.
addAction
(
action
)
action
=
action_map
[
None
]
=
self
.
input_device_menu
.
addAction
(
u'None'
)
action
.
setData
(
None
)
action
.
setCheckable
(
True
)
self
.
input_devices_group
.
addAction
(
action
)
active_action
=
action_map
.
get
(
settings
.
audio
.
input_device
,
Null
)
active_action
.
setChecked
(
True
)
action
=
QAction
(
u'System default'
,
self
.
alert_devices_group
)
action_map
=
{}
action
=
action_map
[
u'system_default'
]
=
self
.
alert_device_menu
.
addAction
(
u'System default'
)
action
.
setData
(
u'system_default'
)
self
.
alert_device_menu
.
addAction
(
action
)
action
.
setCheckable
(
True
)
self
.
alert_devices_group
.
addAction
(
action
)
self
.
alert_device_menu
.
addSeparator
()
for
device
in
SIPApplication
.
engine
.
output_devices
:
action
=
QAction
(
device
,
self
.
alert_devices_group
)
action
=
action_map
[
device
]
=
self
.
alert_device_menu
.
addAction
(
device
)
action
.
setData
(
device
)
self
.
alert_device_menu
.
addAction
(
action
)
action
=
QAction
(
u'None'
,
self
.
alert_devices_group
)
action
.
setData
(
None
)
self
.
alert_device_menu
.
addAction
(
action
)
for
action
in
self
.
alert_devices_group
.
actions
():
action
.
setCheckable
(
True
)
if
settings
.
audio
.
alert_device
==
action
.
data
():
action
.
setChecked
(
True
)
self
.
alert_devices_group
.
addAction
(
action
)
action
=
action_map
[
None
]
=
self
.
alert_device_menu
.
addAction
(
u'None'
)
action
.
setData
(
None
)
action
.
setCheckable
(
True
)
self
.
alert_devices_group
.
addAction
(
action
)
active_action
=
action_map
.
get
(
settings
.
audio
.
alert_device
,
Null
)
active_action
.
setChecked
(
True
)
def
load_video_devices
(
self
):
settings
=
SIPSimpleSettings
()
action
=
QAction
(
u'System default'
,
self
.
video_devices_group
)
action_map
=
{}
action
=
action_map
[
u'system_default'
]
=
self
.
video_camera_menu
.
addAction
(
u'System default'
)
action
.
setData
(
u'system_default'
)
self
.
video_camera_menu
.
addAction
(
action
)
action
.
setCheckable
(
True
)
self
.
video_devices_group
.
addAction
(
action
)
self
.
video_camera_menu
.
addSeparator
()
for
device
in
SIPApplication
.
engine
.
video_devices
:
action
=
QAction
(
device
,
self
.
video_devices_group
)
action
=
action_map
[
device
]
=
self
.
video_camera_menu
.
addAction
(
device
)
action
.
setData
(
device
)
self
.
video_camera_menu
.
addAction
(
action
)
action
=
QAction
(
u'None'
,
self
.
video_devices_group
)
action
.
setData
(
None
)
self
.
video_camera_menu
.
addAction
(
action
)
for
action
in
self
.
video_devices_group
.
actions
():
action
.
setCheckable
(
True
)
if
settings
.
video
.
device
==
action
.
data
():
action
.
setChecked
(
True
)
self
.
video_devices_group
.
addAction
(
action
)
action
=
action_map
[
None
]
=
self
.
video_camera_menu
.
addAction
(
u'None'
)
action
.
setData
(
None
)
action
.
setCheckable
(
True
)
self
.
video_devices_group
.
addAction
(
action
)
active_action
=
action_map
.
get
(
settings
.
video
.
device
,
Null
)
active_action
.
setChecked
(
True
)
def
_AH_AccountActionTriggered
(
self
,
action
,
enabled
):
account
=
action
.
data
()
...
...
@@ -764,19 +792,11 @@ class MainWindow(base_class, ui_class):
self
.
account_state
.
setState
(
state
,
blink_settings
.
presence
.
current_state
.
note
)
def
_NH_AudioDevicesDidChange
(
self
,
notification
):
for
action
in
self
.
output_device_menu
.
actions
():
self
.
output_devices_group
.
removeAction
(
action
)
self
.
output_device_menu
.
removeAction
(
action
)
for
action
in
self
.
input_device_menu
.
actions
():
self
.
input_devices_group
.
removeAction
(
action
)
self
.
input_device_menu
.
removeAction
(
action
)
for
action
in
self
.
alert_device_menu
.
actions
():
self
.
alert_devices_group
.
removeAction
(
action
)
self
.
alert_device_menu
.
removeAction
(
action
)
self
.
output_device_menu
.
clear
()
# because actions are owned by the menu and only referenced by their corresponding action groups,
self
.
input_device_menu
.
clear
()
# clearing the menus will result in the actions automatically disappearing from the corresponding
self
.
alert_device_menu
.
clear
()
# action groups as well
if
self
.
session_model
.
active_sessions
:
old_devices
=
set
(
notification
.
data
.
old_devices
)
new_devices
=
set
(
notification
.
data
.
new_devices
)
added_devices
=
new_devices
-
old_devices
added_devices
=
set
(
notification
.
data
.
new_devices
)
.
difference
(
notification
.
data
.
old_devices
)
if
added_devices
:
new_device
=
added_devices
.
pop
()
settings
=
SIPSimpleSettings
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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