mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 12:38:48 +03:00
Optimize includes a bit
This commit is contained in:
parent
558fd10f7b
commit
4cd260bfcf
41 changed files with 271 additions and 228 deletions
|
@ -256,6 +256,7 @@ set(SRC_FILES
|
|||
# UI components
|
||||
src/ui/Avatar.cpp
|
||||
src/ui/Badge.cpp
|
||||
src/ui/DropShadow.cpp
|
||||
src/ui/LoadingIndicator.cpp
|
||||
src/ui/InfoMessage.cpp
|
||||
src/ui/FlatButton.cpp
|
||||
|
|
|
@ -84,7 +84,7 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
|||
// SideBar
|
||||
sideBar_ = new QFrame(this);
|
||||
sideBar_->setObjectName("sideBar");
|
||||
sideBar_->setMinimumWidth(utils::calculateSidebarSizes(QFont{}).normal);
|
||||
sideBar_->setMinimumWidth(::splitter::calculateSidebarSizes(QFont{}).normal);
|
||||
sideBarLayout_ = new QVBoxLayout(sideBar_);
|
||||
sideBarLayout_->setSpacing(0);
|
||||
sideBarLayout_->setMargin(0);
|
||||
|
@ -1307,7 +1307,7 @@ ChatPage::timelineWidth()
|
|||
bool
|
||||
ChatPage::isSideBarExpanded()
|
||||
{
|
||||
const auto sz = utils::calculateSidebarSizes(QFont{});
|
||||
const auto sz = splitter::calculateSidebarSizes(QFont{});
|
||||
return sideBar_->size().width() > sz.normal;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
#include "Cache.h"
|
||||
#include "Logging.h"
|
||||
#include "MatrixClient.h"
|
||||
#include "Utils.h"
|
||||
#include "Splitter.h"
|
||||
|
||||
#include <mtx/responses/groups.hpp>
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
|
@ -20,7 +22,7 @@ CommunitiesList::CommunitiesList(QWidget *parent)
|
|||
topLayout_->setSpacing(0);
|
||||
topLayout_->setMargin(0);
|
||||
|
||||
const auto sideBarSizes = utils::calculateSidebarSizes(QFont{});
|
||||
const auto sideBarSizes = splitter::calculateSidebarSizes(QFont{});
|
||||
setFixedWidth(sideBarSizes.groups);
|
||||
|
||||
scrollArea_ = new QScrollArea(this);
|
||||
|
@ -185,7 +187,8 @@ void
|
|||
CommunitiesList::updateCommunityAvatar(const QString &community_id, const QPixmap &img)
|
||||
{
|
||||
if (!communityExists(community_id)) {
|
||||
qWarning() << "Avatar update on nonexistent community" << community_id;
|
||||
nhlog::ui()->warn("Avatar update on nonexistent community {}",
|
||||
community_id.toStdString());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -196,7 +199,7 @@ void
|
|||
CommunitiesList::highlightSelectedCommunity(const QString &community_id)
|
||||
{
|
||||
if (!communityExists(community_id)) {
|
||||
qDebug() << "CommunitiesList: clicked unknown community";
|
||||
nhlog::ui()->debug("CommunitiesList: clicked unknown community");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
#include "CommunitiesListItem.h"
|
||||
#include "ui/Theme.h"
|
||||
|
||||
namespace mtx::responses {
|
||||
struct GroupProfile;
|
||||
struct JoinedGroups;
|
||||
}
|
||||
|
||||
class CommunitiesList : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
#include "CommunitiesListItem.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include "Utils.h"
|
||||
#include "ui/Painter.h"
|
||||
#include "ui/Ripple.h"
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QSharedPointer>
|
||||
#include <QWidget>
|
||||
|
||||
#include <mtx/responses/groups.hpp>
|
||||
|
||||
#include "Config.h"
|
||||
#include "ui/Theme.h"
|
||||
|
||||
class RippleOverlay;
|
||||
class QPainter;
|
||||
class QMouseEvent;
|
||||
|
||||
class CommunitiesListItem : public QWidget
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
|
||||
#include <mtx/identifiers.hpp>
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "MainWindow.h"
|
||||
#include "MatrixClient.h"
|
||||
#include "RegisterPage.h"
|
||||
#include "Splitter.h"
|
||||
#include "TrayIcon.h"
|
||||
#include "UserSettingsPage.h"
|
||||
#include "Utils.h"
|
||||
|
@ -191,7 +192,7 @@ MainWindow::resizeEvent(QResizeEvent *event)
|
|||
void
|
||||
MainWindow::adjustSideBars()
|
||||
{
|
||||
const auto sz = utils::calculateSidebarSizes(QFont{});
|
||||
const auto sz = splitter::calculateSidebarSizes(QFont{});
|
||||
|
||||
const uint64_t timelineWidth = chat_page_->timelineWidth();
|
||||
const uint64_t minAvailableWidth = sz.collapsePoint + sz.groups;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
#include <QTimer>
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QSettings>
|
||||
|
@ -26,6 +25,7 @@
|
|||
#include "Cache.h"
|
||||
#include "Config.h"
|
||||
#include "RoomInfoListItem.h"
|
||||
#include "Splitter.h"
|
||||
#include "Utils.h"
|
||||
#include "ui/Menu.h"
|
||||
#include "ui/Ripple.h"
|
||||
|
@ -116,7 +116,7 @@ RoomInfoListItem::resizeEvent(QResizeEvent *)
|
|||
QPainterPath path;
|
||||
path.addRect(0, 0, width(), height());
|
||||
|
||||
const auto sidebarSizes = utils::calculateSidebarSizes(QFont{});
|
||||
const auto sidebarSizes = splitter::calculateSidebarSizes(QFont{});
|
||||
|
||||
if (width() > sidebarSizes.small)
|
||||
setToolTip("");
|
||||
|
@ -165,7 +165,7 @@ RoomInfoListItem::paintEvent(QPaintEvent *event)
|
|||
// Description line with the default font.
|
||||
int bottom_y = wm.maxHeight - wm.padding - metrics.ascent() / 2;
|
||||
|
||||
const auto sidebarSizes = utils::calculateSidebarSizes(QFont{});
|
||||
const auto sidebarSizes = splitter::calculateSidebarSizes(QFont{});
|
||||
|
||||
if (width() > sidebarSizes.small) {
|
||||
QFont headingFont;
|
||||
|
|
|
@ -17,18 +17,14 @@
|
|||
|
||||
#include <limits>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QBuffer>
|
||||
#include <QObject>
|
||||
#include <QPainter>
|
||||
#include <QTimer>
|
||||
|
||||
#include "Cache.h"
|
||||
#include "Logging.h"
|
||||
#include "MainWindow.h"
|
||||
#include "MatrixClient.h"
|
||||
#include "RoomInfoListItem.h"
|
||||
#include "RoomList.h"
|
||||
#include "UserSettingsPage.h"
|
||||
#include "Utils.h"
|
||||
#include "ui/OverlayModal.h"
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
#include <QDebug>
|
||||
#include <QIcon>
|
||||
#include <QPainter>
|
||||
#include <QResizeEvent>
|
||||
|
||||
#include <mtx/requests.hpp>
|
||||
|
||||
#include "Config.h"
|
||||
#include "MainWindow.h"
|
||||
#include "SideBarActions.h"
|
||||
#include "Utils.h"
|
||||
#include "Splitter.h"
|
||||
#include "ui/FlatButton.h"
|
||||
#include "ui/Menu.h"
|
||||
#include "ui/OverlayModal.h"
|
||||
|
||||
SideBarActions::SideBarActions(QWidget *parent)
|
||||
: QWidget{parent}
|
||||
|
@ -93,7 +93,7 @@ SideBarActions::resizeEvent(QResizeEvent *event)
|
|||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
const auto sidebarSizes = utils::calculateSidebarSizes(QFont{});
|
||||
const auto sidebarSizes = splitter::calculateSidebarSizes(QFont{});
|
||||
|
||||
if (width() <= sidebarSizes.small) {
|
||||
roomDirectory_->hide();
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include <QAction>
|
||||
#include <QHBoxLayout>
|
||||
#include <QResizeEvent>
|
||||
#include <QWidget>
|
||||
|
||||
namespace mtx {
|
||||
|
@ -13,6 +12,7 @@ struct CreateRoom;
|
|||
|
||||
class Menu;
|
||||
class FlatButton;
|
||||
class QResizeEvent;
|
||||
|
||||
class SideBarActions : public QWidget
|
||||
{
|
||||
|
|
|
@ -16,19 +16,20 @@
|
|||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QDesktopWidget>
|
||||
#include <QSettings>
|
||||
#include <QShortcut>
|
||||
|
||||
#include "Config.h"
|
||||
#include "Logging.h"
|
||||
#include "Splitter.h"
|
||||
#include "Utils.h"
|
||||
|
||||
constexpr auto MaxWidth = (1 << 24) - 1;
|
||||
|
||||
Splitter::Splitter(QWidget *parent)
|
||||
: QSplitter(parent)
|
||||
, sz_{utils::calculateSidebarSizes(QFont{})}
|
||||
, sz_{splitter::calculateSidebarSizes(QFont{})}
|
||||
{
|
||||
connect(this, &QSplitter::splitterMoved, this, &Splitter::onSplitterMoved);
|
||||
setChildrenCollapsible(false);
|
||||
|
@ -80,7 +81,7 @@ Splitter::onSplitterMoved(int pos, int index)
|
|||
auto s = sizes();
|
||||
|
||||
if (s.count() < 2) {
|
||||
qWarning() << "Splitter needs at least two children";
|
||||
nhlog::ui()->warn("Splitter needs at least two children");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -165,3 +166,18 @@ Splitter::showFullRoomList()
|
|||
left->show();
|
||||
left->setMaximumWidth(MaxWidth);
|
||||
}
|
||||
|
||||
splitter::SideBarSizes
|
||||
splitter::calculateSidebarSizes(const QFont &f)
|
||||
{
|
||||
const auto height = static_cast<double>(QFontMetrics{f}.lineSpacing());
|
||||
|
||||
SideBarSizes sz;
|
||||
sz.small = std::ceil(3.5 * height + height / 4.0);
|
||||
sz.normal = std::ceil(16 * height);
|
||||
sz.groups = std::ceil(3 * height);
|
||||
sz.collapsePoint = 2 * sz.normal;
|
||||
|
||||
return sz;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,9 +17,21 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "Utils.h"
|
||||
#include <QSplitter>
|
||||
|
||||
namespace splitter {
|
||||
struct SideBarSizes
|
||||
{
|
||||
int small;
|
||||
int normal;
|
||||
int groups;
|
||||
int collapsePoint;
|
||||
};
|
||||
|
||||
SideBarSizes
|
||||
calculateSidebarSizes(const QFont &f);
|
||||
}
|
||||
|
||||
class Splitter : public QSplitter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -45,5 +57,5 @@ private:
|
|||
int leftMoveCount_ = 0;
|
||||
int rightMoveCount_ = 0;
|
||||
|
||||
utils::SideBarSizes sz_;
|
||||
splitter::SideBarSizes sz_;
|
||||
};
|
||||
|
|
|
@ -16,12 +16,9 @@
|
|||
*/
|
||||
|
||||
#include <QAbstractTextDocumentLayout>
|
||||
#include <QApplication>
|
||||
#include <QBuffer>
|
||||
#include <QClipboard>
|
||||
#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
#include <QImageReader>
|
||||
#include <QMimeData>
|
||||
#include <QMimeDatabase>
|
||||
#include <QMimeType>
|
||||
|
@ -31,7 +28,7 @@
|
|||
|
||||
#include "Cache.h"
|
||||
#include "ChatPage.h"
|
||||
#include "Config.h"
|
||||
#include "Logging.h"
|
||||
#include "TextInputWidget.h"
|
||||
#include "Utils.h"
|
||||
#include "ui/FlatButton.h"
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include <optional>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPaintEvent>
|
||||
#include <QTextEdit>
|
||||
|
|
|
@ -15,8 +15,16 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QDebug>
|
||||
#include <QAction>
|
||||
#include <QIcon>
|
||||
#include <QLabel>
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
#include <QPen>
|
||||
#include <QPoint>
|
||||
#include <QStyle>
|
||||
#include <QStyleOption>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "Config.h"
|
||||
#include "MainWindow.h"
|
||||
|
@ -210,3 +218,19 @@ TopRoomBar::updateRoomTopic(QString topic)
|
|||
topicLabel_->setHtml(topic);
|
||||
update();
|
||||
}
|
||||
|
||||
void
|
||||
TopRoomBar::mousePressEvent(QMouseEvent *)
|
||||
{
|
||||
if (roomSettings_ != nullptr)
|
||||
roomSettings_->trigger();
|
||||
}
|
||||
|
||||
void
|
||||
TopRoomBar::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QStyleOption opt;
|
||||
opt.init(this);
|
||||
QPainter p(this);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||
}
|
||||
|
|
|
@ -17,17 +17,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <QAction>
|
||||
#include <QIcon>
|
||||
#include <QImage>
|
||||
#include <QLabel>
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
#include <QPen>
|
||||
#include <QPoint>
|
||||
#include <QStyle>
|
||||
#include <QStyleOption>
|
||||
#include <QVBoxLayout>
|
||||
#include <QColor>
|
||||
#include <QStringList>
|
||||
#include <QWidget>
|
||||
|
||||
class Avatar;
|
||||
class FlatButton;
|
||||
|
@ -35,6 +27,12 @@ class Menu;
|
|||
class TextLabel;
|
||||
class OverlayModal;
|
||||
|
||||
class QPainter;
|
||||
class QLabel;
|
||||
class QIcon;
|
||||
class QHBoxLayout;
|
||||
class QVBoxLayout;
|
||||
|
||||
class TopRoomBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -67,19 +65,8 @@ signals:
|
|||
void mentionsClicked(const QPoint &pos);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *) override
|
||||
{
|
||||
if (roomSettings_ != nullptr)
|
||||
roomSettings_->trigger();
|
||||
}
|
||||
|
||||
void paintEvent(QPaintEvent *) override
|
||||
{
|
||||
QStyleOption opt;
|
||||
opt.init(this);
|
||||
QPainter p(this);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||
}
|
||||
void mousePressEvent(QMouseEvent *) override;
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
|
||||
private:
|
||||
QHBoxLayout *topLayout_ = nullptr;
|
||||
|
|
|
@ -15,9 +15,11 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QList>
|
||||
#include <QMenu>
|
||||
#include <QPainter>
|
||||
#include <QTimer>
|
||||
|
||||
#include "TrayIcon.h"
|
||||
|
|
|
@ -17,13 +17,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <QAction>
|
||||
#include <QIcon>
|
||||
#include <QIconEngine>
|
||||
#include <QPainter>
|
||||
#include <QRect>
|
||||
#include <QSystemTrayIcon>
|
||||
|
||||
class QAction;
|
||||
class QPainter;
|
||||
|
||||
class MsgCountComposedIcon : public QIconEngine
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -16,14 +16,15 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QPainter>
|
||||
#include <QTimer>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "Config.h"
|
||||
#include "MainWindow.h"
|
||||
#include "Splitter.h"
|
||||
#include "UserInfoWidget.h"
|
||||
#include "Utils.h"
|
||||
#include "ui/Avatar.h"
|
||||
#include "ui/FlatButton.h"
|
||||
#include "ui/OverlayModal.h"
|
||||
|
@ -108,7 +109,7 @@ UserInfoWidget::resizeEvent(QResizeEvent *event)
|
|||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
const auto sz = utils::calculateSidebarSizes(QFont{});
|
||||
const auto sz = splitter::calculateSidebarSizes(QFont{});
|
||||
|
||||
if (width() <= sz.small) {
|
||||
topLayout_->setContentsMargins(0, 0, logoutButtonSize_, 0);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QMessageBox>
|
||||
#include <QPainter>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QPushButton>
|
||||
#include <QScrollArea>
|
||||
|
|
|
@ -22,6 +22,25 @@ using TimelineEvent = mtx::events::collections::TimelineEvents;
|
|||
|
||||
QHash<QString, QString> authorColors_;
|
||||
|
||||
template<class T, class Event>
|
||||
static DescInfo
|
||||
createDescriptionInfo(const Event &event, const QString &localUser, const QString &room_id)
|
||||
{
|
||||
const auto msg = std::get<T>(event);
|
||||
const auto sender = QString::fromStdString(msg.sender);
|
||||
|
||||
const auto username = cache::displayName(room_id, sender);
|
||||
const auto ts = QDateTime::fromMSecsSinceEpoch(msg.origin_server_ts);
|
||||
|
||||
return DescInfo{
|
||||
QString::fromStdString(msg.event_id),
|
||||
sender,
|
||||
utils::messageDescription<T>(
|
||||
username, QString::fromStdString(msg.content.body).trimmed(), sender == localUser),
|
||||
utils::descriptiveTime(ts),
|
||||
ts};
|
||||
}
|
||||
|
||||
QString
|
||||
utils::localUser()
|
||||
{
|
||||
|
@ -633,16 +652,3 @@ utils::restoreCombobox(QComboBox *combo, const QString &value)
|
|||
}
|
||||
}
|
||||
|
||||
utils::SideBarSizes
|
||||
utils::calculateSidebarSizes(const QFont &f)
|
||||
{
|
||||
const auto height = static_cast<double>(QFontMetrics{f}.lineSpacing());
|
||||
|
||||
SideBarSizes sz;
|
||||
sz.small = std::ceil(3.5 * height + height / 4.0);
|
||||
sz.normal = std::ceil(16 * height);
|
||||
sz.groups = std::ceil(3 * height);
|
||||
sz.collapsePoint = 2 * sz.normal;
|
||||
|
||||
return sz;
|
||||
}
|
||||
|
|
33
src/Utils.h
33
src/Utils.h
|
@ -2,8 +2,6 @@
|
|||
|
||||
#include <variant>
|
||||
|
||||
#include "RoomInfoListItem.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDateTime>
|
||||
#include <QPixmap>
|
||||
|
@ -12,6 +10,8 @@
|
|||
|
||||
#include <qmath.h>
|
||||
|
||||
struct DescInfo;
|
||||
|
||||
namespace cache {
|
||||
// Forward declarations to prevent dependency on Cache.h, since this header is included often!
|
||||
QString
|
||||
|
@ -166,25 +166,6 @@ messageDescription(const QString &username = "",
|
|||
}
|
||||
}
|
||||
|
||||
template<class T, class Event>
|
||||
DescInfo
|
||||
createDescriptionInfo(const Event &event, const QString &localUser, const QString &room_id)
|
||||
{
|
||||
const auto msg = std::get<T>(event);
|
||||
const auto sender = QString::fromStdString(msg.sender);
|
||||
|
||||
const auto username = cache::displayName(room_id, sender);
|
||||
const auto ts = QDateTime::fromMSecsSinceEpoch(msg.origin_server_ts);
|
||||
|
||||
return DescInfo{QString::fromStdString(msg.event_id),
|
||||
sender,
|
||||
messageDescription<T>(username,
|
||||
QString::fromStdString(msg.content.body).trimmed(),
|
||||
sender == localUser),
|
||||
utils::descriptiveTime(ts),
|
||||
ts};
|
||||
}
|
||||
|
||||
//! Scale down an image to fit to the given width & height limitations.
|
||||
QPixmap
|
||||
scaleDown(uint64_t maxWidth, uint64_t maxHeight, const QPixmap &source);
|
||||
|
@ -326,14 +307,4 @@ centerWidget(QWidget *widget, QWidget *parent);
|
|||
void
|
||||
restoreCombobox(QComboBox *combo, const QString &value);
|
||||
|
||||
struct SideBarSizes
|
||||
{
|
||||
int small;
|
||||
int normal;
|
||||
int groups;
|
||||
int collapsePoint;
|
||||
};
|
||||
|
||||
SideBarSizes
|
||||
calculateSidebarSizes(const QFont &f);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
|
||||
#include "Config.h"
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "Cache.h"
|
||||
#include "ChatPage.h"
|
||||
#include "Config.h"
|
||||
#include "Logging.h"
|
||||
#include "Utils.h"
|
||||
#include "ui/Avatar.h"
|
||||
|
||||
|
@ -116,7 +117,7 @@ MemberList::MemberList(const QString &room_id, QWidget *parent)
|
|||
try {
|
||||
addUsers(cache::getMembers(room_id_.toStdString()));
|
||||
} catch (const lmdb::error &e) {
|
||||
qCritical() << e.what();
|
||||
nhlog::db()->critical("Failed to retrieve members from cache: {}", e.what());
|
||||
}
|
||||
|
||||
auto closeShortcut = new QShortcut(QKeySequence(QKeySequence::Cancel), this);
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QListWidget>
|
||||
#include <QSettings>
|
||||
#include <QShortcut>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "AvatarProvider.h"
|
||||
#include "Cache.h"
|
||||
#include "ChatPage.h"
|
||||
#include "Logging.h"
|
||||
#include "MatrixClient.h"
|
||||
#include "Utils.h"
|
||||
#include "dialogs/UserProfile.h"
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QSettings>
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QPainter>
|
||||
#include <QPushButton>
|
||||
#include <QScrollBar>
|
||||
#include <QVBoxLayout>
|
||||
|
|
|
@ -2,19 +2,14 @@
|
|||
|
||||
#include <mtx/responses.hpp>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QEvent>
|
||||
#include <QMap>
|
||||
#include <QPaintEvent>
|
||||
#include <QScrollArea>
|
||||
#include <QScrollBar>
|
||||
#include <QString>
|
||||
#include <QTabWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
#include <Qt>
|
||||
|
||||
#include "Logging.h"
|
||||
|
||||
namespace popups {
|
||||
|
||||
|
|
|
@ -6,16 +6,18 @@
|
|||
#include <QHash>
|
||||
#include <QSet>
|
||||
|
||||
#include <mtx/common.hpp>
|
||||
#include <mtx/responses.hpp>
|
||||
#include <mtxclient/http/errors.hpp>
|
||||
|
||||
#include "CacheCryptoStructs.h"
|
||||
#include "Logging.h"
|
||||
|
||||
namespace mtx::http {
|
||||
using RequestErr = const std::optional<mtx::http::ClientError> &;
|
||||
}
|
||||
namespace mtx::responses {
|
||||
struct Timeline;
|
||||
struct Messages;
|
||||
struct ClaimKeys;
|
||||
}
|
||||
|
||||
namespace qml_mtx_events {
|
||||
Q_NAMESPACE
|
||||
|
|
110
src/ui/DropShadow.cpp
Normal file
110
src/ui/DropShadow.cpp
Normal file
|
@ -0,0 +1,110 @@
|
|||
#include "DropShadow.h"
|
||||
|
||||
#include <QLinearGradient>
|
||||
#include <QPainter>
|
||||
|
||||
|
||||
void DropShadow::draw(QPainter &painter,
|
||||
qint16 margin,
|
||||
qreal radius,
|
||||
QColor start,
|
||||
QColor end,
|
||||
qreal startPosition,
|
||||
qreal endPosition0,
|
||||
qreal endPosition1,
|
||||
qreal width,
|
||||
qreal height)
|
||||
{
|
||||
painter.setPen(Qt::NoPen);
|
||||
|
||||
QLinearGradient gradient;
|
||||
gradient.setColorAt(startPosition, start);
|
||||
gradient.setColorAt(endPosition0, end);
|
||||
|
||||
// Right
|
||||
QPointF right0(width - margin, height / 2);
|
||||
QPointF right1(width, height / 2);
|
||||
gradient.setStart(right0);
|
||||
gradient.setFinalStop(right1);
|
||||
painter.setBrush(QBrush(gradient));
|
||||
// Deprecated in 5.13: painter.drawRoundRect(
|
||||
// QRectF(QPointF(width - margin * radius, margin), QPointF(width, height -
|
||||
// margin)), 0.0, 0.0);
|
||||
painter.drawRoundedRect(
|
||||
QRectF(QPointF(width - margin * radius, margin), QPointF(width, height - margin)),
|
||||
0.0,
|
||||
0.0);
|
||||
|
||||
// Left
|
||||
QPointF left0(margin, height / 2);
|
||||
QPointF left1(0, height / 2);
|
||||
gradient.setStart(left0);
|
||||
gradient.setFinalStop(left1);
|
||||
painter.setBrush(QBrush(gradient));
|
||||
painter.drawRoundedRect(
|
||||
QRectF(QPointF(margin * radius, margin), QPointF(0, height - margin)), 0.0, 0.0);
|
||||
|
||||
// Top
|
||||
QPointF top0(width / 2, margin);
|
||||
QPointF top1(width / 2, 0);
|
||||
gradient.setStart(top0);
|
||||
gradient.setFinalStop(top1);
|
||||
painter.setBrush(QBrush(gradient));
|
||||
painter.drawRoundedRect(
|
||||
QRectF(QPointF(width - margin, 0), QPointF(margin, margin)), 0.0, 0.0);
|
||||
|
||||
// Bottom
|
||||
QPointF bottom0(width / 2, height - margin);
|
||||
QPointF bottom1(width / 2, height);
|
||||
gradient.setStart(bottom0);
|
||||
gradient.setFinalStop(bottom1);
|
||||
painter.setBrush(QBrush(gradient));
|
||||
painter.drawRoundedRect(
|
||||
QRectF(QPointF(margin, height - margin), QPointF(width - margin, height)),
|
||||
0.0,
|
||||
0.0);
|
||||
|
||||
// BottomRight
|
||||
QPointF bottomright0(width - margin, height - margin);
|
||||
QPointF bottomright1(width, height);
|
||||
gradient.setStart(bottomright0);
|
||||
gradient.setFinalStop(bottomright1);
|
||||
gradient.setColorAt(endPosition1, end);
|
||||
painter.setBrush(QBrush(gradient));
|
||||
painter.drawRoundedRect(QRectF(bottomright0, bottomright1), 0.0, 0.0);
|
||||
|
||||
// BottomLeft
|
||||
QPointF bottomleft0(margin, height - margin);
|
||||
QPointF bottomleft1(0, height);
|
||||
gradient.setStart(bottomleft0);
|
||||
gradient.setFinalStop(bottomleft1);
|
||||
gradient.setColorAt(endPosition1, end);
|
||||
painter.setBrush(QBrush(gradient));
|
||||
painter.drawRoundedRect(QRectF(bottomleft0, bottomleft1), 0.0, 0.0);
|
||||
|
||||
// TopLeft
|
||||
QPointF topleft0(margin, margin);
|
||||
QPointF topleft1(0, 0);
|
||||
gradient.setStart(topleft0);
|
||||
gradient.setFinalStop(topleft1);
|
||||
gradient.setColorAt(endPosition1, end);
|
||||
painter.setBrush(QBrush(gradient));
|
||||
painter.drawRoundedRect(QRectF(topleft0, topleft1), 0.0, 0.0);
|
||||
|
||||
// TopRight
|
||||
QPointF topright0(width - margin, margin);
|
||||
QPointF topright1(width, 0);
|
||||
gradient.setStart(topright0);
|
||||
gradient.setFinalStop(topright1);
|
||||
gradient.setColorAt(endPosition1, end);
|
||||
painter.setBrush(QBrush(gradient));
|
||||
painter.drawRoundedRect(QRectF(topright0, topright1), 0.0, 0.0);
|
||||
|
||||
// Widget
|
||||
painter.setBrush(QBrush("#FFFFFF"));
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.drawRoundedRect(
|
||||
QRectF(QPointF(margin, margin), QPointF(width - margin, height - margin)),
|
||||
radius,
|
||||
radius);
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <QColor>
|
||||
#include <QLinearGradient>
|
||||
#include <QPainter>
|
||||
|
||||
class QPainter;
|
||||
|
||||
class DropShadow
|
||||
{
|
||||
|
@ -16,99 +16,5 @@ public:
|
|||
qreal endPosition0,
|
||||
qreal endPosition1,
|
||||
qreal width,
|
||||
qreal height)
|
||||
{
|
||||
painter.setPen(Qt::NoPen);
|
||||
|
||||
QLinearGradient gradient;
|
||||
gradient.setColorAt(startPosition, start);
|
||||
gradient.setColorAt(endPosition0, end);
|
||||
|
||||
// Right
|
||||
QPointF right0(width - margin, height / 2);
|
||||
QPointF right1(width, height / 2);
|
||||
gradient.setStart(right0);
|
||||
gradient.setFinalStop(right1);
|
||||
painter.setBrush(QBrush(gradient));
|
||||
// Deprecated in 5.13: painter.drawRoundRect(
|
||||
// QRectF(QPointF(width - margin * radius, margin), QPointF(width, height -
|
||||
// margin)), 0.0, 0.0);
|
||||
painter.drawRoundedRect(
|
||||
QRectF(QPointF(width - margin * radius, margin), QPointF(width, height - margin)),
|
||||
0.0,
|
||||
0.0);
|
||||
|
||||
// Left
|
||||
QPointF left0(margin, height / 2);
|
||||
QPointF left1(0, height / 2);
|
||||
gradient.setStart(left0);
|
||||
gradient.setFinalStop(left1);
|
||||
painter.setBrush(QBrush(gradient));
|
||||
painter.drawRoundedRect(
|
||||
QRectF(QPointF(margin * radius, margin), QPointF(0, height - margin)), 0.0, 0.0);
|
||||
|
||||
// Top
|
||||
QPointF top0(width / 2, margin);
|
||||
QPointF top1(width / 2, 0);
|
||||
gradient.setStart(top0);
|
||||
gradient.setFinalStop(top1);
|
||||
painter.setBrush(QBrush(gradient));
|
||||
painter.drawRoundedRect(
|
||||
QRectF(QPointF(width - margin, 0), QPointF(margin, margin)), 0.0, 0.0);
|
||||
|
||||
// Bottom
|
||||
QPointF bottom0(width / 2, height - margin);
|
||||
QPointF bottom1(width / 2, height);
|
||||
gradient.setStart(bottom0);
|
||||
gradient.setFinalStop(bottom1);
|
||||
painter.setBrush(QBrush(gradient));
|
||||
painter.drawRoundedRect(
|
||||
QRectF(QPointF(margin, height - margin), QPointF(width - margin, height)),
|
||||
0.0,
|
||||
0.0);
|
||||
|
||||
// BottomRight
|
||||
QPointF bottomright0(width - margin, height - margin);
|
||||
QPointF bottomright1(width, height);
|
||||
gradient.setStart(bottomright0);
|
||||
gradient.setFinalStop(bottomright1);
|
||||
gradient.setColorAt(endPosition1, end);
|
||||
painter.setBrush(QBrush(gradient));
|
||||
painter.drawRoundedRect(QRectF(bottomright0, bottomright1), 0.0, 0.0);
|
||||
|
||||
// BottomLeft
|
||||
QPointF bottomleft0(margin, height - margin);
|
||||
QPointF bottomleft1(0, height);
|
||||
gradient.setStart(bottomleft0);
|
||||
gradient.setFinalStop(bottomleft1);
|
||||
gradient.setColorAt(endPosition1, end);
|
||||
painter.setBrush(QBrush(gradient));
|
||||
painter.drawRoundedRect(QRectF(bottomleft0, bottomleft1), 0.0, 0.0);
|
||||
|
||||
// TopLeft
|
||||
QPointF topleft0(margin, margin);
|
||||
QPointF topleft1(0, 0);
|
||||
gradient.setStart(topleft0);
|
||||
gradient.setFinalStop(topleft1);
|
||||
gradient.setColorAt(endPosition1, end);
|
||||
painter.setBrush(QBrush(gradient));
|
||||
painter.drawRoundedRect(QRectF(topleft0, topleft1), 0.0, 0.0);
|
||||
|
||||
// TopRight
|
||||
QPointF topright0(width - margin, margin);
|
||||
QPointF topright1(width, 0);
|
||||
gradient.setStart(topright0);
|
||||
gradient.setFinalStop(topright1);
|
||||
gradient.setColorAt(endPosition1, end);
|
||||
painter.setBrush(QBrush(gradient));
|
||||
painter.drawRoundedRect(QRectF(topright0, topright1), 0.0, 0.0);
|
||||
|
||||
// Widget
|
||||
painter.setBrush(QBrush("#FFFFFF"));
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.drawRoundedRect(
|
||||
QRectF(QPointF(margin, margin), QPointF(width - margin, height - margin)),
|
||||
radius,
|
||||
radius);
|
||||
}
|
||||
qreal height);
|
||||
};
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#include <QFontDatabase>
|
||||
#include <QIcon>
|
||||
#include <QMouseEvent>
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
#include <QResizeEvent>
|
||||
#include <QSignalTransition>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
#include <QPushButton>
|
||||
#include <QStateMachine>
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
|
||||
#include "FloatingButton.h"
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "LoadingIndicator.h"
|
||||
|
||||
#include <QPoint>
|
||||
#include <QtGlobal>
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
#include <QTimer>
|
||||
|
||||
LoadingIndicator::LoadingIndicator(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <QColor>
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
#include <QTimer>
|
||||
#include <QWidget>
|
||||
|
||||
class QPainter;
|
||||
class QTimer;
|
||||
class QPaintEvent;
|
||||
class LoadingIndicator : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "OverlayWidget.h"
|
||||
#include <QEvent>
|
||||
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
|
||||
OverlayWidget::OverlayWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <QEvent>
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
#include <QWidget>
|
||||
|
||||
class QPainter;
|
||||
|
||||
class OverlayWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
Loading…
Reference in a new issue