on cfcde21 help sign in
unity8/plugins/LightDM/SessionsModel.h
68 lines 2.4 kB history raw
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
18#ifndef UNITY_SESSIONSMODEL_H
19#define UNITY_SESSIONSMODEL_H
21#include <unitysortfilterproxymodelqml.h>
22#include <QLightDM/SessionsModel>
23#include <QtCore/QHash>
24#include <QtCore/QObject>
25#include <QtCore/QUrl>
27class SessionsModel : public UnitySortFilterProxyModelQML
29 Q_OBJECT
31 Q_ENUMS(SessionModelRoles)
33 Q_PROPERTY(QList<QUrl> iconSearchDirectories READ iconSearchDirectories
34 WRITE setIconSearchDirectories NOTIFY iconSearchDirectoriesChanged)
35Q_SIGNALS:
36 void iconSearchDirectoriesChanged();
38public:
39 enum SessionModelRoles {
40 /* This is tricky / ugly. Since we are ultimately chaining 3 enums together,
41 * the _first_ value of this enum MUST be the _last_ value of
42 * QLightDM::SessionsModel::SessionModelRoles and consquently, this must
43 * also match the last value in the corresponding enum of the integrated lib
44 */
45 TypeRole = QLightDM::SessionsModel::SessionModelRoles::TypeRole,
46 IconRole
47 };
49 explicit SessionsModel(QObject* parent=nullptr);
51 QHash<int, QByteArray> roleNames() const override;
52 int rowCount(const QModelIndex& parent) const override;
53 QVariant data(const QModelIndex& index, int role) const override;
54 QList<QUrl> iconSearchDirectories() const;
55 Q_INVOKABLE QUrl iconUrl(const QString sessionName) const;
57 void setIconSearchDirectories(const QList<QUrl> searchDirectories);
58private:
59 QLightDM::SessionsModel* m_model;
60 QHash<int, QByteArray> m_roleNames;
61 QList<QUrl> m_iconSearchDirectories{
62 QUrl("/usr/share/unity8/Greeter/graphics/session_icons"),
63 QUrl("/usr/local/share/unity-greeter"),
64 QUrl("/usr/share/unity-greeter/")};
66};
68#endif // UNITY_SESSIONSMODEL_H