From 2474af635d2bf2406e27150050f5508083010352 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Sun, 21 Sep 2014 13:28:29 -0700 Subject: [PATCH] Qt: Use wsiconcap while we're capturing. Set the main window icon to the "wsiconcap" version while we're capturing similar to the GTK+ version. Verified on Windows. Not sure if this will do anything on other platforms. Change-Id: I9b082601a2c47e5f52cc38ac8d9b4d9f5fb9a4d9 Reviewed-on: https://code.wireshark.org/review/4230 Petri-Dish: Gerald Combs Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs --- Makefile.am | 1 + image/wsicon.qrc | 22 ++++++++++++++++++++++ ui/qt/CMakeLists.txt | 1 + ui/qt/Makefile.common | 1 + ui/qt/Wireshark.pro | 1 + ui/qt/main_window_slots.cpp | 11 +++++++---- ui/qt/wireshark_application.cpp | 9 +++++++++ ui/qt/wireshark_application.h | 5 +++++ 8 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 image/wsicon.qrc diff --git a/Makefile.am b/Makefile.am index cba4952375..c2a2aa59fd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1065,6 +1065,7 @@ EXTRA_DIST = \ image/WiresharkDoc-128.png \ image/WiresharkDoc-256.png \ image/wiretap.rc.in \ + image/wsicon.qrc \ image/wsicon.svg \ image/wsicon16.png \ image/wsicon24.png \ diff --git a/image/wsicon.qrc b/image/wsicon.qrc new file mode 100644 index 0000000000..1e833e72ab --- /dev/null +++ b/image/wsicon.qrc @@ -0,0 +1,22 @@ + + + wsiconcap16.png + wsiconcap24.png + wsiconcap32.png + wsiconcap48.png + wsiconcap64.png + wsiconcap128.png + wsiconcap256.png + wsiconcap512.png + wsiconcap1024.png + wsicon16.png + wsicon24.png + wsicon32.png + wsicon48.png + wsicon64.png + wsicon128.png + wsicon256.png + wsicon512.png + wsicon1024.png + + diff --git a/ui/qt/CMakeLists.txt b/ui/qt/CMakeLists.txt index 02a32938bb..bacb144fb9 100644 --- a/ui/qt/CMakeLists.txt +++ b/ui/qt/CMakeLists.txt @@ -283,6 +283,7 @@ set(WIRESHARK_QT_QRC ../../image/layout.qrc ../../image/status.qrc ../../image/toolbar.qrc + ../../image/wsicon.qrc i18n.qrc ) diff --git a/ui/qt/Makefile.common b/ui/qt/Makefile.common index d869da1501..9e9941e8e1 100644 --- a/ui/qt/Makefile.common +++ b/ui/qt/Makefile.common @@ -263,6 +263,7 @@ QRC_FILES = \ ../../image/layout.qrc \ ../../image/status.qrc \ ../../image/toolbar.qrc \ + ../../image/wsicon.qrc \ i18n.qrc # diff --git a/ui/qt/Wireshark.pro b/ui/qt/Wireshark.pro index 01a27b9b35..c01681ff42 100644 --- a/ui/qt/Wireshark.pro +++ b/ui/qt/Wireshark.pro @@ -499,6 +499,7 @@ RESOURCES += \ ../../image/layout.qrc \ ../../image/status.qrc \ ../../image/toolbar.qrc \ + ../../image/wsicon.qrc \ i18n.qrc \ diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index 712c08c3b6..f9e73b60c3 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -373,10 +373,7 @@ void MainWindow::captureCapturePrepared(capture_session *cap_session) { qDebug() << "FIX captureCapturePrepared"; setTitlebarForCaptureInProgress(); -// if(icon_list == NULL) { -// icon_list = icon_list_create(wsiconcap16_xpm, wsiconcap32_xpm, wsiconcap48_xpm, NULL); -// } -// gtk_window_set_icon_list(GTK_WINDOW(top_level), icon_list); + setWindowIcon(wsApp->captureIcon()); /* Disable menu items that make no sense if you're currently running a capture. */ @@ -417,6 +414,8 @@ void MainWindow::captureCaptureUpdateFinished(capture_session *cap_session) { /* Enable menu items that make sense if you're not currently running a capture. */ setForCaptureInProgress(false); + + setWindowIcon(wsApp->normalIcon()); #endif // HAVE_LIBPCAP } void MainWindow::captureCaptureFixedStarted(capture_session *cap_session) { @@ -436,6 +435,8 @@ void MainWindow::captureCaptureFixedFinished(capture_session *cap_session) { /* Enable menu items that make sense if you're not currently running a capture. */ setForCaptureInProgress(false); + + setWindowIcon(wsApp->normalIcon()); #endif // HAVE_LIBPCAP } void MainWindow::captureCaptureStopping(capture_session *cap_session) { @@ -454,6 +455,8 @@ void MainWindow::captureCaptureFailed(capture_session *cap_session) { capture_stopping_ = false; setForCaptureInProgress(false); + + setWindowIcon(wsApp->normalIcon()); #endif // HAVE_LIBPCAP } diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp index 04ac8b03cb..fb0991fbb6 100644 --- a/ui/qt/wireshark_application.cpp +++ b/ui/qt/wireshark_application.cpp @@ -580,6 +580,7 @@ WiresharkApplication::WiresharkApplication(int &argc, char **argv) : Q_INIT_RESOURCE(layout); Q_INIT_RESOURCE(status); Q_INIT_RESOURCE(toolbar); + Q_INIT_RESOURCE(wsicon); #ifdef Q_OS_WIN /* RichEd20.DLL is needed for native file dialog filter entries. */ @@ -594,6 +595,14 @@ WiresharkApplication::WiresharkApplication(int &argc, char **argv) : setAttribute(Qt::AA_DontShowIconsInMenus, true); + QList icon_sizes = QList() << 16 << 24 << 32 << 48 << 64 << 128 << 256 << 512 << 1024; + foreach (int icon_size, icon_sizes) { + QString icon_path = QString(":/wsicon/wsicon%1.png").arg(icon_size); + normal_icon_.addFile(icon_path); + icon_path = QString(":/wsicon/wsiconcap%1.png").arg(icon_size); + capture_icon_.addFile(icon_path); + } + recent_timer_.setParent(this); connect(&recent_timer_, SIGNAL(timeout()), this, SLOT(refreshRecentFiles())); recent_timer_.start(2000); diff --git a/ui/qt/wireshark_application.h b/ui/qt/wireshark_application.h index 6b758d2c8a..cdfac6c7ae 100644 --- a/ui/qt/wireshark_application.h +++ b/ui/qt/wireshark_application.h @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -89,6 +90,8 @@ public: int monospaceTextSize(const char *str, bool bold = false); void setConfigurationProfile(const gchar *profile_name); bool isInitialized() { return initialized_; } + const QIcon &normalIcon() const { return normal_icon_; } + const QIcon &captureIcon() const { return capture_icon_; } private: bool initialized_; @@ -99,6 +102,8 @@ private: QTimer tap_update_timer_; QList pending_open_files_; QSocketNotifier *if_notifier_; + QIcon normal_icon_; + QIcon capture_icon_; protected: bool event(QEvent *event);