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
8fd67017
Commit
8fd67017
authored
May 17, 2010
by
Dan Pascu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added contacts editing panel
parent
4147aca4
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
744 additions
and
90 deletions
+744
-90
contacts.py
blink/contacts.py
+221
-58
mainwindow.py
blink/mainwindow.py
+43
-21
iconselector.py
blink/widgets/iconselector.py
+46
-0
blink.ui
resources/blink.ui
+11
-11
contact_editor.ui
resources/contact_editor.ui
+423
-0
No files found.
blink/contacts.py
View file @
8fd67017
This diff is collapsed.
Click to expand it.
blink/mainwindow.py
View file @
8fd67017
...
...
@@ -15,7 +15,7 @@ from zope.interface import implements
from
sipsimple.account
import
AccountManager
,
BonjourAccount
from
blink.contacts
import
Contact
,
ContactModel
,
ContactSearchModel
from
blink.contacts
import
Contact
,
Contact
Group
,
ContactEditorDialog
,
Contact
Model
,
ContactSearchModel
from
blink.resources
import
Resources
from
blink.util
import
run_in_gui_thread
...
...
@@ -47,6 +47,8 @@ class MainWindow(base_class, ui_class):
self
.
contact_model
.
load
()
self
.
contact_editor
=
ContactEditorDialog
(
self
.
contact_model
,
self
)
self
.
contacts_panel
.
sibling_panel
=
self
.
sessions_panel
self
.
contacts_panel
.
sibling_name
=
u'Sessions'
self
.
sessions_panel
.
sibling_panel
=
self
.
contacts_panel
...
...
@@ -56,12 +58,16 @@ class MainWindow(base_class, ui_class):
self
.
contacts_view
.
setCurrentWidget
(
self
.
contact_list_panel
)
self
.
search_view
.
setCurrentWidget
(
self
.
search_list_panel
)
self
.
switch_view
.
clicked
.
connect
(
self
.
switch_main_view
)
self
.
switch_view
_button
.
clicked
.
connect
(
self
.
switch_main_view
)
self
.
search_box
.
textChanged
.
connect
(
self
.
search_box_text_changed
)
self
.
contact_model
.
itemsAdded
.
connect
(
self
.
contact_model_added_items
)
self
.
contact_model
.
itemsRemoved
.
connect
(
self
.
contact_model_removed_items
)
self
.
back_to_contacts_button
.
clicked
.
connect
(
self
.
search_box
.
clear
)
# this can be set in designer -Dan
self
.
back_to_contacts
.
clicked
.
connect
(
self
.
search_box
.
clear
)
# this can be set in designer -Dan
self
.
add_
contact
.
clicked
.
connect
(
self
.
test_
add_contact
)
self
.
add_contact_button
.
clicked
.
connect
(
self
.
add_contact
)
self
.
add_
search_contact_button
.
clicked
.
connect
(
self
.
add_contact
)
self
.
identity
.
activated
[
int
]
.
connect
(
self
.
set_identity
)
...
...
@@ -73,6 +79,19 @@ class MainWindow(base_class, ui_class):
notification_center
.
add_observer
(
self
,
name
=
"SIPAccountDidActivate"
)
notification_center
.
add_observer
(
self
,
name
=
"SIPAccountDidDeactivate"
)
def
add_contact
(
self
,
clicked
):
model
=
self
.
contact_model
selected_items
=
((
index
.
row
(),
model
.
data
(
index
))
for
index
in
self
.
contact_list
.
selectionModel
()
.
selectedIndexes
())
try
:
item
=
(
item
for
row
,
item
in
sorted
(
selected_items
)
if
type
(
item
)
in
(
Contact
,
ContactGroup
))
.
next
()
preferred_group
=
item
if
type
(
item
)
is
ContactGroup
else
item
.
group
except
StopIteration
:
try
:
preferred_group
=
(
group
for
group
in
model
.
contact_groups
if
type
(
group
)
is
ContactGroup
)
.
next
()
except
StopIteration
:
preferred_group
=
None
self
.
contact_editor
.
open_for_add
(
self
.
search_box
.
text
(),
preferred_group
)
def
set_user_icon
(
self
,
image_file_name
):
pixmap
=
QPixmap
(
32
,
32
)
pixmap
.
fill
(
QColor
(
Qt
.
transparent
))
...
...
@@ -91,9 +110,9 @@ class MainWindow(base_class, ui_class):
self
.
image
.
setPixmap
(
pixmap
)
def
enable_call_buttons
(
self
,
enabled
):
self
.
audio_call
.
setEnabled
(
enabled
)
self
.
im_session
.
setEnabled
(
enabled
)
self
.
ds_session
.
setEnabled
(
enabled
)
self
.
audio_call
_button
.
setEnabled
(
enabled
)
self
.
im_session
_button
.
setEnabled
(
enabled
)
self
.
ds_session
_button
.
setEnabled
(
enabled
)
def
set_identity
(
self
,
index
):
account_manager
=
AccountManager
()
...
...
@@ -102,7 +121,7 @@ class MainWindow(base_class, ui_class):
def
search_box_text_changed
(
self
,
text
):
if
text
:
self
.
main_view
.
setCurrentWidget
(
self
.
contacts_panel
)
self
.
switch_view
.
setText
(
u"Sessions"
)
self
.
switch_view
_button
.
setText
(
u"Sessions"
)
self
.
enable_call_buttons
(
True
)
else
:
selected_items
=
self
.
contact_list
.
selectionModel
()
.
selectedIndexes
()
...
...
@@ -113,6 +132,21 @@ class MainWindow(base_class, ui_class):
active_widget
=
self
.
search_list_panel
if
self
.
contact_search_model
.
rowCount
()
else
self
.
not_found_panel
self
.
search_view
.
setCurrentWidget
(
active_widget
)
def
contact_model_added_items
(
self
,
items
):
if
self
.
search_box
.
text
()
.
isEmpty
():
return
active_widget
=
self
.
search_list_panel
if
self
.
contact_search_model
.
rowCount
()
else
self
.
not_found_panel
self
.
search_view
.
setCurrentWidget
(
active_widget
)
def
contact_model_removed_items
(
self
,
items
):
if
self
.
search_box
.
text
()
.
isEmpty
():
return
if
any
(
type
(
item
)
is
Contact
for
item
in
items
)
and
self
.
contact_search_model
.
rowCount
()
==
0
:
self
.
search_box
.
clear
()
else
:
active_widget
=
self
.
search_list_panel
if
self
.
contact_search_model
.
rowCount
()
else
self
.
not_found_panel
self
.
search_view
.
setCurrentWidget
(
active_widget
)
def
contact_list_selection_changed
(
self
,
selected
,
deselected
):
selected_items
=
self
.
contact_list
.
selectionModel
()
.
selectedIndexes
()
self
.
enable_call_buttons
(
len
(
selected_items
)
==
1
and
type
(
self
.
contact_model
.
data
(
selected_items
[
0
]))
is
Contact
)
...
...
@@ -120,19 +154,7 @@ class MainWindow(base_class, ui_class):
def
switch_main_view
(
self
):
widget
=
self
.
main_view
.
currentWidget
()
.
sibling_panel
self
.
main_view
.
setCurrentWidget
(
widget
)
self
.
switch_view
.
setText
(
widget
.
sibling_name
)
def
test_add_contact
(
self
):
from
blink.contacts
import
Contact
,
ContactGroup
import
random
no
=
random
.
randrange
(
1
,
100
)
try
:
test_group
=
(
group
for
group
in
self
.
contact_model
.
contact_groups
if
group
.
name
==
'Test'
)
.
next
()
except
StopIteration
:
test_group
=
ContactGroup
(
'Test'
)
contact
=
Contact
(
test_group
,
'John Doe
%02
d'
%
no
,
'user
%02
d@test.com'
%
no
)
contact
.
status
=
random
.
choice
((
'online'
,
'away'
,
'busy'
,
'offline'
))
self
.
contact_model
.
addContact
(
contact
)
self
.
switch_view_button
.
setText
(
widget
.
sibling_name
)
@
run_in_gui_thread
def
handle_notification
(
self
,
notification
):
...
...
blink/widgets/iconselector.py
0 → 100644
View file @
8fd67017
# Copyright (c) 2010 AG Projects. See LICENSE for details.
#
import
os
from
PyQt4.QtCore
import
Qt
from
PyQt4.QtGui
import
QFileDialog
,
QLabel
,
QPixmap
from
blink.resources
import
ApplicationData
,
Resources
from
blink.widgets.util
import
QtDynamicProperty
class
IconSelector
(
QLabel
):
default_icon
=
QtDynamicProperty
(
'default_icon'
,
unicode
)
def
__init__
(
self
,
parent
=
None
):
super
(
QLabel
,
self
)
.
__init__
(
parent
)
self
.
setMinimumSize
(
36
,
36
)
self
.
filename
=
None
self
.
default_icon
=
None
self
.
last_icon_directory
=
os
.
path
.
expanduser
(
'~'
)
def
_get_filename
(
self
):
return
self
.
__dict__
[
'filename'
]
def
_set_filename
(
self
,
filename
):
self
.
__dict__
[
'filename'
]
=
filename
filename
=
ApplicationData
.
get
(
filename
)
if
filename
else
Resources
.
get
(
self
.
default_icon
)
pixmap
=
QPixmap
()
if
pixmap
.
load
(
filename
):
self
.
setPixmap
(
pixmap
.
scaled
(
32
,
32
,
Qt
.
KeepAspectRatio
,
Qt
.
SmoothTransformation
))
else
:
self
.
setPixmap
(
pixmap
)
filename
=
property
(
_get_filename
,
_set_filename
)
del
_get_filename
,
_set_filename
def
mouseReleaseEvent
(
self
,
event
):
if
event
.
button
()
==
Qt
.
LeftButton
and
self
.
rect
()
.
contains
(
event
.
pos
()):
filename
=
unicode
(
QFileDialog
.
getOpenFileName
(
self
,
u'Select Icon'
,
self
.
last_icon_directory
,
u"Images (*.png *.tiff *.jpg *.xmp *.svg)"
))
if
filename
:
self
.
last_icon_directory
=
os
.
path
.
dirname
(
filename
)
self
.
filename
=
filename
if
os
.
path
.
realpath
(
filename
)
!=
os
.
path
.
realpath
(
Resources
.
get
(
self
.
default_icon
))
else
None
super
(
IconSelector
,
self
)
.
mouseReleaseEvent
(
event
)
resources/blink.ui
View file @
8fd67017
...
...
@@ -230,7 +230,7 @@
</layout>
</item>
<item>
<widget
class=
"QPushButton"
name=
"switch_view"
>
<widget
class=
"QPushButton"
name=
"switch_view
_button
"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Expanding"
vsizetype=
"Minimum"
>
<horstretch>
0
</horstretch>
...
...
@@ -345,7 +345,7 @@
<number>
3
</number>
</property>
<item>
<widget
class=
"QPushButton"
name=
"back_to_contacts"
>
<widget
class=
"QPushButton"
name=
"back_to_contacts
_button
"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Expanding"
vsizetype=
"Fixed"
>
<horstretch>
0
</horstretch>
...
...
@@ -367,7 +367,7 @@
</widget>
</item>
<item>
<widget
class=
"QPushButton"
name=
"add_search_contact"
>
<widget
class=
"QPushButton"
name=
"add_search_contact
_button
"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Expanding"
vsizetype=
"Fixed"
>
<horstretch>
0
</horstretch>
...
...
@@ -486,7 +486,7 @@ buttons below.</string>
<number>
3
</number>
</property>
<item>
<widget
class=
"QToolButton"
name=
"add_contact"
>
<widget
class=
"QToolButton"
name=
"add_contact
_button
"
>
<property
name=
"minimumSize"
>
<size>
<width>
29
</width>
...
...
@@ -533,7 +533,7 @@ buttons below.</string>
<number>
0
</number>
</property>
<item>
<widget
class=
"QToolButton"
name=
"audio_call"
>
<widget
class=
"QToolButton"
name=
"audio_call
_button
"
>
<property
name=
"minimumSize"
>
<size>
<width>
29
</width>
...
...
@@ -559,7 +559,7 @@ buttons below.</string>
</widget>
</item>
<item>
<widget
class=
"QToolButton"
name=
"im_session"
>
<widget
class=
"QToolButton"
name=
"im_session
_button
"
>
<property
name=
"minimumSize"
>
<size>
<width>
29
</width>
...
...
@@ -584,7 +584,7 @@ buttons below.</string>
</widget>
</item>
<item>
<widget
class=
"QToolButton"
name=
"ds_session"
>
<widget
class=
"QToolButton"
name=
"ds_session
_button
"
>
<property
name=
"minimumSize"
>
<size>
<width>
29
</width>
...
...
@@ -625,7 +625,7 @@ buttons below.</string>
</spacer>
</item>
<item>
<widget
class=
"QToolButton"
name=
"silent"
>
<widget
class=
"QToolButton"
name=
"silent
_button
"
>
<property
name=
"minimumSize"
>
<size>
<width>
29
</width>
...
...
@@ -690,7 +690,7 @@ buttons below.</string>
<number>
3
</number>
</property>
<item>
<widget
class=
"QPushButton"
name=
"hangup_all"
>
<widget
class=
"QPushButton"
name=
"hangup_all
_button
"
>
<property
name=
"minimumSize"
>
<size>
<width>
0
</width>
...
...
@@ -712,7 +712,7 @@ buttons below.</string>
</widget>
</item>
<item>
<widget
class=
"QPushButton"
name=
"conference"
>
<widget
class=
"QPushButton"
name=
"conference
_button
"
>
<property
name=
"minimumSize"
>
<size>
<width>
0
</width>
...
...
@@ -747,7 +747,7 @@ buttons below.</string>
</spacer>
</item>
<item>
<widget
class=
"QToolButton"
name=
"mute"
>
<widget
class=
"QToolButton"
name=
"mute
_button
"
>
<property
name=
"minimumSize"
>
<size>
<width>
29
</width>
...
...
resources/contact_editor.ui
0 → 100644
View file @
8fd67017
This diff is collapsed.
Click to expand it.
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