author | kergoth <kergoth> | 2003-04-18 22:17:38 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-04-18 22:17:38 (UTC) |
commit | 6e7112a3610c4e562f991ba6d6f33ca2fe0c605d (patch) (side-by-side diff) | |
tree | ae90d7b8c36c49f109e3c2f231a119fc7fd5b799 | |
parent | d0852e67c15c5a973b7bc7f7bee238a6fd00dee6 (diff) | |
download | opie-6e7112a3610c4e562f991ba6d6f33ca2fe0c605d.zip opie-6e7112a3610c4e562f991ba6d6f33ca2fe0c605d.tar.gz opie-6e7112a3610c4e562f991ba6d6f33ca2fe0c605d.tar.bz2 |
Make appearance and rotate applet use the new rotation method of odevice.
-rw-r--r-- | core/applets/rotateapplet/rotate.cpp | 25 | ||||
-rw-r--r-- | noncore/settings/appearance2/appearance.cpp | 27 |
2 files changed, 33 insertions, 19 deletions
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp index 04270f1..62567ed 100644 --- a/core/applets/rotateapplet/rotate.cpp +++ b/core/applets/rotateapplet/rotate.cpp @@ -22,34 +22,38 @@ -- :-= this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <qpe/resource.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/qpeapplication.h> #include <qpe/config.h> #include <qiconset.h> #include <qpopupmenu.h> +#include <opie/odevice.h> + #include "rotate.h" +using namespace Opie; + RotateApplet::RotateApplet ( ) : QObject ( 0, "RotateApplet" ), ref ( 0 ), m_flipped( false ) { #if defined(Q_WS_QWS) #if !defined(QT_NO_COP) QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this ); connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ), this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); #endif #endif } RotateApplet::~RotateApplet ( ) @@ -100,68 +104,71 @@ QIconSet RotateApplet::icon ( ) const QImage img = Resource::loadImage ( "Rotation" ); if ( !img. isNull ( )) pix. convertFromImage ( img. smoothScale ( 14, 14 )); return pix; } QPopupMenu *RotateApplet::popup ( QWidget * ) const { return 0; } void RotateApplet::activated ( ) { int defaultRotation = QPEApplication::defaultRotation(); - - int newRotation; + int newRotation = defaultRotation; Config cfg( "qpe" ); cfg.setGroup( "Appearance" ); - // 0 -> 90° clockwise, 1 -> 90° counterclockwise - int rotDirection = cfg.readNumEntry( "rotatedir", 0 ); + int rotDirection = cfg.readNumEntry( "rotatedir" ); + ODirection rot = CW; + + if (rotDirection == -1) { + rot = ODevice::inst ( )-> direction ( ); + } else { + rot = (ODirection)rotDirection; + } // hide inputs methods before rotation QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); if ( m_flipped ) { // if flipped, flip back to the original state, // regardless of rotation direction newRotation = defaultRotation; } else { - if ( rotDirection == 1 ) { + if ( rot == CCW ) { newRotation = ( defaultRotation + 90 ) % 360; - } else if ( rotDirection == 0 ) { + } else if ( rot == CW ) { newRotation = ( defaultRotation + 270 ) % 360; - } else { + } else if ( rot == Flip ) { newRotation = ( defaultRotation + 180 ) % 360; } } QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); env << newRotation; m_flipped = !m_flipped; } QRESULT RotateApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) { *iface = 0; if ( uuid == IID_QUnknown ) *iface = this; else if ( uuid == IID_MenuApplet ) *iface = this; if ( *iface ) (*iface)-> addRef ( ); return QS_OK; } Q_EXPORT_INTERFACE( ) { Q_CREATE_INSTANCE( RotateApplet ) } - - diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp index 83532de..c376ec7 100644 --- a/noncore/settings/appearance2/appearance.cpp +++ b/noncore/settings/appearance2/appearance.cpp @@ -416,36 +416,44 @@ QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) rotbtngrp-> hide ( ); rotbtngrp-> setExclusive ( true ); rotbtngrp-> insert ( m_rotdir_cw ); rotbtngrp-> insert ( m_rotdir_ccw ); rotbtngrp-> insert ( m_rotdir_flip ); ccw1. convertFromImage( ccwImage ); m_rotdir_cw-> setPixmap( cw1 ); m_rotdir_ccw-> setPixmap( ccw1 ); m_rotdir_flip-> setPixmap( flip1 ); rotLay-> addWidget ( rotlabel, 0 ); rotLay-> addWidget ( m_rotdir_cw, 0 ); rotLay-> addWidget ( m_rotdir_ccw, 0 ); rotLay-> addWidget ( m_rotdir_flip, 0 ); - int rot = cfg. readNumEntry ( "rotatedir", 0 ); - m_rotdir_cw-> setChecked ( rot == 0 ); - m_rotdir_ccw-> setChecked ( rot == 1 ); - m_rotdir_flip-> setChecked ( rot == 2 ); + int rotDirection = cfg.readNumEntry( "rotatedir" ); + ODirection rot = CW; + + if (rotDirection == -1) { + rot = ODevice::inst ( )-> direction ( ); + } else { + rot = (ODirection)rotDirection; + } + + m_rotdir_cw-> setChecked ( rot == CW ); + m_rotdir_ccw-> setChecked ( rot == CCW ); + m_rotdir_flip-> setChecked ( rot == Flip ); return tab; } Appearance::Appearance( QWidget* parent, const char* name, WFlags ) : QDialog ( parent, name, true, WStyle_ContextHelp ) { setCaption( tr( "Appearance Settings" ) ); Config config( "qpe" ); config.setGroup( "Appearance" ); QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 ); m_sample = new SampleWindow ( this ); @@ -513,42 +521,41 @@ void Appearance::accept ( ) if ( m_font_changed ) { config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); } if ( m_color_changed ) { ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); if ( item ) item-> save ( config ); } - bool is_rotdir_ccw = m_rotdir_ccw-> isChecked ( ); - int rotval; + ODirection rot; if (m_rotdir_ccw-> isChecked ( )) { - rotval = 1; + rot = CCW; } else if (m_rotdir_cw-> isChecked ( )) { - rotval = 0; + rot = CW; } else { - rotval = 2; + rot = Flip; } - config. writeEntry ( "rotatedir", rotval ); + config. writeEntry ( "rotatedir", (int)rot ); m_except-> setFocus ( ); // if the focus was on the embedded line-edit, we have to move it away first, so the contents are updated QStringList sl; QString exceptstr; for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( )) { int fl = 0; fl |= ( it-> noStyle ( ) ? 0x01 : 0 ); fl |= ( it-> noFont ( ) ? 0x02 : 0 ); fl |= ( it-> noDeco ( ) ? 0x04 : 0 ); exceptstr = QString::number ( fl, 32 ); exceptstr.append( it-> pattern ( )); sl << exceptstr; } config. writeEntry ( "NoStyle", sl, ';' ); config. writeEntry ( "ForceStyle", m_force-> isChecked ( )); |