From ee46be7501081a10d744471582426db92ec22a9e Mon Sep 17 00:00:00 2001 From: mickeyl Date: Sun, 04 Jan 2004 17:03:31 +0000 Subject: code clean up and smoothscale the pixmap according to the resolution --- (limited to 'noncore') 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,32 +10,34 @@ * * *************************************************************************/ - #include "autorotate.h" -#include - +/* OPIE */ #include - #include #include +#include +/* QT */ +#include +#include #include -#include #include -#include -#include +#include +#include +#include #include -#include +#include 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); popupMenu = 0; @@ -52,24 +54,15 @@ AutoRotate::~AutoRotate() 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); } @@ -79,19 +72,14 @@ void AutoRotate::mousePressEvent(QMouseEvent *) 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 ); } void AutoRotate::setRotateEnabled(bool status) { Config cfg( "qpe" ); cfg.setGroup( "Appearance" ); - cfg.writeEntry( "rotateEnabled",status ); + cfg.writeEntry( "rotateEnabled", status ); } bool AutoRotate::isRotateEnabled() @@ -101,7 +89,7 @@ bool AutoRotate::isRotateEnabled() bool res = cfg.readBoolEntry( "rotateEnabled" ); - if (res ) + if (res ) qDebug("Enabled"); else qDebug("Disabled"); -- cgit v0.9.0.2