Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,8 @@ qt()
DIRECTORIES = ../ ../Core ../Logging \
../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/viewModeWidget
......
......@@ -69,7 +69,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
viewModeMenu_(0),
viewGroup_(0),
splitter_(0),
textedit_(0),
logWidget_(0),
recentFilesMenu_(0),
pluginsMenu_(0),
fileMenu_(0),
......@@ -95,11 +95,11 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
// ======================================================================
// Set up the logging window
// ======================================================================
textedit_ = new QTextEdit(splitter_);
textedit_->setReadOnly(true);
textedit_->setSizePolicy( QSizePolicy ( QSizePolicy::Preferred , QSizePolicy::Preferred ) );
textedit_->resize( splitter_->width() ,120);
textedit_->setLineWrapMode( QTextEdit::NoWrap );
logWidget_ = new LoggerWidget(splitter_);
logWidget_->setReadOnly(true);
logWidget_->setSizePolicy( QSizePolicy ( QSizePolicy::Preferred , QSizePolicy::Preferred ) );
logWidget_->resize( splitter_->width() ,120);
logWidget_->setLineWrapMode( QTextEdit::NoWrap );
originalLoggerSize_ = 0;
......@@ -473,6 +473,8 @@ CoreWidget::showToolbox( bool _state ) {
void
CoreWidget::keyPressEvent(QKeyEvent* _e)
{
std::cerr << "Key event in core" << std::endl;
if (_e->modifiers() == Qt::ControlModifier ) {
switch (_e->key())
{
......@@ -497,6 +499,11 @@ CoreWidget::keyPressEvent(QKeyEvent* _e)
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
default:
mapKeyPressEvent(_e);
......
......@@ -68,6 +68,7 @@
#include <QDockWidget>
#include <OpenFlipper/widgets/aboutWidget/aboutWidget.hh>
#include <OpenFlipper/widgets/loggerWidget/loggerWidget.hh>
#include <OpenFlipper/widgets/optionsWidget/optionsWidget.hh>
#include <OpenFlipper/widgets/helpBrowser/helpWidget.hh>
......@@ -305,7 +306,7 @@ public:
QSplitter* splitter_;
/// Textedit at the bottom for log messages
QTextEdit* textedit_;
LoggerWidget* logWidget_;
/// Size of the logging window ( defaults to 240 )
int originalLoggerSize_;
......
......@@ -65,22 +65,22 @@ CoreWidget::
slotLog(Logtype _type, QString _message) {
switch (_type) {
case LOGINFO:
textedit_->setTextColor(QColor(0,160,0));
logWidget_->setTextColor(QColor(0,160,0));
break;
case LOGOUT:
textedit_->setTextColor(QColor(0,0,0));
logWidget_->setTextColor(QColor(0,0,0));
break;
case LOGWARN:
textedit_->setTextColor(QColor(160,160,0));
logWidget_->setTextColor(QColor(160,160,0));
break;
case LOGERR:
textedit_->setTextColor(QColor(250,0,0));
logWidget_->setTextColor(QColor(250,0,0));
break;
}
textedit_->append(_message);
logWidget_->append(_message);
QScrollBar* bar = textedit_->verticalScrollBar();
QScrollBar* bar = logWidget_->verticalScrollBar();
bar->setValue(bar->maximum());
// Make shure, we see the message
......
//=============================================================================
//
// 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment