Application icons loading.

This commit is contained in:
ABaptista 2017-04-19 19:26:13 -04:00
parent 459cc76579
commit 1533fb62bb
2 changed files with 18 additions and 30 deletions

View file

@ -195,41 +195,20 @@
<string>Take this action:</string>
</property>
</widget>
<widget class="QGraphicsView" name="logoGraphicsView">
<widget class="QLabel" name="iconLabel">
<property name="geometry">
<rect>
<x>432</x>
<x>430</x>
<y>-2</y>
<width>60</width>
<height>60</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>60</height>
</size>
<property name="text">
<string/>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background: transparent</string>
</property>
<property name="backgroundBrush">
<brush brushstyle="NoBrush">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</widget>

View file

@ -20,7 +20,7 @@
from opensnitch.rule import Rule
from PyQt4 import QtCore, QtGui, uic
import sys, os
import sys, os, gtk
# TODO: Implement tray icon and menu.
# TODO: Implement rules editor.
@ -53,6 +53,7 @@ class OpenSnitchDialog( QtGui.QMainWindow, dialog_ui ):
self.init_widgets()
self.start_listeners()
self.setup_labels()
self.setup_icon()
self.setup_extra()
self.result = OpenSnitchDialog.DEFAULT_RESULT
@ -76,7 +77,7 @@ class OpenSnitchDialog( QtGui.QMainWindow, dialog_ui ):
self.deny_button = self.findChild( QtGui.QPushButton, "denyButton" )
self.whitelist_button = self.findChild( QtGui.QPushButton, "whitelistButton" )
self.block_button = self.findChild( QtGui.QPushButton, "blockButton" )
self.logo_graphics_view = self.findChild( QtGui.QGraphicsView, "logoGraphicsView" )
self.icon_label = self.findChild( QtGui.QLabel, "iconLabel" )
def start_listeners(self):
self.allow_button.clicked.connect( self._allow_action )
@ -85,6 +86,14 @@ class OpenSnitchDialog( QtGui.QMainWindow, dialog_ui ):
self.block_button.clicked.connect( self._block_action )
self.action_combo_box.currentIndexChanged[str].connect ( self._action_changed )
def setup_icon(self):
icon_theme = gtk.icon_theme_get_default()
icon = icon_theme.lookup_icon(self.connection.app.icon, 48, 0)
if icon is not None:
icon_path = icon.get_filename()
pixmap = QtGui.QPixmap(icon_path)
self.icon_label.setPixmap(pixmap)
def setup_extra(self):
self._action_changed()