Qt's window menus
Qt on OSX is inserting "Search [_____]" as the first entry in the Help dropdown menu (the one in the toolbar at the top of the desttop). While trying--and failing--to figure out how to get rid of that, I cleaned up a little bit of the old menu hackery (that tries to workaround the fact that Qt on OSX insists that some menu actions--based solely on their names--should go into the appication menu rather than whichever menu the program is trying to insert them into). The only observeable difference is that 'About NetHack-Qt' will be at the top (actually second because of that Search one) of the Help dropdown, where it is on non-OSX builds, rather than last. This tries to make the program name consistent too, changing several instances of "Qt NetHack" to be "NetHack-Qt". The latter is the name being set up as ApplicationName in qt_bind.cpp that gets used when Qt stashes the Qt-specific settings wherever it stashes them. It also makes another tweak in formatting of 'About NetHack-Qt', inserting one explicit line break to avoid some poor looking line wrapping. I still haven't figured out how to control that popup's size.
This commit is contained in:
@@ -26,6 +26,12 @@ around by giving focus to some other application (which will put up
|
||||
its own menu bar) and then back to nethack (thereby reloading nethack's
|
||||
menu bar).
|
||||
|
||||
On OSX, a "Search [______]" action is inserted as the first entry of
|
||||
the dropdown Help menu on the toolbar. NetHack has no control over
|
||||
what it does or where it looks, so it should be eliminated somehow.
|
||||
(It is not releated to nethack's search command, nor the interception
|
||||
of an attempt to insert "Search" into the dropdown Action menu.)
|
||||
|
||||
Sometimes scrolling a menu leaves the displayed text not matching what
|
||||
nethack thinks is displayed, so making a selection by mouse click may
|
||||
occasionally pick the wrong item. There's usually a visual clue when
|
||||
|
||||
@@ -454,10 +454,12 @@ aboutMsg()
|
||||
but we're using it mid-sentence so strip period off */
|
||||
if ((p = strrchr(getversionstring(vbuf), '.')) != 0 && *(p + 1) == '\0')
|
||||
*p = '\0';
|
||||
/* it's also long; break it into two pieces */
|
||||
(void) strsubst(vbuf, " - ", "\n- ");
|
||||
QString msg;
|
||||
msg.sprintf(
|
||||
// format
|
||||
"Qt NetHack is a version of NetHack built using" // no newline
|
||||
"NetHack-Qt is a version of NetHack built using" // no newline
|
||||
#ifdef KDE
|
||||
" KDE and" // ditto
|
||||
#endif
|
||||
@@ -527,7 +529,7 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
|
||||
addToolBar(toolbar);
|
||||
menubar = menuBar();
|
||||
|
||||
setWindowTitle("Qt NetHack");
|
||||
setWindowTitle("NetHack-Qt");
|
||||
setWindowIcon(QIcon(QPixmap(qt_compact_mode ? nh_icon_small : nh_icon)));
|
||||
|
||||
#ifdef MACOSX
|
||||
@@ -672,26 +674,42 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
int i;
|
||||
|
||||
game->addAction(
|
||||
QAction *actn;
|
||||
#ifndef MACOSX
|
||||
"Qt settings...",
|
||||
(void) game->addAction("Qt settings...", this, SLOT(doQtSettings(bool)));
|
||||
#else
|
||||
/* on OSX, put this in the application menu by using
|
||||
a name that Qt will move to that menu */
|
||||
"Preferences...",
|
||||
/* on OSX, put this in the application menu instead of the game menu;
|
||||
Qt would change the action name behind our backs; do it explicitly */
|
||||
actn = game->addAction("Preferences...", this, SLOT(doQtSettings(bool)));
|
||||
actn->setMenuRole(QWidgetAction::PreferencesRole);
|
||||
/* we also want a "Quit NetHack" entry in the application menu;
|
||||
when "_Quit-without-saving" was called "Quit" it got intercepted
|
||||
for that, but now this needs to be added separately; we'll use a
|
||||
handy menu and let the interception put it in the intended place;
|
||||
unlike About, it is not a duplicate; _Quit-without-saving runs
|
||||
nethack's #quit command with "really quit?" prompt, this quit--with
|
||||
Command+q as shortcut--pops up a dialog to choose between quit or
|
||||
cancel-and-resume-playing */
|
||||
actn = game->addAction("Quit NetHack-Qt", this, SLOT(doQuit(bool)));
|
||||
actn->setMenuRole(QWidgetAction::QuitRole);
|
||||
#endif
|
||||
|
||||
actn = help->addAction("About NetHack-Qt", this, SLOT(doAbout(bool)));
|
||||
#ifdef MACOSX
|
||||
actn->setMenuRole(QWidgetAction::AboutRole);
|
||||
/* for OSX, the preceding "About" went into the application menu;
|
||||
now add another duplicate one to the Help dropdown menu */
|
||||
actn = help->addAction("About NetHack-Qt", this, SLOT(doAbout(bool)));
|
||||
actn->setMenuRole(QWidgetAction::NoRole);
|
||||
#else
|
||||
nhUse(actn);
|
||||
#endif
|
||||
this, SLOT(doQtSettings(bool)));
|
||||
/* on OSX, 'about' will end up in the application menu rather than
|
||||
the help menu (this had trailing "..." but that conflicts with
|
||||
the convention that an elipsis indicates the choice will bring
|
||||
up its own sub-menu) */
|
||||
help->addAction("About Qt NetHack", this, SLOT(doAbout(bool)));
|
||||
//help->addAction("NetHack Guidebook", this, SLOT(doGuidebook(bool)));
|
||||
help->addSeparator();
|
||||
|
||||
for (i=0; item[i].menu; i++) {
|
||||
//help->addAction("NetHack Guidebook", this, SLOT(doGuidebook(bool)));
|
||||
//help->addSeparator();
|
||||
|
||||
for (int i = 0; item[i].menu; ++i) {
|
||||
if ( item[i].flags & (qt_compact_mode ? 1 : 2) ) {
|
||||
if (item[i].name) {
|
||||
char actchar[32];
|
||||
@@ -766,21 +784,6 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
|
||||
help->setTitle("Help");
|
||||
menubar->addMenu(help);
|
||||
}
|
||||
#ifdef MACOSX
|
||||
/* for OSX, the attempt above to add "About Qt NetHack" went into
|
||||
the application menu instead of the help menu; we'll add it to
|
||||
the latter now and have two ways to access it; without the
|
||||
leading underscore (or some other spelling variation such as
|
||||
"'bout"), this one would get intercepted too and then evidently
|
||||
be discarded as a duplicate */
|
||||
help->addSeparator();
|
||||
help->addAction("_About_Qt_NetHack_", this, SLOT(doAbout(bool)));
|
||||
/* we also want a "Quit NetHack" entry in the application menu;
|
||||
when "_Quit-without-saving" was called "Quit" it got intercepted
|
||||
for that, but now it needs to be added separately; we'll use a
|
||||
handy menu and let the interception put it in the intended place */
|
||||
game->addAction("Quit NetHack", this, SLOT(doQuit(bool)));
|
||||
#endif
|
||||
|
||||
// order changed: was Again, Get, Kick, Throw, Fire, Drop, Eat, Rest
|
||||
// now Again, PickUp, Drop, Kick, Throw, Fire, Eat, Rest
|
||||
@@ -952,7 +955,7 @@ void NetHackQtMainWindow::doQtSettings(bool)
|
||||
|
||||
void NetHackQtMainWindow::doAbout(bool)
|
||||
{
|
||||
QMessageBox::about(this, "About Qt NetHack", aboutMsg());
|
||||
QMessageBox::about(this, "About NetHack-Qt", aboutMsg());
|
||||
}
|
||||
|
||||
// on OSX, "quit nethack" has been selected in the application menu or
|
||||
|
||||
Reference in New Issue
Block a user