Blame SOURCES/firewalld-0.4.4.3-qt4_applet.patch

843f86
diff -up firewalld-0.4.4.3/src/firewall-applet.qt4_applet firewalld-0.4.4.3/src/firewall-applet
843f86
--- firewalld-0.4.4.3/src/firewall-applet.qt4_applet	2017-01-26 13:07:25.000000000 +0100
843f86
+++ firewalld-0.4.4.3/src/firewall-applet	2017-02-08 19:13:03.196185899 +0100
843f86
@@ -21,14 +21,14 @@
843f86
 #
843f86
 
843f86
 import sys
843f86
-from PyQt5 import QtGui, QtCore, QtWidgets
843f86
+from PyQt4 import QtGui, QtCore
843f86
 
843f86
 import gi
843f86
 gi.require_version('Notify', '0.7')
843f86
 from gi.repository import Notify
843f86
 
843f86
 import os
843f86
-from dbus.mainloop.pyqt5 import DBusQtMainLoop
843f86
+from dbus.mainloop.qt import DBusQtMainLoop
843f86
 import functools
843f86
 
843f86
 from firewall.config import *
843f86
@@ -74,20 +74,21 @@ def escape(text):
843f86
     return text
843f86
 
843f86
 def fromUTF8(text):
843f86
-    if PY2 and QtCore.QT_VERSION < 0x050000:
843f86
+    if PY2:
843f86
         return QtCore.QString.fromUtf8(text)
843f86
-    return text
843f86
+    else:
843f86
+        return text        
843f86
 
843f86
 # ZoneInterfaceEditor #########################################################
843f86
 
843f86
-class ZoneInterfaceEditor(QtWidgets.QDialog):
843f86
+class ZoneInterfaceEditor(QtGui.QDialog):
843f86
     def __init__(self, fw, interface, zone):
843f86
         self.fw = fw
843f86
         self.interface = interface
843f86
         self.zone = None
843f86
         self.title = _("Select zone for interface '%s'") % self.interface
843f86
 
843f86
-        QtWidgets.QDialog.__init__(self)
843f86
+        QtGui.QDialog.__init__(self)
843f86
         self.create_ui(zone)
843f86
 
843f86
     def create_ui(self, zone):
843f86
@@ -96,19 +97,19 @@ class ZoneInterfaceEditor(QtWidgets.QDia
843f86
 
843f86
         self.resize(100, 50)
843f86
 
843f86
-        vbox = QtWidgets.QVBoxLayout()
843f86
+        vbox = QtGui.QVBoxLayout()
843f86
         vbox.setSpacing(6)
843f86
 
843f86
-        label = QtWidgets.QLabel(fromUTF8(escape(self.title)))
843f86
+        label = QtGui.QLabel(fromUTF8(escape(self.title)))
843f86
         vbox.addWidget(label)
843f86
 
843f86
-        self.combo = QtWidgets.QComboBox()
843f86
+        self.combo = QtGui.QComboBox()
843f86
         self.fill_zone_combo()
843f86
         vbox.addWidget(self.combo)
843f86
 
843f86
-        buttonBox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok
843f86
-                                           | QtWidgets.QDialogButtonBox.Cancel)
843f86
-        self.ok_button = buttonBox.button(QtWidgets.QDialogButtonBox.Ok)
843f86
+        buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok
843f86
+                                           | QtGui.QDialogButtonBox.Cancel)
843f86
+        self.ok_button = buttonBox.button(QtGui.QDialogButtonBox.Ok)
843f86
         buttonBox.accepted.connect(self.ok)
843f86
         buttonBox.rejected.connect(self.hide)
843f86
         vbox.addWidget(buttonBox)
843f86
@@ -160,7 +161,7 @@ class ZoneConnectionEditor(ZoneInterface
843f86
         self.zone = None
843f86
         self.title = _("Select zone for connection '%s'") % self.connection
843f86
 
843f86
-        QtWidgets.QDialog.__init__(self)
843f86
+        QtGui.QDialog.__init__(self)
843f86
         self.create_ui(zone)
843f86
 
843f86
     def ok(self):
843f86
@@ -169,7 +170,7 @@ class ZoneConnectionEditor(ZoneInterface
843f86
             nm_set_zone_of_connection(self.get_zone(), self.connection)
843f86
         except Exception as msg:
843f86
             text = _("Failed to set zone {zone} for connection {connection}")
843f86
-            QtWidgets.QMessageBox.warning(None, fromUTF8(escape(self.title)),
843f86
+            QtGui.QMessageBox.warning(None, fromUTF8(escape(self.title)),
843f86
                                       escape(text.format(
843f86
                                           zone=self.get_zone(),
843f86
                                           connection=self.connection)))
843f86
@@ -184,7 +185,7 @@ class ZoneSourceEditor(ZoneInterfaceEdit
843f86
         self.zone = None
843f86
         self.title = _("Select zone for source '%s'") % self.source
843f86
 
843f86
-        QtWidgets.QDialog.__init__(self)
843f86
+        QtGui.QDialog.__init__(self)
843f86
         self.create_ui(zone)
843f86
 
843f86
     def ok(self):
843f86
@@ -193,7 +194,7 @@ class ZoneSourceEditor(ZoneInterfaceEdit
843f86
 
843f86
 # ShieldsEditor #########################################################
843f86
 
843f86
-class ShieldsEditor(QtWidgets.QDialog):
843f86
+class ShieldsEditor(QtGui.QDialog):
843f86
     def __init__(self, fw, settings, shields_up, shields_down):
843f86
         self.fw = fw
843f86
         self.settings = settings
843f86
@@ -201,63 +202,63 @@ class ShieldsEditor(QtWidgets.QDialog):
843f86
         self.shields_down = shields_down
843f86
         self.title = _("Configure Shields Up/Down Zones")
843f86
 
843f86
-        QtWidgets.QDialog.__init__(self)
843f86
+        QtGui.QDialog.__init__(self)
843f86
         self.create_ui()
843f86
 
843f86
     def create_ui(self):
843f86
         self.setWindowTitle(fromUTF8(escape(self.title)))
843f86
         self.rejected.connect(self.hide)
843f86
 
843f86
-        vbox = QtWidgets.QVBoxLayout()
843f86
+        vbox = QtGui.QVBoxLayout()
843f86
         vbox.setSpacing(6)
843f86
 
843f86
-        label = QtWidgets.QLabel(fromUTF8(escape(
843f86
+        label = QtGui.QLabel(fromUTF8(escape(
843f86
             _("Here you can select the zones used for Shields Up and "
843f86
               "Shields Down."))))
843f86
         label.setWordWrap(True)
843f86
         vbox.addWidget(label)
843f86
 
843f86
-        label = QtWidgets.QLabel(fromUTF8(escape(
843f86
+        label = QtGui.QLabel(fromUTF8(escape(
843f86
             _("This feature is useful for people using the default zones "
843f86
               "mostly. For users, that are changing zones of connections, it "
843f86
               "might be of limited use."))))
843f86
         label.setWordWrap(True)
843f86
         vbox.addWidget(label)
843f86
 
843f86
-        grid = QtWidgets.QGridLayout()
843f86
+        grid = QtGui.QGridLayout()
843f86
         grid.setSpacing(6)
843f86
 
843f86
-        label = QtWidgets.QLabel(fromUTF8(escape(_("Shields Up Zone:"))))
843f86
+        label = QtGui.QLabel(fromUTF8(escape(_("Shields Up Zone:"))))
843f86
         label.setWordWrap(True)
843f86
         grid.addWidget(label, 0, 0, 1, 1)
843f86
 
843f86
-        self.shields_up_combo = QtWidgets.QComboBox()
843f86
+        self.shields_up_combo = QtGui.QComboBox()
843f86
         #self.fill_combo(self.shields_up_combo)
843f86
         #self.set_shields_up(self.shields_up)
843f86
         grid.addWidget(self.shields_up_combo, 0, 1, 1, 1)
843f86
 
843f86
-        button = QtWidgets.QPushButton(_("Reset To Default"))
843f86
+        button = QtGui.QPushButton(_("Reset To Default"))
843f86
         button.clicked.connect(self.reset_shields_up)
843f86
         grid.addWidget(button, 0, 2, 1, 1)
843f86
 
843f86
-        label = QtWidgets.QLabel(fromUTF8(escape(_("Shields Down Zone:"))))
843f86
+        label = QtGui.QLabel(fromUTF8(escape(_("Shields Down Zone:"))))
843f86
         label.setWordWrap(True)
843f86
         grid.addWidget(label, 1, 0, 1, 1)
843f86
 
843f86
-        self.shields_down_combo = QtWidgets.QComboBox()
843f86
+        self.shields_down_combo = QtGui.QComboBox()
843f86
         #self.fill_combo(self.shields_down_combo)
843f86
         #self.set_shields_down(self.shields_down)
843f86
         grid.addWidget(self.shields_down_combo, 1, 1, 1, 1)
843f86
 
843f86
-        button = QtWidgets.QPushButton(_("Reset To Default"))
843f86
+        button = QtGui.QPushButton(_("Reset To Default"))
843f86
         button.clicked.connect(self.reset_shields_down)
843f86
         grid.addWidget(button, 1, 2, 1, 1)
843f86
 
843f86
         vbox.addLayout(grid)
843f86
 
843f86
-        buttonBox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok
843f86
-                                           | QtWidgets.QDialogButtonBox.Cancel)
843f86
-        self.ok_button = buttonBox.button(QtWidgets.QDialogButtonBox.Ok)
843f86
+        buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok
843f86
+                                           | QtGui.QDialogButtonBox.Cancel)
843f86
+        self.ok_button = buttonBox.button(QtGui.QDialogButtonBox.Ok)
843f86
         buttonBox.accepted.connect(self.ok)
843f86
         buttonBox.rejected.connect(self.hide)
843f86
         vbox.addWidget(buttonBox)
843f86
@@ -328,56 +329,56 @@ class ShieldsEditor(QtWidgets.QDialog):
843f86
 
843f86
 # AboutDialog #################################################################
843f86
 
843f86
-class AboutDialog(QtWidgets.QDialog):
843f86
+class AboutDialog(QtGui.QDialog):
843f86
     def __init__(self, name, icon, version, url, copyright, authors, license):
843f86
-        QtWidgets.QDialog.__init__(self)
843f86
+        QtGui.QDialog.__init__(self)
843f86
         self.setWindowIcon(icon)
843f86
         self.setWindowTitle(fromUTF8(escape(_("About %s" % name))))
843f86
         self.resize(500, 250)
843f86
 
843f86
-        vbox = QtWidgets.QVBoxLayout()
843f86
+        vbox = QtGui.QVBoxLayout()
843f86
         vbox.setSpacing(6)
843f86
 
843f86
-        hbox = QtWidgets.QHBoxLayout()
843f86
+        hbox = QtGui.QHBoxLayout()
843f86
         hbox.setSpacing(24)
843f86
 
843f86
-        label = QtWidgets.QLabel()
843f86
+        label = QtGui.QLabel()
843f86
         label.setPixmap(icon.pixmap(96))
843f86
         label.setMinimumSize(96, 96)
843f86
         label.setMaximumSize(96, 96)
843f86
         hbox.addWidget(label)
843f86
 
843f86
-        vbox2 = QtWidgets.QVBoxLayout()
843f86
+        vbox2 = QtGui.QVBoxLayout()
843f86
         vbox2.setSpacing(3)
843f86
 
843f86
-        label = QtWidgets.QLabel(name)
843f86
+        label = QtGui.QLabel(name)
843f86
         font = label.font()
843f86
         font.setPointSize(font.pointSize()*2)
843f86
         font.setBold(True)
843f86
         label.setFont(font)
843f86
         vbox2.addWidget(label)
843f86
 
843f86
-        vbox2.addWidget(QtWidgets.QLabel(version))
843f86
+        vbox2.addWidget(QtGui.QLabel(version))
843f86
 
843f86
-        label = QtWidgets.QLabel("%s" % (url, url))
843f86
+        label = QtGui.QLabel("%s" % (url, url))
843f86
         label.setTextFormat(QtCore.Qt.RichText)
843f86
         label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
843f86
         label.setOpenExternalLinks(True)
843f86
 
843f86
         vbox2.addWidget(label)
843f86
 
843f86
-        vbox2.addWidget(QtWidgets.QLabel(copyright))
843f86
+        vbox2.addWidget(QtGui.QLabel(copyright))
843f86
 
843f86
         hbox.addLayout(vbox2)
843f86
 
843f86
         vbox.addLayout(hbox)
843f86
 
843f86
-        tabs = QtWidgets.QTabWidget()
843f86
+        tabs = QtGui.QTabWidget()
843f86
         tabs.setStyleSheet("QTabWidget::tab { padding: 1px 1px 1px 1px; }")
843f86
 
843f86
-        tab = QtWidgets.QWidget()
843f86
-        vbox3 = QtWidgets.QVBoxLayout()
843f86
-        textedit = QtWidgets.QPlainTextEdit()
843f86
+        tab = QtGui.QWidget()
843f86
+        vbox3 = QtGui.QVBoxLayout()
843f86
+        textedit = QtGui.QPlainTextEdit()
843f86
         #textedit.setStyleSheet("QPlainTextEdit { border: 0; padding: 0; }")
843f86
         textedit.setReadOnly(True)
843f86
         textedit.setPlainText(fromUTF8("\n".join(authors)))
843f86
@@ -385,9 +386,9 @@ class AboutDialog(QtWidgets.QDialog):
843f86
         tab.setLayout(vbox3)
843f86
         tabs.addTab(tab, fromUTF8(escape(_("Authors"))))
843f86
 
843f86
-        tab = QtWidgets.QWidget()
843f86
-        vbox3 = QtWidgets.QVBoxLayout()
843f86
-        textedit = QtWidgets.QPlainTextEdit()
843f86
+        tab = QtGui.QWidget()
843f86
+        vbox3 = QtGui.QVBoxLayout()
843f86
+        textedit = QtGui.QPlainTextEdit()
843f86
         #textedit.setStyleSheet("QPlainTextEdit { border: 0; padding: 0; }")
843f86
         textedit.setReadOnly(True)
843f86
         textedit.setPlainText(license)
843f86
@@ -397,7 +398,7 @@ class AboutDialog(QtWidgets.QDialog):
843f86
 
843f86
         vbox.addWidget(tabs)
843f86
 
843f86
-        buttonBox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Close)
843f86
+        buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Close)
843f86
         buttonBox.rejected.connect(self.hide)
843f86
         vbox.addWidget(buttonBox)
843f86
 
843f86
@@ -405,7 +406,7 @@ class AboutDialog(QtWidgets.QDialog):
843f86
 
843f86
 # TrayApplet ##################################################################
843f86
 
843f86
-class TrayApplet(QtWidgets.QSystemTrayIcon):
843f86
+class TrayApplet(QtGui.QSystemTrayIcon):
843f86
     def __init__(self):
843f86
         super(TrayApplet, self).__init__()
843f86
         self.name = _("Firewall Applet")
843f86
@@ -452,67 +453,67 @@ class TrayApplet(QtWidgets.QSystemTrayIc
843f86
 
843f86
         # urgencies
843f86
 
843f86
-        self.urgencies = { "noicon": QtWidgets.QSystemTrayIcon.NoIcon,
843f86
-                           "information": QtWidgets.QSystemTrayIcon.Information,
843f86
-                           "warning": QtWidgets.QSystemTrayIcon.Warning,
843f86
-                           "critical": QtWidgets.QSystemTrayIcon.Critical }
843f86
+        self.urgencies = { "noicon": QtGui.QSystemTrayIcon.NoIcon,
843f86
+                           "information": QtGui.QSystemTrayIcon.Information,
843f86
+                           "warning": QtGui.QSystemTrayIcon.Warning,
843f86
+                           "critical": QtGui.QSystemTrayIcon.Critical }
843f86
 
843f86
         # actions
843f86
 
843f86
-        self.shieldsupAction = QtWidgets.QAction(fromUTF8(escape(_("Shields Up"))),
843f86
+        self.shieldsupAction = QtGui.QAction(fromUTF8(escape(_("Shields Up"))),
843f86
                                              self)
843f86
         self.shieldsupAction.setCheckable(True)
843f86
         self.shieldsupAction.setChecked(False)
843f86
         self.shieldsupAction.triggered.connect(self.shieldsup_changed_cb)
843f86
 
843f86
-        self.notificationsAction = QtWidgets.QAction(
843f86
+        self.notificationsAction = QtGui.QAction(
843f86
             fromUTF8(escape(_("Enable Notifications"))), self)
843f86
         self.notificationsAction.setCheckable(True)
843f86
         self.notificationsAction.setChecked(False)
843f86
         self.notificationsAction.triggered.connect(self.notification_changed_cb)
843f86
 
843f86
-        self.settingsAction = QtWidgets.QAction(
843f86
+        self.settingsAction = QtGui.QAction(
843f86
             fromUTF8(escape(_("Edit Firewall Settings..."))), self)
843f86
         self.settingsAction.triggered.connect(self.configure_cb)
843f86
 
843f86
-        self.changeZonesAction = QtWidgets.QAction(
843f86
+        self.changeZonesAction = QtGui.QAction(
843f86
             fromUTF8(escape(_("Change Zones of Connections..."))), self)
843f86
         self.changeZonesAction.triggered.connect(self.nm_connection_editor)
843f86
 
843f86
-        self.shieldsAction = QtWidgets.QAction(
843f86
+        self.shieldsAction = QtGui.QAction(
843f86
             fromUTF8(escape(_("Configure Shields UP/Down Zones..."))), self)
843f86
         self.shieldsAction.triggered.connect(self.configure_shields)
843f86
 
843f86
-        self.panicAction = QtWidgets.QAction(
843f86
+        self.panicAction = QtGui.QAction(
843f86
             fromUTF8(escape(_("Block all network traffic"))), self)
843f86
         self.panicAction.setCheckable(True)
843f86
         self.panicAction.setChecked(False)
843f86
         self.panicAction.triggered.connect(self.panic_mode_cb)
843f86
 
843f86
-        self.aboutAction = QtWidgets.QAction(fromUTF8(escape(_("About"))), self)
843f86
+        self.aboutAction = QtGui.QAction(fromUTF8(escape(_("About"))), self)
843f86
         self.aboutAction.triggered.connect(self.about_dialog.exec_)
843f86
 
843f86
-        #self.quitAction = QtWidgets.QAction(fromUTF8(escape(_("Quit"))), self,
843f86
+        #self.quitAction = QtGui.QAction(fromUTF8(escape(_("Quit"))), self,
843f86
         #                                triggered=self.quit)
843f86
 
843f86
-        self.connectionsAction = QtWidgets.QWidgetAction(self)
843f86
-        self.connectionsAction.setDefaultWidget(QtWidgets.QLabel(
843f86
+        self.connectionsAction = QtGui.QWidgetAction(self)
843f86
+        self.connectionsAction.setDefaultWidget(QtGui.QLabel(
843f86
             fromUTF8(""+escape(_("Connections"))+" ")))
843f86
 
843f86
-        self.interfacesAction = QtWidgets.QWidgetAction(self)
843f86
-        self.interfacesAction.setDefaultWidget(QtWidgets.QLabel(
843f86
+        self.interfacesAction = QtGui.QWidgetAction(self)
843f86
+        self.interfacesAction.setDefaultWidget(QtGui.QLabel(
843f86
             fromUTF8(""+escape(_("Interfaces"))+" ")))
843f86
 
843f86
-        self.sourcesAction = QtWidgets.QWidgetAction(self)
843f86
-        self.sourcesAction.setDefaultWidget(QtWidgets.QLabel(
843f86
+        self.sourcesAction = QtGui.QWidgetAction(self)
843f86
+        self.sourcesAction.setDefaultWidget(QtGui.QLabel(
843f86
             fromUTF8(""+escape(_("Sources"))+" ")))
843f86
 
843f86
         # init
843f86
 
843f86
-        self.left_menu = QtWidgets.QMenu()
843f86
+        self.left_menu = QtGui.QMenu()
843f86
         self.left_menu.setStyleSheet('QMenu { margin: 5px; }')
843f86
 
843f86
-        self.right_menu = QtWidgets.QMenu()
843f86
+        self.right_menu = QtGui.QMenu()
843f86
         self.right_menu.addAction(self.shieldsupAction)
843f86
         self.right_menu.addAction(self.notificationsAction)
843f86
         self.right_menu.addSeparator()
843f86
@@ -631,7 +632,7 @@ class TrayApplet(QtWidgets.QSystemTrayIc
843f86
             self.setVisible(True)
843f86
 
843f86
     def activated_cb(self, reason):
843f86
-        if reason == QtWidgets.QSystemTrayIcon.Trigger:
843f86
+        if reason == QtGui.QSystemTrayIcon.Trigger:
843f86
             self.left_menu.popup(QtGui.QCursor.pos())
843f86
 
843f86
     def update_active_zones(self):
843f86
@@ -679,12 +680,12 @@ class TrayApplet(QtWidgets.QSystemTrayIc
843f86
             zone = connections[connection][0]
843f86
             if zone == "":
843f86
                 _binding = _("{entry} (Default Zone: {default_zone})")
843f86
-                action = QtWidgets.QAction(
843f86
+                action = QtGui.QAction(
843f86
                     fromUTF8(escape(
843f86
                         _binding.format(default_zone=self.default_zone,
843f86
                                         entry=connection))), self)
843f86
             else:
843f86
-                action = QtWidgets.QAction(
843f86
+                action = QtGui.QAction(
843f86
                     fromUTF8(escape(binding.format(zone=zone,
843f86
                                                    entry=connection))), self)
843f86
             action.triggered.connect(functools.partial(
843f86
@@ -697,7 +698,7 @@ class TrayApplet(QtWidgets.QSystemTrayIc
843f86
         # add other interfaces
843f86
         for interface in sorted(interfaces):
843f86
             zone = interfaces[interface]
843f86
-            action = QtWidgets.QAction(
843f86
+            action = QtGui.QAction(
843f86
                 fromUTF8(escape(binding.format(zone=zone, entry=interface))),
843f86
                 self)
843f86
             action.triggered.connect(functools.partial(
843f86
@@ -709,7 +710,7 @@ class TrayApplet(QtWidgets.QSystemTrayIc
843f86
 
843f86
         for source in sorted(sources):
843f86
             zone = sources[source]
843f86
-            action = QtWidgets.QAction(
843f86
+            action = QtGui.QAction(
843f86
                 fromUTF8(escape(binding.format(zone=zone, entry=source))),
843f86
                 self)
843f86
             action.triggered.connect(functools.partial(
843f86
@@ -931,10 +932,10 @@ class TrayApplet(QtWidgets.QSystemTrayIc
843f86
             os.system("%s &" % NM_CONNECTION_EDITOR)
843f86
 
843f86
     def warning(self, text):
843f86
-        QtWidgets.QMessageBox.warning(None, fromUTF8(escape(self.name)), text)
843f86
+        QtGui.QMessageBox.warning(None, fromUTF8(escape(self.name)), text)
843f86
 
843f86
     def error(self, text):
843f86
-        QtWidgets.QMessageBox.critical(None, fromUTF8(escape(self.name)), text)
843f86
+        QtGui.QMessageBox.critical(None, fromUTF8(escape(self.name)), text)
843f86
 
843f86
     def configure_cb(self, widget):
843f86
         os.system("firewall-config &")
843f86
@@ -970,8 +971,6 @@ class TrayApplet(QtWidgets.QSystemTrayIc
843f86
     def reloaded(self):
843f86
         if self.notificationsAction.isChecked():
843f86
             self.notify(escape(_("FirewallD has been reloaded.")))
843f86
-        self.update_active_zones()
843f86
-        self.update_tooltip()
843f86
 
843f86
     def default_zone_changed(self, zone):
843f86
         self.default_zone = zone
843f86
@@ -1118,7 +1117,7 @@ Options:
843f86
 # reset SIGINT signal to default
843f86
 signal.signal(signal.SIGINT, signal.SIG_DFL)
843f86
 
843f86
-app = QtWidgets.QApplication(sys.argv)
843f86
+app = QtGui.QApplication(sys.argv)
843f86
 app.setQuitOnLastWindowClosed(False)
843f86
 
843f86
 applet = TrayApplet()