mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Support Unity's global menu bar for the ebook editor
This commit is contained in:
parent
b4c173c598
commit
89abf8a12b
@ -75,6 +75,9 @@ class MainWindow(QMainWindow):
|
|||||||
__actions = []
|
__actions = []
|
||||||
|
|
||||||
keyboard_interrupt = pyqtSignal()
|
keyboard_interrupt = pyqtSignal()
|
||||||
|
# See https://bugreports.qt-project.org/browse/QTBUG-42281
|
||||||
|
window_blocked = pyqtSignal()
|
||||||
|
window_unblocked = pyqtSignal()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_application_menubar(cls):
|
def create_application_menubar(cls):
|
||||||
@ -129,3 +132,12 @@ class MainWindow(QMainWindow):
|
|||||||
pass
|
pass
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def event(self, ev):
|
||||||
|
# See https://bugreports.qt-project.org/browse/QTBUG-42281
|
||||||
|
etype = ev.type()
|
||||||
|
if etype == ev.WindowBlocked:
|
||||||
|
self.window_blocked.emit()
|
||||||
|
elif etype == ev.WindowUnblocked:
|
||||||
|
self.window_unblocked.emit()
|
||||||
|
return QMainWindow.event(self, ev)
|
||||||
|
@ -19,6 +19,7 @@ from PyQt5.Qt import (
|
|||||||
from calibre import prints
|
from calibre import prints
|
||||||
from calibre.constants import __appname__, get_version, isosx, DEBUG
|
from calibre.constants import __appname__, get_version, isosx, DEBUG
|
||||||
from calibre.gui2 import elided_text, open_url
|
from calibre.gui2 import elided_text, open_url
|
||||||
|
from calibre.gui2.dbus_export.widgets import factory
|
||||||
from calibre.gui2.keyboard import Manager as KeyboardManager
|
from calibre.gui2.keyboard import Manager as KeyboardManager
|
||||||
from calibre.gui2.main_window import MainWindow
|
from calibre.gui2.main_window import MainWindow
|
||||||
from calibre.gui2.throbber import ThrobbingButton, create_donate_widget
|
from calibre.gui2.throbber import ThrobbingButton, create_donate_widget
|
||||||
@ -461,10 +462,12 @@ class Main(MainWindow):
|
|||||||
create_plugin_actions(actions, toolbar_actions, self.plugin_menu_actions)
|
create_plugin_actions(actions, toolbar_actions, self.plugin_menu_actions)
|
||||||
|
|
||||||
def create_menubar(self):
|
def create_menubar(self):
|
||||||
p, q = self.create_application_menubar()
|
if isosx:
|
||||||
q.triggered.connect(self.action_quit.trigger)
|
p, q = self.create_application_menubar()
|
||||||
p.triggered.connect(self.action_preferences.trigger)
|
q.triggered.connect(self.action_quit.trigger)
|
||||||
b = self.menuBar()
|
p.triggered.connect(self.action_preferences.trigger)
|
||||||
|
f = factory(app_id='com.calibre-ebook.EditBook-%d' % os.getpid())
|
||||||
|
b = f.create_window_menubar(self)
|
||||||
|
|
||||||
f = b.addMenu(_('&File'))
|
f = b.addMenu(_('&File'))
|
||||||
f.addAction(self.action_new_file)
|
f.addAction(self.action_new_file)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user