Bug 273723

Summary: KConfigDialog::addPage() requires hardcoded icon sizes
Product: [Frameworks and Libraries] kdelibs Reporter: Lukas Sommer <sommerluk>
Component: kdeuiAssignee: kdelibs bugs <kdelibs-bugs>
Status: RESOLVED NOT A BUG    
Severity: normal CC: pino
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Unlisted Binaries   
OS: Linux   
Latest Commit: Version Fixed In:

Description Lukas Sommer 2011-05-20 13:56:48 UTC
Version:           unspecified (using Devel) 
OS:                Linux

KConfigDialog manages various pages and displays at the left of the dialog a list of the pages, which can contain a text and an icon for each page.


Reproducible: Always

Steps to Reproduce:
Use KConfigDialog::addPage() to add a new page.


Actual Results:  
KConfigDialog::addPage() only accepts "const QString &pixmapName" to determine the icon that is displayed. To use a simple standard icon, you have to so something like

KIconLoader iconloader;
addPage(new settings_general_widget_saving(this),
        i18nc("@title of a page in the configuration dialog", "Saving"),
        iconloader.iconPath("document-save", KIconLoader::SizeEnormous * (-1)));

This is not very practical. And above all you have to use a hardcoded icon size. Icon sizes should not be hardcoded, but they should be managed by the kdeui library.



Expected Results:  
KConfigDialog::addPage() has overloaded functions that accept KIcon (or QIcon?) instead of the path to the icon file.

The icon size is not hardcoded but determined by the kdeui library (like it is done for the icons in the toolbar) or by the widget style. (Would this be possible with QStyle? Some widget styles like "Skulpture" resize the icons in Buttons and Menus!)



This is a spin-off bug of Bug 272266

The default icon size should be DPI sensitive. Maybe it could depend on QStyle/KStyle?
Comment 1 Pino Toscano 2011-05-20 18:42:44 UTC
(In reply to comment #0)
> KConfigDialog::addPage() only accepts "const QString &pixmapName" to determine
> the icon that is displayed. To use a simple standard icon, you have to so
> something like
> 
> KIconLoader iconloader;
> addPage(new settings_general_widget_saving(this),
>         i18nc("@title of a page in the configuration dialog", "Saving"),
>         iconloader.iconPath("document-save", KIconLoader::SizeEnormous *
> (-1)));

No that's wrong, "pixmapName" means the name of an icon in the current icon theme.
Just one example of the okular sources:

    addPage( m_general, i18n("General"), "okular", i18n("General Options") );

(Oh, and a side note: creating a new KIconLoader is not the best idea, just use the global one you have at KIconLoader::global().)
Comment 2 Lukas Sommer 2011-05-20 19:43:04 UTC
Shame on me. I didn't even notice that it was possible to pass just the icon name. (I've yet changed the corresponding code in KStreamRipper, the program from which was taken the code example.)
Comment 3 Lukas Sommer 2011-05-21 12:34:45 UTC
I've made a patch that fixes the documentation:

http://git.reviewboard.kde.org/r/101409/
Comment 4 Lukas Sommer 2011-05-23 09:14:12 UTC
Closing as INVALID because the requested behaviour exists yet.