aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2013-10-14 21:17:38 +0000
committerGerald Combs <gerald@wireshark.org>2013-10-14 21:17:38 +0000
commit0efe942aab7e985c825422e3f7a0d2e5aee9a5b9 (patch)
treeac35d507b15f6d5596801f880c7beb29adc527c8
parent2e405d7261ee7a1ebfddbed468537de741b81571 (diff)
Let Qt lay out and size elements in FollowStreamDialog. Make it
resizable. Get rid of the group box -- the OS X and Windows HIGs discourage its use and I'm not sure if it fits the GNOME HIG in this case either. Make the stream contents monospace. Set the cursor to the beginning of the text when we follow a stream. Continue the War On Unnecessary Dialogs. Move "Find"ing from a pop-up window to the main Follow dialog. Wrap back to the beginning as needed. Add a "Cancel" button. Make sure it and the escape key work as expected. svn path=/trunk/; revision=52607
-rw-r--r--ui/qt/follow_stream_dialog.cpp98
-rw-r--r--ui/qt/follow_stream_dialog.h13
-rw-r--r--ui/qt/follow_stream_dialog.ui121
-rw-r--r--ui/qt/main_window_slots.cpp3
4 files changed, 157 insertions, 78 deletions
diff --git a/ui/qt/follow_stream_dialog.cpp b/ui/qt/follow_stream_dialog.cpp
index 1c3264520b..d919662f2d 100644
--- a/ui/qt/follow_stream_dialog.cpp
+++ b/ui/qt/follow_stream_dialog.cpp
@@ -44,6 +44,7 @@
#include "ws_symbol_export.h"
#include "qt_ui_utils.h"
+#include "wireshark_application.h"
#include "globals.h"
#include "file.h"
@@ -56,10 +57,11 @@
#include <zlib.h>
#endif
-#include <QInputDialog>
+#include <QKeyEvent>
#include <QMessageBox>
#include <QPrintDialog>
#include <QPrinter>
+#include <QTextEdit>
#include <QTextStream>
FollowStreamDialog::FollowStreamDialog(QWidget *parent) :
@@ -69,16 +71,16 @@ 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()));
@@ -99,16 +101,17 @@ void FollowStreamDialog::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);
}
}
@@ -201,6 +204,21 @@ void FollowStreamDialog::on_cbCharset_currentIndexChanged(int index)
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()
{
@@ -392,6 +410,7 @@ FollowStreamDialog::follow_stream()
follow_info->is_ipv6 = stats.is_ipv6;
follow_read_stream();
+ ui->teStreamContent->moveCursor(QTextCursor::Start);
}
@@ -463,6 +482,57 @@ void FollowStreamDialog::add_text(char *buffer, size_t nchars, gboolean is_from_
}
}
+// 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,
diff --git a/ui/qt/follow_stream_dialog.h b/ui/qt/follow_stream_dialog.h
index fdd943134a..5f8ec74714 100644
--- a/ui/qt/follow_stream_dialog.h
+++ b/ui/qt/follow_stream_dialog.h
@@ -93,16 +93,23 @@ public:
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);
diff --git a/ui/qt/follow_stream_dialog.ui b/ui/qt/follow_stream_dialog.ui
index bf9b1205ed..43c7042c2f 100644
--- a/ui/qt/follow_stream_dialog.ui
+++ b/ui/qt/follow_stream_dialog.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>667</width>
- <height>426</height>
+ <height>639</height>
</rect>
</property>
<property name="sizePolicy">
@@ -17,54 +17,38 @@
</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">
<string>Charset</string>
@@ -104,21 +88,36 @@
</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>&amp;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/>
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index c19763fb5b..de435c56e1 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -1703,6 +1703,9 @@ void MainWindow::on_actionAnalyzePAFOrNotSelected_triggered()
void MainWindow::on_actionAnalyzeFollowTCPStream_triggered()
{
+ // XXX Keeping a window or dialog in memory is common in the GTK+
+ // code but not in the Qt code. Should we just create a new
+ // dialog and exec() it instead?
follow_stream_dialog_.Follow(getFilter(), FOLLOW_TCP);
if (follow_stream_dialog_.isMinimized() == true)