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);
......
This diff is collapsed.
This diff is collapsed.
......@@ -56,27 +56,144 @@ class viewModeWidget : public QDialog, public Ui::viewMode
{
Q_OBJECT
private:
// Vector holding list of all available modes
const QVector< ViewMode* >& modes_;
public:
viewModeWidget(const QVector< ViewMode* >& _modes, QWidget *parent = 0 );
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:
void slotMoveUp();
void slotMoveDown();
void slotRemoveWidget();
void slotRemoveMode();
void slotChangeView();
void slotModeChanged(QString _mode);
void slotModeClicked(QModelIndex _id);
void slotSaveMode();
void slotSetToolWidgets();
/// Context Menus
void slotModeContextMenu ( const QPoint & _pos );
void slotToolContextMenu ( const QPoint & _pos );
// ============================================
// ViewMode Buttons
// ============================================
/** \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
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