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
6class QNetworkAccessManager;
7class QLabel;
9
19class NetworkStatusWidget final : public QWidget {
20 Q_OBJECT
21
22public:
30 explicit NetworkStatusWidget(QWidget *parent = nullptr);
31
35 ~NetworkStatusWidget() override;
36
37public slots:
44 void CheckNetworkStatus();
45
46protected:
53 void paintEvent(QPaintEvent *event) override;
54
55private:
66
72
79 void CreateNetworkIcon(NetworkQuality quality) const;
80
87 static QColor GetQualityColor(NetworkQuality quality);
88
92 QLabel *ping_label_;
94 QLabel *icon_label_;
96 QNetworkAccessManager *network_manager_;
107};
108
109#endif // NETWORK_STATUS_WIDGET_H
~NetworkStatusWidget() override
Destructor. Stops the update timer.
Definition network_status_widget.cpp:71
NetworkQuality
Enum representing the perceived quality of the network connection.
Definition network_status_widget.h:59
@ kNone
No connection detected.
Definition network_status_widget.h:60
@ kGood
Good latency.
Definition network_status_widget.h:63
@ kFair
Moderate latency.
Definition network_status_widget.h:62
@ kExcellent
Low latency.
Definition network_status_widget.h:64
@ kPoor
Very high latency or unstable connection.
Definition network_status_widget.h:61
NetworkQuality current_quality_
The currently determined network quality level.
Definition network_status_widget.h:100
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
QLabel * ping_label_
Label displaying the measured ping time in milliseconds.
Definition network_status_widget.h:92
QTimer * update_timer_
Timer triggering periodic calls to CheckNetworkStatus().
Definition network_status_widget.h:98
void CheckNetworkStatus()
Performs a network status check. Sends a network request, measures the response time (ping),...
Definition network_status_widget.cpp:96
QLabel * icon_label_
Label displaying the WiFi-style icon.
Definition network_status_widget.h:94
NetworkStatusWidget(QWidget *parent=nullptr)
Constructs a NetworkStatusWidget. Initializes UI elements (labels, layout), sets appearance (size,...
Definition network_status_widget.cpp:13
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
QLabel * status_label_
Label displaying the textual status (e.g., "SYSTEM READY").
Definition network_status_widget.h:90
qint64 ping_value_
The last measured ping time in milliseconds.
Definition network_status_widget.h:104
QNetworkAccessManager * network_manager_
Manages network requests for status checking.
Definition network_status_widget.h:96
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
QColor border_color_
The color used for the border, text, and active icon parts, based on current_quality_.
Definition network_status_widget.h:102
TranslationManager * translator_
Pointer to the translation manager for handling UI translations.
Definition network_status_widget.h:106
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
Manages the loading and delivery of translations for applications.
Definition translation_manager.h:15