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