Merge branch '0.7.0-dev' of ssh://github.com/Nheko-Reborn/nheko into 0.7.0-dev

This commit is contained in:
Joseph Donofry 2019-09-06 16:03:54 -04:00
commit 8b33c51457
No known key found for this signature in database
GPG Key ID: E8A1D78EF044B0CB
6 changed files with 51 additions and 4 deletions

6
.gitignore vendored
View File

@ -1,8 +1,14 @@
build build
tags tags
cscope*
.clang_complete .clang_complete
*wintoastlib* *wintoastlib*
# GTAGS
GTAGS
GRTAGS
GPATH
# C++ objects and libs # C++ objects and libs
*.slo *.slo

View File

@ -19,6 +19,7 @@
#include <QDebug> #include <QDebug>
#include <QMouseEvent> #include <QMouseEvent>
#include <QPainter> #include <QPainter>
#include <QSettings>
#include <QtGlobal> #include <QtGlobal>
#include "AvatarProvider.h" #include "AvatarProvider.h"
@ -141,6 +142,8 @@ RoomInfoListItem::resizeEvent(QResizeEvent *)
void void
RoomInfoListItem::paintEvent(QPaintEvent *event) RoomInfoListItem::paintEvent(QPaintEvent *event)
{ {
bool rounded = QSettings().value("user/avatar/circles", true).toBool();
Q_UNUSED(event); Q_UNUSED(event);
QPainter p(this); QPainter p(this);
@ -288,7 +291,8 @@ RoomInfoListItem::paintEvent(QPaintEvent *event)
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
p.setBrush(brush); p.setBrush(brush);
p.drawEllipse(avatarRegion.center(), wm.iconSize / 2, wm.iconSize / 2); rounded ? p.drawEllipse(avatarRegion.center(), wm.iconSize / 2, wm.iconSize / 2)
: p.drawRoundedRect(avatarRegion, 3, 3);
QFont bubbleFont; QFont bubbleFont;
bubbleFont.setPointSizeF(bubbleFont.pointSizeF() * 1.4); bubbleFont.setPointSizeF(bubbleFont.pointSizeF() * 1.4);
@ -301,7 +305,9 @@ RoomInfoListItem::paintEvent(QPaintEvent *event)
p.save(); p.save();
QPainterPath path; QPainterPath path;
path.addEllipse(wm.padding, wm.padding, wm.iconSize, wm.iconSize); rounded ? path.addEllipse(wm.padding, wm.padding, wm.iconSize, wm.iconSize)
: path.addRoundedRect(avatarRegion, 3, 3);
p.setClipPath(path); p.setClipPath(path);
p.drawPixmap(avatarRegion, roomAvatar_); p.drawPixmap(avatarRegion, roomAvatar_);

View File

@ -1,3 +1,4 @@
/* /*
* nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr> * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
* *

View File

@ -53,6 +53,7 @@ UserSettings::load()
isReadReceiptsEnabled_ = settings.value("user/read_receipts", true).toBool(); isReadReceiptsEnabled_ = settings.value("user/read_receipts", true).toBool();
theme_ = settings.value("user/theme", defaultTheme_).toString(); theme_ = settings.value("user/theme", defaultTheme_).toString();
font_ = settings.value("user/font_family", "default").toString(); font_ = settings.value("user/font_family", "default").toString();
avatarCircles_ = settings.value("user/avatar/circles", true).toBool();
emojiFont_ = settings.value("user/emoji_font_family", "default").toString(); emojiFont_ = settings.value("user/emoji_font_family", "default").toString();
baseFontSize_ = settings.value("user/font_size", QFont().pointSizeF()).toDouble(); baseFontSize_ = settings.value("user/font_size", QFont().pointSizeF()).toDouble();
@ -118,6 +119,10 @@ UserSettings::save()
settings.setValue("start_in_tray", isStartInTrayEnabled_); settings.setValue("start_in_tray", isStartInTrayEnabled_);
settings.endGroup(); settings.endGroup();
settings.beginGroup("avatar");
settings.setValue("circles", avatarCircles_);
settings.endGroup();
settings.setValue("font_size", baseFontSize_); settings.setValue("font_size", baseFontSize_);
settings.setValue("typing_notifications", isTypingNotificationsEnabled_); settings.setValue("typing_notifications", isTypingNotificationsEnabled_);
settings.setValue("read_receipts", isReadReceiptsEnabled_); settings.setValue("read_receipts", isReadReceiptsEnabled_);
@ -192,6 +197,15 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
groupViewLayout->addWidget(groupViewLabel); groupViewLayout->addWidget(groupViewLabel);
groupViewLayout->addWidget(groupViewToggle_, 0, Qt::AlignRight); groupViewLayout->addWidget(groupViewToggle_, 0, Qt::AlignRight);
auto avatarViewLayout = new QHBoxLayout;
avatarViewLayout->setContentsMargins(0, OptionMargin, 0, OptionMargin);
auto avatarViewLabel = new QLabel(tr("Circular Avatars"), this);
avatarViewLabel->setFont(font);
avatarCircles_ = new Toggle(this);
avatarViewLayout->addWidget(avatarViewLabel);
avatarViewLayout->addWidget(avatarCircles_, 0, Qt::AlignRight);
auto typingLayout = new QHBoxLayout; auto typingLayout = new QHBoxLayout;
typingLayout->setContentsMargins(0, OptionMargin, 0, OptionMargin); typingLayout->setContentsMargins(0, OptionMargin, 0, OptionMargin);
auto typingLabel = new QLabel(tr("Typing notifications"), this); auto typingLabel = new QLabel(tr("Typing notifications"), this);
@ -368,6 +382,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
mainLayout_->addLayout(startInTrayOptionLayout_); mainLayout_->addLayout(startInTrayOptionLayout_);
mainLayout_->addWidget(new HorizontalLine(this)); mainLayout_->addWidget(new HorizontalLine(this));
mainLayout_->addLayout(groupViewLayout); mainLayout_->addLayout(groupViewLayout);
mainLayout_->addLayout(avatarViewLayout);
mainLayout_->addWidget(new HorizontalLine(this)); mainLayout_->addWidget(new HorizontalLine(this));
mainLayout_->addLayout(typingLayout); mainLayout_->addLayout(typingLayout);
mainLayout_->addLayout(receiptsLayout); mainLayout_->addLayout(receiptsLayout);
@ -448,6 +463,10 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
settings_->setGroupView(!isDisabled); settings_->setGroupView(!isDisabled);
}); });
connect(avatarCircles_, &Toggle::toggled, this, [this](bool isDisabled) {
settings_->setAvatarCircles(!isDisabled);
});
connect(typingNotifications_, &Toggle::toggled, this, [this](bool isDisabled) { connect(typingNotifications_, &Toggle::toggled, this, [this](bool isDisabled) {
settings_->setTypingNotifications(!isDisabled); settings_->setTypingNotifications(!isDisabled);
}); });

View File

@ -86,6 +86,12 @@ public:
save(); save();
} }
void setAvatarCircles(bool state)
{
avatarCircles_ = state;
save();
}
QString theme() const { return !theme_.isEmpty() ? theme_ : defaultTheme_; } QString theme() const { return !theme_.isEmpty() ? theme_ : defaultTheme_; }
bool isTrayEnabled() const { return isTrayEnabled_; } bool isTrayEnabled() const { return isTrayEnabled_; }
bool isStartInTrayEnabled() const { return isStartInTrayEnabled_; } bool isStartInTrayEnabled() const { return isStartInTrayEnabled_; }
@ -113,6 +119,7 @@ private:
bool isTypingNotificationsEnabled_; bool isTypingNotificationsEnabled_;
bool isReadReceiptsEnabled_; bool isReadReceiptsEnabled_;
bool hasDesktopNotifications_; bool hasDesktopNotifications_;
bool avatarCircles_;
double baseFontSize_; double baseFontSize_;
QString font_; QString font_;
QString emojiFont_; QString emojiFont_;
@ -162,6 +169,7 @@ private:
Toggle *typingNotifications_; Toggle *typingNotifications_;
Toggle *readReceipts_; Toggle *readReceipts_;
Toggle *desktopNotifications_; Toggle *desktopNotifications_;
Toggle *avatarCircles_;
QLabel *deviceFingerprintValue_; QLabel *deviceFingerprintValue_;
QLabel *deviceIdValue_; QLabel *deviceIdValue_;

View File

@ -1,4 +1,5 @@
#include <QPainter> #include <QPainter>
#include <QSettings>
#include "AvatarProvider.h" #include "AvatarProvider.h"
#include "Utils.h" #include "Utils.h"
@ -100,6 +101,8 @@ Avatar::setIcon(const QIcon &icon)
void void
Avatar::paintEvent(QPaintEvent *) Avatar::paintEvent(QPaintEvent *)
{ {
bool rounded = QSettings().value("user/avatar/circles", true).toBool();
QPainter painter(this); QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::Antialiasing);
@ -113,7 +116,8 @@ Avatar::paintEvent(QPaintEvent *)
painter.setPen(Qt::NoPen); painter.setPen(Qt::NoPen);
painter.setBrush(brush); painter.setBrush(brush);
painter.drawEllipse(r.center(), hs, hs); rounded ? painter.drawEllipse(r.center(), hs, hs)
: painter.drawRoundedRect(r, 3, 3);
} }
switch (type_) { switch (type_) {
@ -126,7 +130,10 @@ Avatar::paintEvent(QPaintEvent *)
} }
case ui::AvatarType::Image: { case ui::AvatarType::Image: {
QPainterPath ppath; QPainterPath ppath;
ppath.addEllipse(width() / 2 - hs, height() / 2 - hs, size_, size_);
rounded ? ppath.addEllipse(width() / 2 - hs, height() / 2 - hs, size_, size_)
: ppath.addRoundedRect(r, 3, 3);
painter.setClipPath(ppath); painter.setClipPath(ppath);
painter.drawPixmap(QRect(width() / 2 - hs, height() / 2 - hs, size_, size_), painter.drawPixmap(QRect(width() / 2 - hs, height() / 2 - hs, size_, size_),
pixmap_); pixmap_);