author | mickeyl <mickeyl> | 2004-01-04 17:03:31 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-01-04 17:03:31 (UTC) |
commit | ee46be7501081a10d744471582426db92ec22a9e (patch) (unidiff) | |
tree | 6fd8fe499fcd8dc77fe7982fbcea0ea8e71a443a | |
parent | c076942e5b0cdaa68a467354a563d1071c866d92 (diff) | |
download | opie-ee46be7501081a10d744471582426db92ec22a9e.zip opie-ee46be7501081a10d744471582426db92ec22a9e.tar.gz opie-ee46be7501081a10d744471582426db92ec22a9e.tar.bz2 |
code clean up and smoothscale the pixmap according to the resolution
-rw-r--r-- | noncore/applets/autorotateapplet/autorotate.cpp | 60 |
1 files changed, 24 insertions, 36 deletions
diff --git a/noncore/applets/autorotateapplet/autorotate.cpp b/noncore/applets/autorotateapplet/autorotate.cpp index 4733860..35a11db 100644 --- a/noncore/applets/autorotateapplet/autorotate.cpp +++ b/noncore/applets/autorotateapplet/autorotate.cpp | |||
@@ -12,19 +12,20 @@ | |||
12 | 12 | ||
13 | |||
14 | #include "autorotate.h" | 13 | #include "autorotate.h" |
15 | 14 | ||
16 | #include <qpe/resource.h> | 15 | /* OPIE */ |
17 | |||
18 | #include <opie/odevice.h> | 16 | #include <opie/odevice.h> |
19 | |||
20 | #include <qpe/applnk.h> | 17 | #include <qpe/applnk.h> |
21 | #include <qpe/config.h> | 18 | #include <qpe/config.h> |
19 | #include <qpe/resource.h> | ||
22 | 20 | ||
21 | /* QT */ | ||
22 | #include <qapplication.h> | ||
23 | #include <qfile.h> | ||
23 | #include <qcopchannel_qws.h> | 24 | #include <qcopchannel_qws.h> |
24 | #include <qpainter.h> | ||
25 | #include <qmessagebox.h> | 25 | #include <qmessagebox.h> |
26 | #include <qfile.h> | 26 | #include <qpainter.h> |
27 | #include <qtextstream.h> | 27 | #include <qpixmap.h> |
28 | #include <qimage.h> | ||
28 | #include <qtimer.h> | 29 | #include <qtimer.h> |
29 | #include <qapplication.h> | 30 | #include <qtextstream.h> |
30 | 31 | ||
@@ -32,8 +33,9 @@ using namespace Opie; | |||
32 | 33 | ||
33 | AutoRotate::AutoRotate(QWidget * parent):QWidget(parent), | 34 | AutoRotate::AutoRotate(QWidget * parent):QWidget(parent) |
34 | enabledPm( Resource::loadPixmap("autorotate/rotate") ), | ||
35 | disabledPm( Resource::loadPixmap("autorotate/norotate") ) | ||
36 | { | 35 | { |
37 | setFixedWidth ( AppLnk::smallIconSize() ); | 36 | setFixedWidth( AppLnk::smallIconSize() ); |
38 | setFixedHeight ( AppLnk::smallIconSize() ); | 37 | setFixedHeight( AppLnk::smallIconSize() ); |
38 | |||
39 | enabledPm.convertFromImage( Resource::loadImage("autorotate/rotate").smoothScale( height(), width() ) ); | ||
40 | disabledPm.convertFromImage( Resource::loadImage("autorotate/norotate").smoothScale( height(), width() ) ); | ||
39 | 41 | ||
@@ -54,8 +56,3 @@ void AutoRotate::mousePressEvent(QMouseEvent *) | |||
54 | QPopupMenu *menu = new QPopupMenu(this); | 56 | QPopupMenu *menu = new QPopupMenu(this); |
55 | 57 | menu->insertItem( isRotateEnabled()? "Disable Rotation" : "Enable Rotation" ,1 ); | |
56 | if (isRotateEnabled()) | ||
57 | menu->insertItem("Disable Rotation",1); | ||
58 | else | ||
59 | menu->insertItem("Enable Rotation",1); | ||
60 | |||
61 | 58 | ||
@@ -63,11 +60,7 @@ void AutoRotate::mousePressEvent(QMouseEvent *) | |||
63 | QSize s = menu->sizeHint(); | 60 | QSize s = menu->sizeHint(); |
64 | int opt = menu->exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), | 61 | int opt = menu->exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), p.y() - s.height()), 0); |
65 | p.y() - s.height()), 0); | 62 | |
66 | 63 | if (opt==1) | |
67 | if (opt==1) { | 64 | { |
68 | if (isRotateEnabled()) | 65 | setRotateEnabled( !isRotateEnabled() ); |
69 | setRotateEnabled(false); | ||
70 | else | ||
71 | setRotateEnabled(true); | ||
72 | |||
73 | repaint(true); | 66 | repaint(true); |
@@ -81,8 +74,3 @@ void AutoRotate::paintEvent(QPaintEvent *) | |||
81 | QPainter p(this); | 74 | QPainter p(this); |
82 | 75 | p.drawPixmap( 0, 0, isRotateEnabled()? enabledPm : disabledPm ); | |
83 | if ( isRotateEnabled() ) { | ||
84 | p.drawPixmap(0, 0, enabledPm ); | ||
85 | } else { | ||
86 | p.drawPixmap(0, 0, disabledPm ); | ||
87 | } | ||
88 | } | 76 | } |
@@ -93,3 +81,3 @@ void AutoRotate::setRotateEnabled(bool status) | |||
93 | cfg.setGroup( "Appearance" ); | 81 | cfg.setGroup( "Appearance" ); |
94 | cfg.writeEntry( "rotateEnabled",status ); | 82 | cfg.writeEntry( "rotateEnabled", status ); |
95 | 83 | ||
@@ -103,3 +91,3 @@ bool AutoRotate::isRotateEnabled() | |||
103 | 91 | ||
104 | if (res ) | 92 | if (res ) |
105 | qDebug("Enabled"); | 93 | qDebug("Enabled"); |