File indexing completed on 2024-05-12 09:41:26

0001 /*  This file is part of the KDE project
0002     SPDX-FileCopyrightText: 2006 Kevin Ottens <ervin@kde.org>
0003     SPDX-FileCopyrightText: 2008-2010 Dario Freddi <drf@kde.org>
0004     SPDX-FileCopyrightText: 2010 Alejandro Fiestas <alex@eyeos.org>
0005     SPDX-FileCopyrightText: 2010-2013 Lukáš Tinkl <ltinkl@redhat.com>
0006     SPDX-FileCopyrightText: 2015 Kai Uwe Broulik <kde@privat.broulik.de>
0007 
0008     SPDX-License-Identifier: LGPL-2.0-only
0009 
0010 */
0011 
0012 #pragma once
0013 
0014 #include <QObject>
0015 
0016 #include "powerdevilcore_export.h"
0017 
0018 #include "upower_interface.h"
0019 
0020 class POWERDEVILCORE_EXPORT LidController : public QObject
0021 {
0022     Q_OBJECT
0023 public:
0024     LidController();
0025 
0026     /**
0027      * @returns whether the lid is closed or not.
0028      */
0029     bool isLidClosed() const;
0030     /**
0031      * @returns whether the a lid is present
0032      */
0033     bool isLidPresent() const;
0034 
0035 Q_SIGNALS:
0036     /**
0037      * This signal is emitted when the laptop lid is closed or opened
0038      *
0039      * @param closed Whether the lid is now closed or not
0040      */
0041     void lidClosedChanged(bool closed);
0042 
0043 private Q_SLOTS:
0044     void onPropertiesChanged(const QString &ifaceName, const QVariantMap &changedProps, const QStringList &invalidatedProps);
0045 
0046 private:
0047     OrgFreedesktopUPowerInterface *m_upowerInterface = nullptr;
0048     bool m_isLidClosed = false;
0049     bool m_isLidPresent = false;
0050 };