@@ -32,6 +32,8 @@ namespace {
3232
3333 std::string onOffText (bool enabled) { return enabled ? " On" : " Off" ; }
3434
35+ std::string disconnectedText (bool resolving) { return resolving ? " Connecting" : " Not connected" ; }
36+
3537 std::string yesNoText (bool enabled) { return enabled ? " Yes" : " No" ; }
3638
3739 std::string networkCountText (std::size_t count) {
@@ -68,6 +70,16 @@ void NetworkWidget::create() {
6870 })
6971 );
7072
73+ // Replaces the glyph while a wired link is activating.
74+ area->addChild (
75+ ui::spinner ({
76+ .out = &m_spinner,
77+ .color = widgetIconColorOr (colorSpecFromRole (ColorRole::OnSurface)),
78+ .spinnerSize = Style::baseGlyphSize * 0 .8f * m_contentScale,
79+ .visible = false ,
80+ })
81+ );
82+
7183 // Always create the label node: horizontal bars honor m_showLabel, but
7284 // vertical bars always display a 3-char truncation under the glyph to match
7385 // volume/brightness.
@@ -96,18 +108,22 @@ void NetworkWidget::doLayout(Renderer& renderer, float containerWidth, float con
96108 m_label->measure (renderer);
97109 }
98110
111+ // Glyph and spinner share one slot; only one is visible.
112+ Node* icon =
113+ (m_spinner != nullptr && m_spinner->visible ()) ? static_cast <Node*>(m_spinner) : static_cast <Node*>(m_glyph);
114+
99115 const bool labelVisible = m_label != nullptr && m_label->width () > 0 .0f && m_label->visible ();
100116 if (m_isVertical && labelVisible) {
101- const float w = std::max (m_glyph ->width (), m_label->width ());
102- m_glyph ->setPosition (std::round ((w - m_glyph ->width ()) * 0 .5f ), 0 .0f );
103- m_label->setPosition (std::round ((w - m_label->width ()) * 0 .5f ), m_glyph ->height ());
104- rootNode->setSize (w, m_glyph ->height () + m_label->height ());
117+ const float w = std::max (icon ->width (), m_label->width ());
118+ icon ->setPosition (std::round ((w - icon ->width ()) * 0 .5f ), 0 .0f );
119+ m_label->setPosition (std::round ((w - m_label->width ()) * 0 .5f ), icon ->height ());
120+ rootNode->setSize (w, icon ->height () + m_label->height ());
105121 } else {
106- const float h = labelVisible ? std::max (m_glyph ->height (), m_label->height ()) : m_glyph ->height ();
107- m_glyph ->setPosition (0 .0f , std::round ((h - m_glyph ->height ()) * 0 .5f ));
108- float totalWidth = m_glyph ->width ();
122+ const float h = labelVisible ? std::max (icon ->height (), m_label->height ()) : icon ->height ();
123+ icon ->setPosition (0 .0f , std::round ((h - icon ->height ()) * 0 .5f ));
124+ float totalWidth = icon ->width ();
109125 if (labelVisible) {
110- m_label->setPosition (m_glyph ->width () + Style::spaceXs, std::round ((h - m_label->height ()) * 0 .5f ));
126+ m_label->setPosition (icon ->width () + Style::spaceXs, std::round ((h - m_label->height ()) * 0 .5f ));
111127 totalWidth = m_label->x () + m_label->width ();
112128 }
113129 rootNode->setSize (totalWidth, h);
@@ -129,6 +145,9 @@ void NetworkWidget::syncState(Renderer& renderer) {
129145 m_haveLastState = true ;
130146 m_lastVertical = m_isVertical;
131147
148+ const bool showSpinner = s.kind == NetworkConnectivity::Wired && s.resolving ;
149+
150+ m_glyph->setVisible (!showSpinner);
132151 m_glyph->setGlyph (network_glyphs::glyphForState (s));
133152 m_glyph->setGlyphSize (Style::baseGlyphSize * m_contentScale);
134153 m_glyph->setColor (
@@ -137,6 +156,16 @@ void NetworkWidget::syncState(Renderer& renderer) {
137156 );
138157 m_glyph->measure (renderer);
139158
159+ if (m_spinner != nullptr ) {
160+ m_spinner->setVisible (showSpinner);
161+ m_spinner->setSpinnerSize (Style::baseGlyphSize * 0 .8f * m_contentScale);
162+ if (showSpinner && !m_spinner->spinning ()) {
163+ m_spinner->start ();
164+ } else if (!showSpinner && m_spinner->spinning ()) {
165+ m_spinner->stop ();
166+ }
167+ }
168+
140169 if (m_label != nullptr ) {
141170 const bool showLabel = m_showLabel;
142171 m_label->setVisible (showLabel);
@@ -216,7 +245,7 @@ std::vector<TooltipRow> NetworkWidget::buildTooltipRows() const {
216245 return rows;
217246 }
218247
219- rows.push_back ({" Network" , " Not connected " });
248+ rows.push_back ({" Network" , disconnectedText (s. resolving ) });
220249 rows.push_back ({" Wi-Fi" , onOffText (s.wirelessEnabled )});
221250 if (s.scanning ) {
222251 rows.push_back ({" Scanning" , yesNoText (s.scanning )});
0 commit comments