]> granicus.if.org Git - nethack/commitdiff
Qt menu bandaid
authorPatR <rankin@nethack.org>
Sun, 9 Aug 2020 01:21:38 +0000 (18:21 -0700)
committerPatR <rankin@nethack.org>
Sun, 9 Aug 2020 01:21:38 +0000 (18:21 -0700)
Menu hackery:  change a couple of menu entry names on OSX to
control where they end up.

Move nethack's 'O' command from its hijacked position (due to name
"Options") of "nethack->Preferences..." to "Game->Run-time options".

Move persistent Qt settings on OSX from "Game->Qt settings" to
"nethack->Preferences...".

The Qt settings dialog (now accessed as Preferences...) desperately
needs a title and/or other explanatory text but I haven't figured
out how do to that.  The values set with it are persistent, with
apparently quite a few choices for where to save them for future
runs.  I used it to increase the size of text in the status window,
and found my settings stored in binary file
 ~/Library/Preferences/org.nethack.NetHack.plist
The subdirectories ~/Library and ~/Library/Preferences are
standard OSX per-user things.  The file name is derived from values
set up in main routine:  qt_main.cpp is setting OrganizationDomain
to "nethack.org" and ApplicationName to "NetHack".  I've added a
value for ApplicationVersion but don't know whether anything cares
about it.

doc/fixes37.0
win/Qt/qt_main.cpp

index b5f63675cc4aded8801f74222e8f361bd6858f68..7f5bc138f1f39910bf7f674726317f4df8ce6bcc 100644 (file)
@@ -1,4 +1,4 @@
-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.277 $ $NHDT-Date: 1596841504 2020/08/07 23:05:04 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.278 $ $NHDT-Date: 1596936095 2020/08/09 01:21:35 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -355,7 +355,6 @@ Qt: switch to fixed-width font for menus
 Qt: don't disable [cancel] button when viewing inventory or other pick-none
        menus; ESC works to dismiss those and [cancel] should be the same
 Qt: bring status conditions up to 3.6 levels but new ones lack pictures
-Qt: fix control key on OSX
 Qt: clicking on the window's Close button brought up a dialog offering
        choices of "Save" and "Cancel"; picking Cancel sent nethack into an
        infinite loop with complaints about Qt's event loop already being
@@ -363,6 +362,10 @@ Qt: clicking on the window's Close button brought up a dialog offering
        with no opportunity to try to back out of the Close operation
 Qt: add 3.6 status fields Stone, Slime, Strngl, Deaf, Lev, Fly, Ride
 Qt: add Attributes, Overview, and Annotate to the "Info" pull down menu
+Qt+QSX: fix control key
+Qt+OSX: rename menu entry "nethack->Preferences..." for invoking nethack's
+       'O' command to "Game->Run-time options" and entry "Game->Qt settings"
+       for making persistent Qt customizations to "nethack->Preferences..."
 tiles: add indicator of thonged portion to aklys tile
 tty: role and race selection menus weren't filtering out potential choices
        which got excluded by OPTIONS=align:!lawful or !neutral or !chaotic
index 0f6870b9d5f381103d0709ee14172e0d8cda79e1..163616d76a485a9148ebf434cd5748bba98ced61 100644 (file)
@@ -520,6 +520,11 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
     QCoreApplication::setOrganizationName("The NetHack DevTeam");
     QCoreApplication::setOrganizationDomain("nethack.org");
     QCoreApplication::setApplicationName("NetHack");
+    {
+        char cvers[BUFSZ];
+        QString qvers = version_string(cvers);
+        QCoreApplication::setApplicationVersion(qvers);
+    }
 #ifdef MACOSX
     /* without this, neither control+x nor option+x do anything;
        with it, control+x is ^X and option+x still does nothing */
@@ -527,11 +532,24 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
 #endif
 
     setWindowTitle("Qt NetHack");
-    if ( qt_compact_mode )
-       setWindowIcon(QIcon(QPixmap(nh_icon_small)));
-    else
-       setWindowIcon(QIcon(QPixmap(nh_icon)));
+    setWindowIcon(QIcon(QPixmap(qt_compact_mode ? nh_icon_small : nh_icon)));
 
+#ifdef MACOSX
+    /*
+     * OSX Note:
+     *  The toolbar on OSX starts with a system menu labeled with the
+     *  Apple logo and an application menu labeled with the application's
+     *  name (taken from Info.plist if present, otherwise the base name
+     *  of the running program).  After that, application-specific menus
+     *  (in our case "game",...,"help") follow.  Several menu entry
+     *  names ("About", "Quit"/"Exit", "Preferences"/"Options"/
+     *  "Settings"/"Setup"/"Config") get hijacked and placed in the
+     *  application menu (and renamed in the process) even if the code
+     *  here tries to put them in another menu.
+     *  See QtWidgets/doc/qmenubar.html for slightly more information.
+     *  setMenuRole() is supposed to be able to override this behavior.
+     */
+#endif
     QMenu* game=new QMenu;
     QMenu* apparel=new QMenu;
     QMenu* act1=new QMenu;
@@ -540,7 +558,6 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
     QMenu* info=new QMenu;
 
     QMenu *help;
-
 #ifdef KDE
     help = kapp->getHelpMenu( true, "" );
     help->addSeparator();
@@ -560,7 +577,15 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
         { game,    "Compilation",        3, doextversion},
         { game,    "History",            3, dohistory},
         { game,    "Redraw",             0, doredraw}, // useless
-        { game,    "Options",            3, doset},
+        { game,
+#ifndef MACOSX
+                   "Options",
+#else
+             /* Qt on OSX would rename "Options" to "Preferences..." and
+                move it from intended destination to the application menu */
+                   "Run-time options",
+#endif
+                                         3, doset},
         { game,    "Explore mode",       3, enter_explore_mode},
         { game,    0, 3},
         { game,    "Save",               3, dosave},
@@ -574,11 +599,11 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
         { apparel, "Two weapon combat",  3, dotwoweapon},
         { apparel, "Load quiver",        3, dowieldquiver},
         { apparel, 0, 3},
-        { apparel, "Wear armour",        3, dowear},
-        { apparel, "Take off armour",    3, dotakeoff},
+        { apparel, "Wear armor",         3, dowear},
+        { apparel, "Take off armor",     3, dotakeoff},
         { apparel, 0, 3},
-        { apparel, "Put on non-armour",  3, doputon},
-        { apparel, "Remove non-armour",  3, doremring},
+        { apparel, "Put on accessories", 3, doputon},
+        { apparel, "Remove accessories", 3, doremring},
 
         /* { act1,      "Again\tCtrl+A",           "\001", 2},
         { act1, 0, 0, 3}, */
@@ -636,10 +661,10 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
         { info,  "Conduct",          3, doconduct},
         { info,  "Discoveries",      3, dodiscovered},
         { info,  "List/reorder spells",  3, dovspell},
-        { info,  "Adjust inventory letters", 2, doorganize },
+        { info,  "Adjust inventory letters", 3, doorganize },
         { info,  0, 3},
         { info,  "Name object or creature", 3, docallcmd},
-        { info,  "Annotate level",   2, donamelevel },
+        { info,  "Annotate level",   3, donamelevel },
         { info,  0, 3},
         { info,  "Skills",  3, enhance_weapon_skill},
 
@@ -648,7 +673,17 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
 
     int i;
 
-    game->addAction("Qt settings...",this,SLOT(doQtSettings(bool)));
+    game->addAction(
+#ifndef MACOSX
+                    "Qt settings...",
+#else
+                    /* on OSX, put this in the application menu by using
+                       a name that Qt will move to that menu */
+                    "Preferences...",
+#endif
+                    this, SLOT(doQtSettings(bool)));
+    /* on OSX, 'about' will end up in the application menu
+       rather than the help menu; at present, just live with that */
     help->addAction("About Qt NetHack...",this,SLOT(doAbout(bool)));
     //help->addAction("NetHack Guidebook...",this,SLOT(doGuidebook(bool)));
     help->addSeparator();