Made custom Qt GUI splashscreen that fades out when initialization is finished. Showing splash screen at startup is now a configuration parameter and defaults to off. Can be turned on in GUI config dialog.
This commit is contained in:
parent
47098b2b8c
commit
cb5bb3446d
|
@ -513,6 +513,7 @@ set(SRC_DRIVERS_SDL
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleVideoConf.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleVideoConf.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleSoundConf.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleSoundConf.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/iNesHeaderEditor.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/iNesHeaderEditor.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/SplashScreen.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TraceLogger.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/TraceLogger.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/AboutWindow.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/AboutWindow.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/fceuWrapper.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/fceuWrapper.cpp
|
||||||
|
|
|
@ -63,6 +63,7 @@ GuiConfDialog_t::GuiConfDialog_t(QWidget *parent)
|
||||||
QGroupBox *frame, *qssFrame;
|
QGroupBox *frame, *qssFrame;
|
||||||
QFrame *hline;
|
QFrame *hline;
|
||||||
std::string qssFile, qpalFile;
|
std::string qssFile, qpalFile;
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
//resize( 512, 600 );
|
//resize( 512, 600 );
|
||||||
//printf("Style: %s \n", style()->objectName().toStdString().c_str() );
|
//printf("Style: %s \n", style()->objectName().toStdString().c_str() );
|
||||||
|
@ -128,16 +129,19 @@ GuiConfDialog_t::GuiConfDialog_t(QWidget *parent)
|
||||||
useNativeMenuBar = new QCheckBox(tr("Use Native OS Menu Bar"));
|
useNativeMenuBar = new QCheckBox(tr("Use Native OS Menu Bar"));
|
||||||
pauseOnMenuAccess = new QCheckBox(tr("Pause On Main Menu Access"));
|
pauseOnMenuAccess = new QCheckBox(tr("Pause On Main Menu Access"));
|
||||||
ctxMenuEnable = new QCheckBox(tr("Context Menu Enable"));
|
ctxMenuEnable = new QCheckBox(tr("Context Menu Enable"));
|
||||||
|
showSplashScreen = new QCheckBox(tr("Show Splash Screen at Startup"));
|
||||||
|
|
||||||
useNativeFileDialog->setChecked(useNativeFileDialogVal);
|
useNativeFileDialog->setChecked(useNativeFileDialogVal);
|
||||||
useNativeMenuBar->setChecked(useNativeMenuBarVal);
|
useNativeMenuBar->setChecked(useNativeMenuBarVal);
|
||||||
pauseOnMenuAccess->setChecked(pauseOnMenuAccessVal);
|
pauseOnMenuAccess->setChecked(pauseOnMenuAccessVal);
|
||||||
ctxMenuEnable->setChecked(contextMenuEnable);
|
ctxMenuEnable->setChecked(contextMenuEnable);
|
||||||
|
showSplashScreen->setChecked( settings.value("mainWindow/showSplashScreen", false).toBool() );
|
||||||
|
|
||||||
connect(useNativeFileDialog, SIGNAL(stateChanged(int)), this, SLOT(useNativeFileDialogChanged(int)));
|
connect(useNativeFileDialog, SIGNAL(stateChanged(int)), this, SLOT(useNativeFileDialogChanged(int)));
|
||||||
connect(useNativeMenuBar , SIGNAL(stateChanged(int)), this, SLOT(useNativeMenuBarChanged(int)));
|
connect(useNativeMenuBar , SIGNAL(stateChanged(int)), this, SLOT(useNativeMenuBarChanged(int)));
|
||||||
connect(pauseOnMenuAccess , SIGNAL(stateChanged(int)), this, SLOT(pauseOnMenuAccessChanged(int)));
|
connect(pauseOnMenuAccess , SIGNAL(stateChanged(int)), this, SLOT(pauseOnMenuAccessChanged(int)));
|
||||||
connect(ctxMenuEnable , SIGNAL(stateChanged(int)), this, SLOT(contextMenuEnableChanged(int)));
|
connect(ctxMenuEnable , SIGNAL(stateChanged(int)), this, SLOT(contextMenuEnableChanged(int)));
|
||||||
|
connect(showSplashScreen , SIGNAL(stateChanged(int)), this, SLOT(showSplashScreenChanged(int)));
|
||||||
|
|
||||||
styleComboBox = new QComboBox();
|
styleComboBox = new QComboBox();
|
||||||
|
|
||||||
|
@ -239,6 +243,7 @@ GuiConfDialog_t::GuiConfDialog_t(QWidget *parent)
|
||||||
vbox1->addWidget(useNativeMenuBar, 1);
|
vbox1->addWidget(useNativeMenuBar, 1);
|
||||||
vbox1->addWidget(pauseOnMenuAccess, 1);
|
vbox1->addWidget(pauseOnMenuAccess, 1);
|
||||||
vbox1->addWidget(ctxMenuEnable, 1);
|
vbox1->addWidget(ctxMenuEnable, 1);
|
||||||
|
vbox1->addWidget(showSplashScreen, 1);
|
||||||
vbox1->addStretch(10);
|
vbox1->addStretch(10);
|
||||||
|
|
||||||
closeButton = new QPushButton( tr("Close") );
|
closeButton = new QPushButton( tr("Close") );
|
||||||
|
@ -310,6 +315,15 @@ void GuiConfDialog_t::contextMenuEnableChanged(int state)
|
||||||
consoleWindow->setContextMenuEnable( value );
|
consoleWindow->setContextMenuEnable( value );
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
void GuiConfDialog_t::showSplashScreenChanged(int state)
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
bool value = (state == Qt::Unchecked) ? 0 : 1;
|
||||||
|
|
||||||
|
settings.setValue("mainWindow/showSplashScreen", value );
|
||||||
|
settings.sync();
|
||||||
|
}
|
||||||
|
//----------------------------------------------------
|
||||||
void GuiConfDialog_t::useCustomStyleChanged(int state)
|
void GuiConfDialog_t::useCustomStyleChanged(int state)
|
||||||
{
|
{
|
||||||
int value = (state == Qt::Unchecked) ? 0 : 1;
|
int value = (state == Qt::Unchecked) ? 0 : 1;
|
||||||
|
|
|
@ -144,6 +144,7 @@ protected:
|
||||||
QCheckBox *useNativeMenuBar;
|
QCheckBox *useNativeMenuBar;
|
||||||
QCheckBox *pauseOnMenuAccess;
|
QCheckBox *pauseOnMenuAccess;
|
||||||
QCheckBox *ctxMenuEnable;
|
QCheckBox *ctxMenuEnable;
|
||||||
|
QCheckBox *showSplashScreen;
|
||||||
QCheckBox *useCustomStyle;
|
QCheckBox *useCustomStyle;
|
||||||
QCheckBox *useCustomPalette;
|
QCheckBox *useCustomPalette;
|
||||||
QComboBox *styleComboBox;
|
QComboBox *styleComboBox;
|
||||||
|
@ -158,6 +159,7 @@ private slots:
|
||||||
void useNativeMenuBarChanged(int v);
|
void useNativeMenuBarChanged(int v);
|
||||||
void pauseOnMenuAccessChanged(int v);
|
void pauseOnMenuAccessChanged(int v);
|
||||||
void contextMenuEnableChanged(int v);
|
void contextMenuEnableChanged(int v);
|
||||||
|
void showSplashScreenChanged(int v);
|
||||||
void useCustomQPaletteChanged(int v);
|
void useCustomQPaletteChanged(int v);
|
||||||
void useCustomStyleChanged(int v);
|
void useCustomStyleChanged(int v);
|
||||||
void styleChanged(int index);
|
void styleChanged(int index);
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
// SplashScreen.cpp
|
||||||
|
#include "Qt/SplashScreen.h"
|
||||||
|
|
||||||
|
fceuSplashScreen::fceuSplashScreen(void)
|
||||||
|
: QSplashScreen( QPixmap(":/fceux1.png") )
|
||||||
|
{
|
||||||
|
|
||||||
|
alpha = 255;
|
||||||
|
|
||||||
|
showMessage("Initializing GUI...");
|
||||||
|
updateTimer = new QTimer(this);
|
||||||
|
|
||||||
|
connect(updateTimer, &QTimer::timeout, this, &fceuSplashScreen::periodicUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
fceuSplashScreen::~fceuSplashScreen(void)
|
||||||
|
{
|
||||||
|
//printf("SplashScreen Detroyed\n");
|
||||||
|
updateTimer->stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void fceuSplashScreen::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
//printf("Splash CloseEvent\n");
|
||||||
|
|
||||||
|
if ( alpha > 0 )
|
||||||
|
{
|
||||||
|
if ( !updateTimer->isActive() )
|
||||||
|
{
|
||||||
|
updateTimer->start(33);
|
||||||
|
}
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
updateTimer->stop();
|
||||||
|
QSplashScreen::closeEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void fceuSplashScreen::periodicUpdate(void)
|
||||||
|
{
|
||||||
|
if ( alpha > 0 )
|
||||||
|
{
|
||||||
|
alpha -= 20;
|
||||||
|
|
||||||
|
if ( alpha < 0 )
|
||||||
|
{
|
||||||
|
alpha = 0;
|
||||||
|
}
|
||||||
|
setWindowOpacity( (double)alpha / 255.0 );
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
close();
|
||||||
|
deleteLater();
|
||||||
|
updateTimer->stop();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
// SplashScreen.h
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QPixmap>
|
||||||
|
#include <QCloseEvent>
|
||||||
|
#include <QSplashScreen>
|
||||||
|
|
||||||
|
class fceuSplashScreen : public QSplashScreen
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
fceuSplashScreen(void);
|
||||||
|
~fceuSplashScreen(void);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QTimer *updateTimer;
|
||||||
|
int alpha;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void periodicUpdate(void);
|
||||||
|
|
||||||
|
};
|
|
@ -21,10 +21,12 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QSplashScreen>
|
#include <QSplashScreen>
|
||||||
|
#include <QSettings>
|
||||||
//#include <QProxyStyle>
|
//#include <QProxyStyle>
|
||||||
|
|
||||||
#include "Qt/ConsoleWindow.h"
|
#include "Qt/ConsoleWindow.h"
|
||||||
#include "Qt/fceuWrapper.h"
|
#include "Qt/fceuWrapper.h"
|
||||||
|
#include "Qt/SplashScreen.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <QtPlatformHeaders/QWindowsWindowFunctions>
|
#include <QtPlatformHeaders/QWindowsWindowFunctions>
|
||||||
|
@ -81,28 +83,35 @@ static void MessageOutput(QtMsgType type, const QMessageLogContext &context, con
|
||||||
|
|
||||||
#undef main // undef main in case SDL_Main
|
#undef main // undef main in case SDL_Main
|
||||||
|
|
||||||
//#define SPLASH_SCREEN_ENABLE
|
static bool showSplashScreen(void)
|
||||||
|
{
|
||||||
|
bool show = false;
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
show = settings.value("mainWindow/showSplashScreen", false).toBool();
|
||||||
|
|
||||||
|
return show;
|
||||||
|
}
|
||||||
|
|
||||||
int main( int argc, char *argv[] )
|
int main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
qInstallMessageHandler(MessageOutput);
|
qInstallMessageHandler(MessageOutput);
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
#ifdef SPLASH_SCREEN_ENABLE
|
|
||||||
QSplashScreen *splash;
|
|
||||||
QPixmap pixmap(":/fceux1.png");
|
|
||||||
|
|
||||||
splash = new QSplashScreen( pixmap );
|
QCoreApplication::setOrganizationName("TasEmulators");
|
||||||
splash->show();
|
QCoreApplication::setOrganizationDomain("TasEmulators.org");
|
||||||
|
|
||||||
splash->showMessage("Initializing GUI...");
|
|
||||||
app.processEvents();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QCoreApplication::setOrganizationName("TasVideos");
|
|
||||||
QCoreApplication::setOrganizationDomain("TasVideos.org");
|
|
||||||
QCoreApplication::setApplicationName("fceux");
|
QCoreApplication::setApplicationName("fceux");
|
||||||
|
|
||||||
|
fceuSplashScreen *splash = NULL;
|
||||||
|
|
||||||
|
if ( showSplashScreen() )
|
||||||
|
{
|
||||||
|
splash = new fceuSplashScreen();
|
||||||
|
splash->show();
|
||||||
|
app.processEvents();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if (AttachConsole(ATTACH_PARENT_PROCESS))
|
if (AttachConsole(ATTACH_PARENT_PROCESS))
|
||||||
{
|
{
|
||||||
|
@ -148,11 +157,11 @@ int main( int argc, char *argv[] )
|
||||||
QWindowsWindowFunctions::setHasBorderInFullScreen( consoleWindow->windowHandle(), true);
|
QWindowsWindowFunctions::setHasBorderInFullScreen( consoleWindow->windowHandle(), true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SPLASH_SCREEN_ENABLE
|
if ( splash )
|
||||||
splash->finish( consoleWindow );
|
{
|
||||||
|
splash->finish( consoleWindow );
|
||||||
delete splash;
|
//delete splash; this is handled by Qt event loop
|
||||||
#endif
|
}
|
||||||
|
|
||||||
retval = app.exec();
|
retval = app.exec();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue