summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-04-18 22:17:38 (UTC)
committer kergoth <kergoth>2003-04-18 22:17:38 (UTC)
commit6e7112a3610c4e562f991ba6d6f33ca2fe0c605d (patch) (unidiff)
treeae90d7b8c36c49f109e3c2f231a119fc7fd5b799
parentd0852e67c15c5a973b7bc7f7bee238a6fd00dee6 (diff)
downloadopie-6e7112a3610c4e562f991ba6d6f33ca2fe0c605d.zip
opie-6e7112a3610c4e562f991ba6d6f33ca2fe0c605d.tar.gz
opie-6e7112a3610c4e562f991ba6d6f33ca2fe0c605d.tar.bz2
Make appearance and rotate applet use the new rotation method of odevice.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/rotateapplet/rotate.cpp25
-rw-r--r--noncore/settings/appearance2/appearance.cpp27
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 @@
22    --        :-= this library; see the file COPYING.LIB. 22    --        :-= this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29 29
30#include <qpe/resource.h> 30#include <qpe/resource.h>
31#include <qpe/qcopenvelope_qws.h> 31#include <qpe/qcopenvelope_qws.h>
32 32
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#include <qpe/config.h> 34#include <qpe/config.h>
35#include <qiconset.h> 35#include <qiconset.h>
36#include <qpopupmenu.h> 36#include <qpopupmenu.h>
37 37
38#include <opie/odevice.h>
39
38#include "rotate.h" 40#include "rotate.h"
39 41
42using namespace Opie;
43
40 44
41RotateApplet::RotateApplet ( ) 45RotateApplet::RotateApplet ( )
42 : QObject ( 0, "RotateApplet" ), ref ( 0 ), m_flipped( false ) 46 : QObject ( 0, "RotateApplet" ), ref ( 0 ), m_flipped( false )
43{ 47{
44 48
45#if defined(Q_WS_QWS) 49#if defined(Q_WS_QWS)
46#if !defined(QT_NO_COP) 50#if !defined(QT_NO_COP)
47 QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this ); 51 QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this );
48 connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ), 52 connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ),
49 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); 53 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) );
50#endif 54#endif
51#endif 55#endif
52 56
53} 57}
54 58
55RotateApplet::~RotateApplet ( ) 59RotateApplet::~RotateApplet ( )
@@ -100,68 +104,71 @@ QIconSet RotateApplet::icon ( ) const
100 QImage img = Resource::loadImage ( "Rotation" ); 104 QImage img = Resource::loadImage ( "Rotation" );
101 105
102 if ( !img. isNull ( )) 106 if ( !img. isNull ( ))
103 pix. convertFromImage ( img. smoothScale ( 14, 14 )); 107 pix. convertFromImage ( img. smoothScale ( 14, 14 ));
104 return pix; 108 return pix;
105} 109}
106 110
107QPopupMenu *RotateApplet::popup ( QWidget * ) const 111QPopupMenu *RotateApplet::popup ( QWidget * ) const
108{ 112{
109 return 0; 113 return 0;
110} 114}
111 115
112void RotateApplet::activated ( ) 116void RotateApplet::activated ( )
113{ 117{
114 118
115 int defaultRotation = QPEApplication::defaultRotation(); 119 int defaultRotation = QPEApplication::defaultRotation();
116 120 int newRotation = defaultRotation;
117 int newRotation;
118 121
119 Config cfg( "qpe" ); 122 Config cfg( "qpe" );
120 cfg.setGroup( "Appearance" ); 123 cfg.setGroup( "Appearance" );
121 124
122 // 0 -> 90° clockwise, 1 -> 90° counterclockwise 125 int rotDirection = cfg.readNumEntry( "rotatedir" );
123 int rotDirection = cfg.readNumEntry( "rotatedir", 0 ); 126 ODirection rot = CW;
127
128 if (rotDirection == -1) {
129 rot = ODevice::inst ( )-> direction ( );
130 } else {
131 rot = (ODirection)rotDirection;
132 }
124 133
125 // hide inputs methods before rotation 134 // hide inputs methods before rotation
126 QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); 135 QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" );
127 136
128 if ( m_flipped ) { 137 if ( m_flipped ) {
129 // if flipped, flip back to the original state, 138 // if flipped, flip back to the original state,
130 // regardless of rotation direction 139 // regardless of rotation direction
131 newRotation = defaultRotation; 140 newRotation = defaultRotation;
132 } else { 141 } else {
133 if ( rotDirection == 1 ) { 142 if ( rot == CCW ) {
134 newRotation = ( defaultRotation + 90 ) % 360; 143 newRotation = ( defaultRotation + 90 ) % 360;
135 } else if ( rotDirection == 0 ) { 144 } else if ( rot == CW ) {
136 newRotation = ( defaultRotation + 270 ) % 360; 145 newRotation = ( defaultRotation + 270 ) % 360;
137 } else { 146 } else if ( rot == Flip ) {
138 newRotation = ( defaultRotation + 180 ) % 360; 147 newRotation = ( defaultRotation + 180 ) % 360;
139 } 148 }
140 } 149 }
141 150
142 QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); 151 QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" );
143 env << newRotation; 152 env << newRotation;
144 153
145 m_flipped = !m_flipped; 154 m_flipped = !m_flipped;
146} 155}
147 156
148 157
149QRESULT RotateApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) 158QRESULT RotateApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface )
150{ 159{
151 *iface = 0; 160 *iface = 0;
152 if ( uuid == IID_QUnknown ) 161 if ( uuid == IID_QUnknown )
153 *iface = this; 162 *iface = this;
154 else if ( uuid == IID_MenuApplet ) 163 else if ( uuid == IID_MenuApplet )
155 *iface = this; 164 *iface = this;
156 165
157 if ( *iface ) 166 if ( *iface )
158 (*iface)-> addRef ( ); 167 (*iface)-> addRef ( );
159 return QS_OK; 168 return QS_OK;
160} 169}
161 170
162Q_EXPORT_INTERFACE( ) 171Q_EXPORT_INTERFACE( )
163{ 172{
164 Q_CREATE_INSTANCE( RotateApplet ) 173 Q_CREATE_INSTANCE( RotateApplet )
165} 174}
166
167
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 )
416 rotbtngrp-> hide ( ); 416 rotbtngrp-> hide ( );
417 rotbtngrp-> setExclusive ( true ); 417 rotbtngrp-> setExclusive ( true );
418 rotbtngrp-> insert ( m_rotdir_cw ); 418 rotbtngrp-> insert ( m_rotdir_cw );
419 rotbtngrp-> insert ( m_rotdir_ccw ); 419 rotbtngrp-> insert ( m_rotdir_ccw );
420 rotbtngrp-> insert ( m_rotdir_flip ); 420 rotbtngrp-> insert ( m_rotdir_flip );
421 421
422 ccw1. convertFromImage( ccwImage ); 422 ccw1. convertFromImage( ccwImage );
423 m_rotdir_cw-> setPixmap( cw1 ); 423 m_rotdir_cw-> setPixmap( cw1 );
424 m_rotdir_ccw-> setPixmap( ccw1 ); 424 m_rotdir_ccw-> setPixmap( ccw1 );
425 m_rotdir_flip-> setPixmap( flip1 ); 425 m_rotdir_flip-> setPixmap( flip1 );
426 426
427 rotLay-> addWidget ( rotlabel, 0 ); 427 rotLay-> addWidget ( rotlabel, 0 );
428 rotLay-> addWidget ( m_rotdir_cw, 0 ); 428 rotLay-> addWidget ( m_rotdir_cw, 0 );
429 rotLay-> addWidget ( m_rotdir_ccw, 0 ); 429 rotLay-> addWidget ( m_rotdir_ccw, 0 );
430 rotLay-> addWidget ( m_rotdir_flip, 0 ); 430 rotLay-> addWidget ( m_rotdir_flip, 0 );
431 431
432 int rot = cfg. readNumEntry ( "rotatedir", 0 ); 432 int rotDirection = cfg.readNumEntry( "rotatedir" );
433 m_rotdir_cw-> setChecked ( rot == 0 ); 433 ODirection rot = CW;
434 m_rotdir_ccw-> setChecked ( rot == 1 ); 434
435 m_rotdir_flip-> setChecked ( rot == 2 ); 435 if (rotDirection == -1) {
436 rot = ODevice::inst ( )-> direction ( );
437 } else {
438 rot = (ODirection)rotDirection;
439 }
440
441 m_rotdir_cw-> setChecked ( rot == CW );
442 m_rotdir_ccw-> setChecked ( rot == CCW );
443 m_rotdir_flip-> setChecked ( rot == Flip );
436 444
437 return tab; 445 return tab;
438} 446}
439 447
440 448
441Appearance::Appearance( QWidget* parent, const char* name, WFlags ) 449Appearance::Appearance( QWidget* parent, const char* name, WFlags )
442 : QDialog ( parent, name, true, WStyle_ContextHelp ) 450 : QDialog ( parent, name, true, WStyle_ContextHelp )
443{ 451{
444 setCaption( tr( "Appearance Settings" ) ); 452 setCaption( tr( "Appearance Settings" ) );
445 453
446 Config config( "qpe" ); 454 Config config( "qpe" );
447 config.setGroup( "Appearance" ); 455 config.setGroup( "Appearance" );
448 456
449 QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 ); 457 QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 );
450 458
451 m_sample = new SampleWindow ( this ); 459 m_sample = new SampleWindow ( this );
@@ -513,42 +521,41 @@ void Appearance::accept ( )
513 521
514 if ( m_font_changed ) { 522 if ( m_font_changed ) {
515 config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); 523 config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( ));
516 config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); 524 config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( ));
517 config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); 525 config. writeEntry ( "FontSize", m_fontselect-> fontSize ( ));
518 } 526 }
519 527
520 528
521 if ( m_color_changed ) 529 if ( m_color_changed )
522 { 530 {
523 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); 531 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( ));
524 532
525 if ( item ) 533 if ( item )
526 item-> save ( config ); 534 item-> save ( config );
527 } 535 }
528 536
529 bool is_rotdir_ccw = m_rotdir_ccw-> isChecked ( ); 537 ODirection rot;
530 int rotval;
531 if (m_rotdir_ccw-> isChecked ( )) { 538 if (m_rotdir_ccw-> isChecked ( )) {
532 rotval = 1; 539 rot = CCW;
533 } else if (m_rotdir_cw-> isChecked ( )) { 540 } else if (m_rotdir_cw-> isChecked ( )) {
534 rotval = 0; 541 rot = CW;
535 } else { 542 } else {
536 rotval = 2; 543 rot = Flip;
537 } 544 }
538 config. writeEntry ( "rotatedir", rotval ); 545 config. writeEntry ( "rotatedir", (int)rot );
539 546
540 m_except-> setFocus ( ); // if the focus was on the embedded line-edit, we have to move it away first, so the contents are updated 547 m_except-> setFocus ( ); // if the focus was on the embedded line-edit, we have to move it away first, so the contents are updated
541 548
542 QStringList sl; 549 QStringList sl;
543 QString exceptstr; 550 QString exceptstr;
544 for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( )) { 551 for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( )) {
545 int fl = 0; 552 int fl = 0;
546 fl |= ( it-> noStyle ( ) ? 0x01 : 0 ); 553 fl |= ( it-> noStyle ( ) ? 0x01 : 0 );
547 fl |= ( it-> noFont ( ) ? 0x02 : 0 ); 554 fl |= ( it-> noFont ( ) ? 0x02 : 0 );
548 fl |= ( it-> noDeco ( ) ? 0x04 : 0 ); 555 fl |= ( it-> noDeco ( ) ? 0x04 : 0 );
549 exceptstr = QString::number ( fl, 32 ); 556 exceptstr = QString::number ( fl, 32 );
550 exceptstr.append( it-> pattern ( )); 557 exceptstr.append( it-> pattern ( ));
551 sl << exceptstr; 558 sl << exceptstr;
552 } 559 }
553 config. writeEntry ( "NoStyle", sl, ';' ); 560 config. writeEntry ( "NoStyle", sl, ';' );
554 config. writeEntry ( "ForceStyle", m_force-> isChecked ( )); 561 config. writeEntry ( "ForceStyle", m_force-> isChecked ( ));