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:
@@ -77,49 +77,9 @@ NetHackQtBind::NetHackQtBind(int& argc, char** argv) :
|
||||
QApplication(argc,argv)
|
||||
#endif
|
||||
{
|
||||
QPixmap pm("nhsplash.xpm");
|
||||
if ( iflags.wc_splash_screen && !pm.isNull() ) {
|
||||
splash = new QFrame(NULL, (Qt::FramelessWindowHint
|
||||
| Qt::X11BypassWindowManagerHint
|
||||
| Qt::WindowStaysOnTopHint));
|
||||
QVBoxLayout *vb = new QVBoxLayout(splash);
|
||||
QLabel *lsplash = new QLabel(splash);
|
||||
vb->addWidget(lsplash);
|
||||
lsplash->setAlignment(Qt::AlignCenter);
|
||||
lsplash->setPixmap(pm);
|
||||
QLabel* capt = new QLabel("Loading...",splash);
|
||||
vb->addWidget(capt);
|
||||
capt->setAlignment(Qt::AlignCenter);
|
||||
if ( !pm.isNull() ) {
|
||||
lsplash->setFixedSize(pm.size());
|
||||
lsplash->setMask(QBitmap(pm));
|
||||
}
|
||||
#if QT_VERSION < 0x060000
|
||||
QSize screensize = QApplication::desktop()->size();
|
||||
#else
|
||||
QSize screensize = splash->screen()->size();
|
||||
#endif
|
||||
splash->move((screensize.width()-pm.width())/2,
|
||||
(screensize.height()-pm.height())/2);
|
||||
//splash->setGeometry(0,0,100,100);
|
||||
if ( qt_compact_mode ) {
|
||||
splash->showMaximized();
|
||||
} else {
|
||||
splash->setFrameStyle(QFrame::WinPanel|QFrame::Raised);
|
||||
splash->setLineWidth(10);
|
||||
splash->adjustSize();
|
||||
splash->show();
|
||||
}
|
||||
|
||||
// force content refresh outside event loop
|
||||
splash->repaint();
|
||||
lsplash->repaint();
|
||||
capt->repaint();
|
||||
qApp->processEvents();
|
||||
|
||||
} else {
|
||||
splash = 0;
|
||||
}
|
||||
splash = 0;
|
||||
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...
|
||||
@@ -128,7 +88,7 @@ NetHackQtBind::NetHackQtBind(int& argc, char** argv) :
|
||||
QCoreApplication::setApplicationName("NetHack-Qt"); // Qt NetHack
|
||||
{
|
||||
char cvers[BUFSZ];
|
||||
QString qvers = version_string(cvers);
|
||||
QString qvers = QString(::version_string(cvers));
|
||||
QCoreApplication::setApplicationVersion(qvers);
|
||||
}
|
||||
#ifdef MACOS
|
||||
@@ -146,6 +106,54 @@ NetHackQtBind::NetHackQtBind(int& argc, char** argv) :
|
||||
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
|
||||
| Qt::X11BypassWindowManagerHint
|
||||
| Qt::WindowStaysOnTopHint));
|
||||
QVBoxLayout *vb = new QVBoxLayout(splash);
|
||||
QLabel *lsplash = new QLabel(splash);
|
||||
vb->addWidget(lsplash);
|
||||
lsplash->setAlignment(Qt::AlignCenter);
|
||||
lsplash->setPixmap(pm);
|
||||
QLabel *capt = new QLabel("Loading...", splash);
|
||||
vb->addWidget(capt);
|
||||
capt->setAlignment(Qt::AlignCenter);
|
||||
lsplash->setFixedSize(pm.size());
|
||||
lsplash->setMask(QBitmap(pm));
|
||||
|
||||
#if QT_VERSION < 0x060000
|
||||
QSize screensize = QApplication::desktop()->size();
|
||||
#else
|
||||
QSize screensize = splash->screen()->size();
|
||||
#endif
|
||||
splash->move((screensize.width() - pm.width()) / 2,
|
||||
(screensize.height() - pm.height()) / 2);
|
||||
//splash->setGeometry(0,0,100,100);
|
||||
if (qt_compact_mode) {
|
||||
splash->showMaximized();
|
||||
} else {
|
||||
splash->setFrameStyle(QFrame::WinPanel | QFrame::Raised);
|
||||
splash->setLineWidth(10);
|
||||
splash->adjustSize();
|
||||
splash->show();
|
||||
}
|
||||
|
||||
// force content refresh outside event loop
|
||||
splash->repaint();
|
||||
lsplash->repaint();
|
||||
capt->repaint();
|
||||
qApp->processEvents();
|
||||
} else {
|
||||
splash = 0; // caller has alrady done this...
|
||||
}
|
||||
}
|
||||
|
||||
void NetHackQtBind::qt_init_nhwindows(int* argc, char** argv)
|
||||
{
|
||||
iflags.menu_tab_sep = true;
|
||||
|
||||
@@ -35,6 +35,7 @@ private:
|
||||
static NetHackQtMainWindow* main;
|
||||
|
||||
public:
|
||||
static void qt_Splash();
|
||||
static void qt_init_nhwindows(int* argc, char** argv);
|
||||
static void qt_player_selection();
|
||||
static void qt_askname();
|
||||
|
||||
Reference in New Issue
Block a user