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
b5599b28
Commit
b5599b28
authored
Apr 30, 2010
by
Luci Stanescu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified MainWindow to use the SIP accounts from the middleware
parent
7d7a6daa
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
12 deletions
+56
-12
mainwindow.py
blink/mainwindow.py
+56
-12
bonjour.png
resources/icons/bonjour.png
+0
-0
No files found.
blink/mainwindow.py
View file @
b5599b28
...
...
@@ -6,16 +6,25 @@ from __future__ import with_statement
__all__
=
[
'MainWindow'
]
from
PyQt4
import
uic
from
PyQt4.QtCore
import
Qt
from
PyQt4.QtGui
import
QBrush
,
QColor
,
QPainter
,
QPen
,
QPixmap
from
PyQt4.QtCore
import
Qt
,
QVariant
from
PyQt4.QtGui
import
QBrush
,
QColor
,
QIcon
,
QPainter
,
QPen
,
QPixmap
from
application.notification
import
IObserver
,
NotificationCenter
from
application.python.util
import
Null
from
zope.interface
import
implements
from
sipsimple.account
import
AccountManager
,
BonjourAccount
from
blink.contacts
import
ContactModel
,
ContactSearchModel
from
blink.resources
import
Resources
from
blink.util
import
run_in_gui_thread
ui_class
,
base_class
=
uic
.
loadUiType
(
Resources
.
get
(
'blink.ui'
))
class
MainWindow
(
base_class
,
ui_class
):
implements
(
IObserver
)
def
__init__
(
self
,
parent
=
None
):
super
(
MainWindow
,
self
)
.
__init__
(
parent
)
...
...
@@ -25,7 +34,7 @@ class MainWindow(base_class, ui_class):
self
.
setWindowTitle
(
'Blink'
)
self
.
setWindowIconText
(
'Blink'
)
self
.
_set
up_identities
()
self
.
_set
_user_icon
(
Resources
.
get
(
"icons/default-avatar.png"
))
# ":/resources/icons/default-avatar.png"
self
.
contact_model
=
ContactModel
(
self
)
self
.
contact_search_model
=
ContactSearchModel
(
self
.
contact_model
,
self
)
...
...
@@ -51,11 +60,17 @@ class MainWindow(base_class, ui_class):
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
.
identity
.
currentIndexChanged
[
str
]
.
connect
(
self
.
set_identity
)
self
.
identity
.
activated
[
int
]
.
connect
(
self
.
set_identity
)
#self.connect(self.contact_list, QtCore.SIGNAL("doubleClicked(const QModelIndex &)"), self.double_click_action)
#self.connect(self.contact_list.selectionModel(), QtCore.SIGNAL("selectionChanged(const QItemSelection &, const QItemSelection &)"), self.selection_changed)
notification_center
=
NotificationCenter
()
notification_center
.
add_observer
(
self
,
name
=
"SIPAccountManagerDidChangeDefaultAccount"
)
notification_center
.
add_observer
(
self
,
name
=
"SIPAccountManagerDidStart"
)
notification_center
.
add_observer
(
self
,
name
=
"SIPAccountDidActivate"
)
notification_center
.
add_observer
(
self
,
name
=
"SIPAccountDidDeactivate"
)
def
_set_user_icon
(
self
,
image_file_name
):
pixmap
=
QPixmap
(
32
,
32
)
pixmap
.
fill
(
QColor
(
Qt
.
transparent
))
...
...
@@ -73,14 +88,9 @@ class MainWindow(base_class, ui_class):
painter
.
end
()
self
.
image
.
setPixmap
(
pixmap
)
def
_setup_identities
(
self
):
self
.
identity
.
addItem
(
"31208005167@ag-projects.com"
)
self
.
identity
.
addItem
(
"Bonjour"
)
self
.
_set_user_icon
(
Resources
.
get
(
"icons/default-avatar.png"
))
#self._set_user_icon(":/resources/icons/default-avatar.png")
def
set_identity
(
self
,
string
):
print
"identity changed"
,
string
def
set_identity
(
self
,
index
):
account_manager
=
AccountManager
()
account_manager
.
default_account
=
self
.
identity
.
itemData
(
index
)
.
toPyObject
()
def
search_box_text_changed
(
self
,
text
):
if
text
:
...
...
@@ -107,6 +117,40 @@ class MainWindow(base_class, ui_class):
contact
.
status
=
random
.
choice
((
'online'
,
'away'
,
'busy'
,
'offline'
))
self
.
contact_model
.
addContact
(
contact
)
@
run_in_gui_thread
def
handle_notification
(
self
,
notification
):
handler
=
getattr
(
self
,
'_NH_
%
s'
%
notification
.
name
,
Null
)
handler
(
notification
)
def
_NH_SIPAccountDidActivate
(
self
,
notification
):
account
=
notification
.
sender
name
=
u'Bonjour'
if
account
is
BonjourAccount
()
else
account
.
id
icon
=
None
if
account
is
BonjourAccount
():
pixmap
=
QPixmap
()
if
pixmap
.
load
(
Resources
.
get
(
'icons/bonjour.png'
)):
pixmap
=
pixmap
.
scaled
(
16
,
16
,
Qt
.
KeepAspectRatio
,
Qt
.
SmoothTransformation
)
icon
=
QIcon
(
pixmap
)
if
icon
is
not
None
:
self
.
identity
.
addItem
(
icon
,
name
,
QVariant
(
account
))
else
:
self
.
identity
.
addItem
(
name
,
QVariant
(
account
))
def
_NH_SIPAccountDidDeactivate
(
self
,
notification
):
account
=
notification
.
sender
name
=
u'Bonjour'
if
account
is
BonjourAccount
()
else
account
.
id
self
.
identity
.
removeItem
(
self
.
identity
.
findText
(
name
))
def
_NH_SIPAccountManagerDidStart
(
self
,
notification
):
account
=
AccountManager
()
.
default_account
name
=
u'Bonjour'
if
account
is
BonjourAccount
()
else
account
.
id
self
.
identity
.
setCurrentIndex
(
self
.
identity
.
findText
(
name
))
def
_NH_SIPAccountManagerDidChangeDefaultAccount
(
self
,
notification
):
account
=
notification
.
data
.
account
name
=
u'Bonjour'
if
account
is
BonjourAccount
()
else
account
.
id
self
.
identity
.
setCurrentIndex
(
self
.
identity
.
findText
(
name
))
del
ui_class
,
base_class
resources/icons/bonjour.png
0 → 100644
View file @
b5599b28
769 Bytes
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