Commit 93044cf7 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Allow to modify item when we double click

parent 54c8c747
......@@ -79,6 +79,7 @@ ViewerPluginExternalConfigureWidget::ViewerPluginExternalConfigureWidget(QWidget
mListExternal->setSelectionMode(QAbstractItemView::SingleSelection);
listLayout->addWidget(mListExternal);
connect(mListExternal, &QListWidget::itemSelectionChanged, this, &ViewerPluginExternalConfigureWidget::updateButtons);
connect(mListExternal, &QListWidget::itemDoubleClicked, this, &ViewerPluginExternalConfigureWidget::slotDoubleClicked);
QVBoxLayout *buttonLayout = new QVBoxLayout;
mainLayout->addLayout(buttonLayout);
......@@ -121,13 +122,7 @@ void ViewerPluginExternalConfigureWidget::slotModifyScript()
{
QListWidgetItem *item = mListExternal->currentItem();
if (item) {
ViewerPluginExternalScriptItem *scriptItem = static_cast<ViewerPluginExternalScriptItem *>(item);
QPointer<ViewerPluginExternalEditDialog> dlg = new ViewerPluginExternalEditDialog(this);
dlg->setScriptInfo(scriptItem->scriptInfo());
if (dlg->exec()) {
scriptItem->setScriptInfo(dlg->scriptInfo());
}
delete dlg;
modifyScript(item);
}
}
......@@ -204,3 +199,22 @@ void ViewerPluginExternalConfigureWidget::updateButtons()
}
}
void ViewerPluginExternalConfigureWidget::slotDoubleClicked(QListWidgetItem * item)
{
if (item) {
modifyScript(item);
}
}
void ViewerPluginExternalConfigureWidget::modifyScript(QListWidgetItem *item)
{
ViewerPluginExternalScriptItem *scriptItem = static_cast<ViewerPluginExternalScriptItem *>(item);
if (!scriptItem->scriptInfo().isReadOnly()) {
QPointer<ViewerPluginExternalEditDialog> dlg = new ViewerPluginExternalEditDialog(this);
dlg->setScriptInfo(scriptItem->scriptInfo());
if (dlg->exec()) {
scriptItem->setScriptInfo(dlg->scriptInfo());
}
delete dlg;
}
}
......@@ -24,6 +24,7 @@
#include "../viewerpluginexternalscriptsloadjob.h"
class QListWidget;
class QPushButton;
class QListWidgetItem;
class ViewerPluginExternalConfigureWidget : public QWidget
{
Q_OBJECT
......@@ -34,11 +35,13 @@ public:
void save();
void reset();
private:
void modifyScript(QListWidgetItem *item);
void fillScriptInfo(const QVector<ViewerPluginExternalScriptInfo> &scriptInfos);
void slotAddScript();
void slotModifyScript();
void updateButtons();
void slotRemoveScript();
void slotDoubleClicked(QListWidgetItem *item);
QStringList mFilesToRemove;
QListWidget *mListExternal;
......
Supports Markdown
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