Qt4: Add menucolors

The Qt4 windowport already supported my 3.4.3 menucolors patch, so
adding that was simple.
This commit is contained in:
Pasi Kallinen
2017-10-08 01:45:46 +03:00
parent b744e2ce1f
commit 583edab99f
3 changed files with 3 additions and 31 deletions

View File

@@ -1723,7 +1723,7 @@ E const char *FDECL(clr2colorname, (int));
E int FDECL(match_str2clr, (char *));
E int FDECL(match_str2attr, (const char *, BOOLEAN_P));
E boolean FDECL(add_menu_coloring, (char *));
E boolean FDECL(get_menu_coloring, (char *, int *, int *));
E boolean FDECL(get_menu_coloring, (const char *, int *, int *));
E void NDECL(free_menu_coloring);
E boolean FDECL(msgtype_parse_add, (char *));
E int FDECL(msgtype_type, (const char *, BOOLEAN_P));

View File

@@ -1747,7 +1747,7 @@ char *tmpstr;
boolean
get_menu_coloring(str, color, attr)
char *str;
const char *str;
int *color, *attr;
{
struct menucoloring *tmpmc;

View File

@@ -32,9 +32,7 @@ extern "C" {
extern "C" int qt_compact_mode;
// end temporary
#ifdef MENU_COLOR
extern "C" struct menucoloring *menu_colorings;
#endif
namespace nethack_qt4 {
@@ -42,8 +40,6 @@ namespace nethack_qt4 {
void centerOnMain( QWidget* w );
// end temporary
static boolean get_menu_coloring(char const *str, int *color, int *attr);
QSize NetHackQtTextListBox::sizeHint() const
{
QScrollBar *hscroll = horizontalScrollBar();
@@ -194,39 +190,17 @@ void NetHackQtMenuWindow::AddMenu(int glyph, const ANY_P* identifier,
+ str.mid(bracket+2);
}
}
#ifdef MENU_COLOR
int mcolor, mattr;
if (attr == 0
&& get_menu_coloring(str.toLatin1().constData(), &mcolor, &mattr)) {
&& get_menu_coloring(str.toLatin1().constData(), &mcolor, &mattr)) {
itemlist[itemcount].attr = mattr;
itemlist[itemcount].color = mcolor;
}
#endif
++itemcount;
if (glyph!=NO_GLYPH) has_glyphs=true;
}
#ifdef MENU_COLOR
static boolean
get_menu_coloring(char const *str, int *color, int *attr)
{
struct menucoloring *tmpmc;
if (iflags.use_menu_color)
for (tmpmc = menu_colorings; tmpmc; tmpmc = tmpmc->next)
# ifdef MENU_COLOR_REGEX
if (re_search(&tmpmc->match, str, strlen(str), 0, 9999, 0) >= 0) {
# else
if (pmatch(tmpmc->match, str)) {
# endif
*color = tmpmc->color;
*attr = tmpmc->attr;
return TRUE;
}
return FALSE;
}
#endif /* MENU_COLOR */
void NetHackQtMenuWindow::EndMenu(const QString& p)
{
prompt.setText(p);
@@ -417,11 +391,9 @@ void NetHackQtMenuWindow::AddRow(int row, const MenuItem& mi)
table->item(row, 4)->setFlags(Qt::ItemIsEnabled);
WidenColumn(4, fm.width(text));
#ifdef MENU_COLOR
if (mi.color != -1) {
twi->setForeground(colors[mi.color]);
}
#endif
QFont itemfont(table->font());
switch (mi.attr) {