summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-01-04 17:03:31 (UTC)
committer mickeyl <mickeyl>2004-01-04 17:03:31 (UTC)
commitee46be7501081a10d744471582426db92ec22a9e (patch) (side-by-side diff)
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) (ignore whitespace changes)
-rw-r--r--noncore/applets/autorotateapplet/autorotate.cpp60
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
@@ -11,30 +11,32 @@
*************************************************************************/
-
#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>
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)
{
- setFixedWidth ( AppLnk::smallIconSize() );
- setFixedHeight ( AppLnk::smallIconSize() );
+ setFixedWidth( AppLnk::smallIconSize() );
+ setFixedHeight( AppLnk::smallIconSize() );
+
+ enabledPm.convertFromImage( Resource::loadImage("autorotate/rotate").smoothScale( height(), width() ) );
+ disabledPm.convertFromImage( Resource::loadImage("autorotate/norotate").smoothScale( height(), width() ) );
repaint(true);
@@ -53,22 +55,13 @@ 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 );
QPoint p = mapToGlobal(QPoint(0, 0));
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);
}
@@ -80,10 +73,5 @@ 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 );
}
@@ -92,5 +80,5 @@ void AutoRotate::setRotateEnabled(bool status)
Config cfg( "qpe" );
cfg.setGroup( "Appearance" );
- cfg.writeEntry( "rotateEnabled",status );
+ cfg.writeEntry( "rotateEnabled", status );
}
@@ -102,5 +90,5 @@ bool AutoRotate::isRotateEnabled()
bool res = cfg.readBoolEntry( "rotateEnabled" );
- if (res )
+ if (res )
qDebug("Enabled");
else