mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add close button to preference category browser on OS X
This commit is contained in:
parent
8e755bf205
commit
6b1ed59109
@ -10,9 +10,10 @@ from functools import partial
|
||||
|
||||
from PyQt4.Qt import QMainWindow, Qt, QIcon, QStatusBar, QFont, QWidget, \
|
||||
QScrollArea, QStackedWidget, QVBoxLayout, QLabel, QFrame, QKeySequence, \
|
||||
QToolBar, QSize, pyqtSignal, QSizePolicy, QToolButton, QAction
|
||||
QToolBar, QSize, pyqtSignal, QSizePolicy, QToolButton, QAction, \
|
||||
QPushButton
|
||||
|
||||
from calibre.constants import __appname__, __version__, islinux
|
||||
from calibre.constants import __appname__, __version__, islinux, isosx
|
||||
from calibre.gui2 import gprefs, min_available_height, available_width, \
|
||||
warning_dialog
|
||||
from calibre.gui2.preferences import init_gui, AbortCommit, get_plugin
|
||||
@ -87,6 +88,7 @@ class Category(QWidget): # {{{
|
||||
class Browser(QScrollArea): # {{{
|
||||
|
||||
show_plugin = pyqtSignal(object)
|
||||
close_signal = pyqtSignal()
|
||||
|
||||
def __init__(self, parent=None):
|
||||
QScrollArea.__init__(self, parent)
|
||||
@ -117,12 +119,20 @@ class Browser(QScrollArea): # {{{
|
||||
self.container = QWidget(self)
|
||||
self.container.setLayout(self._layout)
|
||||
self.setWidget(self.container)
|
||||
if isosx:
|
||||
self.close_button = QPushButton(_('Close'))
|
||||
self.close_button.clicked.connect(self.close_requested)
|
||||
self._layout.addWidget(self.close_button)
|
||||
|
||||
for name, plugins in self.category_map.items():
|
||||
w = Category(name, plugins, self)
|
||||
self.widgets.append(w)
|
||||
self._layout.addWidget(w)
|
||||
w.plugin_activated.connect(self.show_plugin.emit)
|
||||
|
||||
def close_requested(self, *args):
|
||||
self.close_signal.emit()
|
||||
|
||||
# }}}
|
||||
|
||||
class Preferences(QMainWindow):
|
||||
@ -165,6 +175,7 @@ class Preferences(QMainWindow):
|
||||
self.stack = QStackedWidget(self)
|
||||
self.setCentralWidget(self.stack)
|
||||
self.browser = Browser(self)
|
||||
self.browser.close_signal.connect(self.close, type=Qt.QueuedConnection)
|
||||
self.browser.show_plugin.connect(self.show_plugin)
|
||||
self.stack.addWidget(self.browser)
|
||||
self.scroll_area = QScrollArea(self)
|
||||
|
Loading…
x
Reference in New Issue
Block a user