mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 13:43:39 +02:00
Add close button to preference category browser on OS X
This commit is contained in:
parent
8e755bf205
commit
6b1ed59109
1 changed files with 13 additions and 2 deletions
|
|
@ -10,9 +10,10 @@
|
|||
|
||||
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 @@ def triggered(self, plugin, *args):
|
|||
class Browser(QScrollArea): # {{{
|
||||
|
||||
show_plugin = pyqtSignal(object)
|
||||
close_signal = pyqtSignal()
|
||||
|
||||
def __init__(self, parent=None):
|
||||
QScrollArea.__init__(self, parent)
|
||||
|
|
@ -117,12 +119,20 @@ def __init__(self, parent=None):
|
|||
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 @@ def __init__(self, gui, initial_plugin=None):
|
|||
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…
Reference in a new issue