Commit 0aa659fb authored by Jan Möbius's avatar Jan Möbius
Browse files

Derive logwidget from qtextwidget

Implement key redirection from log widget to core
implement escape key handling in core

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4128 383ad7c9-94d9-4d36-a494-682f7c89f535
parent ac0aa0a1
...@@ -15,7 +15,8 @@ qt() ...@@ -15,7 +15,8 @@ qt()
DIRECTORIES = ../ ../Core ../Logging \ DIRECTORIES = ../ ../Core ../Logging \
../Scripting ../Scripting/scriptPrototypes ../Scripting/scriptWrappers ../SimpleOpt \ ../Scripting ../Scripting/scriptPrototypes ../Scripting/scriptWrappers ../SimpleOpt \
../widgets/aboutWidget ../widgets/addEmptyWidget ../widgets/coreWidget ../widgets/helpBrowser \ ../widgets/aboutWidget ../widgets/addEmptyWidget ../widgets/loggerWidget \
../widgets/coreWidget ../widgets/helpBrowser \
../widgets/loadWidget ../widgets/optionsWidget ../widgets/unloadPluginsWidget \ ../widgets/loadWidget ../widgets/optionsWidget ../widgets/unloadPluginsWidget \
../widgets/viewModeWidget ../widgets/viewModeWidget
......
...@@ -69,7 +69,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -69,7 +69,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
viewModeMenu_(0), viewModeMenu_(0),
viewGroup_(0), viewGroup_(0),
splitter_(0), splitter_(0),
textedit_(0), logWidget_(0),
recentFilesMenu_(0), recentFilesMenu_(0),
pluginsMenu_(0), pluginsMenu_(0),
fileMenu_(0), fileMenu_(0),
...@@ -95,11 +95,11 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -95,11 +95,11 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
// ====================================================================== // ======================================================================
// Set up the logging window // Set up the logging window
// ====================================================================== // ======================================================================
textedit_ = new QTextEdit(splitter_); logWidget_ = new LoggerWidget(splitter_);
textedit_->setReadOnly(true); logWidget_->setReadOnly(true);
textedit_->setSizePolicy( QSizePolicy ( QSizePolicy::Preferred , QSizePolicy::Preferred ) ); logWidget_->setSizePolicy( QSizePolicy ( QSizePolicy::Preferred , QSizePolicy::Preferred ) );
textedit_->resize( splitter_->width() ,120); logWidget_->resize( splitter_->width() ,120);
textedit_->setLineWrapMode( QTextEdit::NoWrap ); logWidget_->setLineWrapMode( QTextEdit::NoWrap );
originalLoggerSize_ = 0; originalLoggerSize_ = 0;
...@@ -473,6 +473,8 @@ CoreWidget::showToolbox( bool _state ) { ...@@ -473,6 +473,8 @@ CoreWidget::showToolbox( bool _state ) {
void void
CoreWidget::keyPressEvent(QKeyEvent* _e) CoreWidget::keyPressEvent(QKeyEvent* _e)
{ {
std::cerr << "Key event in core" << std::endl;
if (_e->modifiers() == Qt::ControlModifier ) { if (_e->modifiers() == Qt::ControlModifier ) {
switch (_e->key()) switch (_e->key())
{ {
...@@ -497,6 +499,11 @@ CoreWidget::keyPressEvent(QKeyEvent* _e) ...@@ -497,6 +499,11 @@ CoreWidget::keyPressEvent(QKeyEvent* _e)
switch (_e->key()) switch (_e->key())
{ {
case Qt::Key_Escape:
std::cerr << "Escape Key" << std::endl;
for ( uint i = 0 ; i < examiner_widgets_.size(); ++i)
examiner_widgets_[i]->actionMode(examiner_widgets_[i]->lastActionMode());
// Send remaining events to plugins // Send remaining events to plugins
default: default:
mapKeyPressEvent(_e); mapKeyPressEvent(_e);
......
...@@ -68,6 +68,7 @@ ...@@ -68,6 +68,7 @@
#include <QDockWidget> #include <QDockWidget>
#include <OpenFlipper/widgets/aboutWidget/aboutWidget.hh> #include <OpenFlipper/widgets/aboutWidget/aboutWidget.hh>
#include <OpenFlipper/widgets/loggerWidget/loggerWidget.hh>
#include <OpenFlipper/widgets/optionsWidget/optionsWidget.hh> #include <OpenFlipper/widgets/optionsWidget/optionsWidget.hh>
#include <OpenFlipper/widgets/helpBrowser/helpWidget.hh> #include <OpenFlipper/widgets/helpBrowser/helpWidget.hh>
...@@ -305,7 +306,7 @@ public: ...@@ -305,7 +306,7 @@ public:
QSplitter* splitter_; QSplitter* splitter_;
/// Textedit at the bottom for log messages /// Textedit at the bottom for log messages
QTextEdit* textedit_; LoggerWidget* logWidget_;
/// Size of the logging window ( defaults to 240 ) /// Size of the logging window ( defaults to 240 )
int originalLoggerSize_; int originalLoggerSize_;
......
...@@ -12,12 +12,12 @@ ...@@ -12,12 +12,12 @@
// it under the terms of the GNU Lesser General Public License as published by // 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 // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// OpenFlipper is distributed in the hope that it will be useful, // OpenFlipper is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details. // GNU Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public License // You should have received a copy of the GNU Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>. // along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
// //
...@@ -50,39 +50,39 @@ ...@@ -50,39 +50,39 @@
#include <QScrollBar> #include <QScrollBar>
#include <QApplication> #include <QApplication>
//== IMPLEMENTATION ========================================================== //== IMPLEMENTATION ==========================================================
/** \brief Slot writing everything to the Logger widget /** \brief Slot writing everything to the Logger widget
* *
* This slot has to be called by all loggers. It is used to serialize * This slot has to be called by all loggers. It is used to serialize
* and color the Output. * and color the Output.
* *
* @param _type Logtype (defines the color of the output) * @param _type Logtype (defines the color of the output)
* @param _message The message for output * @param _message The message for output
**/ **/
void void
CoreWidget:: CoreWidget::
slotLog(Logtype _type, QString _message) { slotLog(Logtype _type, QString _message) {
switch (_type) { switch (_type) {
case LOGINFO: case LOGINFO:
textedit_->setTextColor(QColor(0,160,0)); logWidget_->setTextColor(QColor(0,160,0));
break; break;
case LOGOUT: case LOGOUT:
textedit_->setTextColor(QColor(0,0,0)); logWidget_->setTextColor(QColor(0,0,0));
break; break;
case LOGWARN: case LOGWARN:
textedit_->setTextColor(QColor(160,160,0)); logWidget_->setTextColor(QColor(160,160,0));
break; break;
case LOGERR: case LOGERR:
textedit_->setTextColor(QColor(250,0,0)); logWidget_->setTextColor(QColor(250,0,0));
break; break;
} }
textedit_->append(_message); logWidget_->append(_message);
QScrollBar* bar = textedit_->verticalScrollBar(); QScrollBar* bar = logWidget_->verticalScrollBar();
bar->setValue(bar->maximum()); bar->setValue(bar->maximum());
// Make shure, we see the message // Make shure, we see the message
QApplication::processEvents(); QApplication::processEvents();
} }
......
//=============================================================================
//
// OpenFlipper
// Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
// www.openflipper.org
//
//-----------------------------------------------------------------------------
//
// License
//
// OpenFlipper 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.
//
// OpenFlipper 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 OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
// $Revision: 1909 $
// $Author: wilden $
// $Date: 2008-06-03 18:45:21 +0200 (Tue, 03 Jun 2008) $
//
//=============================================================================
#include "loggerWidget.hh"
LoggerWidget::LoggerWidget( QWidget *parent)
: QTextEdit(parent)
{
}
void LoggerWidget::keyPressEvent (QKeyEvent * _event ) {
// Return key event to parent if not one of the standard key combinations ( ... Core )
if ( ( (_event->modifiers() & Qt::ControlModifier ) && ( _event->key() == Qt::Key_C ) ) ||
( (_event->modifiers() & Qt::ControlModifier ) && ( _event->key() == Qt::Key_A ) ) ) {
QTextEdit::keyPressEvent(_event);
} else
_event->ignore();
}
//=============================================================================
//
// OpenFlipper
// Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
// www.openflipper.org
//
//-----------------------------------------------------------------------------
//
// License
//
// OpenFlipper 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.
//
// OpenFlipper 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 OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
// $Revision: 1909 $
// $Author: wilden $
// $Date: 2008-06-03 18:45:21 +0200 (Tue, 03 Jun 2008) $
//
//=============================================================================
#ifndef LOGGERWIDGET_HH
#define LOGGERWIDGET_HH
#include <QtGui>
/** \brief Implementation of the logger Widget
*
* This class adds some special features to the textedit for the log window
*/
class LoggerWidget : public QTextEdit
{
Q_OBJECT
public:
LoggerWidget( QWidget *parent = 0 );
protected:
/** \brief Grab key events before TextEdit
*
* This function grabs all key events and passes them back to the core to handle them correctly
*/
void keyPressEvent (QKeyEvent * _event );
};
#endif //LOGGERWIDGET_HH
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