Commit 6dfc98b7 authored by Jan Möbius's avatar Jan Möbius
Browse files

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 3eb36f71
...@@ -98,6 +98,15 @@ class ViewModeInterface { ...@@ -98,6 +98,15 @@ class ViewModeInterface {
* @param _usedWidgets list of used toolbars * @param _usedWidgets list of used toolbars
*/ */
virtual void defineViewModeToolbars(QString /*_mode*/, QStringList /*_usedToolbars*/){}; 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{ ...@@ -81,7 +81,8 @@ class PluginInfo{
rpcFunctions.clear(); rpcFunctions.clear();
slotInfos.clear(); slotInfos.clear();
keys.clear(); keys.clear();
widgets.clear(); toolboxWidgets.clear();
toolbars.clear();
optionsWidget = 0; optionsWidget = 0;
} }
...@@ -97,7 +98,8 @@ class PluginInfo{ ...@@ -97,7 +98,8 @@ class PluginInfo{
rpcFunctions = _i.rpcFunctions; rpcFunctions = _i.rpcFunctions;
slotInfos = _i.slotInfos; slotInfos = _i.slotInfos;
keys = _i.keys; keys = _i.keys;
widgets = _i.widgets; toolboxWidgets = _i.toolboxWidgets;
toolbars = _i.toolbars;
optionsWidget = _i.optionsWidget; optionsWidget = _i.optionsWidget;
} }
...@@ -128,8 +130,11 @@ class PluginInfo{ ...@@ -128,8 +130,11 @@ class PluginInfo{
/// List of registered keys with description /// List of registered keys with description
QList< KeyBinding > keys; QList< KeyBinding > keys;
/// Pointer to plugins toolbar widget (if available) /// Pointer to plugins toolbox widget (if available)
std::vector< std::pair< QString , QWidget* > > widgets; 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) /// Pointer to plugins options widget (if available)
QWidget* optionsWidget; QWidget* optionsWidget;
......
...@@ -312,10 +312,10 @@ void Core::unloadPlugin(QString name){ ...@@ -312,10 +312,10 @@ void Core::unloadPlugin(QString name){
name_nospace.remove(" "); name_nospace.remove(" ");
if ( coreWidget_->viewModes_[0]->visibleToolboxes.contains(name_nospace) ) if ( coreWidget_->viewModes_[0]->visibleToolboxes.contains(name_nospace) )
coreWidget_->viewModes_[0]->visibleToolboxes.removeAt(coreWidget_->viewModes_[0]->visibleToolboxes.indexOf(name_nospace)); coreWidget_->viewModes_[0]->visibleToolboxes.removeAt(coreWidget_->viewModes_[0]->visibleToolboxes.indexOf(name_nospace));
for ( uint j = 0 ; j < plugins[i].widgets.size() ; ++j ) for ( uint j = 0 ; j < plugins[i].toolboxWidgets.size() ; ++j )
if (plugins[i].widgets[j].second ){ if (plugins[i].toolboxWidgets[j].second ){
plugins[i].widgets[j].second->setVisible(false); plugins[i].toolboxWidgets[j].second->setVisible(false);
delete plugins[i].widgets[j].second; delete plugins[i].toolboxWidgets[j].second;
} }
plugins.erase(plugins.begin() + i); plugins.erase(plugins.begin() + i);
...@@ -595,12 +595,12 @@ void Core::loadPlugin(QString filename, bool silent){ ...@@ -595,12 +595,12 @@ void Core::loadPlugin(QString filename, bool silent){
QWidget* widget = 0; QWidget* widget = 0;
if ( toolboxPlugin->initializeToolbox( widget ) ) { 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' // add widget name to viewMode 'all'
if ( !viewModes_[0]->visibleToolboxes.contains(info.name) ){ if ( !viewModes_[0]->visibleToolboxes.contains(info.name) ){
viewModes_[0]->visibleToolboxes << info.name; viewModes_[0]->visibleToolboxes << info.name;
viewModes_[0]->visibleToolboxes.sort(); viewModes_[0]->visibleToolboxes.sort();
} }
} }
...@@ -625,6 +625,10 @@ void Core::loadPlugin(QString filename, bool silent){ ...@@ -625,6 +625,10 @@ void Core::loadPlugin(QString filename, bool silent){
connect(plugin, SIGNAL( defineViewModeToolbars(QString, QStringList) ), connect(plugin, SIGNAL( defineViewModeToolbars(QString, QStringList) ),
coreWidget_, SLOT( slotAddViewModeToolbars(QString, QStringList) ),Qt::DirectConnection ); 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 //Check if the plugin supports Options-Interface
...@@ -658,6 +662,7 @@ void Core::loadPlugin(QString filename, bool silent){ ...@@ -658,6 +662,7 @@ void Core::loadPlugin(QString filename, bool silent){
if ( checkSignal(plugin,"getToolBar(QString,QToolBar*&)") ) if ( checkSignal(plugin,"getToolBar(QString,QToolBar*&)") )
connect(plugin,SIGNAL(getToolBar(QString,QToolBar*&)), connect(plugin,SIGNAL(getToolBar(QString,QToolBar*&)),
coreWidget_,SLOT(getToolBar(QString,QToolBar*&)),Qt::DirectConnection); coreWidget_,SLOT(getToolBar(QString,QToolBar*&)),Qt::DirectConnection);
} }
//Check if the plugin supports StatusBar-Interface //Check if the plugin supports StatusBar-Interface
......
...@@ -72,12 +72,12 @@ void Core::applyOptions(){ ...@@ -72,12 +72,12 @@ void Core::applyOptions(){
//Set default Viewmode //Set default Viewmode
if (OpenFlipper::Options::defaultToolboxMode() != "") if (OpenFlipper::Options::defaultToolboxMode() != "")
coreWidget_->slotChangeView(OpenFlipper::Options::defaultToolboxMode(), QStringList()); coreWidget_->slotChangeView(OpenFlipper::Options::defaultToolboxMode(), QStringList(), QStringList());
//Set Fullscreen //Set Fullscreen
if ( OpenFlipper::Options::fullScreen() ) if ( OpenFlipper::Options::fullScreen() )
coreWidget_->setWindowState( coreWidget_->windowState() | Qt::WindowFullScreen); coreWidget_->setWindowState( coreWidget_->windowState() | Qt::WindowFullScreen);
else else
coreWidget_->setWindowState( (coreWidget_->windowState() | Qt::WindowFullScreen) ^ Qt::WindowFullScreen); coreWidget_->setWindowState( (coreWidget_->windowState() | Qt::WindowFullScreen) ^ Qt::WindowFullScreen);
// Logger // Logger
coreWidget_->showLogger( OpenFlipper::Options::loggerState() ); coreWidget_->showLogger( OpenFlipper::Options::loggerState() );
......
...@@ -173,7 +173,7 @@ void Core::addToolbox(QString _name ,QWidget* _widget) { ...@@ -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' // add widget name to viewMode 'all'
if ( !viewModes_[0]->visibleToolboxes.contains(_name) ){ if ( !viewModes_[0]->visibleToolboxes.contains(_name) ){
......
...@@ -106,6 +106,10 @@ struct ViewMode{ ...@@ -106,6 +106,10 @@ struct ViewMode{
/// Name of the View Mode /// Name of the View Mode
QString name; 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 /// Is this a user defined custom view mode or a plugin generated one
bool custom; bool custom;
...@@ -404,9 +408,15 @@ public: ...@@ -404,9 +408,15 @@ public:
/// Add or change Toolbars for a ViewMode (_custom == userdefined viewMode) /// Add or change Toolbars for a ViewMode (_custom == userdefined viewMode)
void slotAddViewModeToolbars(QString _mode, bool _custom, QStringList _usedToolbars); 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 /// Slot for Changing visible toolWidgets
void slotChangeView(QString _mode, QStringList _toolWidgets); void slotChangeView(QString _mode, QStringList _toolboxWidgets, QStringList _toolbars);
private slots: private slots:
/// Remove viewMode /// Remove viewMode
......
...@@ -72,6 +72,13 @@ void CoreWidget::slotAddToolbar(QToolBar* _toolbar) { ...@@ -72,6 +72,13 @@ void CoreWidget::slotAddToolbar(QToolBar* _toolbar) {
_toolbar->setObjectName( _toolbar->windowTitle() ); _toolbar->setObjectName( _toolbar->windowTitle() );
toolbars_.push_back( _toolbar ); toolbars_.push_back( _toolbar );
addToolBar( _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) { void CoreWidget::getToolBar( QString _name, QToolBar*& _toolbar) {
......
...@@ -91,22 +91,40 @@ void CoreWidget::slotAddViewModeToolboxes(QString _mode, QStringList _usedWidget ...@@ -91,22 +91,40 @@ void CoreWidget::slotAddViewModeToolboxes(QString _mode, QStringList _usedWidget
} }
void CoreWidget::slotAddViewModeToolboxes(QString _mode, bool _custom, QStringList _usedWidgets){ void CoreWidget::slotAddViewModeToolboxes(QString _mode, bool _custom, QStringList _usedWidgets){
ViewMode* vm = new ViewMode(); int id = -1;
vm->name = _mode;
vm->custom = _custom; // Check if it already exists
vm->visibleToolboxes = _usedWidgets; for ( int i = 0 ; i < viewModes_.size(); i++) {
if (_custom) if ( viewModes_[i]->name == _mode ) {
viewModes_.push_back(vm); id = i;
else{ break;
//insert before custom viewModes }
int i = viewModes_.size(); }
for (int k=0; k < viewModes_.size(); k++)
if (viewModes_[k]->custom == true){ ViewMode* vm = 0;
i = k; if ( id == -1 ) {
break; vm = new ViewMode();
} vm->name = _mode;
viewModes_.insert(i,vm); 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(); initViewModes();
} }
...@@ -115,7 +133,46 @@ void CoreWidget::slotAddViewModeToolbars(QString _mode, QStringList _usedToolbar ...@@ -115,7 +133,46 @@ void CoreWidget::slotAddViewModeToolbars(QString _mode, QStringList _usedToolbar
} }
void CoreWidget::slotAddViewModeToolbars(QString _mode, bool _custom, QStringList _usedToolbars) { 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 /// Remove a viewMode
...@@ -143,9 +200,13 @@ void CoreWidget::slotSetViewMode( QAction* action){ ...@@ -143,9 +200,13 @@ void CoreWidget::slotSetViewMode( QAction* action){
/// Slot for setting the viewMode from menu /// Slot for setting the viewMode from menu
void CoreWidget::setViewMode( QString _mode ){ 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 /// show dialog for changing ViewMode
void CoreWidget::slotViewModeDialog(){ void CoreWidget::slotViewModeDialog(){
...@@ -154,32 +215,36 @@ void CoreWidget::slotViewModeDialog(){ ...@@ -154,32 +215,36 @@ void CoreWidget::slotViewModeDialog(){
if ( !widget ){ if ( !widget ){
widget = new viewModeWidget(viewModes_); widget = new viewModeWidget(viewModes_);
widget->setWindowIcon( OpenFlipper::Options::OpenFlipperIcon() ); widget->setWindowIcon( OpenFlipper::Options::OpenFlipperIcon() );
connect(widget, SIGNAL(changeView(QString, QStringList)), this, SLOT(slotChangeView(QString, QStringList)) ); connect(widget, SIGNAL(changeView(QString, QStringList, QStringList)), this, SLOT(slotChangeView(QString, QStringList, QStringList)) );
connect(widget, SIGNAL(saveMode(QString, bool, QStringList)), this, SLOT(slotAddViewModeToolboxes(QString, bool, 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)) ); connect(widget, SIGNAL(removeMode(QString)), this, SLOT(slotRemoveViewMode(QString)) );
} }
widget->show( OpenFlipper::Options::defaultToolboxMode() ); widget->show( OpenFlipper::Options::defaultToolboxMode() );
} }
/// Slot for Changing visible toolWidgets /// 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 //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++) for (int i=0; i < viewModes_.size(); i++)
if (viewModes_[i]->name == _mode) if (viewModes_[i]->name == _mode)
_toolWidgets = viewModes_[i]->visibleToolboxes; _toolboxWidgets = viewModes_[i]->visibleToolboxes;
// remove all toolbox entries // remove all toolbox entries
toolBox_->clear (); toolBox_->clear ();
//find all widgets that should be visible //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 p=0; p < plugins_.size(); p++){
for ( uint j = 0 ; j < plugins_[p].widgets.size(); ++j ) for ( uint j = 0 ; j < plugins_[p].toolboxWidgets.size(); ++j )
if (_toolWidgets[i] == plugins_[p].widgets[j].first ) if (_toolboxWidgets[i] == plugins_[p].toolboxWidgets[j].first )
toolBox_->addItem (plugins_[p].widgets[j].second, plugins_[p].widgets[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 != "") if (_mode != "")
OpenFlipper::Options::defaultToolboxMode(_mode); OpenFlipper::Options::defaultToolboxMode(_mode);
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>777</width> <width>703</width>
<height>600</height> <height>724</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -49,11 +49,29 @@ ...@@ -49,11 +49,29 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="removeButton"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="text"> <item>
<string>Remove Mode</string> <widget class="QPushButton" name="removeButton">
</property> <property name="text">
</widget> <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> </item>
</layout> </layout>
</widget> </widget>
...@@ -67,64 +85,90 @@ ...@@ -67,64 +85,90 @@
<attribute name="title"> <attribute name="title">
<string>Toolboxes</string> <string>Toolboxes</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout"> <layout class="QVBoxLayout" name="verticalLayout_7">
<item row="1" column="0" colspan="2"> <item>
<layout class="QHBoxLayout" name="_10"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
<widget class="QPushButton" name="cancelButton"> <widget class="QGroupBox" name="groupBox_3">
<property name="text"> <property name="title">
<string>&amp;Cancel</string> <string>Used</string>
</property> </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> </widget>
</item> </item>
<item> <item>
<spacer> <layout class="QVBoxLayout" name="_11">
<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">