NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

treeViewSettingsItem.py (3663B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\notifications\client\controls\treeViewSettingsItem.py
      2 from __future__ import print_function
      3 from carbon.common.script.sys.serviceConst import ROLE_PROGRAMMER
      4 from carbonui.primitives.container import Container
      5 from eve.client.script.ui.control.treeViewEntry import TreeViewEntry
      6 from eve.common.lib import appConst
      7 from notifications.client.controls.notificationSettingEntityDeco import NotificationSettingEntityDeco
      8 from carbonui.control.checkbox import Checkbox
      9 import carbonui.const as uiconst
     10 import localization
     11 
     12 class TreeViewSettingsItem(TreeViewEntry):
     13     default_name = 'TreeViewEntrySettings'
     14 
     15     def ApplyAttributes(self, attributes):
     16         TreeViewEntry.ApplyAttributes(self, attributes)
     17         if hasattr(self.data, 'settings'):
     18             self.settings = self.data.settings
     19             if self.settings:
     20                 labelCont = Container(name='labelCont', parent=self.topRightCont, align=uiconst.TOALL, padRight=44, idx=0)
     21                 self.label.SetParent(labelCont)
     22                 self.label.autoFadeSides = 20
     23                 self.GetMenuCallback = self.settings[NotificationSettingEntityDeco.GETMENU_CALLBACK]
     24                 visibilityChecked = self.settings[NotificationSettingEntityDeco.VISIBILITY_CHECKED_KEY]
     25                 showPopupChecked = self.settings[NotificationSettingEntityDeco.POPUP_CHECKED_KEY]
     26                 self.visibilityCallBack = self.settings[NotificationSettingEntityDeco.VISIBILITY_CHANGED_CALLBACK_KEY]
     27                 self.showPopupCallBack = self.settings[NotificationSettingEntityDeco.POPUP_CHANGED_CALLBACK_KEY]
     28                 self.popupCheckBox = Checkbox(name='UsepopupNotifications', text='', parent=self.topRightCont, align=uiconst.TORIGHT, checked=showPopupChecked, callback=self.OnPopupNotificationToggle, hint=localization.GetByLabel('Notifications/NotificationSettings/PopupVisibilityCheckboxTooltip'))
     29                 self.visibilityChckbox = Checkbox(name='visibilityNotification', text='', parent=self.topRightCont, align=uiconst.TORIGHT, checked=visibilityChecked, callback=self.OnVisibiltyToggle, hint=localization.GetByLabel('Notifications/NotificationSettings/HistoryVisibilityCheckboxTooltip'))
     30                 self.isGroup = self.settings['isGroup']
     31                 self.id = self.settings['id']
     32 
     33     def OnPopupNotificationToggle(self, checkbox):
     34         if self.isGroup:
     35             for child in self.childCont.children:
     36                 child.UpdatePopupCheckBox(checkbox._checked, report=True)
     37 
     38         self.showPopupCallBack(self.isGroup, self.id, checkbox._checked)
     39 
     40     def OnVisibiltyToggle(self, checkbox):
     41         if self.isGroup:
     42             for child in self.childCont.children:
     43                 child.UpdateVisibilitySetting(checkbox._checked, report=True)
     44 
     45         self.visibilityCallBack(self.isGroup, self.id, checkbox._checked)
     46 
     47     def OnOneClick(self, *args):
     48         print('click')
     49 
     50     def GetMenu(self):
     51         m = self.GetMenuCallback(self.isGroup, self.id)
     52         if session.role & ROLE_PROGRAMMER:
     53             m.append(('GM: Send test event!', self._SendTestEvent))
     54         return m
     55 
     56     def _SendTestEvent(self):
     57         sm.ScatterEvent('OnNotificationReceived', 123, self.id, appConst.factionAmarrEmpire, session.charid)
     58 
     59     def GetTreeViewEntryClassByTreeData(self, treeData):
     60         return TreeViewSettingsItem
     61 
     62     def UpdateVisibilitySetting(self, on, report = False):
     63         self.visibilityChckbox.SetChecked(isChecked=on, report=report)
     64 
     65     def UpdatePopupCheckBox(self, on, report = False):
     66         self.popupCheckBox.SetChecked(isChecked=on, report=report)