-rw-r--r-- | library/qpemenubar.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/library/qpemenubar.cpp b/library/qpemenubar.cpp index c658d10..4aa0bf3 100644 --- a/library/qpemenubar.cpp +++ b/library/qpemenubar.cpp | |||
@@ -1,110 +1,119 @@ | |||
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> | 25 | #include <qguardedptr.h> |
26 | #include <qtimer.h> | 26 | #include <qtimer.h> |
27 | 27 | ||
28 | 28 | ||
29 | class QMenuBarHack : public QMenuBar | 29 | class QMenuBarHack : public QMenuBar |
30 | { | 30 | { |
31 | public: | 31 | public: |
32 | int activeItem() const { return actItem; } | 32 | int activeItem() const { return actItem; } |
33 | 33 | ||
34 | void goodbye() | 34 | void goodbye() |
35 | { | 35 | { |
36 | activateItemAt(-1); | 36 | activateItemAt(-1); |
37 | for ( unsigned int i = 0; i < count(); i++ ) { | 37 | for ( unsigned int i = 0; i < count(); i++ ) { |
38 | QMenuItem *mi = findItem( idAt(i) ); | 38 | QMenuItem *mi = findItem( idAt(i) ); |
39 | if ( mi->popup() ) { | 39 | if ( mi->popup() ) { |
40 | mi->popup()->hide(); | 40 | mi->popup()->hide(); |
41 | } | 41 | } |
42 | } | 42 | } |
43 | } | 43 | } |
44 | }; | 44 | }; |
45 | 45 | ||
46 | 46 | ||
47 | // Sharp ROM compatibility | ||
48 | void QPEMenuToolFocusManager::setMenukeyEnabled ( bool ) | ||
49 | { | ||
50 | } | ||
51 | int QPEMenuBar::getOldFocus ( ) | ||
52 | { | ||
53 | return 0; | ||
54 | } | ||
55 | |||
47 | QPEMenuToolFocusManager *QPEMenuToolFocusManager::me = 0; | 56 | QPEMenuToolFocusManager *QPEMenuToolFocusManager::me = 0; |
48 | 57 | ||
49 | QPEMenuToolFocusManager::QPEMenuToolFocusManager() : QObject() | 58 | QPEMenuToolFocusManager::QPEMenuToolFocusManager() : QObject() |
50 | { | 59 | { |
51 | qApp->installEventFilter( this ); | 60 | qApp->installEventFilter( this ); |
52 | } | 61 | } |
53 | 62 | ||
54 | void QPEMenuToolFocusManager::addWidget( QWidget *w ) | 63 | void QPEMenuToolFocusManager::addWidget( QWidget *w ) |
55 | { | 64 | { |
56 | list.append( GuardedWidget(w) ); | 65 | list.append( GuardedWidget(w) ); |
57 | } | 66 | } |
58 | 67 | ||
59 | void QPEMenuToolFocusManager::removeWidget( QWidget *w ) | 68 | void QPEMenuToolFocusManager::removeWidget( QWidget *w ) |
60 | { | 69 | { |
61 | list.remove( GuardedWidget(w) ); | 70 | list.remove( GuardedWidget(w) ); |
62 | } | 71 | } |
63 | 72 | ||
64 | void QPEMenuToolFocusManager::setActive( bool a ) | 73 | void QPEMenuToolFocusManager::setActive( bool a ) |
65 | { | 74 | { |
66 | if ( a ) { | 75 | if ( a ) { |
67 | oldFocus = qApp->focusWidget(); | 76 | oldFocus = qApp->focusWidget(); |
68 | QValueList<GuardedWidget>::Iterator it; | 77 | QValueList<GuardedWidget>::Iterator it; |
69 | it = list.begin(); | 78 | it = list.begin(); |
70 | while ( it != list.end() ) { | 79 | while ( it != list.end() ) { |
71 | QWidget *w = (*it); | 80 | QWidget *w = (*it); |
72 | if ( w && w->isEnabled() && w->isVisible() && | 81 | if ( w && w->isEnabled() && w->isVisible() && |
73 | w->topLevelWidget() == qApp->activeWindow() ) { | 82 | w->topLevelWidget() == qApp->activeWindow() ) { |
74 | setFocus( w ); | 83 | setFocus( w ); |
75 | return; | 84 | return; |
76 | } | 85 | } |
77 | ++it; | 86 | ++it; |
78 | } | 87 | } |
79 | } else { | 88 | } else { |
80 | if ( inFocus ) { | 89 | if ( inFocus ) { |
81 | if ( inFocus->inherits( "QMenuBar" ) ) | 90 | if ( inFocus->inherits( "QMenuBar" ) ) |
82 | ((QMenuBarHack *)(QWidget *)inFocus)->goodbye(); | 91 | ((QMenuBarHack *)(QWidget *)inFocus)->goodbye(); |
83 | if ( inFocus->hasFocus() ) { | 92 | if ( inFocus->hasFocus() ) { |
84 | if ( oldFocus && oldFocus->isVisible() && oldFocus->isEnabled() ) { | 93 | if ( oldFocus && oldFocus->isVisible() && oldFocus->isEnabled() ) { |
85 | oldFocus->setFocus(); | 94 | oldFocus->setFocus(); |
86 | } else { | 95 | } else { |
87 | inFocus->clearFocus(); | 96 | inFocus->clearFocus(); |
88 | } | 97 | } |
89 | } | 98 | } |
90 | } | 99 | } |
91 | inFocus = 0; | 100 | inFocus = 0; |
92 | oldFocus = 0; | 101 | oldFocus = 0; |
93 | } | 102 | } |
94 | } | 103 | } |
95 | 104 | ||
96 | bool QPEMenuToolFocusManager::isActive() const | 105 | bool QPEMenuToolFocusManager::isActive() const |
97 | { | 106 | { |
98 | return !inFocus.isNull(); | 107 | return !inFocus.isNull(); |
99 | } | 108 | } |
100 | 109 | ||
101 | void QPEMenuToolFocusManager::moveFocus( bool next ) | 110 | void QPEMenuToolFocusManager::moveFocus( bool next ) |
102 | { | 111 | { |
103 | if ( !isActive() ) | 112 | if ( !isActive() ) |
104 | return; | 113 | return; |
105 | 114 | ||
106 | int n = list.count(); | 115 | int n = list.count(); |
107 | QValueList<GuardedWidget>::Iterator it; | 116 | QValueList<GuardedWidget>::Iterator it; |
108 | it = list.find( inFocus ); | 117 | it = list.find( inFocus ); |
109 | if ( it == list.end() ) | 118 | if ( it == list.end() ) |
110 | it = list.begin(); | 119 | it = list.begin(); |