author | chicken <chicken> | 2004-03-01 18:10:37 (UTC) |
---|---|---|
committer | chicken <chicken> | 2004-03-01 18:10:37 (UTC) |
commit | 7fd20d139e2d9bc37ce22bbdb07f4ebc54903f91 (patch) (unidiff) | |
tree | 15ef5e3d00c5476ea98ca36ba6c8392eb02e53c8 /library/qpemenubar.cpp | |
parent | 5b4e342004537f84fa53911a46cd00d810378da7 (diff) | |
download | opie-7fd20d139e2d9bc37ce22bbdb07f4ebc54903f91.zip opie-7fd20d139e2d9bc37ce22bbdb07f4ebc54903f91.tar.gz opie-7fd20d139e2d9bc37ce22bbdb07f4ebc54903f91.tar.bz2 |
fix includes
-rw-r--r-- | library/qpemenubar.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/library/qpemenubar.cpp b/library/qpemenubar.cpp index 3e5bad5..1d8eff4 100644 --- a/library/qpemenubar.cpp +++ b/library/qpemenubar.cpp | |||
@@ -1,153 +1,152 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define INCLUDE_MENUITEM_DEF | 21 | #define INCLUDE_MENUITEM_DEF |
22 | 22 | ||
23 | #include "qpemenubar.h" | 23 | #include "qpemenubar.h" |
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | #include <qguardedptr.h> | ||
26 | #include <qtimer.h> | 25 | #include <qtimer.h> |
27 | 26 | ||
28 | 27 | ||
29 | class QMenuBarHack : public QMenuBar | 28 | class QMenuBarHack : public QMenuBar |
30 | { | 29 | { |
31 | public: | 30 | public: |
32 | int activeItem() const { return actItem; } | 31 | int activeItem() const { return actItem; } |
33 | 32 | ||
34 | void goodbye() | 33 | void goodbye() |
35 | { | 34 | { |
36 | activateItemAt(-1); | 35 | activateItemAt(-1); |
37 | for ( unsigned int i = 0; i < count(); i++ ) { | 36 | for ( unsigned int i = 0; i < count(); i++ ) { |
38 | QMenuItem *mi = findItem( idAt(i) ); | 37 | QMenuItem *mi = findItem( idAt(i) ); |
39 | if ( mi->popup() ) { | 38 | if ( mi->popup() ) { |
40 | mi->popup()->hide(); | 39 | mi->popup()->hide(); |
41 | } | 40 | } |
42 | } | 41 | } |
43 | } | 42 | } |
44 | }; | 43 | }; |
45 | 44 | ||
46 | 45 | ||
47 | // Sharp ROM compatibility | 46 | // Sharp ROM compatibility |
48 | void QPEMenuToolFocusManager::setMenukeyEnabled ( bool ) | 47 | void QPEMenuToolFocusManager::setMenukeyEnabled ( bool ) |
49 | { | 48 | { |
50 | } | 49 | } |
51 | int QPEMenuBar::getOldFocus ( ) | 50 | int QPEMenuBar::getOldFocus ( ) |
52 | { | 51 | { |
53 | return 0; | 52 | return 0; |
54 | } | 53 | } |
55 | 54 | ||
56 | QPEMenuToolFocusManager *QPEMenuToolFocusManager::me = 0; | 55 | QPEMenuToolFocusManager *QPEMenuToolFocusManager::me = 0; |
57 | 56 | ||
58 | QPEMenuToolFocusManager::QPEMenuToolFocusManager() : QObject() | 57 | QPEMenuToolFocusManager::QPEMenuToolFocusManager() : QObject() |
59 | { | 58 | { |
60 | qApp->installEventFilter( this ); | 59 | qApp->installEventFilter( this ); |
61 | } | 60 | } |
62 | 61 | ||
63 | void QPEMenuToolFocusManager::addWidget( QWidget *w ) | 62 | void QPEMenuToolFocusManager::addWidget( QWidget *w ) |
64 | { | 63 | { |
65 | list.append( GuardedWidget(w) ); | 64 | list.append( GuardedWidget(w) ); |
66 | } | 65 | } |
67 | 66 | ||
68 | void QPEMenuToolFocusManager::removeWidget( QWidget *w ) | 67 | void QPEMenuToolFocusManager::removeWidget( QWidget *w ) |
69 | { | 68 | { |
70 | list.remove( GuardedWidget(w) ); | 69 | list.remove( GuardedWidget(w) ); |
71 | } | 70 | } |
72 | 71 | ||
73 | void QPEMenuToolFocusManager::setActive( bool a ) | 72 | void QPEMenuToolFocusManager::setActive( bool a ) |
74 | { | 73 | { |
75 | if ( a ) { | 74 | if ( a ) { |
76 | oldFocus = qApp->focusWidget(); | 75 | oldFocus = qApp->focusWidget(); |
77 | QValueList<GuardedWidget>::Iterator it; | 76 | QValueList<GuardedWidget>::Iterator it; |
78 | it = list.begin(); | 77 | it = list.begin(); |
79 | while ( it != list.end() ) { | 78 | while ( it != list.end() ) { |
80 | QWidget *w = (*it); | 79 | QWidget *w = (*it); |
81 | if ( w && w->isEnabled() && w->isVisible() && | 80 | if ( w && w->isEnabled() && w->isVisible() && |
82 | w->topLevelWidget() == qApp->activeWindow() ) { | 81 | w->topLevelWidget() == qApp->activeWindow() ) { |
83 | setFocus( w ); | 82 | setFocus( w ); |
84 | return; | 83 | return; |
85 | } | 84 | } |
86 | ++it; | 85 | ++it; |
87 | } | 86 | } |
88 | } else { | 87 | } else { |
89 | if ( inFocus ) { | 88 | if ( inFocus ) { |
90 | if ( inFocus->inherits( "QMenuBar" ) ) | 89 | if ( inFocus->inherits( "QMenuBar" ) ) |
91 | ((QMenuBarHack *)(QWidget *)inFocus)->goodbye(); | 90 | ((QMenuBarHack *)(QWidget *)inFocus)->goodbye(); |
92 | if ( inFocus->hasFocus() ) { | 91 | if ( inFocus->hasFocus() ) { |
93 | if ( oldFocus && oldFocus->isVisible() && oldFocus->isEnabled() ) { | 92 | if ( oldFocus && oldFocus->isVisible() && oldFocus->isEnabled() ) { |
94 | oldFocus->setFocus(); | 93 | oldFocus->setFocus(); |
95 | } else { | 94 | } else { |
96 | inFocus->clearFocus(); | 95 | inFocus->clearFocus(); |
97 | } | 96 | } |
98 | } | 97 | } |
99 | } | 98 | } |
100 | inFocus = 0; | 99 | inFocus = 0; |
101 | oldFocus = 0; | 100 | oldFocus = 0; |
102 | } | 101 | } |
103 | } | 102 | } |
104 | 103 | ||
105 | bool QPEMenuToolFocusManager::isActive() const | 104 | bool QPEMenuToolFocusManager::isActive() const |
106 | { | 105 | { |
107 | return !inFocus.isNull(); | 106 | return !inFocus.isNull(); |
108 | } | 107 | } |
109 | 108 | ||
110 | void QPEMenuToolFocusManager::moveFocus( bool next ) | 109 | void QPEMenuToolFocusManager::moveFocus( bool next ) |
111 | { | 110 | { |
112 | if ( !isActive() ) | 111 | if ( !isActive() ) |
113 | return; | 112 | return; |
114 | 113 | ||
115 | int n = list.count(); | 114 | int n = list.count(); |
116 | QValueList<GuardedWidget>::Iterator it; | 115 | QValueList<GuardedWidget>::Iterator it; |
117 | it = list.find( inFocus ); | 116 | it = list.find( inFocus ); |
118 | if ( it == list.end() ) | 117 | if ( it == list.end() ) |
119 | it = list.begin(); | 118 | it = list.begin(); |
120 | while ( --n ) { | 119 | while ( --n ) { |
121 | if ( next ) { | 120 | if ( next ) { |
122 | ++it; | 121 | ++it; |
123 | if ( it == list.end() ) | 122 | if ( it == list.end() ) |
124 | it = list.begin(); | 123 | it = list.begin(); |
125 | } else { | 124 | } else { |
126 | if ( it == list.begin() ) | 125 | if ( it == list.begin() ) |
127 | it = list.end(); | 126 | it = list.end(); |
128 | --it; | 127 | --it; |
129 | } | 128 | } |
130 | QWidget *w = (*it); | 129 | QWidget *w = (*it); |
131 | if ( w && w->isEnabled() && w->isVisible() && !w->inherits("QToolBarSeparator") && | 130 | if ( w && w->isEnabled() && w->isVisible() && !w->inherits("QToolBarSeparator") && |
132 | w->topLevelWidget() == qApp->activeWindow() ) { | 131 | w->topLevelWidget() == qApp->activeWindow() ) { |
133 | setFocus( w, next ); | 132 | setFocus( w, next ); |
134 | return; | 133 | return; |
135 | } | 134 | } |
136 | } | 135 | } |
137 | } | 136 | } |
138 | 137 | ||
139 | void QPEMenuToolFocusManager::initialize() | 138 | void QPEMenuToolFocusManager::initialize() |
140 | { | 139 | { |
141 | if ( !me ) | 140 | if ( !me ) |
142 | me = new QPEMenuToolFocusManager; | 141 | me = new QPEMenuToolFocusManager; |
143 | } | 142 | } |
144 | 143 | ||
145 | QPEMenuToolFocusManager *QPEMenuToolFocusManager::manager() | 144 | QPEMenuToolFocusManager *QPEMenuToolFocusManager::manager() |
146 | { | 145 | { |
147 | if ( !me ) | 146 | if ( !me ) |
148 | me = new QPEMenuToolFocusManager; | 147 | me = new QPEMenuToolFocusManager; |
149 | 148 | ||
150 | return me; | 149 | return me; |
151 | } | 150 | } |
152 | 151 | ||
153 | void QPEMenuToolFocusManager::setFocus( QWidget *w, bool next ) | 152 | void QPEMenuToolFocusManager::setFocus( QWidget *w, bool next ) |