Qt: Configure the selection color via the preferences

The active selection color and inactive selection color can be configured via Edit / Preferences / Font and Colors
There are 3 styles that can be used for the selection color:
Default: legacy behavior
Flat: Use background and foreground color with no gradient.
Gradient: Use background and foreground color with a gradient.

Bug: 14714
Change-Id: Ieca293bb9830d2c5702949d0459d1d6f679e41e4
Reviewed-on: https://code.wireshark.org/review/27701
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
This commit is contained in:
Paul Zander 2018-05-22 10:06:27 +02:00 committed by Stig Bjørlykke
parent 31663c4056
commit 53dfec9b99
7 changed files with 572 additions and 171 deletions

View File

@ -139,6 +139,13 @@ static const enum_val_t gui_update_channel[] = {
{NULL, NULL, -1}
};
static const enum_val_t gui_selection_style[] = {
{"DEFAULT", "DEFAULT", COLOR_STYLE_DEFAULT},
{"FLAT", "FLAT", COLOR_STYLE_FLAT},
{"GRADIENT", "GRADIENT", COLOR_STYLE_GRADIENT},
{NULL, NULL, -1}
};
#if defined(HAVE_PCAP_CREATE)
/* Can set monitor mode and buffer size. */
static gint num_capture_cols = 7;
@ -3091,6 +3098,24 @@ prefs_register_modules(void)
/* User Interface : Colors */
gui_color_module = prefs_register_subtree(gui_module, "Colors", "Colors", NULL);
prefs_register_color_preference(gui_color_module, "active_frame.fg", "Foregound color for an active selected item",
"Foregound color for an active selected item", &prefs.gui_active_fg);
prefs_register_color_preference(gui_color_module, "active_frame.bg", "Backgound color for an active selected item",
"Backgound color for an active selected item", &prefs.gui_active_bg);
prefs_register_enum_preference(gui_color_module, "active_frame.style", "Color style for an active selected item",
"Color style for an active selected item", &prefs.gui_active_style, gui_selection_style, FALSE);
prefs_register_color_preference(gui_color_module, "inactive_frame.fg", "Foregound color for an inactive selected item",
"Foregound color for an inactive selected item", &prefs.gui_inactive_fg);
prefs_register_color_preference(gui_color_module, "inactive_frame.bg", "Backgound color for an inactive selected item",
"Backgound color for an inactive selected item", &prefs.gui_inactive_bg);
prefs_register_enum_preference(gui_color_module, "inactive_frame.style", "Color style for an inactive selected item",
"Color style for an inactive selected item", &prefs.gui_inactive_style, gui_selection_style, FALSE);
prefs_register_color_preference(gui_color_module, "marked_frame.fg", "Color preferences for a marked frame",
"Color preferences for a marked frame", &prefs.gui_marked_fg);
@ -3955,6 +3980,20 @@ pre_init_prefs(void)
/* We try to find the best font in the Qt code */
g_free(prefs.gui_qt_font_name);
prefs.gui_qt_font_name = g_strdup("");
prefs.gui_active_fg.red = 0;
prefs.gui_active_fg.green = 0;
prefs.gui_active_fg.blue = 0;
prefs.gui_active_bg.red = 52223;
prefs.gui_active_bg.green = 59647;
prefs.gui_active_bg.blue = 65535;
prefs.gui_active_style = COLOR_STYLE_DEFAULT;
prefs.gui_inactive_fg.red = 0;
prefs.gui_inactive_fg.green = 0;
prefs.gui_inactive_fg.blue = 0;
prefs.gui_inactive_bg.red = 61439;
prefs.gui_inactive_bg.green = 61439;
prefs.gui_inactive_bg.blue = 61439;
prefs.gui_inactive_style = COLOR_STYLE_DEFAULT;
prefs.gui_marked_fg.red = 65535;
prefs.gui_marked_fg.green = 65535;
prefs.gui_marked_fg.blue = 65535;

View File

@ -64,6 +64,15 @@ char string_to_name_resolve(const char *string, struct _e_addr_resolve *name_res
#define TB_STYLE_TEXT 1
#define TB_STYLE_BOTH 2
/*
* Color styles.
*/
#define COLOR_STYLE_DEFAULT 0
#define COLOR_STYLE_FLAT 1
#define COLOR_STYLE_GRADIENT 2
#define COLOR_STYLE_ALPHA 0.25
/*
* Types of layout of summary/details/hex panes.
*/
@ -146,6 +155,12 @@ typedef struct _e_prefs {
gint gui_toolbar_main_style;
gint gui_toolbar_filter_style;
gchar *gui_qt_font_name;
color_t gui_active_fg;
color_t gui_active_bg;
gint gui_active_style;
color_t gui_inactive_fg;
color_t gui_inactive_bg;
gint gui_inactive_style;
color_t gui_marked_fg;
color_t gui_marked_bg;
color_t gui_ignored_fg;

View File

@ -36,6 +36,12 @@ FontColorPreferencesFrame::FontColorPreferencesFrame(QWidget *parent) :
ui->setupUi(this);
pref_qt_gui_font_name_ = prefFromPrefPtr(&prefs.gui_qt_font_name);
pref_active_fg_ = prefFromPrefPtr(&prefs.gui_active_fg);
pref_active_bg_ = prefFromPrefPtr(&prefs.gui_active_bg);
pref_active_style_ = prefFromPrefPtr(&prefs.gui_active_style);
pref_inactive_fg_ = prefFromPrefPtr(&prefs.gui_inactive_fg);
pref_inactive_bg_ = prefFromPrefPtr(&prefs.gui_inactive_bg);
pref_inactive_style_ = prefFromPrefPtr(&prefs.gui_inactive_style);
pref_marked_fg_ = prefFromPrefPtr(&prefs.gui_marked_fg);
pref_marked_bg_ = prefFromPrefPtr(&prefs.gui_marked_bg);
pref_ignored_fg_ = prefFromPrefPtr(&prefs.gui_ignored_fg);
@ -71,87 +77,207 @@ void FontColorPreferencesFrame::showEvent(QShowEvent *)
void FontColorPreferencesFrame::updateWidgets()
{
gint colorstyle;
QColor foreground;
QColor background1;
QColor background2;
QPalette default_pal;
int margin = style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
ui->fontPushButton->setText(
cur_font_.family() + " " + cur_font_.styleName() + " " +
QString::number(cur_font_.pointSizeF(), 'f', 1));
cur_font_.family() + " " + cur_font_.styleName() + " " +
QString::number(cur_font_.pointSizeF(), 'f', 1));
ui->fontSampleLineEdit->setFont(cur_font_);
QString line_edit_ss = QString("QLineEdit { margin-left: %1px; }").arg(margin);
ui->fontSampleLineEdit->setStyleSheet(line_edit_ss);
QString color_button_ss =
"QPushButton {"
" border: 1px solid palette(Dark);"
" background-color: %1;"
" margin-left: %2px;"
"}";
"QPushButton {"
" border: 1px solid palette(Dark);"
" background-color: %1;"
" margin-left: %2px;"
"}";
QString sample_text_ss =
"QLineEdit {"
" color: %1;"
" background-color: %2;"
"}";
"QLineEdit {"
" color: %1;"
" background-color: %2;"
"}";
QString sample_text_ex_ss =
"QLineEdit {"
" color: %1;"
" background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1 stop: 0 %3, stop: 0.5 %2, stop: 1 %3);"
"}";
//
// Sample active selected item
//
colorstyle = prefs_get_enum_value(pref_active_style_, pref_stashed);
// Make foreground and background colors
switch (colorstyle)
{
case COLOR_STYLE_DEFAULT:
default_pal = QApplication::palette();
default_pal.setCurrentColorGroup(QPalette::Active);
foreground = default_pal.highlightedText().color();
background1 = default_pal.highlight().color();
background2 = default_pal.highlight().color();
break;
case COLOR_STYLE_FLAT:
foreground = ColorUtils::fromColorT(prefs_get_color_value(pref_active_fg_, pref_stashed));
background1 = ColorUtils::fromColorT(prefs_get_color_value(pref_active_bg_, pref_stashed));
background2 = ColorUtils::fromColorT(prefs_get_color_value(pref_active_bg_, pref_stashed));
break;
case COLOR_STYLE_GRADIENT:
foreground = ColorUtils::fromColorT(prefs_get_color_value(pref_active_fg_, pref_stashed));
background1 = ColorUtils::fromColorT(prefs_get_color_value(pref_active_bg_, pref_stashed));
background2 = QColor::fromRgb(ColorUtils::alphaBlend(foreground, background1, COLOR_STYLE_ALPHA));
break;
}
ui->activeFGPushButton->setStyleSheet(color_button_ss.arg(foreground.name()).arg(margin));
ui->activeBGPushButton->setStyleSheet(color_button_ss.arg(background1.name()).arg(0));
ui->activeSampleLineEdit->setStyleSheet(sample_text_ex_ss.arg(
foreground.name(),
background1.name(),
background2.name()));
ui->activeSampleLineEdit->setFont(cur_font_);
ui->activeStyleComboBox->setCurrentIndex(prefs_get_enum_value(pref_active_style_, pref_stashed));
// Enable or disable the widgets
ui->activeFGPushButton->setEnabled(colorstyle != COLOR_STYLE_DEFAULT);
ui->activeBGPushButton->setEnabled(colorstyle != COLOR_STYLE_DEFAULT);
//
// Sample inactive selected item
//
colorstyle = prefs_get_enum_value(pref_inactive_style_, pref_stashed);
// Make foreground and background colors
switch (colorstyle)
{
case COLOR_STYLE_DEFAULT:
default_pal = QApplication::palette();
default_pal.setCurrentColorGroup(QPalette::Inactive);
foreground = default_pal.highlightedText().color();
background1 = default_pal.highlight().color();
background2 = default_pal.highlight().color();
break;
case COLOR_STYLE_FLAT:
foreground = ColorUtils::fromColorT(prefs_get_color_value(pref_inactive_fg_, pref_stashed));
background1 = ColorUtils::fromColorT(prefs_get_color_value(pref_inactive_bg_, pref_stashed));
background2 = ColorUtils::fromColorT(prefs_get_color_value(pref_inactive_bg_, pref_stashed));
break;
case COLOR_STYLE_GRADIENT:
foreground = ColorUtils::fromColorT(prefs_get_color_value(pref_inactive_fg_, pref_stashed));
background1 = ColorUtils::fromColorT(prefs_get_color_value(pref_inactive_bg_, pref_stashed));
background2 = QColor::fromRgb(ColorUtils::alphaBlend(foreground, background1, COLOR_STYLE_ALPHA));
break;
}
ui->inactiveFGPushButton->setStyleSheet(color_button_ss.arg(foreground.name()).arg(margin));
ui->inactiveBGPushButton->setStyleSheet(color_button_ss.arg(background1.name()).arg(0));
ui->inactiveSampleLineEdit->setStyleSheet(sample_text_ex_ss.arg(
foreground.name(),
background1.name(),
background2.name()));
ui->inactiveSampleLineEdit->setFont(cur_font_);
ui->inactiveStyleComboBox->setCurrentIndex(prefs_get_enum_value(pref_inactive_style_, pref_stashed));
// Enable or disable the widgets
ui->inactiveFGPushButton->setEnabled(colorstyle != COLOR_STYLE_DEFAULT);
ui->inactiveBGPushButton->setEnabled(colorstyle != COLOR_STYLE_DEFAULT);
//
// Sample marked packet text
//
ui->markedFGPushButton->setStyleSheet(color_button_ss.arg(
ColorUtils::fromColorT(prefs_get_color_value(pref_marked_fg_, pref_stashed)).name())
.arg(margin));
.arg(margin));
ui->markedBGPushButton->setStyleSheet(color_button_ss.arg(
ColorUtils::fromColorT(prefs_get_color_value(pref_marked_bg_, pref_stashed)).name())
.arg(0));
.arg(0));
ui->markedSampleLineEdit->setStyleSheet(sample_text_ss.arg(
ColorUtils::fromColorT(prefs_get_color_value(pref_marked_fg_, pref_stashed)).name(),
ColorUtils::fromColorT(prefs_get_color_value(pref_marked_bg_, pref_stashed)).name()));
ui->markedSampleLineEdit->setFont(cur_font_);
//
// Sample ignored packet text
//
ui->ignoredFGPushButton->setStyleSheet(color_button_ss.arg(
ColorUtils::fromColorT(prefs_get_color_value(pref_ignored_fg_, pref_stashed)).name())
.arg(margin));
ColorUtils::fromColorT(prefs_get_color_value(pref_ignored_fg_, pref_stashed)).name())
.arg(margin));
ui->ignoredBGPushButton->setStyleSheet(color_button_ss.arg(
ColorUtils::fromColorT(prefs_get_color_value(pref_ignored_bg_, pref_stashed)).name())
.arg(0));
ColorUtils::fromColorT(prefs_get_color_value(pref_ignored_bg_, pref_stashed)).name())
.arg(0));
ui->ignoredSampleLineEdit->setStyleSheet(sample_text_ss.arg(
ColorUtils::fromColorT(prefs_get_color_value(pref_ignored_fg_, pref_stashed)).name(),
ColorUtils::fromColorT(prefs_get_color_value(pref_ignored_bg_, pref_stashed)).name()));
ColorUtils::fromColorT(prefs_get_color_value(pref_ignored_fg_, pref_stashed)).name(),
ColorUtils::fromColorT(prefs_get_color_value(pref_ignored_bg_, pref_stashed)).name()));
ui->ignoredSampleLineEdit->setFont(cur_font_);
//
// Sample "Follow Stream" client text
//
ui->clientFGPushButton->setStyleSheet(color_button_ss.arg(
ColorUtils::fromColorT(prefs_get_color_value(pref_client_fg_, pref_stashed)).name())
.arg(margin));
.arg(margin));
ui->clientBGPushButton->setStyleSheet(color_button_ss.arg(
ColorUtils::fromColorT(prefs_get_color_value(pref_client_bg_, pref_stashed)).name())
.arg(0));
.arg(0));
ui->clientSampleLineEdit->setStyleSheet(sample_text_ss.arg(
ColorUtils::fromColorT(prefs_get_color_value(pref_client_fg_, pref_stashed)).name(),
ColorUtils::fromColorT(prefs_get_color_value(pref_client_bg_, pref_stashed)).name()));
ui->clientSampleLineEdit->setFont(cur_font_);
//
// Sample "Follow Stream" server text
//
ui->serverFGPushButton->setStyleSheet(color_button_ss.arg(
ColorUtils::fromColorT(prefs_get_color_value(pref_server_fg_, pref_stashed)).name())
.arg(margin));
.arg(margin));
ui->serverBGPushButton->setStyleSheet(color_button_ss.arg(
ColorUtils::fromColorT(prefs_get_color_value(pref_server_bg_, pref_stashed)).name())
.arg(0));
.arg(0));
ui->serverSampleLineEdit->setStyleSheet(sample_text_ss.arg(
ColorUtils::fromColorT(prefs_get_color_value(pref_server_fg_, pref_stashed)).name(),
ColorUtils::fromColorT(prefs_get_color_value(pref_server_bg_, pref_stashed)).name()));
ui->serverSampleLineEdit->setFont(cur_font_);
//
// Sample valid filter
//
ui->validFilterBGPushButton->setStyleSheet(color_button_ss.arg(
ColorUtils::fromColorT(prefs_get_color_value(pref_valid_bg_, pref_stashed)).name())
.arg(0));
.arg(0));
ui->validFilterSampleLineEdit->setStyleSheet(sample_text_ss.arg(
"palette(text)",
ColorUtils::fromColorT(prefs_get_color_value(pref_valid_bg_, pref_stashed)).name()));
//
// Sample invalid filter
//
ui->invalidFilterBGPushButton->setStyleSheet(color_button_ss.arg(
ColorUtils::fromColorT(prefs_get_color_value(pref_invalid_bg_, pref_stashed)).name())
.arg(0));
.arg(0));
ui->invalidFilterSampleLineEdit->setStyleSheet(sample_text_ss.arg(
"palette(text)",
ColorUtils::fromColorT(prefs_get_color_value(pref_invalid_bg_, pref_stashed)).name()));
//
// Sample warning filter
//
ui->deprecatedFilterBGPushButton->setStyleSheet(color_button_ss.arg(
ColorUtils::fromColorT(prefs_get_color_value(pref_deprecated_bg_, pref_stashed)).name())
.arg(0));
.arg(0));
ui->deprecatedFilterSampleLineEdit->setStyleSheet(sample_text_ss.arg(
"palette(text)",
ColorUtils::fromColorT(prefs_get_color_value(pref_deprecated_bg_, pref_stashed)).name()));
@ -189,6 +315,39 @@ void FontColorPreferencesFrame::on_fontPushButton_clicked()
}
}
void FontColorPreferencesFrame::on_activeFGPushButton_clicked()
{
changeColor(pref_active_fg_);
}
void FontColorPreferencesFrame::on_activeBGPushButton_clicked()
{
changeColor(pref_active_bg_);
}
void FontColorPreferencesFrame::on_activeStyleComboBox_currentIndexChanged(int index)
{
prefs_set_enum_value(pref_active_style_, index, pref_stashed);
updateWidgets();
}
void FontColorPreferencesFrame::on_inactiveFGPushButton_clicked()
{
changeColor(pref_inactive_fg_);
}
void FontColorPreferencesFrame::on_inactiveBGPushButton_clicked()
{
changeColor(pref_inactive_bg_);
}
void FontColorPreferencesFrame::on_inactiveStyleComboBox_currentIndexChanged(int index)
{
prefs_set_enum_value(pref_inactive_style_, index, pref_stashed);
updateWidgets();
}
void FontColorPreferencesFrame::on_markedFGPushButton_clicked()
{
changeColor(pref_marked_fg_);

View File

@ -34,6 +34,12 @@ private:
Ui::FontColorPreferencesFrame *ui;
pref_t *pref_qt_gui_font_name_;
pref_t *pref_active_fg_;
pref_t *pref_active_bg_;
pref_t *pref_active_style_;
pref_t *pref_inactive_fg_;
pref_t *pref_inactive_bg_;
pref_t *pref_inactive_style_;
pref_t *pref_marked_fg_;
pref_t *pref_marked_bg_;
pref_t *pref_ignored_fg_;
@ -53,6 +59,12 @@ private:
private slots:
void on_fontPushButton_clicked();
void on_activeFGPushButton_clicked();
void on_activeBGPushButton_clicked();
void on_activeStyleComboBox_currentIndexChanged(int index);
void on_inactiveFGPushButton_clicked();
void on_inactiveBGPushButton_clicked();
void on_inactiveStyleComboBox_currentIndexChanged(int index);
void on_markedFGPushButton_clicked();
void on_markedBGPushButton_clicked();
void on_ignoredFGPushButton_clicked();

View File

@ -73,8 +73,11 @@
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QPushButton" name="ignoredBGPushButton">
<item row="0" column="0">
<widget class="QPushButton" name="activeFGPushButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="styleSheet">
<string notr="true">QPushButton { border: 1px solid palette(Dark); }</string>
</property>
@ -83,77 +86,120 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="ignoredSampleLineEdit">
<property name="text">
<string>Sample ignored packet text</string>
</property>
<property name="readOnly">
<item row="0" column="1">
<widget class="QPushButton" name="activeBGPushButton">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="clientBGPushButton">
<property name="styleSheet">
<string notr="true">QPushButton { border: 1px solid palette(Dark); }</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="markedSampleLineEdit">
<property name="text">
<string>Sample marked packet text</string>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="activeSampleLineEdit">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Sample active selected item</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Style:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="activeStyleComboBox">
<item>
<property name="text">
<string>Default</string>
</property>
</item>
<item>
<property name="text">
<string>Flat</string>
</property>
</item>
<item>
<property name="text">
<string>Gradient</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="inactiveFGPushButton">
<property name="styleSheet">
<string notr="true">QPushButton { border: 1px solid palette(Dark); }</string>
</property>
<property name="readOnly">
<bool>true</bool>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="inactiveBGPushButton">
<property name="styleSheet">
<string notr="true">QPushButton { border: 1px solid palette(Dark); }</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLineEdit" name="inactiveSampleLineEdit">
<property name="text">
<string>Sample inactive selected item</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Style:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="inactiveStyleComboBox">
<item>
<property name="text">
<string>Default</string>
</property>
</item>
<item>
<property name="text">
<string>Flat</string>
</property>
</item>
<item>
<property name="text">
<string>Gradient</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="clientFGPushButton">
<property name="styleSheet">
<string notr="true">QPushButton { border: 1px solid palette(Dark); }</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="clientSampleLineEdit">
<property name="text">
<string>Sample &quot;Follow Stream&quot; client text</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="serverFGPushButton">
<property name="styleSheet">
<string notr="true">QPushButton { border: 1px solid palette(Dark); }</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLineEdit" name="serverSampleLineEdit">
<property name="text">
<string>Sample &quot;Follow Stream&quot; server text</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="markedFGPushButton">
<property name="styleSheet">
<string notr="true">QPushButton { border: 1px solid palette(Dark); }</string>
@ -163,7 +209,27 @@
</property>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="1">
<widget class="QPushButton" name="markedBGPushButton">
<property name="styleSheet">
<string notr="true">QPushButton { border: 1px solid palette(Dark); }</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="markedSampleLineEdit">
<property name="text">
<string>Sample marked packet text</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="ignoredFGPushButton">
<property name="styleSheet">
<string notr="true">QPushButton { border: 1px solid palette(Dark); }</string>
@ -174,7 +240,7 @@
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="serverBGPushButton">
<widget class="QPushButton" name="ignoredBGPushButton">
<property name="styleSheet">
<string notr="true">QPushButton { border: 1px solid palette(Dark); }</string>
</property>
@ -183,8 +249,28 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="markedBGPushButton">
<item row="3" column="2">
<widget class="QLineEdit" name="ignoredSampleLineEdit">
<property name="text">
<string>Sample ignored packet text</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QPushButton" name="clientFGPushButton">
<property name="styleSheet">
<string notr="true">QPushButton { border: 1px solid palette(Dark); }</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="clientBGPushButton">
<property name="styleSheet">
<string notr="true">QPushButton { border: 1px solid palette(Dark); }</string>
</property>
@ -194,37 +280,17 @@
</widget>
</item>
<item row="4" column="2">
<widget class="QLineEdit" name="validFilterSampleLineEdit">
<widget class="QLineEdit" name="clientSampleLineEdit">
<property name="text">
<string>Sample valid filter</string>
<string>Sample &quot;Follow Stream&quot; client text</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLineEdit" name="invalidFilterSampleLineEdit">
<property name="text">
<string>Sample invalid filter</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLineEdit" name="deprecatedFilterSampleLineEdit">
<property name="text">
<string>Sample warning filter</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="validFilterBGPushButton">
<item row="5" column="0">
<widget class="QPushButton" name="serverFGPushButton">
<property name="styleSheet">
<string notr="true">QPushButton { border: 1px solid palette(Dark); }</string>
</property>
@ -234,6 +300,46 @@
</widget>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="serverBGPushButton">
<property name="styleSheet">
<string notr="true">QPushButton { border: 1px solid palette(Dark); }</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLineEdit" name="serverSampleLineEdit">
<property name="text">
<string>Sample &quot;Follow Stream&quot; server text</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QPushButton" name="validFilterBGPushButton">
<property name="styleSheet">
<string notr="true">QPushButton { border: 1px solid palette(Dark); }</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLineEdit" name="validFilterSampleLineEdit">
<property name="text">
<string>Sample valid filter</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QPushButton" name="invalidFilterBGPushButton">
<property name="styleSheet">
<string notr="true">QPushButton { border: 1px solid palette(Dark); }</string>
@ -243,7 +349,17 @@
</property>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="2">
<widget class="QLineEdit" name="invalidFilterSampleLineEdit">
<property name="text">
<string>Sample invalid filter</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QPushButton" name="deprecatedFilterBGPushButton">
<property name="styleSheet">
<string notr="true">QPushButton { border: 1px solid palette(Dark); }</string>
@ -253,6 +369,16 @@
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QLineEdit" name="deprecatedFilterSampleLineEdit">
<property name="text">
<string>Sample warning filter</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
@ -270,5 +396,6 @@
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -259,62 +259,6 @@ PacketList::PacketList(QWidget *parent) :
g_assert(gbl_cur_packet_list == NULL);
gbl_cur_packet_list = this;
bool style_inactive_selected = true;
#ifdef Q_OS_WIN // && Qt version >= 4.8.6
if (QSysInfo::windowsVersion() < QSysInfo::WV_WINDOWS8) {
if (IsAppThemed() && IsThemeActive()) {
style_inactive_selected = false;
}
}
#endif
if (style_inactive_selected) {
// XXX Style the protocol tree as well?
QPalette active_pal = palette();
active_pal.setCurrentColorGroup(QPalette::Active);
QColor active_border = QColor::fromRgb(ColorUtils::alphaBlend(
active_pal.highlightedText(),
active_pal.highlight(),
0.25));
QPalette inactive_pal = palette();
inactive_pal.setCurrentColorGroup(QPalette::Inactive);
QColor inactive_border = QColor::fromRgb(ColorUtils::alphaBlend(
inactive_pal.highlightedText(),
inactive_pal.highlight(),
0.25));
setStyleSheet(QString(
"QTreeView::item:selected:first:!active {"
" border-left: 1px solid %1;"
"}"
"QTreeView::item:selected:last:!active {"
" border-right: 1px solid %1;"
"}"
"QTreeView::item:selected:!active {"
" border-top: 0px solid %1;"
" border-bottom: 0px solid %1;"
" color: %2;"
// Use a linear background gradient
" background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1 stop: 0 %1, stop: 1 %3);"
"}"
"QTreeView::item:selected:active {"
" border-top: 0px solid %4;"
" border-bottom: 0px solid %4;"
" color: %5;"
// Use a linear background gradient
" background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1 stop: 0 %4, stop: 1 %6);"
"}")
.arg(inactive_border.name())
.arg(inactive_pal.highlightedText().color().name())
.arg(inactive_pal.highlight().color().name())
.arg(active_border.name())
.arg(active_pal.highlightedText().color().name())
.arg(active_pal.highlight().color().name())
);
}
connect(packet_list_model_, SIGNAL(goToPacket(int)), this, SLOT(goToPacket(int)));
connect(packet_list_model_, SIGNAL(itemHeightChanged(const QModelIndex&)), this, SLOT(updateRowHeights(const QModelIndex&)));
connect(wsApp, SIGNAL(addressResolutionChanged()), this, SLOT(redrawVisiblePacketsDontSelectCurrent()));
@ -336,6 +280,107 @@ PacketList::PacketList(QWidget *parent) :
this, SIGNAL(editProtocolPreference(preference*,pref_module*)));
}
void PacketList::colorsChanged()
{
const QString c_active = "active";
const QString c_inactive = "!active";
QString default_style_format =
"QTreeView::item:selected:%1 {}";
QString flat_style_format =
"QTreeView::item:selected:%1 {"
" color: %2;"
" background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1 stop: 0 %3, stop: 1 %3);"
"}";
QString gradient_style_format =
"QTreeView::item:selected:%1 {"
" color: %2;"
" background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1 stop: 0 %4, stop: 0.5 %3, stop: 1 %4);"
"}";
QString active_style = QString();
QString inactive_style = QString();
bool style_inactive_selected = true;
#ifdef Q_OS_WIN // && Qt version >= 4.8.6
if (QSysInfo::windowsVersion() < QSysInfo::WV_WINDOWS8) {
if (IsAppThemed() && IsThemeActive()) {
style_inactive_selected = false;
}
}
#endif
if (prefs.gui_active_style == COLOR_STYLE_DEFAULT) {
// ACTIVE = Default
active_style = default_style_format.arg(c_active);
} else if (prefs.gui_active_style == COLOR_STYLE_FLAT) {
// ACTIVE = Flat OR Gradient
QColor foreground = ColorUtils::fromColorT(prefs.gui_active_fg);
QColor background = ColorUtils::fromColorT(prefs.gui_active_bg);
active_style = flat_style_format.arg(
c_active,
foreground.name(),
background.name());
} else if (prefs.gui_active_style == COLOR_STYLE_GRADIENT) {
// ACTIVE = Gradient
QColor foreground = ColorUtils::fromColorT(prefs.gui_active_fg);
QColor background1 = ColorUtils::fromColorT(prefs.gui_active_bg);
QColor background2 = QColor::fromRgb(ColorUtils::alphaBlend(foreground, background1, COLOR_STYLE_ALPHA));
active_style = gradient_style_format.arg(
c_active,
foreground.name(),
background1.name(),
background2.name());
}
// INACTIVE style sheet settings
if (prefs.gui_inactive_style == COLOR_STYLE_DEFAULT) {
// INACTIVE = Default
if (style_inactive_selected) {
QPalette inactive_pal = palette();
inactive_pal.setCurrentColorGroup(QPalette::Inactive);
QColor foreground = inactive_pal.highlightedText().color();
QColor background = inactive_pal.highlight().color();
inactive_style = flat_style_format.arg(
c_inactive,
foreground.name(),
background.name());
} else {
inactive_style = default_style_format.arg(c_inactive);
}
} else if (prefs.gui_inactive_style == COLOR_STYLE_FLAT) {
// INACTIVE = Flat
QColor foreground = ColorUtils::fromColorT(prefs.gui_inactive_fg);
QColor background = ColorUtils::fromColorT(prefs.gui_inactive_bg);
inactive_style = flat_style_format.arg(
c_inactive,
foreground.name(),
background.name());
} else if (prefs.gui_inactive_style == COLOR_STYLE_GRADIENT) {
// INACTIVE = Gradient
QColor foreground = ColorUtils::fromColorT(prefs.gui_inactive_fg);
QColor background1 = ColorUtils::fromColorT(prefs.gui_inactive_bg);
QColor background2 = QColor::fromRgb(ColorUtils::alphaBlend(foreground, background1, COLOR_STYLE_ALPHA));
inactive_style = gradient_style_format.arg(
c_inactive,
foreground.name(),
background1.name(),
background2.name());
}
// Set the style sheet
setStyleSheet(active_style + inactive_style);
}
void PacketList::drawRow (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QTreeView::drawRow(painter, option, index);
@ -820,6 +865,9 @@ void PacketList::applyRecentColumnWidths()
void PacketList::preferencesChanged()
{
// Update color style changes
colorsChanged();
// Related packet delegate
if (prefs.gui_packet_list_show_related) {
setItemDelegateForColumn(0, &related_packet_delegate_);

View File

@ -134,6 +134,7 @@ private:
void drawCurrentPacket();
void applyRecentColumnWidths();
void scrollViewChanged(bool at_end);
void colorsChanged();
signals:
void packetDissectionChanged();