hydrus/include/ClientGUIHoverFrames.py

1074 lines
41 KiB
Python
Raw Normal View History

2015-06-17 20:01:41 +00:00
import ClientConstants as CC
2015-08-26 21:18:39 +00:00
import ClientData
2018-03-28 21:55:58 +00:00
import ClientDragDrop
2015-06-17 20:01:41 +00:00
import ClientGUICanvas
import ClientGUICommon
2017-04-12 21:46:46 +00:00
import ClientGUIDialogs
2017-02-01 21:11:17 +00:00
import ClientGUIListBoxes
2017-04-19 20:58:30 +00:00
import ClientGUITopLevelWindows
import ClientGUIScrolledPanelsEdit
import ClientGUIScrolledPanelsManagement
2017-05-17 21:53:02 +00:00
import ClientMedia
2015-06-17 20:01:41 +00:00
import HydrusConstants as HC
import HydrusData
2017-05-10 21:33:58 +00:00
import HydrusGlobals as HG
2017-04-19 20:58:30 +00:00
import HydrusSerialisable
2017-04-26 21:58:12 +00:00
import urlparse
2015-06-17 20:01:41 +00:00
import os
import wx
2018-01-03 22:37:30 +00:00
import wx.adv
2015-06-17 20:01:41 +00:00
class FullscreenHoverFrame( wx.Frame ):
def __init__( self, parent, canvas_key ):
if HC.PLATFORM_WINDOWS:
border_style = wx.BORDER_RAISED
else:
border_style = wx.BORDER_SIMPLE
wx.Frame.__init__( self, parent, style = wx.FRAME_TOOL_WINDOW | wx.FRAME_NO_TASKBAR | wx.FRAME_FLOAT_ON_PARENT | border_style )
self._canvas_key = canvas_key
self._current_media = None
2015-12-02 22:32:18 +00:00
self._last_ideal_position = None
2015-06-17 20:01:41 +00:00
2016-08-10 19:04:08 +00:00
self.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_FRAMEBK ) )
2018-01-03 22:37:30 +00:00
self.SetCursor( wx.Cursor( wx.CURSOR_ARROW ) )
2015-06-17 20:01:41 +00:00
2016-12-07 22:12:52 +00:00
self._hide_until = None
2017-05-10 21:33:58 +00:00
HG.client_controller.sub( self, 'SetDisplayMedia', 'canvas_new_display_media' )
2015-06-17 20:01:41 +00:00
2018-01-03 22:37:30 +00:00
HG.client_controller.gui.RegisterUIUpdateWindow( self )
2015-06-17 20:01:41 +00:00
def _GetIdealSizeAndPosition( self ):
raise NotImplementedError()
def _SizeAndPosition( self ):
2018-05-30 20:13:21 +00:00
if self.GetParent().IsShown():
2017-05-17 21:53:02 +00:00
2017-05-24 20:28:24 +00:00
( should_resize, my_ideal_size, my_ideal_position ) = self._GetIdealSizeAndPosition()
2017-05-17 21:53:02 +00:00
2017-05-24 20:28:24 +00:00
if should_resize:
self.Fit()
self.SetSize( my_ideal_size )
2015-06-17 20:01:41 +00:00
2017-05-24 20:28:24 +00:00
self.SetPosition( my_ideal_position )
2015-06-17 20:01:41 +00:00
2016-12-07 22:12:52 +00:00
2015-06-17 20:01:41 +00:00
def SetDisplayMedia( self, canvas_key, media ):
if canvas_key == self._canvas_key:
self._current_media = media
2018-01-03 22:37:30 +00:00
def TIMERUIUpdate( self ):
new_options = HG.client_controller.new_options
2015-06-17 20:01:41 +00:00
2018-01-03 22:37:30 +00:00
if new_options.GetBoolean( 'always_show_hover_windows' ):
2015-06-17 20:01:41 +00:00
2018-01-03 22:37:30 +00:00
self._SizeAndPosition()
2017-09-13 20:50:41 +00:00
2018-01-03 22:37:30 +00:00
self.Show()
2017-09-13 20:50:41 +00:00
2018-01-03 22:37:30 +00:00
return
2016-12-07 22:12:52 +00:00
2018-01-03 22:37:30 +00:00
if self._hide_until is not None:
if HydrusData.TimeHasPassed( self._hide_until ):
2015-06-17 20:01:41 +00:00
2018-01-03 22:37:30 +00:00
self._hide_until = None
2015-06-17 20:01:41 +00:00
2015-11-18 22:44:07 +00:00
else:
2015-06-17 20:01:41 +00:00
2018-01-03 22:37:30 +00:00
return
2015-11-18 22:44:07 +00:00
2018-01-03 22:37:30 +00:00
2018-05-30 20:13:21 +00:00
if self._current_media is None or not self.GetParent().IsShown():
2018-01-03 22:37:30 +00:00
2018-01-17 22:52:10 +00:00
if self.IsShown():
if HG.hover_window_report_mode:
HydrusData.ShowText( repr( self ) + ' - hiding because nothing to show or parent hidden.' )
self.Hide()
2018-01-03 22:37:30 +00:00
else:
( mouse_x, mouse_y ) = wx.GetMousePosition()
( my_width, my_height ) = self.GetSize()
( should_resize, ( my_ideal_width, my_ideal_height ), ( my_ideal_x, my_ideal_y ) ) = self._GetIdealSizeAndPosition()
if my_ideal_width == -1:
2015-11-18 22:44:07 +00:00
2018-01-03 22:37:30 +00:00
my_ideal_width = max( my_width, 50 )
2015-11-18 22:44:07 +00:00
2018-01-03 22:37:30 +00:00
if my_ideal_height == -1:
2015-11-18 22:44:07 +00:00
2018-01-03 22:37:30 +00:00
my_ideal_height = max( my_height, 50 )
2015-06-17 20:01:41 +00:00
2018-01-03 22:37:30 +00:00
( my_x, my_y ) = self.GetPosition()
in_ideal_x = my_ideal_x <= mouse_x and mouse_x <= my_ideal_x + my_ideal_width
in_ideal_y = my_ideal_y <= mouse_y and mouse_y <= my_ideal_y + my_ideal_height
in_actual_x = my_x <= mouse_x and mouse_x <= my_x + my_width
in_actual_y = my_y <= mouse_y and mouse_y <= my_y + my_height
# we test both ideal and actual here because setposition is not always honoured by the OS
# for instance, in Linux on a fullscreen view, the top taskbar is hidden, but when hover window is shown, it takes focus and causes taskbar to reappear
# the reappearance shuffles the screen coordinates down a bit so the hover sits +20px y despite wanting to be lined up with the underlying fullscreen viewer
# wew lad
in_position = ( in_ideal_x or in_actual_x ) and ( in_ideal_y or in_actual_y )
menu_open = HG.client_controller.MenuIsOpen()
dialog_open = False
tlps = wx.GetTopLevelWindows()
for tlp in tlps:
2015-11-18 22:44:07 +00:00
2018-01-03 22:37:30 +00:00
if isinstance( tlp, wx.Dialog ):
2015-11-18 22:44:07 +00:00
2018-01-03 22:37:30 +00:00
dialog_open = True
2015-11-25 22:00:57 +00:00
2015-11-18 22:44:07 +00:00
2018-01-03 22:37:30 +00:00
mime = self._current_media.GetMime()
2015-11-18 22:44:07 +00:00
2018-01-03 22:37:30 +00:00
mouse_is_over_interactable_media = mime == HC.APPLICATION_FLASH and self.GetParent().MouseIsOverMedia()
2015-11-18 22:44:07 +00:00
2018-01-03 22:37:30 +00:00
mouse_is_near_animation_bar = self.GetParent().MouseIsNearAnimationBar()
2015-11-18 22:44:07 +00:00
2018-01-03 22:37:30 +00:00
mouse_is_over_something_important = mouse_is_over_interactable_media or mouse_is_near_animation_bar
2015-11-18 22:44:07 +00:00
2018-01-03 22:37:30 +00:00
focus_is_good = ClientGUICommon.TLPHasFocus( self ) or ClientGUICommon.TLPHasFocus( self.GetParent() )
2015-06-17 20:01:41 +00:00
2018-01-03 22:37:30 +00:00
ready_to_show = in_position and not mouse_is_over_something_important and focus_is_good and not dialog_open and not menu_open
ready_to_hide = not menu_open and ( not in_position or dialog_open or not focus_is_good )
2018-01-17 22:52:10 +00:00
def get_logic_report_string():
tuples = []
tuples.append( ( 'in position: ', in_position ) )
tuples.append( ( 'menu open: ', menu_open ) )
tuples.append( ( 'dialog open: ', dialog_open ) )
tuples.append( ( 'mouse over interactable media: ', mouse_is_over_interactable_media ) )
tuples.append( ( 'mouse near animation bar: ', mouse_is_near_animation_bar ) )
tuples.append( ( 'focus is good: ', focus_is_good ) )
message = os.linesep * 2 + os.linesep.join( ( a + str( b ) for ( a, b ) in tuples ) ) + os.linesep
return message
2018-01-03 22:37:30 +00:00
if ready_to_show:
self._SizeAndPosition()
2018-01-17 22:52:10 +00:00
if not self.IsShown():
if HG.hover_window_report_mode:
HydrusData.ShowText( repr( self ) + ' - showing.' + get_logic_report_string() )
self.Show()
2018-01-03 22:37:30 +00:00
elif ready_to_hide:
2018-01-17 22:52:10 +00:00
if self.IsShown():
if HG.hover_window_report_mode:
HydrusData.ShowText( repr( self ) + ' - hiding.' + get_logic_report_string() )
self.Hide()
2018-01-03 22:37:30 +00:00
2015-06-17 20:01:41 +00:00
2017-03-29 19:39:34 +00:00
class FullscreenHoverFrameTop( FullscreenHoverFrame ):
2015-06-17 20:01:41 +00:00
def __init__( self, parent, canvas_key ):
FullscreenHoverFrame.__init__( self, parent, canvas_key )
self._current_zoom = 1.0
self._current_index_string = ''
2017-03-29 19:39:34 +00:00
self._top_hbox = wx.BoxSizer( wx.HORIZONTAL )
2017-04-19 20:58:30 +00:00
self._title_text = ClientGUICommon.BetterStaticText( self, 'title' )
self._info_text = ClientGUICommon.BetterStaticText( self, 'info' )
2017-05-17 21:53:02 +00:00
self._additional_info_text = ClientGUICommon.BetterStaticText( self, '', style = wx.ALIGN_CENTER )
2017-03-29 19:39:34 +00:00
self._button_hbox = wx.BoxSizer( wx.HORIZONTAL )
self._PopulateLeftButtons()
2018-01-03 22:37:30 +00:00
self._top_hbox.Add( ( 20, 20 ), CC.FLAGS_EXPAND_BOTH_WAYS )
2017-03-29 19:39:34 +00:00
self._PopulateCenterButtons()
2018-01-03 22:37:30 +00:00
self._top_hbox.Add( ( 20, 20 ), CC.FLAGS_EXPAND_BOTH_WAYS )
2017-03-29 19:39:34 +00:00
self._PopulateRightButtons()
2015-06-17 20:01:41 +00:00
vbox = wx.BoxSizer( wx.VERTICAL )
2018-01-03 22:37:30 +00:00
vbox.Add( self._top_hbox, CC.FLAGS_EXPAND_PERPENDICULAR )
vbox.Add( self._title_text, CC.FLAGS_CENTER )
vbox.Add( self._info_text, CC.FLAGS_CENTER )
vbox.Add( self._additional_info_text, CC.FLAGS_CENTER )
vbox.Add( self._button_hbox, CC.FLAGS_CENTER )
2015-06-17 20:01:41 +00:00
2017-03-29 19:39:34 +00:00
self.SetSizer( vbox )
2015-06-17 20:01:41 +00:00
2017-05-10 21:33:58 +00:00
HG.client_controller.sub( self, 'ProcessContentUpdates', 'content_updates_gui' )
HG.client_controller.sub( self, 'SetCurrentZoom', 'canvas_new_zoom' )
HG.client_controller.sub( self, 'SetIndexString', 'canvas_new_index_string' )
2015-06-17 20:01:41 +00:00
2017-03-29 19:39:34 +00:00
self.Bind( wx.EVT_MOUSEWHEEL, self.EventMouseWheel )
2015-06-17 20:01:41 +00:00
2017-03-29 19:39:34 +00:00
def _Archive( self ):
2015-06-17 20:01:41 +00:00
2017-03-29 19:39:34 +00:00
if self._current_media.HasInbox():
2017-05-10 21:33:58 +00:00
command = ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'archive_file' )
2017-03-29 19:39:34 +00:00
else:
2017-05-10 21:33:58 +00:00
command = ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'inbox_file' )
2017-03-29 19:39:34 +00:00
2018-03-14 21:01:02 +00:00
HG.client_controller.pub( 'canvas_application_command', command, self._canvas_key )
2017-05-10 21:33:58 +00:00
2017-03-29 19:39:34 +00:00
def _GetIdealSizeAndPosition( self ):
2015-06-17 20:01:41 +00:00
2017-03-29 19:39:34 +00:00
parent = self.GetParent()
( parent_width, parent_height ) = parent.GetClientSize()
( my_width, my_height ) = self.GetSize()
my_ideal_width = int( parent_width * 0.6 )
should_resize = my_ideal_width != my_width
ideal_size = ( my_ideal_width, -1 )
2018-05-30 20:13:21 +00:00
ideal_position = ClientGUICommon.ClientToScreen( parent, ( int( parent_width * 0.2 ), 0 ) )
2017-03-29 19:39:34 +00:00
return ( should_resize, ideal_size, ideal_position )
2017-04-19 20:58:30 +00:00
def _ManageShortcuts( self ):
with ClientGUITopLevelWindows.DialogManage( self, 'manage shortcuts' ) as dlg:
panel = ClientGUIScrolledPanelsManagement.ManageShortcutsPanel( dlg )
dlg.SetPanel( panel )
dlg.ShowModal()
2017-03-29 19:39:34 +00:00
def _PopulateCenterButtons( self ):
self._archive_button = ClientGUICommon.BetterBitmapButton( self, CC.GlobalBMPs.archive, self._Archive )
2017-05-10 21:33:58 +00:00
self._trash_button = ClientGUICommon.BetterBitmapButton( self, CC.GlobalBMPs.delete, HG.client_controller.pub, 'canvas_delete', self._canvas_key )
2018-01-03 22:37:30 +00:00
self._trash_button.SetToolTip( 'send to trash' )
2015-08-05 18:42:35 +00:00
2017-05-10 21:33:58 +00:00
self._delete_button = ClientGUICommon.BetterBitmapButton( self, CC.GlobalBMPs.trash_delete, HG.client_controller.pub, 'canvas_delete', self._canvas_key )
2018-01-03 22:37:30 +00:00
self._delete_button.SetToolTip( 'delete completely' )
2015-08-05 18:42:35 +00:00
2017-05-10 21:33:58 +00:00
self._undelete_button = ClientGUICommon.BetterBitmapButton( self, CC.GlobalBMPs.undelete, HG.client_controller.pub, 'canvas_undelete', self._canvas_key )
2018-01-03 22:37:30 +00:00
self._undelete_button.SetToolTip( 'undelete' )
2015-06-17 20:01:41 +00:00
2018-01-03 22:37:30 +00:00
self._top_hbox.Add( self._archive_button, CC.FLAGS_VCENTER )
self._top_hbox.Add( self._trash_button, CC.FLAGS_VCENTER )
self._top_hbox.Add( self._delete_button, CC.FLAGS_VCENTER )
self._top_hbox.Add( self._undelete_button, CC.FLAGS_VCENTER )
2017-03-29 19:39:34 +00:00
def _PopulateLeftButtons( self ):
2017-04-19 20:58:30 +00:00
self._index_text = ClientGUICommon.BetterStaticText( self, 'index' )
2017-03-29 19:39:34 +00:00
2018-01-03 22:37:30 +00:00
self._top_hbox.Add( self._index_text, CC.FLAGS_VCENTER )
2017-03-29 19:39:34 +00:00
def _PopulateRightButtons( self ):
2017-04-19 20:58:30 +00:00
self._zoom_text = ClientGUICommon.BetterStaticText( self, 'zoom' )
2015-06-17 20:01:41 +00:00
2018-03-14 21:01:02 +00:00
zoom_in = ClientGUICommon.BetterBitmapButton( self, CC.GlobalBMPs.zoom_in, HG.client_controller.pub, 'canvas_application_command', ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'zoom_in' ), self._canvas_key )
2018-01-03 22:37:30 +00:00
zoom_in.SetToolTip( 'zoom in' )
2015-06-17 20:01:41 +00:00
2018-03-14 21:01:02 +00:00
zoom_out = ClientGUICommon.BetterBitmapButton( self, CC.GlobalBMPs.zoom_out, HG.client_controller.pub, 'canvas_application_command', ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'zoom_out' ), self._canvas_key )
2018-01-03 22:37:30 +00:00
zoom_out.SetToolTip( 'zoom out' )
2015-06-17 20:01:41 +00:00
2018-03-14 21:01:02 +00:00
zoom_switch = ClientGUICommon.BetterBitmapButton( self, CC.GlobalBMPs.zoom_switch, HG.client_controller.pub, 'canvas_application_command', ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'switch_between_100_percent_and_canvas_zoom' ), self._canvas_key )
2018-01-03 22:37:30 +00:00
zoom_switch.SetToolTip( 'zoom switch' )
2015-06-17 20:01:41 +00:00
2017-04-19 20:58:30 +00:00
menu_items = []
menu_items.append( ( 'normal', 'edit shortcuts', 'edit your sets of shortcuts, and change what shortcuts are currently active on this media viewer', self._ManageShortcuts ) )
2017-05-10 21:33:58 +00:00
menu_items.append( ( 'normal', 'set current shortcuts', 'change which custom shortcuts are active on this media viewers', HydrusData.Call( HG.client_controller.pub, 'edit_media_viewer_custom_shortcuts', self._canvas_key ) ) )
2017-04-19 20:58:30 +00:00
menu_items.append( ( 'normal', 'set default shortcuts', 'change which custom shortcuts are typically active on new media viewers', self._SetDefaultShortcuts ) )
shortcuts = ClientGUICommon.MenuBitmapButton( self, CC.GlobalBMPs.keyboard, menu_items )
2018-01-03 22:37:30 +00:00
shortcuts.SetToolTip( 'shortcuts' )
2017-04-19 20:58:30 +00:00
2017-05-10 21:33:58 +00:00
fullscreen_switch = ClientGUICommon.BetterBitmapButton( self, CC.GlobalBMPs.fullscreen_switch, HG.client_controller.pub, 'canvas_fullscreen_switch', self._canvas_key )
2018-01-03 22:37:30 +00:00
fullscreen_switch.SetToolTip( 'fullscreen switch' )
2015-06-17 20:01:41 +00:00
2018-03-14 21:01:02 +00:00
open_externally = ClientGUICommon.BetterBitmapButton( self, CC.GlobalBMPs.open_externally, HG.client_controller.pub, 'canvas_application_command', ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'open_file_in_external_program' ), self._canvas_key )
2018-01-03 22:37:30 +00:00
open_externally.SetToolTip( 'open externally' )
2015-08-05 18:42:35 +00:00
2018-03-28 21:55:58 +00:00
drag_button = wx.BitmapButton( self, bitmap = CC.GlobalBMPs.drag )
drag_button.SetToolTip( 'drag from here to export file' )
drag_button.Bind( wx.EVT_LEFT_DOWN, self.EventDragButton )
2017-05-10 21:33:58 +00:00
close = ClientGUICommon.BetterButton( self, 'X', HG.client_controller.pub, 'canvas_close', self._canvas_key )
2018-01-03 22:37:30 +00:00
close.SetToolTip( 'close' )
2015-06-17 20:01:41 +00:00
2018-01-03 22:37:30 +00:00
self._top_hbox.Add( self._zoom_text, CC.FLAGS_VCENTER )
self._top_hbox.Add( zoom_in, CC.FLAGS_VCENTER )
self._top_hbox.Add( zoom_out, CC.FLAGS_VCENTER )
self._top_hbox.Add( zoom_switch, CC.FLAGS_VCENTER )
self._top_hbox.Add( shortcuts, CC.FLAGS_VCENTER )
self._top_hbox.Add( fullscreen_switch, CC.FLAGS_VCENTER )
self._top_hbox.Add( open_externally, CC.FLAGS_VCENTER )
2018-03-28 21:55:58 +00:00
self._top_hbox.Add( drag_button, CC.FLAGS_VCENTER )
2018-01-03 22:37:30 +00:00
self._top_hbox.Add( close, CC.FLAGS_VCENTER )
2015-06-17 20:01:41 +00:00
2017-03-29 19:39:34 +00:00
def _ResetArchiveButton( self ):
2015-06-17 20:01:41 +00:00
2017-03-29 19:39:34 +00:00
if self._current_media.HasInbox():
2018-01-10 22:41:51 +00:00
ClientGUICommon.SetBitmapButtonBitmap( self._archive_button, CC.GlobalBMPs.archive )
2018-01-03 22:37:30 +00:00
self._archive_button.SetToolTip( 'archive' )
2017-03-29 19:39:34 +00:00
else:
2018-01-10 22:41:51 +00:00
ClientGUICommon.SetBitmapButtonBitmap( self._archive_button, CC.GlobalBMPs.to_inbox )
2018-01-03 22:37:30 +00:00
self._archive_button.SetToolTip( 'return to inbox' )
2017-03-29 19:39:34 +00:00
2015-06-17 20:01:41 +00:00
def _ResetButtons( self ):
if self._current_media is not None:
2017-03-29 19:39:34 +00:00
self._ResetArchiveButton()
2015-06-17 20:01:41 +00:00
2015-08-05 18:42:35 +00:00
current_locations = self._current_media.GetLocationsManager().GetCurrent()
if CC.LOCAL_FILE_SERVICE_KEY in current_locations:
self._trash_button.Show()
self._delete_button.Hide()
self._undelete_button.Hide()
elif CC.TRASH_SERVICE_KEY in current_locations:
self._trash_button.Hide()
self._delete_button.Show()
self._undelete_button.Show()
2017-03-29 19:39:34 +00:00
self.Fit()
self._SizeAndPosition()
2015-06-17 20:01:41 +00:00
def _ResetText( self ):
if self._current_media is None:
self._title_text.Hide()
self._info_text.Hide()
else:
label = self._current_media.GetTitleString()
if len( label ) > 0:
2016-03-23 19:42:56 +00:00
self._title_text.SetLabelText( label )
2015-06-17 20:01:41 +00:00
self._title_text.Show()
else: self._title_text.Hide()
2016-04-20 20:42:21 +00:00
lines = self._current_media.GetPrettyInfoLines()
label = ' | '.join( lines )
2015-06-17 20:01:41 +00:00
2016-03-23 19:42:56 +00:00
self._info_text.SetLabelText( label )
2015-06-17 20:01:41 +00:00
self._info_text.Show()
2017-05-17 21:53:02 +00:00
if self._additional_info_text.GetLabelText() == '':
self._additional_info_text.Hide()
else:
self._additional_info_text.Show()
2015-06-17 20:01:41 +00:00
2017-04-19 20:58:30 +00:00
def _SetDefaultShortcuts( self ):
2017-12-06 22:06:56 +00:00
new_options = HG.client_controller.new_options
2017-04-19 20:58:30 +00:00
default_media_viewer_custom_shortcuts = new_options.GetStringList( 'default_media_viewer_custom_shortcuts' )
2017-05-10 21:33:58 +00:00
all_shortcut_names = HG.client_controller.Read( 'serialisable_names', HydrusSerialisable.SERIALISABLE_TYPE_SHORTCUTS )
2017-04-19 20:58:30 +00:00
custom_shortcuts_names = [ name for name in all_shortcut_names if name not in CC.SHORTCUTS_RESERVED_NAMES ]
if len( custom_shortcuts_names ) == 0:
wx.MessageBox( 'You have no custom shortcuts set up, so you cannot choose any!' )
return
2017-04-26 21:58:12 +00:00
with ClientGUITopLevelWindows.DialogEdit( self, 'choose shortcuts' ) as dlg:
2017-04-19 20:58:30 +00:00
choice_tuples = [ ( name, name, name in default_media_viewer_custom_shortcuts ) for name in custom_shortcuts_names ]
panel = ClientGUIScrolledPanelsEdit.EditChooseMultiple( dlg, choice_tuples )
dlg.SetPanel( panel )
if dlg.ShowModal() == wx.ID_OK:
new_default_media_viewer_custom_shortcuts = panel.GetValue()
new_options.SetStringList( 'default_media_viewer_custom_shortcuts', new_default_media_viewer_custom_shortcuts )
2018-03-28 21:55:58 +00:00
def EventDragButton( self, event ):
if self._current_media is None:
event.Skip()
return
page_key = None
media = [ self._current_media ]
cmd_down = event.CmdDown()
result = ClientDragDrop.DoFileExportDragDrop( self, page_key, media, cmd_down )
if result not in ( wx.DragError, wx.DragNone ):
HG.client_controller.pub( 'canvas_application_command', ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'pause_media' ), self._canvas_key )
2015-09-16 18:11:00 +00:00
def EventMouseWheel( self, event ):
event.ResumePropagation( 1 )
event.Skip()
2015-06-17 20:01:41 +00:00
def ProcessContentUpdates( self, service_keys_to_content_updates ):
if self._current_media is not None:
my_hash = self._current_media.GetHash()
do_redraw = False
for ( service_key, content_updates ) in service_keys_to_content_updates.items():
if True in ( my_hash in content_update.GetHashes() for content_update in content_updates ):
do_redraw = True
break
if do_redraw:
self._ResetButtons()
def SetCurrentZoom( self, canvas_key, zoom ):
if canvas_key == self._canvas_key:
self._current_zoom = zoom
2015-08-26 21:18:39 +00:00
label = ClientData.ConvertZoomToPercentage( self._current_zoom )
2015-06-17 20:01:41 +00:00
2016-03-23 19:42:56 +00:00
self._zoom_text.SetLabelText( label )
2015-06-17 20:01:41 +00:00
self._top_hbox.Layout()
def SetDisplayMedia( self, canvas_key, media ):
if canvas_key == self._canvas_key:
FullscreenHoverFrame.SetDisplayMedia( self, canvas_key, media )
self._ResetText()
2017-03-29 19:39:34 +00:00
self._ResetButtons()
2015-07-15 20:28:26 +00:00
2015-06-17 20:01:41 +00:00
def SetIndexString( self, canvas_key, text ):
if canvas_key == self._canvas_key:
self._current_index_string = text
2016-03-23 19:42:56 +00:00
self._index_text.SetLabelText( self._current_index_string )
2015-06-17 20:01:41 +00:00
self._top_hbox.Layout()
2017-05-10 21:33:58 +00:00
class FullscreenHoverFrameTopArchiveDeleteFilter( FullscreenHoverFrameTop ):
def _Archive( self ):
2018-03-14 21:01:02 +00:00
HG.client_controller.pub( 'canvas_application_command', ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'archive_file' ), self._canvas_key )
2017-05-10 21:33:58 +00:00
def _PopulateLeftButtons( self ):
2018-03-14 21:01:02 +00:00
self._back_button = ClientGUICommon.BetterBitmapButton( self, CC.GlobalBMPs.previous, HG.client_controller.pub, 'canvas_application_command', ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'archive_delete_filter_back' ), self._canvas_key )
2018-01-03 22:37:30 +00:00
self._back_button.SetToolTip( 'back' )
2017-05-31 21:50:53 +00:00
2018-01-03 22:37:30 +00:00
self._top_hbox.Add( self._back_button, CC.FLAGS_VCENTER )
2017-05-31 21:50:53 +00:00
2017-05-10 21:33:58 +00:00
FullscreenHoverFrameTop._PopulateLeftButtons( self )
2018-03-14 21:01:02 +00:00
self._skip_button = ClientGUICommon.BetterBitmapButton( self, CC.GlobalBMPs.next, HG.client_controller.pub, 'canvas_application_command', ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'archive_delete_filter_skip' ), self._canvas_key )
2018-01-03 22:37:30 +00:00
self._skip_button.SetToolTip( 'skip' )
2017-05-31 21:50:53 +00:00
2018-01-03 22:37:30 +00:00
self._top_hbox.Add( self._skip_button, CC.FLAGS_VCENTER )
2017-05-10 21:33:58 +00:00
def _ResetArchiveButton( self ):
2018-01-10 22:41:51 +00:00
ClientGUICommon.SetBitmapButtonBitmap( self._archive_button, CC.GlobalBMPs.archive )
2018-01-03 22:37:30 +00:00
self._archive_button.SetToolTip( 'archive' )
2017-05-10 21:33:58 +00:00
2017-05-31 21:50:53 +00:00
class FullscreenHoverFrameTopNavigable( FullscreenHoverFrameTop ):
def _PopulateLeftButtons( self ):
2018-03-14 21:01:02 +00:00
self._previous_button = ClientGUICommon.BetterBitmapButton( self, CC.GlobalBMPs.previous, HG.client_controller.pub, 'canvas_application_command', ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'view_previous' ), self._canvas_key )
2018-01-03 22:37:30 +00:00
self._previous_button.SetToolTip( 'previous' )
2017-05-31 21:50:53 +00:00
self._index_text = ClientGUICommon.BetterStaticText( self, 'index' )
2018-03-14 21:01:02 +00:00
self._next_button = ClientGUICommon.BetterBitmapButton( self, CC.GlobalBMPs.next, HG.client_controller.pub, 'canvas_application_command', ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'view_next' ), self._canvas_key )
2018-01-03 22:37:30 +00:00
self._next_button.SetToolTip( 'next' )
2017-05-31 21:50:53 +00:00
2018-01-03 22:37:30 +00:00
self._top_hbox.Add( self._previous_button, CC.FLAGS_VCENTER )
self._top_hbox.Add( self._index_text, CC.FLAGS_VCENTER )
self._top_hbox.Add( self._next_button, CC.FLAGS_VCENTER )
2017-05-31 21:50:53 +00:00
class FullscreenHoverFrameTopDuplicatesFilter( FullscreenHoverFrameTopNavigable ):
2017-03-29 19:39:34 +00:00
2017-05-17 21:53:02 +00:00
def __init__( self, parent, canvas_key ):
2017-05-31 21:50:53 +00:00
FullscreenHoverFrameTopNavigable.__init__( self, parent, canvas_key )
2017-05-17 21:53:02 +00:00
HG.client_controller.sub( self, 'SetDuplicatePair', 'canvas_new_duplicate_pair' )
2017-03-29 19:39:34 +00:00
def _PopulateCenterButtons( self ):
2015-06-17 20:01:41 +00:00
2017-03-29 19:39:34 +00:00
menu_items = []
2017-04-26 21:58:12 +00:00
menu_items.append( ( 'normal', 'edit duplicate action options for \'this is better\'', 'edit what content is merged when you filter files', HydrusData.Call( self._EditMergeOptions, HC.DUPLICATE_BETTER ) ) )
2017-06-07 22:05:15 +00:00
menu_items.append( ( 'normal', 'edit duplicate action options for \'same quality\'', 'edit what content is merged when you filter files', HydrusData.Call( self._EditMergeOptions, HC.DUPLICATE_SAME_QUALITY ) ) )
2017-04-26 21:58:12 +00:00
menu_items.append( ( 'normal', 'edit duplicate action options for \'alternates\'', 'edit what content is merged when you filter files', HydrusData.Call( self._EditMergeOptions, HC.DUPLICATE_ALTERNATE ) ) )
menu_items.append( ( 'normal', 'edit duplicate action options for \'not duplicates\'', 'edit what content is merged when you filter files', HydrusData.Call( self._EditMergeOptions, HC.DUPLICATE_NOT_DUPLICATE ) ) )
2017-05-17 21:53:02 +00:00
menu_items.append( ( 'separator', None, None, None ) )
menu_items.append( ( 'normal', 'edit background lighten/darken switch intensity', 'edit how much the background will brighten or darken as you switch between the pair', self._EditBackgroundSwitchIntensity ) )
2017-03-29 19:39:34 +00:00
cog_button = ClientGUICommon.MenuBitmapButton( self, CC.GlobalBMPs.cog, menu_items )
2018-01-03 22:37:30 +00:00
self._top_hbox.Add( cog_button, CC.FLAGS_SIZER_VCENTER )
2017-03-29 19:39:34 +00:00
2017-05-31 21:50:53 +00:00
FullscreenHoverFrameTopNavigable._PopulateCenterButtons( self )
2017-03-29 19:39:34 +00:00
2017-05-24 20:28:24 +00:00
dupe_commands = []
dupe_commands.append( ( 'this is better', 'Set that the current file you are looking at is better than the other in the pair.', ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'duplicate_filter_this_is_better' ) ) )
2017-06-07 22:05:15 +00:00
dupe_commands.append( ( 'same quality', 'Set that the two files are duplicates of very similar quality.', ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'duplicate_filter_exactly_the_same' ) ) )
2017-05-24 20:28:24 +00:00
dupe_commands.append( ( 'alternates', 'Set that the files are not duplicates, but that one is derived from the other or that they are both descendants of a common ancestor.', ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'duplicate_filter_alternates' ) ) )
dupe_commands.append( ( 'not duplicates', 'Set that the files are not duplicates or otherwise related--that this pair is a false-positive match.', ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'duplicate_filter_not_dupes' ) ) )
dupe_commands.append( ( 'custom action', 'Choose one of the other actions but customise the merge and delete options for this specific decision.', ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'duplicate_filter_custom_action' ) ) )
for ( label, tooltip, command ) in dupe_commands:
2018-03-14 21:01:02 +00:00
command_button = ClientGUICommon.BetterButton( self, label, HG.client_controller.pub, 'canvas_application_command', command, self._canvas_key )
2017-05-24 20:28:24 +00:00
2018-01-03 22:37:30 +00:00
command_button.SetToolTip( tooltip )
2017-05-24 20:28:24 +00:00
2018-01-03 22:37:30 +00:00
self._button_hbox.Add( command_button, CC.FLAGS_VCENTER )
2017-05-24 20:28:24 +00:00
2017-03-29 19:39:34 +00:00
2017-05-17 21:53:02 +00:00
def _EditBackgroundSwitchIntensity( self ):
2017-12-06 22:06:56 +00:00
new_options = HG.client_controller.new_options
2017-05-17 21:53:02 +00:00
value = new_options.GetNoneableInteger( 'duplicate_background_switch_intensity' )
with ClientGUITopLevelWindows.DialogEdit( self, 'edit lighten/darken intensity' ) as dlg:
panel = ClientGUIScrolledPanelsEdit.EditNoneableIntegerPanel( dlg, value, message = 'intensity: ', none_phrase = 'do not change', min = 1, max = 9 )
dlg.SetPanel( panel )
if dlg.ShowModal() == wx.ID_OK:
new_value = panel.GetValue()
new_options.SetNoneableInteger( 'duplicate_background_switch_intensity', new_value )
2017-05-31 21:50:53 +00:00
def _EditMergeOptions( self, duplicate_type ):
2017-04-26 21:58:12 +00:00
2017-12-06 22:06:56 +00:00
new_options = HG.client_controller.new_options
2017-04-12 21:46:46 +00:00
2017-05-31 21:50:53 +00:00
duplicate_action_options = new_options.GetDuplicateActionOptions( duplicate_type )
2017-04-26 21:58:12 +00:00
with ClientGUITopLevelWindows.DialogEdit( self, 'edit duplicate merge options' ) as dlg:
2017-05-31 21:50:53 +00:00
panel = ClientGUIScrolledPanelsEdit.EditDuplicateActionOptionsPanel( dlg, duplicate_type, duplicate_action_options )
2017-04-26 21:58:12 +00:00
dlg.SetPanel( panel )
if dlg.ShowModal() == wx.ID_OK:
duplicate_action_options = panel.GetValue()
2017-05-31 21:50:53 +00:00
new_options.SetDuplicateActionOptions( duplicate_type, duplicate_action_options )
2017-04-26 21:58:12 +00:00
2017-04-12 21:46:46 +00:00
2017-03-29 19:39:34 +00:00
def _PopulateLeftButtons( self ):
2018-03-14 21:01:02 +00:00
self._first_button = ClientGUICommon.BetterBitmapButton( self, CC.GlobalBMPs.first, HG.client_controller.pub, 'canvas_application_command', ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'duplicate_filter_back' ), self._canvas_key )
2018-01-03 22:37:30 +00:00
self._first_button.SetToolTip( 'go back a pair' )
2017-05-17 21:53:02 +00:00
2018-01-03 22:37:30 +00:00
self._top_hbox.Add( self._first_button, CC.FLAGS_VCENTER )
2017-05-17 21:53:02 +00:00
2017-05-31 21:50:53 +00:00
FullscreenHoverFrameTopNavigable._PopulateLeftButtons( self )
2017-03-29 19:39:34 +00:00
2018-03-14 21:01:02 +00:00
self._last_button = ClientGUICommon.BetterBitmapButton( self, CC.GlobalBMPs.last, HG.client_controller.pub, 'canvas_application_command', ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'duplicate_filter_skip' ), self._canvas_key )
2018-01-03 22:37:30 +00:00
self._last_button.SetToolTip( 'show a different pair' )
2017-03-29 19:39:34 +00:00
2018-01-03 22:37:30 +00:00
self._top_hbox.Add( self._last_button, CC.FLAGS_VCENTER )
2017-03-29 19:39:34 +00:00
2017-05-17 21:53:02 +00:00
def SetDisplayMedia( self, canvas_key, media ):
if canvas_key == self._canvas_key:
if media is None:
self._additional_info_text.SetLabelText( '' )
2017-05-31 21:50:53 +00:00
FullscreenHoverFrameTopNavigable.SetDisplayMedia( self, canvas_key, media )
2017-05-17 21:53:02 +00:00
def SetDuplicatePair( self, canvas_key, shown_media, comparison_media ):
if canvas_key == self._canvas_key:
( statements, score ) = ClientMedia.GetDuplicateComparisonStatements( shown_media, comparison_media )
self._additional_info_text.SetLabelText( os.linesep.join( statements ) )
self._ResetText()
self._ResetButtons()
2017-05-31 21:50:53 +00:00
class FullscreenHoverFrameTopNavigableList( FullscreenHoverFrameTopNavigable ):
2017-03-29 19:39:34 +00:00
def _PopulateLeftButtons( self ):
2018-03-14 21:01:02 +00:00
self._first_button = ClientGUICommon.BetterBitmapButton( self, CC.GlobalBMPs.first, HG.client_controller.pub, 'canvas_application_command', ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'view_first' ), self._canvas_key )
2018-01-03 22:37:30 +00:00
self._first_button.SetToolTip( 'first' )
2017-03-29 19:39:34 +00:00
2018-01-03 22:37:30 +00:00
self._top_hbox.Add( self._first_button, CC.FLAGS_VCENTER )
2017-03-29 19:39:34 +00:00
2017-05-31 21:50:53 +00:00
FullscreenHoverFrameTopNavigable._PopulateLeftButtons( self )
2017-03-29 19:39:34 +00:00
2018-03-14 21:01:02 +00:00
self._last_button = ClientGUICommon.BetterBitmapButton( self, CC.GlobalBMPs.last, HG.client_controller.pub, 'canvas_application_command', ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'view_last' ), self._canvas_key )
2018-01-03 22:37:30 +00:00
self._last_button.SetToolTip( 'last' )
2017-03-29 19:39:34 +00:00
2018-01-03 22:37:30 +00:00
self._top_hbox.Add( self._last_button, CC.FLAGS_VCENTER )
2017-03-29 19:39:34 +00:00
2017-05-10 21:33:58 +00:00
class FullscreenHoverFrameTopRight( FullscreenHoverFrame ):
2015-06-17 20:01:41 +00:00
def __init__( self, parent, canvas_key ):
FullscreenHoverFrame.__init__( self, parent, canvas_key )
vbox = wx.BoxSizer( wx.VERTICAL )
self._icon_panel = wx.Panel( self )
2015-07-08 21:45:38 +00:00
self._trash_icon = ClientGUICommon.BufferedWindowIcon( self._icon_panel, CC.GlobalBMPs.trash )
2015-07-01 22:02:07 +00:00
self._inbox_icon = ClientGUICommon.BufferedWindowIcon( self._icon_panel, CC.GlobalBMPs.inbox )
2015-06-17 20:01:41 +00:00
icon_hbox = wx.BoxSizer( wx.HORIZONTAL )
2018-01-03 22:37:30 +00:00
icon_hbox.Add( ( 16, 16 ), CC.FLAGS_EXPAND_SIZER_BOTH_WAYS )
icon_hbox.Add( self._trash_icon, CC.FLAGS_VCENTER )
icon_hbox.Add( self._inbox_icon, CC.FLAGS_VCENTER )
2015-06-17 20:01:41 +00:00
self._icon_panel.SetSizer( icon_hbox )
# repo strings
self._file_repos = wx.StaticText( self, label = '', style = wx.ALIGN_RIGHT )
2017-04-26 21:58:12 +00:00
# urls
self._last_seen_urls = []
self._urls_vbox = wx.BoxSizer( wx.VERTICAL )
2015-06-17 20:01:41 +00:00
# likes
like_hbox = wx.BoxSizer( wx.HORIZONTAL )
2017-06-28 20:23:21 +00:00
like_services = HG.client_controller.services_manager.GetServices( ( HC.LOCAL_RATING_LIKE, ), randomised = False )
2015-06-17 20:01:41 +00:00
2018-08-15 20:40:30 +00:00
if len( like_services ) > 0:
like_hbox.Add( ( 16, 16 ), CC.FLAGS_EXPAND_BOTH_WAYS )
2015-06-17 20:01:41 +00:00
for service in like_services:
service_key = service.GetServiceKey()
control = ClientGUICommon.RatingLikeCanvas( self, service_key, canvas_key )
2018-01-03 22:37:30 +00:00
like_hbox.Add( control, CC.FLAGS_NONE )
2015-06-17 20:01:41 +00:00
# each numerical one in turn
2018-01-03 22:37:30 +00:00
vbox.Add( like_hbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS )
2015-06-17 20:01:41 +00:00
2017-06-28 20:23:21 +00:00
numerical_services = HG.client_controller.services_manager.GetServices( ( HC.LOCAL_RATING_NUMERICAL, ), randomised = False )
2015-06-17 20:01:41 +00:00
for service in numerical_services:
service_key = service.GetServiceKey()
control = ClientGUICommon.RatingNumericalCanvas( self, service_key, canvas_key )
hbox = wx.BoxSizer( wx.HORIZONTAL )
2018-01-03 22:37:30 +00:00
hbox.Add( ( 16, 16 ), CC.FLAGS_EXPAND_SIZER_BOTH_WAYS )
hbox.Add( control, CC.FLAGS_NONE )
2015-06-17 20:01:41 +00:00
2018-01-03 22:37:30 +00:00
vbox.Add( hbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS )
2015-06-17 20:01:41 +00:00
2018-01-03 22:37:30 +00:00
vbox.Add( self._icon_panel, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR )
vbox.Add( self._file_repos, CC.FLAGS_EXPAND_PERPENDICULAR )
vbox.Add( self._urls_vbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR )
2017-05-10 21:33:58 +00:00
2015-06-17 20:01:41 +00:00
self.SetSizer( vbox )
self._ResetData()
2017-05-10 21:33:58 +00:00
HG.client_controller.sub( self, 'ProcessContentUpdates', 'content_updates_gui' )
2015-09-16 18:11:00 +00:00
self.Bind( wx.EVT_MOUSEWHEEL, self.EventMouseWheel )
2015-06-17 20:01:41 +00:00
def _GetIdealSizeAndPosition( self ):
parent = self.GetParent()
( parent_width, parent_height ) = parent.GetClientSize()
( my_width, my_height ) = self.GetSize()
my_ideal_width = int( parent_width * 0.2 )
should_resize = my_ideal_width != my_width
ideal_size = ( my_ideal_width, -1 )
2018-05-30 20:13:21 +00:00
ideal_position = ClientGUICommon.ClientToScreen( parent, ( int( parent_width * 0.8 ), 0 ) )
2015-06-17 20:01:41 +00:00
return ( should_resize, ideal_size, ideal_position )
def _ResetData( self ):
if self._current_media is not None:
2015-07-08 21:45:38 +00:00
has_inbox = self._current_media.HasInbox()
has_trash = CC.TRASH_SERVICE_KEY in self._current_media.GetLocationsManager().GetCurrent()
if has_inbox or has_trash:
2015-06-17 20:01:41 +00:00
self._icon_panel.Show()
2015-07-08 21:45:38 +00:00
if has_inbox:
self._inbox_icon.Show()
else:
self._inbox_icon.Hide()
if has_trash:
self._trash_icon.Show()
else:
self._trash_icon.Hide()
2015-06-17 20:01:41 +00:00
else:
self._icon_panel.Hide()
2016-02-24 21:42:54 +00:00
remote_strings = self._current_media.GetLocationsManager().GetRemoteLocationStrings()
2015-06-17 20:01:41 +00:00
2016-02-24 21:42:54 +00:00
if len( remote_strings ) == 0:
2015-06-17 20:01:41 +00:00
self._file_repos.Hide()
else:
2016-02-24 21:42:54 +00:00
remote_string = os.linesep.join( remote_strings )
2015-06-17 20:01:41 +00:00
2016-03-23 19:42:56 +00:00
self._file_repos.SetLabelText( remote_string )
2015-06-17 20:01:41 +00:00
self._file_repos.Show()
2017-04-26 21:58:12 +00:00
# urls
urls = self._current_media.GetLocationsManager().GetURLs()
if urls != self._last_seen_urls:
self._last_seen_urls = list( urls )
2018-01-03 22:37:30 +00:00
self._urls_vbox.Clear( delete_windows = True )
2017-04-26 21:58:12 +00:00
2017-12-06 22:06:56 +00:00
url_tuples = HG.client_controller.network_engine.domain_manager.ConvertURLsToMediaViewerTuples( urls )
for ( display_string, url ) in url_tuples:
2017-04-26 21:58:12 +00:00
2018-01-03 22:37:30 +00:00
link = wx.adv.HyperlinkCtrl( self, id = -1, label = display_string, url = url )
2017-04-26 21:58:12 +00:00
2018-01-03 22:37:30 +00:00
link.SetToolTip( url )
2017-09-20 19:47:31 +00:00
2018-01-03 22:37:30 +00:00
self._urls_vbox.Add( link, CC.FLAGS_EXPAND_PERPENDICULAR )
2017-04-26 21:58:12 +00:00
2015-06-17 20:01:41 +00:00
self.Fit()
self._SizeAndPosition()
2015-09-16 18:11:00 +00:00
def EventMouseWheel( self, event ):
event.ResumePropagation( 1 )
event.Skip()
2015-06-17 20:01:41 +00:00
def ProcessContentUpdates( self, service_keys_to_content_updates ):
if self._current_media is not None:
my_hash = self._current_media.GetHash()
do_redraw = False
for ( service_key, content_updates ) in service_keys_to_content_updates.items():
2017-07-27 00:47:13 +00:00
# ratings updates do not change the shape of this hover but file changes of several kinds do
if True in ( my_hash in content_update.GetHashes() for content_update in content_updates if content_update.GetDataType() == HC.CONTENT_TYPE_FILES ):
2015-06-17 20:01:41 +00:00
2017-05-10 21:33:58 +00:00
do_redraw = True
break
2015-06-17 20:01:41 +00:00
if do_redraw:
self._ResetData()
def SetDisplayMedia( self, canvas_key, media ):
if canvas_key == self._canvas_key:
FullscreenHoverFrame.SetDisplayMedia( self, canvas_key, media )
self._ResetData()
2015-07-15 20:28:26 +00:00
2017-04-19 20:58:30 +00:00
2015-06-17 20:01:41 +00:00
class FullscreenHoverFrameTags( FullscreenHoverFrame ):
def __init__( self, parent, canvas_key ):
FullscreenHoverFrame.__init__( self, parent, canvas_key )
vbox = wx.BoxSizer( wx.VERTICAL )
2017-02-01 21:11:17 +00:00
self._tags = ClientGUIListBoxes.ListBoxTagsSelectionHoverFrame( self, self._canvas_key )
2015-06-17 20:01:41 +00:00
2018-01-03 22:37:30 +00:00
vbox.Add( self._tags, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS )
2015-06-17 20:01:41 +00:00
self.SetSizer( vbox )
2017-05-10 21:33:58 +00:00
HG.client_controller.sub( self, 'ProcessContentUpdates', 'content_updates_gui' )
2015-06-17 20:01:41 +00:00
def _GetIdealSizeAndPosition( self ):
parent = self.GetParent()
( parent_width, parent_height ) = parent.GetClientSize()
( my_width, my_height ) = self.GetSize()
my_ideal_width = int( parent_width * 0.2 )
my_ideal_height = parent_height
should_resize = my_ideal_width != my_width or my_ideal_height != my_height
ideal_size = ( my_ideal_width, my_ideal_height )
2018-05-30 20:13:21 +00:00
ideal_position = ClientGUICommon.ClientToScreen( parent, ( 0, 0 ) )
2015-06-17 20:01:41 +00:00
return ( should_resize, ideal_size, ideal_position )
def _ResetTags( self ):
2015-10-28 21:29:05 +00:00
if self._current_media is not None:
2015-06-17 20:01:41 +00:00
2015-10-28 21:29:05 +00:00
self._tags.SetTagsByMedia( [ self._current_media ], force_reload = True )
2015-06-17 20:01:41 +00:00
def ProcessContentUpdates( self, service_keys_to_content_updates ):
if self._current_media is not None:
my_hash = self._current_media.GetHash()
do_redraw = False
for ( service_key, content_updates ) in service_keys_to_content_updates.items():
if True in ( my_hash in content_update.GetHashes() for content_update in content_updates ):
do_redraw = True
break
if do_redraw:
self._ResetTags()
def SetDisplayMedia( self, canvas_key, media ):
if canvas_key == self._canvas_key:
FullscreenHoverFrame.SetDisplayMedia( self, canvas_key, media )
self._ResetTags()
2016-12-07 22:12:52 +00:00