Promoe kind of works.
This commit is contained in:
parent
9fb1376afe
commit
b8ec3a6cae
15 changed files with 183 additions and 65 deletions
41
Button.cpp
41
Button.cpp
|
|
@ -17,7 +17,6 @@ Button::setPixmaps(Skin *skin)
|
|||
m_pixmap_normal = skin->getItem (m_name_normal);
|
||||
m_pixmap_pressed = skin->getItem (m_name_pressed);
|
||||
m_pixmap = m_pixmap_normal;
|
||||
m_func = NULL;
|
||||
|
||||
setMinimumSize (m_pixmap.size ());
|
||||
setMaximumSize (m_pixmap.size ());
|
||||
|
|
@ -25,30 +24,22 @@ Button::setPixmaps(Skin *skin)
|
|||
update();
|
||||
}
|
||||
|
||||
void Button::mousePressEvent (QMouseEvent *event)
|
||||
void
|
||||
Button::mousePressEvent (QMouseEvent *event)
|
||||
{
|
||||
((SkinDisplay *)parent ())->setNoDrag (true);
|
||||
m_pixmap = m_pixmap_pressed;
|
||||
update ();
|
||||
}
|
||||
|
||||
void Button::mouseReleaseEvent (QMouseEvent *event)
|
||||
void
|
||||
Button::mouseReleaseEvent (QMouseEvent *event)
|
||||
{
|
||||
((SkinDisplay *)parent())->setNoDrag (false);
|
||||
m_pixmap = m_pixmap_normal;
|
||||
update();
|
||||
emit clicked();
|
||||
|
||||
if (m_func) {
|
||||
m_func (m_userdata);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
clicked (void *userdata)
|
||||
{
|
||||
ToggleButton *t = (ToggleButton *)userdata;
|
||||
t->toggleOn (!t->getOn());
|
||||
t->runFunc ();
|
||||
}
|
||||
|
||||
ToggleButton::ToggleButton (QWidget *parent, uint on_normal, uint on_pressed,
|
||||
|
|
@ -60,12 +51,11 @@ ToggleButton::ToggleButton (QWidget *parent, uint on_normal, uint on_pressed,
|
|||
m_name_on_pressed = on_pressed;
|
||||
m_name_off_normal = off_normal;
|
||||
m_name_off_pressed = off_pressed;
|
||||
m_toggled_on = true;
|
||||
|
||||
m_func = clicked;
|
||||
m_userdata = (void *)this;
|
||||
toggleOn ();
|
||||
|
||||
m_func2 = NULL;
|
||||
m_userdata2 = NULL;
|
||||
connect (this, SIGNAL(clicked()), this, SLOT (toggleOn()));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -77,27 +67,16 @@ ToggleButton::setPixmaps(Skin *skin)
|
|||
m_pixmap_off_normal = skin->getItem(m_name_off_normal);
|
||||
m_pixmap_off_pressed = skin->getItem(m_name_off_pressed);
|
||||
|
||||
toggleOn(m_toggled_on);
|
||||
|
||||
setMinimumSize (m_pixmap.size ());
|
||||
setMaximumSize (m_pixmap.size ());
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ToggleButton::runFunc ()
|
||||
ToggleButton::toggleOn ()
|
||||
{
|
||||
if (m_func2) {
|
||||
m_func2 (m_userdata2);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ToggleButton::toggleOn (bool t)
|
||||
{
|
||||
if (t) {
|
||||
if (!m_toggled_on) {
|
||||
m_pixmap_normal = m_pixmap_on_normal;
|
||||
m_pixmap_pressed = m_pixmap_on_pressed;
|
||||
m_toggled_on = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue