src/eric7/WebBrowser/Download/DownloadItem.py

Wed, 13 Jul 2022 14:55:47 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 13 Jul 2022 14:55:47 +0200
branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
permissions
-rw-r--r--

Reformatted the source code using the 'Black' utility.

668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
8881
54e42bc2437a Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8872
diff changeset
3 # Copyright (c) 2010 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a widget controlling a download.
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
8563
3c6547443fb2 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8556
diff changeset
10 import enum
5194
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5033
diff changeset
11 import os
9153
506e35e424d5 Finished replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
12 import pathlib
5194
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5033
diff changeset
13
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
14 from PyQt6.QtCore import pyqtSlot, pyqtSignal, QTime, QUrl, QStandardPaths, QDateTime
8872
ee64dbfefd5f Changed the web browser download items to use a transparent background and adapt some colors to the lightness of the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8856
diff changeset
15 from PyQt6.QtGui import QDesktopServices
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
16 from PyQt6.QtWidgets import QWidget, QStyle, QDialog
8556
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
17 from PyQt6.QtWebEngineCore import QWebEngineDownloadRequest
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
8358
144a6b854f70 Sorted the eric specific extensions into packages named like the corresponding PyQt packages (i.e. EricCore,EricGui and EricWidgets).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8356
diff changeset
19 from EricWidgets import EricFileDialog
8872
ee64dbfefd5f Changed the web browser download items to use a transparent background and adapt some colors to the lightness of the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8856
diff changeset
20 from EricWidgets.EricApplication import ericApp
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 from .Ui_DownloadItem import Ui_DownloadItem
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
6221
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6134
diff changeset
24 from .DownloadUtilities import timeString, dataString, speedString
4769
2b6f7e026cdc Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4768
diff changeset
25 from WebBrowser.WebBrowserWindow import WebBrowserWindow
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 import UI.PixmapCache
4769
2b6f7e026cdc Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4768
diff changeset
28 import Utilities.MimeTypes
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
30
8563
3c6547443fb2 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8556
diff changeset
31 class DownloadState(enum.Enum):
3c6547443fb2 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8556
diff changeset
32 """
3c6547443fb2 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8556
diff changeset
33 Class implementing the various download states.
3c6547443fb2 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8556
diff changeset
34 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
35
8563
3c6547443fb2 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8556
diff changeset
36 Downloading = 0
3c6547443fb2 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8556
diff changeset
37 Successful = 1
3c6547443fb2 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8556
diff changeset
38 Cancelled = 2
3c6547443fb2 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8556
diff changeset
39
3c6547443fb2 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8556
diff changeset
40
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 class DownloadItem(QWidget, Ui_DownloadItem):
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 Class implementing a widget controlling a download.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
44
757
d3daf1d8f058 Fixed the handling of 'javascript' schemes in the web browser and enhanced the download manager a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 679
diff changeset
45 @signal statusChanged() emitted upon a status change of a download
6224
08875555771a Web Browser (NG): some more improvements of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6221
diff changeset
46 @signal downloadFinished(success) emitted when a download finished
757
d3daf1d8f058 Fixed the handling of 'javascript' schemes in the web browser and enhanced the download manager a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 679
diff changeset
47 @signal progress(int, int) emitted to signal the download progress
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
49
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 statusChanged = pyqtSignal()
6224
08875555771a Web Browser (NG): some more improvements of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6221
diff changeset
51 downloadFinished = pyqtSignal(bool)
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 progress = pyqtSignal(int, int)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
53
8556
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
54 def __init__(self, downloadRequest=None, pageUrl=None, parent=None):
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
57
8556
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
58 @param downloadRequest reference to the download object containing the
4769
2b6f7e026cdc Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4768
diff changeset
59 download data.
8556
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
60 @type QWebEngineDownloadRequest
6134
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6091
diff changeset
61 @param pageUrl URL of the calling page
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6091
diff changeset
62 @type QUrl
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6091
diff changeset
63 @param parent reference to the parent widget
cb0985e8da91 Introduced a navigation bar button to open the downloads manager window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6091
diff changeset
64 @type QWidget
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8205
diff changeset
66 super().__init__(parent)
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 self.setupUi(self)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
68
8872
ee64dbfefd5f Changed the web browser download items to use a transparent background and adapt some colors to the lightness of the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8856
diff changeset
69 self.fileIcon.setStyleSheet("background-color: transparent")
ee64dbfefd5f Changed the web browser download items to use a transparent background and adapt some colors to the lightness of the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8856
diff changeset
70 self.datetimeLabel.setStyleSheet("background-color: transparent")
ee64dbfefd5f Changed the web browser download items to use a transparent background and adapt some colors to the lightness of the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8856
diff changeset
71 self.filenameLabel.setStyleSheet("background-color: transparent")
ee64dbfefd5f Changed the web browser download items to use a transparent background and adapt some colors to the lightness of the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8856
diff changeset
72 if ericApp().usesDarkPalette():
ee64dbfefd5f Changed the web browser download items to use a transparent background and adapt some colors to the lightness of the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8856
diff changeset
73 self.infoLabel.setStyleSheet(
ee64dbfefd5f Changed the web browser download items to use a transparent background and adapt some colors to the lightness of the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8856
diff changeset
74 "color: #c0c0c0; background-color: transparent"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
75 ) # light gray
8872
ee64dbfefd5f Changed the web browser download items to use a transparent background and adapt some colors to the lightness of the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8856
diff changeset
76 else:
ee64dbfefd5f Changed the web browser download items to use a transparent background and adapt some colors to the lightness of the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8856
diff changeset
77 self.infoLabel.setStyleSheet(
ee64dbfefd5f Changed the web browser download items to use a transparent background and adapt some colors to the lightness of the palette.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8856
diff changeset
78 "color: #808080; background-color: transparent"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
79 ) # dark gray
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
80
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.progressBar.setMaximum(0)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
82
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
83 self.pauseButton.setIcon(UI.PixmapCache.getIcon("pause"))
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
84 self.stopButton.setIcon(UI.PixmapCache.getIcon("stopLoading"))
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
85 self.openButton.setIcon(UI.PixmapCache.getIcon("open"))
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 self.openButton.setEnabled(False)
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.openButton.setVisible(False)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
88
8563
3c6547443fb2 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8556
diff changeset
89 self.__state = DownloadState.Downloading
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
90
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
91 icon = self.style().standardIcon(QStyle.StandardPixmap.SP_FileIcon)
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 self.fileIcon.setPixmap(icon.pixmap(48, 48))
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
93
8556
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
94 self.__downloadRequest = downloadRequest
6286
2c8a751d6137 DownloadManager: fixed an issue getting the main window
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6224
diff changeset
95 if pageUrl is None:
2c8a751d6137 DownloadManager: fixed an issue getting the main window
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6224
diff changeset
96 self.__pageUrl = QUrl()
2c8a751d6137 DownloadManager: fixed an issue getting the main window
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6224
diff changeset
97 else:
2c8a751d6137 DownloadManager: fixed an issue getting the main window
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6224
diff changeset
98 self.__pageUrl = pageUrl
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 self.__bytesReceived = 0
679
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
100 self.__bytesTotal = -1
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.__downloadTime = QTime()
670
bb833c4bcf28 Some fixes to the download manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 668
diff changeset
102 self.__fileName = ""
1094
743900906d8e Added a puse button to the web browser download.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 978
diff changeset
103 self.__originalFileName = ""
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 self.__finishedDownloading = False
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 self.__gettingFileName = False
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 self.__canceledFileSelect = False
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 self.__autoOpen = False
5928
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
108 self.__downloadedDateTime = QDateTime()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
109
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 self.__initialize()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
111
4769
2b6f7e026cdc Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4768
diff changeset
112 def __initialize(self):
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 """
4769
2b6f7e026cdc Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4768
diff changeset
114 Private method to initialize the widget.
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 """
8556
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
116 if self.__downloadRequest is None:
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
118
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 self.__finishedDownloading = False
679
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
120 self.__bytesReceived = 0
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
121 self.__bytesTotal = -1
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
122
670
bb833c4bcf28 Some fixes to the download manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 668
diff changeset
123 # start timer for the download estimation
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
124 self.__downloadTime = QTime.currentTime()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
125
4769
2b6f7e026cdc Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4768
diff changeset
126 # attach to the download item object
8556
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
127 self.__url = self.__downloadRequest.url()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
128 self.__downloadRequest.receivedBytesChanged.connect(self.__downloadProgress)
8556
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
129 self.__downloadRequest.isFinishedChanged.connect(self.__finished)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
130
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 # reset info
5928
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
132 self.datetimeLabel.clear()
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
133 self.datetimeLabel.hide()
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 self.infoLabel.clear()
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 self.progressBar.setValue(0)
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
136 if (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
137 self.__downloadRequest.state()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
138 == QWebEngineDownloadRequest.DownloadState.DownloadRequested
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
139 ):
5530
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
140 self.__getFileName()
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
141 if not self.__fileName:
8556
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
142 self.__downloadRequest.cancel()
5530
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
143 else:
8556
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
144 self.__downloadRequest.setDownloadFileName(self.__fileName)
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
145 self.__downloadRequest.accept()
4769
2b6f7e026cdc Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4768
diff changeset
146 else:
8556
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
147 fileName = self.__downloadRequest.downloadFileName()
5530
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
148 self.__setFileName(fileName)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
149
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 def __getFileName(self):
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 """
2954
bf0215fe12d1 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2523
diff changeset
152 Private method to get the file name to save to from the user.
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 if self.__gettingFileName:
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
156
8556
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
157 savePage = self.__downloadRequest.isSavePageDownload()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
158
5194
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5033
diff changeset
159 documentLocation = QStandardPaths.writableLocation(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
160 QStandardPaths.StandardLocation.DocumentsLocation
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
161 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
162 downloadDirectory = WebBrowserWindow.downloadManager().downloadDirectory()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
163
670
bb833c4bcf28 Some fixes to the download manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 668
diff changeset
164 if self.__fileName:
bb833c4bcf28 Some fixes to the download manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 668
diff changeset
165 fileName = self.__fileName
1094
743900906d8e Added a puse button to the web browser download.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 978
diff changeset
166 originalFileName = self.__originalFileName
670
bb833c4bcf28 Some fixes to the download manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 668
diff changeset
167 self.__toDownload = True
bb833c4bcf28 Some fixes to the download manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 668
diff changeset
168 ask = False
bb833c4bcf28 Some fixes to the download manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 668
diff changeset
169 else:
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
170 defaultFileName, originalFileName = self.__saveFileName(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
171 documentLocation if savePage else downloadDirectory
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
172 )
670
bb833c4bcf28 Some fixes to the download manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 668
diff changeset
173 fileName = defaultFileName
1094
743900906d8e Added a puse button to the web browser download.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 978
diff changeset
174 self.__originalFileName = originalFileName
670
bb833c4bcf28 Some fixes to the download manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 668
diff changeset
175 ask = True
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 self.__autoOpen = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
177
5194
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5033
diff changeset
178 if not savePage:
5033
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
179 from .DownloadAskActionDialog import DownloadAskActionDialog
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
180
8556
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
181 url = self.__downloadRequest.url()
5033
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
182 mimetype = Utilities.MimeTypes.mimeType(originalFileName)
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
183 dlg = DownloadAskActionDialog(
9153
506e35e424d5 Finished replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
184 pathlib.Path(originalFileName).name,
5033
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
185 mimetype,
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
186 "{0}://{1}".format(url.scheme(), url.authority()),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
187 self,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
188 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
189
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
190 if dlg.exec() == QDialog.DialogCode.Rejected or dlg.getAction() == "cancel":
5033
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
191 self.progressBar.setVisible(False)
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
192 self.on_stopButton_clicked()
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
193 self.filenameLabel.setText(
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
194 self.tr("Download canceled: {0}").format(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
195 pathlib.Path(defaultFileName).name
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
196 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
197 )
5033
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
198 self.__canceledFileSelect = True
5928
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
199 self.__setDateTime()
5033
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
200 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
201
5033
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
202 if dlg.getAction() == "scan":
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
203 self.__mainWindow.requestVirusTotalScan(url)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
204
5033
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
205 self.progressBar.setVisible(False)
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
206 self.on_stopButton_clicked()
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
207 self.filenameLabel.setText(
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
208 self.tr("VirusTotal scan scheduled: {0}").format(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
209 pathlib.Path(defaultFileName).name
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
210 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
211 )
5033
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
212 self.__canceledFileSelect = True
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
213 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
214
5033
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4917
diff changeset
215 self.__autoOpen = dlg.getAction() == "open"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
216
5194
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5033
diff changeset
217 tempLocation = QStandardPaths.writableLocation(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
218 QStandardPaths.StandardLocation.TempLocation
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
219 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
220 fileName = tempLocation + "/" + pathlib.Path(fileName).stem
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
221
5194
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5033
diff changeset
222 if ask and not self.__autoOpen:
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5033
diff changeset
223 self.__gettingFileName = True
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
224 fileName = EricFileDialog.getSaveFileName(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
225 None, self.tr("Save File"), defaultFileName, ""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
226 )
5194
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5033
diff changeset
227 self.__gettingFileName = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
228
5194
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5033
diff changeset
229 if not fileName:
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5033
diff changeset
230 self.progressBar.setVisible(False)
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5033
diff changeset
231 self.on_stopButton_clicked()
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5033
diff changeset
232 self.filenameLabel.setText(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
233 self.tr("Download canceled: {0}").format(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
234 pathlib.Path(defaultFileName).name
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
235 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
236 )
5194
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5033
diff changeset
237 self.__canceledFileSelect = True
5928
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
238 self.__setDateTime()
5194
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5033
diff changeset
239 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
240
5530
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
241 self.__setFileName(fileName)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
242
5530
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
243 def __setFileName(self, fileName):
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
244 """
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
245 Private method to set the file name to save the download into.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
246
5530
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
247 @param fileName name of the file to save into
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
248 @type str
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
249 """
9153
506e35e424d5 Finished replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
250 fpath = pathlib.Path(fileName)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
251 WebBrowserWindow.downloadManager().setDownloadDirectory(fpath.parent.resolve())
9153
506e35e424d5 Finished replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
252 self.filenameLabel.setText(fpath.name)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
253
9153
506e35e424d5 Finished replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
254 self.__fileName = str(fpath)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
255
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 # check file path for saving
9153
506e35e424d5 Finished replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
257 saveDirPath = pathlib.Path(self.__fileName).parent()
506e35e424d5 Finished replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
258 if not saveDirPath.exists():
506e35e424d5 Finished replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
259 saveDirPath.mkdir(parents=True)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
260
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 def __saveFileName(self, directory):
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 Private method to calculate a name for the file to download.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
264
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 @param directory name of the directory to store the file into (string)
1094
743900906d8e Added a puse button to the web browser download.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 978
diff changeset
266 @return proposed filename and original filename (string, string)
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 """
9153
506e35e424d5 Finished replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
268 fpath = pathlib.Path(self.__downloadRequest.downloadFileName())
506e35e424d5 Finished replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
269 origName = fpath.name
506e35e424d5 Finished replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
270 name = os.path.join(directory, origName)
1094
743900906d8e Added a puse button to the web browser download.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 978
diff changeset
271 return name, origName
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
272
6085
7e48a0d98cce Added the capability to pause/resume download (Qt 5.10.0/PyQt 5.10.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
273 @pyqtSlot(bool)
7e48a0d98cce Added the capability to pause/resume download (Qt 5.10.0/PyQt 5.10.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
274 def on_pauseButton_clicked(self, checked):
7e48a0d98cce Added the capability to pause/resume download (Qt 5.10.0/PyQt 5.10.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
275 """
7e48a0d98cce Added the capability to pause/resume download (Qt 5.10.0/PyQt 5.10.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
276 Private slot to pause the download.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
277
6085
7e48a0d98cce Added the capability to pause/resume download (Qt 5.10.0/PyQt 5.10.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
278 @param checked flag indicating the state of the button
7e48a0d98cce Added the capability to pause/resume download (Qt 5.10.0/PyQt 5.10.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
279 @type bool
7e48a0d98cce Added the capability to pause/resume download (Qt 5.10.0/PyQt 5.10.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
280 """
7e48a0d98cce Added the capability to pause/resume download (Qt 5.10.0/PyQt 5.10.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
281 if checked:
8556
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
282 self.__downloadRequest.pause()
6085
7e48a0d98cce Added the capability to pause/resume download (Qt 5.10.0/PyQt 5.10.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
283 else:
8556
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
284 self.__downloadRequest.resume()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
285
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 @pyqtSlot()
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 def on_stopButton_clicked(self):
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 Private slot to stop the download.
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 """
679
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
291 self.cancelDownload()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
292
679
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
293 def cancelDownload(self):
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
294 """
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
295 Public slot to stop the download.
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
296 """
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 self.setUpdatesEnabled(False)
4769
2b6f7e026cdc Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4768
diff changeset
298 self.stopButton.setEnabled(False)
2b6f7e026cdc Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4768
diff changeset
299 self.stopButton.setVisible(False)
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 self.openButton.setEnabled(False)
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 self.openButton.setVisible(False)
6085
7e48a0d98cce Added the capability to pause/resume download (Qt 5.10.0/PyQt 5.10.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
302 self.pauseButton.setEnabled(False)
7e48a0d98cce Added the capability to pause/resume download (Qt 5.10.0/PyQt 5.10.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
303 self.pauseButton.setVisible(False)
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 self.setUpdatesEnabled(True)
8563
3c6547443fb2 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8556
diff changeset
305 self.__state = DownloadState.Cancelled
8556
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
306 self.__downloadRequest.cancel()
5928
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
307 self.__setDateTime()
6224
08875555771a Web Browser (NG): some more improvements of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6221
diff changeset
308 self.downloadFinished.emit(False)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
309
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 @pyqtSlot()
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 def on_openButton_clicked(self):
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 Private slot to open the downloaded file.
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 """
679
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
315 self.openFile()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
316
679
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
317 def openFile(self):
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
318 """
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
319 Public slot to open the downloaded file.
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
320 """
9153
506e35e424d5 Finished replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
321 url = QUrl.fromLocalFile(pathlib.Path(self.__fileName).resolve())
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 QDesktopServices.openUrl(url)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
323
679
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
324 def openFolder(self):
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
325 """
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
326 Public slot to open the folder containing the downloaded file.
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
327 """
9153
506e35e424d5 Finished replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
328 url = QUrl.fromLocalFile(pathlib.Path(self.__fileName).resolve())
679
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
329 QDesktopServices.openUrl(url)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
330
8556
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
331 @pyqtSlot()
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
332 def __downloadProgress(self):
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 """
8556
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
334 Private slot to show the download progress.
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 """
8556
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
336 self.__bytesReceived = self.__downloadRequest.receivedBytes()
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
337 self.__bytesTotal = self.__downloadRequest.totalBytes()
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 currentValue = 0
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 totalValue = 0
8556
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
340 if self.__bytesTotal > 0:
8856
df77fbfc150f Corrected some Python 3.10 precision related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8563
diff changeset
341 currentValue = self.__bytesReceived * 100 // self.__bytesTotal
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 totalValue = 100
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 self.progressBar.setValue(currentValue)
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344 self.progressBar.setMaximum(totalValue)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
345
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 self.progress.emit(currentValue, totalValue)
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 self.__updateInfoLabel()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
348
6221
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6134
diff changeset
349 def downloadProgress(self):
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6134
diff changeset
350 """
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6134
diff changeset
351 Public method to get the download progress.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
352
6221
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6134
diff changeset
353 @return current download progress
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6134
diff changeset
354 @rtype int
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6134
diff changeset
355 """
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6134
diff changeset
356 return self.progressBar.value()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
357
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 def bytesTotal(self):
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 Public method to get the total number of bytes of the download.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
361
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 @return total number of bytes (integer)
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 """
679
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
364 if self.__bytesTotal == -1:
8556
766e1566cb74 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
365 self.__bytesTotal = self.__downloadRequest.totalBytes()
679
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
366 return self.__bytesTotal
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
367
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 def bytesReceived(self):
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 Public method to get the number of bytes received.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
371
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 @return number of bytes received (integer)
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 return self.__bytesReceived
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
375
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 def remainingTime(self):
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 Public method to get an estimation for the remaining time.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
379
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 @return estimation for the remaining time (float)
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 if not self.downloading():
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 return -1.0
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
384
679
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
385 if self.bytesTotal() == -1:
673
1c1f3a125e68 Fixed a few issues with the download manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 670
diff changeset
386 return -1.0
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
387
4443
f7f61a66dc38 A little fix in the download item for a situation causing a division by zero.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4326
diff changeset
388 cSpeed = self.currentSpeed()
8260
2161475d9639 Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8227
diff changeset
389 timeRemaining = (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
390 (self.bytesTotal() - self.bytesReceived()) / cSpeed if cSpeed != 0 else 1
8260
2161475d9639 Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8227
diff changeset
391 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
392
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 # ETA should never be 0
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 if timeRemaining == 0:
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 timeRemaining = 1
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
396
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 return timeRemaining
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
398
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 def currentSpeed(self):
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 Public method to get an estimation for the download speed.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
402
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 @return estimation for the download speed (float)
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 if not self.downloading():
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 return -1.0
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
407
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
408 return (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
409 self.__bytesReceived
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
410 * 1000.0
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
411 / self.__downloadTime.msecsTo(QTime.currentTime())
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
412 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
413
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414 def __updateInfoLabel(self):
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 Private method to update the info label.
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 """
673
1c1f3a125e68 Fixed a few issues with the download manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 670
diff changeset
418 bytesTotal = self.bytesTotal()
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 running = not self.downloadedSuccessfully()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
420
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 speed = self.currentSpeed()
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 timeRemaining = self.remainingTime()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
423
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 info = ""
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425 if running:
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 remaining = ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
427
679
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
428 if bytesTotal > 0:
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 remaining = timeString(timeRemaining)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
430
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
431 info = self.tr("{0} of {1} ({2}/sec) {3}").format(
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
432 dataString(self.__bytesReceived),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
433 bytesTotal == -1 and self.tr("?") or dataString(bytesTotal),
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
434 speedString(speed),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
435 remaining,
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
436 )
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 else:
8205
4a0f1f896341 Applied some code simplifications suggested by the new Simplify checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
438 if bytesTotal in (self.__bytesReceived, -1):
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
439 info = self.tr("{0} downloaded").format(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
440 dataString(self.__bytesReceived)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
441 )
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442 else:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
443 info = self.tr("{0} of {1} - Stopped").format(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
444 dataString(self.__bytesReceived), dataString(bytesTotal)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
445 )
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 self.infoLabel.setText(info)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
447
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448 def downloading(self):
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 Public method to determine, if a download is in progress.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
451
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452 @return flag indicating a download is in progress (boolean)
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453 """
8563
3c6547443fb2 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8556
diff changeset
454 return self.__state == DownloadState.Downloading
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
455
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 def downloadedSuccessfully(self):
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 Public method to check for a successful download.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
459
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 @return flag indicating a successful download (boolean)
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 """
8563
3c6547443fb2 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8556
diff changeset
462 return self.__state == DownloadState.Successful
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
463
679
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
464 def downloadCanceled(self):
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
465 """
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
466 Public method to check, if the download was cancelled.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
467
679
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
468 @return flag indicating a canceled download (boolean)
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
469 """
8563
3c6547443fb2 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8556
diff changeset
470 return self.__state == DownloadState.Cancelled
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
471
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472 def __finished(self):
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474 Private slot to handle the download finished.
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 self.__finishedDownloading = True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
477
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
478 noError = (
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
479 self.__downloadRequest.state()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
480 == QWebEngineDownloadRequest.DownloadState.DownloadCompleted
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
481 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
482
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483 self.progressBar.setVisible(False)
6085
7e48a0d98cce Added the capability to pause/resume download (Qt 5.10.0/PyQt 5.10.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
484 self.pauseButton.setEnabled(False)
7e48a0d98cce Added the capability to pause/resume download (Qt 5.10.0/PyQt 5.10.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
485 self.pauseButton.setVisible(False)
4769
2b6f7e026cdc Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4768
diff changeset
486 self.stopButton.setEnabled(False)
2b6f7e026cdc Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4768
diff changeset
487 self.stopButton.setVisible(False)
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
488 self.openButton.setEnabled(noError)
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489 self.openButton.setVisible(noError)
8563
3c6547443fb2 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8556
diff changeset
490 self.__state = DownloadState.Successful
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491 self.__updateInfoLabel()
5928
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
492 self.__setDateTime()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
493
5928
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
494 self.__adjustSize()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
495
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496 self.statusChanged.emit()
6224
08875555771a Web Browser (NG): some more improvements of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6221
diff changeset
497 self.downloadFinished.emit(True)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
498
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 if self.__autoOpen:
6091
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
500 self.openFile()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
501
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 def canceledFileSelect(self):
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504 Public method to check, if the user canceled the file selection.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
505
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
506 @return flag indicating cancellation (boolean)
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508 return self.__canceledFileSelect
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
509
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
510 def setIcon(self, icon):
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
511 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
512 Public method to set the download icon.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
513
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
514 @param icon reference to the icon to be set (QIcon)
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
515 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
516 self.fileIcon.setPixmap(icon.pixmap(48, 48))
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
517
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
518 def fileName(self):
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
519 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
520 Public method to get the name of the output file.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
521
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
522 @return name of the output file (string)
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523 """
670
bb833c4bcf28 Some fixes to the download manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 668
diff changeset
524 return self.__fileName
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
525
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
526 def absoluteFilePath(self):
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
527 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
528 Public method to get the absolute path of the output file.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
529
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530 @return absolute path of the output file (string)
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
531 """
9153
506e35e424d5 Finished replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
532 return pathlib.Path(self.__fileName).resolve()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
533
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534 def getData(self):
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
535 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
536 Public method to get the relevant download data.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
537
6091
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
538 @return dictionary containing the URL, save location, done flag,
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
539 the URL of the related web page and the date and time of the
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
540 download
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
541 @rtype dict of {"URL": QUrl, "Location": str, "Done": bool,
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
542 "PageURL": QUrl, "Downloaded": QDateTime}
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543 """
6091
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
544 return {
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
545 "URL": self.__url,
9153
506e35e424d5 Finished replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
546 "Location": self.__fileName,
6091
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
547 "Done": self.downloadedSuccessfully(),
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
548 "PageURL": self.__pageUrl,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
549 "Downloaded": self.__downloadedDateTime,
6091
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
550 }
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
551
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
552 def setData(self, data):
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
553 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554 Public method to set the relevant download data.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
555
6091
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
556 @param data dictionary containing the URL, save location, done flag,
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
557 the URL of the related web page and the date and time of the
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
558 download
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
559 @type dict of {"URL": QUrl, "Location": str, "Done": bool,
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
560 "PageURL": QUrl, "Downloaded": QDateTime}
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
561 """
6091
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
562 self.__url = data["URL"]
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
563 self.__fileName = data["Location"]
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
564 self.__pageUrl = data["PageURL"]
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
565
9153
506e35e424d5 Finished replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
566 self.filenameLabel.setText(pathlib.Path(self.__fileName).name)
670
bb833c4bcf28 Some fixes to the download manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 668
diff changeset
567 self.infoLabel.setText(self.__fileName)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
568
6091
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
569 try:
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
570 self.__setDateTime(data["Downloaded"])
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
571 except KeyError:
5928
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
572 self.__setDateTime(QDateTime())
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
573
6085
7e48a0d98cce Added the capability to pause/resume download (Qt 5.10.0/PyQt 5.10.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
574 self.pauseButton.setEnabled(False)
7e48a0d98cce Added the capability to pause/resume download (Qt 5.10.0/PyQt 5.10.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
575 self.pauseButton.setVisible(False)
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
576 self.stopButton.setEnabled(False)
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
577 self.stopButton.setVisible(False)
6091
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
578 self.openButton.setEnabled(data["Done"])
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
579 self.openButton.setVisible(data["Done"])
7b989321d74c Improved maintainability of the DownloadItem code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6090
diff changeset
580 if data["Done"]:
8563
3c6547443fb2 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8556
diff changeset
581 self.__state = DownloadState.Successful
2055
9165261f3e06 Some optimisations for DownloadItem and disabled the stop and pause buttons for FTP downloads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
582 else:
8563
3c6547443fb2 Next batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8556
diff changeset
583 self.__state = DownloadState.Cancelled
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
584 self.progressBar.setVisible(False)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
585
5928
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
586 self.__adjustSize()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
587
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
588 def getInfoData(self):
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
589 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
590 Public method to get the text of the info label.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
591
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
592 @return text of the info label (string)
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
593 """
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
594 return self.infoLabel.text()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
595
679
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
596 def getPageUrl(self):
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
597 """
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
598 Public method to get the URL of the download page.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
599
679
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
600 @return URL of the download page (QUrl)
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
601 """
b427350a9d97 Added a context menu to the download manager of the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 673
diff changeset
602 return self.__pageUrl
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
603
5928
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
604 def __adjustSize(self):
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
605 """
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
606 Private method to adjust the size of the download item.
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
607 """
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
608 self.ensurePolished()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
609
5928
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
610 msh = self.minimumSizeHint()
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
611 self.resize(max(self.width(), msh.width()), msh.height())
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
612
5928
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
613 def __setDateTime(self, dateTime=None):
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
614 """
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
615 Private method to set the download date and time.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
616
5928
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
617 @param dateTime date and time to be set
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
618 @type QDateTime
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
619 """
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
620 if dateTime is None:
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
621 self.__downloadedDateTime = QDateTime.currentDateTime()
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
622 else:
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
623 self.__downloadedDateTime = dateTime
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
624 if self.__downloadedDateTime.isValid():
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
625 labelText = self.__downloadedDateTime.toString("yyyy-MM-dd hh:mm")
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
626 self.datetimeLabel.setText(labelText)
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
627 self.datetimeLabel.show()
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
628 else:
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
629 self.datetimeLabel.clear()
a3809f75ca07 Changed the logic of the two web browsers in order to put new downloads at the top of the list of downloads and add the download date and time to the shown info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
630 self.datetimeLabel.hide()

eric ide

mercurial