diff --git a/BasePlugin/OptionsInterface.hh b/BasePlugin/OptionsInterface.hh
new file mode 100644
index 0000000000000000000000000000000000000000..ee89c70839cd4c81c94b21977f942644c6133692
--- /dev/null
+++ b/BasePlugin/OptionsInterface.hh
@@ -0,0 +1,85 @@
+//=============================================================================
+//
+// OpenFlipper
+// Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
+// www.openflipper.org
+//
+//-----------------------------------------------------------------------------
+//
+// License
+//
+// 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.
+//
+// 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 Lesser General Public License
+// along with OpenFlipper. If not, see .
+//
+//-----------------------------------------------------------------------------
+//
+// $Revision: 3265 $
+// $Author: wilden $
+// $Date: 2008-09-30 18:08:19 +0200 (Tue, 30 Sep 2008) $
+//
+//=============================================================================
+
+
+#ifndef OPTIONSINTERFACE_HH
+#define OPTIONSINTERFACE_HH
+
+#include
+
+ /**
+ * This Interface should be used by plugins which will provide a their own options.
+ * For your options to show up in OpenFlippers Options window implement the initializeOptionsWidget() slot.
+ * The widget you return with this slot will be integrated into the options window and when
+ * the user hits the apply- or ok-button in the options window the slot applyOptions() is called and
+ * thus enables you to store the changes in your options.
+ */
+class OptionsInterface {
+
+ private slots :
+
+ public :
+
+ /// Destructor
+ virtual ~OptionsInterface() {};
+
+ /** \brief Initialize the Options Widget
+ *
+ * Initialize the options widget (create a widget and return a pointer to it ) \n
+ * \n
+ * Example : \n
+ * _widget = new QWidget(); \n
+ * \n
+ * In the widget you can add anything you want.\n
+ * \n
+ * use the slot applyOptions() to save the values of options currently entered
+ * in your widget.
+ * \n
+ * @param _widget Pointer to the new Widget
+ * @return Return true if a widget has been created
+ */
+ virtual bool initializeOptionsWidget(QWidget*& /*_widget*/) = 0;
+
+ /** \brief Apply changes to options
+ *
+ * Called, when the user hits the apply/ok button in the options window
+ * of Openflipper.\n
+ *
+ * use this slot to save the values of options currently entered
+ * in your options widget.
+ */
+ virtual void applyOptions() = 0;
+
+};
+
+Q_DECLARE_INTERFACE(OptionsInterface,"OpenFlipper.OptionsInterface/1.0")
+
+#endif // OPTIONSINTERFACE_HH
diff --git a/Core/PluginInfo.hh b/Core/PluginInfo.hh
index 341a49630421360b8b919f24b7603a9249eb940b..20b956407b468b99ed2e1382528b9c308bc5f38c 100644
--- a/Core/PluginInfo.hh
+++ b/Core/PluginInfo.hh
@@ -39,6 +39,7 @@ class PluginInfo{
slotInfos.clear();
keys.clear();
widget = 0;
+ optionsWidget = 0;
}
@@ -54,6 +55,7 @@ class PluginInfo{
slotInfos = _i.slotInfos;
keys = _i.keys;
widget = _i.widget;
+ optionsWidget = _i.optionsWidget;
}
/// Pointer to the loaded plugin (Already casted when loading it)
@@ -85,6 +87,9 @@ class PluginInfo{
/// Pointer to plugins toolbar widget (if available)
QDockWidget* widget;
+
+ /// Pointer to plugins options widget (if available)
+ QWidget* optionsWidget;
};
#endif //PLUGININFO_HH
diff --git a/Core/PluginLoader.cc b/Core/PluginLoader.cc
index 3a821d06cd6ee67952c1133e12f393fcb8529f6f..709c622fac609073d29b0b29eb21a490e5d375aa 100644
--- a/Core/PluginLoader.cc
+++ b/Core/PluginLoader.cc
@@ -57,6 +57,7 @@
#include "OpenFlipper/BasePlugin/MouseInterface.hh"
#include "OpenFlipper/BasePlugin/PickingInterface.hh"
#include "OpenFlipper/BasePlugin/ToolboxInterface.hh"
+#include "OpenFlipper/BasePlugin/OptionsInterface.hh"
#include "OpenFlipper/BasePlugin/ToolbarInterface.hh"
#include "OpenFlipper/BasePlugin/TextureInterface.hh"
#include "OpenFlipper/BasePlugin/MenuInterface.hh"
@@ -618,7 +619,22 @@ void Core::loadPlugin(QString filename, bool silent){
}
- //Check if the plugin supports Toolbox-Interface
+ //Check if the plugin supports Options-Interface
+ OptionsInterface* optionsPlugin = qobject_cast< OptionsInterface * >(plugin);
+ if ( optionsPlugin && OpenFlipper::Options::gui() ) {
+ supported = supported + "Options ";
+
+ QWidget* widget = 0;
+ if ( optionsPlugin->initializeOptionsWidget( widget ) ) {
+ info.optionsWidget = widget;
+
+ if ( checkSlot(plugin,"applyOptions()") )
+ connect(coreWidget_ , SIGNAL( applyOptions() ),
+ plugin , SLOT( applyOptions() ),Qt::DirectConnection);
+ }
+ }
+
+ //Check if the plugin supports Toolbar-Interface
ToolbarInterface* toolbarPlugin = qobject_cast< ToolbarInterface * >(plugin);
if ( toolbarPlugin && OpenFlipper::Options::gui() ) {
supported = supported + "Toolbars ";
diff --git a/widgets/coreWidget/keyHandling.cc b/widgets/coreWidget/keyHandling.cc
index 269b3bc90727c3495ff74e01f48343aa8f322c59..7ef07a2b32866666215e7c8cbe279561eb42eb11 100644
--- a/widgets/coreWidget/keyHandling.cc
+++ b/widgets/coreWidget/keyHandling.cc
@@ -212,6 +212,7 @@ void CoreWidget::slotAddKeyMapping(int _key, Qt::KeyboardModifiers _modifiers, Q
replace = true;
oldCombi = (*it).first;
oldTarget = (*it).second;
+std::cerr << "replacing \n";
continue;
}
diff --git a/widgets/optionsWidget/optionsWidget.cc b/widgets/optionsWidget/optionsWidget.cc
index 141034d4c99a4603cda954a34d18f23ec225a96c..cd7a7f1a08429a924074814de121f03a29c98268 100644
--- a/widgets/optionsWidget/optionsWidget.cc
+++ b/widgets/optionsWidget/optionsWidget.cc
@@ -50,6 +50,7 @@ OptionsWidget::OptionsWidget(std::vector& _plugins, std::vector& _plugins, std::vectorsetLayout( pluginOptionsLayout );
+
http = new QHttp(this);
// http specific connections
@@ -131,6 +135,9 @@ void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) {
color.fill( OpenFlipper::Options::defaultBackgroundColor() );
backgroundButton->setIcon( QIcon(color) );
+ // plugin options
+ initPluginOptions();
+
// updates
updateUser->setText( OpenFlipper::Options::updateUsername() );
updatePass->setText( OpenFlipper::Options::updatePassword() );
@@ -291,6 +298,47 @@ void OptionsWidget::updateVersionsTable() {
}
+void OptionsWidget::initPluginOptions(){
+
+ pluginList->disconnect();
+
+ connect(pluginList, SIGNAL( currentTextChanged(const QString&) ), this, SLOT( slotShowPluginOptions(const QString&) ) );
+
+ //init list of plugins
+ pluginList->clear();
+
+ for ( uint i = 0 ; i < plugins_.size(); ++i )
+ if (plugins_[i].optionsWidget != 0){
+
+ pluginList->addItem( plugins_[i].name );
+ }
+
+ if ( pluginList->count() > 0)
+ pluginList->setCurrentRow(0);
+}
+
+void OptionsWidget::slotShowPluginOptions(const QString& _pluginName ){
+
+ //remove old children
+ for (int i = 0; i < pluginOptionsLayout->count(); ++i){
+ QWidget* w = pluginOptionsLayout->itemAt(i)->widget();
+
+ if (w != 0)
+ w->setParent(0);
+
+ pluginOptionsLayout->removeItem( pluginOptionsLayout->itemAt(i) );
+ }
+
+ //find the new optionsWidget
+ for ( uint i = 0 ; i < plugins_.size(); ++i )
+ if (plugins_[i].optionsWidget != 0 && plugins_[i].name == _pluginName){
+
+ pluginOptionsLayout->addWidget( plugins_[i].optionsWidget );
+ pluginOptionsLayout->addStretch();
+ return;
+ }
+}
+
void OptionsWidget::slotApply() {
//general
@@ -336,7 +384,10 @@ void OptionsWidget::slotApply() {
emit applyOptions();
emit saveOptions();
+}
+void OptionsWidget::slotOk(){
+ slotApply();
hide();
}
diff --git a/widgets/optionsWidget/optionsWidget.hh b/widgets/optionsWidget/optionsWidget.hh
index bb259fc37d39938d06e71527f955df30c4a8f7a4..89c5ea68df5f5a7837e6bc50cad6705e319ca789 100644
--- a/widgets/optionsWidget/optionsWidget.hh
+++ b/widgets/optionsWidget/optionsWidget.hh
@@ -61,7 +61,9 @@ signals:
void addKeyMapping(int _key, Qt::KeyboardModifiers _modifiers, QObject* _plugin, int _keyBindingID);
private slots:
- /// Hide widget, Update Options and tell others about changed Options
+ /// call slotApply and hide widget
+ void slotOk();
+ /// Update Options and tell others about changed Options
void slotApply();
/// Only hide widget
@@ -83,11 +85,18 @@ private slots:
void updateShortcut();
+ void slotShowPluginOptions(const QString& _pluginName );
+
protected:
void showEvent ( QShowEvent * event );
private:
+ // plugin Options
+ void initPluginOptions();
+
+ QVBoxLayout* pluginOptionsLayout;
+
//key-bindings
std::vector& plugins_;
std::vector& coreKeys_;
diff --git a/widgets/optionsWidget/optionsWidget.ui b/widgets/optionsWidget/optionsWidget.ui
index 1234f99fc88c431292b544df4e02658476b8a3c3..fcb4e406a3910e27016991fc3600038a3ac487b5 100644
--- a/widgets/optionsWidget/optionsWidget.ui
+++ b/widgets/optionsWidget/optionsWidget.ui
@@ -5,7 +5,7 @@
0
0
- 472
+ 541
763
@@ -382,6 +382,36 @@ You can select multiple modes at the same time.
+
+
+ Plugins
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 150
+ 16777215
+
+
+
+
+ -
+
+
+ Options
+
+
+
+
+
Key Bindings
@@ -677,6 +707,13 @@ p, li { white-space: pre-wrap; }
-
+
-
+
+
+ &Apply
+
+
+
-
@@ -684,23 +721,23 @@ p, li { white-space: pre-wrap; }
- 40
- 20
+ 188
+ 23
-
-
+
- Apply
+ &Ok
-
- Cancel
+ &Cancel