コード例 #1
0
ファイル: config_dialog.py プロジェクト: mnunberg/yobot
 def add_modify_account(self, add=False):
     dlg = AccountSettingsDialog(self)
     if not add:
         item = self.widgets.accounts.currentItem()
         if not item:
             return
         account = self.account_items.get(item)
         if not account:
             return
         #account = item.data(0, ITEM_PLACEHOLDER_ROLE).toPyObject()
         dlg.fill_from(account)
     else:
         item = QTreeWidgetItem()
     result = dlg.exec_()
     
     if not result == QDialog.Accepted:
         return
     new_a = dlg.values
     
     item.setText(0, new_a["name"])
     #get icon and name...
     name, icon = getProtoIconAndName(getattr(yobotproto, new_a["improto"], -1))
     item.setText(1, name)
     item.setIcon(1, icon)
     if add:
         if self.account_exists(new_a):
             print "account already exists.. not adding"
             return
         item.setData(0, ITEM_PLACEHOLDER_ROLE, new_a)
         self.widgets.accounts.addTopLevelItem(item)
         self.config.accounts.append(new_a)
     else:
         account.update(new_a)
コード例 #2
0
ファイル: config_dialog.py プロジェクト: mnunberg/yobot
 def load_settings(self):
     w = self.widgets
     if not self.config:
         log_warn("config object not available! bailing")
         return
     #for font..
     appearance = self.config.globals.setdefault("appearance", {})
     family = appearance.get("font_family", None)
     size = appearance.get("font_size", None)
     color = appearance.get("font_color", None)
     
     if family: self.font.setFamily(family)
     if size: self.font.setPointSize(size)
     if color: self.color.setNamedColor(color)
     
     bold = appearance.get("font_bold", False)
     italic = appearance.get("font_italic", False)
     underline = appearance.get("font_underline", False)
     html_relsize = appearance.get("use_html_relsize", False)
     show_joinpart = appearance.get("show_joinpart", False)
     
     self.font.setBold(bold)
     self.font.setItalic(italic)
     self.font.setUnderline(underline)
     w.html_relsize.setChecked(html_relsize)
     w.show_joinpart.setChecked(show_joinpart)
     
     self.change_formatting()
     
     #for the agent...
     agent = self.config.globals.get("agent_address", None)
     if agent: w.agent_address.setText(agent)
     self.change_agent()
     #for accounts:
     for a in self.config.accounts:
         log_warn("got account", a)
         if a.get("name", None) and a.get("improto", None):
             #get name and icon
             name, icon = getProtoIconAndName(getattr(yobotproto, a["improto"], ""))
             log_debug(icon, name)
             i = QTreeWidgetItem((a["name"], name))
             i.setIcon(1, icon)
             i.setData(0, ITEM_PLACEHOLDER_ROLE, a)
             self.account_items[i] = a
             self.widgets.accounts.addTopLevelItem(i)