2009-02-05 10:29:43 -05:00
|
|
|
#include "PluginManagerWidget.h"
|
|
|
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QWidget>
|
2009-02-09 16:01:41 -05:00
|
|
|
#include <QTextEdit>
|
2009-02-05 10:29:43 -05:00
|
|
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
|
|
|
#include <QDebug>
|
2009-02-09 16:01:41 -05:00
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
#include "PluginManagerWidget.h"
|
2009-02-05 10:29:43 -05:00
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//=============================================================================
|
|
|
|
//=============================================================================
|
2009-02-09 16:01:41 -05:00
|
|
|
PluginFrame::PluginFrame( QString pluginName, QWidget * parent)
|
2009-02-05 10:29:43 -05:00
|
|
|
:QFrame(parent)
|
|
|
|
{
|
|
|
|
plgName = pluginName;
|
|
|
|
|
|
|
|
// labels
|
|
|
|
labelsLay = new QVBoxLayout() ;
|
|
|
|
nameLabel = new QLabel();
|
|
|
|
nameLabel->setText(pluginName);
|
|
|
|
nameLabel->setAlignment(Qt::AlignHCenter);
|
|
|
|
labelsLay->addWidget(nameLabel);
|
|
|
|
descrLabel = new QLabel();
|
2009-02-09 16:01:41 -05:00
|
|
|
descrLabel->setText("# # # # # # # # # #");
|
|
|
|
// "plugin description will appear here someday");
|
2009-02-05 10:29:43 -05:00
|
|
|
descrLabel->setWordWrap(true);
|
|
|
|
labelsLay->addWidget(descrLabel);
|
|
|
|
|
|
|
|
// buttons
|
|
|
|
buttonsLay = new QVBoxLayout() ;
|
2009-02-09 16:01:41 -05:00
|
|
|
|
2009-02-05 10:29:43 -05:00
|
|
|
removeBtn = new QPushButton() ;
|
|
|
|
removeBtn->setText( tr("Remove") ) ;
|
2009-02-09 16:01:41 -05:00
|
|
|
connect( removeBtn, SIGNAL( clicked() ) ,
|
|
|
|
this , SLOT ( removeButtonClicked() ) ) ;
|
2009-02-05 10:29:43 -05:00
|
|
|
buttonsLay->addWidget( removeBtn ) ;
|
|
|
|
|
|
|
|
//all together
|
|
|
|
mainLay = new QHBoxLayout(this);
|
|
|
|
mainLay->addLayout(labelsLay);
|
|
|
|
mainLay->addLayout(buttonsLay);
|
|
|
|
|
|
|
|
this->setFrameStyle(QFrame::Box | QFrame::Raised);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
PluginFrame::~PluginFrame()
|
|
|
|
{
|
|
|
|
//nothing to do here at this moment
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginFrame::removeButtonClicked()
|
|
|
|
{
|
2009-02-09 16:01:41 -05:00
|
|
|
emit needToRemove( plgName );
|
2009-02-05 10:29:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
2009-02-09 16:01:41 -05:00
|
|
|
QString
|
|
|
|
PluginFrame::getPluginName()
|
2009-02-05 10:29:43 -05:00
|
|
|
{
|
2009-02-09 16:01:41 -05:00
|
|
|
return plgName ;
|
2009-02-05 10:29:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//=============================================================================
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
PluginManagerWidget::PluginManagerWidget(QWidget * parent)
|
|
|
|
:QFrame(parent)
|
2009-02-09 16:01:41 -05:00
|
|
|
{
|
|
|
|
qDebug() << " " << "PluginManagerWidget::PluginManagerWidget here";
|
|
|
|
|
|
|
|
mainLayout = new QVBoxLayout(this);
|
2009-02-05 10:29:43 -05:00
|
|
|
|
2009-02-09 16:01:41 -05:00
|
|
|
//===
|
|
|
|
installPluginLayout = new QHBoxLayout();
|
|
|
|
installPluginButton = new QPushButton();
|
|
|
|
|
2009-04-13 19:00:34 -04:00
|
|
|
installPluginButton->setText(tr("Install New Plugin..."));
|
2009-02-09 16:01:41 -05:00
|
|
|
connect( installPluginButton, SIGNAL( clicked() ),
|
|
|
|
this , SLOT( installPluginButtonClicked() ) );
|
|
|
|
installPluginLayout->addWidget(installPluginButton);
|
|
|
|
installPluginSpacer = new QSpacerItem(283, 20,
|
|
|
|
QSizePolicy::Expanding, QSizePolicy::Minimum);
|
|
|
|
installPluginLayout->addItem(installPluginSpacer);
|
|
|
|
|
|
|
|
mainLayout->addLayout( installPluginLayout );
|
|
|
|
|
|
|
|
//===
|
|
|
|
pluginFramesContainer = new QFrame();
|
|
|
|
pluginFramesLayout = new QVBoxLayout(pluginFramesContainer);
|
2009-02-05 10:29:43 -05:00
|
|
|
|
2009-02-09 16:01:41 -05:00
|
|
|
mainLayout->addWidget(pluginFramesContainer);
|
|
|
|
|
|
|
|
//===
|
|
|
|
errorsConsole = new QTextEdit();
|
|
|
|
|
|
|
|
mainLayout->addWidget( errorsConsole );
|
|
|
|
|
|
|
|
qDebug() << " " << "PluginManagerWidget::PluginManagerWidget done";
|
2009-02-05 10:29:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
PluginManagerWidget::~PluginManagerWidget()
|
|
|
|
{
|
2009-02-09 16:01:41 -05:00
|
|
|
//nothing to do here
|
2009-02-05 10:29:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
void
|
2009-02-09 16:01:41 -05:00
|
|
|
PluginManagerWidget::registerNewPlugin(QString pluginName)
|
2009-02-05 10:29:43 -05:00
|
|
|
{
|
2009-02-09 16:01:41 -05:00
|
|
|
qDebug() << " " << "PluginManagerWidget::registerNewPlugin "<< pluginName;
|
|
|
|
|
|
|
|
PluginFrame* pf = new PluginFrame(pluginName, pluginFramesContainer) ;
|
|
|
|
|
|
|
|
connect( pf , SIGNAL( needToRemove(QString)),
|
|
|
|
this, SIGNAL( removeRequested(QString) ) );
|
|
|
|
|
|
|
|
pluginFramesLayout->addWidget(pf);
|
2009-02-05 10:29:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
void
|
2009-02-09 16:01:41 -05:00
|
|
|
PluginManagerWidget::installPluginButtonClicked()
|
2009-02-05 10:29:43 -05:00
|
|
|
{
|
|
|
|
QString fileName = QFileDialog::getOpenFileName(this,
|
|
|
|
tr("Open Plugin to install"),
|
|
|
|
"./",
|
|
|
|
tr("Plugins (*.so *.dll)"));
|
|
|
|
if (!fileName.isNull())
|
|
|
|
{
|
2009-02-09 16:01:41 -05:00
|
|
|
emit installPluginRequested(fileName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginManagerWidget::removePluginFrame(QString pluginName)
|
|
|
|
{
|
|
|
|
foreach(QObject* ob, pluginFramesContainer->children())
|
|
|
|
{
|
|
|
|
PluginFrame* pf = qobject_cast<PluginFrame*> (ob);
|
|
|
|
if (pf)
|
|
|
|
{
|
|
|
|
if (pf->getPluginName() == pluginName )
|
|
|
|
{
|
|
|
|
pf->setParent(0);
|
|
|
|
delete pf;
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
}
|
2009-02-05 10:29:43 -05:00
|
|
|
}
|
2009-02-09 16:01:41 -05:00
|
|
|
|
|
|
|
// normally unreachable place
|
|
|
|
QString em = QString("Widget for plugin %1 not found on plugins frame")
|
|
|
|
.arg( pluginName ) ;
|
|
|
|
acceptErrorMessage( em );
|
2009-02-05 10:29:43 -05:00
|
|
|
}
|
|
|
|
|
2009-02-09 16:01:41 -05:00
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginManagerWidget::acceptErrorMessage(QString errorMessage)
|
|
|
|
{
|
|
|
|
errorsConsole->append( errorMessage );
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|