[PATCH}Re: Konqueror throbber size -- too small and doesn't resize

David Faure faure at kde.org
Mon Jun 9 11:24:56 BST 2008


On Saturday 07 June 2008, James Richard Tyrer wrote:
> This is not going very well.
> 
> With 12 point type, the Menu bar is 30 pixels tall.  However, if I use a 
> throbber icon that is larger than 20 pixels, the Menu bar gets taller.
> 
> And using the pixel height of the font:
> 
>    int size = QFontInfo(KGlobalSettings::menuFont()).pixelSize();
> 
> seems to have problems as well since the value is only 17 (which is 
> correct).

Like Rafael, I don't like the use of hardcoded values; I would prefer a precise
reverse calculation from QMenuBar::sizeHint.

This would give something like this....

int KonqMainWindow::maxThrobberHeight()
{
    const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, menuBar());
    const int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, menuBar());
    const int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, menuBar());
    const int margin = 2*vmargin + 2*fw + spaceBelowMenuBar;
    // Let's see how much height the widget style adds
    QStyleOptionMenuItem opt;
    opt.rect = menuBar()->rect();
    opt.menuRect = opt.rect;
    opt.state = QStyle::State_None;
    opt.menuItemType = QStyleOptionMenuItem::Normal;
    opt.checkType = QStyleOptionMenuItem::NotCheckable;
    const QRect finalRect = style()->sizeFromContents(QStyle::CT_MenuBar, &opt, opt.rect), menuBar()));
    const int stylePadding = finalRect.height() - opt.rect.height();
    return menuBar()->height() - margin - stylePadding;
}

Oh... BUT -- that's the maximum height of the widget, not its icon size! We also need to subtract the
difference between the iconsize of a qtoolbutton and its final size...

More complete patch attached.
Although from a quick test I have the feeling it's still a little bit too big... Can you give it
a bit of testing?

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: throbber_size.diff
Type: text/x-diff
Size: 2748 bytes
Desc: not available
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20080609/d35373a7/attachment.diff>


More information about the kfm-devel mailing list