Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 from __future__ import division
00010 import os
00011 
00012 from python_qt_binding import loadUi
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 from python_qt_binding.QtGui import QWidget, QPixmap
00028 
00029 
00030 
00031 from qt_gui.plugin import Plugin
00032 
00033 import rospkg
00034 
00035 import concert_service_utilities
00036 
00037 
00038 
00039 
00040 class ServiceInfo(Plugin):
00041     def __init__(self, context):
00042         super(ServiceInfo, self).__init__(context)
00043         self.initialised = False
00044         self.setObjectName('ServiceInfo')
00045         self._current_dotcode = None
00046         counter = 0
00047         service_info = concert_service_utilities.service_information.get_services_info()
00048         dict = service_info[1] 
00049         nameList = service_info[0] 
00050 
00051         
00052         self._widget = QWidget()
00053         self._widget.setObjectName('ConcertServiceInfoUi')
00054         rospack = rospkg.RosPack()
00055         ui_file = os.path.join(rospack.get_path('concert_qt_service_info'), 'ui', 'concert_service_info.ui')
00056         loadUi(ui_file, self._widget)
00057         if context.serial_number() > 1:
00058             self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
00059 
00060         for value in nameList:
00061             info_text = "<html>"
00062             info_text += "<p><b>Resource Name: </b>" + dict[value].resource_name + "</p>"
00063             info_text += "<p><b>Name: </b>" + dict[value].name + "</p>"
00064             info_text += "<p><b>Description: </b>" + dict[value].description + "</p>"
00065             info_text += "<p><b>Author: </b>" + dict[value].author + "</p>"
00066             info_text += "<p><b>Priority: </b>" + str(dict[value].priority) + "</p>"
00067             info_text += "<p><b>Launcher: </b>" + dict[value].launcher_type + "</p>"
00068             info_text += "<p><b>Status: </b>" + str(dict[value].status) + "</p>"
00069             info_text += "<p><b>Enabled: </b>" + str(dict[value].enabled) + "</p>"
00070             info_text += "<p><b>Icon: </b>" + str(dict[value].icon.resource_name) + "</p>"
00071             info_text += "</html>"
00072 
00073             if counter == 0:
00074                 self._widget.app_info.appendHtml(info_text)
00075                 pixmap2 = QPixmap()
00076                 pixmap2.loadFromData(dict[value].icon.data, format=dict[value].icon.format)
00077                 if QPixmap.isNull(pixmap2):
00078                     icon_file2 = os.path.join(rospack.get_path('concert_qt_service_info'), 'resources', 'images', 'unknown.png')
00079                     pixmap2 = QPixmap(icon_file2, format="png")
00080                     self._widget.app_icon2.setPixmap(pixmap2)
00081                     self._widget.app_icon2.resize(pixmap2.width(), pixmap2.height())
00082                 if not QPixmap.isNull(pixmap2):
00083                     self._widget.app_icon2.setPixmap(pixmap2)
00084                     self._widget.app_icon2.resize(pixmap2.width(), pixmap2.height())
00085             if counter == 1:
00086                 self._widget.app_info2.appendHtml(info_text)
00087                 pixmap = QPixmap()
00088                 pixmap.loadFromData(dict[value].icon.data, format=dict[value].icon.format)
00089                 if QPixmap.isNull(pixmap):
00090                     icon_file = os.path.join(rospack.get_path('concert_qt_service_info'), 'resources', 'images', 'unknown.png')
00091                     pixmap = QPixmap(icon_file, format="png")
00092                     self._widget.app_icon.setPixmap(pixmap)
00093                     self._widget.app_icon.resize(pixmap.width(), pixmap.height())   
00094                 if not QPixmap.isNull(pixmap):
00095                     self._widget.app_icon.setPixmap(pixmap)
00096                     self._widget.app_icon.resize(pixmap.width(), pixmap.height())
00097             counter = counter + 1 
00098 
00099         context.add_widget(self._widget)
00100 
00101     def shutdown_plugin(self):
00102         pass