Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 import os
00034 import rospkg
00035
00036 from python_qt_binding import loadUi
00037 from python_qt_binding.QtGui import QIcon
00038 from python_qt_binding.QtWidgets import QWidget
00039
00040
00041 class FilterWrapperWidget(QWidget):
00042 """
00043 Wraps the other filter widgets to provide enable check box, delete button control and uniform labeling
00044 """
00045 def __init__(self, widget, filter_name):
00046 """
00047 :param widget: the Qwidget to wrap ''Qwidget''
00048 :param filter_name: the name to be placed on the label ''str''
00049 """
00050 super(FilterWrapperWidget, self).__init__()
00051 rp = rospkg.RosPack()
00052 ui_file = os.path.join(rp.get_path('rqt_console'), 'resource/filters', 'filter_wrapper_widget.ui')
00053 loadUi(ui_file, self)
00054 self.setObjectName('FilterWrapperWidget')
00055 self.delete_button.setIcon(QIcon.fromTheme('list-remove'))
00056 self._widget = widget
00057
00058
00059 stretch = self.layout_frame.stretch(2)
00060 self.layout_frame.insertWidget(2, widget)
00061 self.layout_frame.setStretch(2, stretch)
00062
00063
00064
00065 self.layout_frame.setStretch(3, 0)
00066
00067 self.enabled_checkbox.clicked[bool].connect(self.enabled_callback)
00068 self.filter_name_label.setText(filter_name + ':')
00069
00070 def enabled_callback(self, checked):
00071 self._widget._parentfilter.set_enabled(checked)
00072 self._widget.setEnabled(checked)
00073
00074 def repopulate(self):
00075 self._widget.repopulate()
00076
00077 def save_settings(self, settings):
00078 """
00079 Handles writing the enabled flag to the ini file and then passes the
00080 settings object to the wrapped widget
00081
00082 :param settings: used to write the settings to an ini file ''qt_gui.settings.Settings''
00083 """
00084 settings.set_value('enabled', self._widget._parentfilter._enabled)
00085 self._widget.save_settings(settings)
00086
00087 def restore_settings(self, settings):
00088 """
00089 Handles reading the enabled flag from the ini file.
00090 :param settings: used to read the settings to an ini file ''qt_gui.settings.Settings''
00091 """
00092 checked = settings.value('enabled') in [True, 'true']
00093 self.enabled_callback(checked)
00094 self.enabled_checkbox.setChecked(checked)
00095 self._widget.restore_settings(settings)