Changeset 2821 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- May 23, 2007 3:44:25 PM (18 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/QIHotKeyEdit.cpp
r2802 r2821 180 180 * to the keycode. 181 181 */ 182 void QIHotKeyEdit::setKey ( int k)182 void QIHotKeyEdit::setKey (int k) 183 183 { 184 184 keyval = k; 185 symbname = QIHotKeyEdit::keyName ( k);185 symbname = QIHotKeyEdit::keyName (k); 186 186 updateText(); 187 187 } … … 204 204 { 205 205 constPolish(); 206 QFontMetrics fm ( font());206 QFontMetrics fm (font()); 207 207 int h = QMAX(fm.lineSpacing(), 14) + 2; 208 208 int w = fm.width( 'x' ) * 17; // "some" 209 209 int m = frameWidth() * 2; 210 210 return (style().sizeFromContents(QStyle::CT_LineEdit, this, 211 QSize( w + m, h + m ). 212 211 QSize (w + m, h + m) 212 .expandedTo(QApplication::globalStrut()))); 213 213 } 214 214 … … 220 220 constPolish(); 221 221 QFontMetrics fm = fontMetrics(); 222 int h = fm.height() + QMAX ( 2, fm.leading());222 int h = fm.height() + QMAX (2, fm.leading()); 223 223 int w = fm.maxWidth(); 224 224 int m = frameWidth() * 2; 225 return QSize ( w + m, h + m);225 return QSize (w + m, h + m); 226 226 } 227 227 … … 234 234 void QIHotKeyEdit::languageChange(void) 235 235 { 236 keyNames ["Shift_L"] = tr ("Left Shift");237 keyNames ["Shift_R"] = tr ("Right Shift");238 keyNames ["Control_L"] = tr ("Left Ctrl");239 keyNames ["Control_R"] = tr ("Right Ctrl");240 keyNames ["Alt_L"] = tr ("Left Alt");241 keyNames ["Alt_R"] = tr ("Right Alt");242 keyNames ["Super_L"] = tr ("Left WinKey");243 keyNames ["Super_R"] = tr ("Right WinKey");244 keyNames ["Menu"] = tr ("Menu key");245 keyNames ["ISO_Level3_Shift"] = tr ("Alt Gr");246 keyNames ["Caps_Lock"] = tr ("Caps Lock");247 keyNames ["Scroll_Lock"] = tr ("Scroll Lock");236 keyNames ["Shift_L"] = tr ("Left Shift"); 237 keyNames ["Shift_R"] = tr ("Right Shift"); 238 keyNames ["Control_L"] = tr ("Left Ctrl"); 239 keyNames ["Control_R"] = tr ("Right Ctrl"); 240 keyNames ["Alt_L"] = tr ("Left Alt"); 241 keyNames ["Alt_R"] = tr ("Right Alt"); 242 keyNames ["Super_L"] = tr ("Left WinKey"); 243 keyNames ["Super_R"] = tr ("Right WinKey"); 244 keyNames ["Menu"] = tr ("Menu key"); 245 keyNames ["ISO_Level3_Shift"] = tr ("Alt Gr"); 246 keyNames ["Caps_Lock"] = tr ("Caps Lock"); 247 keyNames ["Scroll_Lock"] = tr ("Scroll Lock"); 248 248 } 249 249 #endif … … 262 262 QString name; 263 263 264 if ( !key ) { 264 if ( !key ) 265 { 265 266 name = tr (NoneSymbName); 266 } else { 267 #if defined(Q_WS_WIN32) 268 // stupid MapVirtualKey doesn't distinguish between right and left 269 // vkeys, even under XP, despite that it stated in msdn. do it by hand. 267 } 268 else 269 { 270 #if defined (Q_WS_WIN32) 271 /* stupid MapVirtualKey doesn't distinguish between right and left 272 * vkeys, even under XP, despite that it stated in msdn. do it by 273 * hand. */ 270 274 int scan; 271 switch( key ) { 275 switch (key) 276 { 272 277 case VK_RSHIFT: scan = 0x36 << 16; break; 273 278 case VK_RCONTROL: scan = (0x1D << 16) | (1 << 24); break; … … 276 281 } 277 282 TCHAR *str = new TCHAR[256]; 278 if ( ::GetKeyNameText( scan, str, 256 ))279 name = QString::fromUcs2 ( str);283 if (::GetKeyNameText (scan, str, 256)) 284 name = QString::fromUcs2 (str); 280 285 else 281 name = QString ( "<key_%1>" ).arg( key);286 name = QString (tr ("<key_%1>")).arg (key); 282 287 delete[] str; 283 #elif defined (Q_WS_X11)288 #elif defined (Q_WS_X11) 284 289 char *sn = ::XKeysymToString( (KeySym) key ); 285 if ( sn)290 if (sn) 286 291 { 287 if ( keyNames.contains(sn) ) 288 name = keyNames[sn]; 289 else 292 name = keyNames [sn]; 293 if (name.isEmpty()) 290 294 name = sn; 291 295 } 292 296 else 293 name = QString ( tr ("<key_%1>") ).arg( key);297 name = QString (tr ("<key_%1>")).arg (key); 294 298 #elif defined(Q_WS_MAC) 295 UInt32 modMask = DarwinKeyCodeToDarwinModifierMask( key ); 296 switch ( modMask ) { 299 UInt32 modMask = DarwinKeyCodeToDarwinModifierMask (key); 300 switch (modMask) 301 { 297 302 case shiftKey: 298 303 case optionKey: 299 304 case controlKey: 300 305 case cmdKey: 301 name = tr ("Left ");306 name = tr ("Left "); 302 307 break; 303 308 case rightShiftKey: … … 305 310 case rightControlKey: 306 311 case kEventKeyModifierRightCmdKeyMask: 307 name = tr ("Right ");312 name = tr ("Right "); 308 313 break; 309 314 default: 310 AssertMsgFailedReturn (( "modMask=%#x\n", modMask), QString());315 AssertMsgFailedReturn (("modMask=%#x\n", modMask), QString()); 311 316 } 312 switch ( modMask ) { 317 switch (modMask) 318 { 313 319 case shiftKey: 314 320 case rightShiftKey: 315 name += QChar ( kShiftUnicode);321 name += QChar (kShiftUnicode); 316 322 break; 317 323 case optionKey: 318 324 case rightOptionKey: 319 name += QChar ( kOptionUnicode);325 name += QChar (kOptionUnicode); 320 326 break; 321 327 case controlKey: 322 328 case rightControlKey: 323 name += QChar ( kControlUnicode);329 name += QChar (kControlUnicode); 324 330 break; 325 331 case cmdKey: 326 332 case kEventKeyModifierRightCmdKeyMask: 327 name += QChar ( kCommandUnicode);333 name += QChar (kCommandUnicode); 328 334 break; 329 335 } 330 336 #else 331 name = QString ( "<key_%1>" ).arg( key);337 name = QString ("<key_%1>").arg (key); 332 338 #endif 333 339 } -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r2802 r2821 1851 1851 1852 1852 detailReportTemplatesReady = false; 1853 #if defined(Q_WS_X11) 1854 /* As X11 does not (to my knowledge) have functionality for providing human readable 1855 * key names, we keep a table of them, which must be updated when the language is 1856 * changed. */ 1853 1854 #if defined (Q_WS_X11) 1855 /* As X11 does not (to my knowledge) have functionality for providing 1856 * human readable key names, we keep a table of them, which must be 1857 * updated when the language is changed. */ 1857 1858 QIHotKeyEdit::languageChange(); 1858 1859 #endif
Note:
See TracChangeset
for help on using the changeset viewer.