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:
Kovid Goyal 2012-06-04 00:51:54 +05:30
parent dc5f2be9b2
commit cc8c4482e1
2 changed files with 6 additions and 19 deletions

View File

@ -27,7 +27,6 @@ from calibre.utils.config import tweaks
from calibre.ebooks.metadata.book.base import Metadata
from calibre.utils.localization import canonicalize_lang
from calibre.utils.date import local_tz
from calibre.constants import iswindows, isosx
BASE_TITLE = _('Edit Metadata')
@ -101,19 +100,6 @@ class MetadataSingleDialogBase(ResizableDialog):
geom = gprefs.get('metasingle_window_geometry3', None)
if geom is not None:
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): # {{{

View File

@ -9685,13 +9685,14 @@ QSize Style::sizeFromContents(ContentsType type, const QStyleOption *option, con
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)
{
bool dialogButton=
// Cant rely on AutoDefaultButton - as VirtualBox does not set this!!!
// btn->features&QStyleOptionButton::AutoDefaultButton &&
widget && widget->parentWidget() &&
(::qobject_cast<const QDialogButtonBox *>(widget->parentWidget()) || widget->parentWidget()->inherits("KFileWidget"));
// Changed by Kovid since we dont care about VirtualBox
bool dialogButton = btn->features&QStyleOptionButton::AutoDefaultButton;
if(dialogButton)
{