17 pyqtSignal, pyqtSlot, Qt, QFile, QIODevice, QUrl, QProcess, QPoint, |
17 pyqtSignal, pyqtSlot, Qt, QFile, QIODevice, QUrl, QProcess, QPoint, |
18 QCoreApplication |
18 QCoreApplication |
19 ) |
19 ) |
20 from PyQt6.QtWidgets import ( |
20 from PyQt6.QtWidgets import ( |
21 QWidget, QDialogButtonBox, QAbstractButton, QTreeWidgetItem, QDialog, |
21 QWidget, QDialogButtonBox, QAbstractButton, QTreeWidgetItem, QDialog, |
22 QVBoxLayout, QMenu |
22 QVBoxLayout, QMenu, QLabel |
23 ) |
23 ) |
24 from PyQt6.QtNetwork import ( |
24 from PyQt6.QtNetwork import ( |
25 QNetworkAccessManager, QNetworkRequest, QNetworkReply, QNetworkInformation |
25 QNetworkAccessManager, QNetworkRequest, QNetworkReply, QNetworkInformation |
26 ) |
26 ) |
27 |
27 |
87 self.__pluginManager = PluginManager() |
89 self.__pluginManager = PluginManager() |
88 self.__external = True |
90 self.__external = True |
89 else: |
91 else: |
90 self.__pluginManager = pluginManager |
92 self.__pluginManager = pluginManager |
91 self.__external = False |
93 self.__external = False |
|
94 self.__integratedWidget = integrated |
92 |
95 |
93 self.__updateButton = self.buttonBox.addButton( |
96 self.__updateButton = self.buttonBox.addButton( |
94 self.tr("Update"), QDialogButtonBox.ButtonRole.ActionRole) |
97 self.tr("Update"), QDialogButtonBox.ButtonRole.ActionRole) |
95 self.__downloadButton = self.buttonBox.addButton( |
98 self.__downloadButton = self.buttonBox.addButton( |
96 self.tr("Download"), QDialogButtonBox.ButtonRole.ActionRole) |
99 self.tr("Download"), QDialogButtonBox.ButtonRole.ActionRole) |
101 self.__downloadInstallButton.setEnabled(False) |
104 self.__downloadInstallButton.setEnabled(False) |
102 self.__downloadCancelButton = self.buttonBox.addButton( |
105 self.__downloadCancelButton = self.buttonBox.addButton( |
103 self.tr("Cancel"), QDialogButtonBox.ButtonRole.ActionRole) |
106 self.tr("Cancel"), QDialogButtonBox.ButtonRole.ActionRole) |
104 self.__downloadCancelButton.setEnabled(False) |
107 self.__downloadCancelButton.setEnabled(False) |
105 self.__installButton = self.buttonBox.addButton( |
108 self.__installButton = self.buttonBox.addButton( |
|
109 self.tr("Install") if self.__integratedWidget else |
106 self.tr("Close && Install"), |
110 self.tr("Close && Install"), |
107 QDialogButtonBox.ButtonRole.ActionRole) |
111 QDialogButtonBox.ButtonRole.ActionRole) |
108 self.__installButton.setEnabled(False) |
112 self.__installButton.setEnabled(False) |
109 self.__closeButton = self.buttonBox.button( |
113 if not self.__integratedWidget: |
110 QDialogButtonBox.StandardButton.Close) |
114 self.__closeButton = self.buttonBox.addButton( |
111 self.__closeButton.setEnabled(True) |
115 self.tr("Close"), QDialogButtonBox.ButtonRole.RejectRole) |
|
116 self.__closeButton.setEnabled(True) |
112 |
117 |
113 self.repositoryUrlEdit.setText( |
118 self.repositoryUrlEdit.setText( |
114 Preferences.getUI("PluginRepositoryUrl7")) |
119 Preferences.getUI("PluginRepositoryUrl7")) |
115 |
120 |
116 self.repositoryList.headerItem().setText( |
121 if self.__integratedWidget: |
117 self.repositoryList.columnCount(), "") |
122 self.repositoryList.setHeaderHidden(True) |
118 self.repositoryList.header().setSortIndicator( |
123 else: |
119 0, Qt.SortOrder.AscendingOrder) |
124 self.repositoryList.headerItem().setText( |
|
125 self.repositoryList.columnCount(), "") |
|
126 self.repositoryList.header().setSortIndicator( |
|
127 0, Qt.SortOrder.AscendingOrder) |
120 |
128 |
121 self.__pluginContextMenu = QMenu(self) |
129 self.__pluginContextMenu = QMenu(self) |
122 self.__hideAct = self.__pluginContextMenu.addAction( |
130 self.__hideAct = self.__pluginContextMenu.addAction( |
123 self.tr("Hide"), self.__hidePlugin) |
131 self.tr("Hide"), self.__hidePlugin) |
124 self.__hideSelectedAct = self.__pluginContextMenu.addAction( |
132 self.__hideSelectedAct = self.__pluginContextMenu.addAction( |
178 self.__online = online |
186 self.__online = online |
179 |
187 |
180 self.__updateButton.setEnabled(online) |
188 self.__updateButton.setEnabled(online) |
181 self.on_repositoryList_itemSelectionChanged() |
189 self.on_repositoryList_itemSelectionChanged() |
182 |
190 |
183 msg = ( |
191 if not self.__integratedWidget: |
184 self.tr("Internet Reachability Status: Reachable") |
192 msg = ( |
185 if online else |
193 self.tr("Internet Reachability Status: Reachable") |
186 self.tr("Internet Reachability Status: Not Reachable") |
194 if online else |
187 ) |
195 self.tr("Internet Reachability Status: Not Reachable") |
188 self.statusLabel.setText(msg) |
196 ) |
|
197 self.statusLabel.setText(msg) |
189 |
198 |
190 @pyqtSlot(QAbstractButton) |
199 @pyqtSlot(QAbstractButton) |
191 def on_buttonBox_clicked(self, button): |
200 def on_buttonBox_clicked(self, button): |
192 """ |
201 """ |
193 Private slot to handle the click of a button of the button box. |
202 Private slot to handle the click of a button of the button box. |
194 |
203 |
195 @param button reference to the button pressed (QAbstractButton) |
204 @param button reference to the button pressed (QAbstractButton) |
196 """ |
205 """ |
197 if button == self.__updateButton: |
206 if button == self.__updateButton: |
198 self.__updateList() |
207 self.updateList() |
199 elif button == self.__downloadButton: |
208 elif button == self.__downloadButton: |
200 self.__isDownloadInstall = False |
209 self.__isDownloadInstall = False |
201 self.__downloadPlugins() |
210 self.__downloadPlugins() |
202 elif button == self.__downloadInstallButton: |
211 elif button == self.__downloadInstallButton: |
203 self.__isDownloadInstall = True |
212 self.__isDownloadInstall = True |
304 enable = bool(self.__selectedItems()) |
313 enable = bool(self.__selectedItems()) |
305 self.__downloadButton.setEnabled(enable and self.__online) |
314 self.__downloadButton.setEnabled(enable and self.__online) |
306 self.__downloadInstallButton.setEnabled(enable and self.__online) |
315 self.__downloadInstallButton.setEnabled(enable and self.__online) |
307 self.__installButton.setEnabled(enable) |
316 self.__installButton.setEnabled(enable) |
308 |
317 |
309 def __updateList(self): |
318 def updateList(self): |
310 """ |
319 """ |
311 Private slot to download a new list and display the contents. |
320 Public slot to download a new list and display the contents. |
312 """ |
321 """ |
313 url = self.repositoryUrlEdit.text() |
322 url = self.repositoryUrlEdit.text() |
314 self.__downloadFile(url, |
323 self.__downloadFile(url, |
315 self.pluginRepositoryFile, |
324 self.pluginRepositoryFile, |
316 self.__downloadRepositoryFileDone) |
325 self.__downloadRepositoryFileDone) |
635 if self.__unknownItem is None: |
646 if self.__unknownItem is None: |
636 self.__unknownItem = QTreeWidgetItem( |
647 self.__unknownItem = QTreeWidgetItem( |
637 self.repositoryList, [self.tr("Unknown")]) |
648 self.repositoryList, [self.tr("Unknown")]) |
638 self.__unknownItem.setExpanded(True) |
649 self.__unknownItem.setExpanded(True) |
639 parent = self.__unknownItem |
650 parent = self.__unknownItem |
640 itm = QTreeWidgetItem(parent, [name, version, short]) |
651 |
|
652 if self.__integratedWidget: |
|
653 entryFormat = "<b>{0}</b> - Version: <i>{1}</i><br/>{2}" |
|
654 itm = QTreeWidgetItem(parent) |
|
655 itm.setFirstColumnSpanned(True) |
|
656 label = QLabel(entryFormat.format(name, version, short)) |
|
657 self.repositoryList.setItemWidget(itm, 0, label) |
|
658 else: |
|
659 itm = QTreeWidgetItem(parent, [name, version, short]) |
641 |
660 |
642 itm.setData(0, PluginRepositoryWidget.UrlRole, url) |
661 itm.setData(0, PluginRepositoryWidget.UrlRole, url) |
643 itm.setData(0, PluginRepositoryWidget.FilenameRole, filename) |
662 itm.setData(0, PluginRepositoryWidget.FilenameRole, filename) |
644 itm.setData(0, PluginRepositoryWidget.AuthorRole, author) |
663 itm.setData(0, PluginRepositoryWidget.AuthorRole, author) |
645 itm.setData(0, PluginRepositoryWidget.DescrRole, description) |
664 itm.setData(0, PluginRepositoryWidget.DescrRole, description) |
646 |
665 |
|
666 iconColumn = 0 if self.__integratedWidget else 1 |
647 updateStatus = self.__updateStatus(filename, version) |
667 updateStatus = self.__updateStatus(filename, version) |
648 if updateStatus == PluginRepositoryWidget.PluginStatusUpToDate: |
668 if updateStatus == PluginRepositoryWidget.PluginStatusUpToDate: |
649 itm.setIcon(1, UI.PixmapCache.getIcon("empty")) |
669 itm.setIcon(iconColumn, UI.PixmapCache.getIcon("empty")) |
650 itm.setToolTip(1, self.tr("up-to-date")) |
670 itm.setToolTip(iconColumn, self.tr("up-to-date")) |
651 elif updateStatus == PluginRepositoryWidget.PluginStatusNew: |
671 elif updateStatus == PluginRepositoryWidget.PluginStatusNew: |
652 itm.setIcon(1, UI.PixmapCache.getIcon("download")) |
672 itm.setIcon(iconColumn, UI.PixmapCache.getIcon("download")) |
653 itm.setToolTip(1, self.tr("new download available")) |
673 itm.setToolTip(iconColumn, self.tr("new download available")) |
654 self.__newItems += 1 |
674 self.__newItems += 1 |
655 elif updateStatus == PluginRepositoryWidget.PluginStatusLocalUpdate: |
675 elif updateStatus == PluginRepositoryWidget.PluginStatusLocalUpdate: |
656 itm.setIcon(1, UI.PixmapCache.getIcon("updateLocal")) |
676 itm.setIcon(iconColumn, UI.PixmapCache.getIcon("updateLocal")) |
657 itm.setToolTip(1, self.tr("update installable")) |
677 itm.setToolTip(iconColumn, self.tr("update installable")) |
658 self.__updateLocalItems += 1 |
678 self.__updateLocalItems += 1 |
659 elif updateStatus == PluginRepositoryWidget.PluginStatusRemoteUpdate: |
679 elif updateStatus == PluginRepositoryWidget.PluginStatusRemoteUpdate: |
660 itm.setIcon(1, UI.PixmapCache.getIcon("updateRemote")) |
680 itm.setIcon(iconColumn, UI.PixmapCache.getIcon("updateRemote")) |
661 itm.setToolTip(1, self.tr("updated download available")) |
681 itm.setToolTip(iconColumn, self.tr("updated download available")) |
662 self.__updateRemoteItems += 1 |
682 self.__updateRemoteItems += 1 |
663 elif updateStatus == PluginRepositoryWidget.PluginStatusError: |
683 elif updateStatus == PluginRepositoryWidget.PluginStatusError: |
664 itm.setIcon(1, UI.PixmapCache.getIcon("warning")) |
684 itm.setIcon(iconColumn, UI.PixmapCache.getIcon("warning")) |
665 itm.setToolTip(1, self.tr("error determining status")) |
685 itm.setToolTip(iconColumn, self.tr("error determining status")) |
666 |
686 |
667 def __updateStatus(self, filename, version): |
687 def __updateStatus(self, filename, version): |
668 """ |
688 """ |
669 Private method to check the given archive update status. |
689 Private method to check the given archive update status. |
670 |
690 |