Qt: Show Python scripts as links in the about box.

Extcap utilities can be Python scripts. Show the files as URLs and
allow double click to open.

Change-Id: I214caa2683896b89fbe6243562eee9b12d4ae217
Reviewed-on: https://code.wireshark.org/review/31221
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
This commit is contained in:
Stig Bjørlykke 2018-12-27 20:45:16 +01:00 committed by Peter Wu
parent ffbd46ce7b
commit b28f283f8b
2 changed files with 4 additions and 10 deletions

View File

@ -356,12 +356,10 @@ AboutDialog::AboutDialog(QWidget *parent) :
pluginTypeModel->setColumnToFilter(2);
ui->tblPlugins->setModel(pluginTypeModel);
ui->tblPlugins->setRootIsDecorated(false);
#ifdef HAVE_LUA
UrlLinkDelegate *plugin_delegate = new UrlLinkDelegate(this);
QString pattern = QString("^%1$").arg(wslua_plugin_type_name());
plugin_delegate->setColCheck(2, pattern);
script_pattern = QString("\\.(lua|py)$");
plugin_delegate->setColCheck(3, script_pattern);
ui->tblPlugins->setItemDelegateForColumn(3, plugin_delegate);
#endif
ui->cmbType->addItems(pluginModel->typeNames());
ui->tblPlugins->setContextMenuPolicy(Qt::CustomContextMenu);
ui->tblPlugins->setTextElideMode(Qt::ElideMiddle);
@ -566,21 +564,18 @@ void AboutDialog::copyActionTriggered(bool copyRow)
clipBoard->setText(clipdata);
}
#ifdef HAVE_LUA
void AboutDialog::on_tblPlugins_doubleClicked(const QModelIndex &index)
{
const int type_col = 2;
const int path_col = 3;
if (index.column() != path_col) {
return;
}
const int row = index.row();
const QAbstractItemModel *model = index.model();
if (model->index(row, type_col).data().toString() == wslua_plugin_type_name()) {
if (model->index(row, path_col).data().toString().contains(QRegExp(script_pattern))) {
QDesktopServices::openUrl(QUrl::fromLocalFile(model->index(row, path_col).data().toString()));
}
}
#endif
/*
* Editor modelines

View File

@ -91,15 +91,14 @@ protected:
private:
Ui::AboutDialog *ui;
QString script_pattern;
private slots:
void urlDoubleClicked(const QModelIndex &);
void handleCopyMenu(QPoint);
void copyActionTriggered(bool row = false);
void copyRowActionTriggered();
#ifdef HAVE_LUA
void on_tblPlugins_doubleClicked(const QModelIndex &index);
#endif
};
#endif // ABOUT_DIALOG_H