Qt 'game' menu tweak for OSX
Change "_Quit-without-saving" in the Game dropdown menu to be "\177Quit-without-saving". That makes the prefix used on OSX to prevent matching "^[&]?[Qq][Uu][Ii][Tt].*" be invisible. Also change the order of the choices for the command+Q and application dropdown menu entry "quit nethack" so that "cancel and return to game" is the default for arbitrary response to the confirmation prompt. <return> and <space> select "quit without saving". Note that the nethack dropdown menu is OSX-specific (a Qt feature to emulate other OSX applications) and its nethack->Quit action is separate-from/in-addition-to Game->Quit menu action mentioned above (which runs nethack's #quit command).
This commit is contained in:
@@ -545,7 +545,7 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
|
|||||||
* application menu (and renamed in the process) even if the code
|
* application menu (and renamed in the process) even if the code
|
||||||
* here tries to put them in another menu.
|
* here tries to put them in another menu.
|
||||||
* See QtWidgets/doc/qmenubar.html for slightly more information.
|
* See QtWidgets/doc/qmenubar.html for slightly more information.
|
||||||
* setMenuRole() is supposed to be able to override this behavior.
|
* setMenuRole() can be used to override this behavior.
|
||||||
*/
|
*/
|
||||||
#endif
|
#endif
|
||||||
QMenu* game=new QMenu;
|
QMenu* game=new QMenu;
|
||||||
@@ -578,7 +578,9 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
|
|||||||
{ game,
|
{ game,
|
||||||
#ifdef MACOSX
|
#ifdef MACOSX
|
||||||
/* Qt on OSX would rename "Options" to "Preferences..." and
|
/* Qt on OSX would rename "Options" to "Preferences..." and
|
||||||
move it from intended destination to the application menu */
|
move it from intended destination to the application menu;
|
||||||
|
the ampersand produces &O which makes Alt+O into a keyboard
|
||||||
|
shortcut--except those are disabled by default by Qt on OSX */
|
||||||
"Run-time &" // rely on adjacent string concatenation
|
"Run-time &" // rely on adjacent string concatenation
|
||||||
#endif
|
#endif
|
||||||
"Options", 3, doset},
|
"Options", 3, doset},
|
||||||
@@ -587,9 +589,10 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
|
|||||||
{ game, "Save-and-exit", 3, dosave},
|
{ game, "Save-and-exit", 3, dosave},
|
||||||
{ game,
|
{ game,
|
||||||
#ifdef MACOSX
|
#ifdef MACOSX
|
||||||
/* need something to prevent matching leading "quit"
|
/* need something to prevent matching leading "quit" so that it
|
||||||
so that it isn't hijacked for the application menu */
|
isn't hijacked for the application menu; the ampersand is to
|
||||||
"_&"
|
make &Q be a keyboard shortcut (but see Options above) */
|
||||||
|
"\177&"
|
||||||
#endif
|
#endif
|
||||||
"Quit-without-saving", 3, done2},
|
"Quit-without-saving", 3, done2},
|
||||||
|
|
||||||
@@ -986,29 +989,34 @@ void NetHackQtMainWindow::doQuit(bool)
|
|||||||
{
|
{
|
||||||
// there is a separate Quit-without-saving menu entry in the game menu
|
// there is a separate Quit-without-saving menu entry in the game menu
|
||||||
// that leads to nethack's "Really quit?" prompt; OSX players can use
|
// that leads to nethack's "Really quit?" prompt; OSX players can use
|
||||||
// either one, other implementations only have that other one but this
|
// either one, other implementations only have that other one (plus
|
||||||
// routine is unconditional in case someone wants to change that
|
// nethack's #quit command itself) but this routine is unconditional
|
||||||
|
// in case someone wants to change that
|
||||||
#ifdef MACOSX
|
#ifdef MACOSX
|
||||||
QString info;
|
QString info;
|
||||||
info.sprintf("This will end your NetHack session.%s",
|
info.sprintf("This will end your NetHack session.%s",
|
||||||
!g.program_state.something_worth_saving ? ""
|
!g.program_state.something_worth_saving ? ""
|
||||||
: "\n(Cancel quitting and use the Save command"
|
: "\n(Cancel quitting and use the Save command"
|
||||||
"\nto save your current game.)");
|
"\nto save your current game.)");
|
||||||
/* this is similar to closeEvent but the details are different */
|
/* this is similar to closeEvent but the details are different;
|
||||||
|
first choice (Cancel) is the default action for most arbitrary keys;
|
||||||
|
the second choice (Quit) is the action for <return> or <space>;
|
||||||
|
<escape> leaves the popup waiting for some other response;
|
||||||
|
the &<char> settings for Alt+<char> shortcuts don't work on OSX */
|
||||||
int act = QMessageBox::information(this, "NetHack", info,
|
int act = QMessageBox::information(this, "NetHack", info,
|
||||||
"&Quit without saving",
|
|
||||||
"&Cancel and return to game",
|
"&Cancel and return to game",
|
||||||
|
"&Quit without saving",
|
||||||
0, 1);
|
0, 1);
|
||||||
switch (act) {
|
switch (act) {
|
||||||
case 0:
|
case 0:
|
||||||
|
// cancel
|
||||||
|
break; // return to game
|
||||||
|
case 1:
|
||||||
// quit -- bypass the prompting preformed by done2()
|
// quit -- bypass the prompting preformed by done2()
|
||||||
g.program_state.stopprint++;
|
g.program_state.stopprint++;
|
||||||
::done(QUIT);
|
::done(QUIT);
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
break;
|
break;
|
||||||
case 1:
|
|
||||||
// cancel
|
|
||||||
break; // return to game
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user