mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2026-05-13 21:37:38 +02:00
Merge next-gen
This commit is contained in:
@@ -2,4 +2,5 @@
|
||||
from .base import basePanel
|
||||
from .conversationList import conversationListPanel
|
||||
from .notifications import notificationsPanel
|
||||
from .user import userPanel
|
||||
from .user import userPanel
|
||||
from .announcements import announcementsPanel
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import wx
|
||||
from multiplatform_widgets import widgets
|
||||
|
||||
class announcementsPanel(wx.Panel):
|
||||
|
||||
def set_focus_function(self, f):
|
||||
self.list.list.Bind(wx.EVT_LIST_ITEM_FOCUSED, f)
|
||||
|
||||
def create_list(self):
|
||||
self.list = widgets.list(self, _("Announcement"), style=wx.LC_REPORT|wx.LC_SINGLE_SEL|wx.LC_VRULES)
|
||||
self.list.set_windows_size(0, 800)
|
||||
self.list.set_size()
|
||||
|
||||
def __init__(self, parent, name):
|
||||
super(announcementsPanel, self).__init__(parent)
|
||||
self.name = name
|
||||
self.type = "baseBuffer"
|
||||
self.sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
self.create_list()
|
||||
self.dismiss = wx.Button(self, -1, _("Dismiss"))
|
||||
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
btnSizer.Add(self.dismiss, 0, wx.ALL, 5)
|
||||
self.sizer.Add(btnSizer, 0, wx.ALL, 5)
|
||||
self.sizer.Add(self.list.list, 1, wx.ALL|wx.EXPAND, 5)
|
||||
self.SetSizer(self.sizer)
|
||||
self.SetClientSize(self.sizer.CalcMin())
|
||||
|
||||
def set_position(self, reversed=False):
|
||||
if reversed == False:
|
||||
self.list.select_item(self.list.get_count()-1)
|
||||
else:
|
||||
self.list.select_item(0)
|
||||
|
||||
def set_focus_in_list(self):
|
||||
self.list.list.SetFocus()
|
||||
@@ -47,7 +47,7 @@ class generalAccount(wx.Panel, baseDialog.BaseWXDialog):
|
||||
self.SetSizer(sizer)
|
||||
|
||||
class templates(wx.Panel, baseDialog.BaseWXDialog):
|
||||
def __init__(self, parent, post_template, conversation_template, person_template):
|
||||
def __init__(self, parent, post_template, conversation_template, person_template, announcement_template):
|
||||
super(templates, self).__init__(parent)
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
self.post = wx.Button(self, wx.ID_ANY, _("Edit template for &posts. Current template: {}").format(post_template))
|
||||
@@ -56,6 +56,8 @@ class templates(wx.Panel, baseDialog.BaseWXDialog):
|
||||
sizer.Add(self.conversation, 0, wx.ALL, 5)
|
||||
self.person = wx.Button(self, wx.ID_ANY, _("Edit template for p&ersons. Current template: {}").format(person_template))
|
||||
sizer.Add(self.person, 0, wx.ALL, 5)
|
||||
self.announcement = wx.Button(self, wx.ID_ANY, _("Edit template for &announcements. Current template: {}").format(announcement_template))
|
||||
sizer.Add(self.announcement, 0, wx.ALL, 5)
|
||||
self.SetSizer(sizer)
|
||||
|
||||
class sound(wx.Panel):
|
||||
@@ -152,8 +154,8 @@ class configurationDialog(baseDialog.BaseWXDialog):
|
||||
self.buffers = other_buffers(self.notebook)
|
||||
self.notebook.AddPage(self.buffers, _(u"Buffers"))
|
||||
|
||||
def create_templates(self, post_template, conversation_template, person_template):
|
||||
self.templates = templates(self.notebook, post_template=post_template, conversation_template=conversation_template, person_template=person_template)
|
||||
def create_templates(self, post_template, conversation_template, person_template, announcement_template):
|
||||
self.templates = templates(self.notebook, post_template=post_template, conversation_template=conversation_template, person_template=person_template, announcement_template=announcement_template)
|
||||
self.notebook.AddPage(self.templates, _("Templates"))
|
||||
|
||||
def create_sound(self, output_devices, input_devices, soundpacks):
|
||||
|
||||
@@ -2,11 +2,43 @@
|
||||
import wx
|
||||
import application
|
||||
|
||||
class BoostDialog(wx.Dialog):
|
||||
def __init__(self):
|
||||
super(BoostDialog, self).__init__(None, title=_("Boost"))
|
||||
p = wx.Panel(self)
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
lbl = wx.StaticText(p, wx.ID_ANY, _("What would you like to do with this post?"))
|
||||
sizer.Add(lbl, 0, wx.ALL, 10)
|
||||
|
||||
btn_sizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
self.btn_boost = wx.Button(p, wx.ID_ANY, _("Boost"))
|
||||
self.btn_quote = wx.Button(p, wx.ID_ANY, _("Quote"))
|
||||
self.btn_cancel = wx.Button(p, wx.ID_CANCEL, _("Cancel"))
|
||||
|
||||
btn_sizer.Add(self.btn_boost, 0, wx.ALL, 5)
|
||||
btn_sizer.Add(self.btn_quote, 0, wx.ALL, 5)
|
||||
btn_sizer.Add(self.btn_cancel, 0, wx.ALL, 5)
|
||||
|
||||
sizer.Add(btn_sizer, 0, wx.ALIGN_CENTER)
|
||||
p.SetSizer(sizer)
|
||||
sizer.Fit(self)
|
||||
|
||||
self.btn_boost.Bind(wx.EVT_BUTTON, self.on_boost)
|
||||
self.btn_quote.Bind(wx.EVT_BUTTON, self.on_quote)
|
||||
self.result = 0
|
||||
|
||||
def on_boost(self, event):
|
||||
self.result = 1
|
||||
self.EndModal(wx.ID_OK)
|
||||
|
||||
def on_quote(self, event):
|
||||
self.result = 2
|
||||
self.EndModal(wx.ID_OK)
|
||||
|
||||
def boost_question():
|
||||
result = False
|
||||
dlg = wx.MessageDialog(None, _("Would you like to share this post?"), _("Boost"), wx.YES_NO|wx.ICON_QUESTION)
|
||||
if dlg.ShowModal() == wx.ID_YES:
|
||||
result = True
|
||||
dlg = BoostDialog()
|
||||
dlg.ShowModal()
|
||||
result = dlg.result
|
||||
dlg.Destroy()
|
||||
return result
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class FilterKeywordPanel(wx.Panel):
|
||||
button_sizer.Add(self.add_button, 0, wx.RIGHT, 5)
|
||||
button_sizer.Add(self.remove_button, 0)
|
||||
main_sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
main_sizer.Add(wx.StaticText(self, label=_("Palabras clave a filtrar:")), 0, wx.BOTTOM, 5)
|
||||
main_sizer.Add(wx.StaticText(self, label=_("Keywords to filter:")), 0, wx.BOTTOM, 5)
|
||||
main_sizer.Add(list_panel, 1, wx.EXPAND | wx.BOTTOM, 5)
|
||||
main_sizer.Add(input_sizer, 0, wx.EXPAND | wx.BOTTOM, 5)
|
||||
main_sizer.Add(button_sizer, 0, wx.ALIGN_RIGHT)
|
||||
|
||||
@@ -6,6 +6,8 @@ class base(wx.Menu):
|
||||
super(base, self).__init__()
|
||||
self.boost = wx.MenuItem(self, wx.ID_ANY, _("&Boost"))
|
||||
self.Append(self.boost)
|
||||
self.quote = wx.MenuItem(self, wx.ID_ANY, _("&Quote"))
|
||||
self.Append(self.quote)
|
||||
self.reply = wx.MenuItem(self, wx.ID_ANY, _(u"Re&ply"))
|
||||
self.Append(self.reply)
|
||||
self.edit = wx.MenuItem(self, wx.ID_ANY, _(u"&Edit"))
|
||||
@@ -14,6 +16,8 @@ class base(wx.Menu):
|
||||
self.Append(self.fav)
|
||||
self.unfav = wx.MenuItem(self, wx.ID_ANY, _(u"R&emove from favorites"))
|
||||
self.Append(self.unfav)
|
||||
self.mute = wx.MenuItem(self, wx.ID_ANY, _(u"Mute/Unmute conversation"))
|
||||
self.Append(self.mute)
|
||||
self.openUrl = wx.MenuItem(self, wx.ID_ANY, _("&Open URL"))
|
||||
self.Append(self.openUrl)
|
||||
self.openInBrowser = wx.MenuItem(self, wx.ID_ANY, _(u"&Open in instance"))
|
||||
@@ -36,6 +40,8 @@ class notification(wx.Menu):
|
||||
if item in valid_types:
|
||||
self.boost = wx.MenuItem(self, wx.ID_ANY, _("&Boost"))
|
||||
self.Append(self.boost)
|
||||
self.quote = wx.MenuItem(self, wx.ID_ANY, _("&Quote"))
|
||||
self.Append(self.quote)
|
||||
self.reply = wx.MenuItem(self, wx.ID_ANY, _(u"Re&ply"))
|
||||
self.Append(self.reply)
|
||||
self.edit = wx.MenuItem(self, wx.ID_ANY, _(u"&Edit"))
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import wx
|
||||
import wx.adv
|
||||
import datetime
|
||||
|
||||
class Post(wx.Dialog):
|
||||
def __init__(self, caption=_("Post"), text="", languages=[], *args, **kwds):
|
||||
@@ -60,6 +62,28 @@ class Post(wx.Dialog):
|
||||
self.sensitive.SetValue(False)
|
||||
self.sensitive.Bind(wx.EVT_CHECKBOX, self.on_sensitivity_changed)
|
||||
main_sizer.Add(self.sensitive, 0, wx.ALL, 5)
|
||||
|
||||
# Scheduled post section
|
||||
scheduled_box = wx.BoxSizer(wx.HORIZONTAL)
|
||||
self.scheduled = wx.CheckBox(self, wx.ID_ANY, _("Schedule &post"))
|
||||
self.scheduled.SetValue(False)
|
||||
self.scheduled.Bind(wx.EVT_CHECKBOX, self.on_schedule_changed)
|
||||
scheduled_box.Add(self.scheduled, 0, wx.ALL, 5)
|
||||
|
||||
# Default to now + 6 minutes to be safe for the 5 minute minimum
|
||||
future_dt = wx.DateTime.Now()
|
||||
future_dt.Add(wx.TimeSpan(0, 6, 0, 0))
|
||||
|
||||
self.date_picker = wx.adv.DatePickerCtrl(self, wx.ID_ANY, dt=future_dt, style=wx.adv.DP_DROPDOWN | wx.adv.DP_SHOWCENTURY)
|
||||
self.date_picker.Enable(False)
|
||||
scheduled_box.Add(self.date_picker, 0, wx.ALL, 5)
|
||||
|
||||
self.time_picker = wx.adv.TimePickerCtrl(self, wx.ID_ANY, dt=future_dt)
|
||||
self.time_picker.Enable(False)
|
||||
scheduled_box.Add(self.time_picker, 0, wx.ALL, 5)
|
||||
|
||||
main_sizer.Add(scheduled_box, 0, wx.ALL, 5)
|
||||
|
||||
spoiler_box = wx.BoxSizer(wx.HORIZONTAL)
|
||||
spoiler_label = wx.StaticText(self, wx.ID_ANY, _("Content warning"))
|
||||
self.spoiler = wx.TextCtrl(self, wx.ID_ANY)
|
||||
@@ -80,8 +104,9 @@ class Post(wx.Dialog):
|
||||
text_actions_sizer.Add(self.translate, 0, 0, 0)
|
||||
btn_sizer = wx.StdDialogButtonSizer()
|
||||
main_sizer.Add(btn_sizer, 0, wx.ALIGN_RIGHT | wx.ALL, 4)
|
||||
self.send = wx.Button(self, wx.ID_OK, "")
|
||||
self.send = wx.Button(self, wx.ID_ANY, _("&Send"))
|
||||
self.send.SetDefault()
|
||||
self.send.Bind(wx.EVT_BUTTON, self.validate_and_send)
|
||||
btn_sizer.AddButton(self.send)
|
||||
self.close = wx.Button(self, wx.ID_CLOSE, "")
|
||||
btn_sizer.AddButton(self.close)
|
||||
@@ -95,13 +120,50 @@ class Post(wx.Dialog):
|
||||
""" Allows to react to certain keyboard events from the text control. """
|
||||
shift=event.ShiftDown()
|
||||
if event.GetKeyCode() == wx.WXK_RETURN and shift==False and hasattr(self,'send'):
|
||||
self.EndModal(wx.ID_OK)
|
||||
self.validate_and_send()
|
||||
else:
|
||||
event.Skip()
|
||||
|
||||
def validate_and_send(self, event=None):
|
||||
scheduled_at = self.get_scheduled_at()
|
||||
if scheduled_at:
|
||||
min_time = datetime.datetime.now() + datetime.timedelta(minutes=5)
|
||||
if scheduled_at < min_time:
|
||||
wx.MessageDialog(self,
|
||||
_("Scheduled posts must be set at least 5 minutes in the future. Please adjust the time."),
|
||||
_("Invalid scheduled time"),
|
||||
wx.ICON_ERROR | wx.OK).ShowModal()
|
||||
return
|
||||
self.EndModal(wx.ID_OK)
|
||||
|
||||
def on_sensitivity_changed(self, *args, **kwargs):
|
||||
self.spoiler.Enable(self.sensitive.GetValue())
|
||||
|
||||
def on_schedule_changed(self, *args, **kwargs):
|
||||
enabled = self.scheduled.GetValue()
|
||||
self.date_picker.Enable(enabled)
|
||||
self.time_picker.Enable(enabled)
|
||||
|
||||
def get_scheduled_at(self):
|
||||
if not self.scheduled.GetValue():
|
||||
return None
|
||||
|
||||
# Get date from date picker
|
||||
wx_date = self.date_picker.GetValue()
|
||||
# Get time from time picker
|
||||
wx_time = self.time_picker.GetValue()
|
||||
|
||||
# Combine into a python datetime object
|
||||
dt = datetime.datetime(
|
||||
wx_date.GetYear(),
|
||||
wx_date.GetMonth() + 1, # wx.DateTime months are 0-11
|
||||
wx_date.GetDay(),
|
||||
wx_time.GetHour(),
|
||||
wx_time.GetMinute(),
|
||||
wx_time.GetSecond()
|
||||
)
|
||||
return dt
|
||||
|
||||
def set_title(self, chars):
|
||||
self.SetTitle(_("Post - {} characters").format(chars))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user