mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Fix more warnings and remove dead code
This commit is contained in:
parent
409ff22d80
commit
bb290f9fec
50 changed files with 276 additions and 695 deletions
|
@ -311,7 +311,6 @@ set(SRC_FILES
|
|||
src/dialogs/CreateRoom.cpp
|
||||
src/dialogs/FallbackAuth.cpp
|
||||
src/dialogs/ImageOverlay.cpp
|
||||
src/dialogs/Logout.cpp
|
||||
src/dialogs/PreviewUploadOverlay.cpp
|
||||
src/dialogs/ReCaptcha.cpp
|
||||
|
||||
|
@ -332,10 +331,8 @@ set(SRC_FILES
|
|||
src/timeline/RoomlistModel.cpp
|
||||
|
||||
# UI components
|
||||
src/ui/Badge.cpp
|
||||
src/ui/DropShadow.cpp
|
||||
src/ui/FlatButton.cpp
|
||||
src/ui/InfoMessage.cpp
|
||||
src/ui/Label.cpp
|
||||
src/ui/LoadingIndicator.cpp
|
||||
src/ui/MxcAnimatedImage.cpp
|
||||
|
@ -522,7 +519,6 @@ qt5_wrap_cpp(MOC_HEADERS
|
|||
src/dialogs/CreateRoom.h
|
||||
src/dialogs/FallbackAuth.h
|
||||
src/dialogs/ImageOverlay.h
|
||||
src/dialogs/Logout.h
|
||||
src/dialogs/PreviewUploadOverlay.h
|
||||
src/dialogs/ReCaptcha.h
|
||||
|
||||
|
@ -542,9 +538,7 @@ qt5_wrap_cpp(MOC_HEADERS
|
|||
src/timeline/RoomlistModel.h
|
||||
|
||||
# UI components
|
||||
src/ui/Badge.h
|
||||
src/ui/FlatButton.h
|
||||
src/ui/InfoMessage.h
|
||||
src/ui/Label.h
|
||||
src/ui/LoadingIndicator.h
|
||||
src/ui/MxcAnimatedImage.h
|
||||
|
|
|
@ -62,6 +62,7 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
|||
|
||||
topLayout_ = new QHBoxLayout(this);
|
||||
topLayout_->setSpacing(0);
|
||||
topLayout_->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
view_manager_ = new TimelineViewManager(callManager_, this);
|
||||
|
||||
|
@ -777,8 +778,7 @@ ChatPage::inviteUser(QString userid, QString reason)
|
|||
if (QMessageBox::question(this,
|
||||
tr("Confirm invite"),
|
||||
tr("Do you really want to invite %1 (%2)?")
|
||||
.arg(cache::displayName(room, userid))
|
||||
.arg(userid)) != QMessageBox::Yes)
|
||||
.arg(cache::displayName(room, userid), userid)) != QMessageBox::Yes)
|
||||
return;
|
||||
|
||||
http::client()->invite_user(
|
||||
|
@ -786,10 +786,9 @@ ChatPage::inviteUser(QString userid, QString reason)
|
|||
userid.toStdString(),
|
||||
[this, userid, room](const mtx::responses::Empty &, mtx::http::RequestErr err) {
|
||||
if (err) {
|
||||
emit showNotification(tr("Failed to invite %1 to %2: %3")
|
||||
.arg(userid)
|
||||
.arg(room)
|
||||
.arg(QString::fromStdString(err->matrix_error.error)));
|
||||
emit showNotification(
|
||||
tr("Failed to invite %1 to %2: %3")
|
||||
.arg(userid, room, QString::fromStdString(err->matrix_error.error)));
|
||||
} else
|
||||
emit showNotification(tr("Invited user: %1").arg(userid));
|
||||
},
|
||||
|
@ -803,8 +802,7 @@ ChatPage::kickUser(QString userid, QString reason)
|
|||
if (QMessageBox::question(this,
|
||||
tr("Confirm kick"),
|
||||
tr("Do you really want to kick %1 (%2)?")
|
||||
.arg(cache::displayName(room, userid))
|
||||
.arg(userid)) != QMessageBox::Yes)
|
||||
.arg(cache::displayName(room, userid), userid)) != QMessageBox::Yes)
|
||||
return;
|
||||
|
||||
http::client()->kick_user(
|
||||
|
@ -812,10 +810,9 @@ ChatPage::kickUser(QString userid, QString reason)
|
|||
userid.toStdString(),
|
||||
[this, userid, room](const mtx::responses::Empty &, mtx::http::RequestErr err) {
|
||||
if (err) {
|
||||
emit showNotification(tr("Failed to kick %1 from %2: %3")
|
||||
.arg(userid)
|
||||
.arg(room)
|
||||
.arg(QString::fromStdString(err->matrix_error.error)));
|
||||
emit showNotification(
|
||||
tr("Failed to kick %1 from %2: %3")
|
||||
.arg(userid, room, QString::fromStdString(err->matrix_error.error)));
|
||||
} else
|
||||
emit showNotification(tr("Kicked user: %1").arg(userid));
|
||||
},
|
||||
|
@ -826,11 +823,11 @@ ChatPage::banUser(QString userid, QString reason)
|
|||
{
|
||||
auto room = currentRoom();
|
||||
|
||||
if (QMessageBox::question(this,
|
||||
tr("Confirm ban"),
|
||||
tr("Do you really want to ban %1 (%2)?")
|
||||
.arg(cache::displayName(room, userid))
|
||||
.arg(userid)) != QMessageBox::Yes)
|
||||
if (QMessageBox::question(
|
||||
this,
|
||||
tr("Confirm ban"),
|
||||
tr("Do you really want to ban %1 (%2)?").arg(cache::displayName(room, userid), userid)) !=
|
||||
QMessageBox::Yes)
|
||||
return;
|
||||
|
||||
http::client()->ban_user(
|
||||
|
@ -838,10 +835,9 @@ ChatPage::banUser(QString userid, QString reason)
|
|||
userid.toStdString(),
|
||||
[this, userid, room](const mtx::responses::Empty &, mtx::http::RequestErr err) {
|
||||
if (err) {
|
||||
emit showNotification(tr("Failed to ban %1 in %2: %3")
|
||||
.arg(userid)
|
||||
.arg(room)
|
||||
.arg(QString::fromStdString(err->matrix_error.error)));
|
||||
emit showNotification(
|
||||
tr("Failed to ban %1 in %2: %3")
|
||||
.arg(userid, room, QString::fromStdString(err->matrix_error.error)));
|
||||
} else
|
||||
emit showNotification(tr("Banned user: %1").arg(userid));
|
||||
},
|
||||
|
@ -855,8 +851,7 @@ ChatPage::unbanUser(QString userid, QString reason)
|
|||
if (QMessageBox::question(this,
|
||||
tr("Confirm unban"),
|
||||
tr("Do you really want to unban %1 (%2)?")
|
||||
.arg(cache::displayName(room, userid))
|
||||
.arg(userid)) != QMessageBox::Yes)
|
||||
.arg(cache::displayName(room, userid), userid)) != QMessageBox::Yes)
|
||||
return;
|
||||
|
||||
http::client()->unban_user(
|
||||
|
@ -864,10 +859,9 @@ ChatPage::unbanUser(QString userid, QString reason)
|
|||
userid.toStdString(),
|
||||
[this, userid, room](const mtx::responses::Empty &, mtx::http::RequestErr err) {
|
||||
if (err) {
|
||||
emit showNotification(tr("Failed to unban %1 in %2: %3")
|
||||
.arg(userid)
|
||||
.arg(room)
|
||||
.arg(QString::fromStdString(err->matrix_error.error)));
|
||||
emit showNotification(
|
||||
tr("Failed to unban %1 in %2: %3")
|
||||
.arg(userid, room, QString::fromStdString(err->matrix_error.error)));
|
||||
} else
|
||||
emit showNotification(tr("Unbanned user: %1").arg(userid));
|
||||
},
|
||||
|
@ -1201,7 +1195,7 @@ ChatPage::startChat(QString userid)
|
|||
auto joined_rooms = cache::joinedRooms();
|
||||
auto room_infos = cache::getRoomInfo(joined_rooms);
|
||||
|
||||
for (std::string room_id : joined_rooms) {
|
||||
for (const std::string &room_id : joined_rooms) {
|
||||
if (room_infos[QString::fromStdString(room_id)].member_count == 2) {
|
||||
auto room_members = cache::roomMembers(room_id);
|
||||
if (std::find(room_members.begin(), room_members.end(), (userid).toStdString()) !=
|
||||
|
@ -1323,8 +1317,9 @@ ChatPage::handleMatrixUri(QString uri)
|
|||
std::vector<std::string> vias;
|
||||
QString action;
|
||||
|
||||
for (QString item :
|
||||
uri_.query(QUrl::ComponentFormattingOption::FullyEncoded).split('&', Qt::SkipEmptyParts)) {
|
||||
auto items =
|
||||
uri_.query(QUrl::ComponentFormattingOption::FullyEncoded).split('&', Qt::SkipEmptyParts);
|
||||
for (QString item : qAsConst(items)) {
|
||||
nhlog::ui()->info("item: {}", item.toStdString());
|
||||
|
||||
if (item.startsWith("action=")) {
|
||||
|
@ -1350,7 +1345,7 @@ ChatPage::handleMatrixUri(QString uri)
|
|||
auto joined_rooms = cache::joinedRooms();
|
||||
auto targetRoomId = mxid1.toStdString();
|
||||
|
||||
for (auto roomid : joined_rooms) {
|
||||
for (const auto &roomid : joined_rooms) {
|
||||
if (roomid == targetRoomId) {
|
||||
view_manager_->rooms()->setCurrentRoom(mxid1);
|
||||
if (!mxid2.isEmpty())
|
||||
|
@ -1368,7 +1363,7 @@ ChatPage::handleMatrixUri(QString uri)
|
|||
auto joined_rooms = cache::joinedRooms();
|
||||
auto targetRoomAlias = mxid1.toStdString();
|
||||
|
||||
for (auto roomid : joined_rooms) {
|
||||
for (const auto &roomid : joined_rooms) {
|
||||
auto aliases = cache::client()->getRoomAliases(roomid);
|
||||
if (aliases) {
|
||||
if (aliases->alias == targetRoomAlias) {
|
||||
|
|
|
@ -48,9 +48,9 @@ CompletionProxyModel::CompletionProxyModel(QAbstractItemModel *model,
|
|||
.toString()
|
||||
.toLower();
|
||||
|
||||
for (const auto &e : QStringView(string1).split(splitPoints)) {
|
||||
if (!e.isEmpty()) // NOTE(Nico): Use Qt::SkipEmptyParts in Qt 5.14
|
||||
trie_.insert(e.toUcs4(), i);
|
||||
auto split1 = QStringView(string1).split(splitPoints, Qt::SkipEmptyParts);
|
||||
for (const auto &e : qAsConst(split1)) {
|
||||
trie_.insert(e.toUcs4(), i);
|
||||
}
|
||||
|
||||
auto string2 = sourceModel()
|
||||
|
@ -59,9 +59,9 @@ CompletionProxyModel::CompletionProxyModel(QAbstractItemModel *model,
|
|||
.toLower();
|
||||
|
||||
if (!string2.isEmpty()) {
|
||||
for (const auto &e : QStringView(string2).split(splitPoints)) {
|
||||
if (!e.isEmpty()) // NOTE(Nico): Use Qt::SkipEmptyParts in Qt 5.14
|
||||
trie_.insert(e.toUcs4(), i);
|
||||
auto split2 = QStringView(string2).split(splitPoints, Qt::SkipEmptyParts);
|
||||
for (const auto &e : qAsConst(split2)) {
|
||||
trie_.insert(e.toUcs4(), i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
15
src/Config.h
15
src/Config.h
|
@ -7,10 +7,11 @@
|
|||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
|
||||
// clazy:excludeall=non-pod-global-static
|
||||
|
||||
// Non-theme app configuration. Layouts, fonts spacing etc.
|
||||
//
|
||||
// Font sizes are in pixels.
|
||||
|
||||
namespace conf {
|
||||
// Global settings.
|
||||
constexpr int fontSize = 14;
|
||||
|
@ -54,16 +55,18 @@ constexpr auto LABEL_BIG_SIZE_RATIO = 2;
|
|||
}
|
||||
|
||||
namespace strings {
|
||||
const QString url_html = "<a href=\"\\1\">\\1</a>";
|
||||
const QString url_html = QStringLiteral("<a href=\"\\1\">\\1</a>");
|
||||
const QRegularExpression url_regex(
|
||||
// match an URL, that is not quoted, i.e.
|
||||
// vvvvvv match quote via negative lookahead/lookbehind vv
|
||||
// vvvv atomic match url -> fail if there is a " before or after vvv
|
||||
R"((?<!["'])(?>((www\.(?!\.)|[a-z][a-z0-9+.-]*://)[^\s<>'"]+[^!,\.\s<>'"\]\)\:]))(?!["']))");
|
||||
QStringLiteral(
|
||||
R"((?<!["'])(?>((www\.(?!\.)|[a-z][a-z0-9+.-]*://)[^\s<>'"]+[^!,\.\s<>'"\]\)\:]))(?!["']))"));
|
||||
// match any markdown matrix.to link. Capture group 1 is the link name, group 2 is the target.
|
||||
static const QRegularExpression
|
||||
matrixToMarkdownLink(R"(\[(.*?)(?<!\\)\]\((https://matrix.to/#/.*?\)))");
|
||||
static const QRegularExpression matrixToLink(R"(<a href=\"(https://matrix.to/#/.*?)\">(.*?)</a>)");
|
||||
static const QRegularExpression matrixToMarkdownLink(
|
||||
R"(\[(.*?)(?<!\\)\]\((https://matrix.to/#/.*?\)))"); // clazy:exclude=non-pod-global-static
|
||||
static const QRegularExpression matrixToLink(
|
||||
R"(<a href=\"(https://matrix.to/#/.*?)\">(.*?)</a>)"); // clazy:exclude=non-pod-global-static
|
||||
}
|
||||
|
||||
// Window geometry.
|
||||
|
|
|
@ -16,7 +16,7 @@ InviteesModel::InviteesModel(QObject *parent)
|
|||
void
|
||||
InviteesModel::addUser(QString mxid)
|
||||
{
|
||||
for (const auto &invitee : invitees_)
|
||||
for (const auto &invitee : qAsConst(invitees_))
|
||||
if (invitee->mxid_ == mxid)
|
||||
return;
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include "JdenticonProvider.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
#include <QPluginLoader>
|
||||
|
@ -27,8 +26,6 @@ getJdenticonInterface()
|
|||
static bool interfaceExists{true};
|
||||
|
||||
if (interface == nullptr && interfaceExists) {
|
||||
QDir pluginsDir(qApp->applicationDirPath());
|
||||
|
||||
QPluginLoader pluginLoader("qtjdenticon");
|
||||
QObject *plugin = pluginLoader.instance();
|
||||
if (plugin) {
|
||||
|
|
|
@ -79,7 +79,7 @@ public slots:
|
|||
auto query = id.mid(queryStart + 1);
|
||||
auto queryBits = query.splitRef('&');
|
||||
|
||||
for (auto b : queryBits) {
|
||||
for (const auto &b : queryBits) {
|
||||
if (b.startsWith(QStringView(u"radius="))) {
|
||||
radius = b.mid(7).toDouble();
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ LoginPage::LoginPage(QWidget *parent)
|
|||
|
||||
top_bar_layout_ = new QHBoxLayout();
|
||||
top_bar_layout_->setSpacing(0);
|
||||
top_bar_layout_->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
back_button_ = new FlatButton(this);
|
||||
back_button_->setMinimumSize(QSize(30, 30));
|
||||
|
|
|
@ -203,7 +203,7 @@ MainWindow::removeOverlayProgressBar()
|
|||
QTimer *timer = new QTimer(this);
|
||||
timer->setSingleShot(true);
|
||||
|
||||
connect(timer, &QTimer::timeout, [this, timer]() {
|
||||
connect(timer, &QTimer::timeout, this, [this, timer]() {
|
||||
timer->deleteLater();
|
||||
|
||||
if (modal_)
|
||||
|
|
|
@ -37,7 +37,6 @@ struct CreateRoom;
|
|||
namespace dialogs {
|
||||
class CreateRoom;
|
||||
class InviteUsers;
|
||||
class Logout;
|
||||
class MemberList;
|
||||
class ReCaptcha;
|
||||
}
|
||||
|
@ -60,7 +59,6 @@ public:
|
|||
void
|
||||
openCreateRoomDialog(std::function<void(const mtx::requests::CreateRoom &request)> callback);
|
||||
void openJoinRoomDialog(std::function<void(const QString &room_id)> callback);
|
||||
void openLogoutDialog();
|
||||
|
||||
void hideOverlay();
|
||||
void showSolidOverlayModal(QWidget *content, QFlags<Qt::AlignmentFlag> flags = Qt::AlignCenter);
|
||||
|
|
|
@ -61,6 +61,7 @@ RegisterPage::RegisterPage(QWidget *parent)
|
|||
logo_->setPixmap(logo.pixmap(128));
|
||||
|
||||
logo_layout_ = new QHBoxLayout();
|
||||
logo_layout_->setContentsMargins(0, 0, 0, 0);
|
||||
logo_layout_->addWidget(logo_, 0, Qt::AlignHCenter);
|
||||
|
||||
form_wrapper_ = new QHBoxLayout();
|
||||
|
@ -127,6 +128,7 @@ RegisterPage::RegisterPage(QWidget *parent)
|
|||
|
||||
button_layout_ = new QHBoxLayout();
|
||||
button_layout_->setSpacing(0);
|
||||
button_layout_->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
error_label_ = new QLabel(this);
|
||||
error_label_->setWordWrap(true);
|
||||
|
|
|
@ -771,6 +771,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
|
|||
|
||||
topBarLayout_ = new QHBoxLayout;
|
||||
topBarLayout_->setSpacing(0);
|
||||
topBarLayout_->setContentsMargins(0, 0, 0, 0);
|
||||
topBarLayout_->addWidget(backBtn_, 1, Qt::AlignLeft | Qt::AlignVCenter);
|
||||
topBarLayout_->addStretch(1);
|
||||
|
||||
|
|
|
@ -155,10 +155,9 @@ messageDescription(const QString &username = "",
|
|||
return QCoreApplication::translate("message-description sent:", "You: %1").arg(body);
|
||||
else
|
||||
return QCoreApplication::translate("message-description sent:", "%1: %2")
|
||||
.arg(username)
|
||||
.arg(body);
|
||||
.arg(username, body);
|
||||
} else if (std::is_same<T, Emote>::value) {
|
||||
return QString("* %1 %2").arg(username).arg(body);
|
||||
return QString("* %1 %2").arg(username, body);
|
||||
} else if (std::is_same<T, Encrypted>::value) {
|
||||
if (isLocal)
|
||||
return QCoreApplication::translate("message-description sent:",
|
||||
|
|
|
@ -85,7 +85,7 @@ CreateRoom::CreateRoom(QWidget *parent)
|
|||
|
||||
auto directLabel_ = new QLabel(tr("Direct Chat"), this);
|
||||
directToggle_ = new Toggle(this);
|
||||
directToggle_->setActiveColor(QColor("#38A3D8"));
|
||||
directToggle_->setActiveColor(QColor(0x38, 0xA3, 0xD8));
|
||||
directToggle_->setInactiveColor(QColor("gray"));
|
||||
directToggle_->setState(false);
|
||||
|
||||
|
@ -120,6 +120,7 @@ CreateRoom::CreateRoom(QWidget *parent)
|
|||
|
||||
connect(visibilityCombo_,
|
||||
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
||||
this,
|
||||
[this](const QString &text) {
|
||||
if (text == "Private") {
|
||||
request_.visibility = mtx::common::RoomVisibility::Private;
|
||||
|
@ -130,6 +131,7 @@ CreateRoom::CreateRoom(QWidget *parent)
|
|||
|
||||
connect(presetCombo_,
|
||||
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
||||
this,
|
||||
[this](const QString &text) {
|
||||
if (text == "Private Chat") {
|
||||
request_.preset = mtx::requests::Preset::PrivateChat;
|
||||
|
|
|
@ -32,6 +32,7 @@ FallbackAuth::FallbackAuth(const QString &authType, const QString &session, QWid
|
|||
|
||||
auto buttonLayout = new QHBoxLayout();
|
||||
buttonLayout->setSpacing(8);
|
||||
buttonLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
openBtn_ = new QPushButton(tr("Open Fallback in Browser"), this);
|
||||
cancelBtn_ = new QPushButton(tr("Cancel"), this);
|
||||
|
@ -58,8 +59,7 @@ FallbackAuth::FallbackAuth(const QString &authType, const QString &session, QWid
|
|||
"fallback/web?session=%3")
|
||||
.arg(QString::fromStdString(http::client()->server()))
|
||||
.arg(http::client()->port())
|
||||
.arg(session)
|
||||
.arg(authType);
|
||||
.arg(session, authType);
|
||||
|
||||
QDesktopServices::openUrl(url);
|
||||
});
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2017 Konstantinos Sideris <siderisk@auth.gr>
|
||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "Config.h"
|
||||
#include "dialogs/Logout.h"
|
||||
|
||||
using namespace dialogs;
|
||||
|
||||
Logout::Logout(QWidget *parent)
|
||||
: QFrame(parent)
|
||||
{
|
||||
setAutoFillBackground(true);
|
||||
setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint);
|
||||
setWindowModality(Qt::WindowModal);
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
|
||||
setMinimumWidth(conf::modals::MIN_WIDGET_WIDTH);
|
||||
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
||||
|
||||
auto layout = new QVBoxLayout(this);
|
||||
layout->setSpacing(conf::modals::WIDGET_SPACING);
|
||||
layout->setContentsMargins(conf::modals::WIDGET_MARGIN,
|
||||
conf::modals::WIDGET_MARGIN,
|
||||
conf::modals::WIDGET_MARGIN,
|
||||
conf::modals::WIDGET_MARGIN);
|
||||
|
||||
auto buttonLayout = new QHBoxLayout();
|
||||
buttonLayout->setSpacing(0);
|
||||
|
||||
confirmBtn_ = new QPushButton("Logout", this);
|
||||
cancelBtn_ = new QPushButton(tr("Cancel"), this);
|
||||
cancelBtn_->setDefault(true);
|
||||
|
||||
buttonLayout->addStretch(1);
|
||||
buttonLayout->setSpacing(15);
|
||||
buttonLayout->addWidget(cancelBtn_);
|
||||
buttonLayout->addWidget(confirmBtn_);
|
||||
|
||||
auto label = new QLabel(tr("Logout. Are you sure?"), this);
|
||||
|
||||
layout->addWidget(label);
|
||||
layout->addLayout(buttonLayout);
|
||||
layout->addStretch(1);
|
||||
|
||||
connect(confirmBtn_, &QPushButton::clicked, this, [this]() {
|
||||
emit loggingOut();
|
||||
emit close();
|
||||
});
|
||||
connect(cancelBtn_, &QPushButton::clicked, this, &Logout::close);
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2017 Konstantinos Sideris <siderisk@auth.gr>
|
||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
class QPushButton;
|
||||
|
||||
namespace dialogs {
|
||||
|
||||
class Logout : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Logout(QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void loggingOut();
|
||||
|
||||
private:
|
||||
QPushButton *confirmBtn_;
|
||||
QPushButton *cancelBtn_;
|
||||
};
|
||||
} // dialogs
|
|
@ -30,6 +30,7 @@ PreviewUploadOverlay::PreviewUploadOverlay(QWidget *parent)
|
|||
, cancel_{tr("Cancel"), this}
|
||||
{
|
||||
auto hlayout = new QHBoxLayout;
|
||||
hlayout->setContentsMargins(0, 0, 0, 0);
|
||||
hlayout->addStretch(1);
|
||||
hlayout->addWidget(&cancel_);
|
||||
hlayout->addWidget(&upload_);
|
||||
|
@ -46,7 +47,7 @@ PreviewUploadOverlay::PreviewUploadOverlay(QWidget *parent)
|
|||
conf::modals::WIDGET_MARGIN);
|
||||
|
||||
upload_.setDefault(true);
|
||||
connect(&upload_, &QPushButton::clicked, [this]() {
|
||||
connect(&upload_, &QPushButton::clicked, this, [this]() {
|
||||
emit confirmUpload(data_, mediaType_, fileName_.text());
|
||||
close();
|
||||
});
|
||||
|
@ -124,8 +125,7 @@ PreviewUploadOverlay::setLabels(const QString &type, const QString &mime, uint64
|
|||
} else {
|
||||
auto const info = QString{tr("Media type: %1\n"
|
||||
"Media size: %2\n")}
|
||||
.arg(mime)
|
||||
.arg(utils::humanReadableFileSize(upload_size));
|
||||
.arg(mime, utils::humanReadableFileSize(upload_size));
|
||||
|
||||
titleLabel_.setText(QString{tr(DEFAULT)}.arg("file"));
|
||||
infoLabel_.setText(info);
|
||||
|
|
|
@ -31,6 +31,7 @@ ReCaptcha::ReCaptcha(const QString &session, QWidget *parent)
|
|||
conf::modals::WIDGET_MARGIN);
|
||||
|
||||
auto buttonLayout = new QHBoxLayout();
|
||||
buttonLayout->setContentsMargins(0, 0, 0, 0);
|
||||
buttonLayout->setSpacing(8);
|
||||
|
||||
openCaptchaBtn_ = new QPushButton("Open reCAPTCHA", this);
|
||||
|
|
|
@ -273,7 +273,7 @@ handle_olm_message(const OlmMessage &msg, const UserKeyCache &otherUserDeviceKey
|
|||
}
|
||||
|
||||
bool from_their_device = false;
|
||||
for (auto [device_id, key] : otherUserDeviceKeys.device_keys) {
|
||||
for (const auto &[device_id, key] : otherUserDeviceKeys.device_keys) {
|
||||
auto c_key = key.keys.find("curve25519:" + device_id);
|
||||
auto e_key = key.keys.find("ed25519:" + device_id);
|
||||
|
||||
|
@ -406,7 +406,7 @@ handle_olm_message(const OlmMessage &msg, const UserKeyCache &otherUserDeviceKey
|
|||
if (failed_decryption) {
|
||||
try {
|
||||
std::map<std::string, std::vector<std::string>> targets;
|
||||
for (auto [device_id, key] : otherUserDeviceKeys.device_keys) {
|
||||
for (const auto &[device_id, key] : otherUserDeviceKeys.device_keys) {
|
||||
if (key.keys.at("curve25519:" + device_id) == msg.sender_key)
|
||||
targets[msg.sender].push_back(device_id);
|
||||
}
|
||||
|
@ -1522,7 +1522,7 @@ request_cross_signing_keys()
|
|||
}
|
||||
|
||||
// timeout after 15 min
|
||||
QTimer::singleShot(15 * 60 * 1000, [secretRequest, body]() {
|
||||
QTimer::singleShot(15 * 60 * 1000, ChatPage::instance(), [secretRequest, body]() {
|
||||
if (request_id_to_secret_name.count(secretRequest.request_id)) {
|
||||
request_id_to_secret_name.erase(secretRequest.request_id);
|
||||
http::client()->send_to_device<mtx::events::msg::SecretRequest>(
|
||||
|
|
|
@ -280,7 +280,7 @@ SelfVerificationStatus::invalidate()
|
|||
|
||||
cache::client()->markUserKeysOutOfDate({http::client()->user_id().to_string()});
|
||||
|
||||
QTimer::singleShot(1'000, [] {
|
||||
QTimer::singleShot(1'000, this, [] {
|
||||
cache::client()->query_keys(http::client()->user_id().to_string(),
|
||||
[](const UserKeyCache &, mtx::http::RequestErr) {});
|
||||
});
|
||||
|
|
|
@ -79,7 +79,7 @@ VerificationManager::verifyUser(QString userid)
|
|||
auto joined_rooms = cache::joinedRooms();
|
||||
auto room_infos = cache::getRoomInfo(joined_rooms);
|
||||
|
||||
for (std::string room_id : joined_rooms) {
|
||||
for (const std::string &room_id : joined_rooms) {
|
||||
if ((room_infos[QString::fromStdString(room_id)].member_count == 2) &&
|
||||
cache::isRoomEncrypted(room_id)) {
|
||||
auto room_members = cache::roomMembers(room_id);
|
||||
|
|
|
@ -394,7 +394,7 @@ CommunitiesModel::setCurrentTagId(QString tagId)
|
|||
{
|
||||
if (tagId.startsWith("tag:")) {
|
||||
auto tag = tagId.mid(4);
|
||||
for (const auto &t : tags_) {
|
||||
for (const auto &t : qAsConst(tags_)) {
|
||||
if (t == tag) {
|
||||
this->currentTagId_ = tagId;
|
||||
emit currentTagIdChanged(currentTagId_);
|
||||
|
|
|
@ -132,7 +132,8 @@ DelegateChooser::DelegateIncubator::statusChanged(QQmlIncubator::Status status)
|
|||
emit chooser.childChanged();
|
||||
|
||||
} else if (status == QQmlIncubator::Error) {
|
||||
for (const auto &e : errors())
|
||||
auto errors_ = errors();
|
||||
for (const auto &e : qAsConst(errors_))
|
||||
nhlog::ui()->error("Error instantiating delegate: {}", e.toString().toStdString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,7 +185,7 @@ EventStore::EventStore(std::string room_id, QObject *)
|
|||
|
||||
// FIXME (introduced by balsoft): this doesn't work for encrypted events, but
|
||||
// allegedly it's hard to fix so I'll leave my first contribution at that
|
||||
for (auto related_event_id : cache::client()->relatedEvents(room_id_, txn_id)) {
|
||||
for (const auto &related_event_id : cache::client()->relatedEvents(room_id_, txn_id)) {
|
||||
if (cache::client()->getEvent(room_id_, related_event_id)) {
|
||||
auto related_event =
|
||||
cache::client()->getEvent(room_id_, related_event_id).value();
|
||||
|
@ -717,7 +717,8 @@ void
|
|||
EventStore::enableKeyRequests(bool suppressKeyRequests_)
|
||||
{
|
||||
if (!suppressKeyRequests_) {
|
||||
for (const auto &key : decryptedEvents_.keys())
|
||||
auto keys = decryptedEvents_.keys();
|
||||
for (const auto &key : qAsConst(keys))
|
||||
if (key.room == this->room_id_)
|
||||
decryptedEvents_.remove(key);
|
||||
suppressKeyRequests = false;
|
||||
|
|
|
@ -324,7 +324,8 @@ InputBar::message(const QString &msg, MarkdownOverride useMarkdown, bool rainbow
|
|||
|
||||
QString body;
|
||||
bool firstLine = true;
|
||||
for (auto line : related.quoted_body.splitRef(u'\n')) {
|
||||
auto lines = related.quoted_body.splitRef(u'\n');
|
||||
for (auto line : qAsConst(lines)) {
|
||||
if (firstLine) {
|
||||
firstLine = false;
|
||||
body = QString("> <%1> %2\n").arg(related.quoted_user, line);
|
||||
|
|
|
@ -317,7 +317,7 @@ RoomlistModel::addRoom(const QString &room_id, bool suppressInsertNotification)
|
|||
|
||||
int total_unread_msgs = 0;
|
||||
|
||||
for (const auto &room : models) {
|
||||
for (const auto &room : qAsConst(models)) {
|
||||
if (!room.isNull())
|
||||
total_unread_msgs += room->notificationCount();
|
||||
}
|
||||
|
@ -586,8 +586,8 @@ RoomlistModel::initializeRooms()
|
|||
}
|
||||
|
||||
invites = cache::client()->invites();
|
||||
for (const auto &id : invites.keys()) {
|
||||
roomids.push_back(id);
|
||||
for (auto id = invites.keyBegin(); id != invites.keyEnd(); ++id) {
|
||||
roomids.push_back(*id);
|
||||
}
|
||||
|
||||
for (const auto &id : cache::client()->roomIds())
|
||||
|
@ -826,10 +826,12 @@ FilteredRoomlistModel::updateHiddenTagsAndSpaces()
|
|||
hiddenTags.clear();
|
||||
hiddenSpaces.clear();
|
||||
hideDMs = false;
|
||||
for (const auto &t : UserSettings::instance()->hiddenTags()) {
|
||||
if (t.startsWith("tag:"))
|
||||
|
||||
auto hidden = UserSettings::instance()->hiddenTags();
|
||||
for (const auto &t : qAsConst(hidden)) {
|
||||
if (t.startsWith(u"tag:"))
|
||||
hiddenTags.push_back(t.mid(4));
|
||||
else if (t.startsWith("space:"))
|
||||
else if (t.startsWith(u"space:"))
|
||||
hiddenSpaces.push_back(t.mid(6));
|
||||
else if (t == "dm")
|
||||
hideDMs = true;
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
Q_DECLARE_METATYPE(QModelIndex)
|
||||
|
||||
namespace std {
|
||||
inline uint
|
||||
inline uint // clazy:exclude=qhash-namespace
|
||||
qHash(const std::string &key, uint seed = 0)
|
||||
{
|
||||
return qHash(QByteArray::fromRawData(key.data(), (int)key.length()), seed);
|
||||
|
@ -1540,9 +1540,8 @@ TimelineModel::cacheMedia(const QString &eventId,
|
|||
if (!event)
|
||||
return;
|
||||
|
||||
QString mxcUrl = QString::fromStdString(mtx::accessors::url(*event));
|
||||
QString originalFilename = QString::fromStdString(mtx::accessors::filename(*event));
|
||||
QString mimeType = QString::fromStdString(mtx::accessors::mimetype(*event));
|
||||
QString mxcUrl = QString::fromStdString(mtx::accessors::url(*event));
|
||||
QString mimeType = QString::fromStdString(mtx::accessors::mimetype(*event));
|
||||
|
||||
auto encryptionInfo = mtx::accessors::file(*event);
|
||||
|
||||
|
@ -1556,10 +1555,9 @@ TimelineModel::cacheMedia(const QString &eventId,
|
|||
|
||||
const auto url = mxcUrl.toStdString();
|
||||
const auto name = QString(mxcUrl).remove("mxc://");
|
||||
QFileInfo filename(QString("%1/media_cache/%2.%3")
|
||||
.arg(QStandardPaths::writableLocation(QStandardPaths::CacheLocation))
|
||||
.arg(name)
|
||||
.arg(suffix));
|
||||
QFileInfo filename(
|
||||
QString("%1/media_cache/%2.%3")
|
||||
.arg(QStandardPaths::writableLocation(QStandardPaths::CacheLocation), name, suffix));
|
||||
if (QDir::cleanPath(name) != name) {
|
||||
nhlog::net()->warn("mxcUrl '{}' is not safe, not downloading file", url);
|
||||
return;
|
||||
|
@ -1780,7 +1778,7 @@ TimelineModel::formatTypingUsers(const std::vector<QString> &users, const QColor
|
|||
uidWithoutLast.append(formatUser(users[i]));
|
||||
}
|
||||
|
||||
return temp.arg(uidWithoutLast.join(", ")).arg(formatUser(users.back()));
|
||||
return temp.arg(uidWithoutLast.join(", "), formatUser(users.back()));
|
||||
}
|
||||
|
||||
QString
|
||||
|
@ -1812,8 +1810,7 @@ TimelineModel::formatJoinRuleEvent(const QString &id)
|
|||
}
|
||||
return tr("%1 allowed members of the following rooms to automatically join this "
|
||||
"room: %2")
|
||||
.arg(name)
|
||||
.arg(rooms.join(", "));
|
||||
.arg(name, rooms.join(", "));
|
||||
}
|
||||
default:
|
||||
// Currently, knock and private are reserved keywords and not implemented in Matrix.
|
||||
|
@ -2035,8 +2032,8 @@ TimelineModel::formatMemberEvent(const QString &id)
|
|||
else
|
||||
rendered =
|
||||
tr("%1 joined via authorisation from %2's server.")
|
||||
.arg(name)
|
||||
.arg(QString::fromStdString(event->content.join_authorised_via_users_server));
|
||||
.arg(name,
|
||||
QString::fromStdString(event->content.join_authorised_via_users_server));
|
||||
}
|
||||
break;
|
||||
case Membership::Leave:
|
||||
|
|
222
src/ui/Badge.cpp
222
src/ui/Badge.cpp
|
@ -1,222 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
#include "Badge.h"
|
||||
|
||||
Badge::Badge(QWidget *parent)
|
||||
: OverlayWidget(parent)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
Badge::Badge(const QIcon &icon, QWidget *parent)
|
||||
: OverlayWidget(parent)
|
||||
{
|
||||
init();
|
||||
setIcon(icon);
|
||||
}
|
||||
|
||||
Badge::Badge(const QString &text, QWidget *parent)
|
||||
: OverlayWidget(parent)
|
||||
{
|
||||
init();
|
||||
setText(text);
|
||||
}
|
||||
|
||||
void
|
||||
Badge::init()
|
||||
{
|
||||
x_ = 0;
|
||||
y_ = 0;
|
||||
// TODO: Make padding configurable.
|
||||
padding_ = 5;
|
||||
diameter_ = 24;
|
||||
|
||||
setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
|
||||
QFont _font(font());
|
||||
_font.setPointSizeF(7.5);
|
||||
_font.setStyleName("Bold");
|
||||
|
||||
setFont(_font);
|
||||
setText("");
|
||||
}
|
||||
|
||||
QString
|
||||
Badge::text() const
|
||||
{
|
||||
return text_;
|
||||
}
|
||||
|
||||
QIcon
|
||||
Badge::icon() const
|
||||
{
|
||||
return icon_;
|
||||
}
|
||||
|
||||
QSize
|
||||
Badge::sizeHint() const
|
||||
{
|
||||
const int d = diameter();
|
||||
return QSize(d + 4, d + 4);
|
||||
}
|
||||
|
||||
qreal
|
||||
Badge::relativeYPosition() const
|
||||
{
|
||||
return y_;
|
||||
}
|
||||
|
||||
qreal
|
||||
Badge::relativeXPosition() const
|
||||
{
|
||||
return x_;
|
||||
}
|
||||
|
||||
QPointF
|
||||
Badge::relativePosition() const
|
||||
{
|
||||
return QPointF(x_, y_);
|
||||
}
|
||||
|
||||
QColor
|
||||
Badge::backgroundColor() const
|
||||
{
|
||||
if (!background_color_.isValid())
|
||||
return QColor("black");
|
||||
|
||||
return background_color_;
|
||||
}
|
||||
|
||||
QColor
|
||||
Badge::textColor() const
|
||||
{
|
||||
if (!text_color_.isValid())
|
||||
return QColor("white");
|
||||
|
||||
return text_color_;
|
||||
}
|
||||
|
||||
void
|
||||
Badge::setTextColor(const QColor &color)
|
||||
{
|
||||
text_color_ = color;
|
||||
}
|
||||
|
||||
void
|
||||
Badge::setBackgroundColor(const QColor &color)
|
||||
{
|
||||
background_color_ = color;
|
||||
}
|
||||
|
||||
void
|
||||
Badge::setRelativePosition(const QPointF &pos)
|
||||
{
|
||||
setRelativePosition(pos.x(), pos.y());
|
||||
}
|
||||
|
||||
void
|
||||
Badge::setRelativePosition(qreal x, qreal y)
|
||||
{
|
||||
x_ = x;
|
||||
y_ = y;
|
||||
update();
|
||||
}
|
||||
|
||||
void
|
||||
Badge::setRelativeXPosition(qreal x)
|
||||
{
|
||||
x_ = x;
|
||||
update();
|
||||
}
|
||||
|
||||
void
|
||||
Badge::setRelativeYPosition(qreal y)
|
||||
{
|
||||
y_ = y;
|
||||
update();
|
||||
}
|
||||
|
||||
void
|
||||
Badge::setIcon(const QIcon &icon)
|
||||
{
|
||||
icon_ = icon;
|
||||
update();
|
||||
}
|
||||
|
||||
void
|
||||
Badge::setText(const QString &text)
|
||||
{
|
||||
text_ = text;
|
||||
|
||||
if (!icon_.isNull())
|
||||
icon_ = QIcon();
|
||||
|
||||
size_ = fontMetrics().size(Qt::TextShowMnemonic, text);
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void
|
||||
Badge::setDiameter(int diameter)
|
||||
{
|
||||
if (diameter > 0) {
|
||||
diameter_ = diameter;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Badge::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.translate(x_, y_);
|
||||
|
||||
QBrush brush;
|
||||
brush.setStyle(Qt::SolidPattern);
|
||||
|
||||
painter.setBrush(brush);
|
||||
painter.setPen(Qt::NoPen);
|
||||
|
||||
const int d = diameter();
|
||||
|
||||
QRectF r(0, 0, d, d);
|
||||
r.translate(QPointF((width() - d), (height() - d)) / 2);
|
||||
|
||||
if (icon_.isNull()) {
|
||||
QPen pen;
|
||||
// TODO: Make badge width configurable.
|
||||
pen.setWidth(1);
|
||||
pen.setColor(textColor());
|
||||
|
||||
painter.setPen(pen);
|
||||
painter.drawEllipse(r);
|
||||
|
||||
painter.setPen(textColor());
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
painter.drawText(r.translated(0, -0.5), Qt::AlignCenter, text_);
|
||||
} else {
|
||||
painter.drawEllipse(r);
|
||||
QRectF q(0, 0, 16, 16);
|
||||
q.moveCenter(r.center());
|
||||
QPixmap pixmap = icon().pixmap(16, 16);
|
||||
QPainter icon(&pixmap);
|
||||
icon.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
||||
icon.fillRect(pixmap.rect(), textColor());
|
||||
painter.drawPixmap(q.toRect(), pixmap);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Badge::diameter() const
|
||||
{
|
||||
if (icon_.isNull()) {
|
||||
return qMax(size_.width(), size_.height()) + padding_;
|
||||
}
|
||||
|
||||
return diameter_;
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QColor>
|
||||
#include <QIcon>
|
||||
#include <QWidget>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "OverlayWidget.h"
|
||||
|
||||
class Badge : public OverlayWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QColor textColor WRITE setTextColor READ textColor)
|
||||
Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor)
|
||||
Q_PROPERTY(QPointF relativePosition WRITE setRelativePosition READ relativePosition)
|
||||
|
||||
public:
|
||||
explicit Badge(QWidget *parent = nullptr);
|
||||
explicit Badge(const QIcon &icon, QWidget *parent = nullptr);
|
||||
explicit Badge(const QString &text, QWidget *parent = nullptr);
|
||||
|
||||
void setBackgroundColor(const QColor &color);
|
||||
void setTextColor(const QColor &color);
|
||||
void setIcon(const QIcon &icon);
|
||||
void setRelativePosition(const QPointF &pos);
|
||||
void setRelativePosition(qreal x, qreal y);
|
||||
void setRelativeXPosition(qreal x);
|
||||
void setRelativeYPosition(qreal y);
|
||||
void setText(const QString &text);
|
||||
void setDiameter(int diameter);
|
||||
|
||||
QIcon icon() const;
|
||||
QString text() const;
|
||||
QColor backgroundColor() const;
|
||||
QColor textColor() const;
|
||||
QPointF relativePosition() const;
|
||||
QSize sizeHint() const override;
|
||||
qreal relativeXPosition() const;
|
||||
qreal relativeYPosition() const;
|
||||
|
||||
int diameter() const;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
QColor background_color_;
|
||||
QColor text_color_;
|
||||
|
||||
QIcon icon_;
|
||||
QSize size_;
|
||||
QString text_;
|
||||
|
||||
int padding_;
|
||||
int diameter_;
|
||||
|
||||
qreal x_;
|
||||
qreal y_;
|
||||
};
|
|
@ -100,7 +100,7 @@ DropShadow::draw(QPainter &painter,
|
|||
painter.drawRoundedRect(QRectF(topright0, topright1), 0.0, 0.0);
|
||||
|
||||
// Widget
|
||||
painter.setBrush(QBrush("#FFFFFF"));
|
||||
painter.setBrush(QBrush(QColor(0xff, 0xff, 0xff)));
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.drawRoundedRect(
|
||||
QRectF(QPointF(margin, margin), QPointF(width - margin, height - margin)), radius, radius);
|
||||
|
|
|
@ -119,6 +119,7 @@ void
|
|||
FlatButton::setForegroundColor(const QColor &color)
|
||||
{
|
||||
foreground_color_ = color;
|
||||
emit foregroundColorChanged();
|
||||
}
|
||||
|
||||
QColor
|
||||
|
@ -147,6 +148,7 @@ void
|
|||
FlatButton::setBackgroundColor(const QColor &color)
|
||||
{
|
||||
background_color_ = color;
|
||||
emit backgroundColorChanged();
|
||||
}
|
||||
|
||||
QColor
|
||||
|
@ -172,6 +174,7 @@ FlatButton::setOverlayColor(const QColor &color)
|
|||
{
|
||||
overlay_color_ = color;
|
||||
setOverlayStyle(ui::OverlayStyle::TintedOverlay);
|
||||
emit overlayColorChanged();
|
||||
}
|
||||
|
||||
QColor
|
||||
|
@ -188,6 +191,7 @@ void
|
|||
FlatButton::setDisabledForegroundColor(const QColor &color)
|
||||
{
|
||||
disabled_color_ = color;
|
||||
emit disabledForegroundColorChanged();
|
||||
}
|
||||
|
||||
QColor
|
||||
|
@ -204,6 +208,7 @@ void
|
|||
FlatButton::setDisabledBackgroundColor(const QColor &color)
|
||||
{
|
||||
disabled_background_color_ = color;
|
||||
emit disabledBackgroundColorChanged();
|
||||
}
|
||||
|
||||
QColor
|
||||
|
@ -225,6 +230,8 @@ FlatButton::setFontSize(qreal size)
|
|||
f.setPointSizeF(size);
|
||||
setFont(f);
|
||||
|
||||
emit fontSizeChanged();
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -617,6 +624,7 @@ void
|
|||
FlatButtonStateMachine::setOverlayOpacity(qreal opacity)
|
||||
{
|
||||
overlay_opacity_ = opacity;
|
||||
emit overlayOpacityChanged();
|
||||
button_->update();
|
||||
}
|
||||
|
||||
|
@ -624,6 +632,7 @@ void
|
|||
FlatButtonStateMachine::setCheckedOverlayProgress(qreal opacity)
|
||||
{
|
||||
checked_overlay_progress_ = opacity;
|
||||
emit checkedOverlayProgressChanged();
|
||||
button_->update();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,10 @@ class FlatButtonStateMachine : public QStateMachine
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(qreal overlayOpacity WRITE setOverlayOpacity READ overlayOpacity)
|
||||
Q_PROPERTY(
|
||||
qreal checkedOverlayProgress WRITE setCheckedOverlayProgress READ checkedOverlayProgress)
|
||||
qreal overlayOpacity WRITE setOverlayOpacity READ overlayOpacity NOTIFY overlayOpacityChanged)
|
||||
Q_PROPERTY(qreal checkedOverlayProgress WRITE setCheckedOverlayProgress READ
|
||||
checkedOverlayProgress NOTIFY checkedOverlayProgressChanged)
|
||||
|
||||
public:
|
||||
explicit FlatButtonStateMachine(FlatButton *parent);
|
||||
|
@ -38,6 +39,9 @@ signals:
|
|||
void buttonChecked();
|
||||
void buttonUnchecked();
|
||||
|
||||
void overlayOpacityChanged();
|
||||
void checkedOverlayProgressChanged();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
|
@ -81,14 +85,17 @@ class FlatButton : public QPushButton
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QColor foregroundColor WRITE setForegroundColor READ foregroundColor)
|
||||
Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor)
|
||||
Q_PROPERTY(QColor overlayColor WRITE setOverlayColor READ overlayColor)
|
||||
Q_PROPERTY(QColor foregroundColor WRITE setForegroundColor READ foregroundColor NOTIFY
|
||||
foregroundColorChanged)
|
||||
Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor NOTIFY
|
||||
backgroundColorChanged)
|
||||
Q_PROPERTY(
|
||||
QColor disabledForegroundColor WRITE setDisabledForegroundColor READ disabledForegroundColor)
|
||||
Q_PROPERTY(
|
||||
QColor disabledBackgroundColor WRITE setDisabledBackgroundColor READ disabledBackgroundColor)
|
||||
Q_PROPERTY(qreal fontSize WRITE setFontSize READ fontSize)
|
||||
QColor overlayColor WRITE setOverlayColor READ overlayColor NOTIFY overlayColorChanged)
|
||||
Q_PROPERTY(QColor disabledForegroundColor WRITE setDisabledForegroundColor READ
|
||||
disabledForegroundColor NOTIFY disabledForegroundColorChanged)
|
||||
Q_PROPERTY(QColor disabledBackgroundColor WRITE setDisabledBackgroundColor READ
|
||||
disabledBackgroundColor NOTIFY disabledBackgroundColorChanged)
|
||||
Q_PROPERTY(qreal fontSize WRITE setFontSize READ fontSize NOTIFY fontSizeChanged)
|
||||
|
||||
public:
|
||||
explicit FlatButton(QWidget *parent = nullptr,
|
||||
|
@ -156,6 +163,14 @@ protected:
|
|||
|
||||
void init();
|
||||
|
||||
signals:
|
||||
void foregroundColorChanged();
|
||||
void backgroundColorChanged();
|
||||
void overlayColorChanged();
|
||||
void disabledForegroundColorChanged();
|
||||
void disabledBackgroundColorChanged();
|
||||
void fontSizeChanged();
|
||||
|
||||
private:
|
||||
RippleOverlay *ripple_overlay_;
|
||||
FlatButtonStateMachine *state_machine_;
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "InfoMessage.h"
|
||||
#include "Config.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QLocale>
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
#include <QPen>
|
||||
#include <QtGlobal>
|
||||
|
||||
constexpr int VPadding = 6;
|
||||
constexpr int HPadding = 12;
|
||||
constexpr int HMargin = 20;
|
||||
|
||||
InfoMessage::InfoMessage(QWidget *parent)
|
||||
: QWidget{parent}
|
||||
{
|
||||
initFont();
|
||||
}
|
||||
|
||||
InfoMessage::InfoMessage(QString msg, QWidget *parent)
|
||||
: QWidget{parent}
|
||||
, msg_{msg}
|
||||
{
|
||||
initFont();
|
||||
|
||||
QFontMetrics fm{font()};
|
||||
width_ = fm.horizontalAdvance(msg_) + HPadding * 2;
|
||||
height_ = fm.ascent() + 2 * VPadding;
|
||||
|
||||
setFixedHeight(height_ + 2 * HMargin);
|
||||
}
|
||||
|
||||
void
|
||||
InfoMessage::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter p(this);
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
p.setFont(font());
|
||||
|
||||
// Center the box horizontally & vertically.
|
||||
auto textRegion = QRectF(width() / 2 - width_ / 2, HMargin, width_, height_);
|
||||
|
||||
QPainterPath ppath;
|
||||
ppath.addRoundedRect(textRegion, height_ / 2, height_ / 2);
|
||||
|
||||
p.setPen(Qt::NoPen);
|
||||
p.fillPath(ppath, boxColor());
|
||||
p.drawPath(ppath);
|
||||
|
||||
p.setPen(QPen(textColor()));
|
||||
p.drawText(textRegion, Qt::AlignCenter, msg_);
|
||||
}
|
||||
|
||||
DateSeparator::DateSeparator(QDateTime datetime, QWidget *parent)
|
||||
: InfoMessage{parent}
|
||||
{
|
||||
auto now = QDateTime::currentDateTime();
|
||||
|
||||
QString fmt = QLocale::system().dateFormat(QLocale::LongFormat);
|
||||
|
||||
if (now.date().year() == datetime.date().year()) {
|
||||
QRegularExpression rx("[^a-zA-Z]*y+[^a-zA-Z]*");
|
||||
fmt = fmt.remove(rx);
|
||||
}
|
||||
|
||||
msg_ = datetime.date().toString(fmt);
|
||||
|
||||
QFontMetrics fm{font()};
|
||||
width_ = fm.horizontalAdvance(msg_) + HPadding * 2;
|
||||
height_ = fm.ascent() + 2 * VPadding;
|
||||
|
||||
setFixedHeight(height_ + 2 * HMargin);
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QColor>
|
||||
#include <QDateTime>
|
||||
#include <QWidget>
|
||||
|
||||
class InfoMessage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QColor textColor WRITE setTextColor READ textColor)
|
||||
Q_PROPERTY(QColor boxColor WRITE setBoxColor READ boxColor)
|
||||
|
||||
public:
|
||||
explicit InfoMessage(QWidget *parent = nullptr);
|
||||
InfoMessage(QString msg, QWidget *parent = nullptr);
|
||||
|
||||
void setTextColor(QColor color) { textColor_ = color; }
|
||||
void setBoxColor(QColor color) { boxColor_ = color; }
|
||||
void saveDatetime(QDateTime datetime) { datetime_ = datetime; }
|
||||
|
||||
QColor textColor() const { return textColor_; }
|
||||
QColor boxColor() const { return boxColor_; }
|
||||
QDateTime datetime() const { return datetime_; }
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void initFont()
|
||||
{
|
||||
QFont f;
|
||||
f.setWeight(QFont::Medium);
|
||||
setFont(f);
|
||||
}
|
||||
|
||||
int width_;
|
||||
int height_;
|
||||
|
||||
QString msg_;
|
||||
|
||||
QDateTime datetime_;
|
||||
|
||||
QColor textColor_ = QColor("black");
|
||||
QColor boxColor_ = QColor("white");
|
||||
};
|
||||
|
||||
class DateSeparator : public InfoMessage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DateSeparator(QDateTime datetime, QWidget *parent = nullptr);
|
||||
};
|
|
@ -13,7 +13,7 @@ class QPaintEvent;
|
|||
class LoadingIndicator : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QColor color READ color WRITE setColor)
|
||||
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
|
||||
|
||||
public:
|
||||
LoadingIndicator(QWidget *parent = nullptr);
|
||||
|
@ -24,7 +24,11 @@ public:
|
|||
void stop();
|
||||
|
||||
QColor color() { return color_; }
|
||||
void setColor(QColor color) { color_ = color; }
|
||||
void setColor(QColor color)
|
||||
{
|
||||
color_ = color;
|
||||
emit colorChanged();
|
||||
}
|
||||
|
||||
int interval() { return interval_; }
|
||||
void setInterval(int interval) { interval_ = interval; }
|
||||
|
@ -32,6 +36,9 @@ public:
|
|||
private slots:
|
||||
void onTimeout();
|
||||
|
||||
signals:
|
||||
void colorChanged();
|
||||
|
||||
private:
|
||||
int interval_;
|
||||
int angle_;
|
||||
|
|
|
@ -39,8 +39,7 @@ MxcAnimatedImage::startDownload()
|
|||
if (!animatable_)
|
||||
return;
|
||||
|
||||
QString mxcUrl = QString::fromStdString(mtx::accessors::url(*event));
|
||||
QString originalFilename = QString::fromStdString(mtx::accessors::filename(*event));
|
||||
QString mxcUrl = QString::fromStdString(mtx::accessors::url(*event));
|
||||
|
||||
auto encryptionInfo = mtx::accessors::file(*event);
|
||||
|
||||
|
@ -53,10 +52,9 @@ MxcAnimatedImage::startDownload()
|
|||
|
||||
const auto url = mxcUrl.toStdString();
|
||||
const auto name = QString(mxcUrl).remove("mxc://");
|
||||
QFileInfo filename(QString("%1/media_cache/media/%2.%3")
|
||||
.arg(QStandardPaths::writableLocation(QStandardPaths::CacheLocation))
|
||||
.arg(name)
|
||||
.arg(suffix));
|
||||
QFileInfo filename(
|
||||
QStringLiteral("%1/media_cache/media/%2.%3")
|
||||
.arg(QStandardPaths::writableLocation(QStandardPaths::CacheLocation), name, suffix));
|
||||
if (QDir::cleanPath(name) != name) {
|
||||
nhlog::net()->warn("mxcUrl '{}' is not safe, not downloading file", url);
|
||||
return;
|
||||
|
|
|
@ -49,9 +49,12 @@ MxcMediaProxy::MxcMediaProxy(QObject *parent)
|
|||
void
|
||||
MxcMediaProxy::setVideoSurface(QAbstractVideoSurface *surface)
|
||||
{
|
||||
qDebug() << "Changing surface";
|
||||
m_surface = surface;
|
||||
setVideoOutput(m_surface);
|
||||
if (surface != m_surface) {
|
||||
qDebug() << "Changing surface";
|
||||
m_surface = surface;
|
||||
setVideoOutput(m_surface);
|
||||
emit videoSurfaceChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QAbstractVideoSurface *
|
||||
|
@ -84,9 +87,8 @@ MxcMediaProxy::startDownload()
|
|||
return;
|
||||
}
|
||||
|
||||
QString mxcUrl = QString::fromStdString(mtx::accessors::url(*event));
|
||||
QString originalFilename = QString::fromStdString(mtx::accessors::filename(*event));
|
||||
QString mimeType = QString::fromStdString(mtx::accessors::mimetype(*event));
|
||||
QString mxcUrl = QString::fromStdString(mtx::accessors::url(*event));
|
||||
QString mimeType = QString::fromStdString(mtx::accessors::mimetype(*event));
|
||||
|
||||
auto encryptionInfo = mtx::accessors::file(*event);
|
||||
|
||||
|
@ -99,10 +101,9 @@ MxcMediaProxy::startDownload()
|
|||
|
||||
const auto url = mxcUrl.toStdString();
|
||||
const auto name = QString(mxcUrl).remove("mxc://");
|
||||
QFileInfo filename(QString("%1/media_cache/media/%2.%3")
|
||||
.arg(QStandardPaths::writableLocation(QStandardPaths::CacheLocation))
|
||||
.arg(name)
|
||||
.arg(suffix));
|
||||
QFileInfo filename(
|
||||
QString("%1/media_cache/media/%2.%3")
|
||||
.arg(QStandardPaths::writableLocation(QStandardPaths::CacheLocation), name, suffix));
|
||||
if (QDir::cleanPath(name) != name) {
|
||||
nhlog::net()->warn("mxcUrl '{}' is not safe, not downloading file", url);
|
||||
return;
|
||||
|
|
|
@ -23,7 +23,8 @@ class MxcMediaProxy : public QMediaPlayer
|
|||
Q_OBJECT
|
||||
Q_PROPERTY(TimelineModel *roomm READ room WRITE setRoom NOTIFY roomChanged REQUIRED)
|
||||
Q_PROPERTY(QString eventId READ eventId WRITE setEventId NOTIFY eventIdChanged)
|
||||
Q_PROPERTY(QAbstractVideoSurface *videoSurface READ getVideoSurface WRITE setVideoSurface)
|
||||
Q_PROPERTY(QAbstractVideoSurface *videoSurface READ getVideoSurface WRITE setVideoSurface NOTIFY
|
||||
videoSurfaceChanged)
|
||||
Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
|
||||
Q_PROPERTY(int orientation READ orientation NOTIFY orientationChanged)
|
||||
|
||||
|
@ -55,6 +56,7 @@ signals:
|
|||
void newBuffer(QMediaContent, QIODevice *buf);
|
||||
|
||||
void orientationChanged();
|
||||
void videoSurfaceChanged();
|
||||
|
||||
private slots:
|
||||
void startDownload();
|
||||
|
|
|
@ -39,6 +39,8 @@ Ripple::setRadius(qreal radius)
|
|||
|
||||
radius_ = radius;
|
||||
overlay_->update();
|
||||
|
||||
emit radiusChanged();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -51,6 +53,8 @@ Ripple::setOpacity(qreal opacity)
|
|||
|
||||
opacity_ = opacity;
|
||||
overlay_->update();
|
||||
|
||||
emit opacityChanged();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -16,8 +16,8 @@ class Ripple : public QParallelAnimationGroup
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(qreal radius WRITE setRadius READ radius)
|
||||
Q_PROPERTY(qreal opacity WRITE setOpacity READ opacity)
|
||||
Q_PROPERTY(qreal radius WRITE setRadius READ radius NOTIFY radiusChanged)
|
||||
Q_PROPERTY(qreal opacity WRITE setOpacity READ opacity NOTIFY opacityChanged)
|
||||
|
||||
public:
|
||||
explicit Ripple(const QPoint ¢er, QObject *parent = nullptr);
|
||||
|
@ -48,6 +48,10 @@ public:
|
|||
protected slots:
|
||||
void destroy();
|
||||
|
||||
signals:
|
||||
void radiusChanged();
|
||||
void opacityChanged();
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(Ripple)
|
||||
|
||||
|
|
|
@ -22,8 +22,9 @@ class SnackBar : public OverlayWidget
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QColor bgColor READ backgroundColor WRITE setBackgroundColor)
|
||||
Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
|
||||
Q_PROPERTY(
|
||||
QColor bgColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged)
|
||||
Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor NOTIFY textColorChanged)
|
||||
Q_PROPERTY(double offset READ offset WRITE setOffset NOTIFY offsetChanged)
|
||||
|
||||
public:
|
||||
|
@ -34,6 +35,7 @@ public:
|
|||
{
|
||||
bgColor_ = color;
|
||||
update();
|
||||
emit backgroundColorChanged();
|
||||
}
|
||||
|
||||
QColor textColor() const { return textColor_; }
|
||||
|
@ -41,6 +43,7 @@ public:
|
|||
{
|
||||
textColor_ = color;
|
||||
update();
|
||||
emit textColorChanged();
|
||||
}
|
||||
void setPosition(SnackBarPosition pos)
|
||||
{
|
||||
|
@ -62,6 +65,8 @@ public slots:
|
|||
|
||||
signals:
|
||||
void offsetChanged();
|
||||
void backgroundColorChanged();
|
||||
void textColorChanged();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
|
|
@ -40,6 +40,7 @@ void
|
|||
TextField::setBackgroundColor(const QColor &color)
|
||||
{
|
||||
background_color_ = color;
|
||||
emit backgroundColorChanged();
|
||||
}
|
||||
|
||||
QColor
|
||||
|
@ -130,6 +131,7 @@ void
|
|||
TextField::setLabelColor(const QColor &color)
|
||||
{
|
||||
label_color_ = color;
|
||||
emit labelColorChanged();
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -147,6 +149,7 @@ void
|
|||
TextField::setInkColor(const QColor &color)
|
||||
{
|
||||
ink_color_ = color;
|
||||
emit inkColorChanged();
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -164,6 +167,7 @@ void
|
|||
TextField::setUnderlineColor(const QColor &color)
|
||||
{
|
||||
underline_color_ = color;
|
||||
emit underlineColorChanged();
|
||||
update();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,10 +20,12 @@ class TextField : public QLineEdit
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QColor inkColor WRITE setInkColor READ inkColor)
|
||||
Q_PROPERTY(QColor labelColor WRITE setLabelColor READ labelColor)
|
||||
Q_PROPERTY(QColor underlineColor WRITE setUnderlineColor READ underlineColor)
|
||||
Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor)
|
||||
Q_PROPERTY(QColor inkColor WRITE setInkColor READ inkColor NOTIFY inkColorChanged)
|
||||
Q_PROPERTY(QColor labelColor WRITE setLabelColor READ labelColor NOTIFY labelColorChanged)
|
||||
Q_PROPERTY(QColor underlineColor WRITE setUnderlineColor READ underlineColor NOTIFY
|
||||
underlineColorChanged)
|
||||
Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor NOTIFY
|
||||
backgroundColorChanged)
|
||||
|
||||
public:
|
||||
explicit TextField(QWidget *parent = nullptr);
|
||||
|
@ -51,6 +53,12 @@ protected:
|
|||
bool event(QEvent *event) override;
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
signals:
|
||||
void inkColorChanged();
|
||||
void labelColorChanged();
|
||||
void underlineColorChanged();
|
||||
void backgroundColorChanged();
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
|
@ -71,9 +79,9 @@ class TextFieldLabel : public QWidget
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(qreal scale WRITE setScale READ scale)
|
||||
Q_PROPERTY(QPointF offset WRITE setOffset READ offset)
|
||||
Q_PROPERTY(QColor color WRITE setColor READ color)
|
||||
Q_PROPERTY(qreal scale WRITE setScale READ scale NOTIFY scaleChanged)
|
||||
Q_PROPERTY(QPointF offset WRITE setOffset READ offset NOTIFY offsetChanged)
|
||||
Q_PROPERTY(QColor color WRITE setColor READ color NOTIFY colorChanged)
|
||||
|
||||
public:
|
||||
TextFieldLabel(TextField *parent);
|
||||
|
@ -89,6 +97,11 @@ public:
|
|||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
signals:
|
||||
void scaleChanged();
|
||||
void offsetChanged();
|
||||
void colorChanged();
|
||||
|
||||
private:
|
||||
TextField *const text_field_;
|
||||
|
||||
|
@ -102,6 +115,7 @@ inline void
|
|||
TextFieldLabel::setColor(const QColor &color)
|
||||
{
|
||||
color_ = color;
|
||||
emit colorChanged();
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -110,6 +124,7 @@ TextFieldLabel::setOffset(const QPointF &pos)
|
|||
{
|
||||
x_ = pos.x();
|
||||
y_ = pos.y();
|
||||
emit offsetChanged();
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -117,6 +132,7 @@ inline void
|
|||
TextFieldLabel::setScale(qreal scale)
|
||||
{
|
||||
scale_ = scale;
|
||||
emit scaleChanged();
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -140,7 +156,7 @@ class TextFieldStateMachine : public QStateMachine
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(qreal progress WRITE setProgress READ progress)
|
||||
Q_PROPERTY(qreal progress WRITE setProgress READ progress NOTIFY progressChanged)
|
||||
|
||||
public:
|
||||
TextFieldStateMachine(TextField *parent);
|
||||
|
@ -153,6 +169,9 @@ public:
|
|||
public slots:
|
||||
void setupProperties();
|
||||
|
||||
signals:
|
||||
void progressChanged();
|
||||
|
||||
private:
|
||||
QPropertyAnimation *color_anim_;
|
||||
QPropertyAnimation *offset_anim_;
|
||||
|
@ -170,6 +189,7 @@ inline void
|
|||
TextFieldStateMachine::setProgress(qreal progress)
|
||||
{
|
||||
progress_ = progress;
|
||||
emit progressChanged();
|
||||
text_field_->update();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,41 +13,41 @@ Theme::paletteFromTheme(std::string_view theme)
|
|||
static QPalette original;
|
||||
if (theme == "light") {
|
||||
QPalette lightActive(
|
||||
/*windowText*/ QColor("#333"),
|
||||
/*button*/ QColor("white"),
|
||||
/*windowText*/ QColor(0x33, 0x33, 0x33),
|
||||
/*button*/ QColor(Qt::GlobalColor::white),
|
||||
/*light*/ QColor(0xef, 0xef, 0xef),
|
||||
/*dark*/ QColor(70, 77, 93),
|
||||
/*mid*/ QColor(220, 220, 220),
|
||||
/*text*/ QColor("#333"),
|
||||
/*bright_text*/ QColor("#f2f5f8"),
|
||||
/*base*/ QColor("#fff"),
|
||||
/*window*/ QColor("white"));
|
||||
lightActive.setColor(QPalette::AlternateBase, QColor("#eee"));
|
||||
lightActive.setColor(QPalette::Highlight, QColor("#38a3d8"));
|
||||
lightActive.setColor(QPalette::HighlightedText, QColor("#f4f4f5"));
|
||||
/*text*/ QColor(0x33, 0x33, 0x33),
|
||||
/*bright_text*/ QColor(0xf2, 0xf5, 0xf8),
|
||||
/*base*/ QColor(Qt::GlobalColor::white),
|
||||
/*window*/ QColor(Qt::GlobalColor::white));
|
||||
lightActive.setColor(QPalette::AlternateBase, QColor(0xee, 0xee, 0xee));
|
||||
lightActive.setColor(QPalette::Highlight, QColor(0x38, 0xa3, 0xd8));
|
||||
lightActive.setColor(QPalette::HighlightedText, QColor(0xf4, 0xf4, 0xf5));
|
||||
lightActive.setColor(QPalette::ToolTipBase, lightActive.base().color());
|
||||
lightActive.setColor(QPalette::ToolTipText, lightActive.text().color());
|
||||
lightActive.setColor(QPalette::Link, QColor("#0077b5"));
|
||||
lightActive.setColor(QPalette::ButtonText, QColor("#555459"));
|
||||
lightActive.setColor(QPalette::Link, QColor(0x00, 0x77, 0xb5));
|
||||
lightActive.setColor(QPalette::ButtonText, QColor(0x55, 0x54, 0x59));
|
||||
return lightActive;
|
||||
} else if (theme == "dark") {
|
||||
QPalette darkActive(
|
||||
/*windowText*/ QColor("#caccd1"),
|
||||
/*button*/ QColor(0xff, 0xff, 0xff),
|
||||
/*light*/ QColor("#caccd1"),
|
||||
/*windowText*/ QColor(0xca, 0xcc, 0xd1),
|
||||
/*button*/ QColor(Qt::GlobalColor::white),
|
||||
/*light*/ QColor(0xca, 0xcc, 0xd1),
|
||||
/*dark*/ QColor(60, 70, 77),
|
||||
/*mid*/ QColor("#202228"),
|
||||
/*text*/ QColor("#caccd1"),
|
||||
/*bright_text*/ QColor("#f4f5f8"),
|
||||
/*base*/ QColor("#202228"),
|
||||
/*window*/ QColor("#2d3139"));
|
||||
darkActive.setColor(QPalette::AlternateBase, QColor("#2d3139"));
|
||||
darkActive.setColor(QPalette::Highlight, QColor("#38a3d8"));
|
||||
darkActive.setColor(QPalette::HighlightedText, QColor("#f4f5f8"));
|
||||
/*mid*/ QColor(0x20, 0x22, 0x28),
|
||||
/*text*/ QColor(0xca, 0xcc, 0xd1),
|
||||
/*bright_text*/ QColor(0xf4, 0xf5, 0xf8),
|
||||
/*base*/ QColor(0x20, 0x22, 0x28),
|
||||
/*window*/ QColor(0x2d, 0x31, 0x39));
|
||||
darkActive.setColor(QPalette::AlternateBase, QColor(0x2d, 0x31, 0x39));
|
||||
darkActive.setColor(QPalette::Highlight, QColor(0x38, 0xa3, 0xd8));
|
||||
darkActive.setColor(QPalette::HighlightedText, QColor(0xf4, 0xf5, 0xf8));
|
||||
darkActive.setColor(QPalette::ToolTipBase, darkActive.base().color());
|
||||
darkActive.setColor(QPalette::ToolTipText, darkActive.text().color());
|
||||
darkActive.setColor(QPalette::Link, QColor("#38a3d8"));
|
||||
darkActive.setColor(QPalette::ButtonText, "#828284");
|
||||
darkActive.setColor(QPalette::Link, QColor(0x38, 0xa3, 0xd8));
|
||||
darkActive.setColor(QPalette::ButtonText, QColor(0x82, 0x82, 0x84));
|
||||
return darkActive;
|
||||
} else {
|
||||
return original;
|
||||
|
@ -59,19 +59,19 @@ Theme::Theme(std::string_view theme)
|
|||
auto p = paletteFromTheme(theme);
|
||||
separator_ = p.mid().color();
|
||||
if (theme == "light") {
|
||||
sidebarBackground_ = QColor("#233649");
|
||||
alternateButton_ = QColor("#ccc");
|
||||
red_ = QColor("#a82353");
|
||||
orange_ = QColor("#fcbe05");
|
||||
sidebarBackground_ = QColor(0x23, 0x36, 0x49);
|
||||
alternateButton_ = QColor(0xcc, 0xcc, 0xcc);
|
||||
red_ = QColor(0xa8, 0x23, 0x53);
|
||||
orange_ = QColor(0xfc, 0xbe, 0x05);
|
||||
} else if (theme == "dark") {
|
||||
sidebarBackground_ = QColor("#2d3139");
|
||||
alternateButton_ = QColor("#414A59");
|
||||
red_ = QColor("#a82353");
|
||||
orange_ = QColor("#fcc53a");
|
||||
sidebarBackground_ = QColor(0x2d, 0x31, 0x39);
|
||||
alternateButton_ = QColor(0x41, 0x4A, 0x59);
|
||||
red_ = QColor(0xa8, 0x23, 0x53);
|
||||
orange_ = QColor(0xfc, 0xc5, 0x3a);
|
||||
} else {
|
||||
sidebarBackground_ = p.window().color();
|
||||
alternateButton_ = p.dark().color();
|
||||
red_ = QColor("red");
|
||||
orange_ = QColor("orange");
|
||||
red_ = QColor(Qt::GlobalColor::red);
|
||||
orange_ = QColor(0xff, 0xa5, 0x00); // SVG orange
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,28 +10,28 @@ QColor
|
|||
ThemeManager::themeColor(const QString &key) const
|
||||
{
|
||||
if (key == "Black")
|
||||
return QColor("#171919");
|
||||
return QColor(0x17, 0x19, 0x19);
|
||||
|
||||
else if (key == "BrightWhite")
|
||||
return QColor("#EBEBEB");
|
||||
return QColor(0xEB, 0xEB, 0xEB);
|
||||
else if (key == "FadedWhite")
|
||||
return QColor("#C9C9C9");
|
||||
return QColor(0xC9, 0xC9, 0xC9);
|
||||
else if (key == "MediumWhite")
|
||||
return QColor("#929292");
|
||||
return QColor(0x92, 0x92, 0x92);
|
||||
|
||||
else if (key == "BrightGreen")
|
||||
return QColor("#1C3133");
|
||||
return QColor(0x1C, 0x31, 0x33);
|
||||
else if (key == "DarkGreen")
|
||||
return QColor("#577275");
|
||||
return QColor(0x57, 0x72, 0x75);
|
||||
else if (key == "LightGreen")
|
||||
return QColor("#46A451");
|
||||
return QColor(0x46, 0xA4, 0x51);
|
||||
|
||||
else if (key == "Gray")
|
||||
return QColor("#5D6565");
|
||||
return QColor(0x5D, 0x65, 0x65);
|
||||
else if (key == "Red")
|
||||
return QColor("#E22826");
|
||||
return QColor(0xE2, 0x28, 0x26);
|
||||
else if (key == "Blue")
|
||||
return QColor("#81B3A9");
|
||||
return QColor(0x81, 0xB3, 0xA9);
|
||||
|
||||
else if (key == "Transparent")
|
||||
return QColor(0, 0, 0, 0);
|
||||
|
|
|
@ -69,6 +69,7 @@ Toggle::setDisabledColor(const QColor &color)
|
|||
{
|
||||
disabledColor_ = color;
|
||||
setupProperties();
|
||||
emit disabledColorChanged();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -76,6 +77,7 @@ Toggle::setActiveColor(const QColor &color)
|
|||
{
|
||||
activeColor_ = color;
|
||||
setupProperties();
|
||||
emit activeColorChanged();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -83,6 +85,7 @@ Toggle::setInactiveColor(const QColor &color)
|
|||
{
|
||||
inactiveColor_ = color;
|
||||
setupProperties();
|
||||
emit inactiveColorChanged();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -90,6 +93,7 @@ Toggle::setTrackColor(const QColor &color)
|
|||
{
|
||||
trackColor_ = color;
|
||||
setupProperties();
|
||||
emit trackColorChanged();
|
||||
}
|
||||
|
||||
ToggleThumb::ToggleThumb(Toggle *parent)
|
||||
|
@ -174,6 +178,7 @@ void
|
|||
ToggleTrack::setTrackColor(const QColor &color)
|
||||
{
|
||||
trackColor_ = color;
|
||||
emit trackColorChanged();
|
||||
update();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,10 +20,12 @@ class Toggle : public QAbstractButton
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QColor activeColor WRITE setActiveColor READ activeColor)
|
||||
Q_PROPERTY(QColor disabledColor WRITE setDisabledColor READ disabledColor)
|
||||
Q_PROPERTY(QColor inactiveColor WRITE setInactiveColor READ inactiveColor)
|
||||
Q_PROPERTY(QColor trackColor WRITE setTrackColor READ trackColor)
|
||||
Q_PROPERTY(QColor activeColor WRITE setActiveColor READ activeColor NOTIFY activeColorChanged)
|
||||
Q_PROPERTY(
|
||||
QColor disabledColor WRITE setDisabledColor READ disabledColor NOTIFY disabledColorChanged)
|
||||
Q_PROPERTY(
|
||||
QColor inactiveColor WRITE setInactiveColor READ inactiveColor NOTIFY inactiveColorChanged)
|
||||
Q_PROPERTY(QColor trackColor WRITE setTrackColor READ trackColor NOTIFY trackColorChanged)
|
||||
|
||||
public:
|
||||
Toggle(QWidget *parent = nullptr);
|
||||
|
@ -38,13 +40,22 @@ public:
|
|||
QColor activeColor() const { return activeColor_; };
|
||||
QColor disabledColor() const { return disabledColor_; };
|
||||
QColor inactiveColor() const { return inactiveColor_; };
|
||||
QColor trackColor() const { return trackColor_.isValid() ? trackColor_ : QColor("#eee"); };
|
||||
QColor trackColor() const
|
||||
{
|
||||
return trackColor_.isValid() ? trackColor_ : QColor(0xee, 0xee, 0xee);
|
||||
};
|
||||
|
||||
QSize sizeHint() const override { return QSize(64, 48); };
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
signals:
|
||||
void activeColorChanged();
|
||||
void disabledColorChanged();
|
||||
void inactiveColorChanged();
|
||||
void trackColorChanged();
|
||||
|
||||
private:
|
||||
void init();
|
||||
void setupProperties();
|
||||
|
@ -62,7 +73,7 @@ class ToggleThumb : public QWidget
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QColor thumbColor WRITE setThumbColor READ thumbColor)
|
||||
Q_PROPERTY(QColor thumbColor WRITE setThumbColor READ thumbColor NOTIFY thumbColorChanged)
|
||||
|
||||
public:
|
||||
ToggleThumb(Toggle *parent);
|
||||
|
@ -75,6 +86,7 @@ public:
|
|||
void setThumbColor(const QColor &color)
|
||||
{
|
||||
thumbColor_ = color;
|
||||
emit thumbColorChanged();
|
||||
update();
|
||||
};
|
||||
|
||||
|
@ -82,6 +94,9 @@ protected:
|
|||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
signals:
|
||||
void thumbColorChanged();
|
||||
|
||||
private:
|
||||
void updateOffset();
|
||||
|
||||
|
@ -96,7 +111,7 @@ class ToggleTrack : public QWidget
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QColor trackColor WRITE setTrackColor READ trackColor)
|
||||
Q_PROPERTY(QColor trackColor WRITE setTrackColor READ trackColor NOTIFY trackColor)
|
||||
|
||||
public:
|
||||
ToggleTrack(Toggle *parent);
|
||||
|
@ -108,6 +123,9 @@ protected:
|
|||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
signals:
|
||||
void trackColorChanged();
|
||||
|
||||
private:
|
||||
Toggle *const toggle_;
|
||||
QColor trackColor_;
|
||||
|
|
|
@ -175,8 +175,6 @@ UserProfile::refreshDevices()
|
|||
void
|
||||
UserProfile::fetchDeviceList(const QString &userID)
|
||||
{
|
||||
auto localUser = utils::localUser();
|
||||
|
||||
if (!cache::client() || !cache::client()->isDatabaseReady())
|
||||
return;
|
||||
|
||||
|
|
|
@ -143,6 +143,7 @@ CallManager::CallManager(QObject *parent)
|
|||
|
||||
connect(&player_,
|
||||
QOverload<QMediaPlayer::Error>::of(&QMediaPlayer::error),
|
||||
this,
|
||||
[this](QMediaPlayer::Error error) {
|
||||
stopRingtone();
|
||||
switch (error) {
|
||||
|
|
Loading…
Reference in a new issue