improvement of photos display

This commit is contained in:
Romain Bignon 2010-11-20 13:24:38 +01:00
commit 8a5a04a214
2 changed files with 79 additions and 26 deletions

View file

@ -236,7 +236,7 @@ class ContactProfile(QWidget):
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)
self.ui.contactURLEdit.setText('%s' % contact.url) self.ui.contactUrlLabel.setText('<b>URL:</b> <a href="%s">%s</a>' % (contact.url, contact.url))
if contact.summary is NotLoaded: if contact.summary is NotLoaded:
self.ui.descriptionEdit.setText('<h1>Description</h1><p><i>Receiving...</i></p>') self.ui.descriptionEdit.setText('<h1>Description</h1><p><i>Receiving...</i></p>')
missing_fields.add('summary') missing_fields.add('summary')
@ -249,7 +249,7 @@ class ContactProfile(QWidget):
self.loaded_profile = True self.loaded_profile = True
for head in contact.profile: for head in contact.profile:
if head.flags & head.HEAD: if head.flags & head.HEAD:
widget = self.ui.headFrame widget = self.ui.headWidget
else: else:
widget = self.ui.profileTab widget = self.ui.profileTab
self.process_node(head, widget) self.process_node(head, widget)
@ -284,6 +284,7 @@ class ContactProfile(QWidget):
label = QLabel(u'<b>%s:</b> ' % node.label) label = QLabel(u'<b>%s:</b> ' % node.label)
widget.layout().addRow(label, value) widget.layout().addRow(label, value)
elif isinstance(widget.layout(), QVBoxLayout): elif isinstance(widget.layout(), QVBoxLayout):
widget.layout().addWidget(QLabel(u'<h3>%s</h3>' % node.label))
widget.layout().addWidget(value) widget.layout().addWidget(value)
else: else:
logging.warning('Not supported widget: %r' % widget) logging.warning('Not supported widget: %r' % widget)
@ -297,12 +298,13 @@ class ContactProfile(QWidget):
self.display_photo(self.contact.photos.values()[self.displayed_photo_idx]) self.display_photo(self.contact.photos.values()[self.displayed_photo_idx])
def display_photo(self, photo, data=None): def display_photo(self, photo, data=None):
img = QImage.fromData(data if data else photo.data) img = QImage.fromData(data if data else photo.data).scaledToWidth(self.width()/3)
self.ui.photoLabel.setPixmap(QPixmap.fromImage(img)) self.ui.photoLabel.setPixmap(QPixmap.fromImage(img))
if not isinstance(photo.url, NotLoadedMeta): if not isinstance(photo.url, NotLoadedMeta):
self.ui.photoURLEdit.setText(photo.url) text = '<a href="%s">%s</a>' % (photo.url, photo.url)
self.ui.shownLabel.setText('' if photo.shown else 'Hidden photo') if not photo.shown:
text += '<br /><font color=#ff0000><i>(Hidden photo)</i></font>'
self.ui.photoUrlLabel.setText(text)
class IGroup(object): class IGroup(object):
def __init__(self, weboob, id, name): def __init__(self, weboob, id, name):

View file

@ -71,19 +71,47 @@
<item> <item>
<widget class="QLabel" name="nicknameLabel"> <widget class="QLabel" name="nicknameLabel">
<property name="text"> <property name="text">
<string>&lt;h1&gt;Nickname&lt;/h1&gt;</string> <string>&lt;h1&gt;Loading...&lt;/h1&gt;</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="statusLabel"> <widget class="QLabel" name="statusLabel">
<property name="text"> <property name="text">
<string>status</string> <string/>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="contactURLEdit"/> <widget class="QLabel" name="contactUrlLabel">
<property name="text">
<string>&lt;b&gt;URL:&lt;/b&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="headWidget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
@ -114,41 +142,64 @@
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QPushButton" name="previousButton"> <widget class="QPushButton" name="previousButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="text"> <property name="text">
<string>Previous</string> <string>&lt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="photoLabel">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="nextButton"> <widget class="QPushButton" name="nextButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="text"> <property name="text">
<string>Next</string> <string>&gt;</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_3"> <widget class="QLabel" name="photoUrlLabel">
<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"> <property name="text">
<string>&lt;i&gt;Receiving...&lt;/i&gt;</string> <string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property> </property>
</widget> </widget>
</item> </item>
@ -160,7 +211,7 @@
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>13</width> <width>13</width>
<height>13</height> <height>0</height>
</size> </size>
</property> </property>
</spacer> </spacer>