Commit ee749552 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD] - we now have a splash screen. Very useful if you start openwalnut...

[ADD] - we now have a splash screen. Very useful if you start openwalnut without a shell to see that there actually is starting something.
parent 2cfffdec
...@@ -92,8 +92,9 @@ ...@@ -92,8 +92,9 @@
#include "WMainWindow.h" #include "WMainWindow.h"
#include "WMainWindow.moc" #include "WMainWindow.moc"
WMainWindow::WMainWindow(): WMainWindow::WMainWindow( QSplashScreen* splash ):
QMainWindow(), QMainWindow(),
m_splash( splash ),
m_currentCompatiblesToolbar( NULL ), m_currentCompatiblesToolbar( NULL ),
m_iconManager() m_iconManager()
{ {
...@@ -107,6 +108,8 @@ WMainWindow::~WMainWindow() ...@@ -107,6 +108,8 @@ WMainWindow::~WMainWindow()
void WMainWindow::setupGUI() void WMainWindow::setupGUI()
{ {
wlog::info( "WMainWindow" ) << "Setting up GUI";
///////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Setting setup // Setting setup
///////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
...@@ -248,6 +251,7 @@ void WMainWindow::setupGUI() ...@@ -248,6 +251,7 @@ void WMainWindow::setupGUI()
// NOTE: we abuse the gl widgets first frame event to handle startup news. // NOTE: we abuse the gl widgets first frame event to handle startup news.
connect( m_mainGLWidget.get(), SIGNAL( renderedFirstFrame() ), this, SLOT( handleStartMessages() ) ); connect( m_mainGLWidget.get(), SIGNAL( renderedFirstFrame() ), this, SLOT( handleStartMessages() ) );
connect( m_mainGLWidget.get(), SIGNAL( renderedFirstFrame() ), this, SLOT( closeSplash() ) );
m_permanentToolBar = new WQtToolBar( "Standard Toolbar", this ); m_permanentToolBar = new WQtToolBar( "Standard Toolbar", this );
addToolBar( Qt::TopToolBarArea, m_permanentToolBar ); addToolBar( Qt::TopToolBarArea, m_permanentToolBar );
...@@ -753,7 +757,8 @@ void WMainWindow::openOpenWalnutHelpDialog() ...@@ -753,7 +757,8 @@ void WMainWindow::openOpenWalnutHelpDialog()
layout->addWidget( view ); layout->addWidget( view );
#else #else
QMessageBox::information( this, "Help", QString::fromStdString( "Sorry! Your version of OpenWalnut was not compiled with embedded help. " QMessageBox::information( this, "Help", QString::fromStdString( "Sorry! Your version of OpenWalnut was not compiled with embedded help. "
"To open the help pages, use this link: <a href="+filename+">Help</a>." ) ); "To open the help pages in your browser, use this link: <a href=" +
filename + ">Help</a>." ) );
#endif #endif
} }
...@@ -836,12 +841,18 @@ void WMainWindow::closeEvent( QCloseEvent* e ) ...@@ -836,12 +841,18 @@ void WMainWindow::closeEvent( QCloseEvent* e )
// handle close event // handle close event
if( reallyClose ) if( reallyClose )
{ {
m_splash->show();
m_splash->showMessage( "Shutting down" );
saveWindowState(); saveWindowState();
// signal everybody to shut down properly. // signal everybody to shut down properly.
m_splash->showMessage( "Shutting down kernel. Waiting for modules to finish." );
WKernel::getRunningKernel()->finalize(); WKernel::getRunningKernel()->finalize();
// now nobody acesses the osg anymore // now nobody acesses the osg anymore
m_splash->showMessage( "Shutting down GUI." );
// clean up gl widgets // clean up gl widgets
m_mainGLWidget->close(); m_mainGLWidget->close();
if( m_navAxial ) if( m_navAxial )
...@@ -1235,3 +1246,13 @@ void WMainWindow::dragEnterEvent( QDragEnterEvent *event ) ...@@ -1235,3 +1246,13 @@ void WMainWindow::dragEnterEvent( QDragEnterEvent *event )
QMainWindow::dragEnterEvent( event ); QMainWindow::dragEnterEvent( event );
} }
void WMainWindow::closeSplash()
{
m_splash->finish( this );
}
QSplashScreen* WMainWindow::getSplash() const
{
return m_splash;
}
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include <QtGui/QMainWindow> #include <QtGui/QMainWindow>
#include <QtGui/QSplashScreen>
#include <QtCore/QSettings> #include <QtCore/QSettings>
#include "WIconManager.h" #include "WIconManager.h"
...@@ -66,9 +67,11 @@ class WMainWindow : public QMainWindow ...@@ -66,9 +67,11 @@ class WMainWindow : public QMainWindow
public: public:
/** /**
* Constructor of the main window * Constructor of the main window.
*
* \param splash the splash screen currently show. This windows later handles its close stuff.
*/ */
WMainWindow(); explicit WMainWindow( QSplashScreen* splash );
/** /**
* Destructor. Stores window state. * Destructor. Stores window state.
...@@ -161,6 +164,13 @@ public: ...@@ -161,6 +164,13 @@ public:
*/ */
void restoreMainGLWidgetSize(); void restoreMainGLWidgetSize();
/**
* Get the current splash screen
*
* \return the splash screen. Might be closed.
*/
QSplashScreen* getSplash() const;
protected: protected:
/** /**
* Setup the GUI by handling special modules. NavSlices for example setup several toolbar buttons. * Setup the GUI by handling special modules. NavSlices for example setup several toolbar buttons.
...@@ -322,6 +332,11 @@ public slots: ...@@ -322,6 +332,11 @@ public slots:
void handleLogLevelUpdate( unsigned int logLevel ); void handleLogLevelUpdate( unsigned int logLevel );
private: private:
/**
* The splash screen object opened on startup.
*/
QSplashScreen* m_splash;
/** /**
* The currently set compatibles toolbar * The currently set compatibles toolbar
*/ */
...@@ -396,6 +411,11 @@ private slots: ...@@ -396,6 +411,11 @@ private slots:
* Shows startup info messages * Shows startup info messages
*/ */
void handleStartMessages(); void handleStartMessages();
/**
* Finally closes the splash screen.
*/
void closeSplash();
}; };
#endif // WMAINWINDOW_H #endif // WMAINWINDOW_H
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <QtGui/QApplication> #include <QtGui/QApplication>
#include <QtGui/QSplashScreen>
#include <QtGui/QFileDialog> #include <QtGui/QFileDialog>
#include <QtCore/QDir> #include <QtCore/QDir>
#include <QtCore/QSettings> #include <QtCore/QSettings>
...@@ -135,6 +136,7 @@ int WQt4Gui::run() ...@@ -135,6 +136,7 @@ int WQt4Gui::run()
XInitThreads(); XInitThreads();
#endif #endif
m_splash = NULL;
// init logger // init logger
m_loggerConnection = WLogger::getLogger()->subscribeSignal( WLogger::AddLog, boost::bind( &WQt4Gui::slotAddLog, this, _1 ) ); m_loggerConnection = WLogger::getLogger()->subscribeSignal( WLogger::AddLog, boost::bind( &WQt4Gui::slotAddLog, this, _1 ) );
...@@ -156,7 +158,6 @@ int WQt4Gui::run() ...@@ -156,7 +158,6 @@ int WQt4Gui::run()
// and sets the paths according to Apple's guidelines inside the bundle // and sets the paths according to Apple's guidelines inside the bundle
if( QApplication::applicationDirPath().endsWith( "/MacOS" ) ) if( QApplication::applicationDirPath().endsWith( "/MacOS" ) )
{ {
std::cout << "OSX bundle" << std::endl;
// we are in a bundle // we are in a bundle
// TODO(mario): apply default OSX behavior of using $HOME/Library/OpenWalnut ? // TODO(mario): apply default OSX behavior of using $HOME/Library/OpenWalnut ?
WPathHelper::getPathHelper()->setBasePathsOSXBundle( walnutBin, boost::filesystem::path( QDir::homePath().toStdString() ) / ".OpenWalnut" ); WPathHelper::getPathHelper()->setBasePathsOSXBundle( walnutBin, boost::filesystem::path( QDir::homePath().toStdString() ) / ".OpenWalnut" );
...@@ -170,6 +171,11 @@ int WQt4Gui::run() ...@@ -170,6 +171,11 @@ int WQt4Gui::run()
// on all other platforms, get the home directory form Qt and the path from the application binary location // on all other platforms, get the home directory form Qt and the path from the application binary location
WPathHelper::getPathHelper()->setBasePaths( walnutBin, boost::filesystem::path( QDir::homePath().toStdString() ) / ".OpenWalnut" ); WPathHelper::getPathHelper()->setBasePaths( walnutBin, boost::filesystem::path( QDir::homePath().toStdString() ) / ".OpenWalnut" );
#endif #endif
QPixmap splashPixmap( QString::fromStdString( ( WPathHelper::getPathHelper()->getSharePath() / "qt4gui/splash.png" ).string() ) );
m_splash = new QSplashScreen( splashPixmap );
m_splash->show();
// with the correct paths, we can load the settings // with the correct paths, we can load the settings
m_settings = new QSettings( QString::fromStdString( ( WPathHelper::getHomePath() / "config.qt4gui" ).string() ), QSettings::IniFormat ); m_settings = new QSettings( QString::fromStdString( ( WPathHelper::getHomePath() / "config.qt4gui" ).string() ), QSettings::IniFormat );
...@@ -230,7 +236,7 @@ int WQt4Gui::run() ...@@ -230,7 +236,7 @@ int WQt4Gui::run()
m_kernel->getRoiManager()->addRemoveNotifier( removeRoiSignal ); m_kernel->getRoiManager()->addRemoveNotifier( removeRoiSignal );
// create the window // create the window
m_mainWindow = new WMainWindow(); m_mainWindow = new WMainWindow( m_splash );
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
//TODO(mario): this should run on all platforms but crashes at least on Linux right now. Therefore, I only use it on OSX //TODO(mario): this should run on all platforms but crashes at least on Linux right now. Therefore, I only use it on OSX
appl.setMyMainWidget( m_mainWindow ); appl.setMyMainWidget( m_mainWindow );
...@@ -270,7 +276,7 @@ void WQt4Gui::slotUpdateTextureSorter() ...@@ -270,7 +276,7 @@ void WQt4Gui::slotUpdateTextureSorter()
void WQt4Gui::slotAddLog( const WLogEntry& /*entry*/ ) void WQt4Gui::slotAddLog( const WLogEntry& /*entry*/ )
{ {
// TODO(rfrohl): create a new event for this and insert it into event queue // emit event?
} }
void WQt4Gui::slotAddDatasetOrModuleToTree( boost::shared_ptr< WModule > module ) void WQt4Gui::slotAddDatasetOrModuleToTree( boost::shared_ptr< WModule > module )
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <QtCore/QSettings> #include <QtCore/QSettings>
#include <QtCore/QMutex> #include <QtCore/QMutex>
#include <QtGui/QSplashScreen>
#include "core/graphicsEngine/WROI.h" #include "core/graphicsEngine/WROI.h"
#include "core/graphicsEngine/WGraphicsEngine.h" #include "core/graphicsEngine/WGraphicsEngine.h"
...@@ -253,6 +254,11 @@ private: ...@@ -253,6 +254,11 @@ private:
* \note can be called from an arbitrary thread. Protected by m_deferredLoadMutex. * \note can be called from an arbitrary thread. Protected by m_deferredLoadMutex.
*/ */
void deferredLoad(); void deferredLoad();
/**
* The splash screen.
*/
QSplashScreen* m_splash;
}; };
#endif // WQT4GUI_H #endif // WQT4GUI_H
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment