def tint_icons(self, tint_color): """Apply the given tint to the various tray icons.""" self._tint = tint_color self._icons = { "connected": utils.qicon_tint("ic_connected", tint_color), "connecting": utils.qicon_tint("ic_connecting", tint_color), "disconnected": utils.qicon_tint("ic_disconnected", tint_color), "hot": utils.qicon_tint("ic_hot", tint_color), } self.set_icon("disconnected") self.update_config()
def __init__(self, pane, *args): QtGui.QVBoxLayout.__init__(*(self,) + args) self.section = "notifications" self.config = QtGui.QApplication.instance().config self.pane = pane self.stack = QtGui.QStackedWidget() self.table = QtGui.QTableWidget() fg_color = self.table.palette().text().color().name() self.action_labels = { "sound": "Play a sound", "message": "Show a message in a popup", "file": "Log to a file", "taskbar": "Mark taskbar entry", "tray": "Mark systray/indicator", "command": "Run a command"} self.action_icons = { "sound": utils.qicon_from_theme("media-playback-start"), "message": utils.qicon_from_theme("dialog-information"), "file": utils.qicon_from_theme("document-export"), "taskbar": utils.qicon_from_theme("weechat"), "tray": utils.qicon_tint("ic_hot", fg_color), "command": utils.qicon_from_theme("system-run")} self.icon_widget_qss = "padding:0;min-height:10px;min-width:16px;" self.table.resizeColumnsToContents() self.table.setColumnCount(2) self.table.resizeRowsToContents() self.table.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) self.table.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) self.table.setHorizontalHeaderLabels(["State", "Type"]) self.table.horizontalHeader().setStretchLastSection(True) self.table.horizontalHeader().setHighlightSections(False) self.table.verticalHeader().setVisible(False) self.table.setShowGrid(False) self.table.itemSelectionChanged.connect(self._table_row_changed) self.buftypes = {} for key, value in config.CONFIG_DEFAULT_NOTIFICATION_OPTIONS: buftype, optkey = key.split(".") if buftype not in self.buftypes: self.buftypes[buftype] = {} self.buftypes[buftype][optkey] = self.config.get(self.section, key) for buftype, optkey in self.buftypes.items(): self._insert_type(buftype) self.update_icons() self.resize_table() self.addWidget(self.table) self.addWidget(self.stack) self.table.selectRow(0)