Qt: Fix Qt5 deprecation warnings
Mostly the warnings were about QString::sprintf and QFontMetrics::width. sprintf replacement is asprintf, which annoyingly behaves differently from sprintf - it seems to append to the string. Not thoroughly tested, but seems to work.
This commit is contained in:
+2
-4
@@ -106,7 +106,7 @@ NetHackQtBind::NetHackQtBind(int& argc, char** argv) :
|
|||||||
splash->repaint();
|
splash->repaint();
|
||||||
lsplash->repaint();
|
lsplash->repaint();
|
||||||
capt->repaint();
|
capt->repaint();
|
||||||
qApp->flush();
|
qApp->processEvents();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
splash = 0;
|
splash = 0;
|
||||||
@@ -156,7 +156,6 @@ void NetHackQtBind::qt_init_nhwindows(int* argc, char** argv)
|
|||||||
seteuid(getuid());
|
seteuid(getuid());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QApplication::setColorSpec(ManyColor);
|
|
||||||
instance=new NetHackQtBind(*argc,argv);
|
instance=new NetHackQtBind(*argc,argv);
|
||||||
|
|
||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
@@ -416,8 +415,7 @@ void NetHackQtBind::qt_display_file(const char *filename, boolean must_exist)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (complain) {
|
if (complain) {
|
||||||
QString message;
|
QString message = QString::asprintf("File not found: %s\n",filename);
|
||||||
message.sprintf("File not found: %s\n",filename);
|
|
||||||
QMessageBox::warning(NULL, "File Error", message, QMessageBox::Ignore);
|
QMessageBox::warning(NULL, "File Error", message, QMessageBox::Ignore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -50,8 +50,7 @@ NetHackQtGlyphs::NetHackQtGlyphs()
|
|||||||
|
|
||||||
tile_file = PIXMAPDIR "/x11tiles";
|
tile_file = PIXMAPDIR "/x11tiles";
|
||||||
if (!img.load(tile_file)) {
|
if (!img.load(tile_file)) {
|
||||||
QString msg;
|
QString msg = QString::asprintf("Cannot load 'nhtiles.bmp' or 'x11tiles'.");
|
||||||
msg.sprintf("Cannot load 'nhtiles.bmp' or 'x11tiles'.");
|
|
||||||
QMessageBox::warning(0, "IO Error", msg);
|
QMessageBox::warning(0, "IO Error", msg);
|
||||||
iflags.wc_ascii_map = 1;
|
iflags.wc_ascii_map = 1;
|
||||||
iflags.wc_tiled_map = 0;
|
iflags.wc_tiled_map = 0;
|
||||||
|
|||||||
+1
-1
@@ -106,7 +106,7 @@ void NetHackQtLabelledIcon::setLabel(const QString& t, long v, long cv,
|
|||||||
if (v==NoNum) {
|
if (v==NoNum) {
|
||||||
buf = "";
|
buf = "";
|
||||||
} else {
|
} else {
|
||||||
buf.sprintf("%ld", v);
|
buf = QString::asprintf("%ld", v);
|
||||||
}
|
}
|
||||||
setLabel(t + buf + tail, cv < prev_value);
|
setLabel(t + buf + tail, cv < prev_value);
|
||||||
prev_value=cv;
|
prev_value=cv;
|
||||||
|
|||||||
+2
-2
@@ -94,7 +94,7 @@ int NetHackQtKeyBuffer::GetAscii()
|
|||||||
|
|
||||||
Qt::KeyboardModifiers NetHackQtKeyBuffer::GetState()
|
Qt::KeyboardModifiers NetHackQtKeyBuffer::GetState()
|
||||||
{
|
{
|
||||||
if ( Empty() ) return 0;
|
if ( Empty() ) return Qt::NoModifier;
|
||||||
Qt::KeyboardModifiers r=TopState();
|
Qt::KeyboardModifiers r=TopState();
|
||||||
out=(out+1)%maxkey;
|
out=(out+1)%maxkey;
|
||||||
return r;
|
return r;
|
||||||
@@ -114,7 +114,7 @@ int NetHackQtKeyBuffer::TopAscii() const
|
|||||||
|
|
||||||
Qt::KeyboardModifiers NetHackQtKeyBuffer::TopState() const
|
Qt::KeyboardModifiers NetHackQtKeyBuffer::TopState() const
|
||||||
{
|
{
|
||||||
if ( Empty() ) return 0;
|
if ( Empty() ) return Qt::NoModifier;
|
||||||
return state[out];
|
return state[out];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-4
@@ -458,8 +458,7 @@ aboutMsg()
|
|||||||
*p = '\0';
|
*p = '\0';
|
||||||
/* it's also long; break it into two pieces */
|
/* it's also long; break it into two pieces */
|
||||||
(void) strsubst(vbuf, " - ", "\n- ");
|
(void) strsubst(vbuf, " - ", "\n- ");
|
||||||
QString msg;
|
QString msg = QString::asprintf(
|
||||||
msg.sprintf(
|
|
||||||
// format
|
// format
|
||||||
"NetHack-Qt is a version of NetHack built using" // no newline
|
"NetHack-Qt is a version of NetHack built using" // no newline
|
||||||
#ifdef KDE
|
#ifdef KDE
|
||||||
@@ -1022,8 +1021,7 @@ void NetHackQtMainWindow::doQuit(bool)
|
|||||||
// nethack's #quit command itself) but this routine is unconditional
|
// nethack's #quit command itself) but this routine is unconditional
|
||||||
// in case someone wants to change that
|
// in case someone wants to change that
|
||||||
#ifdef MACOS
|
#ifdef MACOS
|
||||||
QString info;
|
QString info = QString::asprintf("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.)");
|
||||||
|
|||||||
+1
-1
@@ -145,7 +145,7 @@ void NetHackQtMapViewport::SetupTextmapFont(QPainter &painter)
|
|||||||
QFont f(fontfamily, pts, maybebold);
|
QFont f(fontfamily, pts, maybebold);
|
||||||
painter.setFont(QFont(fontfamily, pts));
|
painter.setFont(QFont(fontfamily, pts));
|
||||||
QFontMetrics fm = painter.fontMetrics();
|
QFontMetrics fm = painter.fontMetrics();
|
||||||
if (fm.width("M") > qt_settings->glyphs().width())
|
if (fm.horizontalAdvance("M") > qt_settings->glyphs().width())
|
||||||
break;
|
break;
|
||||||
if (fm.height() > qt_settings->glyphs().height())
|
if (fm.height() > qt_settings->glyphs().height())
|
||||||
break;
|
break;
|
||||||
|
|||||||
+12
-12
@@ -196,7 +196,7 @@ NetHackQtMenuWindow::NetHackQtMenuWindow(QWidget *parent) :
|
|||||||
|
|
||||||
QPoint pos(0,ok->height());
|
QPoint pos(0,ok->height());
|
||||||
move(pos);
|
move(pos);
|
||||||
prompt.setParent(this,0);
|
prompt.setParent(this);
|
||||||
prompt.move(pos);
|
prompt.move(pos);
|
||||||
|
|
||||||
grid->addWidget(ok, 0, 0);
|
grid->addWidget(ok, 0, 0);
|
||||||
@@ -378,8 +378,8 @@ void NetHackQtMenuWindow::PadMenuColumns(bool split_descr)
|
|||||||
QFontMetrics fm(table->font());
|
QFontMetrics fm(table->font());
|
||||||
QString col0width_str = "";
|
QString col0width_str = "";
|
||||||
if (biggestcount > 0L)
|
if (biggestcount > 0L)
|
||||||
col0width_str.sprintf("%*ld", std::max(countdigits, 1), biggestcount);
|
col0width_str = QString::asprintf("%*ld", std::max(countdigits, 1), biggestcount);
|
||||||
int col0width_int = (int) fm.width(col0width_str) + MENU_WIDTH_SLOP;
|
int col0width_int = (int) fm.horizontalAdvance(col0width_str) + MENU_WIDTH_SLOP;
|
||||||
if (col0width_int > table->columnWidth(0))
|
if (col0width_int > table->columnWidth(0))
|
||||||
WidenColumn(0, col0width_int);
|
WidenColumn(0, col0width_int);
|
||||||
|
|
||||||
@@ -401,7 +401,7 @@ void NetHackQtMenuWindow::PadMenuColumns(bool split_descr)
|
|||||||
QStringList columns = itemlist[row].str.split("\t");
|
QStringList columns = itemlist[row].str.split("\t");
|
||||||
for (int fld = 0; fld < (int) columns.size(); ++fld) {
|
for (int fld = 0; fld < (int) columns.size(); ++fld) {
|
||||||
bool lastcol = (fld == (int) columns.size() - 1);
|
bool lastcol = (fld == (int) columns.size() - 1);
|
||||||
int w = fm.width(columns[fld] + (lastcol ? "" : " "));
|
int w = fm.horizontalAdvance(columns[fld] + (lastcol ? "" : " "));
|
||||||
if (fld >= (int) col_widths.size()) {
|
if (fld >= (int) col_widths.size()) {
|
||||||
col_widths.push_back(w); // add another element
|
col_widths.push_back(w); // add another element
|
||||||
} else if (col_widths[fld] < w) {
|
} else if (col_widths[fld] < w) {
|
||||||
@@ -421,7 +421,7 @@ void NetHackQtMenuWindow::PadMenuColumns(bool split_descr)
|
|||||||
QString Amt = "";
|
QString Amt = "";
|
||||||
long amt = count(row); // fetch item(row,0) as a number
|
long amt = count(row); // fetch item(row,0) as a number
|
||||||
if (amt > 0L)
|
if (amt > 0L)
|
||||||
Amt.sprintf("%*ld", countdigits, amt);
|
Amt = QString::asprintf("%*ld", countdigits, amt);
|
||||||
cnt->setText(Amt);
|
cnt->setText(Amt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,14 +435,14 @@ void NetHackQtMenuWindow::PadMenuColumns(bool split_descr)
|
|||||||
for (int fld = 0; fld < (int) columns.size() - 1; ++fld) {
|
for (int fld = 0; fld < (int) columns.size() - 1; ++fld) {
|
||||||
//columns[fld] += "\t"; /* (used to pad with tabs) */
|
//columns[fld] += "\t"; /* (used to pad with tabs) */
|
||||||
int width = col_widths[fld];
|
int width = col_widths[fld];
|
||||||
while (fm.width(columns[fld]) < width)
|
while (fm.horizontalAdvance(columns[fld]) < width)
|
||||||
columns[fld] += " "; //"\t";
|
columns[fld] += " "; //"\t";
|
||||||
}
|
}
|
||||||
text = columns.join("");
|
text = columns.join("");
|
||||||
twi->setText(text);
|
twi->setText(text);
|
||||||
}
|
}
|
||||||
// TODO? if description needs to wrap, increase the height of this row
|
// TODO? if description needs to wrap, increase the height of this row
|
||||||
int wid = fm.width(text) + MENU_WIDTH_SLOP;
|
int wid = fm.horizontalAdvance(text) + MENU_WIDTH_SLOP;
|
||||||
if (wid > widest4)
|
if (wid > widest4)
|
||||||
widest4 = wid;
|
widest4 = wid;
|
||||||
}
|
}
|
||||||
@@ -464,7 +464,7 @@ void NetHackQtMenuWindow::UpdateCountColumn(long newcount)
|
|||||||
} else {
|
} else {
|
||||||
biggestcount = std::max(biggestcount, newcount);
|
biggestcount = std::max(biggestcount, newcount);
|
||||||
QString num;
|
QString num;
|
||||||
num.sprintf("%*ld", std::max(countdigits, 1), biggestcount);
|
num = QString::asprintf("%*ld", std::max(countdigits, 1), biggestcount);
|
||||||
int numlen = (int) num.length();
|
int numlen = (int) num.length();
|
||||||
if (numlen % 2)
|
if (numlen % 2)
|
||||||
++numlen;
|
++numlen;
|
||||||
@@ -552,7 +552,7 @@ void NetHackQtMenuWindow::AddRow(int row, const MenuItem& mi)
|
|||||||
table->setItem(row, 0, twi);
|
table->setItem(row, 0, twi);
|
||||||
twi->setFlags(Qt::ItemIsEnabled);
|
twi->setFlags(Qt::ItemIsEnabled);
|
||||||
#if 0 // active count field now widened as needed rather than preset
|
#if 0 // active count field now widened as needed rather than preset
|
||||||
WidenColumn(0, fm.width("999999") + MENU_WIDTH_SLOP);
|
WidenColumn(0, fm.horizontalAdvance("999999") + MENU_WIDTH_SLOP);
|
||||||
#else
|
#else
|
||||||
WidenColumn(0, MENU_WIDTH_SLOP);
|
WidenColumn(0, MENU_WIDTH_SLOP);
|
||||||
#endif
|
#endif
|
||||||
@@ -600,7 +600,7 @@ void NetHackQtMenuWindow::AddRow(int row, const MenuItem& mi)
|
|||||||
// for the normal case of "a - ", the trailing space hid the fact that
|
// for the normal case of "a - ", the trailing space hid the fact that
|
||||||
// the column wasn't wide enough for four characters; for the " #"
|
// the column wasn't wide enough for four characters; for the " #"
|
||||||
// and " *" cases, the last character was replaced by very tiny "..."
|
// and " *" cases, the last character was replaced by very tiny "..."
|
||||||
int w = (int) fm.width(letter);
|
int w = (int) fm.horizontalAdvance(letter);
|
||||||
if (w)
|
if (w)
|
||||||
w += MENU_WIDTH_SLOP / 2;
|
w += MENU_WIDTH_SLOP / 2;
|
||||||
WidenColumn(3, w);
|
WidenColumn(3, w);
|
||||||
@@ -608,7 +608,7 @@ void NetHackQtMenuWindow::AddRow(int row, const MenuItem& mi)
|
|||||||
twi = new QTableWidgetItem(text);
|
twi = new QTableWidgetItem(text);
|
||||||
table->setItem(row, 4, twi);
|
table->setItem(row, 4, twi);
|
||||||
table->item(row, 4)->setFlags(Qt::ItemIsEnabled);
|
table->item(row, 4)->setFlags(Qt::ItemIsEnabled);
|
||||||
WidenColumn(4, fm.width(text));
|
WidenColumn(4, fm.horizontalAdvance(text));
|
||||||
|
|
||||||
if ((int) mi.color != -1) {
|
if ((int) mi.color != -1) {
|
||||||
twi->setForeground(colors[mi.color].q);
|
twi->setForeground(colors[mi.color].q);
|
||||||
@@ -875,7 +875,7 @@ void NetHackQtMenuWindow::ToggleSelect(int row, bool already_toggled)
|
|||||||
amt = count(row); // fetch item(row,0) as a number
|
amt = count(row); // fetch item(row,0) as a number
|
||||||
QString Amt = "";
|
QString Amt = "";
|
||||||
if (amt > 0L)
|
if (amt > 0L)
|
||||||
Amt.sprintf("%*ld", countdigits, amt);
|
Amt = QString::asprintf("%*ld", countdigits, amt);
|
||||||
countfield->setText(Amt); // store right-justified value
|
countfield->setText(Amt); // store right-justified value
|
||||||
}
|
}
|
||||||
ClearCount(); // blank out 'countstr' and reset 'counting'
|
ClearCount(); // blank out 'countstr' and reset 'counting'
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ public:
|
|||||||
int width = 0;
|
int width = 0;
|
||||||
QFontMetrics fm(font());
|
QFontMetrics fm(font());
|
||||||
for (int i = 0; i < count(); i++) {
|
for (int i = 0; i < count(); i++) {
|
||||||
int lwidth = fm.width(item(i)->text());
|
int lwidth = fm.horizontalAdvance(item(i)->text());
|
||||||
width = std::max(width, lwidth);
|
width = std::max(width, lwidth);
|
||||||
}
|
}
|
||||||
return width;
|
return width;
|
||||||
|
|||||||
+1
-1
@@ -36,7 +36,7 @@ tryload(QPixmap& pm, const char* fn)
|
|||||||
{
|
{
|
||||||
if (!pm.load(fn)) {
|
if (!pm.load(fn)) {
|
||||||
QString msg;
|
QString msg;
|
||||||
msg.sprintf("Cannot load \"%s\"", fn);
|
msg = QString::asprintf("Cannot load \"%s\"", fn);
|
||||||
QMessageBox::warning(NetHackQtBind::mainWidget(), "IO Error", msg);
|
QMessageBox::warning(NetHackQtBind::mainWidget(), "IO Error", msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-14
@@ -622,7 +622,7 @@ void NetHackQtStatusWindow::HitpointBar()
|
|||||||
geoH.setRight(std::min(lox + pxl_health - 1, hix));
|
geoH.setRight(std::min(lox + pxl_health - 1, hix));
|
||||||
hpbar_health.setGeometry(geoH);
|
hpbar_health.setGeometry(geoH);
|
||||||
w = geoH.right() - geoH.left() + 1; // might yield 0 (ie, if dead)
|
w = geoH.right() - geoH.left() + 1; // might yield 0 (ie, if dead)
|
||||||
styleH.sprintf(styleformat, barcolors[colorindx][0], w, w);
|
styleH = QString::asprintf(styleformat, barcolors[colorindx][0], w, w);
|
||||||
hpbar_health.setStyleSheet(styleH);
|
hpbar_health.setStyleSheet(styleH);
|
||||||
// when healing, having the old injury-side shown while the new
|
// when healing, having the old injury-side shown while the new
|
||||||
// health-side expands pushes the injury farther right and it's
|
// health-side expands pushes the injury farther right and it's
|
||||||
@@ -635,7 +635,7 @@ void NetHackQtStatusWindow::HitpointBar()
|
|||||||
geoI.setRight(hix);
|
geoI.setRight(hix);
|
||||||
hpbar_injury.setGeometry(geoI);
|
hpbar_injury.setGeometry(geoI);
|
||||||
w = geoI.right() - geoI.left() + 1;
|
w = geoI.right() - geoI.left() + 1;
|
||||||
styleI.sprintf(styleformat, barcolors[colorindx][1], w, w);
|
styleI = QString::asprintf(styleformat, barcolors[colorindx][1], w, w);
|
||||||
hpbar_injury.setStyleSheet(styleI);
|
hpbar_injury.setStyleSheet(styleI);
|
||||||
if (geoI.left() != oldleft)
|
if (geoI.left() != oldleft)
|
||||||
hpbar_injury.move(geoI.left(), geoI.top());
|
hpbar_injury.move(geoI.left(), geoI.top());
|
||||||
@@ -653,7 +653,7 @@ void NetHackQtStatusWindow::HitpointBar()
|
|||||||
geoH.setRight(hix);
|
geoH.setRight(hix);
|
||||||
hpbar_health.setGeometry(geoH);
|
hpbar_health.setGeometry(geoH);
|
||||||
w = geoH.right() - geoH.left() + 1;
|
w = geoH.right() - geoH.left() + 1;
|
||||||
styleH.sprintf(styleformat, barcolors[colorindx][0], w, w);
|
styleH = QString::asprintf(styleformat, barcolors[colorindx][0], w, w);
|
||||||
hpbar_health.setStyleSheet(styleH);
|
hpbar_health.setStyleSheet(styleH);
|
||||||
hpbar_health.show();
|
hpbar_health.show();
|
||||||
|
|
||||||
@@ -704,13 +704,13 @@ void NetHackQtStatusWindow::updateStats()
|
|||||||
|
|
||||||
int st = ACURR(A_STR);
|
int st = ACURR(A_STR);
|
||||||
if (st > STR18(100)) {
|
if (st > STR18(100)) {
|
||||||
buf.sprintf("Str:%d", st - 100); // 19..25
|
buf = QString::asprintf("Str:%d", st - 100); // 19..25
|
||||||
} else if (st == STR18(100)) {
|
} else if (st == STR18(100)) {
|
||||||
buf.sprintf("Str:18/**"); // 18/100
|
buf = QString::asprintf("Str:18/**"); // 18/100
|
||||||
} else if (st > 18) {
|
} else if (st > 18) {
|
||||||
buf.sprintf("Str:18/%02d", st - 18); // 18/01..18/99
|
buf = QString::asprintf("Str:18/%02d", st - 18); // 18/01..18/99
|
||||||
} else {
|
} else {
|
||||||
buf.sprintf("Str:%d", st); // 3..18
|
buf = QString::asprintf("Str:%d", st); // 3..18
|
||||||
}
|
}
|
||||||
str.setLabel(buf, NetHackQtLabelledIcon::NoNum, (long) st);
|
str.setLabel(buf, NetHackQtLabelledIcon::NoNum, (long) st);
|
||||||
dex.setLabel("Dex:", (long) ACURR(A_DEX));
|
dex.setLabel("Dex:", (long) ACURR(A_DEX));
|
||||||
@@ -799,7 +799,7 @@ void NetHackQtStatusWindow::updateStats()
|
|||||||
}
|
}
|
||||||
QString buf2;
|
QString buf2;
|
||||||
char buf3[BUFSZ];
|
char buf3[BUFSZ];
|
||||||
buf2.sprintf("%s the %s", upstart(strcpy(buf3, g.plname)),
|
buf2 = QString::asprintf("%s the %s", upstart(strcpy(buf3, g.plname)),
|
||||||
buf.toLatin1().constData());
|
buf.toLatin1().constData());
|
||||||
name.setLabel(buf2, NetHackQtLabelledIcon::NoNum, u.ulevel);
|
name.setLabel(buf2, NetHackQtLabelledIcon::NoNum, u.ulevel);
|
||||||
|
|
||||||
@@ -818,13 +818,13 @@ void NetHackQtStatusWindow::updateStats()
|
|||||||
level.setCompareMode(NeitherIsBetter);
|
level.setCompareMode(NeitherIsBetter);
|
||||||
if (Upolyd) {
|
if (Upolyd) {
|
||||||
// You're a monster!
|
// You're a monster!
|
||||||
buf.sprintf("/%d", u.mhmax);
|
buf = QString::asprintf("/%d", u.mhmax);
|
||||||
hp.setLabel("HP:", std::max((long) u.mh, 0L), buf);
|
hp.setLabel("HP:", std::max((long) u.mh, 0L), buf);
|
||||||
level.setLabel("HD:", (long) mons[u.umonnum].mlevel); // hit dice
|
level.setLabel("HD:", (long) mons[u.umonnum].mlevel); // hit dice
|
||||||
// Exp points are not shown when HD is displayed instead of Xp level
|
// Exp points are not shown when HD is displayed instead of Xp level
|
||||||
} else {
|
} else {
|
||||||
// You're normal.
|
// You're normal.
|
||||||
buf.sprintf("/%d", u.uhpmax);
|
buf = QString::asprintf("/%d", u.uhpmax);
|
||||||
hp.setLabel("HP:", std::max((long) u.uhp, 0L), buf);
|
hp.setLabel("HP:", std::max((long) u.uhp, 0L), buf);
|
||||||
// if Exp points are to be displayed, append them to Xp level;
|
// if Exp points are to be displayed, append them to Xp level;
|
||||||
// up/down highlighting becomes tricky--don't try very hard;
|
// up/down highlighting becomes tricky--don't try very hard;
|
||||||
@@ -835,9 +835,9 @@ void NetHackQtStatusWindow::updateStats()
|
|||||||
for (int i = ::flags.showexp ? 0 : 3; i < 4; ++i) {
|
for (int i = ::flags.showexp ? 0 : 3; i < 4; ++i) {
|
||||||
// passes 0,1,2 are with Exp, 3 is without Exp and always fits
|
// passes 0,1,2 are with Exp, 3 is without Exp and always fits
|
||||||
if (i < 3) {
|
if (i < 3) {
|
||||||
buf.sprintf("%s%ld/%ld", lvllbl[i], (long) u.ulevel, u.uexp);
|
buf = QString::asprintf("%s%ld/%ld", lvllbl[i], (long) u.ulevel, u.uexp);
|
||||||
} else {
|
} else {
|
||||||
buf.sprintf("%s%ld", lvllbl[i - 3], (long) u.ulevel);
|
buf = QString::asprintf("%s%ld", lvllbl[i - 3], (long) u.ulevel);
|
||||||
}
|
}
|
||||||
// +2: allow a couple of pixels at either end to be clipped off
|
// +2: allow a couple of pixels at either end to be clipped off
|
||||||
if (fm.size(0, buf).width() <= (2 + level.label->width() + 2))
|
if (fm.size(0, buf).width() <= (2 + level.label->width() + 2))
|
||||||
@@ -857,7 +857,7 @@ void NetHackQtStatusWindow::updateStats()
|
|||||||
was_polyd = Upolyd ? true : false;
|
was_polyd = Upolyd ? true : false;
|
||||||
had_exp = (::flags.showexp && !was_polyd) ? true : false;
|
had_exp = (::flags.showexp && !was_polyd) ? true : false;
|
||||||
|
|
||||||
buf.sprintf("/%d", u.uenmax);
|
buf = QString::asprintf("/%d", u.uenmax);
|
||||||
power.setLabel("Pow:", (long) u.uen, buf);
|
power.setLabel("Pow:", (long) u.uen, buf);
|
||||||
ac.setLabel("AC:", (long) u.uac);
|
ac.setLabel("AC:", (long) u.uac);
|
||||||
// gold prefix used to be "Au:", tty uses "$:"; never too wide to fit;
|
// gold prefix used to be "Au:", tty uses "$:"; never too wide to fit;
|
||||||
@@ -917,7 +917,7 @@ void NetHackQtStatusWindow::updateStats()
|
|||||||
static const char *const scrlbl[3] = { "Score:", "Scr:", "S:" };
|
static const char *const scrlbl[3] = { "Score:", "Scr:", "S:" };
|
||||||
QFontMetrics fm(score.label->font());
|
QFontMetrics fm(score.label->font());
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
buf.sprintf("%s%ld", scrlbl[i], pts);
|
buf = QString::asprintf("%s%ld", scrlbl[i], pts);
|
||||||
// +2: allow couple of pixels at either end to be clipped off
|
// +2: allow couple of pixels at either end to be clipped off
|
||||||
if (fm.size(0, buf).width() <= (2 + score.width() + 2))
|
if (fm.size(0, buf).width() <= (2 + score.width() + 2))
|
||||||
break;
|
break;
|
||||||
|
|||||||
+2
-2
@@ -80,8 +80,8 @@ bool NetHackQtStringRequestor::Get(char *buffer, int maxchar, int minchar)
|
|||||||
input.setMaxLength(maxchar - 1);
|
input.setMaxLength(maxchar - 1);
|
||||||
|
|
||||||
const QString &txt = prompt.text();
|
const QString &txt = prompt.text();
|
||||||
int pw = fontMetrics().width(txt),
|
int pw = fontMetrics().horizontalAdvance(txt),
|
||||||
ww = minchar * input.fontMetrics().width(QChar('X'));
|
ww = minchar * input.fontMetrics().horizontalAdvance(QChar('X'));
|
||||||
int heightfactor = ((txt.size() > 16) ? 3 : 2) * 2; // 2 or 3 lines high
|
int heightfactor = ((txt.size() > 16) ? 3 : 2) * 2; // 2 or 3 lines high
|
||||||
int widthfudge = (((txt.size() > 16) ? 1 : 2) * 5) * 2; // 5: margn, guttr
|
int widthfudge = (((txt.size() > 16) ? 1 : 2) * 5) * 2; // 5: margn, guttr
|
||||||
resize(pw + ww + widthfudge, fontMetrics().height() * heightfactor);
|
resize(pw + ww + widthfudge, fontMetrics().height() * heightfactor);
|
||||||
|
|||||||
+1
-1
@@ -244,7 +244,7 @@ NetHackQtExtCmdRequestor::NetHackQtExtCmdRequestor(QWidget *parent) :
|
|||||||
for (i = 0; extcmdlist[i].ef_txt; ++i) {
|
for (i = 0; extcmdlist[i].ef_txt; ++i) {
|
||||||
if (interesting_command(i, set)) {
|
if (interesting_command(i, set)) {
|
||||||
++ncmds;
|
++ncmds;
|
||||||
butw = std::max(butw, 30 + fm.width(extcmdlist[i].ef_txt));
|
butw = std::max(butw, 30 + fm.horizontalAdvance(extcmdlist[i].ef_txt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if any of the choice buttons were bigger than the control buttons,
|
// if any of the choice buttons were bigger than the control buttons,
|
||||||
|
|||||||
+2
-2
@@ -148,7 +148,7 @@ char NetHackQtYnDialog::Exec()
|
|||||||
q->setMargin(4);
|
q->setMargin(4);
|
||||||
vb->addWidget(q);
|
vb->addWidget(q);
|
||||||
}
|
}
|
||||||
QGroupBox *group = new QGroupBox(bigq ? QString::null : qlabel, this);
|
QGroupBox *group = new QGroupBox(bigq ? QString() : qlabel, this);
|
||||||
vb->addWidget(group);
|
vb->addWidget(group);
|
||||||
QHBoxLayout *groupbox = new QHBoxLayout();
|
QHBoxLayout *groupbox = new QHBoxLayout();
|
||||||
group->setLayout(groupbox);
|
group->setLayout(groupbox);
|
||||||
@@ -350,7 +350,7 @@ char NetHackQtYnDialog::Exec()
|
|||||||
QPushButton cancel("Dismiss",this);
|
QPushButton cancel("Dismiss",this);
|
||||||
label.setFrameStyle(QFrame::Box|QFrame::Sunken);
|
label.setFrameStyle(QFrame::Box|QFrame::Sunken);
|
||||||
label.setAlignment(Qt::AlignCenter);
|
label.setAlignment(Qt::AlignCenter);
|
||||||
label.resize(fontMetrics().width(qlabel)+60,30+fontMetrics().height());
|
label.resize(fontMetrics().horizontalAdvance(qlabel)+60,30+fontMetrics().height());
|
||||||
cancel.move(width()/2-cancel.width()/2,label.geometry().bottom()+8);
|
cancel.move(width()/2-cancel.width()/2,label.geometry().bottom()+8);
|
||||||
connect(&cancel,SIGNAL(clicked()),this,SLOT(reject()));
|
connect(&cancel,SIGNAL(clicked()),this,SLOT(reject()));
|
||||||
centerOnMain(this);
|
centerOnMain(this);
|
||||||
|
|||||||
Reference in New Issue
Block a user