mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-07-18 06:06:06 -04:00
Added an alias manager dialog in the application menu
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import wx
|
||||
import gettext
|
||||
from . import baseDialog
|
||||
|
||||
class addAliasDialog(baseDialog.BaseWXDialog):
|
||||
@@ -34,3 +35,61 @@ class addAliasDialog(baseDialog.BaseWXDialog):
|
||||
def get_user(self):
|
||||
return (self.cb.GetValue(), self.alias.GetValue())
|
||||
|
||||
class userAliasEditorDialog(wx.Dialog):
|
||||
def __init__(self, *args, **kwds):
|
||||
super(userAliasEditorDialog, self).__init__(parent=None)
|
||||
self.SetTitle(_("Edit user aliases"))
|
||||
main_sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
userListSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, _("Users")), wx.VERTICAL)
|
||||
main_sizer.Add(userListSizer, 1, wx.EXPAND, 0)
|
||||
self.users = wx.ListBox(self, wx.ID_ANY, choices=[])
|
||||
self.users.Bind(wx.EVT_LISTBOX, self.on_selection_changes)
|
||||
userListSizer.Add(self.users, 0, 0, 0)
|
||||
actionsSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, _("Actions")), wx.HORIZONTAL)
|
||||
main_sizer.Add(actionsSizer, 1, wx.EXPAND, 0)
|
||||
self.add = wx.Button(self, wx.ID_ANY, _("Add alias"))
|
||||
self.add.SetToolTip(_("Adds a new user alias"))
|
||||
actionsSizer.Add(self.add, 0, 0, 0)
|
||||
self.edit = wx.Button(self, wx.ID_ANY, _("Edit"))
|
||||
self.edit.SetToolTip(_("Edit the currently focused user Alias."))
|
||||
self.edit.Enable(False)
|
||||
actionsSizer.Add(self.edit, 0, 0, 0)
|
||||
self.remove = wx.Button(self, wx.ID_ANY, _("Remove"))
|
||||
self.remove.SetToolTip(_("Remove the currently focused user alias."))
|
||||
self.remove.Enable(False)
|
||||
actionsSizer.Add(self.remove, 0, 0, 0)
|
||||
btnSizer = wx.StdDialogButtonSizer()
|
||||
main_sizer.Add(btnSizer, 0, wx.ALIGN_RIGHT | wx.ALL, 4)
|
||||
self.button_CLOSE = wx.Button(self, wx.ID_CLOSE, "")
|
||||
btnSizer.AddButton(self.button_CLOSE)
|
||||
btnSizer.Realize()
|
||||
self.SetSizer(main_sizer)
|
||||
main_sizer.Fit(self)
|
||||
self.SetEscapeId(self.button_CLOSE.GetId())
|
||||
self.Layout()
|
||||
|
||||
def on_selection_changes(self, *args, **kwargs):
|
||||
selection = self.users.GetSelection()
|
||||
if selection == -1:
|
||||
self.enable_action_buttons(False)
|
||||
else:
|
||||
self.enable_action_buttons(True)
|
||||
|
||||
def get_selected_user(self):
|
||||
return self.users.GetStringSelection()
|
||||
|
||||
def remove_alias_dialog(self, *args, **kwargs):
|
||||
dlg = wx.MessageDialog(self, _("Are you sure you want to delete this user alias?"), _("Remove user alias"), wx.YES_NO)
|
||||
if dlg.ShowModal() == wx.ID_YES:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def enable_action_buttons(self, enabled=True):
|
||||
self.edit.Enable(enabled)
|
||||
self.remove.Enable(enabled)
|
||||
|
||||
def edit_alias_dialog(self, title):
|
||||
dlg = wx.TextEntryDialog(self, title, _("User alias"))
|
||||
if dlg.ShowModal() == wx.ID_OK:
|
||||
return dlg.GetValue()
|
@@ -20,6 +20,7 @@ class mainFrame(wx.Frame):
|
||||
self.show_hide = app.Append(wx.ID_ANY, _(u"&Hide window"))
|
||||
self.menuitem_search = app.Append(wx.ID_ANY, _(u"&Search"))
|
||||
self.lists = app.Append(wx.ID_ANY, _(u"&Lists manager"))
|
||||
self.manageAliases = app.Append(wx.ID_ANY, _("Manage user aliases"))
|
||||
self.keystroke_editor = app.Append(wx.ID_ANY, _(u"&Edit keystrokes"))
|
||||
self.account_settings = app.Append(wx.ID_ANY, _(u"Account se&ttings"))
|
||||
self.prefs = app.Append(wx.ID_PREFERENCES, _(u"&Global settings"))
|
||||
|
Reference in New Issue
Block a user