~nataliabidart/ubuntuone-control-panel/focus

« back to all changes in this revision

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

  • Committer: Natalia B. Bidart
  • Date: 2012-03-08 14:13:27 UTC
  • Revision ID: natalia.bidart@canonical.com-20120308141327-u20ya4qjtf3fuvly
- Make the "Explore" buttons for folders be disabled when the folder is not
  synched (LP: #949035).

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
YES = QtGui.QMessageBox.Yes
62
62
 
63
63
 
 
64
class ExploreFolderButton(QtGui.QPushButton):
 
65
 
 
66
    def __init__(self, folder_path, enabled=True, parent=None):
 
67
        super(ExploreFolderButton, self).__init__(parent=parent)
 
68
        self.folder_path = folder_path
 
69
        self.setFlat(True)
 
70
        self.setText(FOLDERS_COLUMN_EXPLORE)
 
71
        policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
 
72
                                   QtGui.QSizePolicy.Fixed)
 
73
        self.setSizePolicy(policy)
 
74
        self.clicked.connect(self.on_clicked)
 
75
 
 
76
    def on_clicked(self):
 
77
        """Open the folder_path in the default file manager."""
 
78
        uri = unicode(QtCore.QUrl.fromLocalFile(self.folder_path).toString())
 
79
        uri_hook(uri)
 
80
 
 
81
 
64
82
class FoldersPanel(UbuntuOneBin):
65
83
    """The Folders Tab Panel widget"""
66
84
 
180
198
 
181
199
                # attach a third item with a button to explore the folder
182
200
                model_index = self.ui.folders.indexFromItem(child, EXPLORE_COL)
183
 
                button = QtGui.QPushButton(parent=self.ui.folders)
184
 
                button.setFlat(True)
185
 
                button.setText(FOLDERS_COLUMN_EXPLORE)
186
 
                button.setObjectName('explore_folder_button')
187
 
                policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
188
 
                                           QtGui.QSizePolicy.Fixed)
189
 
                button.setSizePolicy(policy)
 
201
                button = ExploreFolderButton(folder_path=child.volume_path,
 
202
                            parent=self.ui.folders)
190
203
                button.setEnabled(bool(volume[u'subscribed']))
191
 
 
192
 
                # Operator not preceded by a space
193
 
                # pylint: disable=C0322
194
 
                cb = lambda checked, item=child: \
195
 
                    self.on_folders_itemActivated(item)
196
 
                # pylint: enable=C0322
197
 
                button.clicked.connect(cb)
198
204
                self.ui.folders.setIndexWidget(model_index, button)
199
205
 
200
206
        self.ui.folders.expandAll()