Helpviewer/Download/DownloadManager.py

changeset 3022
57179e4cdadd
parent 3020
542e97d4ecb3
child 3034
7ce719013078
child 3058
0a02c433f52d
equal deleted inserted replaced
3021:801289962f4e 3022:57179e4cdadd
78 78
79 if selectedRowsCount == 1: 79 if selectedRowsCount == 1:
80 row = self.downloadsView.selectionModel().selectedRows()[0].row() 80 row = self.downloadsView.selectionModel().selectedRows()[0].row()
81 itm = self.__downloads[row] 81 itm = self.__downloads[row]
82 if itm.downloadCanceled(): 82 if itm.downloadCanceled():
83 menu.addAction(UI.PixmapCache.getIcon("restart.png"), 83 menu.addAction(
84 UI.PixmapCache.getIcon("restart.png"),
84 self.trUtf8("Retry"), self.__contextMenuRetry) 85 self.trUtf8("Retry"), self.__contextMenuRetry)
85 else: 86 else:
86 if itm.downloadedSuccessfully(): 87 if itm.downloadedSuccessfully():
87 menu.addAction(UI.PixmapCache.getIcon("open.png"), 88 menu.addAction(
89 UI.PixmapCache.getIcon("open.png"),
88 self.trUtf8("Open"), self.__contextMenuOpen) 90 self.trUtf8("Open"), self.__contextMenuOpen)
89 elif itm.downloading(): 91 elif itm.downloading():
90 menu.addAction(UI.PixmapCache.getIcon("stopLoading.png"), 92 menu.addAction(
93 UI.PixmapCache.getIcon("stopLoading.png"),
91 self.trUtf8("Cancel"), self.__contextMenuCancel) 94 self.trUtf8("Cancel"), self.__contextMenuCancel)
92 menu.addSeparator() 95 menu.addSeparator()
93 menu.addAction(self.trUtf8("Open Containing Folder"), 96 menu.addAction(
97 self.trUtf8("Open Containing Folder"),
94 self.__contextMenuOpenFolder) 98 self.__contextMenuOpenFolder)
95 menu.addSeparator() 99 menu.addSeparator()
96 menu.addAction(self.trUtf8("Go to Download Page"), 100 menu.addAction(
101 self.trUtf8("Go to Download Page"),
97 self.__contextMenuGotoPage) 102 self.__contextMenuGotoPage)
98 menu.addAction(self.trUtf8("Copy Download Link"), 103 menu.addAction(
104 self.trUtf8("Copy Download Link"),
99 self.__contextMenuCopyLink) 105 self.__contextMenuCopyLink)
100 menu.addSeparator() 106 menu.addSeparator()
101 menu.addAction(self.trUtf8("Select All"), self.__contextMenuSelectAll) 107 menu.addAction(self.trUtf8("Select All"), self.__contextMenuSelectAll)
102 if selectedRowsCount > 1 or \ 108 if selectedRowsCount > 1 or \
103 (selectedRowsCount == 1 and \ 109 (selectedRowsCount == 1 and \
104 not self.__downloads[ 110 not self.__downloads[
105 self.downloadsView.selectionModel().selectedRows()[0].row()]\ 111 self.downloadsView.selectionModel().selectedRows()[0].row()]\
106 .downloading()): 112 .downloading()):
107 menu.addSeparator() 113 menu.addSeparator()
108 menu.addAction(self.trUtf8("Remove From List"), 114 menu.addAction(
115 self.trUtf8("Remove From List"),
109 self.__contextMenuRemoveSelected) 116 self.__contextMenuRemoveSelected)
110 117
111 menu.exec_(QCursor.pos()) 118 menu.exec_(QCursor.pos())
112 119
113 def shutdown(self): 120 def shutdown(self):
161 @keyparam mainWindow reference to the main window (HelpWindow) 168 @keyparam mainWindow reference to the main window (HelpWindow)
162 """ 169 """
163 request = QNetworkRequest(requestOrUrl) 170 request = QNetworkRequest(requestOrUrl)
164 if request.url().isEmpty(): 171 if request.url().isEmpty():
165 return 172 return
166 self.handleUnsupportedContent(self.__manager.get(request), 173 self.handleUnsupportedContent(
174 self.__manager.get(request),
167 requestFileName=requestFileName, 175 requestFileName=requestFileName,
168 download=True, 176 download=True,
169 mainWindow=mainWindow) 177 mainWindow=mainWindow)
170 178
171 def handleUnsupportedContent(self, reply, requestFileName=False, 179 def handleUnsupportedContent(self, reply, requestFileName=False,
249 if icon.isNull(): 257 if icon.isNull():
250 icon = self.style().standardIcon(QStyle.SP_FileIcon) 258 icon = self.style().standardIcon(QStyle.SP_FileIcon)
251 itm.setIcon(icon) 259 itm.setIcon(icon)
252 260
253 oldHeight = self.downloadsView.rowHeight(row) 261 oldHeight = self.downloadsView.rowHeight(row)
254 self.downloadsView.setRowHeight(row, 262 self.downloadsView.setRowHeight(
263 row,
255 max(oldHeight, itm.minimumSizeHint().height() * 1.5)) 264 max(oldHeight, itm.minimumSizeHint().height() * 1.5))
256 265
257 remove = False 266 remove = False
258 globalSettings = QWebSettings.globalSettings() 267 globalSettings = QWebSettings.globalSettings()
259 if not itm.downloading() and \ 268 if not itm.downloading() and \

eric ide

mercurial