From 8ec357bc04c282970d2c58ee3b778c812e3b025a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 17 Sep 2008 16:28:57 +0000 Subject: [PATCH] Cleanup icon mess git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@2851 383ad7c9-94d9-4d36-a494-682f7c89f535 --- widgets/coreWidget/ContextMenu.cc | 94 +++++++------- widgets/coreWidget/CoreWidget.cc | 196 +++++++++++++++--------------- 2 files changed, 145 insertions(+), 145 deletions(-) diff --git a/widgets/coreWidget/ContextMenu.cc b/widgets/coreWidget/ContextMenu.cc index 3786ce46..d8439bd8 100644 --- a/widgets/coreWidget/ContextMenu.cc +++ b/widgets/coreWidget/ContextMenu.cc @@ -12,12 +12,12 @@ // 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 . // @@ -47,12 +47,12 @@ #include #include -//== IMPLEMENTATION ========================================================== +//== IMPLEMENTATION ========================================================== void CoreWidget::slotCustomContextMenu( const QPoint& _point ) { - + updatePopupMenu(_point); - + // If not initialized, dont show it!! if ( !contextMenu_->isEmpty () ) contextMenu_->exec( examiner_widget_->mapToGlobal(_point) ); @@ -61,20 +61,20 @@ void CoreWidget::slotCustomContextMenu( const QPoint& _point ) { void CoreWidget::updatePopupMenu(const QPoint& _point) { contextMenu_->clear(); contextSelectionMenu_->clear(); - + QIcon icon; QAction* typeEntry = new QAction("No type",contextMenu_); contextMenu_->addAction( typeEntry ); - + QAction* entrySeparator = contextMenu_->addSeparator( ); - - + + QAction* contextSelectionAction = contextMenu_->addMenu( contextSelectionMenu_ ); - + // -1 if no object id found for the current picking position // otherwise the id of the object int objectId = -1; - + // Do picking in the gl area to find an object unsigned int node_idx, target_idx; ACG::Vec3d hit_point; @@ -83,19 +83,19 @@ void CoreWidget::updatePopupMenu(const QPoint& _point) { if ( PluginFunctions::get_picked_object(node_idx, object) ) objectId = object->id(); } - + int topLevelAdded = 0; - + if ( objectId != -1) { - + // Add an empty Menu defining the current Type if ( object->dataType() == DATA_POLY_MESH ){ typeEntry->setText("Poly Mesh"); - icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"PolyType.png"); + icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"PolyType.svg"); typeEntry->setIcon(icon); } else if ( object->dataType() == DATA_TRIANGLE_MESH ) { typeEntry->setText("Triangle Mesh"); - icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"TriangleType.png"); + icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"TriangleType.svg"); typeEntry->setIcon(icon); } else if ( object->dataType() == DATA_POLY_LINE ) { typeEntry->setText("Poly Line"); @@ -103,14 +103,14 @@ void CoreWidget::updatePopupMenu(const QPoint& _point) { typeEntry->setIcon(icon); } else if ( object->dataType() == DATA_BSPLINE_CURVE ) { typeEntry->setText("BSpline Curve"); - icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"BSplineCurveType.png"); + icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"BSplineCurveType.svg"); typeEntry->setIcon(icon); } - - + + // Add real context Menus first for ( uint i = 0 ; i < contextMenus_.size(); ++i ) { - + // check if the dataType of the object matches the context type if ( object->dataType( contextMenus_[i].contextType ) ) { if ( contextMenus_[i].position == CONTEXTTOPLEVELMENU ) { @@ -119,20 +119,20 @@ void CoreWidget::updatePopupMenu(const QPoint& _point) { } else if ( contextMenus_[i].position == CONTEXTSELECTIONMENU ) { contextSelectionMenu_->addMenu(contextMenus_[i].menu); } - - // Get all Actions in the menu and its submenus. + + // Get all Actions in the menu and its submenus. // Set their data to the picked Object id QList< QAction *> allActions = contextMenus_[i].menu->actions(); while ( !allActions.empty() ) { QList< QAction *> tmpList; - + // Set userdata of all actions to the picked Object Id for ( int j = 0 ; j < allActions.size(); ++j ) { - allActions[j]->setData( QVariant( objectId ) ); - if ( allActions[j]->menu() != 0 ) + allActions[j]->setData( QVariant( objectId ) ); + if ( allActions[j]->menu() != 0 ) tmpList << allActions[j]->menu()->actions(); } - + allActions = tmpList; } } @@ -141,62 +141,62 @@ void CoreWidget::updatePopupMenu(const QPoint& _point) { contextMenu_->removeAction(typeEntry); contextMenu_->removeAction(entrySeparator); } - - if ( contextSelectionMenu_->isEmpty() ) + + if ( contextSelectionMenu_->isEmpty() ) contextMenu_->removeAction( contextSelectionAction ); - + if ( topLevelAdded > 0 ) contextMenu_->addSeparator(); - + emit updateContextMenu(objectId); - + // Add persistent context Menus as second part for ( uint i = 0 ; i < persistentContextMenus_.size(); ++i ) { contextMenu_->addMenu( persistentContextMenus_[i].menu ); - - // Get all Actions in the menu and its submenus. + + // Get all Actions in the menu and its submenus. // Set their data to the picked Object id QList< QAction *> allActions = persistentContextMenus_[i].menu->actions(); while ( !allActions.empty() ) { QList< QAction *> tmpList; - + // Set userdata of all actions to the picked Object Id for ( int j = 0 ; j < allActions.size(); ++j ) { - allActions[j]->setData( QVariant( objectId ) ); - if ( allActions[j]->menu() != 0 ) + allActions[j]->setData( QVariant( objectId ) ); + if ( allActions[j]->menu() != 0 ) tmpList << allActions[j]->menu()->actions(); } - + allActions = tmpList; } - + } - + // Only add Separator if we had plugin context menus if ( persistentContextMenus_.size() > 0 ) contextMenu_->addSeparator(); - + if (examiner_widget_->getPickMenu() != NULL) { examiner_widget_->getPickMenu()->setTitle("&Picking"); contextMenu_->addMenu(examiner_widget_->getPickMenu() ); examiner_widget_->getPickMenu()->setTearOffEnabled(true); } - + if (examiner_widget_->getFuncMenu() != NULL) { examiner_widget_->getFuncMenu()->setTitle("&Functions"); contextMenu_->addMenu(examiner_widget_->getFuncMenu() ); examiner_widget_->getFuncMenu()->setTearOffEnabled(true); } - + if (examiner_widget_->getDrawMenu() != NULL) { - + examiner_widget_->getDrawMenu()->setTitle("&DrawModes"); QAction* drawMenuAction = contextMenu_->addMenu(examiner_widget_->getDrawMenu() ); - + QIcon icon; icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"drawModes.png"); drawMenuAction->setIcon(icon); - + examiner_widget_->getDrawMenu()->setTearOffEnabled(true); } } @@ -204,7 +204,7 @@ void CoreWidget::updatePopupMenu(const QPoint& _point) { void CoreWidget::slotAddContextMenu(QMenu* _menu) { MenuInfo info; info.menu = _menu; - + persistentContextMenus_.push_back(info); } @@ -213,7 +213,7 @@ void CoreWidget::slotAddContextMenu( QMenu* _menu , DataType _dataType ,ContextM info.menu = _menu; info.contextType = _dataType; info.position = _type; - + contextMenus_.push_back(info); } diff --git a/widgets/coreWidget/CoreWidget.cc b/widgets/coreWidget/CoreWidget.cc index 19e55afb..9fe23339 100644 --- a/widgets/coreWidget/CoreWidget.cc +++ b/widgets/coreWidget/CoreWidget.cc @@ -12,12 +12,12 @@ // 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 . // @@ -54,10 +54,10 @@ #define WIDGET_HEIGHT 800 #define WIDGET_WIDTH 800 -//== IMPLEMENTATION ========================================================== +//== IMPLEMENTATION ========================================================== -/** \brief Constuctor for the Core Widget - * +/** \brief Constuctor for the Core Widget + * */ CoreWidget:: CoreWidget( QVector& _viewModes, @@ -77,21 +77,21 @@ CoreWidget( QVector& _viewModes, viewMenu_(0), fileMenuEnd_(0), contextMenu_(0), - contextSelectionMenu_(0), + contextSelectionMenu_(0), stackMenu_(0), stackedWidget_(0), helpBrowserDeveloper_(0), helpBrowserUser_(0), optionsWidget_(0), plugins_(_plugins) - + { setupStatusBar(); - + splitter_ = new QSplitter(Qt::Vertical,this); setCentralWidget(splitter_); stackedWidget_ = new QStackedWidget(splitter_); - + // ====================================================================== // Set up the logging window // ====================================================================== @@ -100,27 +100,27 @@ CoreWidget( QVector& _viewModes, textedit_->setSizePolicy( QSizePolicy ( QSizePolicy::Preferred , QSizePolicy::Preferred ) ); textedit_->resize( splitter_->width() ,120); textedit_->setLineWrapMode( QTextEdit::NoWrap ); - + QList wsizes( splitter_->sizes() ); if (OpenFlipper::Options::hideLogger()) { wsizes[1] = 0; splitter_->setSizes(wsizes); } - + // ====================================================================== // Create examiner // ====================================================================== QGLFormat format; QGLFormat::setDefaultFormat(format); format.setStereo( OpenFlipper::Options::stereo() ); - examiner_widget_ = new ACG::QtWidgets::QtExaminerViewer(stackedWidget_, - "Examiner Widget", - statusBar_ , + examiner_widget_ = new ACG::QtWidgets::QtExaminerViewer(stackedWidget_, + "Examiner Widget", + statusBar_ , &format); examiner_widget_->sceneGraph( PluginFunctions::getSceneGraphRootNode() ); examiner_widget_->enablePopupMenu(false); stackedWidget_->addWidget(examiner_widget_); - + // ====================================================================== // Setup dragging for examiner widget // ====================================================================== @@ -130,104 +130,104 @@ CoreWidget( QVector& _viewModes, connect( examiner_widget_, SIGNAL(dragEnterEvent( QDragEnterEvent*)), this, SLOT(dragEnterEvent(QDragEnterEvent* ))); connect( examiner_widget_, SIGNAL(dropEvent( QDropEvent*)), - this, SLOT(dropEvent(QDropEvent* ))); - + this, SLOT(dropEvent(QDropEvent* ))); + // ====================================================================== // Create main Toolbar // ====================================================================== - + mainToolbar_ = new QToolBar("Main Toolbar"); addToolBar(mainToolbar_); - + // ====================================================================== // Get Toolbar from examiner and integrate it into main window // ====================================================================== - + // Take control over the toolbar viewerToolbar_ = examiner_widget_->removeToolBar(); addToolBar(Qt::TopToolBarArea,viewerToolbar_); viewerToolbar_->setParent(this); viewerToolbar_->setAllowedAreas(Qt::AllToolBarAreas); viewerToolbar_->setIconSize(QSize(20,20)); - + // Set our own Icons QList actions = viewerToolbar_->actions(); for ( int i = 0 ; i < actions.size(); ++i ) { if ( actions[i]->text() == "Move" ) { QIcon icon; icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"transform-move.png"); - + QToolButton * button = qobject_cast( viewerToolbar_->widgetForAction ( actions[i] ) ); button->setIcon(icon); } else if ( actions[i]->text() == "Home" ) { QIcon icon; icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"go-home.png"); - + QToolButton * button = qobject_cast( viewerToolbar_->widgetForAction ( actions[i] ) ); button->setIcon(icon); } else if ( actions[i]->text() == "Set Home" ) { QIcon icon; icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"set-home.png"); - + QToolButton * button = qobject_cast( viewerToolbar_->widgetForAction ( actions[i] ) ); button->setIcon(icon); } else if ( actions[i]->text() == "Light" ) { QIcon icon; icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"ktip.png"); - + QToolButton * button = qobject_cast( viewerToolbar_->widgetForAction ( actions[i] ) ); button->setIcon(icon); } else if ( actions[i]->text() == "Question" ) { QIcon icon; icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"help-about.png"); - + QToolButton * button = qobject_cast( viewerToolbar_->widgetForAction ( actions[i] ) ); button->setIcon(icon); } else if ( actions[i]->text() == "SceneGraph" ) { QIcon icon; icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"scenegraph.png"); - + QToolButton * button = qobject_cast( viewerToolbar_->widgetForAction ( actions[i] ) ); button->setIcon(icon); } else if ( actions[i]->text() == "Pick" ) { // QIcon icon; // icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"scenegraph.png"); -// +// // QToolButton * button = qobject_cast( viewerToolbar_->widgetForAction ( actions[i] ) ); // button->setIcon(icon); } else if ( actions[i]->text() == "View All" ) { // QIcon icon; // icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"scenegraph.png"); -// +// // QToolButton * button = qobject_cast( viewerToolbar_->widgetForAction ( actions[i] ) ); // button->setIcon(icon); } else if ( actions[i]->text() == "Projection" ) { // QIcon icon; // icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"scenegraph.png"); -// +// // QToolButton * button = qobject_cast( viewerToolbar_->widgetForAction ( actions[i] ) ); // button->setIcon(icon); } else if ( actions[i]->text() == "Stereo" ) { // QIcon icon; // icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"scenegraph.png"); -// +// // QToolButton * button = qobject_cast( viewerToolbar_->widgetForAction ( actions[i] ) ); // button->setIcon(icon); } - -// else -// std::cerr << actions[i]->text().toStdString() << std::endl; + +// else +// std::cerr << actions[i]->text().toStdString() << std::endl; } - + stackWidgetList_.push_back( StackWidgetInfo( false, "3D Examiner Widget", examiner_widget_ ) ); - + // Remember logger size wsizes = splitter_->sizes(); originalLoggerSize_ = wsizes[1]; - + // ====================================================================== // Create Upper DockWidget for ToolWidget control - // ====================================================================== + // ====================================================================== dockViewMode_ = new QDockWidget("ViewMode" , this ); QPushButton* button = new QPushButton("Change View Mode"); dockViewMode_->setWidget(button); @@ -237,21 +237,21 @@ CoreWidget( QVector& _viewModes, addDockWidget(Qt::RightDockWidgetArea,dockViewMode_); connect(button, SIGNAL(clicked()), this, SLOT(slotViewModeDialog())); dockViewMode_->setVisible(false); - + // ====================================================================== // Context menu setup // ====================================================================== - - connect( examiner_widget_ , SIGNAL(signalCustomContextMenuRequested( const QPoint&) ) , + + connect( examiner_widget_ , SIGNAL(signalCustomContextMenuRequested( const QPoint&) ) , this , SLOT( slotCustomContextMenu( const QPoint&) ) ); - + contextMenu_ = new QMenu(0); contextSelectionMenu_ = new QMenu("Selection",0); - + setupMenuBar(); - + updateRecent(); - + statusBar_->showMessage("Ready", 5000); //register keys for coreWidget @@ -267,7 +267,7 @@ CoreWidget( QVector& _viewModes, CoreWidget::~CoreWidget() { - + } //----------------------------------------------------------------------------- @@ -290,22 +290,22 @@ void CoreWidget::toggleLogger() { // toggle OpenFlipper::Options::hideLogger( !OpenFlipper::Options::hideLogger() ); - + //Hide Logger if ( OpenFlipper::Options::hideLogger() ) { QList wsizes( splitter_->sizes() ); - + // Remember old size originalLoggerSize_ = wsizes[1]; - + wsizes[0] = wsizes[0]+wsizes[1]; wsizes[1] = 0; splitter_->setSizes(wsizes); } else { - - if ( originalLoggerSize_ == 0) + + if ( originalLoggerSize_ == 0) originalLoggerSize_ = 240; - + QList wsizes( splitter_->sizes() ); wsizes[0] = wsizes[0]+wsizes[1] - originalLoggerSize_; wsizes[1] = originalLoggerSize_; @@ -319,18 +319,18 @@ CoreWidget::toggleLogger() { */ void CoreWidget::toggleToolbox() { - + //toggle OpenFlipper::Options::hideToolbox(!OpenFlipper::Options::hideToolbox()); - 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 - dockViewMode_->setVisible(false); + dockViewMode_->setVisible(false); }else{ //reset last ViewMode @@ -340,37 +340,37 @@ CoreWidget::toggleToolbox() { setViewMode( OpenFlipper::Options::defaultToolboxMode() ); } } - + //----------------------------------------------------------------------------- - + /** Handles keypress events or passes them to plugins */ void CoreWidget::keyPressEvent(QKeyEvent* _e) { if (_e->modifiers() == Qt::ControlModifier ) { - switch (_e->key()) + switch (_e->key()) { case Qt::Key_F : toggleFullscreen(); return; - + case Qt::Key_L : toggleLogger(); return; - + case Qt::Key_T : toggleToolbox(); return; - + // Send remaining events to plugins - default: + default: mapKeyPressEvent(_e); return; - } + } } - - switch (_e->key()) + + switch (_e->key()) { // Send remaining events to plugins default: @@ -382,7 +382,7 @@ CoreWidget::keyPressEvent(QKeyEvent* _e) //----------------------------------------------------------------------------- /** Handle Key Release Events */ -void +void CoreWidget::keyReleaseEvent(QKeyEvent* _e) { mapKeyReleaseEvent(_e); } @@ -395,7 +395,7 @@ CoreWidget::mapKeyPressEvent(QKeyEvent* _e){ //find the first plugin which wants to handle that key for (uint i=0; i < plugins_.size(); i++) for (int k=0; k < plugins_[i].keys.count(); k++) - if ( plugins_[i].keys[k].key == _e->key() + if ( plugins_[i].keys[k].key == _e->key() && plugins_[i].keys[k].modifiers == _e->modifiers() ){ KeyInterface* keyPlugin = qobject_cast< KeyInterface * >(plugins_[i].plugin); @@ -507,74 +507,74 @@ CoreWidget::slotRegisterKey(int _key, Qt::KeyboardModifiers _modifiers, QString //============================================================================= -void -CoreWidget::addRecent(QString _filename, DataType _type) +void +CoreWidget::addRecent(QString _filename, DataType _type) { //dont add objects within INI files to recentMenu - if ( OpenFlipper::Options::openingIni() ) return; - + if ( OpenFlipper::Options::openingIni() ) return; + OpenFlipper::Options::addRecentFile(_filename, _type); - + updateRecent(); - -} - -//============================================================================= - -void -CoreWidget::updateRecent() + +} + +//============================================================================= + +void +CoreWidget::updateRecent() { if ( recentFilesMenu_ == NULL) return; - + recentFilesMenu_->clear(); QVector< OpenFlipper::Options::RecentFile > recentFiles = OpenFlipper::Options::recentFiles(); for (int i = 0 ; i < recentFiles.size() ; ++i ) { QString path = OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator(); switch(recentFiles[i].type){ - case DATA_TRIANGLE_MESH: - path += "TriangleType.png"; break; - case DATA_POLY_MESH: - path += "PolyType.png"; break; - case DATA_POLY_LINE: - path += "PolyLineType.png"; break; - case DATA_BSPLINE_CURVE: - path += "BSplineCurveType.png"; break; + case DATA_TRIANGLE_MESH: + path += "TriangleType.svg"; break; + case DATA_POLY_MESH: + path += "PolyType.svg"; break; + case DATA_POLY_LINE: + path += "PolyLineType.svg"; break; + case DATA_BSPLINE_CURVE: + path += "BSplineCurveType.svg"; break; default: path = ""; } - recentFilesMenu_->addAction(QIcon(path), recentFiles[i].filename); + recentFilesMenu_->addAction(QIcon(path), recentFiles[i].filename); } - -} -void +} + +void CoreWidget::closeEvent ( QCloseEvent * /* event */ ) { emit exit(); } void CoreWidget::showOptionsWidget() { - + if ( OpenFlipper::Options::nogui() ) return; - + if ( optionsWidget_ == 0 ) { optionsWidget_ = new OptionsWidget(plugins_, coreKeys_, 0); connect(optionsWidget_,SIGNAL(applyOptions()),this,SIGNAL(applyOptions())); connect(optionsWidget_,SIGNAL(saveOptions()),this,SIGNAL(saveOptions())); } - //show the optionsWidget centered + //show the optionsWidget centered QPoint center; - center.setX( x() + width() / 2 ); + center.setX( x() + width() / 2 ); center.setY( y() + height() / 2 ); optionsWidget_->setGeometry(center.x() - optionsWidget_->width() / 2, center.y() - optionsWidget_->height()/ 2, optionsWidget_->width(), optionsWidget_->height()); optionsWidget_->show(); - + } - + //============================================================================= -- GitLab