Commit 8de9fa35 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD #227] added message dock. Not yet working.

parent 4413f222
......@@ -245,6 +245,10 @@ void WMainWindow::setupGUI()
addDockWidget( Qt::RightDockWidgetArea, m_controlPanel->getColormapperDock() );
addDockWidget( Qt::RightDockWidgetArea, m_controlPanel->getRoiDock() );
// the message dock:
m_messageDock = new WQtMessageDock( "Messages", this );
addDockWidget( Qt::RightDockWidgetArea, m_messageDock );
// tabify those panels by default
if( m_networkEditor )
{
......@@ -252,6 +256,7 @@ void WMainWindow::setupGUI()
}
tabifyDockWidget( m_controlPanel->getModuleDock(), m_controlPanel->getColormapperDock() );
tabifyDockWidget( m_controlPanel->getColormapperDock(), m_controlPanel->getRoiDock() );
tabifyDockWidget( m_controlPanel->getRoiDock(), m_messageDock );
m_glDock = new QMainWindow();
m_glDock->setObjectName( "GLDock" );
......@@ -939,7 +944,7 @@ bool WMainWindow::event( QEvent* event )
{
QString title = "Module \"" + QString::fromStdString( e1->getModule()->getName() ) + "\" caused a problem.";
QString message = QString::fromStdString( e1->getMessage() );
reportError( m_networkEditor->getView(), title, message );
reportError( this, title, message );
}
}
......@@ -997,7 +1002,7 @@ bool WMainWindow::event( QEvent* event )
if( curWarnCount && curErrCount ) // Errors and warnings
{
reportError( m_networkEditor->getView(), "There where errors and warnings during load.",
reportError( this, "There where errors and warnings during load.",
"Errors occurred during load of \"" + QString::fromStdString( e1->getFilename() ) + "\". "
"The loader tried to apply as much as possible, ignoring the erroneous data. The first errors where:"
+ QString::fromStdString( errors ) +
......@@ -1007,14 +1012,14 @@ bool WMainWindow::event( QEvent* event )
}
else if( curWarnCount && !curErrCount ) // only warnings
{
reportWarning( m_networkEditor->getView(), "There where warnings during load.",
reportWarning( this, "There where warnings during load.",
"Warnings occurred during load of \"" + QString::fromStdString( e1->getFilename() ) + "\". "
+ QString::fromStdString( warnings )
);
}
else if( !curWarnCount && curErrCount ) // only errors
{
reportError( m_networkEditor->getView(), "There where errors during load.",
reportError( this, "There where errors during load.",
"Errors occurred during load of \"" + QString::fromStdString( e1->getFilename() ) + "\". "
"The loader tried to apply as much as possible, ignoring the erroneous data. The first errors where:"
+ QString::fromStdString( errors )
......@@ -1335,3 +1340,12 @@ void WMainWindow::addGlobalMenu( QWidget* widget )
widget->addAction( m_quitAction );
}
const WQtMessageDock* WMainWindow::getMessageDock() const
{
return m_messageDock;
}
WQtMessageDock* WMainWindow::getMessageDock()
{
return m_messageDock;
}
......@@ -41,6 +41,7 @@
#include "WQtGLWidget.h"
#include "WSettingAction.h"
#include "networkEditor/WQtNetworkEditor.h"
#include "WQtMessageDock.h"
// forward declarations
class QMenuBar;
......@@ -221,6 +222,20 @@ public:
* \param message the message
*/
void reportInfo( QWidget* parent, QString title, QString message );
/**
* Return the message dock widget
*
* \return the message dock
*/
const WQtMessageDock* getMessageDock() const;
/**
* Return the message dock widget
*
* \return the message dock
*/
WQtMessageDock* getMessageDock();
protected:
/**
* Setup the GUI by handling special modules. NavSlices for example setup several toolbar buttons.
......@@ -374,6 +389,11 @@ private:
WQtToolBar* m_permanentToolBar; //!< The permanent toolbar of the main window.
/**
* Message and log window
*/
WQtMessageDock* m_messageDock;
// several menu items
QAction* m_newAction; //!< the new project button
QAction* m_loadButton; //!< the load button
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <QtGui/QAction>
#include <QtGui/QDockWidget>
#include <QtGui/QVBoxLayout>
#include "WQt4Gui.h"
#include "WQtMessageDock.h"
#include "WQtMessageDock.moc"
WQtMessageDock::WQtMessageDock( QString dockTitle, QWidget* parent ):
QDockWidget( dockTitle, parent )
{
setObjectName( "MessageDock:" + dockTitle );
setAllowedAreas( Qt::AllDockWidgetAreas );
setFeatures( QDockWidget::AllDockWidgetFeatures );
}
WQtMessageDock::~WQtMessageDock()
{
// cleanup
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WQTMESSAGEDOCK_H
#define WQTMESSAGEDOCK_H
#include <QtGui/QDockWidget>
#include <QtGui/QVBoxLayout>
/**
* Dock widget for showing messages and logs
*/
class WQtMessageDock: public QDockWidget
{
Q_OBJECT
public:
/**
* Constructor
*
* \param dockTitle the title
* \param parent parent widget
*/
WQtMessageDock( QString dockTitle, QWidget* parent );
/**
* Destructor.
*/
virtual ~WQtMessageDock();
protected:
private:
};
#endif // WQTMESSAGEDOCK_H
......@@ -22,6 +22,8 @@
//
//---------------------------------------------------------------------------
#include <algorithm>
#include <QtGui/QHBoxLayout>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
......@@ -43,6 +45,7 @@
#define OUTERMARGIN 10
#define BORDERWIDTH 2
#define CONTENTHEIGHT 16
#define MAXWIDTH 600
WQtMessagePopup::WQtMessagePopup( QWidget* parent, const QString& title, const QString& message, MessageType type ):
QDialog( parent, Qt::Popup | Qt::FramelessWindowHint ),
......@@ -54,19 +57,13 @@ WQtMessagePopup::WQtMessagePopup( QWidget* parent, const QString& title, const Q
setWindowModality( Qt::NonModal );
setModal( false );
// get top left corner
QPoint p = parent->mapToGlobal( QPoint( 0, 0 ) );
// determine a width and height for the popup
unsigned int w = parent->width() - ( 2.0 * OUTERMARGIN );
unsigned int w = std::min( parent->width() - ( 2 * OUTERMARGIN ), MAXWIDTH );
unsigned int h = CONTENTHEIGHT + BORDERWIDTH + BORDERWIDTH;
// change size of popup
resize( w, h );
// set position, include margins
move( p.x() + OUTERMARGIN, p.y() + OUTERMARGIN );
QString borderColor = "red";
QString titlePrefix = "";
......@@ -169,6 +166,18 @@ WQtMessagePopup::WQtMessagePopup( QWidget* parent, const QString& title, const Q
detailsBtn->setObjectName( "popupDialogButton" );
}
void WQtMessagePopup::showEvent( QShowEvent* event )
{
// move widget to correct position
// get top left corner
QPoint p = parentWidget()->mapToGlobal( QPoint( parentWidget()->width() / 2, parentWidget()->height() ) );
// set position, include margins
move( p.x() - width() / 2 - OUTERMARGIN / 2, p.y() - height()- OUTERMARGIN );
QDialog::showEvent( event );
}
WQtMessagePopup::~WQtMessagePopup()
{
// cleanup
......
......@@ -68,6 +68,12 @@ public slots:
*/
void showMessage();
protected:
/**
* On show. Called when opening the widget.
*
* \param event
*/
virtual void showEvent( QShowEvent* event );
private:
/**
* Title Text
......
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