summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-01-04 17:03:31 (UTC)
committer mickeyl <mickeyl>2004-01-04 17:03:31 (UTC)
commitee46be7501081a10d744471582426db92ec22a9e (patch) (unidiff)
tree6fd8fe499fcd8dc77fe7982fbcea0ea8e71a443a
parentc076942e5b0cdaa68a467354a563d1071c866d92 (diff)
downloadopie-ee46be7501081a10d744471582426db92ec22a9e.zip
opie-ee46be7501081a10d744471582426db92ec22a9e.tar.gz
opie-ee46be7501081a10d744471582426db92ec22a9e.tar.bz2
code clean up and smoothscale the pixmap according to the resolution
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/applets/autorotateapplet/autorotate.cpp50
1 files changed, 19 insertions, 31 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
@@ -10,33 +10,35 @@
10 * * 10 * *
11 *************************************************************************/ 11 *************************************************************************/
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
31using namespace Opie; 32using namespace Opie;
32 33
33AutoRotate::AutoRotate(QWidget * parent):QWidget(parent), 34AutoRotate::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() );
39 38
39 enabledPm.convertFromImage( Resource::loadImage("autorotate/rotate").smoothScale( height(), width() ) );
40 disabledPm.convertFromImage( Resource::loadImage("autorotate/norotate").smoothScale( height(), width() ) );
41
40 repaint(true); 42 repaint(true);
41 popupMenu = 0; 43 popupMenu = 0;
42 show(); 44 show();
@@ -52,24 +54,15 @@ AutoRotate::~AutoRotate()
52void AutoRotate::mousePressEvent(QMouseEvent *) 54void AutoRotate::mousePressEvent(QMouseEvent *)
53{ 55{
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
62 QPoint p = mapToGlobal(QPoint(0, 0)); 59 QPoint p = mapToGlobal(QPoint(0, 0));
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);
66
67 if (opt==1) {
68 if (isRotateEnabled())
69 setRotateEnabled(false);
70 else
71 setRotateEnabled(true);
72 62
63 if (opt==1)
64 {
65 setRotateEnabled( !isRotateEnabled() );
73 repaint(true); 66 repaint(true);
74 } 67 }
75 68
@@ -79,12 +72,7 @@ void AutoRotate::mousePressEvent(QMouseEvent *)
79void AutoRotate::paintEvent(QPaintEvent *) 72void AutoRotate::paintEvent(QPaintEvent *)
80{ 73{
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}
89 77
90void AutoRotate::setRotateEnabled(bool status) 78void AutoRotate::setRotateEnabled(bool status)