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.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:
self.ui.descriptionEdit.setText('<h1>Description</h1><p><i>Receiving...</i></p>')
missing_fields.add('summary')
@ -249,7 +249,7 @@ class ContactProfile(QWidget):
self.loaded_profile = True
for head in contact.profile:
if head.flags & head.HEAD:
widget = self.ui.headFrame
widget = self.ui.headWidget
else:
widget = self.ui.profileTab
self.process_node(head, widget)
@ -284,6 +284,7 @@ class ContactProfile(QWidget):
label = QLabel(u'<b>%s:</b> ' % node.label)
widget.layout().addRow(label, value)
elif isinstance(widget.layout(), QVBoxLayout):
widget.layout().addWidget(QLabel(u'<h3>%s</h3>' % node.label))
widget.layout().addWidget(value)
else:
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])
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))
if not isinstance(photo.url, NotLoadedMeta):
self.ui.photoURLEdit.setText(photo.url)
self.ui.shownLabel.setText('' if photo.shown else 'Hidden photo')
text = '<a href="%s">%s</a>' % (photo.url, photo.url)
if not photo.shown:
text += '<br /><font color=#ff0000><i>(Hidden photo)</i></font>'
self.ui.photoUrlLabel.setText(text)
class IGroup(object):
def __init__(self, weboob, id, name):

View file

@ -71,19 +71,47 @@
<item>
<widget class="QLabel" name="nicknameLabel">
<property name="text">
<string>&lt;h1&gt;Nickname&lt;/h1&gt;</string>
<string>&lt;h1&gt;Loading...&lt;/h1&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="statusLabel">
<property name="text">
<string>status</string>
<string/>
</property>
</widget>
</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>
<spacer name="verticalSpacer">
@ -114,41 +142,64 @@
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<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">
<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>
</widget>
</item>
<item>
<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">
<string>Next</string>
<string>&gt;</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">
<widget class="QLabel" name="photoUrlLabel">
<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>
</widget>
</item>
@ -160,7 +211,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>13</width>
<height>13</height>
<height>0</height>
</size>
</property>
</spacer>