Fix #1858284 [Automatic adding dialog has an unnecessary scrollbar](https://bugs.launchpad.net/calibre/+bug/1858284)

This commit is contained in:
Kovid Goyal 2020-01-06 14:16:45 +05:30
parent 9a452f67b8
commit b2c4abd9b0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 45 additions and 9 deletions

View File

@ -15,7 +15,7 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<widget class="ScrollingTabWidget" name="tabWidget">
<property name="currentIndex">
<number>2</number>
</property>
@ -47,10 +47,10 @@
<item>
<widget class="QCheckBox" name="opt_swap_author_names">
<property name="toolTip">
<string>Swap the firstname and lastname of the author. This affects only metadata read from file names.</string>
<string>Swap the first name and last name of the author. This affects only metadata read from file names.</string>
</property>
<property name="text">
<string>&amp;Swap author firstname and lastname when reading author from filename</string>
<string>&amp;Swap author first name and last name when reading author from filename</string>
</property>
</widget>
</item>
@ -445,6 +445,12 @@ that have been explicitly ignored below.</string>
<extends>QLineEdit</extends>
<header>calibre/gui2/widgets.h</header>
</customwidget>
<customwidget>
<class>ScrollingTabWidget</class>
<extends>QTabWidget</extends>
<header>calibre/gui2/widgets2.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../../../resources/images.qrc"/>

View File

@ -15,7 +15,7 @@
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<widget class="ScrollingTabWidget" name="tabWidget">
<property name="currentIndex">
<number>2</number>
</property>
@ -1319,6 +1319,12 @@ column being examined (the left-hand pane)</string>
<extends>QComboBox</extends>
<header>calibre/gui2/complete2.h</header>
</customwidget>
<customwidget>
<class>ScrollingTabWidget</class>
<extends>QTabWidget</extends>
<header>calibre/gui2/widgets2.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../../../resources/images.qrc"/>

View File

@ -8,17 +8,17 @@ import weakref
from PyQt5.Qt import (
QAbstractListModel, QApplication, QCheckBox, QColor, QColorDialog, QComboBox,
QDialog, QDialogButtonBox, QFont, QIcon, QKeySequence, QLabel, QLayout,
QModelIndex, QPalette, QPixmap, QPoint, QPushButton, QRect, QSize, QSizePolicy,
QStyle, QStyledItemDelegate, Qt, QTextBrowser, QToolButton, QUndoCommand, QFontInfo,
QUndoStack, QWidget, pyqtSignal
QDialog, QDialogButtonBox, QFont, QFontInfo, QIcon, QKeySequence, QLabel,
QLayout, QModelIndex, QPalette, QPixmap, QPoint, QPushButton, QRect, QScrollArea,
QSize, QSizePolicy, QStyle, QStyledItemDelegate, Qt, QTabWidget, QTextBrowser,
QToolButton, QUndoCommand, QUndoStack, QWidget, pyqtSignal
)
from calibre.ebooks.metadata import rating_to_stars
from calibre.utils.config_base import tweaks
from calibre.gui2 import gprefs, rating_font
from calibre.gui2.complete2 import EditWithComplete, LineEdit
from calibre.gui2.widgets import history
from calibre.utils.config_base import tweaks
from polyglot.builtins import unicode_type
@ -482,6 +482,30 @@ class HTMLDisplay(QTextBrowser):
self.anchor_clicked.emit(qurl)
class ScrollingTabWidget(QTabWidget):
def __init__(self, parent=None):
QTabWidget.__init__(self, parent)
def wrap_widget(self, page):
sw = QScrollArea(self)
sw.setWidget(page)
sw.setWidgetResizable(True)
page.setAutoFillBackground(False)
sw.setStyleSheet('QScrollArea { background: transparent }')
return sw
def indexOf(self, page):
for i in range(self.count()):
t = self.widget(i)
if t.widget() is page:
return i
return -1
def addTab(self, page, *args):
return QTabWidget.addTab(self, self.wrap_widget(page), *args)
if __name__ == '__main__':
from calibre.gui2 import Application
app = Application([])