Changes for Qt 6 on MacOS
This commit is contained in:
+13
-8
@@ -7,15 +7,20 @@
|
||||
extern "C" {
|
||||
#include "hack.h"
|
||||
}
|
||||
#undef C
|
||||
|
||||
#include "qt_pre.h"
|
||||
#include <QtGui/QtGui>
|
||||
#include <QtCore/QStringList>
|
||||
#if QT_VERSION >= 0x050000
|
||||
#if QT_VERSION < 0x050000
|
||||
#include <QtGui/QSound>
|
||||
#elif QT_VERSION < 0x060000
|
||||
#include <QtWidgets/QtWidgets>
|
||||
#include <QtMultimedia/QSound>
|
||||
#else
|
||||
#include <QtGui/QSound>
|
||||
#include <QtWidgets/QtWidgets>
|
||||
#undef QT_NO_SOUND
|
||||
#define QT_NO_SOUND 1
|
||||
#endif
|
||||
#include "qt_post.h"
|
||||
#include "qt_bind.h"
|
||||
@@ -88,10 +93,10 @@ NetHackQtBind::NetHackQtBind(int& argc, char** argv) :
|
||||
capt->setAlignment(Qt::AlignCenter);
|
||||
if ( !pm.isNull() ) {
|
||||
lsplash->setFixedSize(pm.size());
|
||||
lsplash->setMask(pm);
|
||||
lsplash->setMask(QBitmap(pm));
|
||||
}
|
||||
splash->move((QApplication::desktop()->width()-pm.width())/2,
|
||||
(QApplication::desktop()->height()-pm.height())/2);
|
||||
splash->move((splash->screen()->size().width()-pm.width())/2,
|
||||
(splash->screen()->size().height()-pm.height())/2);
|
||||
//splash->setGeometry(0,0,100,100);
|
||||
if ( qt_compact_mode ) {
|
||||
splash->showMaximized();
|
||||
@@ -930,9 +935,9 @@ bool NetHackQtBind::notify(QObject *receiver, QEvent *event)
|
||||
}
|
||||
}
|
||||
QString key = key_event->text();
|
||||
QChar ch = !key.isEmpty() ? key.at(0) : 0;
|
||||
if (ch > 128)
|
||||
ch = 0;
|
||||
QChar ch = !key.isEmpty() ? key.at(0) : QChar(0);
|
||||
if (ch > QChar(128))
|
||||
ch = QChar(0);
|
||||
// on OSX, ascii control codes are not sent, force them
|
||||
if (ch == 0 && (mod & Qt::ControlModifier) != 0) {
|
||||
if (k >= Qt::Key_A && k <= Qt::Key_Underscore)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
extern "C" {
|
||||
#include "hack.h"
|
||||
}
|
||||
#undef C
|
||||
|
||||
#include "qt_pre.h"
|
||||
#include <QtGui/QtGui>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
extern "C" {
|
||||
#include "hack.h"
|
||||
}
|
||||
#undef C
|
||||
|
||||
#include "qt_pre.h"
|
||||
#include <QtGui/QtGui>
|
||||
|
||||
@@ -8,6 +8,7 @@ extern "C" {
|
||||
#include "hack.h"
|
||||
#include "tile2x11.h" /* x11tiles is potential fallback for nhtiles.bmp */
|
||||
}
|
||||
#undef C
|
||||
|
||||
#include "qt_pre.h"
|
||||
#include <QtGui/QtGui>
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
extern "C" {
|
||||
#include "hack.h"
|
||||
}
|
||||
#undef C
|
||||
|
||||
#include "qt_pre.h"
|
||||
#include <QtGui/QtGui>
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
extern "C" {
|
||||
#include "hack.h"
|
||||
}
|
||||
#undef C
|
||||
|
||||
#include "qt_pre.h"
|
||||
#include <QtGui/QtGui>
|
||||
|
||||
+4
-3
@@ -7,6 +7,7 @@
|
||||
extern "C" {
|
||||
#include "hack.h"
|
||||
}
|
||||
#undef C
|
||||
|
||||
#include "qt_pre.h"
|
||||
#include <QtGui/QtGui>
|
||||
@@ -25,10 +26,10 @@ uchar keyValue(QKeyEvent *key_event)
|
||||
const int k = key_event->key();
|
||||
Qt::KeyboardModifiers mod = key_event->modifiers();
|
||||
const QString &txt = key_event->text();
|
||||
QChar ch = !txt.isEmpty() ? txt.at(0) : 0;
|
||||
QChar ch = !txt.isEmpty() ? txt.at(0) : QChar(0);
|
||||
|
||||
if (ch >= 128)
|
||||
ch = 0;
|
||||
if (ch >= QChar(128))
|
||||
ch = QChar(0);
|
||||
// on OSX, ascii control codes are not sent, force them
|
||||
if (ch == 0 && (mod & Qt::ControlModifier) != 0) {
|
||||
if (k >= Qt::Key_A && k <= Qt::Key_Underscore)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
extern "C" {
|
||||
#include "hack.h"
|
||||
}
|
||||
#undef C
|
||||
|
||||
#include "qt_pre.h"
|
||||
#include <QtGui/QtGui>
|
||||
|
||||
+9
-3
@@ -7,10 +7,16 @@
|
||||
extern "C" {
|
||||
#include "hack.h"
|
||||
}
|
||||
#undef C
|
||||
#define CTRL(c) (0x1f & (c))
|
||||
|
||||
#include "qt_pre.h"
|
||||
#include <QtGui/QtGui>
|
||||
#if QT_VERSION >= 0x060000
|
||||
#include <QtGui/QShortcut>
|
||||
#else
|
||||
#include <QtWidgets/QShortcut>
|
||||
#endif
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QtWidgets/QtWidgets>
|
||||
@@ -856,8 +862,8 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
|
||||
#endif
|
||||
|
||||
int x=0,y=0;
|
||||
int w=QApplication::desktop()->width()-10; // XXX arbitrary extra space for frame
|
||||
int h=QApplication::desktop()->height()-50;
|
||||
int w=screen()->size().width()-10; // XXX arbitrary extra space for frame
|
||||
int h=screen()->size().height()-50;
|
||||
|
||||
int maxwn;
|
||||
int maxhn;
|
||||
@@ -902,7 +908,7 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
|
||||
// all other control characters go through NetHackQtBind::notify()
|
||||
void NetHackQtMainWindow::CtrlV()
|
||||
{
|
||||
static const char cV[] = { C('V'), '\0' };
|
||||
static const char cV[] = { CTRL('V'), '\0' };
|
||||
doKeys(cV);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
extern "C" {
|
||||
#include "hack.h"
|
||||
}
|
||||
#undef C
|
||||
|
||||
#include "qt_pre.h"
|
||||
#include <QtGui/QtGui>
|
||||
|
||||
+2
-1
@@ -28,6 +28,7 @@
|
||||
extern "C" {
|
||||
#include "hack.h"
|
||||
}
|
||||
#undef C
|
||||
|
||||
#include "qt_pre.h"
|
||||
#include <QtGui/QtGui>
|
||||
@@ -1132,7 +1133,7 @@ void NetHackQtTextWindow::Display(bool block UNUSED)
|
||||
search.show();
|
||||
rip.hide();
|
||||
}
|
||||
int mh = QApplication::desktop()->height()*3/5;
|
||||
int mh = screen()->size().height()*3/5;
|
||||
if ( (qt_compact_mode && lines->TotalHeight() > mh) || use_rip ) {
|
||||
// big, so make it fill
|
||||
showMaximized();
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
extern "C" {
|
||||
#include "hack.h"
|
||||
}
|
||||
#undef C
|
||||
|
||||
#include "qt_pre.h"
|
||||
#include <QtGui/QtGui>
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
extern "C" {
|
||||
#include "hack.h"
|
||||
}
|
||||
#undef C
|
||||
|
||||
#include "qt_pre.h"
|
||||
#include <QtGui/QtGui>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
extern "C" {
|
||||
#include "hack.h"
|
||||
}
|
||||
#undef C
|
||||
|
||||
#include "qt_pre.h"
|
||||
#include <QtGui/QtGui>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
extern "C" {
|
||||
#include "hack.h"
|
||||
}
|
||||
#undef C
|
||||
|
||||
#include "qt_pre.h"
|
||||
#include <QtGui/QtGui>
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
extern "C" {
|
||||
#include "hack.h"
|
||||
}
|
||||
#undef C
|
||||
|
||||
#include "qt_pre.h"
|
||||
#include <QtGui/QtGui>
|
||||
@@ -557,7 +558,9 @@ QHBoxLayout *NetHackQtStatusWindow::InitHitpointBar()
|
||||
|
||||
QHBoxLayout *hpbar = new QHBoxLayout;
|
||||
hpbar->setSpacing(0);
|
||||
#if QT_VERSION < 0x060000
|
||||
hpbar->setMargin(0);
|
||||
#endif
|
||||
hpbar->addWidget(&hpbar_health);
|
||||
hpbar->setAlignment(&hpbar_health, Qt::AlignLeft);
|
||||
hpbar->addWidget(&hpbar_injury);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
extern "C" {
|
||||
#include "hack.h"
|
||||
}
|
||||
#undef C
|
||||
|
||||
#include "qt_pre.h"
|
||||
#include <QtGui/QtGui>
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
extern "C" {
|
||||
#include "hack.h"
|
||||
}
|
||||
#undef C
|
||||
|
||||
#include "qt_pre.h"
|
||||
#include <QtGui/QtGui>
|
||||
|
||||
+4
-3
@@ -49,6 +49,7 @@
|
||||
extern "C" {
|
||||
#include "hack.h"
|
||||
}
|
||||
#undef C
|
||||
|
||||
#include "qt_pre.h"
|
||||
#include <QtGui/QtGui>
|
||||
@@ -78,10 +79,10 @@ namespace nethack_qt_ {
|
||||
void
|
||||
centerOnMain(QWidget *w)
|
||||
{
|
||||
QPoint p(0, 0);
|
||||
QWidget *m = NetHackQtBind::mainWidget();
|
||||
if (!m)
|
||||
m = qApp->desktop();
|
||||
QPoint p = m->mapToGlobal(QPoint(0, 0));
|
||||
if (m)
|
||||
p = m->mapToGlobal(p);
|
||||
w->move(p.x() + m->width() / 2 - w->width() / 2,
|
||||
p.y() + m->height() / 2 - w->height() / 2);
|
||||
}
|
||||
|
||||
+2
-1
@@ -77,6 +77,7 @@ extern "C" {
|
||||
#include "hack.h"
|
||||
#include "func_tab.h"
|
||||
}
|
||||
#undef C
|
||||
|
||||
#include "qt_pre.h"
|
||||
#include <QtGui/QtGui>
|
||||
@@ -544,7 +545,7 @@ void NetHackQtExtCmdRequestor::keyPressEvent(QKeyEvent *event)
|
||||
// <return> or <space> without a pending exact match; cancel
|
||||
reject();
|
||||
} else if (matches >= 2
|
||||
|| promptstr.midRef(1, len) == rest.leftRef(len)) {
|
||||
|| promptstr.mid(1, len) == rest.left(len)) {
|
||||
// update the text-so-far
|
||||
prompt->setText(promptstr);
|
||||
} else if (saveexactmatchindx != xcmdNoMatch) {
|
||||
|
||||
+3
-2
@@ -7,6 +7,7 @@
|
||||
extern "C" {
|
||||
#include "hack.h"
|
||||
}
|
||||
#undef C
|
||||
|
||||
#include "qt_pre.h"
|
||||
#include <QtGui/QtGui>
|
||||
@@ -96,7 +97,7 @@ char NetHackQtYnDialog::Exec()
|
||||
if ( question[c] == '-' ) {
|
||||
from = question[c - 1].cell();
|
||||
} else if ( from != 0 ) {
|
||||
for (unsigned f=from+1; f<=question[c]; f++)
|
||||
for (unsigned f=from+1; QChar(f)<=question[c]; f++)
|
||||
ch.append(QChar(f));
|
||||
from = 0;
|
||||
} else {
|
||||
@@ -259,7 +260,7 @@ char NetHackQtYnDialog::Exec()
|
||||
// two consecutive ampersands are needed to display
|
||||
// one in a button label; first check whether caller
|
||||
// has already done that, skip this one if so
|
||||
if (i > 0 && ch[i - 1].cell() == QChar('&'))
|
||||
if (i > 0 && ch[i - 1].cell() == '&')
|
||||
continue; // next i
|
||||
button_name = "&&";
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user