Changeset 769 for trunk/src/gui/kernel/qsoftkeymanager.cpp
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.3 (added) merged: 768 /branches/vendor/nokia/qt/current merged: 767 /branches/vendor/nokia/qt/4.6.2 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/kernel/qsoftkeymanager.cpp
r651 r769 56 56 QSoftKeyManager *QSoftKeyManagerPrivate::self = 0; 57 57 58 const char *QSoftKeyManager::standardSoftKeyText(StandardSoftKey standardKey)59 { 60 const char *softKeyText = 0;58 QString QSoftKeyManager::standardSoftKeyText(StandardSoftKey standardKey) 59 { 60 QString softKeyText; 61 61 switch (standardKey) { 62 62 case OkSoftKey: 63 softKeyText = Q T_TRANSLATE_NOOP("QSoftKeyManager","Ok");63 softKeyText = QSoftKeyManager::tr("Ok"); 64 64 break; 65 65 case SelectSoftKey: 66 softKeyText = Q T_TRANSLATE_NOOP("QSoftKeyManager","Select");66 softKeyText = QSoftKeyManager::tr("Select"); 67 67 break; 68 68 case DoneSoftKey: 69 softKeyText = Q T_TRANSLATE_NOOP("QSoftKeyManager","Done");69 softKeyText = QSoftKeyManager::tr("Done"); 70 70 break; 71 71 case MenuSoftKey: 72 softKeyText = Q T_TRANSLATE_NOOP("QSoftKeyManager","Options");72 softKeyText = QSoftKeyManager::tr("Options"); 73 73 break; 74 74 case CancelSoftKey: 75 softKeyText = Q T_TRANSLATE_NOOP("QSoftKeyManager","Cancel");75 softKeyText = QSoftKeyManager::tr("Cancel"); 76 76 break; 77 77 default: … … 101 101 QAction *QSoftKeyManager::createAction(StandardSoftKey standardKey, QWidget *actionWidget) 102 102 { 103 const char* text = standardSoftKeyText(standardKey); 104 QAction *action = new QAction(QSoftKeyManager::tr(text), actionWidget); 103 QAction *action = new QAction(standardSoftKeyText(standardKey), actionWidget); 105 104 QAction::SoftKeyRole softKeyRole = QAction::NoSoftKey; 106 105 switch (standardKey) { … … 117 116 } 118 117 action->setSoftKeyRole(softKeyRole); 118 action->setVisible(false); 119 setForceEnabledInSoftkeys(action); 119 120 return action; 120 121 } … … 170 171 Q_D(QSoftKeyManager); 171 172 bool ret = false; 172 QList<QAction*> actions = source.actions();173 for (int i = 0; i < actions.count(); ++i) {174 if (actions.at(i)->softKeyRole() != QAction::NoSoftKey) {175 d->requestedSoftKeyActions.insert(level, action s.at(i));173 foreach(QAction *action, source.actions()) { 174 if (action->softKeyRole() != QAction::NoSoftKey 175 && (action->isVisible() || isForceEnabledInSofkeys(action))) { 176 d->requestedSoftKeyActions.insert(level, action); 176 177 ret = true; 177 178 } 178 179 } 179 180 return ret; 181 } 182 183 184 static bool isChildOf(const QWidget *c, const QWidget *p) 185 { 186 while (c) { 187 if (c == p) 188 return true; 189 c = c->parentWidget(); 190 } 191 return false; 180 192 } 181 193 … … 186 198 if (!previousSource) { 187 199 // Initial source is primarily focuswidget and secondarily activeWindow 188 source = QApplication::focusWidget(); 189 if (!source) 190 source = QApplication::activeWindow(); 200 QWidget *focus = QApplication::focusWidget(); 201 QWidget *popup = QApplication::activePopupWidget(); 202 if (popup) { 203 if (isChildOf(focus, popup)) 204 source = focus; 205 else 206 source = popup; 207 } 208 if (!source) { 209 QWidget *modal = QApplication::activeModalWidget(); 210 if (modal) { 211 if (isChildOf(focus, modal)) 212 source = focus; 213 else 214 source = modal; 215 } 216 } 217 if (!source) { 218 source = focus; 219 if (!source) 220 source = QApplication::activeWindow(); 221 } 191 222 } else { 192 223 // Softkey merging is based on four criterias … … 212 243 bool recursiveMerging = false; 213 244 QWidget *source = softkeySource(NULL, recursiveMerging); 214 do { 215 if (source) { 216 bool added = appendSoftkeys(*source, level); 217 source = softkeySource(source, recursiveMerging); 218 level = added ? ++level : level; 219 } 220 } while (source); 245 d->initialSoftKeySource = source; 246 while (source) { 247 if (appendSoftkeys(*source, level)) 248 ++level; 249 source = softkeySource(source, recursiveMerging); 250 } 221 251 222 252 d->updateSoftKeys_sys(); 223 253 return true; 254 } 255 256 void QSoftKeyManager::setForceEnabledInSoftkeys(QAction *action) 257 { 258 action->setProperty(FORCE_ENABLED_PROPERTY, QVariant(true)); 259 } 260 261 bool QSoftKeyManager::isForceEnabledInSofkeys(QAction *action) 262 { 263 bool ret = false; 264 QVariant property = action->property(FORCE_ENABLED_PROPERTY); 265 if (property.isValid() && property.toBool()) 266 ret = true; 267 return ret; 224 268 } 225 269
Note:
See TracChangeset
for help on using the changeset viewer.