summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/wireshark_application.cpp34
-rw-r--r--ui/qt/wireshark_application.h2
-rw-r--r--ui/recent.c10
-rw-r--r--ui/recent.h1
4 files changed, 47 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();
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. */