~ubuntu-branches/ubuntu/trusty/kdeplasma-addons/trusty

« back to all changes in this revision

Viewing changes to applets/plasmaboard/AlphaNumKey.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2010-05-25 09:50:14 UTC
  • mfrom: (1.1.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20100525095014-6mlrm9z9bkws0zkt
Tags: 4:4.4.80-0ubuntu1
* New upstream beta release:
  - Bump kde-sc-dev-latest build-dep version to 4.4.80
  - Refresh kubuntu_04_kimpanel_disable_scim.diff
  - Update various .install files
  - Drop liblancelot0a and liblancelot-dev packages; Upstream has broken ABI
    without an .so version bump, and after discussion with Debian it was
    decided it was not worth it to ship an unstable library.
  - Add liblancelot files to plasma-widget-lancelot, adding appropriate
    Replaces: entries
* Switch to source format 3.0 (quilt):
  - Bump debhelper build-depend version to 7.3.16 or greater

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
 
21
21
#include "AlphaNumKey.h"
22
 
 
23
22
#include "Helpers.h"
24
 
 
25
 
AlphaNumKey::AlphaNumKey(PlasmaboardWidget *parent, unsigned int keysym):
26
 
        BoardKey(parent){
27
 
 
28
 
        QObject::connect(this, SIGNAL( clicked() ), parent, SLOT( clear() ) );
29
 
        QObject::connect(this, SIGNAL( keyPressed ( QString, QSizeF, QPointF ) ), parent, SLOT( setTooltip( QString, QSizeF, QPointF ) ) );
30
 
 
31
 
        setKeycode(keysym);
 
23
#include <QPainter>
 
24
#include <plasma/theme.h>
 
25
 
 
26
AlphaNumKey::AlphaNumKey(QPoint relativePosition, QSize relativeSize, unsigned int keycode):
 
27
        BoardKey(relativePosition, relativeSize, keycode){
 
28
 
 
29
    setLabel(0);
32
30
}
33
31
 
34
32
AlphaNumKey::~AlphaNumKey() {
35
33
 
36
34
}
37
35
 
38
 
void AlphaNumKey::pressed(){
39
 
        BoardKey::pressed();
40
 
        emit keyPressed(text(), size(), pos());
41
 
}
42
 
 
43
 
void AlphaNumKey::setKeycode(unsigned int keycodeP) {
44
 
        keycode = keycodeP;
45
 
        setLabel(0);
46
 
}
47
 
 
48
 
void AlphaNumKey::setLabel(int level){
49
 
        setText( Helpers::mapToUnicode(Helpers::keycodeToKeysym(getKeycode(),level)) );
50
 
}
51
 
 
52
 
void AlphaNumKey::switchKey(bool isLevel2, bool isAlternative, bool isLocked){
 
36
QString AlphaNumKey::label() const
 
37
{
 
38
    return m_label;
 
39
}
 
40
 
 
41
void AlphaNumKey::paint(QPainter *painter)
 
42
{
 
43
    BoardKey::paint(painter);
 
44
    paintLabel(painter);
 
45
 
 
46
}
 
47
 
 
48
void AlphaNumKey::paintLabel(QPainter *painter)
 
49
{
 
50
    painter->save();
 
51
    int fontSize = qMin(size().width(), size().height()) / 2;
 
52
    painter->setFont(QFont( Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont).toString(), fontSize ));
 
53
    painter->drawText(rect(), Qt::AlignCenter, m_label);
 
54
    painter->restore();
 
55
}
 
56
 
 
57
void AlphaNumKey::setLabel(int level)
 
58
{
 
59
    //m_label = Helpers::mapToUnicode(Helpers::keycodeToKeysym(getKeycode(),level));
 
60
    setLabel(Helpers::mapToUnicode(getKeysymbol(level)));
 
61
}
 
62
 
 
63
void AlphaNumKey::setLabel(const QString &label)
 
64
{
 
65
    m_label = label;
 
66
}
 
67
 
 
68
void AlphaNumKey::switchKey(bool isLevel2, bool isAlternative, bool isLocked)
 
69
{
53
70
        if(isLocked){
54
71
                isLevel2 = !isLevel2;
55
72
        }
61
78
                /*isAlternative ?
62
79
                setText(QChar(Helpers::mapToUnicode(Helpers::keycodeToKeysym(getKeycode(),0)))) :
63
80
                setText(QChar(Helpers::mapToUnicode(Helpers::keycodeToKeysym(getKeycode(),0))));*/
64
 
        }
65
 
        update();
 
81
    }
66
82
}
67
83
 
68
84