eric6/WebBrowser/Network/ProtocolHandlerManagerDialog.py

changeset 6942
2602857055c5
parent 6695
0a51887c13cd
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to manage registered protocol handlers.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtCore import pyqtSlot, Qt
13 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem
14
15 from .Ui_ProtocolHandlerManagerDialog import Ui_ProtocolHandlerManagerDialog
16
17
18 class ProtocolHandlerManagerDialog(QDialog, Ui_ProtocolHandlerManagerDialog):
19 """
20 Class implementing a dialog to manage registered protocol handlers.
21 """
22 def __init__(self, manager, parent=None):
23 """
24 Constructor
25
26 @param manager reference to the protocol handlers manager object
27 @type ProtocolHandlerManager
28 @param parent reference to the parent widget
29 @type QWidget
30 """
31 super(ProtocolHandlerManagerDialog, self).__init__(parent)
32 self.setupUi(self)
33 self.setAttribute(Qt.WA_DeleteOnClose)
34
35 self.__manager = manager
36 handlers = self.__manager.protocolHandlers()
37 for scheme in sorted(handlers.keys()):
38 QTreeWidgetItem(self.protocolHandlersList,
39 [scheme, handlers[scheme].toString()])
40
41 self.on_protocolHandlersList_itemSelectionChanged()
42
43 @pyqtSlot()
44 def on_protocolHandlersList_itemSelectionChanged(self):
45 """
46 Private slot handling a change of the selection.
47 """
48 self.deleteButton.setEnabled(
49 len(self.protocolHandlersList.selectedItems()) == 1)
50
51 @pyqtSlot()
52 def on_deleteButton_clicked(self):
53 """
54 Private slot to delete the selected protocol handler.
55 """
56 itm = self.protocolHandlersList.selectedItems()[0]
57 self.__manager.removeProtocolHandler(itm.text(0))
58
59 self.protocolHandlersList.takeTopLevelItem(
60 self.protocolHandlersList.indexOfTopLevelItem(itm))
61 del itm

eric ide

mercurial