Ticket #10056: keybindings.diff
| File keybindings.diff, 11.5 KB (added by , 15 years ago) |
|---|
-
mythtv/libs/libmythui/mythmainwindow.cpp
diff --git a/mythtv/libs/libmythui/mythmainwindow.cpp b/mythtv/libs/libmythui/mythmainwindow.cpp index e69e4fd..2a60ada 100644
a b using namespace std; 80 80 81 81 #define LOC QString("MythMainWindow: ") 82 82 83 84 83 85 class KeyContext 84 86 { 85 87 public: … … int MythMainWindowPrivate::TranslateKeyNum(QKeyEvent* e) 288 290 return keynum; 289 291 } 290 292 293 MythKeyBinding::MythKeyBinding(const QString &context, const QString &action, const QString &description, const QString &hostname, const QString &keylist) 294 { 295 m_context = context; 296 m_action = action; 297 m_keylist = keylist; 298 m_hostname = hostname; 299 m_description = description; 300 }; 301 302 MythKeyBinding::MythKeyBinding(const MythKeyBinding &keyBinding) 303 { 304 m_context = keyBinding.m_context; 305 m_action = keyBinding.m_action; 306 m_keylist = keyBinding.m_keylist; 307 m_hostname = keyBinding.m_hostname; 308 m_description = keyBinding.m_description; 309 }; 310 311 312 void MythMainWindow::loadKeyBindings(QList<MythKeyBinding> &keybindings, const QString &hostname) 313 { 314 MSqlQuery query(MSqlQuery::InitCon()); 315 query.prepare( 316 "SELECT context, action, description, hostname, keylist " 317 "FROM keybindings " 318 "WHERE hostname = :HOSTNAME " 319 "ORDER BY context, action"); 320 query.bindValue(":HOSTNAME", hostname); 321 322 if (!query.exec() || !query.isActive()) 323 { 324 MythDB::DBError("MythMainWindow::loadKeyBindings", query); 325 return; 326 } 327 328 while (query.next()) 329 { 330 MythKeyBinding keyBinding(query.value(0).toString(),query.value(1).toString(), 331 query.value(2).toString(),query.value(3).toString(),query.value(4).toString()); 332 keybindings.append(keyBinding); 333 } 334 } 335 336 bool MythMainWindow::saveKeyBinding(const MythKeyBinding & keybinding) 337 { 338 339 MSqlQuery query(MSqlQuery::InitCon()); 340 query.prepare( 341 "UPDATE keybindings " 342 "SET keylist = :KEYLIST " 343 "WHERE hostname = :HOSTNAME AND " 344 " action = :ACTION AND " 345 " context = :CONTEXT"); 346 347 query.bindValue(":KEYLIST", keybinding.keylist()); 348 query.bindValue(":HOSTNAME", keybinding.hostname()); 349 query.bindValue(":CONTEXT", keybinding.context()); 350 query.bindValue(":ACTION", keybinding.action()); 351 352 if (!query.exec() || !query.isActive()) 353 { 354 MythDB::DBError("MythMainWindow::saveKeyBinding", query); 355 return false; 356 } 357 return true; 358 } 359 360 MythJumpPoint::MythJumpPoint(const QString &destination, const QString &description, const QString &hostname, const QString &keylist) 361 { 362 m_destination = destination; 363 m_keylist = keylist; 364 m_hostname = hostname; 365 m_description = description; 366 }; 367 368 MythJumpPoint::MythJumpPoint(const MythJumpPoint &jumpPoint) 369 { 370 m_destination = jumpPoint.m_destination; 371 m_keylist = jumpPoint.m_keylist; 372 m_hostname = jumpPoint.m_hostname; 373 m_description = jumpPoint.m_description; 374 }; 375 376 377 void MythMainWindow::loadJumpPoints(QList<MythJumpPoint> &jumpPoints, const QString &hostname) 378 { 379 MSqlQuery query(MSqlQuery::InitCon()); 380 query.prepare( 381 "SELECT destination, keylist, hostname, description " 382 "FROM jumppoints " 383 "WHERE hostname = :HOSTNAME " 384 "ORDER BY destination"); 385 query.bindValue(":HOSTNAME", hostname); 386 387 if (!query.exec() || !query.isActive()) 388 { 389 MythDB::DBError("MythMainWindow::loadJumpPoints", query); 390 return; 391 } 392 393 while (query.next()) 394 { 395 MythJumpPoint jumpPoint(query.value(0).toString(),query.value(1).toString(), 396 query.value(2).toString(),query.value(3).toString()); 397 jumpPoints.append(jumpPoint); 398 } 399 } 400 401 bool MythMainWindow::saveJumpPoint(const MythJumpPoint & jumpPoint) 402 { 403 MSqlQuery query(MSqlQuery::InitCon()); 404 query.prepare( 405 "UPDATE jumppoints " 406 "SET keylist = :KEYLIST " 407 "WHERE hostname = :HOSTNAME AND" 408 " destination = :DESTINATION"); 409 query.bindValue(":KEYLIST", jumpPoint.keylist()); 410 query.bindValue(":HOSTNAME", jumpPoint.hostname()); 411 query.bindValue(":DESTINATION", jumpPoint.destination()); 412 413 if (!query.exec() || !query.isActive()) 414 { 415 MythDB::DBError("MythMainWindow::saveJumpPoint", query); 416 return false; 417 } 418 return true; 419 } 420 291 421 static MythMainWindow *mainWin = NULL; 292 422 static QMutex mainLock; 293 423 -
mythtv/libs/libmythui/mythmainwindow.h
diff --git a/mythtv/libs/libmythui/mythmainwindow.h b/mythtv/libs/libmythui/mythmainwindow.h index 46ea69d..e3860b4 100644
a b class MythPainterWindowVDPAU; 28 28 class MythPainterWindowD3D9; 29 29 class MythRender; 30 30 31 class MUI_PUBLIC MythKeyBinding 32 { 33 public: 34 MythKeyBinding(const QString &context, const QString &action, const QString &description, const QString &hostname, const QString &keylist); 35 MythKeyBinding(const MythKeyBinding &keyBinding); 36 const QString & context () const{return m_context;}; 37 const QString & action () const{return m_action;}; 38 const QString & keylist () const{return m_keylist;}; 39 const QString & hostname () const{return m_hostname;}; 40 const QString & description () const{return m_description;}; 41 private: 42 QString m_context; 43 QString m_action; 44 QString m_keylist; 45 QString m_hostname; 46 QString m_description; 47 }; 48 49 50 class MUI_PUBLIC MythJumpPoint 51 { 52 public: 53 MythJumpPoint(const QString &action, const QString &description, const QString &hostname, const QString &keylist); 54 MythJumpPoint(const MythJumpPoint &keyBinding); 55 const QString & destination () const{return m_destination;}; 56 const QString & keylist () const{return m_keylist;}; 57 const QString & hostname () const{return m_hostname;}; 58 const QString & description () const{return m_description;}; 59 private: 60 QString m_destination; 61 QString m_keylist; 62 QString m_hostname; 63 QString m_description; 64 }; 65 66 31 67 class MUI_PUBLIC MythMainWindow : public QWidget 32 68 { 33 69 Q_OBJECT … … class MUI_PUBLIC MythMainWindow : public QWidget 126 162 void SetEffectsEnabled(bool enable); 127 163 void draw(void); 128 164 165 void loadKeyBindings(QList<MythKeyBinding> &list, const QString &hostname); 166 bool saveKeyBinding(const MythKeyBinding & keybinding); 167 void loadJumpPoints(QList<MythJumpPoint> &jumpPoints, const QString &hostname); 168 bool saveJumpPoint(const MythJumpPoint & jumpPoint); 169 129 170 public slots: 130 171 void mouseTimeout(); 131 172 void HideMouseTimeout(); -
mythtv/programs/mythfrontend/keybindings.cpp
diff --git a/mythtv/programs/mythfrontend/keybindings.cpp b/mythtv/programs/mythfrontend/keybindings.cpp index e15de26..c4063db 100644
a b bool KeyBindings::RemoveActionKey(const QString &context_name, 262 262 */ 263 263 void KeyBindings::CommitAction(const ActionID &id) 264 264 { 265 MSqlQuery query(MSqlQuery::InitCon());266 query.prepare(267 "UPDATE keybindings "268 "SET keylist = :KEYLIST "269 "WHERE hostname = :HOSTNAME AND "270 " action = :ACTION AND "271 " context = :CONTEXT");272 273 265 QString keys = m_actionSet.GetKeyString(id); 274 query.bindValue(":KEYLIST", keys); 275 query.bindValue(":HOSTNAME", m_hostname); 276 query.bindValue(":CONTEXT", id.GetContext()); 277 query.bindValue(":ACTION", id.GetAction()); 278 279 if (!query.exec() || !query.isActive()) 280 { 281 MythDB::DBError("KeyBindings::CommitAction", query); 282 return; 283 } 266 if (!GetMythMainWindow()->saveKeyBinding(MythKeyBinding( 267 id.GetContext(), id.GetAction(), "", 268 m_hostname,keys))) return; 284 269 285 270 GetMythMainWindow()->ClearKey(id.GetContext(), id.GetAction()); 286 271 GetMythMainWindow()->BindKey(id.GetContext(), id.GetAction(), keys); … … void KeyBindings::CommitAction(const ActionID &id) 293 278 */ 294 279 void KeyBindings::CommitJumppoint(const ActionID &id) 295 280 { 296 MSqlQuery query(MSqlQuery::InitCon());297 query.prepare(298 "UPDATE jumppoints "299 "SET keylist = :KEYLIST "300 "WHERE hostname = :HOSTNAME AND"301 " destination = :DESTINATION");302 303 281 QString keys = m_actionSet.GetKeyString(id); 304 query.bindValue(":KEYLIST", keys); 305 query.bindValue(":HOSTNAME", m_hostname); 306 query.bindValue(":DESTINATION", id.GetAction()); 307 308 if (!query.exec() || !query.isActive()) 309 { 310 MythDB::DBError("KeyBindings::CommitJumppoint", query); 311 return; 312 } 282 if (!GetMythMainWindow()->saveJumpPoint(MythJumpPoint( 283 id.GetAction(), "", 284 m_hostname,keys))) return; 313 285 314 286 GetMythMainWindow()->ClearJump(id.GetAction()); 315 287 GetMythMainWindow()->BindJump(id.GetAction(), keys); … … void KeyBindings::CommitChanges(void) 350 322 */ 351 323 void KeyBindings::LoadJumppoints(void) 352 324 { 353 MSqlQuery query(MSqlQuery::InitCon()); 354 query.prepare( 355 "SELECT destination, description, keylist " 356 "FROM jumppoints " 357 "WHERE hostname = :HOSTNAME " 358 "ORDER BY destination"); 359 query.bindValue(":HOSTNAME", m_hostname); 360 361 if (!query.exec() || !query.isActive()) 362 { 363 MythDB::DBError("KeyBindings::LoadJumppoint", query); 364 return; 365 } 325 QList<MythJumpPoint> jumpPoints; 326 GetMythMainWindow()->loadJumpPoints(jumpPoints, m_hostname); 366 327 367 while (query.next())328 foreach (const MythJumpPoint& currentJumpPoint, jumpPoints) 368 329 { 369 ActionID id(ActionSet::kJumpContext, query.value(0).toString());330 ActionID id(ActionSet::kJumpContext, currentJumpPoint.destination()); 370 331 371 if ( query.value(1).toString().isEmpty())332 if (currentJumpPoint.description().isEmpty()) 372 333 { 373 m_actionSet.AddAction(id, query.value(0).toString(),374 query.value(2).toString());334 m_actionSet.AddAction(id, currentJumpPoint.destination(), 335 currentJumpPoint.keylist()); 375 336 } 376 337 else 377 338 { 378 m_actionSet.AddAction(id, query.value(1).toString(),379 query.value(2).toString());339 m_actionSet.AddAction(id, currentJumpPoint.description(), 340 currentJumpPoint.keylist()); 380 341 } 381 342 } 382 343 } … … void KeyBindings::LoadJumppoints(void) 389 350 */ 390 351 void KeyBindings::LoadContexts(void) 391 352 { 392 MSqlQuery query(MSqlQuery::InitCon()); 393 query.prepare( 394 "SELECT context, action, description, keylist " 395 "FROM keybindings " 396 "WHERE hostname = :HOSTNAME " 397 "ORDER BY context, action"); 398 query.bindValue(":HOSTNAME", m_hostname); 399 400 if (!query.exec() || !query.isActive()) 401 { 402 MythDB::DBError("KeyBindings::LoadContexts", query); 403 return; 404 } 353 QList<MythKeyBinding> keybindings; 354 GetMythMainWindow()->loadKeyBindings(keybindings, m_hostname); 405 355 406 while (query.next())356 foreach (const MythKeyBinding& currentKeyBinding, keybindings) 407 357 { 408 ActionID id(query.value(0).toString(), query.value(1).toString()); 409 m_actionSet.AddAction(id, query.value(2).toString(), 410 query.value(3).toString()); 358 359 ActionID id(currentKeyBinding.context(), currentKeyBinding.action()); 360 m_actionSet.AddAction(id, currentKeyBinding.description(), 361 currentKeyBinding.keylist()); 411 362 } 412 363 } 413 364
