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 { ...@@ -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);
......
This diff is collapsed.
This diff is collapsed.
...@@ -56,27 +56,144 @@ class viewModeWidget : public QDialog, public Ui::viewMode ...@@ -56,27 +56,144 @@ class viewModeWidget : public QDialog, public Ui::viewMode
{ {
Q_OBJECT Q_OBJECT
private: private:
// Vector holding list of all available modes
const QVector< ViewMode* >& modes_; const QVector< ViewMode* >& modes_;
public: public:
viewModeWidget(const QVector< ViewMode* >& _modes, QWidget *parent = 0 ); viewModeWidget(const QVector< ViewMode* >& _modes, QWidget *parent = 0 );
void show(QString _lastMode); void show(QString _lastMode);
signals:
void saveMode(QString _name, bool _custom, QStringList _toolWidgets);
void removeMode(QString _name);
void changeView(QString _mode, QStringList _toolWidgets);
private slots: private slots:
void slotMoveUp();
void slotMoveDown();
void slotRemoveWidget();
void slotRemoveMode();
void slotChangeView();
void slotModeChanged(QString _mode); void slotModeChanged(QString _mode);
void slotModeClicked(QModelIndex _id); void slotModeClicked(QModelIndex _id);
void slotSaveMode();
void slotSetToolWidgets();
/// Context Menus // ============================================
void slotModeContextMenu ( const QPoint & _pos ); // ViewMode Buttons
void slotToolContextMenu ( const QPoint & _pos ); // ============================================
/** \brief Button slot to remove the selected view mode
*
* This slot removes the currently selected view mode
*/
void slotRemoveMode();
// ============================================
// ViewMode Context Menu
// ============================================
/** \brief Context Menu View Modes
*
* This slot shows the used toolbar Context Menu
*/
void slotModeContextMenu ( const QPoint & _pos );
// ============================================
// ToolBox and ToolBar Lists update functions
// ============================================
/** \brief Update list views
*
* This slot updates all list views depending on the currently selected view mode
*/
void slotSetToolWidgets();
// ============================================
// ToolBar Views Context Menu
// ============================================
/** \brief Context Menu Used Toolbars
*
* This slot shows the used toolbar Context Menu
*/
void slotUsedToolbarContextMenu ( const QPoint & _pos );
/** \brief Context Menu Available Toolbars
*
* This slot shows the available toolbar Context Menu
*/
void slotAvailableToolbarContextMenu ( const QPoint & _pos );
// ============================================
// ToolBox Views Context Menu
// ============================================
/** \brief Context Menu Used Toolboxes
*
* This slot shows the used toolbox Context Menu
*/
void slotUsedToolboxContextMenu ( const QPoint & _pos );
/** \brief Context Menu Available Toolboxes
*
* This slot shows the available toolbox Context Menu
*/
void slotAvailableToolboxContextMenu ( const QPoint & _pos );
// ============================================
// ToolBar Buttons
// ============================================
/** \brief remove Toolbars from Mode
*
* This slot removes the selected toolbars from the current view Mode
*/
void slotRightArrowToolbar();
/** \brief add Toolbars to Mode
*
* This slot adds the selected toolbars to the current view Mode
*/
void slotLeftArrowToolbar();
// ============================================
//ToolBox Buttons
// ============================================
/** \brief remove Toolboxes from Mode
*
* This slot removes the selected widgets from the current view Mode
*/
void slotRightArrowToolbox();
/** \brief add Toolboxes to Mode
*
* This slot adds the selected widgets to the current view Mode
*/
void slotLeftArrowToolbox();
/** \brief Move Toolbox up
*
* This slot moves the widget upward in the list of used modes
*/
void slotMoveUp();
/** \brief Move Toolbox down
*
* This slot moves the widget downward in the list of used modes
*/
void slotMoveDown();
// ============================================
// External Communication
// ============================================
private slots:
/// Slot for changing the current view to currently configured one
void slotChangeView();
/** \brief Save the current view mode configuration
*
* Takes the given configuration and saves the mode
*/
void slotSaveMode();
signals:
/// Changes the view mode to the currently configured one
void changeView(QString _mode, QStringList _toolboxWidgets, QStringList _toolbars);
/// saves the given mode
void saveMode(QString _name, bool _custom, QStringList _toolboxWidgets, QStringList _toolbars);
/// This signal is emitted to remove a mode
void removeMode(QString _name);
}; };
#endif //VIEWMODEWIDGET_HH #endif //VIEWMODEWIDGET_HH
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