diff options
-rw-r--r-- | ui/qt/CMakeLists.txt | 3 | ||||
-rw-r--r-- | ui/qt/Makefile.common | 5 | ||||
-rw-r--r-- | ui/qt/QtShark.pro | 9 | ||||
-rw-r--r-- | ui/qt/main.cpp | 10 | ||||
-rw-r--r-- | ui/qt/main_welcome.cpp | 55 | ||||
-rw-r--r-- | ui/qt/main_welcome.h | 16 | ||||
-rw-r--r-- | ui/qt/splash_overlay.cpp | 205 | ||||
-rw-r--r-- | ui/qt/splash_overlay.h | 77 | ||||
-rw-r--r-- | ui/qt/splash_overlay.ui | 97 | ||||
-rw-r--r-- | ui/qt/wireshark_application.cpp | 6 | ||||
-rw-r--r-- | ui/qt/wireshark_application.h | 4 |
11 files changed, 430 insertions, 57 deletions
diff --git a/ui/qt/CMakeLists.txt b/ui/qt/CMakeLists.txt index 1a6aa0f0f5..fb3c025185 100644 --- a/ui/qt/CMakeLists.txt +++ b/ui/qt/CMakeLists.txt @@ -52,6 +52,7 @@ set(QTSHARK_H_SRC proto_tree.h recent_file_status.h simple_dialog_qt.h + splash_overlay.h syntax_line_edit.h wireshark_application.h @@ -94,6 +95,7 @@ set(QTSHARK_CPP_SRC recent_file_status.cpp simple_dialog_qt.cpp sparkline_delegate.cpp + splash_overlay.cpp syntax_line_edit.cpp wireshark_application.cpp ) @@ -111,6 +113,7 @@ set(QTSHARK_UI packet_format_group_box.ui packet_range_group_box.ui print_dialog.ui + splash_overlay.ui ) set(QTSHARK_QRC diff --git a/ui/qt/Makefile.common b/ui/qt/Makefile.common index 80b05e5d33..af284fb849 100644 --- a/ui/qt/Makefile.common +++ b/ui/qt/Makefile.common @@ -35,7 +35,8 @@ GENERATED_NODIST_HEADER_FILES = \ ui_main_welcome.h \ ui_main_window.h \ ui_packet_range_group_box.h \ - ui_print_dialog.h + ui_print_dialog.h \ + ui_splash_overlay.h # Generated C source files that we want in the distribution. GENERATED_C_FILES = @@ -97,6 +98,7 @@ MOC_HDRS = \ recent_file_status.h \ simple_dialog_qt.h \ sparkline_delegate.h \ + splash_overlay.h \ syntax_line_edit.h \ wireshark_application.h @@ -158,6 +160,7 @@ WIRESHARK_QT_SRC = \ recent_file_status.cpp \ simple_dialog_qt.cpp \ sparkline_delegate.cpp \ + splash_overlay.cpp \ syntax_line_edit.cpp \ wireshark_application.cpp diff --git a/ui/qt/QtShark.pro b/ui/qt/QtShark.pro index 78fa0ee475..0f49bce95b 100644 --- a/ui/qt/QtShark.pro +++ b/ui/qt/QtShark.pro @@ -184,7 +184,8 @@ FORMS += main_window.ui \ packet_range_group_box.ui \ packet_format_group_box.ui \ export_object_dialog.ui \ - print_dialog.ui + print_dialog.ui \ + splash_overlay.ui win32 { ## These should be in config.pri ?? !isEmpty(PORTAUDIO_DIR) { @@ -211,7 +212,8 @@ HEADERS += $$HEADERS_WS_C \ export_dissection_dialog.h \ packet_format_group_box.h \ export_object_dialog.h \ - print_dialog.h + print_dialog.h \ + splash_overlay.h win32 { OBJECTS_WS_C = $$SOURCES_WS_C @@ -420,4 +422,5 @@ SOURCES += \ export_dissection_dialog.cpp \ packet_format_group_box.cpp \ export_object_dialog.cpp \ - print_dialog.cpp + print_dialog.cpp \ + splash_overlay.cpp diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp index 69394395f1..17be1a97b2 100644 --- a/ui/qt/main.cpp +++ b/ui/qt/main.cpp @@ -623,7 +623,6 @@ int main(int argc, char *argv[]) // gboolean rfilter_parse_failed = FALSE; e_prefs *prefs_p; // char badopt; - //GtkWidget *splash_win = NULL; GLogLevelFlags log_flags; // guint go_to_packet = 0; // gboolean jump_backwards = FALSE; @@ -655,8 +654,6 @@ int main(int argc, char *argv[]) // to force the issue. w->connect(&a, SIGNAL(openCaptureFile(QString&)), w, SLOT(openCaptureFile(QString&))); - // XXX Turn MWOverlay into its own widget and use it for a splash screen. - // XXX Should the remaining code be in WiresharkApplcation::WiresharkApplication? #ifdef HAVE_LIBPCAP @@ -925,13 +922,12 @@ int main(int argc, char *argv[]) dissectors, and we must do it before we read the preferences, in case any dissectors register preferences. */ epan_init(register_all_protocols,register_all_protocol_handoffs, - NULL, NULL, -// splash_update, (gpointer) splash_win, + splash_update, NULL, failure_alert_box,open_failure_alert_box,read_failure_alert_box, write_failure_alert_box ); -// splash_update(RA_LISTENERS, NULL, (gpointer)splash_win); + splash_update(RA_LISTENERS, NULL, NULL); /* Register all tap listeners; we do this before we parse the arguments, as the "-z" argument can specify a registered tap. */ @@ -947,7 +943,7 @@ int main(int argc, char *argv[]) // register_all_tap_listeners(); -// splash_update(RA_PREFERENCES, NULL, (gpointer)splash_win); + splash_update(RA_PREFERENCES, NULL, NULL); prefs_p = read_configuration_files (&gdp_path, &dp_path); /* Removed thread code: diff --git a/ui/qt/main_welcome.cpp b/ui/qt/main_welcome.cpp index 4e6678631b..b6c3dcc3dd 100644 --- a/ui/qt/main_welcome.cpp +++ b/ui/qt/main_welcome.cpp @@ -37,39 +37,12 @@ #include "interface_tree.h" #include <QWidget> - -//MWOverlay::MWOverlay(QWidget *parent) : QWidget(parent) -//{ -// setPalette(Qt::transparent); -// setAttribute(Qt::WA_TransparentForMouseEvents); - -// QGraphicsBlurEffect *blur = new QGraphicsBlurEffect(this); -// setGraphicsEffect(blur); -//} - -//void MWOverlay::paintEvent(QPaintEvent *event) -//{ -// QPainter painter(this); -// painter.setRenderHint(QPainter::Antialiasing); - -// QRect border = rect(); -//// g_log(NULL, G_LOG_LEVEL_DEBUG, "rect pre: %d %d %d %d", border.top(), border.left(), border.bottom(), border.right()); -// border.setWidth(border.width() - 8); -// border.moveLeft(4); -// border.setHeight(border.height() - 8); -// border.moveTop(4); -//// g_log(NULL, G_LOG_LEVEL_DEBUG, "rect post: %d %d %d %d", border.top(), border.left(), border.bottom(), border.right()); -// QPen pen; -// pen.setWidth(8); -// pen.setColor(QColor(60, 60, 60, 80)); -// painter.setPen(pen); -//// painter.setBrush(Qt::blue); -// painter.drawRect(border); -//} +#include <QResizeEvent> MainWelcome::MainWelcome(QWidget *parent) : QFrame(parent), - welcome_ui_(new Ui::MainWelcome) + welcome_ui_(new Ui::MainWelcome), + splash_overlay_(NULL) { // QGridLayout *grid = new QGridLayout(this); @@ -160,11 +133,20 @@ MainWelcome::MainWelcome(QWidget *parent) : recent_files_->setTextElideMode(Qt::ElideLeft); connect(wsApp, SIGNAL(updateRecentItemStatus(const QString &, qint64, bool)), this, SLOT(updateRecentFiles())); + connect(wsApp, SIGNAL(appInitialized()), this, SLOT(destroySplashOverlay())); connect(task_list_, SIGNAL(itemSelectionChanged()), this, SLOT(showTask())); connect(recent_files_, SIGNAL(itemActivated(QListWidgetItem *)), this, SLOT(openRecentItem(QListWidgetItem *))); updateRecentFiles(); task_list_->setCurrentRow(0); + + splash_overlay_ = new SplashOverlay(this); +} + +void MainWelcome::destroySplashOverlay() +{ + delete splash_overlay_; + splash_overlay_ = NULL; } void MainWelcome::showTask() { @@ -218,13 +200,14 @@ void MainWelcome::openRecentItem(QListWidgetItem *item) { emit recentFileActivated(cfPath); } -//void MainWelcome::resizeEvent(QResizeEvent *event) -//{ -// overlay->resize(event->size()); -//// event->accept(); +void MainWelcome::resizeEvent(QResizeEvent *event) +{ + if (splash_overlay_) + splash_overlay_->resize(event->size()); +// event->accept(); -// QFrame::resizeEvent(event); -//} + QFrame::resizeEvent(event); +} /* * Editor modelines diff --git a/ui/qt/main_welcome.h b/ui/qt/main_welcome.h index 6605cdc490..6b61734c83 100644 --- a/ui/qt/main_welcome.h +++ b/ui/qt/main_welcome.h @@ -27,14 +27,7 @@ #include <QFrame> #include <QListWidget> -//class MWOverlay : public QWidget -//{ -//public: -// MWOverlay(QWidget *parent); - -//protected: -// void paintEvent(QPaintEvent *event); -//}; +#include "splash_overlay.h" namespace Ui { class MainWelcome; @@ -47,12 +40,14 @@ public: explicit MainWelcome(QWidget *parent = 0); protected: -// void resizeEvent(QResizeEvent *event); + void resizeEvent(QResizeEvent *event); private: + Ui::MainWelcome *welcome_ui_; + + SplashOverlay *splash_overlay_; // QListWidget doesn't activate items when the return or enter keys are pressed on OS X. // We may want to subclass it at some point. - Ui::MainWelcome *welcome_ui_; QListWidget *task_list_; QListWidget *recent_files_; // MWOverlay *overlay; @@ -62,6 +57,7 @@ signals: void recentFileActivated(QString& cfile); private slots: + void destroySplashOverlay(); void showTask(); void updateRecentFiles(); void openRecentItem(QListWidgetItem *item); diff --git a/ui/qt/splash_overlay.cpp b/ui/qt/splash_overlay.cpp new file mode 100644 index 0000000000..ee28e9f2ea --- /dev/null +++ b/ui/qt/splash_overlay.cpp @@ -0,0 +1,205 @@ +/* splash_overlay.cpp + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "splash_overlay.h" +#include "ui_splash_overlay.h" +#include "wireshark_application.h" + +#include <QGraphicsBlurEffect> +#include <QPainter> + +#include "ui/utf8_entities.h" +#include "tango_colors.h" + +/* + * Update frequency for the splash screen, given in milliseconds. + */ +const int info_update_freq_ = 50; + +void splash_update(register_action_e action, const char *message, void *dummy) { + Q_UNUSED(dummy); + + emit wsApp->registerUpdate(action, message); +} + +SplashOverlay::SplashOverlay(QWidget *parent) : + QWidget(parent), + bo_ui_(new Ui::SplashOverlay), + last_action_(RA_NONE), + register_cur_(0) +{ + bo_ui_->setupUi(this); + + /* additional 6 for: + * dissectors, listeners, + * registering plugins, handingoff plugins, + * preferences and configuration + */ + int register_add = 6; +#ifdef HAVE_LUA + register_add++; /* additional one for lua plugins */ +#endif +#ifdef HAVE_PYTHON + register_add += 2; /* additional 2 for python register and handoff */ +#endif + bo_ui_->progressBar->setMaximum((int)register_count() + register_add); + time_.start(); + + setPalette(Qt::transparent); + setStyleSheet(QString( + "QLabel {" + " color: white;" + " background: rgba(0,0,0,0);" + "}" + "QProgressBar {" + " height: 1em;" + " width: 20em;" + " border: 0.1em solid white;" + " border-radius: 0.2em;" + " color: white;" + " background: rgba(0,0,0,0);" + "}" + "QProgressBar::chunk {" + " width: 0.1em;" + " background: rgba(255, 255, 255, 50%);" + "}" + )); + + connect(wsApp, SIGNAL(splashUpdate(register_action_e,const char*)), + this, SLOT(splashUpdate(register_action_e,const char*))); + + // It would be nice to be able to blur the background, sort of like VMware Fusion. + // Unfortunately setGraphicsEffect applies to the widget *and* its children and + // the code below crashes with Qt 4.8.2 on OS X. +// QGraphicsBlurEffect *blur = new QGraphicsBlurEffect(); +// setGraphicsEffect(blur); +} + +SplashOverlay::~SplashOverlay() +{ + delete bo_ui_; +} + +// Useful for debugging on fast machines. +//#include <QThread> +//class SleeperThread : public QThread +//{ +//public: +// static void msleep(unsigned long msecs) +// { +// QThread::msleep(msecs); +// } +//}; + +void SplashOverlay::splashUpdate(register_action_e action, const char *message) +{ + QString action_msg = UTF8_HORIZONTAL_ELLIPSIS; + +// SleeperThread::msleep(2); + + register_cur_++; + if (last_action_ == action && time_.elapsed() < info_update_freq_ && register_cur_ < bo_ui_->progressBar->maximum()) { + /* Only update every splash_register_freq milliseconds */ + return; + } + time_.restart(); + last_action_ = action; + + switch(action) { + case RA_DISSECTORS: + action_msg = "Initializing dissectors"; + break; + case RA_LISTENERS: + action_msg = "Initializing tap listeners"; + break; + case RA_REGISTER: + action_msg = "Registering dissector"; + break; + case RA_PLUGIN_REGISTER: + action_msg = "Registering plugins"; + break; + case RA_PYTHON_REGISTER: + action_msg = "Registering Python dissectors"; + break; + case RA_HANDOFF: + action_msg = "Handing off dissector"; + break; + case RA_PLUGIN_HANDOFF: + action_msg = "Handing off plugins"; + break; + case RA_PYTHON_HANDOFF: + action_msg = "Handing off Python dissectors"; + break; + case RA_LUA_PLUGINS: + action_msg = "Loading Lua plugins"; + break; + case RA_PREFERENCES: + action_msg = "Loading module preferences"; + break; + case RA_CONFIGURATION: + action_msg = "Loading configuration files"; + break; + default: + action_msg = "(Unknown action)"; + break; + } + + if (message) { + if (!strncmp(message, "proto_register_", 15)) + message += 15; + else if (!strncmp(message, "proto_reg_handoff_", 18)) + message += 18; + action_msg.append(" ").append(message); + } + bo_ui_->actionLabel->setText(action_msg); + + register_cur_++; + bo_ui_->progressBar->setValue(register_cur_); + + wsApp->processEvents(); +} + +void SplashOverlay::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event); + + QPainter painter(this); + + painter.setRenderHint(QPainter::Antialiasing); + painter.setBrush(QColor(tango_aluminium_6)); + painter.setOpacity(0.4); + painter.drawRect(rect()); +} + +/* + * Editor modelines + * + * Local Variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * ex: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/ui/qt/splash_overlay.h b/ui/qt/splash_overlay.h new file mode 100644 index 0000000000..9cf56d592f --- /dev/null +++ b/ui/qt/splash_overlay.h @@ -0,0 +1,77 @@ +/* splash_overlay.h + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef SPLASH_OVERLAY_H +#define SPLASH_OVERLAY_H + +#include "config.h" + +#include <glib.h> + +#include "register.h" + +#include <QWidget> +#include <QTime> + +void splash_update(register_action_e action, const char *message, void *dummy); + +namespace Ui { +class SplashOverlay; +} + +class SplashOverlay : public QWidget +{ + Q_OBJECT + +public: + explicit SplashOverlay(QWidget *parent = 0); + ~SplashOverlay(); + +protected: + void paintEvent(QPaintEvent *event); + +private: + Ui::SplashOverlay *bo_ui_; + bool blurred_; + register_action_e last_action_; + int register_cur_; + QTime time_; + +private slots: + void splashUpdate(register_action_e action, const char *message); +}; + +#endif // SPLASH_OVERLAY_H + +/* + * Editor modelines + * + * Local Variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * ex: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/ui/qt/splash_overlay.ui b/ui/qt/splash_overlay.ui new file mode 100644 index 0000000000..4b0051408b --- /dev/null +++ b/ui/qt/splash_overlay.ui @@ -0,0 +1,97 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>SplashOverlay</class> + <widget class="QWidget" name="SplashOverlay"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>116</width> + <height>50</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="actionLabel"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QProgressBar" name="progressBar"> + <property name="value"> + <number>24</number> + </property> + <property name="textVisible"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>116</width> + <height>50</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp index 3334b09754..235b5dea13 100644 --- a/ui/qt/wireshark_application.cpp +++ b/ui/qt/wireshark_application.cpp @@ -397,9 +397,15 @@ WiresharkApplication::WiresharkApplication(int &argc, char **argv) : recent_timer_->start(2000); } +void WiresharkApplication::registerUpdate(register_action_e action, const char *message) +{ + emit splashUpdate(action, message); +} + void WiresharkApplication::allSystemsGo() { initialized_ = true; + emit appInitialized(); while (pending_open_files_.length() > 0) { emit openCaptureFile(pending_open_files_.front()); pending_open_files_.pop_front(); diff --git a/ui/qt/wireshark_application.h b/ui/qt/wireshark_application.h index 868ce47e0d..df77715bbf 100644 --- a/ui/qt/wireshark_application.h +++ b/ui/qt/wireshark_application.h @@ -30,6 +30,7 @@ #include "capture_opts.h" #include "file.h" +#include "register.h" #include "ui/help_url.h" @@ -57,6 +58,7 @@ class WiresharkApplication : public QApplication public: explicit WiresharkApplication(int &argc, char **argv); + void registerUpdate(register_action_e action, const char *message); void allSystemsGo(); QList<recent_item_status *> recentItems() const; void addRecentItem(const QString &filename, qint64 size, bool accessible); @@ -80,8 +82,10 @@ protected: bool event(QEvent *event); signals: + void appInitialized(); void openCaptureFile(QString &cf_path); void updateRecentItemStatus(const QString &filename, qint64 size, bool accessible); + void splashUpdate(register_action_e action, const char *message); #ifdef HAVE_LIBPCAP // XXX It might make more sense to move these to main.cpp or main_window.cpp or their own class. |