mirror of
git://projects.qi-hardware.com/nanomap.git
synced 2024-11-23 13:48:27 +02:00
remove unused code
This commit is contained in:
parent
012268a764
commit
baed4e06d9
@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QFile>
|
#include <QtCore/QFile>
|
||||||
//#include <QtCore/QFileSystemWatcher>
|
|
||||||
#include <QtCore/QTextStream>
|
#include <QtCore/QTextStream>
|
||||||
#include <QtCore/QTime>
|
#include <QtCore/QTime>
|
||||||
|
|
||||||
@ -37,12 +36,7 @@ BatteryLayer::BatteryLayer(MapWidget *map) :
|
|||||||
connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(repaint()));
|
connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(repaint()));
|
||||||
m_updateTimer->start();
|
m_updateTimer->start();
|
||||||
|
|
||||||
// QFileSystemWatcher *w = new QFileSystemWatcher(this);
|
reload();
|
||||||
// w->addPath("/sys/class/power_supply/battery/capacity");
|
|
||||||
// w->addPath("/sys/class/power_supply/battery/status");
|
|
||||||
// connect(w, SIGNAL(fileChanged(QString)), this, SLOT(fileChanged(QString)));
|
|
||||||
|
|
||||||
repaint();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatteryLayer::keyPressed(QKeyEvent *event)
|
void BatteryLayer::keyPressed(QKeyEvent *event)
|
||||||
@ -50,6 +44,7 @@ void BatteryLayer::keyPressed(QKeyEvent *event)
|
|||||||
if (event->modifiers() == Qt::NoModifier &&
|
if (event->modifiers() == Qt::NoModifier &&
|
||||||
event->key() == Qt::Key_B) {
|
event->key() == Qt::Key_B) {
|
||||||
toggleVisibility();
|
toggleVisibility();
|
||||||
|
reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,33 +67,37 @@ void BatteryLayer::paint(QPainter *painter)
|
|||||||
void BatteryLayer::repaint()
|
void BatteryLayer::repaint()
|
||||||
{
|
{
|
||||||
if (isVisible()) {
|
if (isVisible()) {
|
||||||
int percent = m_percent;
|
if (reload()) {
|
||||||
QFile capacity("/sys/class/power_supply/battery/capacity");
|
|
||||||
if (capacity.open(QFile::ReadOnly | QFile::Text)) {
|
|
||||||
QTextStream in(&capacity);
|
|
||||||
QString l = in.readLine();
|
|
||||||
percent = l.toInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool charging = m_isCharging;
|
|
||||||
QFile status("/sys/class/power_supply/battery/status");
|
|
||||||
if (status.open(QFile::ReadOnly | QFile::Text)) {
|
|
||||||
QTextStream in(&status);
|
|
||||||
QString l = in.readLine().toLower();
|
|
||||||
charging = (l == "charging");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (charging != m_isCharging || percent != m_percent) {
|
|
||||||
m_percent = percent;
|
|
||||||
m_isCharging = charging;
|
|
||||||
map()->update();
|
map()->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatteryLayer::fileChanged(const QString &filename)
|
bool BatteryLayer::reload()
|
||||||
{
|
{
|
||||||
qDebug() << filename;
|
int percent = m_percent;
|
||||||
repaint();
|
QFile capacity("/sys/class/power_supply/battery/capacity");
|
||||||
|
if (capacity.open(QFile::ReadOnly | QFile::Text)) {
|
||||||
|
QTextStream in(&capacity);
|
||||||
|
QString l = in.readLine();
|
||||||
|
percent = l.toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool charging = m_isCharging;
|
||||||
|
QFile status("/sys/class/power_supply/battery/status");
|
||||||
|
if (status.open(QFile::ReadOnly | QFile::Text)) {
|
||||||
|
QTextStream in(&status);
|
||||||
|
QString l = in.readLine().toLower();
|
||||||
|
charging = (l == "charging");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (charging != m_isCharging || percent != m_percent) {
|
||||||
|
m_isCharging = charging;
|
||||||
|
m_percent = percent;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,9 +38,10 @@ protected:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void repaint();
|
void repaint();
|
||||||
void fileChanged(const QString &filename);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool reload();
|
||||||
|
|
||||||
QTimer *m_updateTimer;
|
QTimer *m_updateTimer;
|
||||||
int m_percent;
|
int m_percent;
|
||||||
bool m_isCharging;
|
bool m_isCharging;
|
||||||
|
Loading…
Reference in New Issue
Block a user