mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
ui almost looks the same, midway between transition from old room settings to new room settings
This commit is contained in:
parent
37679ac57e
commit
b70f37194f
12 changed files with 112 additions and 37 deletions
|
@ -257,7 +257,7 @@ set(SRC_FILES
|
|||
src/dialogs/PreviewUploadOverlay.cpp
|
||||
src/dialogs/ReCaptcha.cpp
|
||||
src/dialogs/ReadReceipts.cpp
|
||||
src/dialogs/RoomSettings.cpp
|
||||
src/dialogs/RoomSettingsOld.cpp
|
||||
|
||||
# Emoji
|
||||
src/emoji/EmojiModel.cpp
|
||||
|
@ -294,6 +294,7 @@ set(SRC_FILES
|
|||
src/ui/ThemeManager.cpp
|
||||
src/ui/ToggleButton.cpp
|
||||
src/ui/UserProfile.cpp
|
||||
src/ui/RoomSettings.cpp
|
||||
|
||||
src/AvatarProvider.cpp
|
||||
src/BlurhashProvider.cpp
|
||||
|
@ -471,7 +472,7 @@ qt5_wrap_cpp(MOC_HEADERS
|
|||
src/dialogs/RawMessage.h
|
||||
src/dialogs/ReCaptcha.h
|
||||
src/dialogs/ReadReceipts.h
|
||||
src/dialogs/RoomSettings.h
|
||||
src/dialogs/RoomSettingsOld.h
|
||||
|
||||
# Emoji
|
||||
src/emoji/EmojiModel.h
|
||||
|
@ -506,6 +507,7 @@ qt5_wrap_cpp(MOC_HEADERS
|
|||
src/ui/Theme.h
|
||||
src/ui/ThemeManager.h
|
||||
src/ui/UserProfile.h
|
||||
src/ui/RoomSettings.h
|
||||
|
||||
src/notifications/Manager.h
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ ApplicationWindow {
|
|||
minimumHeight: 420
|
||||
palette: colors
|
||||
color: colors.window
|
||||
title: "Room Settings"
|
||||
title: roomSettings.roomName
|
||||
modality: Qt.Modal
|
||||
|
||||
Shortcut {
|
||||
|
|
|
@ -177,7 +177,9 @@ Page {
|
|||
Connections {
|
||||
target: TimelineManager
|
||||
onOpenRoomSettingsDialog: {
|
||||
var roomSettings = roomSettingsComponent.createObject(timelineRoot);
|
||||
var roomSettings = roomSettingsComponent.createObject(timelineRoot, {
|
||||
"roomSettings": roomSettings
|
||||
});
|
||||
roomSettings.show();
|
||||
}
|
||||
}
|
||||
|
|
10
resources/qml/ToggleButton.qml
Normal file
10
resources/qml/ToggleButton.qml
Normal file
|
@ -0,0 +1,10 @@
|
|||
import QtQuick 2.5
|
||||
import QtQuick.Controls 2.3
|
||||
import im.nheko 1.0
|
||||
|
||||
Switch {
|
||||
property color activeColor
|
||||
property color disabledColor
|
||||
property color inactiveColor
|
||||
property color trackColor
|
||||
}
|
|
@ -51,7 +51,7 @@
|
|||
#include "dialogs/Logout.h"
|
||||
#include "dialogs/MemberList.h"
|
||||
#include "dialogs/ReadReceipts.h"
|
||||
#include "dialogs/RoomSettings.h"
|
||||
#include "dialogs/RoomSettingsOld.h"
|
||||
|
||||
MainWindow *MainWindow::instance_ = nullptr;
|
||||
|
||||
|
@ -366,7 +366,7 @@ MainWindow::hasActiveUser()
|
|||
void
|
||||
MainWindow::openRoomSettings(const QString &room_id)
|
||||
{
|
||||
auto dialog = new dialogs::RoomSettings(room_id, this);
|
||||
auto dialog = new dialogs::RoomSettingsOld(room_id, this);
|
||||
|
||||
showDialog(dialog);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ class LeaveRoom;
|
|||
class Logout;
|
||||
class MemberList;
|
||||
class ReCaptcha;
|
||||
class RoomSettings;
|
||||
class RoomSettingsOld;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "dialogs/RoomSettings.h"
|
||||
#include "dialogs/RoomSettingsOld.h"
|
||||
#include <QApplication>
|
||||
#include <QComboBox>
|
||||
#include <QEvent>
|
||||
|
@ -195,7 +195,7 @@ EditModal::setFields(const QString &roomName, const QString &roomTopic)
|
|||
topicInput_->setText(roomTopic);
|
||||
}
|
||||
|
||||
RoomSettings::RoomSettings(const QString &room_id, QWidget *parent)
|
||||
RoomSettingsOld::RoomSettingsOld(const QString &room_id, QWidget *parent)
|
||||
: QFrame(parent)
|
||||
, room_id_{std::move(room_id)}
|
||||
{
|
||||
|
@ -253,7 +253,7 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent)
|
|||
notifCombo->addItem(tr("Mentions only")); // {"actions":["dont_notify"]}
|
||||
notifCombo->addItem(tr("All messages")); // delete rule
|
||||
|
||||
connect(this, &RoomSettings::notifChanged, notifCombo, &QComboBox::setCurrentIndex);
|
||||
connect(this, &RoomSettingsOld::notifChanged, notifCombo, &QComboBox::setCurrentIndex);
|
||||
http::client()->get_pushrules(
|
||||
"global",
|
||||
"override",
|
||||
|
@ -487,7 +487,7 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent)
|
|||
auto filter = new ClickableFilter(this);
|
||||
avatar_->installEventFilter(filter);
|
||||
avatar_->setCursor(Qt::PointingHandCursor);
|
||||
connect(filter, &ClickableFilter::clicked, this, &RoomSettings::updateAvatar);
|
||||
connect(filter, &ClickableFilter::clicked, this, &RoomSettingsOld::updateAvatar);
|
||||
}
|
||||
|
||||
roomNameLabel_ = new QLabel(QString::fromStdString(info_.name), this);
|
||||
|
@ -542,7 +542,7 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent)
|
|||
layout->addLayout(spinnerLayout);
|
||||
layout->addStretch(1);
|
||||
|
||||
connect(this, &RoomSettings::enableEncryptionError, this, [this](const QString &msg) {
|
||||
connect(this, &RoomSettingsOld::enableEncryptionError, this, [this](const QString &msg) {
|
||||
encryptionToggle_->setState(false);
|
||||
keyRequestsToggle_->setState(false);
|
||||
keyRequestsToggle_->setEnabled(false);
|
||||
|
@ -551,7 +551,7 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent)
|
|||
emit ChatPage::instance()->showNotification(msg);
|
||||
});
|
||||
|
||||
connect(this, &RoomSettings::showErrorMessage, this, [this](const QString &msg) {
|
||||
connect(this, &RoomSettingsOld::showErrorMessage, this, [this](const QString &msg) {
|
||||
if (!errorLabel_)
|
||||
return;
|
||||
|
||||
|
@ -561,18 +561,18 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent)
|
|||
errorLabel_->setText(msg);
|
||||
});
|
||||
|
||||
connect(this, &RoomSettings::accessRulesUpdated, this, [this]() {
|
||||
connect(this, &RoomSettingsOld::accessRulesUpdated, this, [this]() {
|
||||
stopLoadingSpinner();
|
||||
resetErrorLabel();
|
||||
});
|
||||
|
||||
auto closeShortcut = new QShortcut(QKeySequence(QKeySequence::Cancel), this);
|
||||
connect(closeShortcut, &QShortcut::activated, this, &RoomSettings::close);
|
||||
connect(okBtn, &QPushButton::clicked, this, &RoomSettings::close);
|
||||
connect(closeShortcut, &QShortcut::activated, this, &RoomSettingsOld::close);
|
||||
connect(okBtn, &QPushButton::clicked, this, &RoomSettingsOld::close);
|
||||
}
|
||||
|
||||
void
|
||||
RoomSettings::setupEditButton()
|
||||
RoomSettingsOld::setupEditButton()
|
||||
{
|
||||
btnLayout_ = new QHBoxLayout;
|
||||
btnLayout_->setSpacing(BUTTON_SPACING);
|
||||
|
@ -610,7 +610,7 @@ RoomSettings::setupEditButton()
|
|||
}
|
||||
|
||||
void
|
||||
RoomSettings::retrieveRoomInfo()
|
||||
RoomSettingsOld::retrieveRoomInfo()
|
||||
{
|
||||
try {
|
||||
usesEncryption_ = cache::isRoomEncrypted(room_id_.toStdString());
|
||||
|
@ -623,7 +623,7 @@ RoomSettings::retrieveRoomInfo()
|
|||
}
|
||||
|
||||
void
|
||||
RoomSettings::enableEncryption()
|
||||
RoomSettingsOld::enableEncryption()
|
||||
{
|
||||
const auto room_id = room_id_.toStdString();
|
||||
http::client()->enable_encryption(
|
||||
|
@ -645,7 +645,7 @@ RoomSettings::enableEncryption()
|
|||
}
|
||||
|
||||
void
|
||||
RoomSettings::showEvent(QShowEvent *event)
|
||||
RoomSettingsOld::showEvent(QShowEvent *event)
|
||||
{
|
||||
resetErrorLabel();
|
||||
stopLoadingSpinner();
|
||||
|
@ -654,7 +654,7 @@ RoomSettings::showEvent(QShowEvent *event)
|
|||
}
|
||||
|
||||
bool
|
||||
RoomSettings::canChangeJoinRules(const std::string &room_id, const std::string &user_id) const
|
||||
RoomSettingsOld::canChangeJoinRules(const std::string &room_id, const std::string &user_id) const
|
||||
{
|
||||
try {
|
||||
return cache::hasEnoughPowerLevel({EventType::RoomJoinRules}, room_id, user_id);
|
||||
|
@ -666,7 +666,7 @@ RoomSettings::canChangeJoinRules(const std::string &room_id, const std::string &
|
|||
}
|
||||
|
||||
bool
|
||||
RoomSettings::canChangeNameAndTopic(const std::string &room_id, const std::string &user_id) const
|
||||
RoomSettingsOld::canChangeNameAndTopic(const std::string &room_id, const std::string &user_id) const
|
||||
{
|
||||
try {
|
||||
return cache::hasEnoughPowerLevel(
|
||||
|
@ -679,7 +679,7 @@ RoomSettings::canChangeNameAndTopic(const std::string &room_id, const std::strin
|
|||
}
|
||||
|
||||
bool
|
||||
RoomSettings::canChangeAvatar(const std::string &room_id, const std::string &user_id) const
|
||||
RoomSettingsOld::canChangeAvatar(const std::string &room_id, const std::string &user_id) const
|
||||
{
|
||||
try {
|
||||
return cache::hasEnoughPowerLevel({EventType::RoomAvatar}, room_id, user_id);
|
||||
|
@ -691,7 +691,7 @@ RoomSettings::canChangeAvatar(const std::string &room_id, const std::string &use
|
|||
}
|
||||
|
||||
void
|
||||
RoomSettings::updateAccessRules(const std::string &room_id,
|
||||
RoomSettingsOld::updateAccessRules(const std::string &room_id,
|
||||
const mtx::events::state::JoinRules &join_rule,
|
||||
const mtx::events::state::GuestAccess &guest_access)
|
||||
{
|
||||
|
@ -732,7 +732,7 @@ RoomSettings::updateAccessRules(const std::string &room_id,
|
|||
}
|
||||
|
||||
void
|
||||
RoomSettings::stopLoadingSpinner()
|
||||
RoomSettingsOld::stopLoadingSpinner()
|
||||
{
|
||||
if (spinner_) {
|
||||
spinner_->stop();
|
||||
|
@ -741,7 +741,7 @@ RoomSettings::stopLoadingSpinner()
|
|||
}
|
||||
|
||||
void
|
||||
RoomSettings::startLoadingSpinner()
|
||||
RoomSettingsOld::startLoadingSpinner()
|
||||
{
|
||||
if (spinner_) {
|
||||
spinner_->start();
|
||||
|
@ -750,7 +750,7 @@ RoomSettings::startLoadingSpinner()
|
|||
}
|
||||
|
||||
void
|
||||
RoomSettings::displayErrorMessage(const QString &msg)
|
||||
RoomSettingsOld::displayErrorMessage(const QString &msg)
|
||||
{
|
||||
stopLoadingSpinner();
|
||||
|
||||
|
@ -759,7 +759,7 @@ RoomSettings::displayErrorMessage(const QString &msg)
|
|||
}
|
||||
|
||||
void
|
||||
RoomSettings::setAvatar()
|
||||
RoomSettingsOld::setAvatar()
|
||||
{
|
||||
stopLoadingSpinner();
|
||||
|
||||
|
@ -768,7 +768,7 @@ RoomSettings::setAvatar()
|
|||
}
|
||||
|
||||
void
|
||||
RoomSettings::resetErrorLabel()
|
||||
RoomSettingsOld::resetErrorLabel()
|
||||
{
|
||||
if (errorLabel_) {
|
||||
errorLabel_->hide();
|
||||
|
@ -777,7 +777,7 @@ RoomSettings::resetErrorLabel()
|
|||
}
|
||||
|
||||
void
|
||||
RoomSettings::updateAvatar()
|
||||
RoomSettingsOld::updateAvatar()
|
||||
{
|
||||
const QString picturesFolder =
|
||||
QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
|
||||
|
@ -811,8 +811,8 @@ RoomSettings::updateAvatar()
|
|||
// Events emitted from the http callbacks (different threads) will
|
||||
// be queued back into the UI thread through this proxy object.
|
||||
auto proxy = std::make_shared<ThreadProxy>();
|
||||
connect(proxy.get(), &ThreadProxy::error, this, &RoomSettings::displayErrorMessage);
|
||||
connect(proxy.get(), &ThreadProxy::avatarChanged, this, &RoomSettings::setAvatar);
|
||||
connect(proxy.get(), &ThreadProxy::error, this, &RoomSettingsOld::displayErrorMessage);
|
||||
connect(proxy.get(), &ThreadProxy::avatarChanged, this, &RoomSettingsOld::setAvatar);
|
||||
|
||||
const auto bin = file.peek(file.size());
|
||||
const auto payload = std::string(bin.data(), bin.size());
|
|
@ -86,11 +86,11 @@ private:
|
|||
|
||||
namespace dialogs {
|
||||
|
||||
class RoomSettings : public QFrame
|
||||
class RoomSettingsOld : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RoomSettings(const QString &room_id, QWidget *parent = nullptr);
|
||||
RoomSettingsOld(const QString &room_id, QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void enableEncryptionError(const QString &msg);
|
|
@ -393,7 +393,9 @@ void
|
|||
TimelineViewManager::openRoomSettings()
|
||||
{
|
||||
MainWindow::instance()->openRoomSettings(timeline_->roomId());
|
||||
emit openRoomSettingsDialog();
|
||||
|
||||
RoomSettings *roomSettings = new RoomSettings(timeline_->roomId(), this);
|
||||
emit openRoomSettingsDialog(roomSettings);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
#include "WebRTCSession.h"
|
||||
#include "emoji/EmojiModel.h"
|
||||
#include "emoji/Provider.h"
|
||||
#include "dialogs/RoomSettings.h"
|
||||
#include "dialogs/RoomSettingsOld.h"
|
||||
#include "ui/RoomSettings.h"
|
||||
|
||||
class MxcImageProvider;
|
||||
class BlurhashProvider;
|
||||
|
@ -88,7 +89,7 @@ signals:
|
|||
void showRoomList();
|
||||
void narrowViewChanged();
|
||||
void focusChanged();
|
||||
void openRoomSettingsDialog();
|
||||
void openRoomSettingsDialog(RoomSettings *roomSettings);
|
||||
|
||||
public slots:
|
||||
void updateReadReceipts(const QString &room_id, const std::vector<QString> &event_ids);
|
||||
|
|
33
src/ui/RoomSettings.cpp
Normal file
33
src/ui/RoomSettings.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include "RoomSettings.h"
|
||||
|
||||
#include <mtx/responses/common.hpp>
|
||||
#include <mtx/responses/media.hpp>
|
||||
|
||||
#include "Cache.h"
|
||||
#include "Logging.h"
|
||||
|
||||
RoomSettings::RoomSettings(QString roomid, QObject *parent)
|
||||
: roomid_{std::move(roomid)}
|
||||
, QObject(parent)
|
||||
{
|
||||
retrieveRoomInfo();
|
||||
}
|
||||
|
||||
QString
|
||||
RoomSettings::roomName() const
|
||||
{
|
||||
return QString(info_.name.c_str());
|
||||
}
|
||||
|
||||
void
|
||||
RoomSettings::retrieveRoomInfo()
|
||||
{
|
||||
try {
|
||||
usesEncryption_ = cache::isRoomEncrypted(roomid_.toStdString());
|
||||
info_ = cache::singleRoomInfo(roomid_.toStdString());
|
||||
//setAvatar();
|
||||
} catch (const lmdb::error &) {
|
||||
nhlog::db()->warn("failed to retrieve room info from cache: {}",
|
||||
roomid_.toStdString());
|
||||
}
|
||||
}
|
25
src/ui/RoomSettings.h
Normal file
25
src/ui/RoomSettings.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "CacheStructs.h"
|
||||
|
||||
class RoomSettings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString roomName READ roomName CONSTANT)
|
||||
|
||||
public:
|
||||
RoomSettings(QString roomid, QObject *parent = nullptr);
|
||||
|
||||
QString roomName() const;
|
||||
|
||||
private:
|
||||
void retrieveRoomInfo();
|
||||
|
||||
private:
|
||||
QString roomid_;
|
||||
bool usesEncryption_ = false;
|
||||
RoomInfo info_;
|
||||
};
|
Loading…
Reference in a new issue