Qt: Make IOConsoleDialog a single instance
When opening a console dialog, make it reuse an existing instance if it is already open. This is required because the output of the Lua code currently only goes into a single GUI dialog (the last one open). And in general it feels correct. This depends on the QAction holding the pointer reference, which seems reasonable because it is a dynamic menu action.
This commit is contained in:
parent
4f53f0acaf
commit
1daa76ae32
|
@ -224,11 +224,21 @@ FunnelConsoleAction::~FunnelConsoleAction()
|
|||
}
|
||||
|
||||
void FunnelConsoleAction::triggerCallback() {
|
||||
IOConsoleDialog *dialog = new IOConsoleDialog(*qobject_cast<QWidget *>(parent()),
|
||||
if (!dialog_) {
|
||||
dialog_ = new IOConsoleDialog(*qobject_cast<QWidget *>(parent()),
|
||||
this->text(),
|
||||
eval_cb_, open_cb_, close_cb_, callback_data_);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dialog->show();
|
||||
dialog_->setAttribute(Qt::WA_DeleteOnClose);
|
||||
}
|
||||
|
||||
if (dialog_->isMinimized()) {
|
||||
dialog_->showNormal();
|
||||
}
|
||||
else {
|
||||
dialog_->show();
|
||||
}
|
||||
dialog_->raise();
|
||||
dialog_->activateWindow();
|
||||
}
|
||||
|
||||
static QHash<int, QList<FunnelAction *> > funnel_actions_;
|
||||
|
|
|
@ -13,8 +13,10 @@
|
|||
#include <QObject>
|
||||
#include <QAction>
|
||||
#include <QSet>
|
||||
#include <QPointer>
|
||||
|
||||
#include <epan/funnel.h>
|
||||
#include "io_console_dialog.h"
|
||||
#include "capture_file.h"
|
||||
#include <ui/qt/filter_action.h>
|
||||
|
||||
|
@ -111,6 +113,7 @@ private:
|
|||
funnel_console_open_cb_t open_cb_;
|
||||
funnel_console_close_cb_t close_cb_;
|
||||
void *callback_data_;
|
||||
QPointer<IOConsoleDialog> dialog_;
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
|
|
Loading…
Reference in New Issue