Commit 3a1e1004 authored by Matthias Möller's avatar Matthias Möller

- removes unloadPlugin functionality

- set backgroundColors for plugins depending on the status
- add block/unblock to the gui

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@15910 383ad7c9-94d9-4d36-a494-682f7c89f535
parent d1e10b14
......@@ -1157,21 +1157,24 @@ private slots:
/// Index of Plugins toolbox widget
int toolboxindex_;
/// Function for loading Plugins
void loadPlugin(QString filename, bool silent, QString& _licenseErrors , QObject* _plugin = 0 );
/// Load all plugins from default plugin directory and from INI-File
void loadPlugins();
private slots:
/// Show Plugins Dialog
void slotShowPlugins();
/// Function for unloading Plugins
void unloadPlugin(QString name);
/// Function for loading Plugins
void loadPlugin(const QString& _filename,const bool _silent, QString& _licenseErrors , QObject* _plugin = 0 );
/// Load Plugins from menu
void slotLoadPlugin();
/// Function for Blocking Plugins. Blocked plugins will unloaded and not loaded wthin the next starts
void slotBlockPlugin(const QString &_rpcName);
/// Function for UnBlocking Plugins. Plugins will not loaded automatically
void slotUnBlockPlugin(const QString &_rpcName);
/** @} */
......
......@@ -44,7 +44,6 @@
#ifndef PLUGININFO_HH
#define PLUGININFO_HH
#include <Qt>
#include <QString>
#include <QObject>
#include <QStringList>
......@@ -86,6 +85,8 @@ class PluginInfo{
toolbars.clear();
contextMenus.clear();
optionsWidget = 0;
buildIn = true;
status = FAILED;
}
......@@ -105,6 +106,8 @@ class PluginInfo{
toolbars = _i.toolbars;
contextMenus = _i.contextMenus;
optionsWidget = _i.optionsWidget;
buildIn = _i.buildIn;
status = _i.status;
}
/// Pointer to the loaded plugin (Already casted when loading it)
......@@ -148,6 +151,20 @@ class PluginInfo{
/// Pointer to plugins options widget (if available)
QWidget* optionsWidget;
/// Indicates, if the plugin is a built in Plugin (in Plugin directory)
bool buildIn;
/// current status of the plugin
enum StatusType
{
LOADED = 0,
BLOCKED,
UNLOADED,
FAILED
}status;
};
#endif //PLUGININFO_HH
This diff is collapsed.
......@@ -47,6 +47,11 @@
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/common/GlobalOptions.hh>
const QColor PluginDialog::blockColor_ = QColor(228, 155, 18);
const QColor PluginDialog::unloadColor_ = QColor(172, 172, 172);
const QColor PluginDialog::loadedBuiltInColor_ = QColor(208, 240, 192);
const QColor PluginDialog::failColor_ = Qt::red;
const QColor PluginDialog::loadedExternalColor_ = QColor(152, 255, 152);
PluginDialog::PluginDialog(std::vector<PluginInfo>& _plugins, QWidget *parent)
: QDialog(parent),
......@@ -54,17 +59,18 @@ PluginDialog::PluginDialog(std::vector<PluginInfo>& _plugins, QWidget *parent)
{
setupUi(this);
list->setContextMenuPolicy(Qt::CustomContextMenu);
connect(closeButton, SIGNAL(clicked()), this, SLOT(accept()));
connect(loadButton, SIGNAL(clicked()), this, SIGNAL(loadPlugin()));
connect(loadButton, SIGNAL(clicked()), this, SLOT(reject()));
connect(unloadButton, SIGNAL(clicked()), this, SLOT(slotUnload()));
connect(list,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(slotContextMenu(const QPoint&)));
//set icons
QString iconPath = OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator();
closeButton->setIcon( QIcon(iconPath + "window-close.png"));
loadButton->setIcon( QIcon(iconPath + "network-connect.png"));
unloadButton->setIcon( QIcon(iconPath + "network-disconnect.png"));
}
......@@ -97,6 +103,7 @@ int PluginDialog::exec()
QVBoxLayout* vlayout = new QVBoxLayout;
QLabel* description = new QLabel( plugins_[i].description );
descriptions_.push_back(description);
vlayout->addLayout(hlayout,20);
vlayout->addWidget(description);
......@@ -105,6 +112,32 @@ int PluginDialog::exec()
QListWidgetItem *item = new QListWidgetItem("");
frames_.push_back(frame);
item->setSizeHint( QSize (100,50) );
//set color depending on the current status
switch(plugins_[i].status)
{
case PluginInfo::LOADED:
if (plugins_[i].buildIn)
item->setBackground(loadedBuiltInColor_);
else
{
item->setBackground(loadedExternalColor_);
description->setText(description->text()+tr(" *EXTERNAL*"));
}
break;
case PluginInfo::FAILED:
item->setBackground(failColor_);
description->setText(description->text()+tr(" *FAILED*"));
break;
case PluginInfo::BLOCKED:
item->setBackground(blockColor_);
description->setText(description->text()+tr(" *BLOCKED*"));
break;
case PluginInfo::UNLOADED:
item->setBackground(unloadColor_);
description->setText(description->text()+tr(" *UNLOADED*"));
break;
}
list->addItem(item);
list->setItemWidget(item, frame);
}
......@@ -117,41 +150,100 @@ int PluginDialog::exec()
return ret;
}
void PluginDialog::slotUnload()
void PluginDialog::slotBlockPlugin()
{
for (int i=0; i < list->selectedItems().size(); ++i)
{
QListWidgetItem* widget = list->selectedItems()[i];
widget->setBackground(blockColor_);
PluginInfo* plugin = &plugins_[ list->row( widget ) ];
descriptions_[list->row( widget )]->setText(plugin->description + tr(" *BLOCKED*"));
emit blockPlugin(plugin->name);
}
}
void PluginDialog::slotUnBlockPlugin()
{
int buttonState = QMessageBox::No;
for (int i=0; i < list->selectedItems().size(); i++){
QString name = plugins_[ list->row( list->selectedItems()[i] ) ].rpcName;
if (list->selectedItems().size() == 1){
//show messageBox without YESTOALL / NOTOALL
buttonState = QMessageBox::question(this, tr("Prevent Plugin Loading"),
tr("Do you want to prevent OpenFlipper from loading this plugin on the next start?"),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No);
}else{
//show messageBox with YESTOALL / NOTOALL
if (buttonState == QMessageBox::Yes || buttonState == QMessageBox::No)
buttonState = QMessageBox::question(this, tr("Prevent Plugin Loading"),
tr("Do you want to prevent OpenFlipper from loading this plugin on the next start?"),
QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll ,
QMessageBox::No);
for (int i=0; i < list->selectedItems().size(); ++i)
{
QListWidgetItem* widget = list->selectedItems()[i];
widget->setBackground(unloadColor_);
PluginInfo* plugin = &plugins_[ list->row( widget ) ];
descriptions_[list->row( widget )]->setText(plugin->description);
emit unBlockPlugin(plugin->name);
}
}
void PluginDialog::slotLoadPlugin()
{
for (int i=0; i < list->selectedItems().size(); ++i)
{
QListWidgetItem* widget = list->selectedItems()[i];
PluginInfo* plugin = &plugins_[ list->row( widget ) ];
if (plugin->status == PluginInfo::BLOCKED)
{
QMessageBox msgBox;
msgBox.setText("Plugin is blocked. Unblock it?");
msgBox.setWindowTitle("Plugin blocked");
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
int rep = msgBox.exec();
if ( rep == QMessageBox::Yes)
emit unBlockPlugin(plugin->name);
}
// Store the new setting and remove plugin from all lists
if (buttonState == QMessageBox::Yes || buttonState == QMessageBox::YesToAll) {
QStringList dontLoadPlugins = OpenFlipperSettings().value("PluginControl/DontLoadNames",QStringList()).toStringList();
if ( !dontLoadPlugins.contains(name) ){
dontLoadPlugins << name;
OpenFlipperSettings().setValue("PluginControl/DontLoadNames",dontLoadPlugins);
}
if (plugin->buildIn)
widget->setBackground(loadedBuiltInColor_);
else
widget->setBackground(loadedExternalColor_);
descriptions_[list->row( widget )]->setText(plugin->description);
QString licenseErros;
emit loadPlugin(plugin->path,false,licenseErros,plugin->plugin);
if (plugin->status == PluginInfo::FAILED)
{
descriptions_[list->row( widget )]->setText(plugin->description + tr(" *FAILED*"));
widget->setBackground(failColor_);
}else
{
plugin->status = PluginInfo::LOADED;
}
}
}
//unload plugin
emit unloadPlugin(name);
void PluginDialog::slotContextMenu(const QPoint& _point)
{
if (!list->count())
return;
QMenu *menu = new QMenu(list);
QAction* action = 0;
PluginInfo* plugin = &plugins_[list->currentRow()];
if ( plugin->status != PluginInfo::BLOCKED)//not blocked
{
action = menu->addAction(tr("Block Plugin"));
connect(action,SIGNAL(triggered(bool)),this,SLOT(slotBlockPlugin()));
}else//blocked
{
action = menu->addAction(tr("Unblock Plugin"));
connect(action,SIGNAL(triggered(bool)),this,SLOT(slotUnBlockPlugin()));
}
reject();
if ( plugin->status != PluginInfo::LOADED)
{
action = menu->addAction(tr("Load Plugin"));
connect(action,SIGNAL(triggered(bool)),this,SLOT(slotLoadPlugin()));
}
menu->exec(list->mapToGlobal(_point),0);
}
......@@ -56,16 +56,28 @@ class PluginDialog : public QDialog, public Ui::PluginDialog
private:
std::vector<PluginInfo>& plugins_;
std::vector<QLabel*> descriptions_;
QVector< QFrame* > frames_;
static const QColor blockColor_;
static const QColor unloadColor_;
static const QColor loadedBuiltInColor_;
static const QColor loadedExternalColor_;
static const QColor failColor_;
private slots:
void slotUnload();
void slotContextMenu(const QPoint& _point);
void slotLoadPlugin();
void slotBlockPlugin();
void slotUnBlockPlugin();
protected:
void closeEvent(QCloseEvent *event);
signals:
void unloadPlugin(QString _name);
void blockPlugin(const QString &_name);
void unBlockPlugin(const QString &_name);
void loadPlugin();
void loadPlugin(const QString& _filename, bool _silent, QString& _licenseErrors, QObject* _plugin);
};
......@@ -98,16 +98,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="unloadButton">
<property name="text">
<string>Unload Plugin</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
......
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