2021-05-13 09:23:56 +03:00
|
|
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
2022-01-01 06:57:53 +03:00
|
|
|
// SPDX-FileCopyrightText: 2022 Nheko Contributors
|
2023-01-02 06:25:33 +03:00
|
|
|
// SPDX-FileCopyrightText: 2023 Nheko Contributors
|
2021-05-13 09:23:56 +03:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-07-31 05:13:58 +03:00
|
|
|
#include <QFontDatabase>
|
2021-05-13 09:23:56 +03:00
|
|
|
#include <QObject>
|
|
|
|
#include <QPalette>
|
2022-08-31 21:44:21 +03:00
|
|
|
#include <QWindow>
|
2021-05-13 09:23:56 +03:00
|
|
|
|
2022-07-08 18:28:28 +03:00
|
|
|
#include "AliasEditModel.h"
|
2022-05-27 17:31:54 +03:00
|
|
|
#include "PowerlevelsEditModels.h"
|
2022-08-05 22:44:40 +03:00
|
|
|
#include "RoomSummary.h"
|
2021-05-15 00:35:34 +03:00
|
|
|
#include "Theme.h"
|
|
|
|
#include "UserProfile.h"
|
|
|
|
|
2022-10-10 15:38:29 +03:00
|
|
|
class Nheko final : public QObject
|
2021-05-13 09:23:56 +03:00
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
Q_OBJECT
|
2021-05-13 09:23:56 +03:00
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
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)
|
2021-12-31 02:47:14 +03:00
|
|
|
Q_PROPERTY(int tooltipDelay READ tooltipDelay CONSTANT)
|
2021-05-13 09:23:56 +03:00
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
Q_PROPERTY(UserProfile *currentUser READ currentUser NOTIFY profileChanged)
|
2021-05-15 00:35:34 +03:00
|
|
|
|
2021-05-13 09:23:56 +03:00
|
|
|
public:
|
2021-09-18 01:22:33 +03:00
|
|
|
Nheko();
|
2021-05-13 09:23:56 +03:00
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
QPalette colors() const;
|
|
|
|
QPalette inactiveColors() const;
|
|
|
|
Theme theme() const;
|
2021-05-13 09:23:56 +03:00
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
int avatarSize() const { return 40; }
|
2021-05-13 12:32:20 +03:00
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
int paddingSmall() const { return 4; }
|
|
|
|
int paddingMedium() const { return 8; }
|
|
|
|
int paddingLarge() const { return 20; }
|
2021-12-31 02:47:14 +03:00
|
|
|
|
|
|
|
int tooltipDelay() const;
|
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
UserProfile *currentUser() const;
|
2021-05-14 16:23:32 +03:00
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
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;
|
2021-09-30 03:15:25 +03:00
|
|
|
Q_INVOKABLE void logout() const;
|
2022-09-05 03:00:20 +03:00
|
|
|
Q_INVOKABLE void createRoom(bool space,
|
2022-10-04 00:57:30 +03:00
|
|
|
const QString &name,
|
|
|
|
const QString &topic,
|
|
|
|
const QString &aliasLocalpart,
|
2022-09-05 03:00:20 +03:00
|
|
|
bool isEncrypted,
|
|
|
|
int preset);
|
2022-05-27 17:31:54 +03:00
|
|
|
Q_INVOKABLE PowerlevelEditingModels *editPowerlevels(QString room_id_) const
|
|
|
|
{
|
|
|
|
return new PowerlevelEditingModels(room_id_);
|
|
|
|
}
|
2022-07-08 18:28:28 +03:00
|
|
|
Q_INVOKABLE AliasEditingModel *editAliases(QString room_id_) const
|
|
|
|
{
|
|
|
|
return new AliasEditingModel(room_id_.toStdString());
|
|
|
|
}
|
2022-08-31 21:44:21 +03:00
|
|
|
Q_INVOKABLE void setTransientParent(QWindow *window, QWindow *parentWindow) const;
|
2023-02-10 20:01:47 +03:00
|
|
|
Q_INVOKABLE void setWindowRole(QWindow *win, QString newRole) const;
|
2021-05-13 09:52:02 +03:00
|
|
|
|
2021-05-22 15:31:38 +03:00
|
|
|
public slots:
|
2021-09-18 01:22:33 +03:00
|
|
|
void updateUserProfile();
|
2021-05-15 00:35:34 +03:00
|
|
|
|
2021-05-13 09:23:56 +03:00
|
|
|
signals:
|
2021-09-18 01:22:33 +03:00
|
|
|
void colorsChanged();
|
|
|
|
void profileChanged();
|
2021-05-13 09:52:02 +03:00
|
|
|
|
2021-09-30 03:15:25 +03:00
|
|
|
void openLogoutDialog();
|
2021-09-25 04:32:06 +03:00
|
|
|
void openJoinRoomDialog();
|
2022-03-31 00:38:38 +03:00
|
|
|
void joinRoom(QString roomId, QString reason = "");
|
2021-09-30 03:15:25 +03:00
|
|
|
|
2022-08-05 22:44:40 +03:00
|
|
|
void showRoomJoinPrompt(RoomSummary *summary);
|
|
|
|
|
2021-05-15 00:35:34 +03:00
|
|
|
private:
|
2021-09-18 01:22:33 +03:00
|
|
|
QScopedPointer<UserProfile> currentUser_;
|
2021-05-15 00:35:34 +03:00
|
|
|
};
|