Commit 01d5ccb2 authored by Jan Möbius's avatar Jan Möbius

A lot of work for view modes (new widget, basic toolbar implementations

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7237 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 82fa72ef
......@@ -98,6 +98,15 @@ class ViewModeInterface {
* @param _usedWidgets list of used toolbars
*/
virtual void defineViewModeToolbars(QString /*_mode*/, QStringList /*_usedToolbars*/){};
/** \brief Defines an Icon for a ViewMode
*
* With this function you can define an Icon associated with this view mode
*
* @param _mode name of the ViewMode
* @param _iconName Name of the Icon used for this view mode
*/
virtual void defineViewModeIcon(QString /*_mode*/, QString /*_iconName*/){};
};
......
......@@ -81,7 +81,8 @@ class PluginInfo{
rpcFunctions.clear();
slotInfos.clear();
keys.clear();
widgets.clear();
toolboxWidgets.clear();
toolbars.clear();
optionsWidget = 0;
}
......@@ -97,7 +98,8 @@ class PluginInfo{
rpcFunctions = _i.rpcFunctions;
slotInfos = _i.slotInfos;
keys = _i.keys;
widgets = _i.widgets;
toolboxWidgets = _i.toolboxWidgets;
toolbars = _i.toolbars;
optionsWidget = _i.optionsWidget;
}
......@@ -128,8 +130,11 @@ class PluginInfo{
/// List of registered keys with description
QList< KeyBinding > keys;
/// Pointer to plugins toolbar widget (if available)
std::vector< std::pair< QString , QWidget* > > widgets;
/// Pointer to plugins toolbox widget (if available)
std::vector< std::pair< QString , QWidget* > > toolboxWidgets;
/// Pointer to plugins toolbox widget (if available)
std::vector< std::pair< QString , QToolBar* > > toolbars;
/// Pointer to plugins options widget (if available)
QWidget* optionsWidget;
......
......@@ -312,10 +312,10 @@ void Core::unloadPlugin(QString name){
name_nospace.remove(" ");
if ( coreWidget_->viewModes_[0]->visibleToolboxes.contains(name_nospace) )
coreWidget_->viewModes_[0]->visibleToolboxes.removeAt(coreWidget_->viewModes_[0]->visibleToolboxes.indexOf(name_nospace));
for ( uint j = 0 ; j < plugins[i].widgets.size() ; ++j )
if (plugins[i].widgets[j].second ){
plugins[i].widgets[j].second->setVisible(false);
delete plugins[i].widgets[j].second;
for ( uint j = 0 ; j < plugins[i].toolboxWidgets.size() ; ++j )
if (plugins[i].toolboxWidgets[j].second ){
plugins[i].toolboxWidgets[j].second->setVisible(false);
delete plugins[i].toolboxWidgets[j].second;
}
plugins.erase(plugins.begin() + i);
......@@ -595,12 +595,12 @@ void Core::loadPlugin(QString filename, bool silent){
QWidget* widget = 0;
if ( toolboxPlugin->initializeToolbox( widget ) ) {
info.widgets.push_back( std::pair< QString,QWidget* >( info.name , widget) );
info.toolboxWidgets.push_back( std::pair< QString,QWidget* >( info.name , widget) );
// add widget name to viewMode 'all'
if ( !viewModes_[0]->visibleToolboxes.contains(info.name) ){
viewModes_[0]->visibleToolboxes << info.name;
viewModes_[0]->visibleToolboxes.sort();
viewModes_[0]->visibleToolboxes << info.name;
viewModes_[0]->visibleToolboxes.sort();
}
}
......@@ -625,6 +625,10 @@ void Core::loadPlugin(QString filename, bool silent){
connect(plugin, SIGNAL( defineViewModeToolbars(QString, QStringList) ),
coreWidget_, SLOT( slotAddViewModeToolbars(QString, QStringList) ),Qt::DirectConnection );
if ( checkSignal(plugin, "defineViewModeIcon(QString,QString)"))
connect(plugin, SIGNAL( defineViewModeIcon(QString, QString) ),
coreWidget_, SLOT( slotSetViewModeIcon(QString, QString) ),Qt::DirectConnection );
}
//Check if the plugin supports Options-Interface
......@@ -658,6 +662,7 @@ void Core::loadPlugin(QString filename, bool silent){
if ( checkSignal(plugin,"getToolBar(QString,QToolBar*&)") )
connect(plugin,SIGNAL(getToolBar(QString,QToolBar*&)),
coreWidget_,SLOT(getToolBar(QString,QToolBar*&)),Qt::DirectConnection);
}
//Check if the plugin supports StatusBar-Interface
......
......@@ -72,12 +72,12 @@ void Core::applyOptions(){
//Set default Viewmode
if (OpenFlipper::Options::defaultToolboxMode() != "")
coreWidget_->slotChangeView(OpenFlipper::Options::defaultToolboxMode(), QStringList());
coreWidget_->slotChangeView(OpenFlipper::Options::defaultToolboxMode(), QStringList(), QStringList());
//Set Fullscreen
if ( OpenFlipper::Options::fullScreen() )
coreWidget_->setWindowState( coreWidget_->windowState() | Qt::WindowFullScreen);
else
coreWidget_->setWindowState( (coreWidget_->windowState() | Qt::WindowFullScreen) ^ Qt::WindowFullScreen);
coreWidget_->setWindowState( (coreWidget_->windowState() | Qt::WindowFullScreen) ^ Qt::WindowFullScreen);
// Logger
coreWidget_->showLogger( OpenFlipper::Options::loggerState() );
......
......@@ -173,7 +173,7 @@ void Core::addToolbox(QString _name ,QWidget* _widget) {
}
}
plugins[id].widgets.push_back( std::pair< QString,QWidget* >( _name , _widget) );
plugins[id].toolboxWidgets.push_back( std::pair< QString,QWidget* >( _name , _widget) );
// add widget name to viewMode 'all'
if ( !viewModes_[0]->visibleToolboxes.contains(_name) ){
......
......@@ -106,6 +106,10 @@ struct ViewMode{
/// Name of the View Mode
QString name;
/// Icon of the View Mode
/// TODO Specify size for Icons
QString icon;
/// Is this a user defined custom view mode or a plugin generated one
bool custom;
......@@ -404,9 +408,15 @@ public:
/// Add or change Toolbars for a ViewMode (_custom == userdefined viewMode)
void slotAddViewModeToolbars(QString _mode, bool _custom, QStringList _usedToolbars);
/// Completly configure a view mode ( set toolbars, toolboxes ... )
void slotAddViewModeComplete(QString _mode , bool _custom, QStringList _toolboxes, QStringList _toolbars);
/// Sets the Icon for a given View Mode
void slotSetViewModeIcon(QString _mode, QString _iconName);
/// Slot for Changing visible toolWidgets
void slotChangeView(QString _mode, QStringList _toolWidgets);
void slotChangeView(QString _mode, QStringList _toolboxWidgets, QStringList _toolbars);
private slots:
/// Remove viewMode
......
......@@ -72,6 +72,13 @@ void CoreWidget::slotAddToolbar(QToolBar* _toolbar) {
_toolbar->setObjectName( _toolbar->windowTitle() );
toolbars_.push_back( _toolbar );
addToolBar( _toolbar );
// add widget name to viewMode 'all'
if ( !viewModes_[0]->visibleToolbars.contains( _toolbar->windowTitle() ) ){
viewModes_[0]->visibleToolbars << _toolbar->windowTitle();
viewModes_[0]->visibleToolbars.sort();
}
}
void CoreWidget::getToolBar( QString _name, QToolBar*& _toolbar) {
......
......@@ -91,22 +91,40 @@ void CoreWidget::slotAddViewModeToolboxes(QString _mode, QStringList _usedWidget
}
void CoreWidget::slotAddViewModeToolboxes(QString _mode, bool _custom, QStringList _usedWidgets){
ViewMode* vm = new ViewMode();
vm->name = _mode;
vm->custom = _custom;
vm->visibleToolboxes = _usedWidgets;
if (_custom)
viewModes_.push_back(vm);
else{
//insert before custom viewModes
int i = viewModes_.size();
for (int k=0; k < viewModes_.size(); k++)
if (viewModes_[k]->custom == true){
i = k;
break;
}
viewModes_.insert(i,vm);
int id = -1;
// Check if it already exists
for ( int i = 0 ; i < viewModes_.size(); i++) {
if ( viewModes_[i]->name == _mode ) {
id = i;
break;
}
}
ViewMode* vm = 0;
if ( id == -1 ) {
vm = new ViewMode();
vm->name = _mode;
vm->custom = _custom;
if (_custom) {
viewModes_.push_back(vm);
} else {
//insert before custom viewModes
int i = viewModes_.size();
for (int k=0; k < viewModes_.size(); k++)
if (viewModes_[k]->custom == true){
i = k;
break;
}
viewModes_.insert(i,vm);
}
} else {
vm = viewModes_[id];
}
vm->visibleToolboxes = _usedWidgets;
initViewModes();
}
......@@ -115,7 +133,46 @@ void CoreWidget::slotAddViewModeToolbars(QString _mode, QStringList _usedToolbar
}
void CoreWidget::slotAddViewModeToolbars(QString _mode, bool _custom, QStringList _usedToolbars) {
std::cerr << "Todo: Implement Toolbar View Modes" << std::endl;
int id = -1;
// Check if it already exists
for ( int i = 0 ; i < viewModes_.size(); i++) {
if ( viewModes_[i]->name == _mode ) {
id = i;
break;
}
}
ViewMode* vm = 0;
if ( id == -1 ) {
vm = new ViewMode();
vm->name = _mode;
vm->custom = _custom;
if (_custom) {
viewModes_.push_back(vm);
} else {
//insert before custom viewModes
int i = viewModes_.size();
for (int k=0; k < viewModes_.size(); k++)
if (viewModes_[k]->custom == true){
i = k;
break;
}
viewModes_.insert(i,vm);
}
} else {
vm = viewModes_[id];
}
vm->visibleToolbars = _usedToolbars;
initViewModes();
}
/// Sets the Icon for a given View Mode
void CoreWidget::slotSetViewModeIcon(QString _mode, QString _iconName) {
std::cerr << "Todo: Implement slotSetViewModeIcon" << std::endl;
}
/// Remove a viewMode
......@@ -143,9 +200,13 @@ void CoreWidget::slotSetViewMode( QAction* action){
/// Slot for setting the viewMode from menu
void CoreWidget::setViewMode( QString _mode ){
slotChangeView(_mode, QStringList());
slotChangeView(_mode, QStringList(), QStringList());
}
void CoreWidget::slotAddViewModeComplete(QString _mode , bool _custom, QStringList _toolboxes, QStringList _toolbars) {
slotAddViewModeToolbars(_mode,_custom,_toolbars);
slotAddViewModeToolboxes(_mode,_custom,_toolboxes);
}
/// show dialog for changing ViewMode
void CoreWidget::slotViewModeDialog(){
......@@ -154,32 +215,36 @@ void CoreWidget::slotViewModeDialog(){
if ( !widget ){
widget = new viewModeWidget(viewModes_);
widget->setWindowIcon( OpenFlipper::Options::OpenFlipperIcon() );
connect(widget, SIGNAL(changeView(QString, QStringList)), this, SLOT(slotChangeView(QString, QStringList)) );
connect(widget, SIGNAL(saveMode(QString, bool, QStringList)), this, SLOT(slotAddViewModeToolboxes(QString, bool, QStringList)) );
connect(widget, SIGNAL(changeView(QString, QStringList, QStringList)), this, SLOT(slotChangeView(QString, QStringList, QStringList)) );
connect(widget, SIGNAL(saveMode(QString, bool, QStringList, QStringList)), this, SLOT(slotAddViewModeComplete(QString, bool, QStringList, QStringList)) );
connect(widget, SIGNAL(removeMode(QString)), this, SLOT(slotRemoveViewMode(QString)) );
}
widget->show( OpenFlipper::Options::defaultToolboxMode() );
}
/// Slot for Changing visible toolWidgets
void CoreWidget::slotChangeView(QString _mode, QStringList _toolWidgets){
void CoreWidget::slotChangeView(QString _mode, QStringList _toolboxWidgets, QStringList _toolbars ){
//try to find Widgets if they aren't given
if (_mode != "" && _toolWidgets.size() == 0)
if (_mode != "" && _toolboxWidgets.size() == 0)
for (int i=0; i < viewModes_.size(); i++)
if (viewModes_[i]->name == _mode)
_toolWidgets = viewModes_[i]->visibleToolboxes;
_toolboxWidgets = viewModes_[i]->visibleToolboxes;
// remove all toolbox entries
toolBox_->clear ();
//find all widgets that should be visible
for (int i=0; i < _toolWidgets.size(); i++)
for (int i=0; i < _toolboxWidgets.size(); i++)
for (uint p=0; p < plugins_.size(); p++){
for ( uint j = 0 ; j < plugins_[p].widgets.size(); ++j )
if (_toolWidgets[i] == plugins_[p].widgets[j].first )
toolBox_->addItem (plugins_[p].widgets[j].second, plugins_[p].widgets[j].first);
for ( uint j = 0 ; j < plugins_[p].toolboxWidgets.size(); ++j )
if (_toolboxWidgets[i] == plugins_[p].toolboxWidgets[j].first )
toolBox_->addItem (plugins_[p].toolboxWidgets[j].second, plugins_[p].toolboxWidgets[j].first);
}
std::cerr << "TODO: Use toolbars from View Mode! " << std::endl;
if (_mode != "")
OpenFlipper::Options::defaultToolboxMode(_mode);
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>777</width>
<height>600</height>
<width>703</width>
<height>724</height>
</rect>
</property>
<property name="windowTitle">
......@@ -49,11 +49,29 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="removeButton">
<property name="text">
<string>Remove Mode</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="removeButton">
<property name="text">
<string>Remove Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="copyButton">
<property name="text">
<string>Copy Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="addButton">
<property name="text">
<string>Add Mode</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
......@@ -67,64 +85,90 @@
<attribute name="title">
<string>Toolboxes</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="_10">
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>&amp;Cancel</string>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Used</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QGridLayout" name="_7">
<item row="0" column="0">
<widget class="QListWidget" name="toolboxList">
<property name="showDropIndicator" stdset="0">
<bool>false</bool>
</property>
<property name="dragDropOverwriteMode">
<bool>false</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::NoDragDrop</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="movement">
<enum>QListView::Static</enum>
</property>
<property name="sortingEnabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="_8">
<item>
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="upButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="downButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="okButton">
<property name="text">
<string>&amp;Ok</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QGridLayout" name="_7">
<item row="0" column="0">
<widget class="QListWidget" name="toolboxList">
<property name="showDropIndicator" stdset="0">
<bool>false</bool>
</property>
<property name="dragDropOverwriteMode">
<bool>false</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::NoDragDrop</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="movement">
<enum>QListView::Static</enum>
</property>
<property name="sortingEnabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="_8">
<layout class="QVBoxLayout" name="_11">
<item>
<spacer>
<property name="orientation">
......@@ -139,21 +183,14 @@
</spacer>
</item>
<item>
<widget class="QToolButton" name="upButton">
<widget class="QToolButton" name="rightArrowToolbox">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="removeWidgetButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="downButton">
<widget class="QToolButton" name="leftArrowToolbox">
<property name="text">
<string/>
</property>
......@@ -174,37 +211,168 @@
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="saveButton">
<property name="text">
<string>Save Configuration</string>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Available</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QListWidget" name="availableToolboxes">
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<widget class="QGroupBox" name="groupBox">
<property name="minimumSize">
<size>
<width>300</width>
<height>0</height>
</size>
</property>
<property name="title">
<string>Widget</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Toolbars</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Used</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QListWidget" name="toolbarList">
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="_9">
<item>
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="rightArrowToolbar">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="leftArrowToolbar">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>Available</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QListWidget" name="availableToolbars">
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>