mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-26 12:53:12 -06:00
Added check boxes for bot, private and discoverable
This commit is contained in:
parent
6d7f808196
commit
f5815d7911
@ -268,6 +268,10 @@ class Handler(object):
|
||||
'header': profile.header,
|
||||
'avatar': profile.avatar,
|
||||
'fields': [(field.name, html_filter(field.value)) for field in profile.fields],
|
||||
'locked': profile.locked,
|
||||
'bot': profile.bot,
|
||||
# discoverable could be None, set it to False
|
||||
'discoverable': profile.discoverable if profile.discoverable else False,
|
||||
}
|
||||
log.debug(f"arafat {data['fields']}")
|
||||
dialog = update_profile_dialogs.UpdateProfileDialog(**data)
|
||||
|
@ -5,7 +5,6 @@ from io import BytesIO
|
||||
import wx
|
||||
|
||||
|
||||
from logging import getLogger;log = getLogger()
|
||||
def return_true():
|
||||
return True
|
||||
|
||||
@ -23,8 +22,7 @@ class UpdateProfileDialog(wx.Dialog):
|
||||
```
|
||||
"""
|
||||
|
||||
def __init__(self, display_name: str="", note: str="", header: str="",
|
||||
avatar: str="", fields: list=[]):
|
||||
def __init__(self, display_name: str, note: str, header: str, avatar: str, fields: list, locked: bool, bot: bool, discoverable: bool):
|
||||
"""Initialize update profile dialog
|
||||
Parameters:
|
||||
- display_name: The user's display name to show in the display name field
|
||||
@ -42,10 +40,18 @@ class UpdateProfileDialog(wx.Dialog):
|
||||
|
||||
# create widgets
|
||||
display_name_label = wx.StaticText(panel, label=_("Display Name"))
|
||||
self.display_name = wx.TextCtrl(panel, value=display_name, style=
|
||||
wx.TE_PROCESS_ENTER)
|
||||
self.display_name = wx.TextCtrl(panel, value=display_name, style= wx.TE_PROCESS_ENTER, size=(100, 30))
|
||||
name_sizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
name_sizer.Add(display_name_label, wx.SizerFlags().Center())
|
||||
name_sizer.Add(self.display_name, wx.SizerFlags().Center())
|
||||
sizer.Add(name_sizer, wx.CENTER)
|
||||
|
||||
bio_label = wx.StaticText(panel, label=_("Bio"))
|
||||
self.bio = wx.TextCtrl(panel, value=note, style=wx.TE_PROCESS_ENTER)
|
||||
self.bio = wx.TextCtrl(panel, value=note, style=wx.TE_PROCESS_ENTER | wx.TE_MULTILINE, size=(200, 30))
|
||||
bio_sizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
bio_sizer.Add(bio_label, wx.SizerFlags().Center())
|
||||
bio_sizer.Add(self.bio, wx.SizerFlags().Center())
|
||||
sizer.Add(bio_sizer, wx.CENTER)
|
||||
|
||||
# header
|
||||
header_label = wx.StaticText(panel, label=_("Header"))
|
||||
@ -62,6 +68,11 @@ class UpdateProfileDialog(wx.Dialog):
|
||||
|
||||
self.header_image.AcceptsFocusFromKeyboard = return_true
|
||||
self.change_header = wx.Button(panel, label=_("Change header"))
|
||||
header_sizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
header_sizer.Add(header_label, wx.SizerFlags().Center())
|
||||
header_sizer.Add(self.header_image, wx.SizerFlags().Center())
|
||||
header_sizer.Add(self.change_header, wx.SizerFlags().Center())
|
||||
sizer.Add(header_sizer, wx.CENTER)
|
||||
|
||||
# avatar
|
||||
avatar_label = wx.StaticText(panel, label=_("Avatar"))
|
||||
@ -78,6 +89,11 @@ class UpdateProfileDialog(wx.Dialog):
|
||||
|
||||
self.avatar_image.AcceptsFocusFromKeyboard = return_true
|
||||
self.change_avatar = wx.Button(panel, label=_("Change avatar"))
|
||||
avatar_sizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
avatar_sizer.Add(avatar_label, wx.SizerFlags().Center())
|
||||
avatar_sizer.Add(self.avatar_image, wx.SizerFlags().Center())
|
||||
avatar_sizer.Add(self.change_avatar, wx.SizerFlags().Center())
|
||||
sizer.Add(avatar_sizer, wx.CENTER)
|
||||
|
||||
self.fields = []
|
||||
for i in range(1, 5):
|
||||
@ -85,57 +101,42 @@ class UpdateProfileDialog(wx.Dialog):
|
||||
field_label = wx.StaticText(panel, label=_("Field {}: Label").format(i))
|
||||
field_sizer.Add(field_label, wx.SizerFlags().Center().Border(wx.ALL, 5))
|
||||
|
||||
label_textctrl = wx.TextCtrl(panel, style=wx.TE_PROCESS_ENTER)
|
||||
label_textctrl = wx.TextCtrl(panel, style=wx.TE_PROCESS_ENTER | wx.TE_MULTILINE, size=(200, 30))
|
||||
if i <= len(fields):
|
||||
label_textctrl.SetValue(fields[i-1][0])
|
||||
log.debug(f"Field {i}: label = {fields[i-1][0]}")
|
||||
field_sizer.Add(label_textctrl, wx.SizerFlags().Expand().Border(wx.ALL, 5))
|
||||
|
||||
content_label = wx.StaticText(panel, label=_("Content"))
|
||||
field_sizer.Add(content_label, wx.SizerFlags().Center().Border(wx.ALL, 5))
|
||||
|
||||
content_textctrl = wx.TextCtrl(panel, style=wx.TE_PROCESS_ENTER)
|
||||
content_textctrl = wx.TextCtrl(panel, style=wx.TE_PROCESS_ENTER | wx.TE_MULTILINE, size=(200, 30))
|
||||
if i <= len(fields):
|
||||
content_textctrl.SetValue(fields[i-1][1])
|
||||
log.debug(f"content: {fields[i-1][1]}")
|
||||
field_sizer.Add(content_textctrl, wx.SizerFlags().Expand().Border(wx.ALL, 5))
|
||||
sizer.Add(field_sizer, 0, wx.CENTER)
|
||||
self.fields.append((label_textctrl, content_textctrl))
|
||||
|
||||
self.locked = wx.CheckBox(panel, label=_("Private account"))
|
||||
self.locked.SetValue(locked)
|
||||
self.bot = wx.CheckBox(panel, label=_("Bot account"))
|
||||
self.bot.SetValue(bot)
|
||||
self.discoverable = wx.CheckBox(panel, label=_("Discoverable account"))
|
||||
self.discoverable.SetValue(discoverable)
|
||||
sizer.Add(self.locked, wx.SizerFlags().Expand().Border(wx.ALL, 5))
|
||||
sizer.Add(self.bot, wx.SizerFlags().Expand().Border(wx.ALL, 5))
|
||||
sizer.Add(self.discoverable, wx.SizerFlags().Expand().Border(wx.ALL, 5))
|
||||
|
||||
ok = wx.Button(panel, wx.ID_OK, _(u"&OK"))
|
||||
ok.SetDefault()
|
||||
cancel = wx.Button(panel, wx.ID_CANCEL, _("&Close"))
|
||||
self.SetEscapeId(cancel.GetId())
|
||||
|
||||
# manage sizers
|
||||
name_sizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
name_sizer.Add(display_name_label, wx.SizerFlags().Center())
|
||||
name_sizer.Add(self.display_name, wx.SizerFlags().Center())
|
||||
sizer.Add(name_sizer, wx.CENTER)
|
||||
|
||||
bio_sizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
bio_sizer.Add(bio_label, wx.SizerFlags().Center())
|
||||
bio_sizer.Add(self.bio, wx.SizerFlags().Center())
|
||||
sizer.Add(bio_sizer, wx.CENTER)
|
||||
|
||||
header_sizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
header_sizer.Add(header_label, wx.SizerFlags().Center())
|
||||
header_sizer.Add(self.header_image, wx.SizerFlags().Center())
|
||||
header_sizer.Add(self.change_header, wx.SizerFlags().Center())
|
||||
sizer.Add(header_sizer, wx.CENTER)
|
||||
|
||||
avatar_sizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
avatar_sizer.Add(avatar_label, wx.SizerFlags().Center())
|
||||
avatar_sizer.Add(self.avatar_image, wx.SizerFlags().Center())
|
||||
avatar_sizer.Add(self.change_avatar, wx.SizerFlags().Center())
|
||||
sizer.Add(avatar_sizer, wx.CENTER)
|
||||
|
||||
action_sizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
action_sizer.Add(ok, wx.SizerFlags().Center())
|
||||
action_sizer.Add(cancel, wx.SizerFlags().Center())
|
||||
sizer.Add(action_sizer, wx.CENTER)
|
||||
panel.SetSizer(sizer)
|
||||
panel.Fit()
|
||||
sizer.Fit(self)
|
||||
self.Center()
|
||||
|
||||
# manage events
|
||||
ok.Bind(wx.EVT_BUTTON, self.on_ok)
|
||||
@ -151,7 +152,10 @@ class UpdateProfileDialog(wx.Dialog):
|
||||
'note': self.bio.GetValue(),
|
||||
'header': self.header,
|
||||
'avatar': self.avatar,
|
||||
'fields': [(label.GetValue(), content.GetValue()) for label, content in self.fields if label.GetValue() and content.GetValue()]
|
||||
'fields': [(label.GetValue(), content.GetValue()) for label, content in self.fields if label.GetValue() and content.GetValue()],
|
||||
'locked': self.locked.GetValue(),
|
||||
'bot': self.bot.GetValue(),
|
||||
'discoverable': self.discoverable.GetValue(),
|
||||
}
|
||||
self.EndModal(wx.ID_OK)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user