1
# -*- coding: utf-8 -*-
3
# Copyright 2012 Canonical Ltd.
5
# This program is free software: you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 3, as published
7
# by the Free Software Foundation.
9
# This program is distributed in the hope that it will be useful, but
10
# WITHOUT ANY WARRANTY; without even the implied warranties of
11
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12
# PURPOSE. See the GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License along
15
# with this program. If not, see <http://www.gnu.org/licenses/>.
17
"""The UI for Share file widget."""
21
from PyQt4 import QtGui, QtCore
23
from ubuntuone.controlpanel import cache
24
from ubuntuone.controlpanel.gui.qt.share_links_search import (
25
get_system_icon_for_filename,
27
from ubuntuone.controlpanel.gui.qt.ui import share_file_ui
28
from ubuntuone.controlpanel.logger import setup_logging
31
logger = setup_logging('qt.share_file')
34
class ShareFileWidget(cache.Cache, QtGui.QWidget):
35
"""Widget with the detail information about the shared file."""
37
linkDisabled = QtCore.pyqtSignal()
39
def __init__(self, file_path='', *args, **kwargs):
40
super(ShareFileWidget, self).__init__(*args, **kwargs)
41
self.ui = share_file_ui.Ui_Form()
43
self.file_path = file_path
45
self.ui.lbl_filename.setText(os.path.basename(file_path))
46
self.ui.lbl_path.setText(file_path)
47
icon = get_system_icon_for_filename(os.path.expanduser(file_path))
48
pixmap = icon.pixmap(24)
49
self.ui.lbl_icon.setPixmap(pixmap)
51
self.ui.btn_open.clicked.connect(self.open_file)
52
self.ui.btn_disable.clicked.connect(self.disable_link)
55
"""Open the specified file."""
56
path = u'file://%s' % self.file_path
57
QtGui.QDesktopServices.openUrl(QtCore.QUrl(path))
59
def disable_link(self, val):
60
"""Change the access of the file to Not Public."""
61
self.backend.change_public_access(
62
os.path.expanduser(self.file_path), False)
63
self.linkDisabled.emit()