diff options
-rw-r--r-- | ui/qt/wireshark_application.cpp | 34 | ||||
-rw-r--r-- | ui/qt/wireshark_application.h | 2 | ||||
-rw-r--r-- | ui/recent.c | 10 | ||||
-rw-r--r-- | ui/recent.h | 1 | ||||
-rw-r--r-- | wireshark-qt.cpp | 16 |
5 files changed, 48 insertions, 15 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(); diff --git a/ui/qt/wireshark_application.h b/ui/qt/wireshark_application.h index e4f74b86ef..6ed971e227 100644 --- a/ui/qt/wireshark_application.h +++ b/ui/qt/wireshark_application.h @@ -111,6 +111,7 @@ public: const QString &windowTitleSeparator() const { return window_title_separator_; } const QString windowTitleString(QStringList title_parts); const QString windowTitleString(QString title_part) { return windowTitleString(QStringList() << title_part); } + void applyCustomColorsFromRecent(); QTranslator translator; QTranslator translatorQt; @@ -130,6 +131,7 @@ private: static QString window_title_separator_; QList<AppSignal> app_signals_; int active_captures_; + void storeCustomColorsInRecent(); protected: bool event(QEvent *event); diff --git a/ui/recent.c b/ui/recent.c index 64c6c1ee11..56bc280aef 100644 --- a/ui/recent.c +++ b/ui/recent.c @@ -71,6 +71,7 @@ #define RECENT_GUI_CONVERSATION_TABS "gui.conversation_tabs" #define RECENT_GUI_ENDPOINT_TABS "gui.endpoint_tabs" #define RECENT_GUI_RLC_PDUS_FROM_MAC_FRAMES "gui.rlc_pdus_from_mac_frames" +#define RECENT_GUI_CUSTOM_COLORS "gui.custom_colors" #define RECENT_GUI_GEOMETRY "gui.geom." @@ -588,6 +589,7 @@ write_recent(void) char *pf_dir_path; char *rf_path; FILE *rf; + char *string_list; /* To do: * - Split output lines longer than MAX_VAL_LEN @@ -689,6 +691,12 @@ write_recent(void) window_geom_recent_write_all(rf); + fprintf(rf, "\n# Custom colors.\n"); + fprintf(rf, "# List of custom colors selected in Qt color picker.\n"); + string_list = join_string_list(recent.custom_colors); + fprintf(rf, RECENT_GUI_CUSTOM_COLORS ": %s\n", string_list); + g_free(string_list); + fclose(rf); /* XXX - catch I/O errors (e.g. "ran out of disk space") and return @@ -929,6 +937,8 @@ read_set_recent_common_pair_static(gchar *key, const gchar *value, parse_recent_boolean(value, &recent.privs_warn_if_elevated); } else if (strcmp(key, RECENT_KEY_PRIVS_WARN_IF_NO_NPF) == 0) { parse_recent_boolean(value, &recent.privs_warn_if_no_npf); + } else if (strcmp(key, RECENT_GUI_CUSTOM_COLORS) == 0) { + recent.custom_colors = prefs_get_string_list(value); } return PREFS_SET_OK; diff --git a/ui/recent.h b/ui/recent.h index 766f5be473..4daf917878 100644 --- a/ui/recent.h +++ b/ui/recent.h @@ -102,6 +102,7 @@ typedef struct recent_settings_tag { GList *endpoint_tabs; /* enabled endpoint dialog tabs */ gchar *gui_fileopen_remembered_dir; /* folder of last capture loaded in File Open dialog */ gboolean gui_rlc_use_pdus_from_mac; + GList *custom_colors; } recent_settings_t; /** Global recent settings. */ diff --git a/wireshark-qt.cpp b/wireshark-qt.cpp index 6f6e6f3669..fc9ef0c9d0 100644 --- a/wireshark-qt.cpp +++ b/wireshark-qt.cpp @@ -745,9 +745,6 @@ int main(int argc, char *argv[]) g_free(rf_path); } - /* Init the "Open file" dialog directory */ - /* (do this after the path settings are processed) */ - /* Read the profile dependent (static part) of the recent file. */ /* Only the static part of it will be read, as we don't have the gui now to fill the */ /* recent lists which is done in the dynamic part. */ @@ -758,6 +755,7 @@ int main(int argc, char *argv[]) rf_path, g_strerror(rf_open_errno)); g_free(rf_path); } + wsApp->applyCustomColorsFromRecent(); // Initialize our language read_language_prefs(); @@ -776,18 +774,6 @@ int main(int argc, char *argv[]) /* Init the "Open file" dialog directory */ /* (do this after the path settings are processed) */ - - /* Read the profile dependent (static part) of the recent file. */ - /* Only the static part of it will be read, as we don't have the gui now to fill the */ - /* recent lists which is done in the dynamic part. */ - /* We have to do this already here, so command line parameters can overwrite these values. */ - if (!recent_read_profile_static(&rf_path, &rf_open_errno)) { - simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, - "Could not open recent file\n\"%s\": %s.", - rf_path, g_strerror(rf_open_errno)); - g_free(rf_path); - } - if (recent.gui_fileopen_remembered_dir && test_for_directory(recent.gui_fileopen_remembered_dir) == EISDIR) { wsApp->setLastOpenDir(recent.gui_fileopen_remembered_dir); |