author | harlekin <harlekin> | 2003-03-25 23:06:12 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-03-25 23:06:12 (UTC) |
commit | aca404f0c049c5b1bace7e842e7e64b987f04616 (patch) (unidiff) | |
tree | 31c0722de0784b8e5c83d2fd5a93d39cb96f13a5 | |
parent | 8ee32661cc5086c2cc34c4587de9649cd290579d (diff) | |
download | opie-aca404f0c049c5b1bace7e842e7e64b987f04616.zip opie-aca404f0c049c5b1bace7e842e7e64b987f04616.tar.gz opie-aca404f0c049c5b1bace7e842e7e64b987f04616.tar.bz2 |
better interaction with the rotate app
-rw-r--r-- | core/applets/rotateapplet/rotate.cpp | 6 | ||||
-rw-r--r-- | core/applets/rotateapplet/rotate.h | 1 |
2 files changed, 3 insertions, 4 deletions
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp index 8f323d6..653c61f 100644 --- a/core/applets/rotateapplet/rotate.cpp +++ b/core/applets/rotateapplet/rotate.cpp | |||
@@ -1,127 +1,127 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2003 Maximilian Reiss <harlekin@handhelds.org> | 3 | .=l. Copyright (c) 2003 Maximilian Reiss <harlekin@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This library is free software; you can | 5 | _;:, .> :=|. This library is free software; you can |
6 | .> <, > . <= redistribute it and/or modify it under | 6 | .> <, > . <= redistribute it and/or modify it under |
7 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public | 7 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%+i> _;_. | 11 | .%+i> _;_. |
12 | .i_,=:_. -<s. This library is distributed in the hope that | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. . .: details. | 18 | ++= -. . .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
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 <qiconset.h> | 34 | #include <qiconset.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | 36 | ||
37 | #include "rotate.h" | 37 | #include "rotate.h" |
38 | 38 | ||
39 | 39 | ||
40 | RotateApplet::RotateApplet ( ) | 40 | RotateApplet::RotateApplet ( ) |
41 | : QObject ( 0, "RotateApplet" ), ref ( 0 ) | 41 | : QObject ( 0, "RotateApplet" ), ref ( 0 ) |
42 | { | 42 | { |
43 | m_native = true; | 43 | m_native = true; |
44 | m_startupRot = QPEApplication::defaultRotation(); | ||
45 | } | 44 | } |
46 | 45 | ||
47 | RotateApplet::~RotateApplet ( ) | 46 | RotateApplet::~RotateApplet ( ) |
48 | { | 47 | { |
49 | } | 48 | } |
50 | 49 | ||
51 | int RotateApplet::position ( ) const | 50 | int RotateApplet::position ( ) const |
52 | { | 51 | { |
53 | return 2; | 52 | return 2; |
54 | } | 53 | } |
55 | 54 | ||
56 | QString RotateApplet::name ( ) const | 55 | QString RotateApplet::name ( ) const |
57 | { | 56 | { |
58 | return tr( "Rotate shortcut" ); | 57 | return tr( "Rotate shortcut" ); |
59 | } | 58 | } |
60 | 59 | ||
61 | QString RotateApplet::text ( ) const | 60 | QString RotateApplet::text ( ) const |
62 | { | 61 | { |
63 | return tr( "Rotate" ); | 62 | return tr( "Rotate" ); |
64 | } | 63 | } |
65 | 64 | ||
66 | QString RotateApplet::tr( const char* s ) const | 65 | QString RotateApplet::tr( const char* s ) const |
67 | { | 66 | { |
68 | return qApp->translate( "RotateApplet", s, 0 ); | 67 | return qApp->translate( "RotateApplet", s, 0 ); |
69 | } | 68 | } |
70 | 69 | ||
71 | QString RotateApplet::tr( const char* s, const char* p ) const | 70 | QString RotateApplet::tr( const char* s, const char* p ) const |
72 | { | 71 | { |
73 | return qApp->translate( "RotateApplet", s, p ); | 72 | return qApp->translate( "RotateApplet", s, p ); |
74 | } | 73 | } |
75 | 74 | ||
76 | QIconSet RotateApplet::icon ( ) const | 75 | QIconSet RotateApplet::icon ( ) const |
77 | { | 76 | { |
78 | QPixmap pix; | 77 | QPixmap pix; |
79 | QImage img = Resource::loadImage ( "Rotation" ); | 78 | QImage img = Resource::loadImage ( "Rotation" ); |
80 | 79 | ||
81 | if ( !img. isNull ( )) | 80 | if ( !img. isNull ( )) |
82 | pix. convertFromImage ( img. smoothScale ( 14, 14 )); | 81 | pix. convertFromImage ( img. smoothScale ( 14, 14 )); |
83 | return pix; | 82 | return pix; |
84 | } | 83 | } |
85 | 84 | ||
86 | QPopupMenu *RotateApplet::popup ( QWidget * ) const | 85 | QPopupMenu *RotateApplet::popup ( QWidget * ) const |
87 | { | 86 | { |
88 | return 0; | 87 | return 0; |
89 | } | 88 | } |
90 | 89 | ||
91 | void RotateApplet::activated ( ) | 90 | void RotateApplet::activated ( ) |
92 | { | 91 | { |
92 | int currentRotation = QPEApplication::defaultRotation(); | ||
93 | int newRotation; | 93 | int newRotation; |
94 | if ( m_native == true ) { | 94 | if ( m_native == true ) { |
95 | newRotation = m_startupRot + 90; | 95 | newRotation = currentRotation + 90; |
96 | } else { | 96 | } else { |
97 | newRotation = m_startupRot; | 97 | newRotation = currentRotation - 90; |
98 | } | 98 | } |
99 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); | 99 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); |
100 | env << newRotation; | 100 | env << newRotation; |
101 | QCopEnvelope env2( "QPE/System", "setDefaultRotation(int)" ); | 101 | QCopEnvelope env2( "QPE/System", "setDefaultRotation(int)" ); |
102 | env2 << newRotation; | 102 | env2 << newRotation; |
103 | 103 | ||
104 | m_native = !m_native; | 104 | m_native = !m_native; |
105 | 105 | ||
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | QRESULT RotateApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) | 109 | QRESULT RotateApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) |
110 | { | 110 | { |
111 | *iface = 0; | 111 | *iface = 0; |
112 | if ( uuid == IID_QUnknown ) | 112 | if ( uuid == IID_QUnknown ) |
113 | *iface = this; | 113 | *iface = this; |
114 | else if ( uuid == IID_MenuApplet ) | 114 | else if ( uuid == IID_MenuApplet ) |
115 | *iface = this; | 115 | *iface = this; |
116 | 116 | ||
117 | if ( *iface ) | 117 | if ( *iface ) |
118 | (*iface)-> addRef ( ); | 118 | (*iface)-> addRef ( ); |
119 | return QS_OK; | 119 | return QS_OK; |
120 | } | 120 | } |
121 | 121 | ||
122 | Q_EXPORT_INTERFACE( ) | 122 | Q_EXPORT_INTERFACE( ) |
123 | { | 123 | { |
124 | Q_CREATE_INSTANCE( RotateApplet ) | 124 | Q_CREATE_INSTANCE( RotateApplet ) |
125 | } | 125 | } |
126 | 126 | ||
127 | 127 | ||
diff --git a/core/applets/rotateapplet/rotate.h b/core/applets/rotateapplet/rotate.h index 11e2ec9..c4087f9 100644 --- a/core/applets/rotateapplet/rotate.h +++ b/core/applets/rotateapplet/rotate.h | |||
@@ -1,62 +1,61 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2003 Maximilian Reiss <harlekin@handhelds.org> | 3 | .=l. Copyright (c) 2003 Maximilian Reiss <harlekin@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This library is free software; you can | 5 | _;:, .> :=|. This library is free software; you can |
6 | .> <_, > . <= redistribute it and/or modify it under | 6 | .> <_, > . <= redistribute it and/or modify it under |
7 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public | 7 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%+i> _;_. | 11 | .%+i> _;_. |
12 | .i_,=:_. -<s. This library is distributed in the hope that | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. . .: details. | 18 | ++= -. . .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
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 | 30 | ||
31 | #ifndef __OPIE_ROTATE_APPLET_H__ | 31 | #ifndef __OPIE_ROTATE_APPLET_H__ |
32 | #define __OPIE_ROTATE_APPLET_H__ | 32 | #define __OPIE_ROTATE_APPLET_H__ |
33 | 33 | ||
34 | #include <qpe/menuappletinterface.h> | 34 | #include <qpe/menuappletinterface.h> |
35 | 35 | ||
36 | class RotateApplet : public QObject, public MenuAppletInterface | 36 | class RotateApplet : public QObject, public MenuAppletInterface |
37 | { | 37 | { |
38 | public: | 38 | public: |
39 | RotateApplet ( ); | 39 | RotateApplet ( ); |
40 | virtual ~RotateApplet ( ); | 40 | virtual ~RotateApplet ( ); |
41 | 41 | ||
42 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | 42 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); |
43 | Q_REFCOUNT | 43 | Q_REFCOUNT |
44 | 44 | ||
45 | virtual int position() const; | 45 | virtual int position() const; |
46 | 46 | ||
47 | virtual QString name ( ) const; | 47 | virtual QString name ( ) const; |
48 | virtual QIconSet icon ( ) const; | 48 | virtual QIconSet icon ( ) const; |
49 | virtual QString text ( ) const; | 49 | virtual QString text ( ) const; |
50 | virtual QString tr( const char* ) const; | 50 | virtual QString tr( const char* ) const; |
51 | virtual QString tr( const char*, const char* ) const; | 51 | virtual QString tr( const char*, const char* ) const; |
52 | virtual QPopupMenu *popup ( QWidget *parent ) const; | 52 | virtual QPopupMenu *popup ( QWidget *parent ) const; |
53 | 53 | ||
54 | virtual void activated ( ); | 54 | virtual void activated ( ); |
55 | 55 | ||
56 | private: | 56 | private: |
57 | bool m_native; | 57 | bool m_native; |
58 | int m_startupRot; | ||
59 | ulong ref; | 58 | ulong ref; |
60 | }; | 59 | }; |
61 | 60 | ||
62 | #endif | 61 | #endif |