Ticket #3446: 3446-mfe-quit-reboot-menu-combined.diff
File 3446-mfe-quit-reboot-menu-combined.diff, 7.4 KB (added by , 17 years ago) |
---|
-
mythtv/programs/mythfrontend/globalsettings.cpp
1446 1446 return gc; 1447 1447 } 1448 1448 1449 static HostComboBox *OverrideExitMenu() 1450 { 1451 HostComboBox *gc = new HostComboBox("OverrideExitMenu"); 1452 gc->setLabel(QObject::tr("Customise exit menu options")); 1453 gc->addSelection(QObject::tr("Autodetect"), "0"); 1454 gc->addSelection(QObject::tr("Show quit"), "1"); 1455 gc->addSelection(QObject::tr("Show quit and shutdown"), "2"); 1456 gc->addSelection(QObject::tr("Show quit, reboot and shutdown"), "3"); 1457 gc->addSelection(QObject::tr("Show shutdown"), "4"); 1458 gc->addSelection(QObject::tr("Show reboot"), "5"); 1459 gc->addSelection(QObject::tr("Show reboot and shutdown"), "6"); 1460 gc->setHelpText(QObject::tr("By default, only remote frontends are shown " 1461 "the shutdown option on the exit menu. Here you can force " 1462 "specific shutdown and reboot options to be displayed.")); 1463 return gc; 1464 } 1465 1449 1466 static HostCheckBox *NoPromptOnExit() 1450 1467 { 1451 1468 HostCheckBox *gc = new HostCheckBox("NoPromptOnExit"); … … 1457 1474 return gc; 1458 1475 } 1459 1476 1477 static HostLineEdit *RebootCommand() 1478 { 1479 HostLineEdit *ge = new HostLineEdit("RebootCommand"); 1480 ge->setLabel(QObject::tr("Reboot command")); 1481 ge->setValue("reboot"); 1482 ge->setHelpText(QObject::tr("Command or script to run if you select " 1483 "the reboot option from the exit menu, if the option " 1484 "is displayed. You must configure an exit key to " 1485 "display the exit menu.")); 1486 return ge; 1487 } 1488 1460 1489 static HostLineEdit *HaltCommand() 1461 1490 { 1462 1491 HostLineEdit *ge = new HostLineEdit("HaltCommand"); 1463 1492 ge->setLabel(QObject::tr("Halt command")); 1464 1493 ge->setValue("halt"); 1465 ge->setHelpText(QObject::tr(" If you have configured an exit key using the"1466 " System Shutdown option, you will be given the opportunity"1467 " to exit MythTV or halt the system completely."1468 " Another possibility for this field is \"poweroff\""));1494 ge->setHelpText(QObject::tr("Command or script to run if you select " 1495 "the shutdown option from the exit menu, if the option " 1496 "is displayed. You must configure an exit key to " 1497 "display the exit menu.")); 1469 1498 return ge; 1470 1499 } 1471 1500 … … 3569 3598 pin->addChild(SetupPinCode()); 3570 3599 misc->addChild(pin); 3571 3600 VerticalConfigurationGroup* shutdownSettings = new VerticalConfigurationGroup(true); 3572 shutdownSettings->setLabel(QObject::tr("Shutdown Settings")); 3601 shutdownSettings->setLabel(QObject::tr("Shutdown/Reboot Settings")); 3602 shutdownSettings->addChild(OverrideExitMenu()); 3573 3603 shutdownSettings->addChild(HaltCommand()); 3604 shutdownSettings->addChild(RebootCommand()); 3574 3605 misc->addChild(shutdownSettings); 3575 3606 addChild(misc); 3576 3607 -
mythtv/programs/mythfrontend/main.cpp
54 54 #define NO_EXIT 0 55 55 #define QUIT 1 56 56 #define HALT 2 57 #define REBOOT 3 57 58 58 59 static MythThemedMenu *menu; 59 60 static MythThemeBase *themeBase; … … 437 438 // first of all find out, if this is a frontend only host... 438 439 bool frontendOnly = gContext->IsFrontendOnly(); 439 440 441 // how do you want to quit today? 442 int exitMenuStyle = gContext->GetNumSetting("OverrideExitMenu", 0); 443 440 444 QString title = QObject::tr("Do you really want to exit MythTV?"); 441 445 446 // 'simplify' exit menu construction 442 447 DialogBox diag(gContext->GetMainWindow(), title); 443 diag.AddButton(QObject::tr("No"));444 diag.AddButton(QObject::tr("Yes, Exit now"));445 if (frontendOnly)446 diag.AddButton(QObject::tr("Yes, Exit and Shutdown"));447 448 448 int result = diag.exec(); 449 switch (result) 449 diag.AddButton(QObject::tr("No")); 450 int result; 451 452 switch (exitMenuStyle) 450 453 { 451 case 1: return NO_EXIT; 452 case 2: return QUIT; 453 case 3: return HALT; 454 default: return NO_EXIT; 454 case 0: 455 diag.AddButton(QObject::tr("Yes, Exit now")); 456 if (frontendOnly) 457 diag.AddButton(QObject::tr("Yes, Exit and Shutdown")); 458 result = diag.exec(); 459 switch (result) 460 { 461 case 1: return NO_EXIT; 462 case 2: return QUIT; 463 case 3: return HALT; 464 default: return NO_EXIT; 465 } 466 case 1: 467 diag.AddButton(QObject::tr("Yes, Exit now")); 468 result = diag.exec(); 469 switch (result) 470 { 471 case 1: return NO_EXIT; 472 case 2: return QUIT; 473 default: return NO_EXIT; 474 } 475 case 2: 476 diag.AddButton(QObject::tr("Yes, Exit now")); 477 diag.AddButton(QObject::tr("Yes, Exit and Shutdown")); 478 result = diag.exec(); 479 switch (result) 480 { 481 case 1: return NO_EXIT; 482 case 2: return QUIT; 483 case 3: return HALT; 484 default: return NO_EXIT; 485 } 486 case 3: 487 diag.AddButton(QObject::tr("Yes, Exit now")); 488 diag.AddButton(QObject::tr("Yes, Exit and Reboot")); 489 diag.AddButton(QObject::tr("Yes, Exit and Shutdown")); 490 result = diag.exec(); 491 switch (result) 492 { 493 case 1: return NO_EXIT; 494 case 2: return QUIT; 495 case 3: return REBOOT; 496 case 4: return HALT; 497 default: return NO_EXIT; 498 } 499 case 4: 500 diag.AddButton(QObject::tr("Yes, Exit and Shutdown")); 501 result = diag.exec(); 502 switch (result) 503 { 504 case 1: return NO_EXIT; 505 case 2: return HALT; 506 default: return NO_EXIT; 507 } 508 case 5: 509 diag.AddButton(QObject::tr("Yes, Exit and Reboot")); 510 result = diag.exec(); 511 switch (result) 512 { 513 case 1: return NO_EXIT; 514 case 2: return REBOOT; 515 default: return NO_EXIT; 516 } 517 case 6: 518 diag.AddButton(QObject::tr("Yes, Exit and Reboot")); 519 diag.AddButton(QObject::tr("Yes, Exit and Shutdown")); 520 result = diag.exec(); 521 switch (result) 522 { 523 case 1: return NO_EXIT; 524 case 2: return REBOOT; 525 case 3: return HALT; 526 default: return NO_EXIT; 527 } 455 528 } 456 529 } 457 530 … … 463 536 system(halt_cmd.ascii()); 464 537 } 465 538 539 void rebootnow() 540 { 541 QString reboot_cmd = gContext->GetSetting("RebootCommand", 542 "sudo /sbin/reboot"); 543 if (!reboot_cmd.isEmpty()) 544 system(reboot_cmd.ascii()); 545 } 546 466 547 bool RunMenu(QString themedir) 467 548 { 468 549 menu = new MythThemedMenu(themedir.ascii(), "mainmenu.xml", … … 1250 1331 if (exitstatus == HALT) 1251 1332 haltnow(); 1252 1333 1334 if (exitstatus == REBOOT) 1335 rebootnow(); 1336 1253 1337 pmanager->DestroyAllPlugins(); 1254 1338 1255 1339 #ifndef _WIN32