historyPanel.py (3901B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\inflight\overviewSettings\historyPanel.py 2 from carbon.common.script.util.format import FmtDate 3 from carbonui.primitives.container import Container 4 from carbonui import uiconst 5 from carbonui.primitives.containerAutoSize import ContainerAutoSize 6 from carbonui.primitives.line import Line 7 from carbonui.util.sortUtil import SortListOfTuples 8 from carbonui.control.button import Button 9 from eve.client.script.ui.control.eveEditPlainText import EditPlainText 10 from eve.client.script.ui.control.eveLabel import EveLabelMedium, EveLabelSmall 11 from localization import GetByLabel 12 from overviewPresets.client.preset_link import overview_preset_link 13 import overviewPresets.overviewSettingsConst as oConst 14 15 class HistoryPanel(Container): 16 default_name = 'HistoryPanel' 17 default_state = uiconst.UI_HIDDEN 18 19 def ApplyAttributes(self, attributes): 20 Container.ApplyAttributes(self, attributes) 21 self.presetSvc = sm.GetService('overviewPresetSvc') 22 historyCont = Container(name='historyCont', parent=self, align=uiconst.TOALL) 23 self.restoreCont = ContainerAutoSize(name='historyCont', parent=historyCont, align=uiconst.TOBOTTOM, left=const.defaultPadding, width=const.defaultPadding, alignMode=uiconst.TOTOP) 24 Line(parent=historyCont, align=uiconst.TOBOTTOM, color=(1, 1, 1, 0.1)) 25 restoreButton = Button(parent=self.restoreCont, label=GetByLabel('UI/Overview/RestoreProfile'), func=self.RestoreOldOverview, left=10, align=uiconst.CENTERRIGHT) 26 restoreLabel = EveLabelMedium(text=GetByLabel('UI/Overview/AutomaticallyStoredOverviewHeader'), parent=self.restoreCont, align=uiconst.TOTOP, padding=(10, 27 3, 28 restoreButton.width + 10, 29 0), state=uiconst.UI_DISABLED) 30 self.restoreOverviewNameLabel = EveLabelSmall(text='', parent=self.restoreCont, align=uiconst.TOTOP, padding=(10, 31 0, 32 restoreButton.width + 10, 33 2), state=uiconst.UI_DISABLED) 34 historyText = EveLabelMedium(text=GetByLabel('UI/Overview/HistoryText'), parent=historyCont, align=uiconst.TOTOP, padding=(10, 3, 10, 0), state=uiconst.UI_DISABLED) 35 historyText.SetRGBA(1, 1, 1, 0.8) 36 self.historyEdit = EditPlainText(setvalue='', parent=historyCont, align=uiconst.TOALL, readonly=True, pos=(10, -2, 10, 0)) 37 self.historyEdit.HideBackground() 38 self.historyEdit.RemoveActiveFrame() 39 return historyCont 40 41 def RestoreOldOverview(self, *args): 42 self.presetSvc.RestoreAutoSavedOverviewProfile() 43 self.UpdateRestoreCont() 44 45 def LoadHistory(self): 46 presetHistoryKeys = settings.user.overview.Get(oConst.SETTING_HISTORY_KEYS, {}) 47 textList = [] 48 for eachKey, eachValue in presetHistoryKeys.iteritems(): 49 overviewName = eachValue.get('overviewName', 'overview_name') 50 presetKey = eachValue.get('presetKey') 51 timestamp = eachValue.get('timestamp') 52 link = overview_preset_link(presetKey, overviewName) 53 text = GetByLabel('UI/Overview/ProfileLinkWithTimestamp', profileLink=link, timestamp=FmtDate(timestamp)) 54 textList.append((timestamp, text)) 55 56 textList = SortListOfTuples(textList, reverse=True) 57 allText = '<br>'.join(textList[:15]) 58 self.historyEdit.SetValue(allText) 59 self.UpdateRestoreCont() 60 61 def UpdateRestoreCont(self): 62 restoreData = settings.user.overview.Get(oConst.SETTING_RESTORE_DATA, {}) 63 if not restoreData: 64 self.restoreCont.display = False 65 return 66 self.restoreCont.display = True 67 overviewName = restoreData['name'] 68 timestamp = restoreData['timestamp'] 69 self.restoreOverviewNameLabel.text = GetByLabel('UI/Overview/StoredOverviewBasedOn', overviewName=overviewName, timestamp=FmtDate(timestamp))