Commit 66434683 by Sebastian Eichelbaum

[ADD] - added command prompt skeleton. Not yet completely done.

parent 6702d537
......@@ -41,6 +41,8 @@ SET(GUI_QT4_MOC_HDRS
networkEditor/WQtNetworkInputPort.h
networkEditor/WQtNetworkOutputPort.h
networkEditor/WQtNetworkArrow.h
commandPrompt/WQtCommandPromptToolbar.h
commandPrompt/WQtCommandPrompt.h
)
IF( CMAKE_HOST_SYSTEM MATCHES Darwin )
LIST( APPEND GUI_QT4_MOC_HDRS platformDependent/WQtGLWidgetMac.h )
......@@ -55,7 +57,8 @@ ENDIF()
QT4_WRAP_CPP(GUI_QT4_MOC_SRCS ${GUI_QT4_MOC_HDRS} )
FILE(GLOB GUI_QT4_SRC "*.cpp" "guiElements/*.cpp" "controlPanel/*.cpp" "events/*.cpp" "networkEditor/*.cpp" "*.h" "guiElements/*.h" "controlPanel/*.h" "events/*.h" "networkEditor/*.h" "../icons/WIcons.h" )
FILE(GLOB GUI_QT4_SRC "*.cpp" "guiElements/*.cpp" "controlPanel/*.cpp" "events/*.cpp" "networkEditor/*.cpp" "*.h" "guiElements/*.h"
"controlPanel/*.h" "events/*.h" "networkEditor/*.h" "../icons/WIcons.h" "commandPrompt/*.h" "commandPrompt/*.cpp" )
IF( CMAKE_HOST_SYSTEM MATCHES Darwin )
FILE( GLOB GUIQT4_PLATFORMDEPENDENT_SRC
"platformDependent/WQtGLWidgetMac.cpp"
......
......@@ -268,6 +268,11 @@ void WMainWindow::setupGUI()
}
}
// create command prompt toolbar
m_commandPrompt = new WQtCommandPromptToolbar( "Command Prompt", this );
addToolBar( Qt::TopToolBarArea, m_commandPrompt );
this->addAction( m_commandPrompt->toggleViewAction() ); // this enables the action even if the menu bar is invisible
// after creating the GUI, restore its saved state
restoreSavedState();
}
......
......@@ -40,6 +40,7 @@
#include "WQtToolBar.h"
#include "WQtGLWidget.h"
#include "networkEditor/WQtNetworkEditor.h"
#include "commandPrompt/WQtCommandPromptToolbar.h"
// forward declarations
class QMenuBar;
......@@ -298,6 +299,8 @@ private:
WQtNetworkEditor* m_networkEditor; //!< network editor
WQtCommandPromptToolbar* m_commandPrompt; //!< command prompt
boost::shared_ptr< WQtGLWidget > m_mainGLWidget; //!< the main GL widget of the GUI
boost::shared_ptr< WQtNavGLWidget > m_navAxial; //!< the axial view widget GL widget of the GUI
boost::shared_ptr< WQtNavGLWidget > m_navCoronal; //!< the coronal view widget GL widget of the GUI
......
//---------------------------------------------------------------------------
//
// 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 <iostream>
#include <QtGui/QAction>
#include <QtGui/QLineEdit>
#include <QtGui/QKeyEvent>
#include "../WMainWindow.h"
#include "WQtCommandPrompt.h"
WQtCommandPrompt::WQtCommandPrompt( QWidget* parent ):
QLineEdit( parent )
{
setText( "Not yet implemented. But as you tried the command prompt I assume you are a cool VIM user ;-)." );
connect( this, SIGNAL( returnPressed() ), this, SLOT( commit() ) );
}
WQtCommandPrompt::~WQtCommandPrompt()
{
// cleanup
}
void WQtCommandPrompt::abort()
{
setText( "" );
emit done();
}
void WQtCommandPrompt::commit()
{
setText( "" );
emit done();
}
void WQtCommandPrompt::keyPressEvent( QKeyEvent* event )
{
QLineEdit::keyPressEvent( event );
}
bool WQtCommandPrompt::event( QEvent* event )
{
// we need to override this to be able to grab the escape key
if ( event->type() == QEvent::KeyRelease )
{
QKeyEvent* keyEvent = dynamic_cast< QKeyEvent* >( event );
// escape quits the prompt
if ( keyEvent && ( keyEvent->key() == Qt::Key_Escape ) )
{
abort();
event->accept();
return true;
}
}
return QLineEdit::event( event );
}
//---------------------------------------------------------------------------
//
// 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 WQTCOMMANDPROMPT_H
#define WQTCOMMANDPROMPT_H
#include <QtGui/QLineEdit>
/**
* This is a toolbar. It provides a command prompt -like interface for adding, removing and connecting modules
*/
class WQtCommandPrompt: public QLineEdit
{
Q_OBJECT
public:
/**
* Constructs the prompt.
*
* \param parent the parent widget of this widget, i.e. the widget that manages it.
*/
explicit WQtCommandPrompt( QWidget* parent );
/**
* destructor
*/
virtual ~WQtCommandPrompt();
signals:
/**
* Emited if the prompt should quit. On ESC or after commiting a command.
*/
void done();
protected:
/**
* Converts the given key press event into a line edit action.
*
* \param event the key
*/
virtual void keyPressEvent( QKeyEvent* event );
/**
* Event handler
*
* \param event the event
*
* \return true if event was handled.
*/
bool event( QEvent* event );
private slots:
/**
* This aborts. The typed command will not be sent.
*/
void abort();
/**
* Commit the current command.
*/
void commit();
private:
};
#endif // WQTCOMMANDPROMPT_H
//---------------------------------------------------------------------------
//
// 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/QLabel>
#include "../WMainWindow.h"
#include "WQtCommandPrompt.h"
#include "WQtCommandPromptToolbar.h"
WQtCommandPromptToolbar::WQtCommandPromptToolbar( const QString& title, WMainWindow* parent ):
QToolBar( title, parent ),
m_mainWindow( parent )
{
setObjectName( title );
this->setAllowedAreas( Qt::TopToolBarArea | Qt::BottomToolBarArea );
setMinimumWidth( 50 );
setMinimumHeight( 30 );
setVisible( false );
// toggle it using ":"
QList< QKeySequence > commandPromptShortcut;
commandPromptShortcut.append( QKeySequence( Qt::Key_Colon ) );
toggleViewAction()->setShortcuts( commandPromptShortcut );
QLabel* label = new QLabel( this );
label->setText( "<b># </b>" );
addWidget( label );
m_prompt = new WQtCommandPrompt( this );
addWidget( m_prompt );
// if the toolbar is triggered:
connect( toggleViewAction(), SIGNAL( triggered( bool ) ), this, SLOT( show() ) );
connect( m_prompt, SIGNAL( done() ), this, SLOT( exit() ) );
}
WQtCommandPromptToolbar::~WQtCommandPromptToolbar()
{
// cleanup
}
void WQtCommandPromptToolbar::show()
{
setVisible( true );
m_prompt->setFocus();
}
void WQtCommandPromptToolbar::exit()
{
setVisible( false );
}
//---------------------------------------------------------------------------
//
// 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 WQTCOMMANDPROMPTTOOLBAR_H
#define WQTCOMMANDPROMPTTOOLBAR_H
#include <QtGui/QToolBar>
class WQtCommandPrompt;
class WMainWindow;
/**
* This is a toolbar. It provides a command prompt -like interface for adding, removing and connecting modules
*/
class WQtCommandPromptToolbar: public QToolBar
{
Q_OBJECT
public:
/**
* Constructs the toolbar.
* \param title name of the toolbar.
* \param parent the parent widget of this widget, i.e. the widget that manages it.
*/
explicit WQtCommandPromptToolbar( const QString& title, WMainWindow* parent );
/**
* destructor
*/
virtual ~WQtCommandPromptToolbar();
protected:
private slots:
/**
* Toggles the prompt toolbar
*/
void show();
/**
* Exit prompt
*/
void exit();
private:
/**
* The main window parent.
*/
WMainWindow* m_mainWindow;
/**
* The actual prompt edit.
*/
WQtCommandPrompt* m_prompt;
};
#endif // WQTCOMMANDPROMPTTOOLBAR_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