Skip to content

Commit

Permalink
wip:
Browse files Browse the repository at this point in the history
I'm currently removing unfinished stuff and doing misc cleanup. I want a new stable v2.0 release ASAP, we can push new features in v2.1+
  • Loading branch information
rodlie committed Feb 5, 2024
1 parent bea47db commit 6c20e38
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 491 deletions.
4 changes: 0 additions & 4 deletions src/powerkit_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ namespace PowerKit
};
}

#define VIRTUAL_MONITOR "VIRTUAL"
#define TURN_OFF_MONITOR "xrandr --output %1 --off"
#define TURN_ON_MONITOR "xrandr --output %1 --auto "

#define LID_BATTERY_DEFAULT PowerKit::lidSleep
#define LID_AC_DEFAULT PowerKit::lidLock
#define CRITICAL_DEFAULT PowerKit::criticalNone
Expand Down
17 changes: 10 additions & 7 deletions src/powerkit_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,8 @@ void Dialog::setupWidgets()

// screensaver
QGroupBox *ssContainer = new QGroupBox(this);
ssContainer->setTitle(tr("Screensaver"));
QVBoxLayout *ssContainerLayout = new QVBoxLayout(ssContainer);
ssContainer->setTitle(tr("Screen saver"));
//QVBoxLayout *ssContainerLayout = new QVBoxLayout(ssContainer);

// notify
QGroupBox *notifyContainer = new QGroupBox(this);
Expand Down Expand Up @@ -871,9 +871,7 @@ void Dialog::drawBattery()
QColor colorFg = Qt::white;
QString status = QString("%1%\n%2").arg(QString::number(battery), batteryTime);
if (onBattery) {
if (battery >= 51) {
colorBg = Qt::yellow;
} else if (battery >= 26) {
if (battery >= 26) {
colorBg = QColor("orange");
} else {
colorBg = Qt::red;
Expand All @@ -898,24 +896,29 @@ void Dialog::drawCpu()
{
if (cpuFreqLabel) {
const auto freq = Cpu::getCpuFreqLabel();
QColor color = Qt::gray;
if (freq.first >= 50) { color = QColor("orange"); }
cpuFreqLabel->setPixmap(Theme::drawCircleProgress(freq.first,
64,
4,
4,
true,
freq.second,
Qt::gray,
color,
Qt::white));
}
if (cpuTempLabel && hasCpuCoreTemp) {
const auto temp = Cpu::getCpuTempLabel();
QColor color = Qt::gray;
if (temp.first >= 75) { color = Qt::red; }
else if (temp.first >= 50) { color = QColor("orange"); }
cpuTempLabel->setPixmap(Theme::drawCircleProgress(temp.first,
64,
4,
4,
true,
temp.second,
Qt::gray,
color,
Qt::white));
}
}
Expand Down
16 changes: 4 additions & 12 deletions src/powerkit_freedesktop_pm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <QDBusConnection>
#include <QCoreApplication>
#include <QProcess>
#include <QRandomGenerator>
#include <QDebug>

#include "powerkit_common.h"
Expand All @@ -23,21 +24,12 @@ PowerManagement::PowerManagement(QObject *parent) : QObject(parent)
timer.start();
}

int PowerManagement::randInt(int low, int high)
{
QTime time = QTime::currentTime();
qsrand((uint)time.msec());
return qrand() % ((high + 1) - low) + low;
}

quint32 PowerManagement::genCookie()
{
int low = 0;
int high = 1000;
quint32 cookie = (quint32)randInt(low, high);
while(!clients.contains(cookie)) {
quint32 cookie = QRandomGenerator::global()->generate();
while (!clients.contains(cookie)) {
if (!clients.contains(cookie)) { clients[cookie] = QTime::currentTime(); }
else { cookie = (quint32)randInt(low, high); }
else { cookie = QRandomGenerator::global()->generate(); }
}
return cookie;
}
Expand Down
1 change: 0 additions & 1 deletion src/powerkit_freedesktop_pm.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class PowerManagement : public QObject
void removedInhibit(quint32 cookie);

private slots:
int randInt(int low, int high);
quint32 genCookie();
void checkForExpiredClients();
bool canInhibit();
Expand Down
Loading

0 comments on commit 6c20e38

Please sign in to comment.