File indexing completed on 2025-02-23 04:35:14

0001 // SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
0002 // SPDX-License-Identifier: GPL-3.0-or-later
0003 
0004 #pragma once
0005 
0006 #include "qinvidiousglobal.h"
0007 
0008 namespace QInvidious
0009 {
0010 
0011 class Preferences
0012 {
0013     Q_GADGET
0014 
0015     Q_PROPERTY(bool autoPlay MEMBER m_autoPlay)
0016     Q_PROPERTY(QString defaultHome MEMBER m_defaultHome)
0017 
0018 public:
0019     FROM_JSON_OVERLOADS(Preferences)
0020     static Preferences fromJson(const QJsonObject &, Preferences &);
0021     [[nodiscard]] QJsonObject toJson() const;
0022 
0023     bool autoPlay() const;
0024     void setAutoPlay(bool autoPlay);
0025 
0026     QString defaultHome() const;
0027     void setDefaultHome(const QString &defaultHome);
0028 
0029 private:
0030     bool m_autoPlay = false;
0031     QString m_defaultHome;
0032     QJsonObject m_originalPreferences; // We need to store all the preferences, to not overwrite them back to default
0033 };
0034 
0035 }
0036 Q_DECLARE_METATYPE(QInvidious::Preferences)