[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: KIconButton sizes
From: Lukas Appelhans <l.appelhans () gmx ! de>
Date: 2008-02-04 18:42:21
Message-ID: 200802041933.51905.l.appelhans () gmx ! de
[Download RAW message or body]
Am Montag, 4. Februar 2008 07:02:59 schrieb David Faure:
> On Saturday 02 February 2008, Lukas Appelhans wrote:
> > Hi!
> > The attached Patch adds the functionality to KIconButton-class to only
> > set the Icon-Size for Dialog or Button.
> > For example: We in KGet need a Size of 16x16 for the Button, which looks
> > pretty bad in the Dialog...
> >
> > Any objections or comments?
>
> I don't understand, buttonIconSize/setButtonIconSize is already available
> as iconSize/setIconSize(QSize) (inherited from QPushButton), and
> setDialogIconSize is already available as setIconSize(int) (which also
> calls QPushButton::setIconSize(QSize)).
> Ah! So the real problem is that KIconButton's setIconSize method clashes
> with QPushButton's setIconSize since they have different meanings. Damn we
> should have renamed it for 4.0.
>
> So... you want a dialog that shows large icons, but a button that shows a
> 16x16 icon?
>
> In that case a solution is to call button->setIconSize(QSize(16,16))
> *after* calling button->setIconSize(int) if you call it at all.
> To make
> this more obvious we could have a setButtonIconSize indeed, but: * in a way
> that makes it work also if setIconSize(int) is called afterwards * and I
> don't see a need for setDialogIconSize... we end up with too many redundant
> setters.
Ok a new patch is attached
Cheers
Lukas
["kiconbutton.diff" (text/x-diff)]
Index: kfile/kicondialog.h
===================================================================
--- kfile/kicondialog.h (revision 770186)
+++ kfile/kicondialog.h (working copy)
@@ -314,6 +314,19 @@
*/
int iconSize() const;
+ /**
+ * Sets the size of the icon to be shown on the button
+ * @see KIconLoader::StdSizes
+ * @see buttonIconSize
+ */
+ void setButtonIconSize( int size );
+
+ /**
+ * Returns the Button's Icon-Size
+ */
+ int buttonIconSize() const;
+
+
Q_SIGNALS:
/**
* Emitted when the icon has changed.
Index: kfile/kicondialog.cpp
===================================================================
--- kfile/kicondialog.cpp (revision 770186)
+++ kfile/kicondialog.cpp (working copy)
@@ -644,6 +644,7 @@
KIconButton *q;
int iconSize;
+ int buttonIconSize;
bool m_bStrictIconSize;
bool mbUser;
@@ -677,6 +678,7 @@
{
m_bStrictIconSize = false;
iconSize = 0; // let KIconLoader choose the default
+ buttonIconSize = -1; //When buttonIconSize is -1, iconSize will be used for the button
mGroup = KIconLoader::Desktop;
mContext = KIconLoader::Application;
@@ -709,7 +711,10 @@
void KIconButton::setIconSize( int size )
{
- QPushButton::setIconSize(QSize(size, size));
+ if (d->buttonIconSize == -1) {
+ QPushButton::setIconSize(QSize(size, size));
+ }
+
d->iconSize = size;
}
@@ -718,6 +723,17 @@
return d->iconSize;
}
+void KIconButton::setButtonIconSize( int size )
+{
+ QPushButton::setIconSize(QSize(size, size));
+ d->buttonIconSize = size;
+}
+
+int KIconButton::buttonIconSize() const
+{
+ return QPushButton::iconSize().height();
+}
+
void KIconButton::setIconType(KIconLoader::Group group, KIconLoader::Context context, bool user)
{
d->mGroup = group;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic