mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Proper fix for QPushButton sizes. We now ensure that push buttons without icons use iconSize pixels for their text, irrespective of font size
This commit is contained in:
parent
dc5f2be9b2
commit
cc8c4482e1
@ -27,7 +27,6 @@ from calibre.utils.config import tweaks
|
|||||||
from calibre.ebooks.metadata.book.base import Metadata
|
from calibre.ebooks.metadata.book.base import Metadata
|
||||||
from calibre.utils.localization import canonicalize_lang
|
from calibre.utils.localization import canonicalize_lang
|
||||||
from calibre.utils.date import local_tz
|
from calibre.utils.date import local_tz
|
||||||
from calibre.constants import iswindows, isosx
|
|
||||||
|
|
||||||
BASE_TITLE = _('Edit Metadata')
|
BASE_TITLE = _('Edit Metadata')
|
||||||
|
|
||||||
@ -101,19 +100,6 @@ class MetadataSingleDialogBase(ResizableDialog):
|
|||||||
geom = gprefs.get('metasingle_window_geometry3', None)
|
geom = gprefs.get('metasingle_window_geometry3', None)
|
||||||
if geom is not None:
|
if geom is not None:
|
||||||
self.restoreGeometry(bytes(geom))
|
self.restoreGeometry(bytes(geom))
|
||||||
self.title.resizeEvent = self.fix_push_buttons
|
|
||||||
|
|
||||||
def fix_push_buttons(self, *args):
|
|
||||||
# Ensure all PushButtons stay the same consistent height throughout this
|
|
||||||
# dialog. Without this, the buttons inside scrollareas get shrunk,
|
|
||||||
# while the buttons outside them do not, leading to weirdness.
|
|
||||||
# Further, buttons with and without icons have different minimum sizes
|
|
||||||
# so things look even more out of whack.
|
|
||||||
ht = self.next_button.height() if iswindows or isosx else self.title.height() + 1
|
|
||||||
for but in self.findChildren(QPushButton):
|
|
||||||
but.setMaximumHeight(ht)
|
|
||||||
but.setMinimumHeight(ht)
|
|
||||||
return TitleEdit.resizeEvent(self.title, *args)
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
def create_basic_metadata_widgets(self): # {{{
|
def create_basic_metadata_widgets(self): # {{{
|
||||||
|
@ -9685,13 +9685,14 @@ QSize Style::sizeFromContents(ContentsType type, const QStyleOption *option, con
|
|||||||
|
|
||||||
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option))
|
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option))
|
||||||
{
|
{
|
||||||
|
// Added by Kovid to ensure that pushbuttons without icons are never narrower than push buttons with icons at small font sizes
|
||||||
|
int min_pb_height = (btn->iconSize.height() > 16) ? btn->iconSize.height() : 16;
|
||||||
|
if (newSize.height() < min_pb_height) newSize.setHeight(min_pb_height);
|
||||||
|
|
||||||
if(!opts.stdBtnSizes)
|
if(!opts.stdBtnSizes)
|
||||||
{
|
{
|
||||||
bool dialogButton=
|
// Changed by Kovid since we dont care about VirtualBox
|
||||||
// Cant rely on AutoDefaultButton - as VirtualBox does not set this!!!
|
bool dialogButton = btn->features&QStyleOptionButton::AutoDefaultButton;
|
||||||
// btn->features&QStyleOptionButton::AutoDefaultButton &&
|
|
||||||
widget && widget->parentWidget() &&
|
|
||||||
(::qobject_cast<const QDialogButtonBox *>(widget->parentWidget()) || widget->parentWidget()->inherits("KFileWidget"));
|
|
||||||
|
|
||||||
if(dialogButton)
|
if(dialogButton)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user