~ubuntu-branches/ubuntu/quantal/qtmobility/quantal

« back to all changes in this revision

Viewing changes to examples/hapticsquare/hapticbutton.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-11-16 16:18:07 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20101116161807-k2dzt2nyse975r3l
Tags: 1.1.0-0ubuntu1
* New upstream release
* Syncronise with Debian, no remaining changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "hapticbutton.h"
 
2
#include <QPainter>
 
3
 
 
4
HapticButton::HapticButton(const QString &label) :
 
5
    QWidget(0), m_label(label), m_checked(false), m_checkable(false)
 
6
{
 
7
    setMinimumSize(100, 100);
 
8
}
 
9
 
 
10
void HapticButton::mousePressEvent(QMouseEvent *)
 
11
{
 
12
    if (m_checkable) {
 
13
        m_checked = !m_checked;
 
14
        emit toggled(m_checked);
 
15
    } else {
 
16
        emit clicked();
 
17
    }
 
18
}
 
19
 
 
20
void HapticButton::paintEvent(QPaintEvent *)
 
21
{
 
22
    QPainter paint(this);
 
23
 
 
24
    QRect r(0, 0, width()-1, height()-1);
 
25
    paint.drawRoundedRect(r, 10, 10);
 
26
    paint.drawText(r, Qt::AlignCenter, m_label);
 
27
}