diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index cd00f8db..3075d386 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1685,25 +1685,23 @@ void CentralWidget::menuAndToolBarInit(void) { qApp->addLibraryPath(QCoreApplication::applicationDirPath()+"../lib"); #endif foreach (QString fileName, pluginsDir.entryList(QDir::Files)) { - QPluginLoader loader(pluginsDir.absoluteFilePath(fileName),this); + QString absoluteFilePath = pluginsDir.absoluteFilePath(fileName); + QPluginLoader loader(absoluteFilePath,this); QJsonObject metaData = loader.metaData(); if(!metaData.contains("MetaData")) { - qInfo() << "plugin metaData not found:" << fileName; - pluginInfoWindow->addPluginInfo(fileName,"",0,false,true); + pluginInfoWindow->addPluginInfo(fileName,"",tr("Plugin metaData not found!"),0,false,true); continue; } QJsonObject metaDataObject = metaData.value("MetaData").toObject(); qInfo() << metaDataObject; if(!metaDataObject.contains("APIVersion")) { - qInfo() << "plugin api version not found:" << fileName; - pluginInfoWindow->addPluginInfo(fileName,"",0,false,true); + pluginInfoWindow->addPluginInfo(fileName,"",tr("Plugin api version not found!"),0,false,true); continue; } int apiVersion = metaDataObject.value("APIVersion").toInt(); QList supportVersion = PluginInfoWindow::supportAPIVersionList(); if(!supportVersion.contains((uint32_t)apiVersion)) { - qInfo() << "plugin api version [" << apiVersion << "] not match:" << fileName; - pluginInfoWindow->addPluginInfo(fileName,"",apiVersion,false,true); + pluginInfoWindow->addPluginInfo(fileName,"",tr("Plugin api version not match!"),apiVersion,false,true); continue; } QObject *plugin = loader.instance(); @@ -1722,7 +1720,7 @@ void CentralWidget::menuAndToolBarInit(void) { pluginStruct.iface = iface; pluginStruct.state = state; pluginList.append(pluginStruct); - pluginInfoWindow->addPluginInfo(iface,apiVersion,state,false); + pluginInfoWindow->addPluginInfo(iface,absoluteFilePath,apiVersion,state,false); connect(iface,SIGNAL(requestTelnetConnect(QString, int, int)),this,SLOT(onPluginRequestTelnetConnect(QString, int, int))); connect(iface,SIGNAL(requestSerialConnect(QString, uint32_t, int, int, int, bool, bool)),this,SLOT(onPluginRequestSerialConnect(QString, uint32_t, int, int, int, bool, bool))); connect(iface,SIGNAL(requestLocalShellConnect(QString, QString)),this,SLOT(onPluginRequestLocalShellConnect(QString, QString))); @@ -1750,10 +1748,14 @@ void CentralWidget::menuAndToolBarInit(void) { } iface->setLanguage(language,qApp); iface->retranslateUi(); + } else { + pluginInfoWindow->addPluginInfo(fileName,"",tr("Plugin init failed!"),apiVersion,false,true); } } else { - qInfo() << "load plugin failed:" << loader.errorString(); + pluginInfoWindow->addPluginInfo(fileName,"",loader.errorString(),apiVersion,false,true); } + } else { + pluginInfoWindow->addPluginInfo(fileName,"",loader.errorString(),apiVersion,false,true); } } laboratoryMenu->addSeparator(); diff --git a/src/plugininfowindow/plugininfowindow.cpp b/src/plugininfowindow/plugininfowindow.cpp index c025e2f2..3d77dca1 100644 --- a/src/plugininfowindow/plugininfowindow.cpp +++ b/src/plugininfowindow/plugininfowindow.cpp @@ -56,16 +56,17 @@ PluginInfoWindow::~PluginInfoWindow() delete ui; } -void PluginInfoWindow::addPluginInfo(PluginInterface *plugin, uint32_t apiVersion, bool enable, bool readOnly) +void PluginInfoWindow::addPluginInfo(PluginInterface *plugin, const QString &tooltip, uint32_t apiVersion, bool enable, bool readOnly) { - addPluginInfo(plugin->name(), plugin->version(), apiVersion, enable, readOnly); + addPluginInfo(plugin->name(), plugin->version(), tooltip, apiVersion, enable, readOnly); } -void PluginInfoWindow::addPluginInfo(QString name, QString version, uint32_t apiVersion, bool enable, bool readOnly) +void PluginInfoWindow::addPluginInfo(QString name, QString version, const QString &tooltip, uint32_t apiVersion, bool enable, bool readOnly) { uint32_t i = ui->tableWidget->rowCount(); ui->tableWidget->setRowCount(i + 1); ui->tableWidget->setItem(i, 0, new QTableWidgetItem(name)); + ui->tableWidget->item(i, 0)->setToolTip(tooltip); ui->tableWidget->setItem(i, 1, new QTableWidgetItem(version)); ui->tableWidget->setItem(i, 2, new QTableWidgetItem(apiVersion?QString::number(apiVersion):"")); QTableWidgetItem *item = new QTableWidgetItem(); diff --git a/src/plugininfowindow/plugininfowindow.h b/src/plugininfowindow/plugininfowindow.h index e0baa448..82c518d5 100644 --- a/src/plugininfowindow/plugininfowindow.h +++ b/src/plugininfowindow/plugininfowindow.h @@ -35,8 +35,8 @@ class PluginInfoWindow : public QDialog public: explicit PluginInfoWindow(QWidget *parent = nullptr); ~PluginInfoWindow(); - void addPluginInfo(PluginInterface *plugin, uint32_t apiVersion, bool enable, bool readOnly); - void addPluginInfo(QString name, QString version, uint32_t apiVersion, bool enable, bool readOnly); + void addPluginInfo(PluginInterface *plugin, const QString &tooltip, uint32_t apiVersion, bool enable, bool readOnly); + void addPluginInfo(QString name, QString version, const QString &tooltip, uint32_t apiVersion, bool enable, bool readOnly); void retranslateUi(void); static QList supportAPIVersionList(void);