Skip to content
Browse files

Plugin settings

  • Loading branch information...
1 parent e173cc4 commit 7c2f997755dc4c523a1360498451a893f75d7df4 @dotevo committed Dec 4, 2011
Showing with 24 additions and 2 deletions.
  1. +10 −1 Pilocik/pluginmanager.cpp
  2. +2 −0 Pilocik/settings.cpp
  3. +5 −1 Pilocik/twidgetmanager.cpp
  4. +7 −0 Pilocik/twidgetmanager.h
View
11 Pilocik/pluginmanager.cpp
@@ -95,10 +95,17 @@ void PluginManager::loadPlugin(QString name){
void PluginManager::unloadPlugin(QString name){
QPluginLoader *a=getPlugin(name);
if(a==0)return;
- if(!a->unload())return;
+
PluginInterface *pi=qobject_cast<PluginInterface *>(a->instance());
Settings::getInstance()->modifyPluginSettings(pi->getName(),pi->getSettings());
+ QListIterator <PluginWidget*> plugin(pi->getWidgets());
+ while(plugin.hasNext()){
+ PluginWidget *n=plugin.next();
+ TWidgetManager::getInstance()->removeWidget(n->getWidgetName());
+ }
+
+ if(!a->unload())return;
}
@@ -108,6 +115,8 @@ void PluginManager::initAll(){
QPluginLoader *a=i.next();
if(a->isLoaded()){
PluginInterface *pi=qobject_cast<PluginInterface *>(a->instance());
+
+
QMap<QString,QString> settings=Settings::getInstance()->getPluginSettings(pi->getName());
pi->init(settings);
}
View
2 Pilocik/settings.cpp
@@ -137,6 +137,8 @@ void Settings::resetDefaultSettings()
" <posy>140</posy>\n"
" </widget>\n"
" </widgets>\n"
+ " <plugins>\n"
+ " </plugins>\n"
" <map>\n"
" <lat>51.1</lat>\n"
" <lon>17.03</lon>\n"
View
6 Pilocik/twidgetmanager.cpp
@@ -86,12 +86,16 @@ void TWidgetManager::addWidget(QString name, TMovableFrame* w) {
QPoint position(PosX,PosY);
w->move(position);
//w->setVisible(widgetSettings["enabled"]=="true");
- w->setVisible(true);
w->setParent(parent);
}
}
+void TWidgetManager::removeWidget(QString name) {
+ widgets.remove(name);
+}
+
+
void TWidgetManager::setParent(QWidget* w) {
//TODO: Zmiana widgetów
parent=w;
View
7 Pilocik/twidgetmanager.h
@@ -88,6 +88,13 @@ class TWidgetManager
*/
void addWidget(QString name, TMovableFrame* w);
/**
+ * @brief
+ *
+ * @fn removeWidget
+ * @param name Widget name
+ */
+ void removeWidget(QString name) ;
+ /**
* @brief Set mode to the opposite one. (from Moving to Stand or from Stand to Moving)
*
* @fn changeMode

0 comments on commit 7c2f997

Please sign in to comment.
Something went wrong with that request. Please try again.