Commit ee749552 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[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 @@
#include "WMainWindow.h"
#include "WMainWindow.moc"
WMainWindow::WMainWindow():
WMainWindow::WMainWindow( QSplashScreen* splash ):
QMainWindow(),
m_splash( splash ),
m_currentCompatiblesToolbar( NULL ),
m_iconManager()
{
......@@ -107,6 +108,8 @@ WMainWindow::~WMainWindow()
void WMainWindow::setupGUI()
{
wlog::info( "WMainWindow" ) << "Setting up GUI";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Setting setup
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -248,6 +251,7 @@ void WMainWindow::setupGUI()
// 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( closeSplash() ) );
m_permanentToolBar = new WQtToolBar( "Standard Toolbar", this );
addToolBar( Qt::TopToolBarArea, m_permanentToolBar );
......@@ -753,7 +757,8 @@ void WMainWindow::openOpenWalnutHelpDialog()
layout->addWidget( view );
#else
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
}
......@@ -836,12 +841,18 @@ void WMainWindow::closeEvent( QCloseEvent* e )
// handle close event
if( reallyClose )
{
m_splash->show();
m_splash->showMessage( "Shutting down" );
saveWindowState();
// signal everybody to shut down properly.
m_splash->showMessage( "Shutting down kernel. Waiting for modules to finish." );
WKernel::getRunningKernel()->finalize();
// now nobody acesses the osg anymore
m_splash->showMessage( "Shutting down GUI." );
// clean up gl widgets
m_mainGLWidget->close();
if( m_navAxial )
......@@ -1235,3 +1246,13 @@ void WMainWindow::dragEnterEvent( QDragEnterEvent *event )
QMainWindow::dragEnterEvent( event );
}
void WMainWindow::closeSplash()
{
m_splash->finish( this );
}
QSplashScreen* WMainWindow::getSplash() const
{
return m_splash;
}
......@@ -33,6 +33,7 @@
#include <boost/thread.hpp>
#include <QtGui/QMainWindow>
#include <QtGui/QSplashScreen>
#include <QtCore/QSettings>
#include "WIconManager.h"
......@@ -66,9 +67,11 @@ class WMainWindow : public QMainWindow
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.
......@@ -161,6 +164,13 @@ public:
*/
void restoreMainGLWidgetSize();
/**
* Get the current splash screen
*
* \return the splash screen. Might be closed.
*/
QSplashScreen* getSplash() const;
protected:
/**
* Setup the GUI by handling special modules. NavSlices for example setup several toolbar buttons.
......@@ -322,6 +332,11 @@ public slots:
void handleLogLevelUpdate( unsigned int logLevel );
private:
/**
* The splash screen object opened on startup.
*/
QSplashScreen* m_splash;
/**
* The currently set compatibles toolbar
*/
......@@ -396,6 +411,11 @@ private slots:
* Shows startup info messages
*/
void handleStartMessages();
/**
* Finally closes the splash screen.
*/
void closeSplash();
};
#endif // WMAINWINDOW_H
......@@ -31,6 +31,7 @@
#include <boost/shared_ptr.hpp>
#include <QtGui/QApplication>
#include <QtGui/QSplashScreen>
#include <QtGui/QFileDialog>
#include <QtCore/QDir>
#include <QtCore/QSettings>
......@@ -135,6 +136,7 @@ int WQt4Gui::run()
XInitThreads();
#endif
m_splash = NULL;
// init logger
m_loggerConnection = WLogger::getLogger()->subscribeSignal( WLogger::AddLog, boost::bind( &WQt4Gui::slotAddLog, this, _1 ) );
......@@ -156,7 +158,6 @@ int WQt4Gui::run()
// and sets the paths according to Apple's guidelines inside the bundle
if( QApplication::applicationDirPath().endsWith( "/MacOS" ) )
{
std::cout << "OSX bundle" << std::endl;
// we are in a bundle
// TODO(mario): apply default OSX behavior of using $HOME/Library/OpenWalnut ?
WPathHelper::getPathHelper()->setBasePathsOSXBundle( walnutBin, boost::filesystem::path( QDir::homePath().toStdString() ) / ".OpenWalnut" );
......@@ -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
WPathHelper::getPathHelper()->setBasePaths( walnutBin, boost::filesystem::path( QDir::homePath().toStdString() ) / ".OpenWalnut" );
#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
m_settings = new QSettings( QString::fromStdString( ( WPathHelper::getHomePath() / "config.qt4gui" ).string() ), QSettings::IniFormat );
......@@ -230,7 +236,7 @@ int WQt4Gui::run()
m_kernel->getRoiManager()->addRemoveNotifier( removeRoiSignal );
// create the window
m_mainWindow = new WMainWindow();
m_mainWindow = new WMainWindow( m_splash );
#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
appl.setMyMainWidget( m_mainWindow );
......@@ -270,7 +276,7 @@ void WQt4Gui::slotUpdateTextureSorter()
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 )
......
......@@ -32,6 +32,7 @@
#include <QtCore/QSettings>
#include <QtCore/QMutex>
#include <QtGui/QSplashScreen>
#include "core/graphicsEngine/WROI.h"
#include "core/graphicsEngine/WGraphicsEngine.h"
......@@ -253,6 +254,11 @@ private:
* \note can be called from an arbitrary thread. Protected by m_deferredLoadMutex.
*/
void deferredLoad();
/**
* The splash screen.
*/
QSplashScreen* m_splash;
};
#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