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
2eea8df1
Commit
2eea8df1
authored
Nov 18, 2012
by
Dan Pascu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use API level 2 for QVariant for better python integration
parent
4a4c1cf7
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
87 additions
and
90 deletions
+87
-90
__init__.py
blink/__init__.py
+2
-1
accounts.py
blink/accounts.py
+11
-11
contacts.py
blink/contacts.py
+6
-10
mainwindow.py
blink/mainwindow.py
+35
-35
preferences.py
blink/preferences.py
+25
-25
sessions.py
blink/sessions.py
+2
-2
util.py
blink/widgets/util.py
+6
-6
No files found.
blink/__init__.py
View file @
2eea8df1
...
...
@@ -14,6 +14,7 @@ import sip
import
cjson
sip
.
setapi
(
'QString'
,
2
)
sip
.
setapi
(
'QVariant'
,
2
)
from
PyQt4.QtGui
import
QApplication
from
application
import
log
...
...
blink/accounts.py
View file @
2eea8df1
...
...
@@ -13,7 +13,7 @@ import urllib2
from
collections
import
defaultdict
from
PyQt4
import
uic
from
PyQt4.QtCore
import
Qt
,
QAbstractListModel
,
QModelIndex
,
QUrl
,
QVariant
from
PyQt4.QtCore
import
Qt
,
QAbstractListModel
,
QModelIndex
,
QUrl
from
PyQt4.QtGui
import
QAction
,
QButtonGroup
,
QComboBox
,
QIcon
,
QMenu
,
QMovie
,
QPalette
,
QPixmap
,
QSortFilterProxyModel
,
QStyledItemDelegate
from
PyQt4.QtNetwork
import
QNetworkAccessManager
from
PyQt4.QtWebKit
import
QWebView
...
...
@@ -173,7 +173,7 @@ class ActiveAccountModel(QSortFilterProxyModel):
class
AccountDelegate
(
QStyledItemDelegate
):
def
paint
(
self
,
painter
,
option
,
index
):
account_info
=
index
.
data
(
Qt
.
UserRole
)
.
toPyObject
()
account_info
=
index
.
data
(
Qt
.
UserRole
)
if
account_info
.
registration_state
==
'succeeded'
:
option
.
palette
.
setColor
(
QPalette
.
Text
,
Qt
.
black
)
else
:
...
...
@@ -202,7 +202,7 @@ class AccountSelector(QComboBox):
def
_SH_DataChanged
(
self
,
topLeft
,
bottomRight
):
index
=
self
.
currentIndex
()
if
topLeft
.
row
()
<=
index
<=
bottomRight
.
row
():
account_info
=
self
.
itemData
(
index
)
.
toPyObject
()
account_info
=
self
.
itemData
(
index
)
palette
=
self
.
palette
()
if
account_info
.
registration_state
==
'succeeded'
:
palette
.
setColor
(
QPalette
.
Text
,
Qt
.
black
)
...
...
@@ -213,7 +213,7 @@ class AccountSelector(QComboBox):
def
_SH_SelectionChanged
(
self
,
index
):
if
index
==
-
1
:
return
account_info
=
self
.
itemData
(
index
)
.
toPyObject
()
account_info
=
self
.
itemData
(
index
)
palette
=
self
.
palette
()
if
account_info
.
registration_state
==
'succeeded'
:
palette
.
setColor
(
QPalette
.
Text
,
Qt
.
black
)
...
...
@@ -639,7 +639,7 @@ class ServerToolsWindow(base_class, ui_class):
def
_SH_AccountButtonMenuTriggered
(
self
,
action
):
view
=
self
.
tab_widget
.
currentWidget
()
account
=
action
.
data
()
.
toPyObject
()
account
=
action
.
data
()
self
.
account_label
.
setText
(
account
.
id
)
self
.
tab_widget
.
setTabText
(
self
.
tab_widget
.
currentIndex
(),
account
.
id
)
view
.
load_account_page
(
account
,
tab
=
view
.
tab
,
task
=
view
.
task
)
...
...
@@ -686,16 +686,16 @@ class ServerToolsWindow(base_class, ui_class):
menu
=
self
.
account_button
.
menu
()
menu
.
clear
()
for
row
in
xrange
(
self
.
model
.
rowCount
()):
account_info
=
self
.
model
.
data
(
self
.
model
.
index
(
row
,
0
),
Qt
.
UserRole
)
.
toPyObject
()
account_info
=
self
.
model
.
data
(
self
.
model
.
index
(
row
,
0
),
Qt
.
UserRole
)
action
=
QAction
(
account_info
.
name
,
self
)
action
.
setData
(
QVariant
(
account_info
.
account
)
)
action
.
setData
(
account_info
.
account
)
menu
.
addAction
(
action
)
def
open_settings_page
(
self
,
account
):
view
=
self
.
tab_widget
.
currentWidget
()
account
=
account
or
view
.
account
if
account
is
None
or
account
.
server
.
settings_url
is
None
:
account
=
self
.
account_button
.
menu
()
.
actions
()[
0
]
.
data
()
.
toPyObject
()
account
=
self
.
account_button
.
menu
()
.
actions
()[
0
]
.
data
()
self
.
account_label
.
setText
(
account
.
id
)
self
.
tab_widget
.
setTabText
(
self
.
tab_widget
.
currentIndex
(),
account
.
id
)
view
.
load_account_page
(
account
,
tab
=
'settings'
)
...
...
@@ -705,7 +705,7 @@ class ServerToolsWindow(base_class, ui_class):
view
=
self
.
tab_widget
.
currentWidget
()
account
=
account
or
view
.
account
if
account
is
None
or
account
.
server
.
settings_url
is
None
:
account
=
self
.
account_button
.
menu
()
.
actions
()[
0
]
.
data
()
.
toPyObject
()
account
=
self
.
account_button
.
menu
()
.
actions
()[
0
]
.
data
()
self
.
account_label
.
setText
(
account
.
id
)
self
.
tab_widget
.
setTabText
(
self
.
tab_widget
.
currentIndex
(),
account
.
id
)
view
.
load_account_page
(
account
,
tab
=
'contacts'
,
task
=
'directory'
)
...
...
@@ -715,7 +715,7 @@ class ServerToolsWindow(base_class, ui_class):
view
=
self
.
tab_widget
.
currentWidget
()
account
=
account
or
view
.
account
if
account
is
None
or
account
.
server
.
settings_url
is
None
:
account
=
self
.
account_button
.
menu
()
.
actions
()[
0
]
.
data
()
.
toPyObject
()
account
=
self
.
account_button
.
menu
()
.
actions
()[
0
]
.
data
()
self
.
account_label
.
setText
(
account
.
id
)
self
.
tab_widget
.
setTabText
(
self
.
tab_widget
.
currentIndex
(),
account
.
id
)
view
.
load_account_page
(
account
,
tab
=
'calls'
)
...
...
@@ -725,7 +725,7 @@ class ServerToolsWindow(base_class, ui_class):
view
=
self
.
tab_widget
.
currentWidget
()
account
=
account
or
view
.
account
if
account
is
None
or
account
.
server
.
settings_url
is
None
:
account
=
self
.
account_button
.
menu
()
.
actions
()[
0
]
.
data
()
.
toPyObject
()
account
=
self
.
account_button
.
menu
()
.
actions
()[
0
]
.
data
()
self
.
account_label
.
setText
(
account
.
id
)
self
.
tab_widget
.
setTabText
(
self
.
tab_widget
.
currentIndex
(),
account
.
id
)
view
.
load_account_page
(
account
,
tab
=
'payments'
)
...
...
blink/contacts.py
View file @
2eea8df1
...
...
@@ -1359,10 +1359,6 @@ class ContactSearchModel(QSortFilterProxyModel):
else
:
return
QSortFilterProxyModel
.
flags
(
self
,
index
)
|
Qt
.
ItemIsDropEnabled
def
data
(
self
,
index
,
role
=
Qt
.
DisplayRole
):
data
=
super
(
ContactSearchModel
,
self
)
.
data
(
index
,
role
)
return
data
.
toPyObject
()
if
role
==
Qt
.
DisplayRole
else
data
def
filterAcceptsRow
(
self
,
source_row
,
source_parent
):
source_model
=
self
.
sourceModel
()
source_index
=
source_model
.
index
(
source_row
,
0
,
source_parent
)
...
...
@@ -1998,9 +1994,9 @@ class ContactEditorGroupModel(QSortFilterProxyModel):
def
data
(
self
,
index
,
role
=
Qt
.
DisplayRole
):
if
role
in
(
Qt
.
DisplayRole
,
Qt
.
EditRole
):
return
super
(
ContactEditorGroupModel
,
self
)
.
data
(
index
,
Qt
.
DisplayRole
)
.
toPyObject
()
.
name
return
super
(
ContactEditorGroupModel
,
self
)
.
data
(
index
,
Qt
.
DisplayRole
)
.
name
elif
role
==
Qt
.
UserRole
:
return
super
(
ContactEditorGroupModel
,
self
)
.
data
(
index
,
Qt
.
DisplayRole
)
.
toPyObject
()
return
super
(
ContactEditorGroupModel
,
self
)
.
data
(
index
,
Qt
.
DisplayRole
)
else
:
return
super
(
ContactEditorGroupModel
,
self
)
.
data
(
index
,
role
)
...
...
@@ -2030,7 +2026,7 @@ class ContactEditorDialog(base_class, ui_class):
self
.
display_name_editor
.
setText
(
u''
)
self
.
sip_aliases_editor
.
setText
(
u''
)
for
index
in
xrange
(
self
.
group
.
count
()):
if
self
.
group
.
itemData
(
index
)
.
toPyObject
()
is
target_group
:
if
self
.
group
.
itemData
(
index
)
is
target_group
:
break
else
:
index
=
0
...
...
@@ -2047,7 +2043,7 @@ class ContactEditorDialog(base_class, ui_class):
self
.
display_name_editor
.
setText
(
contact
.
name
)
self
.
sip_aliases_editor
.
setText
(
u'; '
.
join
(
contact
.
sip_aliases
))
for
index
in
xrange
(
self
.
group
.
count
()):
if
self
.
group
.
itemData
(
index
)
.
toPyObject
()
is
contact
.
group
:
if
self
.
group
.
itemData
(
index
)
is
contact
.
group
:
break
else
:
index
=
0
...
...
@@ -2078,11 +2074,11 @@ class ContactEditorDialog(base_class, ui_class):
# user edited the group name. first look if we already have a group with that name
index
=
self
.
group
.
findText
(
group_name
)
if
index
>=
0
:
group
=
self
.
group
.
itemData
(
index
)
.
toPyObject
()
group
=
self
.
group
.
itemData
(
index
)
else
:
group
=
ContactGroup
(
group_name
)
else
:
group
=
self
.
group
.
itemData
(
group_index
)
.
toPyObject
()
group
=
self
.
group
.
itemData
(
group_index
)
if
self
.
edited_contact
is
None
:
contact
=
Contact
(
group
,
name
,
uri
,
image
=
image
)
contact
.
preferred_media
=
preferred_media
...
...
blink/mainwindow.py
View file @
2eea8df1
This diff is collapsed.
Click to expand it.
blink/preferences.py
View file @
2eea8df1
...
...
@@ -9,7 +9,7 @@ import os
import
urlparse
from
PyQt4
import
uic
from
PyQt4.QtCore
import
Qt
,
QRegExp
,
QVariant
from
PyQt4.QtCore
import
Qt
,
QRegExp
from
PyQt4.QtGui
import
QActionGroup
,
QButtonGroup
,
QFileDialog
,
QListView
,
QListWidgetItem
,
QMessageBox
,
QRegExpValidator
,
QSpinBox
,
QStyle
,
QStyleOptionComboBox
,
QValidator
from
application
import
log
...
...
@@ -305,10 +305,10 @@ class PreferencesWindow(base_class, ui_class):
for
index
in
xrange
(
self
.
idd_prefix_button
.
count
()):
text
=
self
.
idd_prefix_button
.
itemText
(
index
)
self
.
idd_prefix_button
.
setItemData
(
index
,
QVariant
(
None
if
text
==
"+"
else
text
)
)
self
.
idd_prefix_button
.
setItemData
(
index
,
None
if
text
==
"+"
else
text
)
for
index
in
xrange
(
self
.
prefix_button
.
count
()):
text
=
self
.
prefix_button
.
itemText
(
index
)
self
.
prefix_button
.
setItemData
(
index
,
QVariant
(
None
if
text
==
"None"
else
text
)
)
self
.
prefix_button
.
setItemData
(
index
,
None
if
text
==
"None"
else
text
)
self
.
voicemail_uri_editor
.
setValidator
(
SIPAddressValidator
(
self
))
self
.
xcap_root_editor
.
setValidator
(
XCAPRootValidator
(
self
))
...
...
@@ -455,31 +455,31 @@ class PreferencesWindow(base_class, ui_class):
class
Separator
:
pass
self
.
audio_input_device_button
.
clear
()
self
.
audio_input_device_button
.
addItem
(
u'System Default'
,
QVariant
(
'system_default'
)
)
self
.
audio_input_device_button
.
addItem
(
u'System Default'
,
'system_default'
)
self
.
audio_input_device_button
.
insertSeparator
(
1
)
self
.
audio_input_device_button
.
setItemData
(
1
,
QVariant
(
Separator
)
)
# prevent the separator from being selectable
self
.
audio_input_device_button
.
setItemData
(
1
,
Separator
)
# prevent the separator from being selectable
for
device
in
SIPApplication
.
engine
.
input_devices
:
self
.
audio_input_device_button
.
addItem
(
device
,
QVariant
(
device
)
)
self
.
audio_input_device_button
.
addItem
(
u'None'
,
QVariant
(
None
)
)
self
.
audio_input_device_button
.
setCurrentIndex
(
self
.
audio_input_device_button
.
findData
(
QVariant
(
settings
.
audio
.
input_device
)
))
self
.
audio_input_device_button
.
addItem
(
device
,
device
)
self
.
audio_input_device_button
.
addItem
(
u'None'
,
None
)
self
.
audio_input_device_button
.
setCurrentIndex
(
self
.
audio_input_device_button
.
findData
(
settings
.
audio
.
input_device
))
self
.
audio_output_device_button
.
clear
()
self
.
audio_output_device_button
.
addItem
(
u'System Default'
,
QVariant
(
'system_default'
)
)
self
.
audio_output_device_button
.
addItem
(
u'System Default'
,
'system_default'
)
self
.
audio_output_device_button
.
insertSeparator
(
1
)
self
.
audio_output_device_button
.
setItemData
(
1
,
QVariant
(
Separator
)
)
# prevent the separator from being selectable
self
.
audio_output_device_button
.
setItemData
(
1
,
Separator
)
# prevent the separator from being selectable
for
device
in
SIPApplication
.
engine
.
output_devices
:
self
.
audio_output_device_button
.
addItem
(
device
,
QVariant
(
device
)
)
self
.
audio_output_device_button
.
addItem
(
u'None'
,
QVariant
(
None
)
)
self
.
audio_output_device_button
.
setCurrentIndex
(
self
.
audio_output_device_button
.
findData
(
QVariant
(
settings
.
audio
.
output_device
)
))
self
.
audio_output_device_button
.
addItem
(
device
,
device
)
self
.
audio_output_device_button
.
addItem
(
u'None'
,
None
)
self
.
audio_output_device_button
.
setCurrentIndex
(
self
.
audio_output_device_button
.
findData
(
settings
.
audio
.
output_device
))
self
.
audio_alert_device_button
.
clear
()
self
.
audio_alert_device_button
.
addItem
(
u'System Default'
,
QVariant
(
'system_default'
)
)
self
.
audio_alert_device_button
.
addItem
(
u'System Default'
,
'system_default'
)
self
.
audio_alert_device_button
.
insertSeparator
(
1
)
self
.
audio_alert_device_button
.
setItemData
(
1
,
QVariant
(
Separator
)
)
# prevent the separator from being selectable
self
.
audio_alert_device_button
.
setItemData
(
1
,
Separator
)
# prevent the separator from being selectable
for
device
in
SIPApplication
.
engine
.
output_devices
:
self
.
audio_alert_device_button
.
addItem
(
device
,
QVariant
(
device
)
)
self
.
audio_alert_device_button
.
addItem
(
u'None'
,
QVariant
(
None
)
)
self
.
audio_alert_device_button
.
setCurrentIndex
(
self
.
audio_alert_device_button
.
findData
(
QVariant
(
settings
.
audio
.
alert_device
)
))
self
.
audio_alert_device_button
.
addItem
(
device
,
device
)
self
.
audio_alert_device_button
.
addItem
(
u'None'
,
None
)
self
.
audio_alert_device_button
.
setCurrentIndex
(
self
.
audio_alert_device_button
.
findData
(
settings
.
audio
.
alert_device
))
def
load_settings
(
self
):
"""Load settings from configuration into the UI controls"""
...
...
@@ -492,7 +492,7 @@ class PreferencesWindow(base_class, ui_class):
self
.
enable_echo_cancelling_button
.
setChecked
(
settings
.
audio
.
tail_length
!=
0
)
self
.
audio_sample_rate_button
.
clear
()
for
rate
in
SIPSimpleSettings
.
audio
.
sample_rate
.
type
.
valid_values
:
self
.
audio_sample_rate_button
.
addItem
(
str
(
rate
),
QVariant
(
rate
)
)
self
.
audio_sample_rate_button
.
addItem
(
str
(
rate
),
rate
)
self
.
audio_sample_rate_button
.
setCurrentIndex
(
self
.
audio_sample_rate_button
.
findText
(
str
(
settings
.
audio
.
sample_rate
)))
# Audio codecs
...
...
@@ -1002,19 +1002,19 @@ class PreferencesWindow(base_class, ui_class):
# Audio devices signal handlers
def
_SH_AudioAlertDeviceButtonActivated
(
self
,
index
):
device
=
self
.
audio_alert_device_button
.
itemData
(
index
)
.
toPyObject
()
device
=
self
.
audio_alert_device_button
.
itemData
(
index
)
settings
=
SIPSimpleSettings
()
settings
.
audio
.
alert_device
=
device
settings
.
save
()
def
_SH_AudioInputDeviceButtonActivated
(
self
,
index
):
device
=
self
.
audio_input_device_button
.
itemData
(
index
)
.
toPyObject
()
device
=
self
.
audio_input_device_button
.
itemData
(
index
)
settings
=
SIPSimpleSettings
()
settings
.
audio
.
input_device
=
device
settings
.
save
()
def
_SH_AudioOutputDeviceButtonActivated
(
self
,
index
):
device
=
self
.
audio_output_device_button
.
itemData
(
index
)
.
toPyObject
()
device
=
self
.
audio_output_device_button
.
itemData
(
index
)
settings
=
SIPSimpleSettings
()
settings
.
audio
.
output_device
=
device
settings
.
save
()
...
...
@@ -1289,11 +1289,11 @@ class PreferencesWindow(base_class, ui_class):
if
'audio.silent'
in
notification
.
data
.
modified
:
self
.
silence_alerts_button
.
setChecked
(
settings
.
audio
.
silent
)
if
'audio.alert_device'
in
notification
.
data
.
modified
:
self
.
audio_alert_device_button
.
setCurrentIndex
(
self
.
audio_alert_device_button
.
findData
(
QVariant
(
settings
.
audio
.
alert_device
)
))
self
.
audio_alert_device_button
.
setCurrentIndex
(
self
.
audio_alert_device_button
.
findData
(
settings
.
audio
.
alert_device
))
if
'audio.input_device'
in
notification
.
data
.
modified
:
self
.
audio_input_device_button
.
setCurrentIndex
(
self
.
audio_input_device_button
.
findData
(
QVariant
(
settings
.
audio
.
input_device
)
))
self
.
audio_input_device_button
.
setCurrentIndex
(
self
.
audio_input_device_button
.
findData
(
settings
.
audio
.
input_device
))
if
'audio.output_device'
in
notification
.
data
.
modified
:
self
.
audio_output_device_button
.
setCurrentIndex
(
self
.
audio_output_device_button
.
findData
(
QVariant
(
settings
.
audio
.
output_device
)
))
self
.
audio_output_device_button
.
setCurrentIndex
(
self
.
audio_output_device_button
.
findData
(
settings
.
audio
.
output_device
))
if
'answering_machine.enabled'
in
notification
.
data
.
modified
:
self
.
enable_answering_machine_button
.
setChecked
(
settings
.
answering_machine
.
enabled
)
if
'chat.auto_accept'
in
notification
.
data
.
modified
:
...
...
blink/sessions.py
View file @
2eea8df1
...
...
@@ -1284,9 +1284,9 @@ class SessionListView(QListView):
current_index
=
selection_model
.
currentIndex
()
if
current_index
.
isValid
():
step
=
1
if
event
.
key
()
==
Qt
.
Key_Down
else
-
1
conference
=
current_index
.
data
()
.
toPyObject
()
.
conference
conference
=
current_index
.
data
()
.
conference
new_index
=
current_index
.
sibling
(
current_index
.
row
()
+
step
,
current_index
.
column
())
while
conference
is
not
None
and
new_index
.
isValid
()
and
new_index
.
data
()
.
toPyObject
()
.
conference
is
conference
:
while
conference
is
not
None
and
new_index
.
isValid
()
and
new_index
.
data
()
.
conference
is
conference
:
new_index
=
new_index
.
sibling
(
new_index
.
row
()
+
step
,
new_index
.
column
())
if
new_index
.
isValid
():
selection_model
.
select
(
new_index
,
selection_model
.
ClearAndSelect
)
...
...
blink/widgets/util.py
View file @
2eea8df1
...
...
@@ -4,18 +4,18 @@
__all__
=
[
'QtDynamicProperty'
]
from
PyQt4.QtCore
import
QVariant
class
QtDynamicProperty
(
object
):
def
__init__
(
self
,
name
,
type
=
unicode
):
self
.
name
=
name
self
.
type
=
type
def
__get__
(
self
,
obj
,
objtype
):
value
=
self
if
obj
is
None
else
obj
.
property
(
self
.
name
)
.
toPyObject
()
return
value
if
value
in
(
self
,
None
)
else
self
.
type
(
value
)
if
obj
is
None
:
return
self
return
obj
.
property
(
self
.
name
)
def
__set__
(
self
,
obj
,
value
):
obj
.
setProperty
(
self
.
name
,
QVariant
(
value
if
value
is
None
else
self
.
type
(
value
)))
if
value
is
not
None
and
not
isinstance
(
value
,
self
.
type
):
value
=
self
.
type
(
value
)
obj
.
setProperty
(
self
.
name
,
value
)
def
__delete__
(
self
,
obj
):
raise
AttributeError
(
"attribute cannot be deleted"
)
...
...
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