Commit 549513b8 authored by Jan Möbius's avatar Jan Möbius

Added ViewMode Change Dialog

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7290 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 8e057d46
......@@ -456,11 +456,15 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
QHBoxLayout *hLayout = new QHBoxLayout;
QPushButton* vmButton = new QPushButton(tr("Change View Mode"));
hLayout->addWidget (vmButton);
vmChangeButton_ = new QPushButton(tr("Change View Mode"));
QPushButton* vmEditButton = new QPushButton(tr("Edit View Modes"));
hLayout->addWidget(vmChangeButton_);
hLayout->addWidget(vmEditButton);
gb->setLayout (hLayout);
connect(vmButton, SIGNAL(clicked()), this, SLOT(slotViewModeDialog()));
connect(vmChangeButton_, SIGNAL(clicked()), this, SLOT(slotViewChangeDialog()));
connect(vmEditButton, SIGNAL(clicked()), this, SLOT(slotViewModeDialog()));
toolBoxScroll_ = new QScrollArea ();
toolBox_ = new SideArea ();
......
......@@ -429,8 +429,11 @@ public:
void slotSetViewMode( QAction* action);
/// Show a dialog in which the viewMode can be changed
/// Show a dialog in which the viewMode can be edited
void slotViewModeDialog();
/// Show a dialog in which the viewMode can be changed
void slotViewChangeDialog();
/// Set the view Mode to the given Mode
public slots :
......@@ -488,6 +491,9 @@ public:
/// Widget for toolBox
QWidget* toolBoxArea_;
/// Button to change viewModes
QPushButton* vmChangeButton_;
/// Spliter between toplevel objects and toolbox
QSplitter* toolSplitter_;
......
......@@ -45,6 +45,7 @@
#include "CoreWidget.hh"
#include <OpenFlipper/widgets/viewModeWidget/viewModeWidget.hh>
#include <OpenFlipper/widgets/viewModeWidget/viewModeChangeWidget.hh>
#include "OpenFlipper/common/GlobalOptions.hh"
......@@ -265,6 +266,26 @@ void CoreWidget::slotViewModeDialog(){
widget->show( OpenFlipper::Options::defaultToolboxMode() );
}
void CoreWidget::slotViewChangeDialog() {
//init widget
static viewModeChangeWidget* modeChangeWidget = 0;
if ( !modeChangeWidget ){
modeChangeWidget = new viewModeChangeWidget(viewModes_, this);
modeChangeWidget->setWindowIcon( OpenFlipper::Options::OpenFlipperIcon() );
connect(modeChangeWidget, SIGNAL(changeView(QString, QStringList, QStringList)), this, SLOT(slotChangeView(QString, QStringList, QStringList)) );
}
// Make it look like a dialog
modeChangeWidget->setWindowFlags(Qt::Popup);
modeChangeWidget->show( OpenFlipper::Options::defaultToolboxMode() );
// Move it to the position of the push button
QPoint posButton = vmChangeButton_->mapToGlobal(vmChangeButton_->pos());
modeChangeWidget->move( posButton);
}
/// Slot for Changing visible toolWidgets
void CoreWidget::slotChangeView(QString _mode, QStringList _toolboxWidgets, QStringList _toolbars ){
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ViewModeChangeDialog</class>
<widget class="QDialog" name="ViewModeChangeDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>389</width>
<height>341</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Choose View Mode</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item>
<widget class="QListWidget" name="viewModeList">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>380</width>
<height>16777215</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<property name="midLineWidth">
<number>0</number>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="iconSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="movement">
<enum>QListView::Static</enum>
</property>
<property name="flow">
<enum>QListView::LeftToRight</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>true</bool>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
</property>
<property name="viewMode">
<enum>QListView::IconMode</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
* *
* 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 with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* 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 LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 7287 $ *
* $Author: moebius $ *
* $Date: 2009-10-01 12:43:17 +0200 (Do, 01. Okt 2009) $ *
* *
\*===========================================================================*/
#include "viewModeChangeWidget.hh"
#include <OpenFlipper/widgets/coreWidget/CoreWidget.hh>
#include <OpenFlipper/common/GlobalOptions.hh>
#include <QInputDialog>
#include <QMessageBox>
/// Constructor
viewModeChangeWidget::viewModeChangeWidget(const QVector< ViewMode* >& _modes, QWidget *_parent)
: QDialog(_parent),
modes_(_modes)
{
setupUi(this);
connect(viewModeList, SIGNAL(clicked (QModelIndex)), this, SLOT(slotModeClicked(QModelIndex)) );
}
// =======================================================================================================
// External communication
// =======================================================================================================
/// Slot for changing View and closing widget
void viewModeChangeWidget::slotModeClicked(QModelIndex _idx ){
// Search for current mode
int id = -1;
if ( viewModeList->selectedItems().count() > 0)
for (int i=0; i < modes_.size(); i++)
if (modes_[i]->name == viewModeList->currentItem()->text()){
id = i;
break;
}
if ( id == -1 ) {
std::cerr << "Currently selected Mode not found?!" << std::endl;
return;
}
emit changeView(modes_[id]->name,modes_[id]->visibleToolboxes,modes_[id]->visibleToolbars);
close();
}
/// overloaded show function
void viewModeChangeWidget::show(QString _lastMode){
QDialog::show();
//fill viewModeList
viewModeList->clear();
for (int i=0; i < modes_.size(); i++){
QListWidgetItem *item = new QListWidgetItem(viewModeList);
item->setTextAlignment(Qt::AlignHCenter);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
item->setIcon(QIcon(OpenFlipper::Options::iconDirStr() + QDir::separator () + modes_[i]->icon));
item->setText(modes_[i]->name);
if (modes_[i]->custom)
viewModeList->item(i)->setForeground( QBrush(QColor(0,0,150) ) );
else
viewModeList->item(i)->setForeground( QBrush(QColor(0,0,0) ) );
}
//select given mode
viewModeList->setCurrentRow(0);
for (int i=0; i < viewModeList->count(); i++)
if (viewModeList->item(i)->text() == _lastMode)
viewModeList->setCurrentRow(i);
}
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
* *
* 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 with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* 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 LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 7238 $ *
* $Author: moebius $ *
* $Date: 2009-09-30 17:06:50 +0200 (Mi, 30. Sep 2009) $ *
* *
\*===========================================================================*/
#ifndef VIEWMODECHANGEWIDGET_HH
#define VIEWMODECHANGEWIDGET_HH
#include "ui_viewModeChange.hh"
#include <QStringList>
#include <QVector>
struct ViewMode;
class viewModeChangeWidget : public QDialog, public Ui::ViewModeChangeDialog
{
Q_OBJECT
private:
// Vector holding list of all available modes
const QVector< ViewMode* >& modes_;
public:
viewModeChangeWidget(const QVector< ViewMode* >& _modes, QWidget *parent = 0 );
void show(QString _lastMode);
private slots:
void slotModeClicked(QModelIndex _id);
signals:
/// Changes the view mode to the currently configured one
void changeView(QString _mode, QStringList _toolboxWidgets, QStringList _toolbars);
};
#endif //VIEWMODECHANGEWIDGET_HH
......@@ -234,6 +234,8 @@ void viewModeWidget::slotModeContextMenu ( const QPoint & _pos ){
break;
}
menu.addAction(tr("Copy Mode"), this, SLOT ( slotCopyMode() ));
menu.exec(viewModeList->mapToGlobal( _pos) );
}
}
......
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