-rw-r--r-- | noncore/applets/autorotateapplet/autorotate.cpp | 50 |
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 @@ -12,19 +12,20 @@ - #include "autorotate.h" -#include <qpe/resource.h> - +/* OPIE */ #include <opie/odevice.h> - #include <qpe/applnk.h> #include <qpe/config.h> +#include <qpe/resource.h> +/* QT */ +#include <qapplication.h> +#include <qfile.h> #include <qcopchannel_qws.h> -#include <qpainter.h> #include <qmessagebox.h> -#include <qfile.h> -#include <qtextstream.h> +#include <qpainter.h> +#include <qpixmap.h> +#include <qimage.h> #include <qtimer.h> -#include <qapplication.h> +#include <qtextstream.h> @@ -32,5 +33,3 @@ using namespace Opie; -AutoRotate::AutoRotate(QWidget * parent):QWidget(parent), - enabledPm( Resource::loadPixmap("autorotate/rotate") ), - disabledPm( Resource::loadPixmap("autorotate/norotate") ) +AutoRotate::AutoRotate(QWidget * parent):QWidget(parent) { @@ -39,2 +38,5 @@ AutoRotate::AutoRotate(QWidget * parent):QWidget(parent), + enabledPm.convertFromImage( Resource::loadImage("autorotate/rotate").smoothScale( height(), width() ) ); + disabledPm.convertFromImage( Resource::loadImage("autorotate/norotate").smoothScale( height(), width() ) ); + repaint(true); @@ -54,8 +56,3 @@ void AutoRotate::mousePressEvent(QMouseEvent *) QPopupMenu *menu = new QPopupMenu(this); - - if (isRotateEnabled()) - menu->insertItem("Disable Rotation",1); - else - menu->insertItem("Enable Rotation",1); - + menu->insertItem( isRotateEnabled()? "Disable Rotation" : "Enable Rotation" ,1 ); @@ -63,11 +60,7 @@ void AutoRotate::mousePressEvent(QMouseEvent *) QSize s = menu->sizeHint(); - int opt = menu->exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), - p.y() - s.height()), 0); - - if (opt==1) { - if (isRotateEnabled()) - setRotateEnabled(false); - else - setRotateEnabled(true); + int opt = menu->exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), p.y() - s.height()), 0); + if (opt==1) + { + setRotateEnabled( !isRotateEnabled() ); repaint(true); @@ -81,8 +74,3 @@ void AutoRotate::paintEvent(QPaintEvent *) QPainter p(this); - - if ( isRotateEnabled() ) { - p.drawPixmap(0, 0, enabledPm ); - } else { - p.drawPixmap(0, 0, disabledPm ); - } + p.drawPixmap( 0, 0, isRotateEnabled()? enabledPm : disabledPm ); } |