Qt: Add option to back white line separator for packet list items

This uses one line (on bottom) of items and makes it white.
Seen in Wireshark on some configurations of GTK 2 on Linux,
so backports it to Qt for people who like it.

In my opinion it helps if you use packet list background colors
for frames and you have a lot of following frames with
the same background color.

Bug: 10954
Change-Id: Id8f58520d7224db4eb8181bcc04febd7416a8578
Reviewed-on: https://code.wireshark.org/review/7293
Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
This commit is contained in:
Michal Labedzki 2015-02-18 13:30:06 +01:00
parent 7e13cacb9b
commit 1e487664bc
7 changed files with 59 additions and 2 deletions

View File

@ -2337,10 +2337,16 @@ prefs_register_modules(void)
"Layout content of the pane 3",
(gint*)(void*)(&prefs.gui_layout_content_3), gui_layout_content, FALSE);
prefs_register_bool_preference(gui_layout_module, "packet_list_separator.enabled",
"Enable Packet List Separator",
"Enable Packet List Separator",
&prefs.gui_qt_packet_list_separator);
prefs_register_bool_preference(gui_module, "packet_editor.enabled",
"Enable Packet Editor",
"Enable Packet Editor (Experimental)",
&prefs.gui_packet_editor);
/* Console
* These are preferences that can be read/written using the
* preference module API. These preferences still use their own
@ -2975,6 +2981,8 @@ pre_init_prefs(void)
prefs.gui_layout_content_3 = layout_pane_content_pbytes;
prefs.gui_packet_editor = FALSE;
prefs.gui_qt_packet_list_separator = FALSE;
if (!prefs.col_list) {
/* First time through */
for (i = 0; i < DEF_NUM_COLS; i++) {

View File

@ -212,7 +212,7 @@ typedef struct _e_prefs {
gchar *saved_at_version;
gboolean unknown_prefs; /* unknown or obsolete pref(s) */
gboolean unknown_colorfilters; /* unknown or obsolete color filter(s) */
guint gui_qt_language; /* Qt Translation language selection */
gboolean gui_qt_packet_list_separator;
gboolean gui_packet_editor; /* Enable Packet Editor */
gboolean st_enable_burstinfo;
gboolean st_burst_showcount;

View File

@ -47,6 +47,9 @@ LayoutPreferencesFrame::LayoutPreferencesFrame(QWidget *parent) :
ui->layout4ToolButton->setStyleSheet(image_pad_ss);
ui->layout5ToolButton->setStyleSheet(image_pad_ss);
ui->layout6ToolButton->setStyleSheet(image_pad_ss);
pref_packet_list_separator_ = prefFromPrefPtr(&prefs.gui_qt_packet_list_separator);
ui->packetListSeparatorCheckBox->setChecked(pref_packet_list_separator_->stashed_val.boolval);
}
LayoutPreferencesFrame::~LayoutPreferencesFrame()
@ -282,6 +285,13 @@ void LayoutPreferencesFrame::on_restoreButtonBox_clicked(QAbstractButton *)
updateWidgets();
pref_layout_content_3_->stashed_val.enumval = pref_layout_content_3_->default_val.enumval;
updateWidgets();
ui->packetListSeparatorCheckBox->setChecked(pref_packet_list_separator_->default_val.boolval);
}
void LayoutPreferencesFrame::on_packetListSeparatorCheckBox_toggled(bool checked)
{
pref_packet_list_separator_->stashed_val.boolval = (gboolean) checked;
}
/*

View File

@ -49,6 +49,7 @@ private:
pref_t *pref_layout_content_1_;
pref_t *pref_layout_content_2_;
pref_t *pref_layout_content_3_;
pref_t *pref_packet_list_separator_;
void updateWidgets();
@ -72,6 +73,7 @@ private slots:
void on_pane3PacketBytesRadioButton_toggled(bool checked);
void on_pane3NoneRadioButton_toggled(bool checked);
void on_restoreButtonBox_clicked(QAbstractButton *button);
void on_packetListSeparatorCheckBox_toggled(bool checked);
};

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>414</width>
<height>259</height>
<height>287</height>
</rect>
</property>
<property name="windowTitle">
@ -328,6 +328,29 @@
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="packetListSeparatorCheckBox">
<property name="text">
<string>Show packet separator on Packet List</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@ -442,6 +442,18 @@ PacketList::PacketList(QWidget *parent) :
this, SIGNAL(editProtocolPreference(preference*,pref_module*)));
}
void PacketList::drawRow (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QTreeView::drawRow(painter, option, index);
if (prefs.gui_qt_packet_list_separator) {
QRect rect = visualRect(index);
painter->setPen(QColor(Qt::white));
painter->drawLine(0, rect.y() + rect.height() - 1, width(), rect.y() + rect.height() - 1);
}
}
void PacketList::setProtoTree (ProtoTree *proto_tree) {
proto_tree_ = proto_tree;

View File

@ -32,6 +32,7 @@
#include <QMenu>
#include <QTime>
#include <QTreeView>
#include <QPainter>
class OverlayScrollBar;
@ -81,6 +82,7 @@ protected:
protected slots:
void rowsInserted(const QModelIndex &parent, int start, int end);
void drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const;
private:
PacketListModel *packet_list_model_;