Additional macOS integration and fixes (#1523)

* Work on quick look integration

* Add pyobjc requirements and make sure it's only imported on macOS

* Fix requirements

* Rename HydrusDataSource to HydrusQLDataSource

* Add version to Info.plist in .app

* Clean up ClientMacIntegration.py
This commit is contained in:
Paul Friederichsen 2024-02-24 14:39:43 -06:00 committed by GitHub
parent 8c9a890bd7
commit 7444f20834
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 85 additions and 12 deletions

View File

@ -36,6 +36,17 @@ jobs:
run: |
cd $GITHUB_WORKSPACE
7z e ffmpeg-macos.7z -obin "ffmpeg"
-
name: Extract Version Metadata
id: meta
run: |
echo "version=${GITHUB_REF##*/}" >> $GITHUB_ENV
echo "version_short=${GITHUB_REF##*/v}" >> $GITHUB_ENV
-
name: Write version to Info.plist
run: |
cd $GITHUB_WORKSPACE
plutil -replace CFBundleShortVersionString -string "${{ env.version_short }}" static/build_files/macos/Info.plist
-
name: Build Hydrus
run: |
@ -61,17 +72,7 @@ jobs:
cd $GITHUB_WORKSPACE
temp_dmg="$(mktemp).dmg"
hdiutil create "$temp_dmg" -ov -volname "HydrusNetwork" -fs HFS+ -format UDZO -srcfolder "$GITHUB_WORKSPACE/build/$(head -n 1 triple.txt)/release"
mv "$temp_dmg" HydrusNetwork.dmg
-
name: Extract Version Metadata
id: meta
run: |
echo "version=${GITHUB_REF##*/}" >> $GITHUB_ENV
echo "version_short=${GITHUB_REF##*/v}" >> $GITHUB_ENV
-
name: Rename Files
run: |
mv HydrusNetwork.dmg Hydrus.Network.${{ env.version_short }}.-.macOS.-.App.dmg
mv "$temp_dmg" Hydrus.Network.${{ env.version_short }}.-.macOS.-.App.dmg
-
name: Upload Files
uses: softprops/action-gh-release@v1

View File

@ -161,6 +161,7 @@ SIMPLE_COPY_LITTLE_BMP = 147
SIMPLE_MOVE_THUMBNAIL_FOCUS = 148
SIMPLE_SELECT_FILES = 149
SIMPLE_REARRANGE_THUMBNAILS = 150
SIMPLE_MAC_QUICKLOOK = 151
REARRANGE_THUMBNAILS_TYPE_FIXED = 0
REARRANGE_THUMBNAILS_TYPE_COMMAND = 1
@ -347,6 +348,7 @@ simple_enum_to_str_lookup = {
SIMPLE_MOVE_THUMBNAIL_FOCUS : 'move the thumbnail focus',
SIMPLE_SELECT_FILES : 'select files',
SIMPLE_REARRANGE_THUMBNAILS : 'move thumbnails',
SIMPLE_MAC_QUICKLOOK : 'open quick look for selected file (macOS only)'
}
legacy_simple_str_to_enum_lookup = {

View File

@ -0,0 +1,28 @@
import objc
from Foundation import NSObject, NSURL
from Quartz import QLPreviewPanel
QLPreviewPanelDataSource = objc.protocolNamed('QLPreviewPanelDataSource')
class HydrusQLDataSource(NSObject, protocols=[QLPreviewPanelDataSource]):
def initWithCurrentlyLooking_(self, currently_showing):
self = objc.super(HydrusQLDataSource, self).init()
if self is None: return None
self.currently_showing = currently_showing
return self
def numberOfPreviewItemsInPreviewPanel_(self, panel):
return 1 if self.currently_showing is not None else 0
def previewPanel_previewItemAtIndex_(self, panel, index):
return NSURL.fileURLWithPath_(self.currently_showing) # or whatever
def show_quicklook_for_path( path ):
hydrus_data_source = HydrusQLDataSource.alloc().initWithCurrentlyLooking_(path)
panel = QLPreviewPanel.sharedPreviewPanel()
panel.setDataSource_(hydrus_data_source)
panel.makeKeyAndOrderFront_(None)

View File

@ -440,7 +440,8 @@ SHORTCUTS_THUMBNAILS_ACTIONS = [
CAC.SIMPLE_OPEN_FILE_IN_FILE_EXPLORER,
CAC.SIMPLE_SELECT_FILES,
CAC.SIMPLE_MOVE_THUMBNAIL_FOCUS,
CAC.SIMPLE_REARRANGE_THUMBNAILS
CAC.SIMPLE_REARRANGE_THUMBNAILS,
CAC.SIMPLE_MAC_QUICKLOOK
]
simple_shortcut_name_to_action_lookup = {

View File

@ -54,6 +54,11 @@ from hydrus.client.metadata import ClientContentUpdates
from hydrus.client.metadata import ClientTags
from hydrus.client.search import ClientSearch
if HC.PLATFORM_MACOS:
from hydrus.client import ClientMacIntegration
FRAME_DURATION_60FPS = 1.0 / 60
class ThumbnailWaitingToBeDrawn( object ):
@ -1303,6 +1308,25 @@ class MediaPanel( CAC.ApplicationCommandProcessorMixin, ClientMedia.ListeningMed
def _MacQuicklook( self ):
if HC.PLATFORM_MACOS and self._HasFocusSingleton():
focused_singleton = self._GetFocusSingleton()
if focused_singleton.GetLocationsManager().IsLocal():
hash = focused_singleton.GetHash()
mime = focused_singleton.GetMime()
client_files_manager = CG.client_controller.client_files_manager
path = client_files_manager.GetFilePath( hash, mime )
#self._SetFocusedMedia( None )
ClientMacIntegration.show_quicklook_for_path( path )
def _OpenKnownURL( self ):
@ -2553,6 +2577,10 @@ class MediaPanel( CAC.ApplicationCommandProcessorMixin, ClientMedia.ListeningMed
self._ArchiveDeleteFilter()
elif action == CAC.SIMPLE_MAC_QUICKLOOK:
self._MacQuicklook()
else:
command_processed = False

View File

@ -245,6 +245,8 @@ elif [ "$install_type" = "a" ]; then
fi
fi
python -m pip install -r static/requirements/advanced/requirements/requirements_macos.txt
deactivate
echo "--------"

View File

@ -31,3 +31,7 @@ PyQt6==6.5.2
PyQt6-Qt6==6.5.2
setuptools==65.5.1
pyobjc-core>=10.1
pyobjc-framework-Cocoa>=10.1
pyobjc-framework-Quartz>=10.1

View File

@ -0,0 +1,3 @@
pyobjc-core>=10.1
pyobjc-framework-Cocoa>=10.1
pyobjc-framework-Quartz>=10.1

View File

@ -3,3 +3,7 @@ pyoxidizer
mock>=4.0.0
httmock>=1.4.0
mkdocs-material
pyobjc-core>=10.1
pyobjc-framework-Cocoa>=10.1
pyobjc-framework-Quartz>=10.1