Show IP in sidebar

This commit is contained in:
FrogAi
2024-02-27 16:34:47 -07:00
parent afcd012241
commit 0f6de976aa
3 changed files with 27 additions and 6 deletions

View File

@@ -360,6 +360,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"SilentMode", PERSISTENT}, {"SilentMode", PERSISTENT},
{"ShowCPU", PERSISTENT}, {"ShowCPU", PERSISTENT},
{"ShowGPU", PERSISTENT}, {"ShowGPU", PERSISTENT},
{"ShowIP", PERSISTENT},
{"ShowMemoryUsage", PERSISTENT}, {"ShowMemoryUsage", PERSISTENT},
{"ShowStorageLeft", PERSISTENT}, {"ShowStorageLeft", PERSISTENT},
{"ShowStorageUsed", PERSISTENT}, {"ShowStorageUsed", PERSISTENT},

View File

@@ -43,6 +43,8 @@ Sidebar::Sidebar(QWidget *parent) : QFrame(parent), onroad(false), flag_pressed(
isCPU = params.getBool("ShowCPU"); isCPU = params.getBool("ShowCPU");
isGPU = params.getBool("ShowGPU"); isGPU = params.getBool("ShowGPU");
isIP = params.getBool("ShowIP");
isMemoryUsage = params.getBool("ShowMemoryUsage"); isMemoryUsage = params.getBool("ShowMemoryUsage");
isStorageLeft = params.getBool("ShowStorageLeft"); isStorageLeft = params.getBool("ShowStorageLeft");
isStorageUsed = params.getBool("ShowStorageUsed"); isStorageUsed = params.getBool("ShowStorageUsed");
@@ -99,10 +101,12 @@ void Sidebar::mousePressEvent(QMouseEvent *event) {
// Declare the click boxes // Declare the click boxes
QRect cpuRect = {30, 496, 240, 126}; QRect cpuRect = {30, 496, 240, 126};
QRect memoryRect = {30, 654, 240, 126}; QRect memoryRect = {30, 654, 240, 126};
QRect networkRect = {30, 196, 240, 126};
QRect tempRect = {30, 338, 240, 126}; QRect tempRect = {30, 338, 240, 126};
static int showChip = 0; static int showChip = 0;
static int showMemory = 0; static int showMemory = 0;
static int showNetwork = 0;
static int showTemp = 0; static int showTemp = 0;
// Swap between the respective metrics upon tap // Swap between the respective metrics upon tap
@@ -122,6 +126,11 @@ void Sidebar::mousePressEvent(QMouseEvent *event) {
params.putBoolNonBlocking("ShowStorageLeft", isStorageLeft); params.putBoolNonBlocking("ShowStorageLeft", isStorageLeft);
params.putBoolNonBlocking("ShowStorageUsed", isStorageUsed); params.putBoolNonBlocking("ShowStorageUsed", isStorageUsed);
update(); update();
} else if (networkRect.contains(event->pos())) {
showNetwork = (showNetwork + 1) % 2;
isIP = (showNetwork == 1);
params.putBoolNonBlocking("ShowIP", isIP);
update();
} else if (tempRect.contains(event->pos())) { } else if (tempRect.contains(event->pos())) {
showTemp = (showTemp + 1) % 3; showTemp = (showTemp + 1) % 3;
scene.fahrenheit = showTemp == 2; scene.fahrenheit = showTemp == 2;
@@ -282,14 +291,24 @@ void Sidebar::paintEvent(QPaintEvent *event) {
// network // network
int x = 58; int x = 58;
const QColor gray(0x54, 0x54, 0x54); const QColor gray(0x54, 0x54, 0x54);
p.setFont(InterFont(35));
if (isIP) {
p.setPen(QColor(0xff, 0xff, 0xff));
p.save();
p.setFont(InterFont(30));
QRect ipBox = QRect(50, 196, 225, 27);
p.drawText(ipBox, Qt::AlignLeft | Qt::AlignVCenter, uiState()->wifi->getIp4Address());
p.restore();
} else {
for (int i = 0; i < 5; ++i) { for (int i = 0; i < 5; ++i) {
p.setBrush(i < net_strength ? Qt::white : gray); p.setBrush(i < net_strength ? Qt::white : gray);
p.drawEllipse(x, 196, 27, 27); p.drawEllipse(x, 196, 27, 27);
x += 37; x += 37;
} }
p.setFont(InterFont(35));
p.setPen(QColor(0xff, 0xff, 0xff)); p.setPen(QColor(0xff, 0xff, 0xff));
}
const QRect r = QRect(50, 247, 100, 50); const QRect r = QRect(50, 247, 100, 50);
p.drawText(r, Qt::AlignCenter, net_type); p.drawText(r, Qt::AlignCenter, net_type);

View File

@@ -73,6 +73,7 @@ private:
bool isCPU; bool isCPU;
bool isGPU; bool isGPU;
bool isIP;
bool isMemoryUsage; bool isMemoryUsage;
bool isStorageLeft; bool isStorageLeft;
bool isStorageUsed; bool isStorageUsed;