#include "ws_symbol_export.h"
#include "qt_ui_utils.h"
+#include "wireshark_application.h"
#include "globals.h"
#include "file.h"
#include <zlib.h>
#endif
-#include <QInputDialog>
+#include <QKeyEvent>
#include <QMessageBox>
#include <QPrintDialog>
#include <QPrinter>
+#include <QTextEdit>
#include <QTextStream>
FollowStreamDialog::FollowStreamDialog(QWidget *parent) :
follow_info = NULL;
ui->setupUi(this);
- this->setFixedSize(this->size());
+ ui->teStreamContent->setFont(wsApp->monospaceFont());
+ ui->teStreamContent->installEventFilter(this);
connect(ui->buttonBox, SIGNAL(helpRequested()), this, SLOT(HelpButton()));
- bFilterOut = ui->buttonBox->addButton(tr("Filter out this stream"), QDialogButtonBox::ActionRole);
+ bFilterOut = ui->buttonBox->addButton(tr("Hide this stream"), QDialogButtonBox::ActionRole);
connect(bFilterOut, SIGNAL(clicked()), this, SLOT(FilterOut()));
-
- bFind = ui->buttonBox->addButton(tr("Find"), QDialogButtonBox::ActionRole);
- connect(bFind, SIGNAL(clicked()), this, SLOT(FindText()));
+// bFind = ui->buttonBox->addButton(tr("Find"), QDialogButtonBox::ActionRole);
+// connect(bFind, SIGNAL(clicked()), this, SLOT(FindText()));
bPrint = ui->buttonBox->addButton(tr("Print"), QDialogButtonBox::ActionRole);
connect(bPrint, SIGNAL(clicked()), this, SLOT(Print()));
#endif
}
-void FollowStreamDialog::FindText()
+void FollowStreamDialog::FindText(bool go_back)
{
- bool ok;
- QString text = QInputDialog::getText(this, tr("Wireshark: Find text"),
- tr("Find text:"), QLineEdit::Normal,
- " ", &ok);
- if (ok && !text.isEmpty())
- {
+ if (ui->leFind->text().isEmpty()) return;
+
+ bool found = ui->teStreamContent->find(ui->leFind->text());
+
+ if (found) {
+ ui->teStreamContent->setFocus();
+ } else if (go_back) {
ui->teStreamContent->moveCursor(QTextCursor::Start);
- ui->teStreamContent->find(text);
+ FindText(false);
}
}
follow_read_stream();
}
+void FollowStreamDialog::on_bFind_clicked()
+{
+ FindText();
+}
+
+void FollowStreamDialog::on_leFind_returnPressed()
+{
+ FindText();
+}
+
+void FollowStreamDialog::on_buttonBox_rejected()
+{
+ hide();
+}
+
frs_return_t
FollowStreamDialog::follow_read_stream()
{
follow_info->is_ipv6 = stats.is_ipv6;
follow_read_stream();
+ ui->teStreamContent->moveCursor(QTextCursor::Start);
}
}
}
+// The following keyboard shortcuts should work (although
+// they may not work consistently depending on focus):
+// / (slash), Ctrl-F - Focus and highlight the search box
+// Ctrl-G, Ctrl-N, F3 - Find next
+// Should we make it so that typing any text starts searching?
+bool FollowStreamDialog::eventFilter(QObject *obj, QEvent *event)
+{
+ Q_UNUSED(obj)
+ if (ui->teStreamContent->hasFocus() && event->type() == QEvent::KeyPress) {
+ ui->leFind->setFocus();
+ QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
+ if (keyEvent->matches(QKeySequence::Find)) {
+ return true;
+ } else if (keyEvent->matches(QKeySequence::FindNext)) {
+ FindText();
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void FollowStreamDialog::keyPressEvent(QKeyEvent *event)
+{
+ if (ui->leFind->hasFocus()) {
+ if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
+ FindText();
+ return;
+ }
+ } else {
+ if (event->key() == Qt::Key_Slash || event->matches(QKeySequence::Find)) {
+ ui->leFind->setFocus();
+ ui->leFind->selectAll();
+ }
+ return;
+ }
+
+ if (event->key() == Qt::Key_F3 || event->key() == Qt::Key_N && event->modifiers() & Qt::ControlModifier) {
+ FindText();
+ return;
+ }
+
+ QDialog::keyPressEvent(event);
+}
+
+void FollowStreamDialog::closeEvent(QCloseEvent *event)
+{
+ Q_UNUSED(event)
+ hide();
+}
+
frs_return_t
FollowStreamDialog::follow_show(char *buffer, size_t nchars, gboolean is_from_server,
void add_text(char *buffer, size_t nchars, gboolean is_from_server);
+protected:
+ bool eventFilter(QObject *obj, QEvent *event);
+ void keyPressEvent(QKeyEvent *event);
+ void closeEvent (QCloseEvent *event);
+
private slots:
void on_cbCharset_currentIndexChanged(int index);
void on_cbDirections_currentIndexChanged(int index);
+ void on_bFind_clicked();
+ void on_leFind_returnPressed();
+ void on_buttonBox_rejected();
+
void HelpButton();
void FilterOut();
- void FindText();
+ void FindText(bool go_back = true);
void SaveAs();
void Print();
-// void on_bNext_clicked();
-// void on_bPrevious_clicked();
signals:
void updateFilter(QString &filter, bool force);
<x>0</x>
<y>0</y>
<width>667</width>
- <height>426</height>
+ <height>639</height>
</rect>
</property>
<property name="sizePolicy">
</sizepolicy>
</property>
<property name="windowTitle">
- <string>Dialog</string>
+ <string>Follow Stream</string>
</property>
- <widget class="QGroupBox" name="groupBox">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>0</y>
- <width>651</width>
- <height>381</height>
- </rect>
- </property>
- <property name="title">
- <string>Stream contents</string>
- </property>
- <widget class="QComboBox" name="cbDirections">
- <property name="geometry">
- <rect>
- <x>11</x>
- <y>352</y>
- <width>461</width>
- <height>27</height>
- </rect>
- </property>
- </widget>
- <widget class="QTextEdit" name="teStreamContent">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>20</y>
- <width>631</width>
- <height>321</height>
- </rect>
- </property>
- <property name="readOnly">
- <bool>true</bool>
- </property>
- </widget>
- <widget class="QWidget" name="layoutWidget">
- <property name="geometry">
- <rect>
- <x>480</x>
- <y>350</y>
- <width>158</width>
- <height>29</height>
- </rect>
- </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QTextEdit" name="teStreamContent">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
<layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QComboBox" name="cbDirections"/>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
<item>
<widget class="QLabel" name="label">
<property name="text">
</widget>
</item>
</layout>
- </widget>
- </widget>
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="geometry">
- <rect>
- <x>20</x>
- <y>390</y>
- <width>631</width>
- <height>27</height>
- </rect>
- </property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Help</set>
- </property>
- </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1,0">
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Find:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="leFind"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="bFind">
+ <property name="text">
+ <string>&Next</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Help</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
<resources/>
<connections/>