• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

parley

  • sources
  • kde-4.14
  • kdeedu
  • parley
  • src
  • practice
statustogglebutton.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  Copyright 2010 Daniel Laidig <laidig@kde.org>
3  ***************************************************************************/
4 
5 /***************************************************************************
6  * *
7  * This program is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  ***************************************************************************/
13 
14 #include "statustogglebutton.h"
15 
16 #include <QMouseEvent>
17 
18 using namespace Practice;
19 
20 void StatusToggleButton::setPixmaps(QPixmap defaultPixmap, QPixmap hoverPixmap, QPixmap pressedPixmap)
21 {
22  if (m_current == 1) {
23  setPixmap(hoverPixmap);
24  } else {
25  setPixmap(defaultPixmap);
26  }
27  m_defaultPixmap = defaultPixmap;
28  m_hoverPixmap = hoverPixmap;
29  m_pressedPixmap = pressedPixmap;
30 }
31 
32 void StatusToggleButton::mousePressEvent(QMouseEvent *e)
33 {
34  if (e->button() == Qt::LeftButton) {
35  this->setFadingEnabled(false);
36  setPixmap(m_pressedPixmap);
37  }
38 }
39 
40 void StatusToggleButton::mouseReleaseEvent(QMouseEvent *e)
41 {
42  if (!m_defaultPixmap.isNull() && e->button() == Qt::LeftButton) {
43  emit clicked();
44  if (m_current == 1) {
45  setPixmap(m_hoverPixmap);
46  } else {
47  setPixmap(m_defaultPixmap);
48  }
49  }
50  this->setFadingEnabled(true);
51 }
52 
53 void StatusToggleButton::enterEvent(QEvent *)
54 {
55  m_current = 1;
56  setPixmap(m_hoverPixmap);
57 }
58 
59 void StatusToggleButton::leaveEvent(QEvent *)
60 {
61  m_current = 0;
62  setPixmap(m_defaultPixmap);
63 }
64 
65 
66 #include "statustogglebutton.moc"
QEvent
QMouseEvent
Practice::StatusToggleButton::leaveEvent
void leaveEvent(QEvent *)
Definition: statustogglebutton.cpp:59
Practice::StatusToggleButton::enterEvent
void enterEvent(QEvent *)
Definition: statustogglebutton.cpp:53
Practice::StatusToggleButton::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *e)
Definition: statustogglebutton.cpp:40
QMouseEvent::button
Qt::MouseButton button() const
Practice::ImageWidget::setPixmap
void setPixmap(const QPixmap &pixmap)
Definition: imagewidget.cpp:200
Practice::StatusToggleButton::clicked
void clicked()
QPixmap
QPixmap::isNull
bool isNull() const
Practice::StatusToggleButton::mousePressEvent
void mousePressEvent(QMouseEvent *e)
Definition: statustogglebutton.cpp:32
Practice::ImageWidget::setFadingEnabled
void setFadingEnabled(bool fading)
Definition: imagewidget.cpp:235
statustogglebutton.h
Practice::StatusToggleButton::setPixmaps
void setPixmaps(QPixmap defaultPixmap, QPixmap hoverPixmap, QPixmap pressedPixmap)
Definition: statustogglebutton.cpp:20
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:15:56 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

parley

Skip menu "parley"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal