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