implement photo caroussel
This commit is contained in:
parent
fc9f6b439f
commit
2921a17a3e
2 changed files with 99 additions and 49 deletions
|
|
@ -26,7 +26,7 @@ from weboob.tools.application.qt import QtDo, HTMLDelegate
|
||||||
from weboob.capabilities.contact import ICapContact, Contact
|
from weboob.capabilities.contact import ICapContact, Contact
|
||||||
from weboob.capabilities.chat import ICapChat
|
from weboob.capabilities.chat import ICapChat
|
||||||
from weboob.capabilities.messages import ICapMessages, ICapMessagesPost, Message
|
from weboob.capabilities.messages import ICapMessages, ICapMessagesPost, Message
|
||||||
from weboob.capabilities.base import NotLoaded
|
from weboob.capabilities.base import NotLoaded, NotLoadedMeta
|
||||||
|
|
||||||
from .ui.contacts_ui import Ui_Contacts
|
from .ui.contacts_ui import Ui_Contacts
|
||||||
from .ui.contact_thread_ui import Ui_ContactThread
|
from .ui.contact_thread_ui import Ui_ContactThread
|
||||||
|
|
@ -190,11 +190,17 @@ class ContactThread(QWidget):
|
||||||
self.process_reply = None
|
self.process_reply = None
|
||||||
|
|
||||||
class ContactProfile(QWidget):
|
class ContactProfile(QWidget):
|
||||||
|
|
||||||
|
displayed_photo_idx = 0
|
||||||
|
|
||||||
def __init__(self, weboob, contact, parent=None):
|
def __init__(self, weboob, contact, parent=None):
|
||||||
QWidget.__init__(self, parent)
|
QWidget.__init__(self, parent)
|
||||||
self.ui = Ui_Profile()
|
self.ui = Ui_Profile()
|
||||||
self.ui.setupUi(self)
|
self.ui.setupUi(self)
|
||||||
|
|
||||||
|
self.connect(self.ui.previousButton, SIGNAL('clicked()'), self.previousClicked)
|
||||||
|
self.connect(self.ui.nextButton, SIGNAL('clicked()'), self.nextClicked)
|
||||||
|
|
||||||
self.weboob = weboob
|
self.weboob = weboob
|
||||||
self.contact = contact
|
self.contact = contact
|
||||||
self.loaded_profile = False
|
self.loaded_profile = False
|
||||||
|
|
@ -214,26 +220,19 @@ class ContactProfile(QWidget):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
missing_fields = set(['photos'])
|
missing_fields = set(['photos'])
|
||||||
first = True
|
photo = contact.photos.values()[0]
|
||||||
for photo in contact.photos.itervalues():
|
data = None
|
||||||
photo = contact.photos.values()[0]
|
if photo.data:
|
||||||
if photo.data:
|
self.displayed_photo_idx = 0
|
||||||
data = photo.data
|
data = photo.data
|
||||||
try:
|
try:
|
||||||
missing_fields.remove('photos')
|
missing_fields.remove('photos')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
|
||||||
elif photo.thumbnail_data:
|
|
||||||
data = photo.thumbnail_data
|
|
||||||
else:
|
|
||||||
continue
|
|
||||||
if first:
|
|
||||||
img = QImage.fromData(data)
|
|
||||||
self.ui.photoLabel.setPixmap(QPixmap.fromImage(img))
|
|
||||||
first = False
|
|
||||||
else:
|
|
||||||
# TODO display thumbnails
|
|
||||||
pass
|
pass
|
||||||
|
elif photo.thumbnail_data:
|
||||||
|
data = photo.thumbnail_data
|
||||||
|
if data:
|
||||||
|
self.display_photo(photo, data)
|
||||||
|
|
||||||
self.ui.nicknameLabel.setText('<h1>%s</h1>' % contact.name)
|
self.ui.nicknameLabel.setText('<h1>%s</h1>' % contact.name)
|
||||||
self.ui.statusLabel.setText('%s' % contact.status_msg)
|
self.ui.statusLabel.setText('%s' % contact.status_msg)
|
||||||
|
|
@ -289,6 +288,22 @@ class ContactProfile(QWidget):
|
||||||
else:
|
else:
|
||||||
logging.warning('Not supported widget: %r' % widget)
|
logging.warning('Not supported widget: %r' % widget)
|
||||||
|
|
||||||
|
def previousClicked(self):
|
||||||
|
self.displayed_photo_idx = (self.displayed_photo_idx - 1) % len(self.contact.photos)
|
||||||
|
self.display_photo(self.contact.photos.values()[self.displayed_photo_idx])
|
||||||
|
|
||||||
|
def nextClicked(self):
|
||||||
|
self.displayed_photo_idx = (self.displayed_photo_idx + 1) % len(self.contact.photos)
|
||||||
|
self.display_photo(self.contact.photos.values()[self.displayed_photo_idx])
|
||||||
|
|
||||||
|
def display_photo(self, photo, data=None):
|
||||||
|
img = QImage.fromData(data if data else photo.data)
|
||||||
|
self.ui.photoLabel.setPixmap(QPixmap.fromImage(img))
|
||||||
|
if not isinstance(photo.url, NotLoadedMeta):
|
||||||
|
self.ui.photoURLEdit.setText(photo.url)
|
||||||
|
self.ui.shownLabel.setText('' if photo.shown else 'Hidden photo')
|
||||||
|
|
||||||
|
|
||||||
class IGroup(object):
|
class IGroup(object):
|
||||||
def __init__(self, weboob, id, name):
|
def __init__(self, weboob, id, name):
|
||||||
self.id = id
|
self.id = id
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>576</width>
|
<width>755</width>
|
||||||
<height>647</height>
|
<height>647</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>576</width>
|
<width>755</width>
|
||||||
<height>647</height>
|
<height>647</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -53,38 +53,6 @@
|
||||||
<enum>QFrame::Raised</enum>
|
<enum>QFrame::Raised</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
|
||||||
<widget class="QFrame" name="frame_photo">
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::StyledPanel</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Raised</enum>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="photoLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string><i>Receiving...</i></string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="headFrame">
|
<widget class="QFrame" name="headFrame">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
|
@ -133,6 +101,73 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="frame_photo">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="previousButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Previous</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="nextButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Next</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="photoURLEdit"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="shownLabel">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">color: rgb(255, 0, 0);</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="photoLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string><i>Receiving...</i></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>13</width>
|
||||||
|
<height>13</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue