Beispiel #1
0
 def onProgress(self, req: RequestWrapper, bytesSend: int,
                bytesTotal: int) -> None:
     logger.debug("FileUploader.onProgress: %r, %r, %r", req, bytesSend,
                  bytesTotal)
     self.bytesTotal = bytesTotal
     self.bytesDone = bytesSend
     self.uploadProgress.emit(bytesSend, bytesTotal)
     if self.isCanceled:
         req.abort()
Beispiel #2
0
	def setImage(self, remoteFile: RequestWrapper) -> None:
		fn = remoteFile.getFileName()
		try:
			self.cache[remoteFile.dlKey] = QtGui.QImage(fn)
		except:
			pass
		self.request_repaint.emit()
Beispiel #3
0
	def setHTML(self, req: RequestWrapper = None) -> None:
		try:  # This request might got canceled meanwhile..
			html = bytes(req.readAll())
		except:
			return
		self.ui.webView.setHtml(html.decode("UTF-8"), QtCore.QUrl(NetworkService.url.replace("/admin", "")))
		self.ui.webView.show()
Beispiel #4
0
 def saveFile(self, req: RequestWrapper) -> None:
     if self._cancel:
         return
     print("xxx", os.path.join(self.localTargetDir, req.fname))
     fh = open(os.path.join(self.localTargetDir, req.fname), "wb+")
     fh.write(req.readAll().data())
     self.stats["filesDone"] += 1
     self.stats["bytesDone"] += req.fsize
     self.downloadProgress.emit(0, 0)
Beispiel #5
0
	def loadIconFromRequest(self, request: RequestWrapper) -> None:
		# this former code should be inspected where and why we attached a icon to self
		# TODO: where self.previewIcon was defined before?
		# icon = QtGui.QIcon(request.getFileName())
		# if not self.previewIcon:
		# 	self.previewIcon = QtWidgets.QLabel(self)
		# 	self.previewIcon.setPixmap(icon.pixmap(QtCore.QSize(32, 32)))
		# 	self.layout.insertWidget(0, self.previewIcon)
		# else:
		# 	self.previewIcon.setPixmap(icon.pixmap(QtCore.QSize(32, 32)))

		preview = QtGui.QIcon(request.getFileName())
		label = self.layout.itemAt(0).widget()
		if not isinstance(label, QtWidgets.QLabel):
			label = QtWidgets.QLabel(self)
			label.setPixmap(preview.pixmap(QtCore.QSize(32, 32)))
			self.layout.insertWidget(0, label)
		else:
			label.setPixmap(preview.pixmap(QtCore.QSize(32, 32)))
Beispiel #6
0
	def loadIconFromRequest(self, request: RequestWrapper) -> None:
		preview = QtGui.QIcon(request.getFileName())
		self.previewImage.setPixmap(preview.pixmap(QtCore.QSize(32, 32)))
		self.previewImage.show()
 def loadIconFromRequest(self, request: RequestWrapper) -> None:
     icon = colorizeIcon(request.getFileContents())
     self.setIcon(icon)
Beispiel #8
0
 def loadIconFromRequest(self, request: RequestWrapper) -> None:
     filename = request.getFileName()
     icon = QtGui.QIcon(filename)
     logger.debug("WidgetHandler.loadIconFromRequest: %r, %r", filename,
                  icon)
     self.setIcon(0, icon)