Simplify layout inheritance

This commit is contained in:
Kovid Goyal 2020-10-26 13:57:19 +05:30
parent 90d474dafe
commit 0c6baca2d1
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -7,14 +7,13 @@ import os
import sys import sys
import textwrap import textwrap
from functools import partial from functools import partial
from threading import Thread
from PyQt5.Qt import ( from PyQt5.Qt import (
QCheckBox, QCursor, QDialog, QDialogButtonBox, QFrame, QGridLayout, QIcon, QApplication, QApplication, QCheckBox, QCursor, QDialog, QDialogButtonBox, QFrame, QGridLayout,
QInputDialog, QItemSelectionModel, QKeySequence, QLabel, QMenu, QPushButton, QIcon, QInputDialog, QItemSelectionModel, QKeySequence, QLabel, QMenu,
QSize, QSizePolicy, QStackedWidget, Qt, QToolButton, QTreeWidget, QPushButton, QSize, QSizePolicy, QStackedLayout, QStackedWidget, Qt, QToolButton,
QTreeWidgetItem, QVBoxLayout, QWidget, pyqtSignal QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget, pyqtSignal
) )
from threading import Thread
from calibre.constants import TOC_DIALOG_APP_UID, islinux, iswindows from calibre.constants import TOC_DIALOG_APP_UID, islinux, iswindows
from calibre.ebooks.oeb.polish.container import AZW3Container, get_container from calibre.ebooks.oeb.polish.container import AZW3Container, get_container
@ -149,15 +148,12 @@ class ItemView(QFrame): # {{{
self.prefs = prefs self.prefs = prefs
self.setFrameShape(QFrame.StyledPanel) self.setFrameShape(QFrame.StyledPanel)
self.setMinimumWidth(250) self.setMinimumWidth(250)
self.stack = s = QStackedWidget(self) self.stacked_layout = l = QStackedLayout(self)
self.l = l = QVBoxLayout()
self.setLayout(l)
l.addWidget(s)
self.root_pane = rp = QWidget(self) self.root_pane = rp = QWidget(self)
self.item_pane = ip = QWidget(self) self.item_pane = ip = QWidget(self)
self.current_item = None self.current_item = None
s.addWidget(rp) l.addWidget(rp)
s.addWidget(ip) l.addWidget(ip)
self.l1 = la = QLabel('<p>'+_( self.l1 = la = QLabel('<p>'+_(
'You can edit existing entries in the Table of Contents by clicking them' 'You can edit existing entries in the Table of Contents by clicking them'
@ -345,10 +341,10 @@ class ItemView(QFrame): # {{{
def __call__(self, item): def __call__(self, item):
if item is None: if item is None:
self.current_item = None self.current_item = None
self.stack.setCurrentIndex(0) self.stacked_layout.setCurrentIndex(0)
else: else:
self.current_item = item self.current_item = item
self.stack.setCurrentIndex(1) self.stacked_layout.setCurrentIndex(1)
self.populate_item_pane() self.populate_item_pane()
def populate_item_pane(self): def populate_item_pane(self):