5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "splash_overlay.h"
25 #include "ui_splash_overlay.h"
26 #include "wireshark_application.h"
31 #include "ui/utf8_entities.h"
32 #include "tango_colors.h"
34 // Uncomment to slow the update progress
35 //#define THROTTLE_STARTUP 1
38 * Update frequency for the splash screen, given in milliseconds.
40 int info_update_freq_
= 15;
42 void splash_update(register_action_e action
, const char *message
, void *dummy
) {
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);
57 * dissectors, listeners,
58 * registering plugins, handingoff plugins,
59 * preferences and configuration
63 register_add
++; /* additional one for lua plugins */
66 register_add
+= 2; /* additional 2 for python register and handoff */
68 so_ui_
->progressBar
->setMaximum((int)register_count() + register_add
);
71 setPalette(Qt::transparent
);
72 setStyleSheet(QString(
75 " background: rgba(0,0,0,0);"
80 " border: 0.1em solid white;"
81 " border-radius: 0.2em;"
83 " background: rgba(0,0,0,0);"
85 "QProgressBar::chunk {"
87 " background: rgba(255, 255, 255, 50%);"
91 #ifndef THROTTLE_STARTUP
92 // Check for a remote connection
93 if (strlen (get_conn_cfilter()) > 0)
94 info_update_freq_
= 1000;
97 connect(wsApp
, SIGNAL(splashUpdate(register_action_e
,const char*)),
98 this, SLOT(splashUpdate(register_action_e
,const char*)));
101 SplashOverlay::~SplashOverlay()
106 // Useful for debugging on fast machines.
107 #ifdef THROTTLE_STARTUP
109 class ThrottleThread
: public QThread
112 static void msleep(unsigned long msecs
)
114 QThread::msleep(msecs
);
119 void SplashOverlay::splashUpdate(register_action_e action
, const char *message
)
121 QString action_msg
= UTF8_HORIZONTAL_ELLIPSIS
;
123 #ifdef THROTTLE_STARTUP
124 ThrottleThread::msleep(100);
128 if (last_action_
== action
&& time_
.elapsed() < info_update_freq_
&& register_cur_
< so_ui_
->progressBar
->maximum()) {
129 /* Only update every splash_register_freq milliseconds */
132 last_action_
= action
;
136 action_msg
= tr("Initializing dissectors");
139 action_msg
= tr("Initializing tap listeners");
142 action_msg
= tr("Registering dissector");
144 case RA_PLUGIN_REGISTER
:
145 action_msg
= tr("Registering plugins");
147 case RA_PYTHON_REGISTER
:
148 action_msg
= tr("Registering Python dissectors");
151 action_msg
= tr("Handing off dissector");
153 case RA_PLUGIN_HANDOFF
:
154 action_msg
= tr("Handing off plugins");
156 case RA_PYTHON_HANDOFF
:
157 action_msg
= tr("Handing off Python dissectors");
160 action_msg
= tr("Loading Lua plugins");
163 action_msg
= tr("Loading module preferences");
165 case RA_CONFIGURATION
:
166 action_msg
= tr("Loading configuration files");
169 action_msg
= tr("(Unknown action)");
174 if (!strncmp(message
, "proto_register_", 15))
176 else if (!strncmp(message
, "proto_reg_handoff_", 18))
178 action_msg
.append(" ").append(message
);
180 so_ui_
->actionLabel
->setText(action_msg
);
183 so_ui_
->progressBar
->setValue(register_cur_
);
185 wsApp
->processEvents();
190 void SplashOverlay::paintEvent(QPaintEvent
*event
)
194 QPainter
painter(this);
196 painter
.setRenderHint(QPainter::Antialiasing
);
197 painter
.setBrush(QColor(tango_aluminium_6
));
198 painter
.setOpacity(0.4);
199 painter
.drawRect(rect());
208 * indent-tabs-mode: nil
211 * ex: set shiftwidth=4 tabstop=8 expandtab:
212 * :indentSize=4:tabSize=8:noTabs=true: