Qt splash code
Move the handling for the Qt interface's splash window into its own routine to unclutter the constructor for QtBind. Also, don't load nhsplash.xpm if OPTIONS=!splash has been specified.
This commit is contained in:
+38
-30
@@ -77,8 +77,42 @@ NetHackQtBind::NetHackQtBind(int& argc, char** argv) :
|
|||||||
QApplication(argc,argv)
|
QApplication(argc,argv)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
QPixmap pm("nhsplash.xpm");
|
splash = 0;
|
||||||
if ( iflags.wc_splash_screen && !pm.isNull() ) {
|
if (iflags.wc_splash_screen)
|
||||||
|
NetHackQtBind::qt_Splash(); // show something while starting up
|
||||||
|
|
||||||
|
// these used to be in MainWindow but we want them before QtSettings
|
||||||
|
// which we want before MainWindow...
|
||||||
|
QCoreApplication::setOrganizationName("The NetHack DevTeam");
|
||||||
|
QCoreApplication::setOrganizationDomain("nethack.org");
|
||||||
|
QCoreApplication::setApplicationName("NetHack-Qt"); // Qt NetHack
|
||||||
|
{
|
||||||
|
char cvers[BUFSZ];
|
||||||
|
QString qvers = QString(::version_string(cvers));
|
||||||
|
QCoreApplication::setApplicationVersion(qvers);
|
||||||
|
}
|
||||||
|
#ifdef MACOS
|
||||||
|
/* without this, neither control+x nor option+x do anything;
|
||||||
|
with it, control+x is ^X and option+x still does nothing */
|
||||||
|
QCoreApplication::setAttribute(Qt::AA_MacDontSwapCtrlAndMeta);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
qt_settings = new NetHackQtSettings(); /*(main->width(),main->height());*/
|
||||||
|
|
||||||
|
main = new NetHackQtMainWindow(keybuffer);
|
||||||
|
connect(qApp, SIGNAL(lastWindowClosed()), qApp, SLOT(quit()));
|
||||||
|
msgs_strings = new QStringList();
|
||||||
|
msgs_initd = false;
|
||||||
|
msgs_saved = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// before the game windows have been rendered, display a small, centered
|
||||||
|
// window showing a red dragon with caption "Loading..."
|
||||||
|
void
|
||||||
|
NetHackQtBind::qt_Splash()
|
||||||
|
{
|
||||||
|
QPixmap pm("nhsplash.xpm"); // load splash image from a file in HACKDIR
|
||||||
|
if (!pm.isNull()) {
|
||||||
splash = new QFrame(NULL, (Qt::FramelessWindowHint
|
splash = new QFrame(NULL, (Qt::FramelessWindowHint
|
||||||
| Qt::X11BypassWindowManagerHint
|
| Qt::X11BypassWindowManagerHint
|
||||||
| Qt::WindowStaysOnTopHint));
|
| Qt::WindowStaysOnTopHint));
|
||||||
@@ -90,10 +124,9 @@ NetHackQtBind::NetHackQtBind(int& argc, char** argv) :
|
|||||||
QLabel *capt = new QLabel("Loading...", splash);
|
QLabel *capt = new QLabel("Loading...", splash);
|
||||||
vb->addWidget(capt);
|
vb->addWidget(capt);
|
||||||
capt->setAlignment(Qt::AlignCenter);
|
capt->setAlignment(Qt::AlignCenter);
|
||||||
if ( !pm.isNull() ) {
|
|
||||||
lsplash->setFixedSize(pm.size());
|
lsplash->setFixedSize(pm.size());
|
||||||
lsplash->setMask(QBitmap(pm));
|
lsplash->setMask(QBitmap(pm));
|
||||||
}
|
|
||||||
#if QT_VERSION < 0x060000
|
#if QT_VERSION < 0x060000
|
||||||
QSize screensize = QApplication::desktop()->size();
|
QSize screensize = QApplication::desktop()->size();
|
||||||
#else
|
#else
|
||||||
@@ -116,34 +149,9 @@ NetHackQtBind::NetHackQtBind(int& argc, char** argv) :
|
|||||||
lsplash->repaint();
|
lsplash->repaint();
|
||||||
capt->repaint();
|
capt->repaint();
|
||||||
qApp->processEvents();
|
qApp->processEvents();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
splash = 0;
|
splash = 0; // caller has alrady done this...
|
||||||
}
|
}
|
||||||
|
|
||||||
// these used to be in MainWindow but we want them before QtSettings
|
|
||||||
// which we want before MainWindow...
|
|
||||||
QCoreApplication::setOrganizationName("The NetHack DevTeam");
|
|
||||||
QCoreApplication::setOrganizationDomain("nethack.org");
|
|
||||||
QCoreApplication::setApplicationName("NetHack-Qt"); // Qt NetHack
|
|
||||||
{
|
|
||||||
char cvers[BUFSZ];
|
|
||||||
QString qvers = version_string(cvers);
|
|
||||||
QCoreApplication::setApplicationVersion(qvers);
|
|
||||||
}
|
|
||||||
#ifdef MACOS
|
|
||||||
/* without this, neither control+x nor option+x do anything;
|
|
||||||
with it, control+x is ^X and option+x still does nothing */
|
|
||||||
QCoreApplication::setAttribute(Qt::AA_MacDontSwapCtrlAndMeta);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
qt_settings = new NetHackQtSettings(); /*(main->width(),main->height());*/
|
|
||||||
|
|
||||||
main = new NetHackQtMainWindow(keybuffer);
|
|
||||||
connect(qApp, SIGNAL(lastWindowClosed()), qApp, SLOT(quit()));
|
|
||||||
msgs_strings = new QStringList();
|
|
||||||
msgs_initd = false;
|
|
||||||
msgs_saved = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetHackQtBind::qt_init_nhwindows(int* argc, char** argv)
|
void NetHackQtBind::qt_init_nhwindows(int* argc, char** argv)
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ private:
|
|||||||
static NetHackQtMainWindow* main;
|
static NetHackQtMainWindow* main;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static void qt_Splash();
|
||||||
static void qt_init_nhwindows(int* argc, char** argv);
|
static void qt_init_nhwindows(int* argc, char** argv);
|
||||||
static void qt_player_selection();
|
static void qt_player_selection();
|
||||||
static void qt_askname();
|
static void qt_askname();
|
||||||
|
|||||||
Reference in New Issue
Block a user