-
-
Save xkr47/45db2d868bc7d460915f to your computer and use it in GitHub Desktop.
Disable SailfishOS app cover animation when cover is not visible
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
#include "myclass.h" | |
... | |
int main(int argc, char *argv[]) | |
{ | |
qmlRegisterType<myclass>("harbour.myapp.myclass", 1, 0, "myclass"); | |
... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <QDBusConnection> | |
#include "myclass.h" | |
myclass::myclass(QObject *parent) : | |
QObject(parent), | |
m_coverStatus(0), | |
m_displayStatus("on"), | |
m_deviceLock(0), | |
m_coverVisible(false) | |
{ | |
QDBusConnection::sessionBus().connect("", "/com/jolla/lipstick", "com.jolla.lipstick", "coverstatus", | |
this, SLOT(handleCoverstatus(const QDBusMessage&))); | |
QDBusConnection::systemBus().connect("", "/com/nokia/mce/signal", "com.nokia.mce.signal", "display_status_ind", | |
this, SLOT(handleDisplaystatus(const QDBusMessage&))); | |
QDBusConnection::systemBus().connect("", "/devicelock", "org.nemomobile.lipstick.devicelock", "stateChanged", | |
this, SLOT(handleDeviceLockChange(const QDBusMessage&))); | |
} | |
void myclass::handleCoverstatus(const QDBusMessage& msg) | |
{ | |
QList<QVariant> args = msg.arguments(); | |
m_coverStatus = args.at(0).toInt(); | |
emit coverStatusChanged(); | |
this->handleCovervisible(); | |
} | |
void myclass::handleDisplaystatus(const QDBusMessage& msg) | |
{ | |
QList<QVariant> args = msg.arguments(); | |
m_displayStatus = args.at(0).toString(); | |
emit displayStatusChanged(); | |
this->handleCovervisible(); | |
} | |
void SystemStatus::handleDevicelock(const QDBusMessage& msg) | |
{ | |
QList<QVariant> args = msg.arguments(); | |
m_deviceLock = args.at(0).toInt(); | |
emit deviceLockChanged(); | |
this->handleCovervisible(); | |
} | |
void SystemStatus::handleCovervisible() { | |
bool newCoverVisible = m_coverStatus != 0 && m_displayStatus != "off" && m_deviceLock == 0; | |
if (newCoverVisible != m_coverVisible) { | |
m_coverVisible = newCoverVisible; | |
emit coverVisibleChanged(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef MYCLASS_H | |
#define MYCLASS_H | |
#include <QDBusMessage> | |
class myclass : public QObject | |
{ | |
Q_OBJECT | |
public: | |
Q_PROPERTY(int coverStatus READ getCoverStatus NOTIFY coverStatusChanged()) | |
Q_PROPERTY(QString displayStatus READ getDisplayStatus NOTIFY displayStatusChanged()) | |
Q_PROPERTY(int deviceLock READ getDeviceLock NOTIFY deviceLockChanged()) | |
Q_PROPERTY(bool coverVisible READ getCoverVisible NOTIFY coverVisibleChanged()) | |
explicit myclass(QObject *parent = 0); | |
public: | |
int getCoverStatus() { return m_coverStatus; } | |
QString getDisplayStatus() { return m_displayStatus; } | |
int getDeviceLock() { return m_deviceLock; } | |
bool getCoverVisible() { return m_coverVisible; } | |
public slots: | |
void handleCoverstatus(const QDBusMessage& msg); | |
void handleDisplaystatus(const QDBusMessage& msg); | |
void handleDevicelock(const QDBusMessage& msg); | |
private: | |
void handleCovervisible(); | |
signals: | |
void coverStatusChanged(); | |
void displayStatusChanged(); | |
void deviceLockChanged(); | |
void coverVisibleChanged(); | |
private: | |
int m_coverStatus; | |
QString m_displayStatus; | |
int m_deviceLock; | |
bool m_coverVisible; | |
}; | |
#endif // MYCLASS_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
QT += dbus |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BuildRequires: pkgconfig(Qt5DBus) | |
# ... or in yourapp.yaml: | |
# | |
# PkgConfigBR: | |
# ... | |
# - Qt5DBus |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
import harbour.myapp.myclass 1.0 | |
... | |
myclass { | |
id: myclass | |
} | |
Timer | |
{ | |
id: coverRefreshTimer | |
interval: 500 | |
running: myclass.coverVisible // timer only active when cover is visible | |
repeat: true | |
onTriggered: updateCover() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
coverStatus
displayStatus
deviceLock
coverVisible
- combination of the above properties -coverStatus != 0 && displayStatus != "off" && deviceLock == 0