forked from osmocom/wireshark
CompiledFilterOutput dialog fixes and updates.
Apply a layout to the "Compiled Filter Output" dialog. Render the filter as monospaced text. Don't add an "expert OK" icon to the list. It doesn't seem to indicate any sort of status. Use a "Close" button instead of "OK". According to http://uxmovement.com/buttons/why-the-ok-button-is-no-longer-okay/ "OK" implies we're going to perform some sort of action. Add a "Copy" button while we're here. Change-Id: Ia63f3032916e322fa9f4f2d465140b128b4f8078 Reviewed-on: https://code.wireshark.org/review/3338 Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
parent
45f3deed0b
commit
69d0788875
|
@ -481,7 +481,6 @@ void CaptureInterfacesDialog::on_compileBPF_clicked()
|
|||
{
|
||||
QTableWidgetItem *it = ui->tbInterfaces->item(row, INTERFACE);
|
||||
if (selected.contains(it)) {
|
||||
QString str = it->text();
|
||||
interfaces->append(it->text());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,11 @@
|
|||
#include <pcap.h>
|
||||
#include "ui/capture_globals.h"
|
||||
|
||||
#include "wireshark_application.h"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QPushButton>
|
||||
|
||||
CompiledFilterOutput::CompiledFilterOutput(QWidget *parent, QStringList *intList, QString &compile_filter) :
|
||||
QDialog(parent),
|
||||
intList_(intList),
|
||||
|
@ -35,6 +40,15 @@ CompiledFilterOutput::CompiledFilterOutput(QWidget *parent, QStringList *intList
|
|||
ui(new Ui::CompiledFilterOutput)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
ui->filterList->setCurrentFont(wsApp->monospaceFont());
|
||||
|
||||
copy_bt_ = ui->buttonBox->addButton(tr("Copy"), QDialogButtonBox::ActionRole);
|
||||
copy_bt_->setToolTip(tr("Copy filter text to the clipboard."));
|
||||
connect(copy_bt_, SIGNAL(clicked()), this, SLOT(copyFilterText()));
|
||||
|
||||
QPushButton *close_bt = ui->buttonBox->button(QDialogButtonBox::Close);
|
||||
close_bt->setDefault(true);
|
||||
|
||||
interface_list_ = ui->interfaceList;
|
||||
#if GLIB_CHECK_VERSION(2,31,0)
|
||||
|
@ -44,15 +58,20 @@ CompiledFilterOutput::CompiledFilterOutput(QWidget *parent, QStringList *intList
|
|||
pcap_compile_mtx = g_mutex_new();
|
||||
#endif
|
||||
compileFilter();
|
||||
connect(interface_list_, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(compile_clicked(QListWidgetItem*, QListWidgetItem*)));
|
||||
}
|
||||
|
||||
CompiledFilterOutput::~CompiledFilterOutput()
|
||||
{
|
||||
// For some reason closing this dialog either lowers the Capture Interfaces dialog
|
||||
// or raises the main window. Work around the problem for now by manually raising
|
||||
// and activating our parent (presumably the Capture Interfaces dialog).
|
||||
if (parentWidget()) {
|
||||
parentWidget()->raise();
|
||||
parentWidget()->activateWindow();
|
||||
}
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void CompiledFilterOutput::compileFilter()
|
||||
{
|
||||
struct bpf_program fcode;
|
||||
|
@ -82,7 +101,7 @@ void CompiledFilterOutput::compileFilter()
|
|||
bpf_code_str = g_string_free(bpf_code_dump, FALSE);
|
||||
g_mutex_unlock(pcap_compile_mtx);
|
||||
compile_results.insert(interfaces, QString("%1").arg(g_strdup(bpf_code_str)));
|
||||
ui->interfaceList->addItem(new QListWidgetItem(QIcon(":expert/expert_ok.png"),interfaces));
|
||||
ui->interfaceList->addItem(new QListWidgetItem(interfaces));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -90,15 +109,19 @@ void CompiledFilterOutput::compileFilter()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void CompiledFilterOutput::compile_clicked(QListWidgetItem *current, QListWidgetItem *previous)
|
||||
void CompiledFilterOutput::on_interfaceList_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous)
|
||||
{
|
||||
Q_UNUSED(previous);
|
||||
|
||||
QString interface = current->text();
|
||||
QHash<QString, QString>::const_iterator iter = compile_results.find(interface);
|
||||
ui->filterList->clear();
|
||||
ui->filterList->setText(iter.value());
|
||||
ui->filterList->setPlainText(iter.value());
|
||||
}
|
||||
|
||||
void CompiledFilterOutput::copyFilterText()
|
||||
{
|
||||
wsApp->clipboard()->setText(ui->filterList->toPlainText());
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -113,3 +136,4 @@ void CompiledFilterOutput::compile_clicked(QListWidgetItem *current, QListWidget
|
|||
// vi: set shiftwidth=4 tabstop=4 expandtab:
|
||||
// :indentSize=4:tabSize=4:noTabs=true:
|
||||
//
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ private:
|
|||
GMutex *pcap_compile_mtx;
|
||||
QHash<QString, QString> compile_results;
|
||||
QListWidget *interface_list_;
|
||||
QPushButton *copy_bt_;
|
||||
void compileFilter();
|
||||
|
||||
public:
|
||||
|
@ -53,7 +54,8 @@ public:
|
|||
~CompiledFilterOutput();
|
||||
|
||||
private slots:
|
||||
void compile_clicked(QListWidgetItem* current, QListWidgetItem* previous);
|
||||
void on_interfaceList_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
|
||||
void copyFilterText();
|
||||
};
|
||||
|
||||
#endif // COMPILEDFILTEROUTPUT_H
|
||||
|
|
|
@ -13,48 +13,35 @@
|
|||
<property name="windowTitle">
|
||||
<string>Compiled Filter Output</string>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>340</y>
|
||||
<width>631</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QListWidget" name="interfaceList">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>241</width>
|
||||
<height>311</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextBrowser" name="filterList">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
<y>20</y>
|
||||
<width>381</width>
|
||||
<height>311</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="2,5">
|
||||
<item>
|
||||
<widget class="QListWidget" name="interfaceList">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="filterList"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
|
|
Loading…
Reference in New Issue