File indexing completed on 2024-04-14 14:32:48

0001 /***************************************************************************
0002  *   Copyright (C) 2012-2016 by Daniel Nicoletti <dantti12@gmail.com>      *
0003  *   2022 by Han Young <hanyoung@protonmail.com>                           *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; see the file COPYING. If not, write to       *
0017  *   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,  *
0018  *   Boston, MA 02110-1301, USA.                                           *
0019  ***************************************************************************/
0020 
0021 #ifndef DESCRIPTION_H
0022 #define DESCRIPTION_H
0023 
0024 #include <QDBusObjectPath>
0025 #include <QDBusPendingCallWatcher>
0026 class CdInterface;
0027 class DeviceDescription : public QObject
0028 {
0029     Q_OBJECT
0030     Q_PROPERTY(QString colorSpace MEMBER m_colorSpace NOTIFY dataChanged)
0031     Q_PROPERTY(QString deviceTitle MEMBER m_deviceTitle NOTIFY dataChanged)
0032     Q_PROPERTY(QString deviceID MEMBER m_currentDeviceID NOTIFY dataChanged)
0033     Q_PROPERTY(QString deviceScope MEMBER m_deviceScope NOTIFY dataChanged)
0034     Q_PROPERTY(QString deviceKind MEMBER m_currentDeviceKind NOTIFY dataChanged)
0035     Q_PROPERTY(QString currentProfileTitle MEMBER m_currentProfileTitle NOTIFY dataChanged)
0036     Q_PROPERTY(QString calibrateTipMessage MEMBER m_calibrateMsg NOTIFY calibrateMessageChanged)
0037 
0038 public:
0039     explicit DeviceDescription(QObject *parent = nullptr);
0040 
0041     void setCdInterface(CdInterface *interface);
0042     void serviceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner);
0043 
0044     Q_INVOKABLE void setDevice(const QDBusObjectPath &objectPath);
0045 
0046 Q_SIGNALS:
0047     void isDeviceChanged();
0048     void dataChanged();
0049     void calibrateChanged();
0050     void calibrateMessageChanged();
0051 
0052 private Q_SLOTS:
0053     void gotSensors(QDBusPendingCallWatcher *call);
0054     void sensorAddedUpdateCalibrateButton(const QDBusObjectPath &sensorPath);
0055     void sensorRemovedUpdateCalibrateButton(const QDBusObjectPath &sensorPath);
0056 
0057 private:
0058     void generateCalibrateMessage(const QString &kind);
0059     void sensorAdded(const QDBusObjectPath &sensorPath, bool updateCalibrateMessage = true);
0060     void sensorRemoved(const QDBusObjectPath &sensorPath, bool updateCalibrateMessage = true);
0061 
0062     QDBusObjectPath m_currentProfile;
0063 
0064     QString m_deviceTitle;
0065     QString m_deviceScope;
0066     QString m_currentDeviceKind;
0067     QString m_currentDeviceID;
0068     QString m_colorSpace;
0069     QString m_currentProfileTitle;
0070     QString m_calibrateMsg;
0071     QList<QDBusObjectPath> m_sensors;
0072 };
0073 
0074 #endif // DESCRIPTION_H