Diffstat (limited to 'noncore/applets/autorotateapplet/autorotate.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/autorotateapplet/autorotate.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/noncore/applets/autorotateapplet/autorotate.cpp b/noncore/applets/autorotateapplet/autorotate.cpp index 5152904..94be0ae 100644 --- a/noncore/applets/autorotateapplet/autorotate.cpp +++ b/noncore/applets/autorotateapplet/autorotate.cpp | |||
@@ -1,90 +1,101 @@ | |||
1 | /* | 1 | /* |
2 | * copyright : (c) 2003 by Greg Gilbert | 2 | * copyright : (c) 2003 by Greg Gilbert |
3 | * email : greg@treke.net | 3 | * email : greg@treke.net |
4 | * based on the cardmon applet by Max Reiss | 4 | * based on the cardmon applet by Max Reiss |
5 | * * | 5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * | 6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License as published by * | 7 | * it under the terms of the GNU General Public License as published by * |
8 | * the Free Software Foundation; either version 2 of the License, or * | 8 | * the Free Software Foundation; either version 2 of the License, or * |
9 | * (at your option) any later version. * | 9 | * (at your option) any later version. * |
10 | * * | 10 | * * |
11 | *************************************************************************/ | 11 | *************************************************************************/ |
12 | 12 | ||
13 | #include "autorotate.h" | 13 | #include "autorotate.h" |
14 | 14 | ||
15 | /* OPIE */ | 15 | /* OPIE */ |
16 | #include <opie2/odevice.h> | 16 | #include <opie2/odevice.h> |
17 | #include <opie2/otaskbarapplet.h> | ||
17 | #include <qpe/applnk.h> | 18 | #include <qpe/applnk.h> |
18 | #include <qpe/config.h> | 19 | #include <qpe/config.h> |
19 | #include <qpe/resource.h> | 20 | #include <qpe/resource.h> |
20 | 21 | ||
21 | /* QT */ | 22 | /* QT */ |
22 | #include <qpainter.h> | 23 | #include <qpainter.h> |
23 | 24 | ||
24 | using namespace Opie; | 25 | using namespace Opie; |
25 | 26 | ||
26 | AutoRotate::AutoRotate(QWidget * parent):QWidget(parent) | 27 | AutoRotate::AutoRotate(QWidget * parent):QWidget(parent) |
27 | { | 28 | { |
28 | setFixedWidth( AppLnk::smallIconSize() ); | 29 | setFixedWidth( AppLnk::smallIconSize() ); |
29 | setFixedHeight( AppLnk::smallIconSize() ); | 30 | setFixedHeight( AppLnk::smallIconSize() ); |
30 | 31 | ||
31 | enabledPm.convertFromImage( Resource::loadImage("autorotate/rotate").smoothScale( height(), width() ) ); | 32 | enabledPm.convertFromImage( Resource::loadImage("autorotate/rotate").smoothScale( height(), width() ) ); |
32 | disabledPm.convertFromImage( Resource::loadImage("autorotate/norotate").smoothScale( height(), width() ) ); | 33 | disabledPm.convertFromImage( Resource::loadImage("autorotate/norotate").smoothScale( height(), width() ) ); |
33 | 34 | ||
34 | repaint(true); | 35 | repaint(true); |
35 | popupMenu = 0; | 36 | popupMenu = 0; |
36 | show(); | 37 | show(); |
37 | } | 38 | } |
38 | 39 | ||
39 | AutoRotate::~AutoRotate() | 40 | AutoRotate::~AutoRotate() |
40 | { | 41 | { |
41 | if (popupMenu) { | 42 | if (popupMenu) { |
42 | delete popupMenu; | 43 | delete popupMenu; |
43 | } | 44 | } |
44 | } | 45 | } |
45 | 46 | ||
47 | int AutoRotate::position() | ||
48 | { | ||
49 | return 7; | ||
50 | } | ||
51 | |||
46 | void AutoRotate::mousePressEvent(QMouseEvent *) | 52 | void AutoRotate::mousePressEvent(QMouseEvent *) |
47 | { | 53 | { |
48 | QPopupMenu *menu = new QPopupMenu(this); | 54 | QPopupMenu *menu = new QPopupMenu(this); |
49 | menu->insertItem( isRotateEnabled()? "Disable Rotation" : "Enable Rotation" ,1 ); | 55 | menu->insertItem( isRotateEnabled()? "Disable Rotation" : "Enable Rotation" ,1 ); |
50 | 56 | ||
51 | QPoint p = mapToGlobal(QPoint(0, 0)); | 57 | QPoint p = mapToGlobal(QPoint(0, 0)); |
52 | QSize s = menu->sizeHint(); | 58 | QSize s = menu->sizeHint(); |
53 | int opt = menu->exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), p.y() - s.height()), 0); | 59 | int opt = menu->exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), p.y() - s.height()), 0); |
54 | 60 | ||
55 | if (opt==1) | 61 | if (opt==1) |
56 | { | 62 | { |
57 | setRotateEnabled( !isRotateEnabled() ); | 63 | setRotateEnabled( !isRotateEnabled() ); |
58 | repaint(true); | 64 | repaint(true); |
59 | } | 65 | } |
60 | 66 | ||
61 | delete menu; | 67 | delete menu; |
62 | } | 68 | } |
63 | 69 | ||
64 | void AutoRotate::paintEvent(QPaintEvent *) | 70 | void AutoRotate::paintEvent(QPaintEvent *) |
65 | { | 71 | { |
66 | QPainter p(this); | 72 | QPainter p(this); |
67 | p.drawPixmap( 0, 0, isRotateEnabled()? enabledPm : disabledPm ); | 73 | p.drawPixmap( 0, 0, isRotateEnabled()? enabledPm : disabledPm ); |
68 | } | 74 | } |
69 | 75 | ||
70 | void AutoRotate::setRotateEnabled(bool status) | 76 | void AutoRotate::setRotateEnabled(bool status) |
71 | { | 77 | { |
72 | Config cfg( "qpe" ); | 78 | Config cfg( "qpe" ); |
73 | cfg.setGroup( "Appearance" ); | 79 | cfg.setGroup( "Appearance" ); |
74 | cfg.writeEntry( "rotateEnabled", status ); | 80 | cfg.writeEntry( "rotateEnabled", status ); |
75 | 81 | ||
76 | } | 82 | } |
77 | bool AutoRotate::isRotateEnabled() | 83 | bool AutoRotate::isRotateEnabled() |
78 | { | 84 | { |
79 | Config cfg( "qpe" ); | 85 | Config cfg( "qpe" ); |
80 | cfg.setGroup( "Appearance" ); | 86 | cfg.setGroup( "Appearance" ); |
81 | 87 | ||
82 | bool res = cfg.readBoolEntry( "rotateEnabled" ); | 88 | bool res = cfg.readBoolEntry( "rotateEnabled" ); |
83 | 89 | ||
84 | if (res ) | 90 | if (res ) |
85 | qDebug("Enabled"); | 91 | qDebug("Enabled"); |
86 | else | 92 | else |
87 | qDebug("Disabled"); | 93 | qDebug("Disabled"); |
88 | return res; | 94 | return res; |
89 | } | 95 | } |
90 | 96 | ||
97 | Q_EXPORT_INTERFACE() | ||
98 | { | ||
99 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<AutoRotate> ); | ||
100 | } | ||
101 | |||