3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "splash_overlay.h"
23 #include <ui_splash_overlay.h>
24 #include "wireshark_application.h"
29 #include <wsutil/utf8_entities.h>
30 #include "tango_colors.h"
33 #include "epan/wslua/init_wslua.h"
36 // Uncomment to slow the update progress
37 //#define THROTTLE_STARTUP 1
40 * Update frequency for the splash screen, given in milliseconds.
42 static int info_update_freq_ = 100;
44 void splash_update(register_action_e action, const char *message, void *) {
45 emit wsApp->registerUpdate(action, message);
48 SplashOverlay::SplashOverlay(QWidget *parent) :
50 so_ui_(new Ui::SplashOverlay),
51 last_action_(RA_NONE),
54 so_ui_->setupUi(this);
56 // Number of register action transitions (e.g. RA_NONE -> RA_DISSECTORS,
57 // RA_DISSECTORS -> RA_PLUGIN_REGISTER) minus two.
60 register_add += wslua_count_plugins(); /* get count of lua plugins */
62 so_ui_->progressBar->setMaximum((int)register_count() + register_add);
63 elapsed_timer_.start();
65 setPalette(Qt::transparent);
66 setStyleSheet(QString(
69 " background: rgba(0,0,0,0);"
74 " border: 0.1em solid white;"
75 " border-radius: 0.2em;"
77 " background: rgba(0,0,0,0);"
79 "QProgressBar::chunk {"
81 " background: rgba(255, 255, 255, 50%);"
85 #ifndef THROTTLE_STARTUP
86 // Check for a remote connection
87 if (display_is_remote())
88 info_update_freq_ = 1000;
91 connect(wsApp, SIGNAL(splashUpdate(register_action_e,const char*)),
92 this, SLOT(splashUpdate(register_action_e,const char*)));
95 SplashOverlay::~SplashOverlay()
100 // Useful for debugging on fast machines.
101 #ifdef THROTTLE_STARTUP
103 class ThrottleThread : public QThread
106 static void msleep(unsigned long msecs)
108 QThread::msleep(msecs);
113 void SplashOverlay::splashUpdate(register_action_e action, const char *message)
115 QString action_msg = UTF8_HORIZONTAL_ELLIPSIS;
117 #ifdef THROTTLE_STARTUP
118 ThrottleThread::msleep(10);
122 if (last_action_ == action && elapsed_timer_.elapsed() < info_update_freq_ && register_cur_ != so_ui_->progressBar->maximum()) {
123 /* Only update every splash_register_freq milliseconds */
126 last_action_ = action;
130 action_msg = tr("Initializing dissectors");
133 action_msg = tr("Initializing tap listeners");
136 action_msg = tr("Registering dissectors");
138 case RA_PLUGIN_REGISTER:
139 action_msg = tr("Registering plugins");
142 action_msg = tr("Handing off dissectors");
144 case RA_PLUGIN_HANDOFF:
145 action_msg = tr("Handing off plugins");
148 action_msg = tr("Loading Lua plugins");
150 case RA_LUA_DEREGISTER:
151 action_msg = tr("Removing Lua plugins");
154 action_msg = tr("Loading module preferences");
156 case RA_CONFIGURATION:
157 action_msg = tr("Loading configuration files");
160 action_msg = tr("(Unknown action)");
165 if (!strncmp(message, "proto_register_", 15))
167 else if (!strncmp(message, "proto_reg_handoff_", 18))
169 action_msg.append(" ").append(message);
171 so_ui_->actionLabel->setText(action_msg);
173 so_ui_->progressBar->setValue(register_cur_);
175 wsApp->processEvents();
176 elapsed_timer_.restart();
179 void SplashOverlay::paintEvent(QPaintEvent *)
181 QPainter painter(this);
183 painter.setRenderHint(QPainter::Antialiasing);
184 painter.setBrush(QColor(tango_aluminium_6));
185 painter.setOpacity(0.4);
186 painter.drawRect(rect());
195 * indent-tabs-mode: nil
198 * ex: set shiftwidth=4 tabstop=8 expandtab:
199 * :indentSize=4:tabSize=8:noTabs=true: