Commit 81530060 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[FIX] - older Qt versions do not seem to provide a default parent for QIntValidator

parent ffa68db5
......@@ -452,12 +452,6 @@ void WMainWindow::setupGUI()
showSagittal->setText( "Toggle Sagittal Slice" );
showSagittal->setIcon( m_iconManager.getIcon( "sagittal icon" ) );
// Temporarily disabled. We need a proper command prompt implementation first.
// 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
// setup permanent toolbar
m_permanentToolBar->addAction( m_loadButton );
m_permanentToolBar->addAction( projectSaveButton );
......
......@@ -41,7 +41,6 @@
#include "WQtGLWidget.h"
#include "WSettingAction.h"
#include "networkEditor/WQtNetworkEditor.h"
#include "commandPrompt/WQtCommandPromptToolbar.h"
// forward declarations
class QMenuBar;
......@@ -349,8 +348,6 @@ private:
WQtNetworkEditor* m_networkEditor; //!< network editor
WQtCommandPromptToolbar* m_commandPrompt; //!< command prompt
boost::shared_ptr< WQtGLWidget > m_mainGLWidget; //!< the main GL widget of the GUI
WQtGLScreenCapture* m_mainGLWidgetScreenCapture; //!< screen recorder in m_mainGLWidget
......
......@@ -90,8 +90,8 @@ WQtGLScreenCapture::WQtGLScreenCapture( WGEViewer::SPtr viewer, WMainWindow* par
m_customWidth = new QLineEdit( "1980", this );
m_customHeight = new QLineEdit( "1080", this );
m_customWidth->setValidator( new QIntValidator( 0, 4096 ) );
m_customHeight->setValidator( new QIntValidator( 0, 4096 ) );
m_customWidth->setValidator( new QIntValidator( 0, 4096, m_customWidth ) );
m_customHeight->setValidator( new QIntValidator( 0, 4096, m_customHeight ) );
QPushButton* resolutionButton = new QPushButton( "Set" );
resolutionButton->setCheckable( true );
......
//---------------------------------------------------------------------------
//
// 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"
#include "WQtCommandPrompt.moc"
WQtCommandPrompt::WQtCommandPrompt( QWidget* parent ):
QLineEdit( parent )
{
// some nice style
// TODO(ebaum): make this configurable
setStyleSheet( "color: white;"
"border: 0px solid gray;"
"border-radius: 0px;"
"border-color: #080808;"
"padding: 0 0px;"
"background: #080808;"
"selection-background-color: gray;" );
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"
#include "WQtCommandPromptToolbar.moc"
WQtCommandPromptToolbar::WQtCommandPromptToolbar( const QString& title, WMainWindow* parent ):
QToolBar( title, parent ),
m_mainWindow( parent )
{
setObjectName( title );
this->setAllowedAreas( Qt::TopToolBarArea | Qt::BottomToolBarArea );
setMinimumWidth( 50 );
setMinimumHeight( 20 );
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>" );
label->setStyleSheet( "background: #080808;" );
addWidget( label );
m_prompt = new WQtCommandPrompt( this );
addWidget( m_prompt );
// some nice style
// TODO(ebaum): make this configurable
setStyleSheet( "background: #080808;"
"border: 2px solid #080808;"
"margin: 0px;"
"padding: 0px;"
"spacing: 0;"
"color: white;"
);
// 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