blob: c1f3579c0138f6149e1567738a1dcb40d909189a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
// SPDX-FileCopyrightText: Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <QFontDatabase>
#include <QObject>
#include <QPalette>
#include <QQmlEngine>
#include <QWindow>
#include "AliasEditModel.h"
#include "PowerlevelsEditModels.h"
#include "RoomSummary.h"
#include "Theme.h"
#include "UserProfile.h"
class Nheko : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_SINGLETON
Q_PROPERTY(QPalette colors READ colors NOTIFY colorsChanged)
Q_PROPERTY(QPalette inactiveColors READ inactiveColors NOTIFY colorsChanged)
Q_PROPERTY(Theme theme READ theme NOTIFY colorsChanged)
Q_PROPERTY(int avatarSize READ avatarSize CONSTANT)
Q_PROPERTY(int paddingSmall READ paddingSmall CONSTANT)
Q_PROPERTY(int paddingMedium READ paddingMedium CONSTANT)
Q_PROPERTY(int paddingLarge READ paddingLarge CONSTANT)
Q_PROPERTY(int tooltipDelay READ tooltipDelay CONSTANT)
Q_PROPERTY(UserProfile *currentUser READ currentUser NOTIFY profileChanged)
public:
Nheko();
QPalette colors() const;
QPalette inactiveColors() const;
Theme theme() const;
int avatarSize() const { return 40; }
int paddingSmall() const { return 4; }
int paddingMedium() const { return 8; }
int paddingLarge() const { return 20; }
int tooltipDelay() const;
UserProfile *currentUser() const;
Q_INVOKABLE QFont monospaceFont() const
{
return QFontDatabase::systemFont(QFontDatabase::FixedFont);
}
Q_INVOKABLE void openLink(QString link) const;
Q_INVOKABLE void setStatusMessage(QString msg) const;
Q_INVOKABLE void showUserSettingsPage() const;
Q_INVOKABLE void logout() const;
Q_INVOKABLE void createRoom(bool space,
const QString &name,
const QString &topic,
const QString &aliasLocalpart,
bool isEncrypted,
int preset);
Q_INVOKABLE PowerlevelEditingModels *editPowerlevels(QString room_id_) const
{
return new PowerlevelEditingModels(room_id_);
}
Q_INVOKABLE AliasEditingModel *editAliases(QString room_id_) const
{
return new AliasEditingModel(room_id_.toStdString());
}
Q_INVOKABLE void setTransientParent(QWindow *window, QWindow *parentWindow) const;
Q_INVOKABLE void setWindowRole(QWindow *win, QString newRole) const;
public slots:
void updateUserProfile();
signals:
void colorsChanged();
void profileChanged();
void openLogoutDialog();
void openJoinRoomDialog();
void joinRoom(QString roomId, QString reason = "");
void showRoomJoinPrompt(RoomSummary *summary);
private:
QScopedPointer<UserProfile> currentUser_;
};
|