Commit b524e0a6 authored by Jan Möbius's avatar Jan Möbius

Dennis:

* Replaced QDockWidgets/Area with own implementation
* Use QSettings to store geometry and states of all widgets/windows

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5202 383ad7c9-94d9-4d36-a494-682f7c89f535
parent ff8821f2
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
#include <QStatusBar> #include <QStatusBar>
#include <QMessageBox> #include <QMessageBox>
#include <QFile> #include <QFile>
#include <QSettings>
#include <QPluginLoader> #include <QPluginLoader>
#include "OpenFlipper/BasePlugin/BaseInterface.hh" #include "OpenFlipper/BasePlugin/BaseInterface.hh"
...@@ -476,32 +477,28 @@ Core::init() { ...@@ -476,32 +477,28 @@ Core::init() {
if ( OpenFlipper::Options::gui() ) { if ( OpenFlipper::Options::gui() ) {
//try to restore the windowState QSettings windowStates(QDir::home().absolutePath() + OpenFlipper::Options::dirSeparator() + ".OpenFlipper" +
QFile file(QDir::home().absolutePath() + OpenFlipper::Options::dirSeparator() + ".OpenFlipper" + OpenFlipper::Options::dirSeparator() + "WindowStates.dat", QSettings::IniFormat);
OpenFlipper::Options::dirSeparator() + "windowState.dat");
if (file.open(QIODevice::ReadOnly)){
QByteArray bytes = file.readAll();
coreWidget_->restoreState( bytes );
file.close();
}
//try to restore the windowState
coreWidget_->restoreState (windowStates.value("Core/Window/State").toByteArray ());
//try to restore the geometry //try to restore the geometry
QFile file2(QDir::home().absolutePath() + OpenFlipper::Options::dirSeparator() + ".OpenFlipper" + coreWidget_->restoreGeometry (windowStates.value("Core/Window/Geometry").toByteArray ());
OpenFlipper::Options::dirSeparator() + "geometry.dat");
if (file2.open(QIODevice::ReadOnly)){
QByteArray bytes = file2.readAll();
coreWidget_->restoreGeometry( bytes );
file2.close(); coreWidget_->toolSplitter_->restoreState (windowStates.value("Core/ToolSplitter").toByteArray ());
} coreWidget_->splitter_->restoreState (windowStates.value("Core/LogSplitter").toByteArray ());
coreWidget_->show(); coreWidget_->show();
applyOptions(); applyOptions();
windowStates.beginGroup ("Core");
windowStates.beginGroup ("LogSlider");
coreWidget_->slidingLogger_->restoreState (windowStates);
windowStates.endGroup ();
coreWidget_->toolBox_->restoreState (windowStates);
windowStates.endGroup ();
if ( OpenFlipper::Options::splash() ) { if ( OpenFlipper::Options::splash() ) {
splash_->finish(coreWidget_); splash_->finish(coreWidget_);
} }
...@@ -835,20 +832,22 @@ Core::writeOnExit() { ...@@ -835,20 +832,22 @@ Core::writeOnExit() {
//store the windowState //store the windowState
if ( OpenFlipper::Options::gui() ) { if ( OpenFlipper::Options::gui() ) {
QFile file(QDir::home().absolutePath() + OpenFlipper::Options::dirSeparator() + ".OpenFlipper" +
OpenFlipper::Options::dirSeparator() + "windowState.dat"); QSettings windowStates(QDir::home().absolutePath() + OpenFlipper::Options::dirSeparator() + ".OpenFlipper" +
if (file.open(QIODevice::WriteOnly)) OpenFlipper::Options::dirSeparator() + "WindowStates.dat", QSettings::IniFormat);
{
file.write( coreWidget_->saveState() ); windowStates.setValue("Core/Window/State", coreWidget_->saveState ());
file.close(); windowStates.setValue("Core/Window/Geometry", coreWidget_->saveGeometry ());
}
QFile file2(QDir::home().absolutePath() + OpenFlipper::Options::dirSeparator() + ".OpenFlipper" + windowStates.setValue ("Core/ToolSplitter", coreWidget_->toolSplitter_->saveState ());
OpenFlipper::Options::dirSeparator() + "geometry.dat"); windowStates.setValue ("Core/LogSplitter", coreWidget_->splitter_->saveState ());
if (file2.open(QIODevice::WriteOnly))
{ windowStates.beginGroup ("Core");
file2.write( coreWidget_->saveGeometry() ); windowStates.beginGroup ("LogSlider");
file2.close(); coreWidget_->slidingLogger_->saveState (windowStates);
} windowStates.endGroup ();
coreWidget_->toolBox_->saveState (windowStates);
windowStates.endGroup ();
} }
// Call exit for all plugins // Call exit for all plugins
......
...@@ -87,7 +87,7 @@ class PluginInfo{ ...@@ -87,7 +87,7 @@ class PluginInfo{
QList< KeyBinding > keys; QList< KeyBinding > keys;
/// Pointer to plugins toolbar widget (if available) /// Pointer to plugins toolbar widget (if available)
QDockWidget* widget; QWidget* widget;
/// Pointer to plugins options widget (if available) /// Pointer to plugins options widget (if available)
QWidget* optionsWidget; QWidget* optionsWidget;
......
...@@ -583,29 +583,7 @@ void Core::loadPlugin(QString filename, bool silent){ ...@@ -583,29 +583,7 @@ void Core::loadPlugin(QString filename, bool silent){
QWidget* widget = 0; QWidget* widget = 0;
if ( toolboxPlugin->initializeToolbox( widget ) ) { if ( toolboxPlugin->initializeToolbox( widget ) ) {
QDockWidget* dock = new QDockWidget(info.name , coreWidget_ ); info.widget = widget;
QScrollArea* scrollArea = new QScrollArea(dock);
scrollArea->setWidget(widget);
scrollArea->setWidgetResizable(true);
dock->setWidget(scrollArea);
dock->setMaximumWidth(400);
// std::cerr << info.name.toStdString() << std::endl;
// std::cerr << "minimumSizeHint : " << widget->minimumSizeHint().width() << std::endl;
// std::cerr << "minimumSize : " << widget->minimumSize().width() << std::endl;
int newNumber = toolboxindex_;
toolboxindex_++;
QString number = QString::number(newNumber);
dock->setObjectName( "ToolWidget" + number );
coreWidget_->setDockOptions(QMainWindow::AllowTabbedDocks | QMainWindow::VerticalTabs);
coreWidget_->addDockWidget(Qt::RightDockWidgetArea,dock);
connect(dock, SIGNAL( visibilityChanged (bool) ), coreWidget_ , SLOT( slotVisibilityChanged(bool) ));
info.widget = dock;
// add widget name to viewMode 'all' // add widget name to viewMode 'all'
QString name_nospace = info.name; QString name_nospace = info.name;
...@@ -1014,10 +992,6 @@ void Core::loadPlugin(QString filename, bool silent){ ...@@ -1014,10 +992,6 @@ void Core::loadPlugin(QString filename, bool silent){
plugins.push_back(info); plugins.push_back(info);
//tab all dockwidgets together
if (OpenFlipper::Options::gui())
coreWidget_->tabDockWidgets( QVector< QDockWidget* >() );
// Initialize Plugin // Initialize Plugin
if ( basePlugin ) { if ( basePlugin ) {
if ( checkSlot(plugin,"initializePlugin()") ) if ( checkSlot(plugin,"initializePlugin()") )
......
...@@ -99,13 +99,8 @@ void Core::applyOptions(){ ...@@ -99,13 +99,8 @@ void Core::applyOptions(){
//hideToolbox //hideToolbox
if (OpenFlipper::Options::hideToolbox()) { if (OpenFlipper::Options::hideToolbox()) {
//hide all toolWidgets
for (uint p=0; p < plugins.size(); p++) coreWidget_->showToolbox (false);
if (plugins[p].widget)
plugins[p].widget->setVisible(false);
//hide ViewMode Selection Widget
coreWidget_->dockViewMode_->setVisible(false);
} }
//setup logFile //setup logFile
......
...@@ -68,7 +68,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -68,7 +68,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
coreSlots_(_coreSlots), coreSlots_(_coreSlots),
shiftPressed_(false), shiftPressed_(false),
viewModes_(_viewModes), viewModes_(_viewModes),
dockViewMode_(0),
viewModeButton_(0), viewModeButton_(0),
viewModeMenu_(0), viewModeMenu_(0),
viewGroup_(0), viewGroup_(0),
...@@ -99,8 +98,11 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -99,8 +98,11 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
{ {
setupStatusBar(); setupStatusBar();
splitter_ = new QSplitter(Qt::Vertical,this); toolSplitter_ = new QSplitter(Qt::Horizontal,this);
setCentralWidget(splitter_);
setCentralWidget(toolSplitter_);
splitter_ = new QSplitter(Qt::Vertical,toolSplitter_);
stackedWidget_ = new QStackedWidget(splitter_); stackedWidget_ = new QStackedWidget(splitter_);
QGLFormat format; QGLFormat format;
...@@ -440,18 +442,39 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -440,18 +442,39 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
originalLoggerSize_ = wsizes[1]; originalLoggerSize_ = wsizes[1];
// ====================================================================== // ======================================================================
// Create Upper DockWidget for ToolWidget control // Create ToolBox area
// ====================================================================== // ======================================================================
dockViewMode_ = new QDockWidget("ViewMode" , this );
dockViewMode_->setObjectName("DockViewMode"); toolBoxArea_ = new QWidget (toolSplitter_);
QPushButton* button = new QPushButton("Change View Mode");
dockViewMode_->setWidget(button); QGroupBox *gb = new QGroupBox ("ViewMode");
button->setParent(dockViewMode_);
dockViewMode_->setFeatures( QDockWidget::NoDockWidgetFeatures ); QHBoxLayout *hLayout = new QHBoxLayout;
button->show();
addDockWidget(Qt::RightDockWidgetArea,dockViewMode_); QPushButton* vmButton = new QPushButton("Change View Mode");
connect(button, SIGNAL(clicked()), this, SLOT(slotViewModeDialog())); hLayout->addWidget (vmButton);
dockViewMode_->setVisible(false); gb->setLayout (hLayout);
connect(vmButton, SIGNAL(clicked()), this, SLOT(slotViewModeDialog()));
toolBoxScroll_ = new QScrollArea ();
toolBox_ = new SideArea ();
toolBoxScroll_->setWidget (toolBox_);
toolBoxScroll_->setWidgetResizable (true);
toolBoxScroll_->setFrameStyle (QFrame::StyledPanel);
QVBoxLayout *vLayout = new QVBoxLayout;
vLayout->addWidget(gb);
vLayout->addWidget(toolBoxScroll_);
toolBoxArea_->setLayout (vLayout);
wsizes = toolSplitter_->sizes();
wsizes[0] = 480;
wsizes[1] = 240;
toolSplitter_->setSizes(wsizes);
// ====================================================================== // ======================================================================
// Context menu setup // Context menu setup
...@@ -679,13 +702,9 @@ CoreWidget::showToolbox( bool _state ) { ...@@ -679,13 +702,9 @@ CoreWidget::showToolbox( bool _state ) {
OpenFlipper::Options::hideToolbox( !_state ); OpenFlipper::Options::hideToolbox( !_state );
if ( OpenFlipper::Options::hideToolbox() ){ if ( OpenFlipper::Options::hideToolbox() ){
//hide all toolWidgets
for (uint p=0; p < plugins_.size(); p++)
if (plugins_[p].widget)
plugins_[p].widget->setVisible(false);
//hide ViewMode Selection Widget //hide ViewMode Selection Widget
dockViewMode_->setVisible(false); toolBoxArea_->setVisible(false);
}else{ }else{
//reset last ViewMode //reset last ViewMode
...@@ -693,6 +712,7 @@ CoreWidget::showToolbox( bool _state ) { ...@@ -693,6 +712,7 @@ CoreWidget::showToolbox( bool _state ) {
setViewMode("All"); setViewMode("All");
else else
setViewMode( OpenFlipper::Options::defaultToolboxMode() ); setViewMode( OpenFlipper::Options::defaultToolboxMode() );
toolBoxArea_->setVisible(true);
} }
} }
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include <OpenFlipper/BasePlugin/ViewInterface.hh> #include <OpenFlipper/BasePlugin/ViewInterface.hh>
#include <OpenFlipper/BasePlugin/StatusbarInterface.hh> #include <OpenFlipper/BasePlugin/StatusbarInterface.hh>
#include <OpenFlipper/widgets/coreWidget/SideArea.hh>
#include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh> #include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh>
#include <OpenFlipper/widgets/glWidget/QtGLGraphicsScene.hh> #include <OpenFlipper/widgets/glWidget/QtGLGraphicsScene.hh>
...@@ -84,6 +85,7 @@ ...@@ -84,6 +85,7 @@
#include <OpenFlipper/INIFile/INIFile.hh> #include <OpenFlipper/INIFile/INIFile.hh>
struct ViewMode{ struct ViewMode{
QString name; QString name;
bool custom; //is the mode defined by the user? bool custom; //is the mode defined by the user?
...@@ -320,9 +322,6 @@ public: ...@@ -320,9 +322,6 @@ public:
/// List of currently available viewModes /// List of currently available viewModes
QVector<ViewMode*>& viewModes_; QVector<ViewMode*>& viewModes_;
///DockWidget and Button for changing viewMode via dialog
QDockWidget* dockViewMode_;
private: private:
QPushButton* viewModeButton_; QPushButton* viewModeButton_;
...@@ -333,10 +332,6 @@ public: ...@@ -333,10 +332,6 @@ public:
/// Group for all menu items /// Group for all menu items
QActionGroup* viewGroup_; QActionGroup* viewGroup_;
public:
/// Tab all DockWidgets which belong to ToolWidgets together
void tabDockWidgets(QVector< QDockWidget* > _widgets);
public slots: public slots:
/// init ViewModes that were loaded via ini-file /// init ViewModes that were loaded via ini-file
...@@ -362,9 +357,6 @@ public: ...@@ -362,9 +357,6 @@ public:
/// Show a dialog in which the viewMode can be changed /// Show a dialog in which the viewMode can be changed
void slotViewModeDialog(); void slotViewModeDialog();
/// Slot is called when the visibility of a toolWidget changes
void slotVisibilityChanged ( bool visible );
/// Set the view Mode to the given Mode /// Set the view Mode to the given Mode
public slots : public slots :
void setViewMode( QString _mode ); void setViewMode( QString _mode );
...@@ -419,6 +411,18 @@ public: ...@@ -419,6 +411,18 @@ public:
/// Temporary widget /// Temporary widget
QWidget* tempLogWidget; QWidget* tempLogWidget;
/// Widget for toolBox
QWidget* toolBoxArea_;
/// Spliter between toplevel objects and toolbox
QSplitter* toolSplitter_;
/// Toolbox
SideArea* toolBox_;
/// Toolbox scroll area
QScrollArea* toolBoxScroll_;
// widget showing the scenegraph // widget showing the scenegraph
ACG::QtWidgets::QtSceneGraphDialog* sceneGraphDialog_; ACG::QtWidgets::QtSceneGraphDialog* sceneGraphDialog_;
......
//=============================================================================
//
// 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: $
// $Author: $
// $Date: $
//
//=============================================================================
//== INCLUDES =================================================================
#include <QVBoxLayout>
#include "SideArea.hh"
#include "SideElement.hh"
//== IMPLEMENTATION ==========================================================
SideArea::SideArea (QWidget *_parent) :
QWidget (_parent)
{
layout_ = new QVBoxLayout;
layout_->setSpacing (0);
QVBoxLayout *l = new QVBoxLayout;
l->addLayout (layout_);
l->addStretch(1);
setLayout (l);
}
//-----------------------------------------------------------------------------
void SideArea::addItem (QWidget *_w, QString _name)
{
SideElement *e = new SideElement (this, _w, _name);
layout_->addWidget (e);
items_.push_back (e);
}
//-----------------------------------------------------------------------------
void SideArea::clear ()
{
foreach (SideElement *e, items_)
{
layout_->removeWidget (e);
delete e;
}
items_.clear ();
}
//-----------------------------------------------------------------------------
void SideArea::saveState (QSettings &_settings)
{
_settings.beginGroup ("SideArea");
foreach (SideElement *e, items_)
{
e->saveState (_settings);
}
_settings.endGroup ();
}
//-----------------------------------------------------------------------------
void SideArea::restoreState (QSettings &_settings)
{
_settings.beginGroup ("SideArea");
foreach (SideElement *e, items_)
{
e->restoreState (_settings);
}
_settings.endGroup ();
}
//=============================================================================
//=============================================================================
//=============================================================================
//
// 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: $
// $Author: $
// $Date: $
//
//=============================================================================
#ifndef SIDE_AREA_
#define SIDE_AREA_
//=============================================================================
//
// CLASS SideElement
//
//=============================================================================
//== INCLUDES =================================================================
#include <QWidget>
#include <QString>
#include <QSettings>
//== FORWARDDECLARATIONS ======================================================
class QVBoxLayout;
class SideElement;
/** \class SideArea SideArea.hh <OpenFlipper/widgets/coreWidget/SideArea.hh>
A widget that holds the different plugin tool widgets
**/
class SideArea : public QWidget {
public:
/** Create a SideElement
\param _parent Parent widget
*/
SideArea (QWidget *_parent = 0);
/** Adds a plugin tool widget
\param _w Plugin widget
\param _name Plugin name
*/
void addItem (QWidget *_w, QString _name);
/// clears the whole tool widget area
void clear ();
/// returns the current state
void saveState (QSettings &_settings);
/// restores the state
void restoreState (QSettings &_settings);
private:
// elements
QVector<SideElement *> items_;
// main layout
QVBoxLayout *layout_;
};
//=============================================================================
//=============================================================================
#endif // SIDE_AREA_ defined
//=============================================================================
\ No newline at end of file
//=============================================================================
//
// 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: $
// $Author: $
// $Date: $
//
//=============================================================================
//== INCLUDES =================================================================
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QToolButton>
#include <QAction>
#include <QFrame>
#include <QMouseEvent>
#include <QFont>
#include <QDialog>
#include <OpenFlipper/common/GlobalOptions.hh>
#include "SideElement.hh"
//== IMPLEMENTATION ==========================================================
SideElement::SideElement (SideArea *_parent, QWidget *_w, QString _name) :
parent_ (_parent),