Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
network_status_widget.h
Go to the documentation of this file.
1
#ifndef NETWORK_STATUS_WIDGET_H
2
#define NETWORK_STATUS_WIDGET_H
3
4
#include <QWidget>
5
6
class
QNetworkAccessManager;
7
class
QLabel;
8
class
TranslationManager
;
9
19
class
NetworkStatusWidget
final :
public
QWidget {
20
Q_OBJECT
21
22
public
:
30
explicit
NetworkStatusWidget
(QWidget *parent =
nullptr
);
31
35
~NetworkStatusWidget
()
override
;
36
37
public
slots:
44
void
CheckNetworkStatus
();
45
46
protected
:
53
void
paintEvent
(QPaintEvent *event)
override
;
54
55
private
:
59
enum
NetworkQuality
{
60
kNone
,
61
kPoor
,
62
kFair
,
63
kGood
,
64
kExcellent
65
};
66
71
void
UpdateStatusDisplay
();
72
79
void
CreateNetworkIcon
(
NetworkQuality
quality)
const
;
80
87
static
QColor
GetQualityColor
(
NetworkQuality
quality);
88
90
QLabel *
status_label_
;
92
QLabel *
ping_label_
;
94
QLabel *
icon_label_
;
96
QNetworkAccessManager *
network_manager_
;
98
QTimer *
update_timer_
;
100
NetworkQuality
current_quality_
;
102
QColor
border_color_
;
104
qint64
ping_value_
;
106
TranslationManager
*
translator_
=
nullptr
;
107
};
108
109
#endif
// NETWORK_STATUS_WIDGET_H
NetworkStatusWidget::~NetworkStatusWidget
~NetworkStatusWidget() override
Destructor. Stops the update timer.
Definition
network_status_widget.cpp:71
NetworkStatusWidget::NetworkQuality
NetworkQuality
Enum representing the perceived quality of the network connection.
Definition
network_status_widget.h:59
NetworkStatusWidget::kNone
@ kNone
No connection detected.
Definition
network_status_widget.h:60
NetworkStatusWidget::kGood
@ kGood
Good latency.
Definition
network_status_widget.h:63
NetworkStatusWidget::kFair
@ kFair
Moderate latency.
Definition
network_status_widget.h:62
NetworkStatusWidget::kExcellent
@ kExcellent
Low latency.
Definition
network_status_widget.h:64
NetworkStatusWidget::kPoor
@ kPoor
Very high latency or unstable connection.
Definition
network_status_widget.h:61
NetworkStatusWidget::current_quality_
NetworkQuality current_quality_
The currently determined network quality level.
Definition
network_status_widget.h:100
NetworkStatusWidget::GetQualityColor
static QColor GetQualityColor(NetworkQuality quality)
Static utility function to get the appropriate color for a given network quality level....
Definition
network_status_widget.cpp:170
NetworkStatusWidget::ping_label_
QLabel * ping_label_
Label displaying the measured ping time in milliseconds.
Definition
network_status_widget.h:92
NetworkStatusWidget::update_timer_
QTimer * update_timer_
Timer triggering periodic calls to CheckNetworkStatus().
Definition
network_status_widget.h:98
NetworkStatusWidget::CheckNetworkStatus
void CheckNetworkStatus()
Performs a network status check. Sends a network request, measures the response time (ping),...
Definition
network_status_widget.cpp:96
NetworkStatusWidget::icon_label_
QLabel * icon_label_
Label displaying the WiFi-style icon.
Definition
network_status_widget.h:94
NetworkStatusWidget::NetworkStatusWidget
NetworkStatusWidget(QWidget *parent=nullptr)
Constructs a NetworkStatusWidget. Initializes UI elements (labels, layout), sets appearance (size,...
Definition
network_status_widget.cpp:13
NetworkStatusWidget::paintEvent
void paintEvent(QPaintEvent *event) override
Overridden paint event handler. Draws the custom widget background and border. Renders a rounded rect...
Definition
network_status_widget.cpp:75
NetworkStatusWidget::status_label_
QLabel * status_label_
Label displaying the textual status (e.g., "SYSTEM READY").
Definition
network_status_widget.h:90
NetworkStatusWidget::ping_value_
qint64 ping_value_
The last measured ping time in milliseconds.
Definition
network_status_widget.h:104
NetworkStatusWidget::network_manager_
QNetworkAccessManager * network_manager_
Manages network requests for status checking.
Definition
network_status_widget.h:96
NetworkStatusWidget::UpdateStatusDisplay
void UpdateStatusDisplay()
Updates the text of the status and ping labels, the icon, and the border color based on the current_q...
Definition
network_status_widget.cpp:135
NetworkStatusWidget::border_color_
QColor border_color_
The color used for the border, text, and active icon parts, based on current_quality_.
Definition
network_status_widget.h:102
NetworkStatusWidget::translator_
TranslationManager * translator_
Pointer to the translation manager for handling UI translations.
Definition
network_status_widget.h:106
NetworkStatusWidget::CreateNetworkIcon
void CreateNetworkIcon(NetworkQuality quality) const
Generates the WiFi-style icon as a QPixmap based on the network quality. Draws a series of arcs,...
Definition
network_status_widget.cpp:186
TranslationManager
Manages the loading and delivery of translations for applications.
Definition
translation_manager.h:15
src
ui
navigation
network_status_widget.h
Generated by
1.13.2