MSWSP: add parse_CNatLanguageRestriction()
[wireshark-wip.git] / ui / qt / splash_overlay.cpp
blobb1d36bd842b9221079a121a9b79f546de2f34d5e
1 /* splash_overlay.cpp
3 * $Id$
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"
28 #include <QPainter>
30 #include "ui/util.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) {
43 Q_UNUSED(dummy);
45 emit wsApp->registerUpdate(action, message);
48 SplashOverlay::SplashOverlay(QWidget *parent) :
49 QWidget(parent),
50 so_ui_(new Ui::SplashOverlay),
51 last_action_(RA_NONE),
52 register_cur_(0)
54 so_ui_->setupUi(this);
56 /* additional 6 for:
57 * dissectors, listeners,
58 * registering plugins, handingoff plugins,
59 * preferences and configuration
61 int register_add = 6;
62 #ifdef HAVE_LUA
63 register_add++; /* additional one for lua plugins */
64 #endif
65 #ifdef HAVE_PYTHON
66 register_add += 2; /* additional 2 for python register and handoff */
67 #endif
68 so_ui_->progressBar->setMaximum((int)register_count() + register_add);
69 time_.start();
71 setPalette(Qt::transparent);
72 setStyleSheet(QString(
73 "QLabel {"
74 " color: white;"
75 " background: rgba(0,0,0,0);"
76 "}"
77 "QProgressBar {"
78 " height: 1em;"
79 " width: 20em;"
80 " border: 0.1em solid white;"
81 " border-radius: 0.2em;"
82 " color: white;"
83 " background: rgba(0,0,0,0);"
84 "}"
85 "QProgressBar::chunk {"
86 " width: 0.1em;"
87 " background: rgba(255, 255, 255, 50%);"
88 "}"
89 ));
91 #ifndef THROTTLE_STARTUP
92 // Check for a remote connection
93 if (strlen (get_conn_cfilter()) > 0)
94 info_update_freq_ = 1000;
95 #endif
97 connect(wsApp, SIGNAL(splashUpdate(register_action_e,const char*)),
98 this, SLOT(splashUpdate(register_action_e,const char*)));
101 SplashOverlay::~SplashOverlay()
103 delete so_ui_;
106 // Useful for debugging on fast machines.
107 #ifdef THROTTLE_STARTUP
108 #include <QThread>
109 class ThrottleThread : public QThread
111 public:
112 static void msleep(unsigned long msecs)
114 QThread::msleep(msecs);
117 #endif
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);
125 #endif
127 register_cur_++;
128 if (last_action_ == action && time_.elapsed() < info_update_freq_ && register_cur_ < so_ui_->progressBar->maximum()) {
129 /* Only update every splash_register_freq milliseconds */
130 return;
132 last_action_ = action;
134 switch(action) {
135 case RA_DISSECTORS:
136 action_msg = tr("Initializing dissectors");
137 break;
138 case RA_LISTENERS:
139 action_msg = tr("Initializing tap listeners");
140 break;
141 case RA_REGISTER:
142 action_msg = tr("Registering dissector");
143 break;
144 case RA_PLUGIN_REGISTER:
145 action_msg = tr("Registering plugins");
146 break;
147 case RA_PYTHON_REGISTER:
148 action_msg = tr("Registering Python dissectors");
149 break;
150 case RA_HANDOFF:
151 action_msg = tr("Handing off dissector");
152 break;
153 case RA_PLUGIN_HANDOFF:
154 action_msg = tr("Handing off plugins");
155 break;
156 case RA_PYTHON_HANDOFF:
157 action_msg = tr("Handing off Python dissectors");
158 break;
159 case RA_LUA_PLUGINS:
160 action_msg = tr("Loading Lua plugins");
161 break;
162 case RA_PREFERENCES:
163 action_msg = tr("Loading module preferences");
164 break;
165 case RA_CONFIGURATION:
166 action_msg = tr("Loading configuration files");
167 break;
168 default:
169 action_msg = tr("(Unknown action)");
170 break;
173 if (message) {
174 if (!strncmp(message, "proto_register_", 15))
175 message += 15;
176 else if (!strncmp(message, "proto_reg_handoff_", 18))
177 message += 18;
178 action_msg.append(" ").append(message);
180 so_ui_->actionLabel->setText(action_msg);
182 register_cur_++;
183 so_ui_->progressBar->setValue(register_cur_);
185 wsApp->processEvents();
187 time_.restart();
190 void SplashOverlay::paintEvent(QPaintEvent *event)
192 Q_UNUSED(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());
203 * Editor modelines
205 * Local Variables:
206 * c-basic-offset: 4
207 * tab-width: 8
208 * indent-tabs-mode: nil
209 * End:
211 * ex: set shiftwidth=4 tabstop=8 expandtab:
212 * :indentSize=4:tabSize=8:noTabs=true: