giveSharesDialog.py (5330B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\neocom\wallet\giveSharesDialog.py 2 import localization 3 from carbonui import const as uiconst 4 from carbonui.control.singlelineedits.singleLineEditInteger import SingleLineEditInteger 5 from carbonui.control.singlelineedits.singleLineEditText import SingleLineEditText 6 from carbonui.primitives.container import Container 7 from carbonui.primitives.containerAutoSize import ContainerAutoSize 8 from carbonui.primitives.layoutGrid import LayoutGrid 9 from eve.client.script.ui.control import eveIcon, eveLabel 10 from carbonui.button.group import ButtonGroup 11 from carbonui.control.button import Button 12 from carbonui.control.window import Window 13 from eve.client.script.ui.util import searchOld 14 from eve.common.lib import appConst as const 15 from eveexceptions import UserError 16 17 class GiveSharesDialog(Window): 18 default_windowID = 'GiveSharesDialog' 19 20 def ApplyAttributes(self, attributes): 21 Window.ApplyAttributes(self, attributes) 22 corporationID = attributes.corporationID 23 maxShares = attributes.maxShares 24 shareholderID = attributes.shareholderID 25 self.ownerID = None 26 self.searchStr = '' 27 self.corporationID = corporationID 28 self.maxShares = maxShares 29 self.shareholderID = shareholderID 30 self.scope = 'all' 31 self.SetCaption(localization.GetByLabel('UI/Wallet/WalletWindow/CaptionGiveSharesTo', who=cfg.eveowners.Get(self.shareholderID).name)) 32 self.SetMinSize([400, 130]) 33 self.Layout() 34 35 def Layout(self): 36 self.sr.standardBtns = ButtonGroup(parent=self.GetMainArea(), btns=[[localization.GetByLabel('UI/Common/Buttons/OK'), self.OnOK], [localization.GetByLabel('UI/Common/Buttons/Cancel'), self.OnCancel]], align=uiconst.TOBOTTOM, padTop=8) 37 self.topParent = ContainerAutoSize(name='topParent', parent=self.GetMainArea(), align=uiconst.TOTOP, clipChildren=True, callback=self._on_main_cont_size_changed, only_use_callback_when_size_changes=True) 38 self.layout_container = LayoutGrid(parent=self.topParent, columns=4, align=uiconst.TOPLEFT, cellSpacing=(8, 8)) 39 self.ShowCorpLogo(self.corporationID) 40 give_shares_label = eveLabel.EveCaptionMedium(text=localization.GetByLabel('UI/Wallet/WalletWindow/CaptionGiveShares')) 41 self.layout_container.AddCell(give_shares_label, colSpan=3) 42 self.sharesLabel = eveLabel.EveLabelSmall(text=localization.GetByLabel('UI/Wallet/WalletWindow/NumberOfShares'), align=uiconst.CENTERLEFT, parent=self.layout_container, state=uiconst.UI_NORMAL) 43 inptShares = SingleLineEditInteger(name='edit', setvalue=self.maxShares, minValue=1, maxValue=self.maxShares, align=uiconst.CENTERLEFT, maxLength=32) 44 self.layout_container.AddCell(inptShares, colSpan=2) 45 self.sr.inptShares = inptShares 46 self.ownerLabel = eveLabel.EveLabelSmall(text=localization.GetByLabel('UI/Wallet/WalletWindow/ToOwner'), parent=self.layout_container, state=uiconst.UI_NORMAL, align=uiconst.CENTERLEFT) 47 inptOwner = SingleLineEditText(name='edit', parent=self.layout_container, align=uiconst.CENTERLEFT, maxLength=48) 48 inptOwner.OnReturn = self.Search 49 self.sr.inptOwner = inptOwner 50 Button(parent=self.layout_container, label=localization.GetByLabel('UI/Wallet/WalletWindow/BtnSearch'), func=self.Search, btn_default=1, align=uiconst.CENTERLEFT) 51 52 def _on_main_cont_size_changed(self): 53 width, height = self.GetWindowSizeForContentSize(height=self.topParent.height + self.sr.standardBtns.height + self.sr.standardBtns.padTop, width=self.topParent.width) 54 self.SetMinSize(size=(width, height), refresh=True) 55 56 def ShowCorpLogo(self, corporationID): 57 loc = ContainerAutoSize(name='logoContainer', align=uiconst.TOPLEFT) 58 self.layout_container.AddCell(loc, rowSpan=4) 59 if loc is not None: 60 loc.Flush() 61 logo = eveIcon.GetLogoIcon(itemID=corporationID, parent=loc, idx=0, state=uiconst.UI_PICKCHILDREN, size=64, ignoreSize=True) 62 if hasattr(logo, 'children'): 63 for child in logo.children: 64 child.state = uiconst.UI_DISABLED 65 66 def Search(self, *args): 67 self.searchStr = self.sr.inptOwner.GetValue().strip() 68 self.ownerID = searchOld.Search(self.searchStr.lower(), const.groupCharacter, const.categoryOwner, hideNPC=1, searchWndName='walletSearchSearch', hideDustChars=True) 69 if self.ownerID: 70 self.sr.inptOwner.SetText(cfg.eveowners.Get(self.ownerID).name) 71 72 def OnOK(self, *args): 73 if not self.ownerID: 74 self.Search() 75 if self.ownerID: 76 self.TransferShares(self.ownerID, self.sr.inptShares.GetValue()) 77 self.CloseByUser() 78 else: 79 raise UserError('GiveSharesSelectOwner') 80 81 def OnCancel(self, *args): 82 self.ownerID = None 83 self.CloseByUser() 84 85 def TransferShares(self, toShareholderID, numberOfShares): 86 if cfg.eveowners.Get(self.shareholderID).typeID == const.typeCorporation: 87 sm.GetService('corp').MoveCompanyShares(self.corporationID, toShareholderID, numberOfShares) 88 else: 89 sm.GetService('corp').MovePrivateShares(self.corporationID, toShareholderID, numberOfShares)