File indexing completed on 2024-05-12 16:14:35

0001 // SPDX-FileCopyrightText: 2021 Han Young <hanyoung@protonmail.com>
0002 // SPDX-License-Identifier: LGPL-2.0-or-later
0003 #ifndef SoundsPickerModel_H
0004 #define SoundsPickerModel_H
0005 
0006 #include <QAbstractListModel>
0007 #include <memory>
0008 class SoundsPickerModel : public QAbstractListModel
0009 {
0010     Q_OBJECT
0011     Q_PROPERTY(bool notification READ notification WRITE setNotification NOTIFY notificationChanged)
0012     Q_PROPERTY(QStringList defaultAudio READ defaultAudio WRITE setDefaultAudio NOTIFY defaultAudioChanged)
0013     Q_PROPERTY(QString theme READ theme WRITE setTheme NOTIFY themeChanged)
0014 public:
0015     enum Roles {
0016         NameRole = Qt::UserRole,
0017         UrlRole
0018     };
0019     
0020     explicit SoundsPickerModel(QObject *parent = nullptr);
0021     ~SoundsPickerModel();
0022     
0023     bool notification() const;
0024     void setNotification(bool notification);
0025     Q_INVOKABLE QString initialSourceUrl(int index);
0026     QHash<int, QByteArray> roleNames() const override;
0027     QVariant data(const QModelIndex &index, int role) const override;
0028     int rowCount(const QModelIndex& parent) const override;
0029 
0030     const QStringList &defaultAudio() const;
0031     void setDefaultAudio(const QStringList &audio);
0032     const QString &theme() const;
0033     void setTheme(const QString &theme);
0034 
0035 Q_SIGNALS:
0036     void notificationChanged();
0037     void defaultAudioChanged();
0038     void themeChanged();
0039     
0040 private:
0041     void loadFiles();
0042     void rearrangeRingtoneOrder();
0043     class Private;
0044     std::unique_ptr<Private> d;
0045 };
0046 
0047 #endif // SoundsPickerModel_H