52 |
52 |
53 @param parent reference to the parent widget (QWidget) |
53 @param parent reference to the parent widget (QWidget) |
54 """ |
54 """ |
55 super(DownloadManager, self).__init__(parent) |
55 super(DownloadManager, self).__init__(parent) |
56 self.setupUi(self) |
56 self.setupUi(self) |
57 self.setWindowFlags(Qt.Window) |
57 self.setWindowFlags(Qt.WindowType.Window) |
58 |
58 |
59 self.__winTaskbarButton = None |
59 self.__winTaskbarButton = None |
60 |
60 |
61 self.__saveTimer = AutoSaver(self, self.save) |
61 self.__saveTimer = AutoSaver(self, self.save) |
62 |
62 |
76 self.downloadsView.verticalHeader().hide() |
76 self.downloadsView.verticalHeader().hide() |
77 self.downloadsView.horizontalHeader().hide() |
77 self.downloadsView.horizontalHeader().hide() |
78 self.downloadsView.setAlternatingRowColors(True) |
78 self.downloadsView.setAlternatingRowColors(True) |
79 self.downloadsView.horizontalHeader().setStretchLastSection(True) |
79 self.downloadsView.horizontalHeader().setStretchLastSection(True) |
80 self.downloadsView.setModel(self.__model) |
80 self.downloadsView.setModel(self.__model) |
81 self.downloadsView.setContextMenuPolicy(Qt.CustomContextMenu) |
81 self.downloadsView.setContextMenuPolicy( |
|
82 Qt.ContextMenuPolicy.CustomContextMenu) |
82 self.downloadsView.customContextMenuRequested.connect( |
83 self.downloadsView.customContextMenuRequested.connect( |
83 self.__customContextMenuRequested) |
84 self.__customContextMenuRequested) |
84 |
85 |
85 self.__clearShortcut = QShortcut(QKeySequence("Ctrl+L"), self) |
86 self.__clearShortcut = QShortcut(QKeySequence("Ctrl+L"), self) |
86 self.__clearShortcut.activated.connect(self.on_cleanupButton_clicked) |
87 self.__clearShortcut.activated.connect(self.on_cleanupButton_clicked) |
316 else: |
317 else: |
317 self.__downloads.insert(0, itm) |
318 self.__downloads.insert(0, itm) |
318 self.__model.endInsertRows() |
319 self.__model.endInsertRows() |
319 |
320 |
320 self.downloadsView.setIndexWidget(self.__model.index(row, 0), itm) |
321 self.downloadsView.setIndexWidget(self.__model.index(row, 0), itm) |
321 icon = self.style().standardIcon(QStyle.SP_FileIcon) |
322 icon = self.style().standardIcon(QStyle.StandardPixmap.SP_FileIcon) |
322 itm.setIcon(icon) |
323 itm.setIcon(icon) |
323 self.downloadsView.setRowHeight( |
324 self.downloadsView.setRowHeight( |
324 row, itm.sizeHint().height() * self.__rowHeightMultiplier) |
325 row, itm.sizeHint().height() * self.__rowHeightMultiplier) |
325 # just in case the download finished before the constructor returned |
326 # just in case the download finished before the constructor returned |
326 self.__updateRow(itm) |
327 self.__updateRow(itm) |
343 if self.__iconProvider is None: |
344 if self.__iconProvider is None: |
344 self.__iconProvider = QFileIconProvider() |
345 self.__iconProvider = QFileIconProvider() |
345 |
346 |
346 icon = self.__iconProvider.icon(QFileInfo(itm.fileName())) |
347 icon = self.__iconProvider.icon(QFileInfo(itm.fileName())) |
347 if icon.isNull(): |
348 if icon.isNull(): |
348 icon = self.style().standardIcon(QStyle.SP_FileIcon) |
349 icon = self.style().standardIcon(QStyle.StandardPixmap.SP_FileIcon) |
349 itm.setIcon(icon) |
350 itm.setIcon(icon) |
350 |
351 |
351 self.downloadsView.setRowHeight( |
352 self.downloadsView.setRowHeight( |
352 row, |
353 row, |
353 itm.minimumSizeHint().height() * self.__rowHeightMultiplier) |
354 itm.minimumSizeHint().height() * self.__rowHeightMultiplier) |
701 """ |
702 """ |
702 Private method to copy the download link to the clipboard. |
703 Private method to copy the download link to the clipboard. |
703 """ |
704 """ |
704 itm = self.__currentItem() |
705 itm = self.__currentItem() |
705 if itm is not None: |
706 if itm is not None: |
706 url = itm.getPageUrl().toDisplayString(QUrl.FullyDecoded) |
707 url = itm.getPageUrl().toDisplayString( |
|
708 QUrl.ComponentFormattingOption.FullyDecoded) |
707 QApplication.clipboard().setText(url) |
709 QApplication.clipboard().setText(url) |
708 |
710 |
709 def __contextMenuSelectAll(self): |
711 def __contextMenuSelectAll(self): |
710 """ |
712 """ |
711 Private method to select all downloads. |
713 Private method to select all downloads. |