summaryrefslogtreecommitdiff
path: root/library
authorsandman <sandman>2002-10-06 03:18:29 (UTC)
committer sandman <sandman>2002-10-06 03:18:29 (UTC)
commit2c16c8767fa5c16c0eeebc7008202a68a61a5308 (patch) (unidiff)
tree427028b8039b967bc5c14b2353f87ffb75cf9f01 /library
parent502dba87e55f7f87ad9ea009a7e283c0c39f0c7f (diff)
downloadopie-2c16c8767fa5c16c0eeebc7008202a68a61a5308.zip
opie-2c16c8767fa5c16c0eeebc7008202a68a61a5308.tar.gz
opie-2c16c8767fa5c16c0eeebc7008202a68a61a5308.tar.bz2
key navigation didn't work in toolbars, which had separators (e.g. qpdf or
drawpad) - now this is accounted for and they are skipped
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpemenubar.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/qpemenubar.cpp b/library/qpemenubar.cpp
index f0171ba..c658d10 100644
--- a/library/qpemenubar.cpp
+++ b/library/qpemenubar.cpp
@@ -74,97 +74,97 @@ void QPEMenuToolFocusManager::setActive( bool a )
74 setFocus( w ); 74 setFocus( w );
75 return; 75 return;
76 } 76 }
77 ++it; 77 ++it;
78 } 78 }
79 } else { 79 } else {
80 if ( inFocus ) { 80 if ( inFocus ) {
81 if ( inFocus->inherits( "QMenuBar" ) ) 81 if ( inFocus->inherits( "QMenuBar" ) )
82 ((QMenuBarHack *)(QWidget *)inFocus)->goodbye(); 82 ((QMenuBarHack *)(QWidget *)inFocus)->goodbye();
83 if ( inFocus->hasFocus() ) { 83 if ( inFocus->hasFocus() ) {
84 if ( oldFocus && oldFocus->isVisible() && oldFocus->isEnabled() ) { 84 if ( oldFocus && oldFocus->isVisible() && oldFocus->isEnabled() ) {
85 oldFocus->setFocus(); 85 oldFocus->setFocus();
86 } else { 86 } else {
87 inFocus->clearFocus(); 87 inFocus->clearFocus();
88 } 88 }
89 } 89 }
90 } 90 }
91 inFocus = 0; 91 inFocus = 0;
92 oldFocus = 0; 92 oldFocus = 0;
93 } 93 }
94} 94}
95 95
96bool QPEMenuToolFocusManager::isActive() const 96bool QPEMenuToolFocusManager::isActive() const
97{ 97{
98 return !inFocus.isNull(); 98 return !inFocus.isNull();
99} 99}
100 100
101void QPEMenuToolFocusManager::moveFocus( bool next ) 101void QPEMenuToolFocusManager::moveFocus( bool next )
102{ 102{
103 if ( !isActive() ) 103 if ( !isActive() )
104 return; 104 return;
105 105
106 int n = list.count(); 106 int n = list.count();
107 QValueList<GuardedWidget>::Iterator it; 107 QValueList<GuardedWidget>::Iterator it;
108 it = list.find( inFocus ); 108 it = list.find( inFocus );
109 if ( it == list.end() ) 109 if ( it == list.end() )
110 it = list.begin(); 110 it = list.begin();
111 while ( --n ) { 111 while ( --n ) {
112 if ( next ) { 112 if ( next ) {
113 ++it; 113 ++it;
114 if ( it == list.end() ) 114 if ( it == list.end() )
115 it = list.begin(); 115 it = list.begin();
116 } else { 116 } else {
117 if ( it == list.begin() ) 117 if ( it == list.begin() )
118 it = list.end(); 118 it = list.end();
119 --it; 119 --it;
120 } 120 }
121 QWidget *w = (*it); 121 QWidget *w = (*it);
122 if ( w && w->isEnabled() && w->isVisible() && 122 if ( w && w->isEnabled() && w->isVisible() && !w->inherits("QToolBarSeparator") &&
123 w->topLevelWidget() == qApp->activeWindow() ) { 123 w->topLevelWidget() == qApp->activeWindow() ) {
124 setFocus( w, next ); 124 setFocus( w, next );
125 return; 125 return;
126 } 126 }
127 } 127 }
128} 128}
129 129
130void QPEMenuToolFocusManager::initialize() 130void QPEMenuToolFocusManager::initialize()
131{ 131{
132 if ( !me ) 132 if ( !me )
133 me = new QPEMenuToolFocusManager; 133 me = new QPEMenuToolFocusManager;
134} 134}
135 135
136QPEMenuToolFocusManager *QPEMenuToolFocusManager::manager() 136QPEMenuToolFocusManager *QPEMenuToolFocusManager::manager()
137{ 137{
138 if ( !me ) 138 if ( !me )
139 me = new QPEMenuToolFocusManager; 139 me = new QPEMenuToolFocusManager;
140 140
141 return me; 141 return me;
142} 142}
143 143
144void QPEMenuToolFocusManager::setFocus( QWidget *w, bool next ) 144void QPEMenuToolFocusManager::setFocus( QWidget *w, bool next )
145{ 145{
146 inFocus = w; 146 inFocus = w;
147// qDebug( "Set focus on %s", w->className() ); 147// qDebug( "Set focus on %s", w->className() );
148 if ( inFocus->inherits( "QMenuBar" ) ) { 148 if ( inFocus->inherits( "QMenuBar" ) ) {
149 QMenuBar *mb = (QMenuBar *)(QWidget *)inFocus; 149 QMenuBar *mb = (QMenuBar *)(QWidget *)inFocus;
150 if ( next ) 150 if ( next )
151 mb->activateItemAt( 0 ); 151 mb->activateItemAt( 0 );
152 else 152 else
153 mb->activateItemAt( mb->count()-1 ); 153 mb->activateItemAt( mb->count()-1 );
154 } 154 }
155 inFocus->setFocus(); 155 inFocus->setFocus();
156} 156}
157 157
158bool QPEMenuToolFocusManager::eventFilter( QObject *object, QEvent *event ) 158bool QPEMenuToolFocusManager::eventFilter( QObject *object, QEvent *event )
159{ 159{
160 if ( event->type() == QEvent::KeyPress ) { 160 if ( event->type() == QEvent::KeyPress ) {
161 QKeyEvent *ke = (QKeyEvent *)event; 161 QKeyEvent *ke = (QKeyEvent *)event;
162 if ( isActive() ) { 162 if ( isActive() ) {
163 if ( object->inherits( "QButton" ) ) { 163 if ( object->inherits( "QButton" ) ) {
164 switch ( ke->key() ) { 164 switch ( ke->key() ) {
165 case Key_Left: 165 case Key_Left:
166 moveFocus( FALSE ); 166 moveFocus( FALSE );
167 return TRUE; 167 return TRUE;
168 168
169 case Key_Right: 169 case Key_Right:
170 moveFocus( TRUE ); 170 moveFocus( TRUE );