save reset calls in setSize() etc., inform buttons about what has changed in reset() so they can better optimize for performance
svn path=/trunk/kdebase/kwin/; revision=397485
This commit is contained in:
parent
66ee8c3b4d
commit
7f9e658fb3
2 changed files with 33 additions and 8 deletions
|
@ -193,6 +193,12 @@ void KCommonDecoration::updateButtons() const
|
||||||
if (m_button[n]) m_button[n]->update();
|
if (m_button[n]) m_button[n]->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KCommonDecoration::resetButtons() const
|
||||||
|
{
|
||||||
|
for (int n=0; n<NumButtons; n++)
|
||||||
|
if (m_button[n]) m_button[n]->reset(KCommonDecorationButton::ManualReset);
|
||||||
|
}
|
||||||
|
|
||||||
void KCommonDecoration::resetLayout()
|
void KCommonDecoration::resetLayout()
|
||||||
{
|
{
|
||||||
for (int n=0; n<NumButtons; n++) {
|
for (int n=0; n<NumButtons; n++) {
|
||||||
|
@ -738,7 +744,7 @@ ButtonType KCommonDecorationButton::type()
|
||||||
return m_type;;
|
return m_type;;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KCommonDecorationButton::reset()
|
void KCommonDecorationButton::reset(unsigned long)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -749,10 +755,12 @@ void KCommonDecorationButton::setRealizeButtons(int btns)
|
||||||
|
|
||||||
void KCommonDecorationButton::setSize(const QSize &s)
|
void KCommonDecorationButton::setSize(const QSize &s)
|
||||||
{
|
{
|
||||||
m_size = s;
|
if (s != size() ) {
|
||||||
|
m_size = s;
|
||||||
|
|
||||||
setFixedSize(m_size);
|
setFixedSize(m_size);
|
||||||
reset();
|
reset(SizeChange);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize KCommonDecorationButton::sizeHint() const
|
QSize KCommonDecorationButton::sizeHint() const
|
||||||
|
@ -768,13 +776,15 @@ void KCommonDecorationButton::setTipText(const QString &tip) {
|
||||||
void KCommonDecorationButton::setToggleButton(bool toggle)
|
void KCommonDecorationButton::setToggleButton(bool toggle)
|
||||||
{
|
{
|
||||||
QButton::setToggleButton(toggle);
|
QButton::setToggleButton(toggle);
|
||||||
reset();
|
reset(ToggleChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KCommonDecorationButton::setOn(bool on)
|
void KCommonDecorationButton::setOn(bool on)
|
||||||
{
|
{
|
||||||
QButton::setOn(on);
|
if (on != isOn() ) {
|
||||||
reset();
|
QButton::setOn(on);
|
||||||
|
reset(StateChange);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KCommonDecorationButton::mousePressEvent(QMouseEvent* e)
|
void KCommonDecorationButton::mousePressEvent(QMouseEvent* e)
|
||||||
|
|
|
@ -201,6 +201,10 @@ class KWIN_EXPORT KCommonDecoration : public KDecoration
|
||||||
* Makes sure all buttons are repainted.
|
* Makes sure all buttons are repainted.
|
||||||
*/
|
*/
|
||||||
void updateButtons() const;
|
void updateButtons() const;
|
||||||
|
/**
|
||||||
|
* Manually call reset() on each button.
|
||||||
|
*/
|
||||||
|
void resetButtons() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience method.
|
* Convenience method.
|
||||||
|
@ -276,10 +280,21 @@ class KWIN_EXPORT KCommonDecorationButton : public QButton
|
||||||
KCommonDecorationButton(ButtonType type, KCommonDecoration *parent, const char *name);
|
KCommonDecorationButton(ButtonType type, KCommonDecoration *parent, const char *name);
|
||||||
~KCommonDecorationButton();
|
~KCommonDecorationButton();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These flags specify what has changed, e.g. the reason for a reset().
|
||||||
|
*/
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
ManualReset = 1 << 0, ///< The button might want to do a full reset for some reason...
|
||||||
|
SizeChange = 1 << 1, ///< The button size changed @see setSize()
|
||||||
|
ToggleChange = 1 << 2, ///< The button toggle state has changed @see setToggleButton()
|
||||||
|
StateChange = 1 << 3, ///< The button has been set pressed or not... @see setOn()
|
||||||
|
DecorationReset = 1 << 4 ///< E.g. when decoration colors have changed
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Initialize the button after size change etc.
|
* Initialize the button after size change etc.
|
||||||
*/
|
*/
|
||||||
virtual void reset();
|
virtual void reset(unsigned long changed);
|
||||||
/**
|
/**
|
||||||
* @returns the KCommonDecoration the button belongs to.
|
* @returns the KCommonDecoration the button belongs to.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue