diff options
author | Pascal Quantin <pascal.quantin@gmail.com> | 2015-12-15 19:47:02 +0100 |
---|---|---|
committer | Stig Bjørlykke <stig@bjorlykke.org> | 2015-12-16 06:53:24 +0000 |
commit | bfe73e3ad7162830c222a5b0d73433a72324baa5 (patch) | |
tree | df1a1ee6779cb31093e9253152317e9f444fc91a /ui/qt/wireshark_application.cpp | |
parent | 3b706bab624a22c500adb3bdf50123f73e56c4ca (diff) | |
download | wireshark-bfe73e3ad7162830c222a5b0d73433a72324baa5.tar.gz |
Qt: save custom colors in recent_common file
This allows to save colors across sessions for systems other than
OSX that do not provide a system wide color picker
While we are at it, let's stop reading the recent file twice at startup
Bug: 11888
Change-Id: I69ff14d699d8111fe6a8bdac0157fcd115a60c2b
Reviewed-on: https://code.wireshark.org/review/12659
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Diffstat (limited to 'ui/qt/wireshark_application.cpp')
-rw-r--r-- | ui/qt/wireshark_application.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp index f1d1df43f6..45e0587b46 100644 --- a/ui/qt/wireshark_application.cpp +++ b/ui/qt/wireshark_application.cpp @@ -81,6 +81,7 @@ #include <QSocketNotifier> #include <QThread> #include <QUrl> +#include <QColorDialog> #ifdef Q_OS_WIN #include <QDebug> @@ -407,6 +408,38 @@ const QString WiresharkApplication::windowTitleString(QStringList title_parts) return title_parts.join(window_title_separator_); } +void WiresharkApplication::applyCustomColorsFromRecent() +{ + int i = 0; + bool ok; + for (GList *custom_color = recent.custom_colors; custom_color; custom_color = custom_color->next) { + QRgb rgb = QString((const char *)custom_color->data).toUInt(&ok, 16); + if (ok) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QColorDialog::setCustomColor(i++, rgb); +#else + QColorDialog::setCustomColor(i++, QColor(rgb)); +#endif + } + } +} + +void WiresharkApplication::storeCustomColorsInRecent() +{ + if (QColorDialog::customCount()) { + prefs_clear_string_list(recent.custom_colors); + recent.custom_colors = NULL; + for (int i = 0; i < QColorDialog::customCount(); i++) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QRgb rgb = QColorDialog::customColor(i); +#else + QRgb rgb = QColorDialog::customColor(i).rgb(); +#endif + recent.custom_colors = g_list_append(recent.custom_colors, g_strdup_printf("%08x", rgb)); + } + } +} + void WiresharkApplication::setLastOpenDir(const char *dir_name) { qint64 len; @@ -470,6 +503,7 @@ void WiresharkApplication::captureFileReadStarted() void WiresharkApplication::cleanup() { software_update_cleanup(); + storeCustomColorsInRecent(); // Write the user's recent file(s) to disk. write_profile_recent(); write_recent(); |