~dobey/ubuntu/oneiric/ubuntuone-control-panel/release-113

« back to all changes in this revision

Viewing changes to ubuntuone/controlpanel/gui/qt/gotoweb.py

  • Committer: Sebastien Bacher
  • Date: 2011-07-25 13:17:38 UTC
  • mfrom: (25.1.2 ubuntuone-control-panel)
  • Revision ID: seb128@ubuntu.com-20110725131738-yuevatnd859d1phs
Tags: 1.1.1-0ubuntu1
releasing version 1.1.1-0ubuntu1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
 
 
3
# Authors: Natalia B. Bidart <natalia.bidart@canonical.com>
 
4
#
 
5
# Copyright 2011 Canonical Ltd.
 
6
#
 
7
# This program is free software: you can redistribute it and/or modify it
 
8
# under the terms of the GNU General Public License version 3, as published
 
9
# by the Free Software Foundation.
 
10
#
 
11
# This program is distributed in the hope that it will be useful, but
 
12
# WITHOUT ANY WARRANTY; without even the implied warranties of
 
13
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
14
# PURPOSE.  See the GNU General Public License for more details.
 
15
#
 
16
# You should have received a copy of the GNU General Public License along
 
17
# with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 
 
19
"""A button that opens links in the web."""
 
20
 
 
21
from PyQt4 import QtGui, QtCore
 
22
 
 
23
from ubuntuone.controlpanel.gui import qt
 
24
 
 
25
 
 
26
class GoToWebButton(QtGui.QPushButton):
 
27
    """The GoToWebButton widget"""
 
28
 
 
29
    def __init__(self, *args, **kwargs):
 
30
        """Initialize the UI of the widget."""
 
31
        super(GoToWebButton, self).__init__(*args, **kwargs)
 
32
        self.uri = None
 
33
        self.setIcon(qt.icon_from_name('external_icon_white'))
 
34
        self.setLayoutDirection(QtCore.Qt.RightToLeft)
 
35
        self.clicked.connect(self.on_clicked)
 
36
 
 
37
    @QtCore.pyqtSlot()
 
38
    def on_clicked(self):
 
39
        """Open self.uri if not None, do nothing otherwise."""
 
40
        if self.uri is not None:
 
41
            qt.uri_hook(self.uri)