~ubuntu-branches/ubuntu/precise/ubuntu-sso-client/precise

« back to all changes in this revision

Viewing changes to ubuntu_sso/qt/__init__.py

  • Committer: Package Import Robot
  • Author(s): Natalia Bidart (nessita)
  • Date: 2012-03-21 12:37:28 UTC
  • mfrom: (1.1.34)
  • Revision ID: package-import@ubuntu.com-20120321123728-tbudi0zedpxy9x7n
Tags: 2.99.91-0ubuntu1
* New upstream release:
  - Do not allow ssl errors to be ignored (LP: #959390).
  - Handle wrong credentials properly in qtnetwork webclient
    (LP: #957317).
  - Use HTTPClientFactory to allow replacing the reactor used to connect
    (LP: #929207).
  - Decode the content of help_text (LP: #951371).
  - Adding missing file for translation (LP: #951376).
  - Adding a general error message when the argument received by
    build_general_error_message is not a dict (LP: #865176).
  - Adding some checks to setup_page (LP: #951461).
  - Adding a padding to the right margin of the reset layout, and align
    one of its layout to the left (LP: #945065).
  - Executing hide_error when the user click the refresh captcha link,
    not inside of the _refresh_captcha method, because this is executed
    automatically when a captcha error is generated, so we will always
    miss the error message (LP: #955010).
  - Removing the align property from the label that wasn't necessary
    and was breakint the work wrap. Also adjust the height of the widget
    depending if it has more than one line (LP: #940392).
  - Improve logging operations (LP: #934500).
  - Making LINK_STYLE to be unicode (LP: #950953).
  - Setting the window title equal to the app_name (LP: #949744).
  - The _move_to_email_verification_page wasn't receiving the params
    that the signal emits (LP: #945066).
  - Improve the grammar for the CLOSE_AND_SETUP_LATER button text
    (LP: #949978).
  - Changed the way in which we deal with proxies to work around bugs
    found in the QNetworkAccessManager (LP: #957313).
  - Stopped listening to the proxyAuthenticationRequired to avoid the
    dialog showing more than once (LP: #957170)
  - Made changes in the way the webclient is selected to ensure that qt
    is used when possible (LP: #957169).
  - Connected the WebKit browser correctly so that the tc page gets
    loaded (LP: #933081).
  - Added code to check if the browser with the t&c was already loaded.
    If it is just show the t&c page, otherwise perform the request
    (LP: #956185).
  - Added a translatable string to give more context of the ssl cert
    info to the user (LP: #948119).
  - Provided the logic required for the Qt webclient implementation to
    detect ssl errors and spawn the ssl dialog to allow the user accept
    the ssl cert exceptions (LP: #948134).
  - Changed the qt webclient implementation to use a proxy factory so
    that the correct proxy is chosen according to the request
    (LP: #950088).
  - Added the required code to allow the webclient use authenticated
    proxies and request the creds when needed (LP: #933727).
  - The tooltip should not be shown for titles and subtitles when
    no cut off was needed (LP: #949741).
  - Enable platform-specific styling (LP: #953318).
  - Only import DBus on Linux (LP: #956304).
  - Don't hard-code font sizes.
  - Remove usage of weight property as a numeric; just use bold
    property instead (LP: #953062).
* Removed patches which were included upstream.
* debian/watch:
  - Updated url to fetch tarball from latest milestone.
* debian/ubuntu-sso-client-qt.install:
  - Install Qt UI executables for providing proxy authentication support.
* debian/control:
  - Added new dependency on python-openssl to python-ubuntu-sso-client.
  - Improved description for ubuntu-sso-client-qt binary package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import collections
20
20
 
21
 
 
22
 
LINK_STYLE = ('<a href="{link_url}">'
 
21
from PyQt4 import QtGui, QtCore
 
22
 
 
23
from ubuntu_sso.logger import setup_gui_logging
 
24
from ubuntu_sso.utils.ui import GENERIC_BACKEND_ERROR
 
25
 
 
26
logger = setup_gui_logging('ubuntu_sso.qt')
 
27
 
 
28
LINK_STYLE = (u'<a href="{link_url}">'
23
29
              '<span style="color:#df2d1f;">{link_text}</span></a>')
24
30
ERROR_ALL = '__all__'
25
 
ERROR_STYLE = u'<font color="#df2d1f"><b>%s</b></font>'
 
31
ERROR_STYLE = u'<font color="#df2d1f" style="font-size:small"><b>%s</b></font>'
26
32
ERROR_MESSAGE = 'message'
27
33
PREFERED_UI_SIZE = {'width': 550, 'height': 525}
28
 
TITLE_STYLE = u'<span style="font-size:24px">%s</span>'
 
34
TITLE_STYLE = u'<span style="font-size:xx-large;font-weight:bold;">%s</span>'
 
35
WINDOW_TITLE = 'Ubuntu Single Sign On'
29
36
 
30
37
 
31
38
# Based on the gtk implementation
32
39
def build_general_error_message(errordict):
33
40
    """Build a user-friendly error message from the errordict."""
 
41
    logger.debug('build_general_error_message: errordict is: %r.', errordict)
34
42
    result = ''
35
43
    if isinstance(errordict, collections.Mapping):
36
44
        msg1 = errordict.get(ERROR_ALL)
50
58
            result = '\n'.join(
51
59
                [('%s: %s' % (k, v)) for k, v in errordict.iteritems()])
52
60
    else:
53
 
        result = repr(errordict)
 
61
        result = GENERIC_BACKEND_ERROR
 
62
        logger.error('build_general_error_message with unknown error: %r',
 
63
            errordict)
 
64
 
 
65
    logger.info('build_general_error_message: returning %r.', result)
54
66
    return result
 
67
 
 
68
 
 
69
def maybe_elide_text(label, text, width, markup=None):
 
70
    """Set 'text' to be the 'label's text.
 
71
 
 
72
    If 'text' is longer than 'width', set the label's tooltip to be the full
 
73
    text, and the text itself to be the elided version of 'text'.
 
74
 
 
75
    """
 
76
    fm = QtGui.QFontMetrics(label.font())
 
77
    elided_text = fm.elidedText(text, QtCore.Qt.ElideRight, width)
 
78
    if elided_text != text:
 
79
        label.setToolTip(text)
 
80
    if markup is not None:
 
81
        elided_text = markup % elided_text
 
82
    label.setText(elided_text)