mirror of
https://github.com/rbreu/beeref.git
synced 2026-03-11 08:54:28 +00:00
Enable opening files from Finder on MacOS X
This commit is contained in:
parent
ce3751912b
commit
becc427e5d
2 changed files with 23 additions and 2 deletions
10
BeeRef.spec
10
BeeRef.spec
|
|
@ -61,4 +61,12 @@ if sys.platform == 'darwin':
|
|||
exe,
|
||||
name=f'{appname}.app',
|
||||
icon=join('beeref', 'assets', icon),
|
||||
bundle_identifier=None)
|
||||
bundle_identifier=None,
|
||||
info_plist={
|
||||
'CFBundleDocumentTypes': [
|
||||
{
|
||||
'CFBundleTypeExtensions': [ 'bee' ],
|
||||
'CFBundleTypeRole': 'Viewer'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
|
|
|||
|
|
@ -30,6 +30,19 @@ from beeref.view import BeeGraphicsView
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BeeRefApplication(QtWidgets.QApplication):
|
||||
|
||||
def event(self, event):
|
||||
if event.type() == QtCore.QEvent.Type.FileOpen:
|
||||
for widget in self.topLevelWidgets():
|
||||
if isinstance(widget, BeeRefMainWindow):
|
||||
widget.view.open_from_file(event.file())
|
||||
return True
|
||||
return False
|
||||
else:
|
||||
return super().event(event)
|
||||
|
||||
|
||||
class BeeRefMainWindow(QtWidgets.QMainWindow):
|
||||
|
||||
def __init__(self, app):
|
||||
|
|
@ -79,7 +92,7 @@ def main():
|
|||
logger.info(f'Using settings: {settings.fileName()}')
|
||||
logger.info(f'Logging to: {logfile_name()}')
|
||||
CommandlineArgs(with_check=True) # Force checking
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
app = BeeRefApplication(sys.argv)
|
||||
palette = create_palette_from_dict(constants.COLORS)
|
||||
app.setPalette(palette)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue