summaryrefslogtreecommitdiff
path: root/ui/qt/font_color_preferences_frame.cpp
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2017-01-07 08:52:23 -0500
committerAnders Broman <a.broman58@gmail.com>2017-01-22 10:43:57 +0000
commit21a3b8cc71ac127e21375c62e0a738db8f3ea286 (patch)
tree5295e34869b8968b328fbf197815ae3d168e0d5e /ui/qt/font_color_preferences_frame.cpp
parent76cf1d0b0a0b804b24bea6afb4a4620a1607b144 (diff)
downloadwireshark-21a3b8cc71ac127e21375c62e0a738db8f3ea286.tar.gz
Internalize struct preference
Move "struct preference" into prefs.c, essentially creating a "private" structure to handle preferences. The 2 motivating factors were: 1. Better memory management so that clients/users of API don't have to worry about it. 2. Hide the ugliness of the union stuff and make it transparent to the API. A few bugs related to preference <-> Decode As integration were fixed while in the neighborhood. Change-Id: I509b9a236235d066b139c98222b701475e0ed365 Reviewed-on: https://code.wireshark.org/review/19578 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/qt/font_color_preferences_frame.cpp')
-rw-r--r--ui/qt/font_color_preferences_frame.cpp64
1 files changed, 33 insertions, 31 deletions
diff --git a/ui/qt/font_color_preferences_frame.cpp b/ui/qt/font_color_preferences_frame.cpp
index 7f90510ad7..84529d1849 100644
--- a/ui/qt/font_color_preferences_frame.cpp
+++ b/ui/qt/font_color_preferences_frame.cpp
@@ -56,7 +56,7 @@ FontColorPreferencesFrame::FontColorPreferencesFrame(QWidget *parent) :
pref_invalid_bg_ = prefFromPrefPtr(&prefs.gui_text_invalid);
pref_deprecated_bg_ = prefFromPrefPtr(&prefs.gui_text_deprecated);
- cur_font_.fromString(pref_qt_gui_font_name_->stashed_val.string);
+ cur_font_.fromString(prefs_get_string_value(pref_qt_gui_font_name_, pref_stashed));
}
@@ -102,83 +102,86 @@ void FontColorPreferencesFrame::updateWidgets()
"}";
ui->markedFGPushButton->setStyleSheet(color_button_ss.arg(
- ColorUtils::fromColorT(&pref_marked_fg_->stashed_val.color).name())
+ ColorUtils::fromColorT(prefs_get_color_value(pref_marked_fg_, pref_stashed)).name())
.arg(margin));
ui->markedBGPushButton->setStyleSheet(color_button_ss.arg(
- ColorUtils::fromColorT(&pref_marked_bg_->stashed_val.color).name())
+ ColorUtils::fromColorT(prefs_get_color_value(pref_marked_bg_, pref_stashed)).name())
.arg(0));
ui->markedSampleLineEdit->setStyleSheet(sample_text_ss.arg(
- ColorUtils::fromColorT(&pref_marked_fg_->stashed_val.color).name(),
- ColorUtils::fromColorT(&pref_marked_bg_->stashed_val.color).name()));
+ 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_);
ui->ignoredFGPushButton->setStyleSheet(color_button_ss.arg(
- ColorUtils::fromColorT(&pref_ignored_fg_->stashed_val.color).name())
+ ColorUtils::fromColorT(prefs_get_color_value(pref_ignored_fg_, pref_stashed)).name())
.arg(margin));
ui->ignoredBGPushButton->setStyleSheet(color_button_ss.arg(
- ColorUtils::fromColorT(&pref_ignored_bg_->stashed_val.color).name())
+ ColorUtils::fromColorT(prefs_get_color_value(pref_ignored_bg_, pref_stashed)).name())
.arg(0));
ui->ignoredSampleLineEdit->setStyleSheet(sample_text_ss.arg(
- ColorUtils::fromColorT(&pref_ignored_fg_->stashed_val.color).name(),
- ColorUtils::fromColorT(&pref_ignored_bg_->stashed_val.color).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_);
ui->clientFGPushButton->setStyleSheet(color_button_ss.arg(
- ColorUtils::fromColorT(&pref_client_fg_->stashed_val.color).name())
+ ColorUtils::fromColorT(prefs_get_color_value(pref_client_fg_, pref_stashed)).name())
.arg(margin));
ui->clientBGPushButton->setStyleSheet(color_button_ss.arg(
- ColorUtils::fromColorT(&pref_client_bg_->stashed_val.color).name())
+ ColorUtils::fromColorT(prefs_get_color_value(pref_client_bg_, pref_stashed)).name())
.arg(0));
ui->clientSampleLineEdit->setStyleSheet(sample_text_ss.arg(
- ColorUtils::fromColorT(&pref_client_fg_->stashed_val.color).name(),
- ColorUtils::fromColorT(&pref_client_bg_->stashed_val.color).name()));
+ 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_);
ui->serverFGPushButton->setStyleSheet(color_button_ss.arg(
- ColorUtils::fromColorT(&pref_server_fg_->stashed_val.color).name())
+ ColorUtils::fromColorT(prefs_get_color_value(pref_server_fg_, pref_stashed)).name())
.arg(margin));
ui->serverBGPushButton->setStyleSheet(color_button_ss.arg(
- ColorUtils::fromColorT(&pref_server_bg_->stashed_val.color).name())
+ ColorUtils::fromColorT(prefs_get_color_value(pref_server_bg_, pref_stashed)).name())
.arg(0));
ui->serverSampleLineEdit->setStyleSheet(sample_text_ss.arg(
- ColorUtils::fromColorT(&pref_server_fg_->stashed_val.color).name(),
- ColorUtils::fromColorT(&pref_server_bg_->stashed_val.color).name()));
+ 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_);
ui->validFilterBGPushButton->setStyleSheet(color_button_ss.arg(
- ColorUtils::fromColorT(&pref_valid_bg_->stashed_val.color).name())
+ ColorUtils::fromColorT(prefs_get_color_value(pref_valid_bg_, pref_stashed)).name())
.arg(0));
ui->validFilterSampleLineEdit->setStyleSheet(sample_text_ss.arg(
"palette(text)",
- ColorUtils::fromColorT(&pref_valid_bg_->stashed_val.color).name()));
+ ColorUtils::fromColorT(prefs_get_color_value(pref_valid_bg_, pref_stashed)).name()));
ui->invalidFilterBGPushButton->setStyleSheet(color_button_ss.arg(
- ColorUtils::fromColorT(&pref_invalid_bg_->stashed_val.color).name())
+ ColorUtils::fromColorT(prefs_get_color_value(pref_invalid_bg_, pref_stashed)).name())
.arg(0));
ui->invalidFilterSampleLineEdit->setStyleSheet(sample_text_ss.arg(
"palette(text)",
- ColorUtils::fromColorT(&pref_invalid_bg_->stashed_val.color).name()));
+ ColorUtils::fromColorT(prefs_get_color_value(pref_invalid_bg_, pref_stashed)).name()));
ui->deprecatedFilterBGPushButton->setStyleSheet(color_button_ss.arg(
- ColorUtils::fromColorT(&pref_deprecated_bg_->stashed_val.color).name())
+ ColorUtils::fromColorT(prefs_get_color_value(pref_deprecated_bg_, pref_stashed)).name())
.arg(0));
ui->deprecatedFilterSampleLineEdit->setStyleSheet(sample_text_ss.arg(
"palette(text)",
- ColorUtils::fromColorT(&pref_deprecated_bg_->stashed_val.color).name()));
+ ColorUtils::fromColorT(prefs_get_color_value(pref_deprecated_bg_, pref_stashed)).name()));
}
void FontColorPreferencesFrame::changeColor(pref_t *pref)
{
QColorDialog color_dlg;
+ color_t* color = prefs_get_color_value(pref, pref_stashed);
color_dlg.setCurrentColor(QColor(
- pref->stashed_val.color.red >> 8,
- pref->stashed_val.color.green >> 8,
- pref->stashed_val.color.blue >> 8
+ color->red >> 8,
+ color->green >> 8,
+ color->blue >> 8
));
if (color_dlg.exec() == QDialog::Accepted) {
QColor cc = color_dlg.currentColor();
- pref->stashed_val.color.red = cc.red() << 8 | cc.red();
- pref->stashed_val.color.green = cc.green() << 8 | cc.green();
- pref->stashed_val.color.blue = cc.blue() << 8 | cc.blue();
+ color_t new_color;
+ new_color.red = cc.red() << 8 | cc.red();
+ new_color.green = cc.green() << 8 | cc.green();
+ new_color.blue = cc.blue() << 8 | cc.blue();
+ prefs_set_color_value(pref, new_color, pref_stashed);
updateWidgets();
}
}
@@ -188,8 +191,7 @@ void FontColorPreferencesFrame::on_fontPushButton_clicked()
bool ok;
QFont new_font = QFontDialog::getFont(&ok, cur_font_, this, wsApp->windowTitleString(tr("Font")));
if (ok) {
- g_free(pref_qt_gui_font_name_->stashed_val.string);
- pref_qt_gui_font_name_->stashed_val.string = qstring_strdup(new_font.toString());
+ prefs_set_string_value(pref_qt_gui_font_name_, new_font.toString().toStdString().c_str(), pref_stashed);
cur_font_ = new_font;
updateWidgets();
}