Skip to content

Commit

Permalink
Fix timepicker controls
Browse files Browse the repository at this point in the history
  • Loading branch information
facelessuser committed Dec 17, 2024
1 parent 657ae18 commit d0eb05f
Show file tree
Hide file tree
Showing 9 changed files with 17,818 additions and 17,714 deletions.
6 changes: 6 additions & 0 deletions docs/src/markdown/about/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 4.21.2

- **FIX**: Use a different wxPython time control on macOS as the previous one would crash on the M series chips.
- **FIX**: Fix an issue with local time to UTC conversion.
- **FIX**: Fix an issue where created time comparisons was actually being done on modified times.

## 4.21.1

- **FIX**: Fix issue with `re` replace in Python 3.12 and Python 3.13.
Expand Down
35,408 changes: 17,780 additions & 17,628 deletions gui.fbp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion rummage/lib/__meta__.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def parse_version(ver):


# (major, minor, micro, release type, pre-release build, post-release build, development-release)
__version_info__ = Version(4, 21, 1, 'final')
__version_info__ = Version(4, 21, 2, 'final')
__version__ = __version_info__._get_canonical()
__app__ = "Rummage"
__status__ = __version_info__[3]
Expand Down
65 changes: 2 additions & 63 deletions rummage/lib/gui/controls/time_picker.py
Original file line number Diff line number Diff line change
@@ -1,63 +1,2 @@
"""Custom time picker that allows us control of the control's color."""
from wx.lib.masked import TimeCtrl
from .. util.colors import Color
from .. import util
import wx


class TimePickerCtrl(TimeCtrl):
"""Time picker that we can force proper colors on."""

def __init__(self, parent, *args, **kwargs):
"""
Initialize.
Create a temporary text control so we can get proper
background and foreground colors.
"""

ctrl = wx.TextCtrl(parent)
self._bg = ctrl.GetBackgroundColour().GetRGB()
bg = Color('red')
bg.mix(Color.from_wxbgr(ctrl.GetBackgroundColour().GetRGBA()), 0.5, in_place=True)
self._error_bg = wx.Colour(bg.to_wxbgr(alpha=False)).GetRGB()
super().__init__(parent, *args, **kwargs)
font = ctrl.GetFont()
self.SetFont(wx.Font(font))
ctrl.Destroy()
self.Bind(wx.EVT_SYS_COLOUR_CHANGED, self.on_color_change)

def on_color_change(self, event):
"""Handle color change."""

self.set_error_bg_color()

if event:
event.Skip()

def set_error_bg_color(self):
"""Set error background color."""

value = self.GetValue()
ctrl = wx.TextCtrl(self.GetParent())
self._bg = ctrl.GetBackgroundColour().GetRGB()
bg = Color('red')
bg.mix(Color.from_wxbgr(ctrl.GetBackgroundColour().GetRGBA()), 0.5, in_place=True)
self._invalidBackgroundColour = wx.Colour(bg.to_wxbgr(alpha=False))
ctrl.Destroy()
self.SetParameters()
self.SetValue(value)

def SetParameters(self, **kwargs):
"""Force the colors we want."""

if 'oob_color' in kwargs:
del kwargs['oob_color']
maskededit_kwargs = super().SetParameters(**kwargs)
if util.platform() != "macos" or not util.MAC_OLD:
maskededit_kwargs['emptyBackgroundColour'] = wx.NullColour
maskededit_kwargs['validBackgroundColour'] = wx.NullColour
maskededit_kwargs['foregroundColour'] = wx.NullColour
maskededit_kwargs['signedForegroundColour'] = wx.NullColour
maskededit_kwargs['invalidBackgroundColour'] = wx.Colour(self._error_bg)
return maskededit_kwargs
"""Time Picker."""
from wx.adv import TimePickerCtrl
2 changes: 1 addition & 1 deletion rummage/lib/gui/data/docs/.dochash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ff7edfad8ee90d27d9cbc711c759338c
9b4772bddbd9dc16a26766bcfa48575b
6 changes: 6 additions & 0 deletions rummage/lib/gui/data/docs/about/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@

<!-- Table of Content (Don't show for static sites) -->
<h1 id="changelog">Changelog</h1>
<h2 id="4212">4.21.2</h2>
<ul>
<li><strong>FIX</strong>: Use a different wxPython time control on macOS as the previous one would crash on the M series chips.</li>
<li><strong>FIX</strong>: Fix an issue with local time to UTC conversion.</li>
<li><strong>FIX</strong>: Fix an issue where created time comparisons was actually being done on modified times.</li>
</ul>
<h2 id="4211">4.21.1</h2>
<ul>
<li><strong>FIX</strong>: Fix issue with <code>re</code> replace in Python 3.12 and Python 3.13.</li>
Expand Down
29 changes: 18 additions & 11 deletions rummage/lib/gui/dialogs/rummage_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
"""
import platform
import wx
import wx.adv
import threading
Expand Down Expand Up @@ -127,12 +128,12 @@ def setup_datepicker(obj, key):
obj.SetValue(day)


def setup_timepicker(obj, spin, key):
def setup_timepicker(obj, key):
"""Setup time control object."""

t = Settings.get_search_setting(key, wx.DateTime.Now().Format("%H:%M:%S"))
obj.SetValue(t)
obj.BindSpinButton(spin)
dt = wx.DateTime()
dt.ParseFormat(Settings.get_search_setting(key, wx.DateTime.Now().Format("%H:%M:%S")), "%H:%M:%S")
obj.SetValue(dt)


def setup_autocomplete_combo(obj, key, load_last=False, changed_callback=None, default=None, autocomplete=None):
Expand Down Expand Up @@ -861,8 +862,8 @@ def setup_inputs(self):

setup_datepicker(self.m_modified_date_picker, "modified_date_string")
setup_datepicker(self.m_created_date_picker, "created_date_string")
setup_timepicker(self.m_modified_time_picker, self.m_modified_spin, "modified_time_string")
setup_timepicker(self.m_created_time_picker, self.m_created_spin, "created_time_string")
setup_timepicker(self.m_modified_time_picker, "modified_time_string")
setup_timepicker(self.m_created_time_picker, "created_time_string")
setup_autocomplete_combo(
self.m_searchin_text,
"target",
Expand Down Expand Up @@ -1419,15 +1420,15 @@ def set_arguments(self, chain, replace):
LIMIT_COMPARE[cmp_modified],
rumcore.util.local_time_to_epoch_timestamp(
self.m_modified_date_picker.GetValue().Format("%m/%d/%Y"),
self.m_modified_time_picker.GetValue()
self.m_modified_time_picker.GetValue().Format("%H:%M:%S")
)
)
if cmp_created:
args.created_compare = (
LIMIT_COMPARE[cmp_created],
rumcore.util.local_time_to_epoch_timestamp(
self.m_modified_date_picker.GetValue().Format("%m/%d/%Y"),
self.m_modified_time_picker.GetValue()
self.m_created_date_picker.GetValue().Format("%m/%d/%Y"),
self.m_created_time_picker.GetValue().Format("%H:%M:%S")
)
)
else:
Expand Down Expand Up @@ -1567,12 +1568,18 @@ def save_history(self, args, replace, chain):
if eng_mod != "on any":
strings += [
("modified_date_string", self.m_modified_date_picker.GetValue().Format("%m/%d/%Y")),
("modified_time_string", self.m_modified_time_picker.GetValue())
(
"modified_time_string",
self.m_modified_time_picker.GetValue().Format("%H:%M:%S")
)
]
if eng_cre != "on any":
strings += [
("created_date_string", self.m_created_date_picker.GetValue().Format("%m/%d/%Y")),
("created_time_string", self.m_created_time_picker.GetValue())
(
"created_time_string",
self.m_created_time_picker.GetValue().Format("%H:%M:%S")
)
]

Settings.add_search_settings(history, toggles, strings)
Expand Down
12 changes: 3 additions & 9 deletions rummage/lib/gui/gui.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

###########################################################################
## Python code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
## Python code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6)
## http://www.wxformbuilder.org/
##
## PLEASE DO *NOT* EDIT THIS FILE!
Expand Down Expand Up @@ -291,12 +291,9 @@ def __init__( self, parent ):
self.m_modified_date_picker = DatePicker(self.m_limit_panel, wx.ID_ANY)
gbSizer3.Add( self.m_modified_date_picker, wx.GBPosition( 1, 2 ), wx.GBSpan( 1, 1 ), wx.ALL|wx.EXPAND, 5 )

self.m_modified_time_picker = TimePickerCtrl(self.m_limit_panel, wx.ID_ANY, style=wx.TE_PROCESS_TAB, fmt24hr=True, useFixedWidthFont=False)
self.m_modified_time_picker = TimePickerCtrl(self.m_limit_panel, wx.ID_ANY)
gbSizer3.Add( self.m_modified_time_picker, wx.GBPosition( 1, 3 ), wx.GBSpan( 1, 1 ), wx.BOTTOM|wx.LEFT|wx.TOP|wx.ALIGN_CENTER_VERTICAL, 5 )

self.m_modified_spin = wx.SpinButton( self.m_limit_panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.SP_WRAP )
gbSizer3.Add( self.m_modified_spin, wx.GBPosition( 1, 4 ), wx.GBSpan( 1, 1 ), wx.TOP|wx.BOTTOM|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5 )

self.m_filematch_label = wx.StaticText( self.m_limit_panel, wx.ID_ANY, u"Files which match", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_filematch_label.Wrap( -1 )

Expand All @@ -321,12 +318,9 @@ def __init__( self, parent ):
self.m_created_date_picker = DatePicker(self.m_limit_panel, wx.ID_ANY)
gbSizer3.Add( self.m_created_date_picker, wx.GBPosition( 2, 2 ), wx.GBSpan( 1, 1 ), wx.ALL|wx.EXPAND, 5 )

self.m_created_time_picker = TimePickerCtrl(self.m_limit_panel, wx.ID_ANY, style=wx.TE_PROCESS_TAB, fmt24hr=True, useFixedWidthFont=False)
self.m_created_time_picker = TimePickerCtrl(self.m_limit_panel, wx.ID_ANY)
gbSizer3.Add( self.m_created_time_picker, wx.GBPosition( 2, 3 ), wx.GBSpan( 1, 1 ), wx.BOTTOM|wx.LEFT|wx.TOP|wx.ALIGN_CENTER_VERTICAL, 5 )

self.m_created_spin = wx.SpinButton( self.m_limit_panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.SP_WRAP )
gbSizer3.Add( self.m_created_spin, wx.GBPosition( 2, 4 ), wx.GBSpan( 1, 1 ), wx.TOP|wx.BOTTOM|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5 )

self.m_staticline41 = wx.StaticLine( self.m_limit_panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_VERTICAL )
gbSizer3.Add( self.m_staticline41, wx.GBPosition( 0, 5 ), wx.GBSpan( 3, 1 ), wx.ALL|wx.EXPAND|wx.RESERVE_SPACE_EVEN_IF_HIDDEN, 5 )

Expand Down
2 changes: 1 addition & 1 deletion rummage/lib/rumcore/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ def local_time_to_epoch_timestamp(date, time):

d = date.split("/")
t = time.split(":")
dt = datetime(int(d[2]), int(d[0]), int(d[1]), int(t[0]), int(t[1]), int(t[2]), 0, UTC)
dt = datetime(int(d[2]), int(d[0]), int(d[1]), int(t[0]), int(t[1]), int(t[2]), 0).astimezone()
delta = dt - EPOCH
return (delta.microseconds + (delta.seconds + delta.days * 24 * 3600) * 10 ** 6) / 1e6

0 comments on commit d0eb05f

Please sign in to comment.