add controll bits for avatar rounding
This commit is contained in:
parent
8a47388ec6
commit
b10d453bd5
@ -287,7 +287,11 @@ RoomInfoListItem::paintEvent(QPaintEvent *event)
|
||||
p.setPen(Qt::NoPen);
|
||||
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,
|
||||
AVATAR_RECT_ROUND,
|
||||
AVATAR_RECT_ROUND);
|
||||
|
||||
QFont bubbleFont;
|
||||
bubbleFont.setPointSizeF(bubbleFont.pointSizeF() * 1.4);
|
||||
@ -300,7 +304,12 @@ RoomInfoListItem::paintEvent(QPaintEvent *event)
|
||||
p.save();
|
||||
|
||||
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,
|
||||
AVATAR_RECT_ROUND,
|
||||
AVATAR_RECT_ROUND);
|
||||
|
||||
p.setClipPath(path);
|
||||
|
||||
p.drawPixmap(avatarRegion, roomAvatar_);
|
||||
@ -446,3 +455,9 @@ RoomInfoListItem::setDescriptionMessage(const DescInfo &info)
|
||||
lastMsgInfo_ = info;
|
||||
update();
|
||||
}
|
||||
|
||||
void
|
||||
RoomInfoListItem::setRounded(bool setting)
|
||||
{
|
||||
rounded_ = setting;
|
||||
}
|
||||
|
@ -109,6 +109,7 @@ public:
|
||||
void setTimestampColor(QColor &color) { timestampColor_ = color; }
|
||||
void setAvatarFgColor(QColor &color) { avatarFgColor_ = color; }
|
||||
void setAvatarBgColor(QColor &color) { avatarBgColor_ = color; }
|
||||
void setAvatarRounded(bool setting) { rounded_ = setting; }
|
||||
|
||||
void setHighlightedTitleColor(QColor &color) { highlightedTitleColor_ = color; }
|
||||
void setHighlightedSubtitleColor(QColor &color) { highlightedSubtitleColor_ = color; }
|
||||
@ -186,6 +187,7 @@ private:
|
||||
|
||||
bool isPressed_ = false;
|
||||
bool hasUnreadMessages_ = true;
|
||||
bool rounded_ = true;
|
||||
|
||||
int unreadMsgCount_ = 0;
|
||||
int unreadHighlightedMsgCount_ = 0;
|
||||
|
@ -53,6 +53,7 @@ UserSettings::load()
|
||||
isReadReceiptsEnabled_ = settings.value("user/read_receipts", true).toBool();
|
||||
theme_ = settings.value("user/theme", defaultTheme_).toString();
|
||||
font_ = settings.value("user/font_family", "default").toString();
|
||||
avatarCircles_ = settings.value("user/avatar/circles", true).toString();
|
||||
emojiFont_ = settings.value("user/emoji_font_family", "default").toString();
|
||||
baseFontSize_ = settings.value("user/font_size", QFont().pointSizeF()).toDouble();
|
||||
|
||||
@ -118,6 +119,10 @@ UserSettings::save()
|
||||
settings.setValue("start_in_tray", isStartInTrayEnabled_);
|
||||
settings.endGroup();
|
||||
|
||||
settings.startGroup("avatar");
|
||||
settings.setValue("circles", avatarCircles_);
|
||||
settings.endGroup();
|
||||
|
||||
settings.setValue("font_size", baseFontSize_);
|
||||
settings.setValue("typing_notifications", isTypingNotificationsEnabled_);
|
||||
settings.setValue("read_receipts", isReadReceiptsEnabled_);
|
||||
@ -192,6 +197,15 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
|
||||
groupViewLayout->addWidget(groupViewLabel);
|
||||
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_);
|
||||
|
||||
auto typingLayout = new QHBoxLayout;
|
||||
typingLayout->setContentsMargins(0, OptionMargin, 0, OptionMargin);
|
||||
auto typingLabel = new QLabel(tr("Typing notifications"), this);
|
||||
@ -369,6 +383,8 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
|
||||
mainLayout_->addWidget(new HorizontalLine(this));
|
||||
mainLayout_->addLayout(groupViewLayout);
|
||||
mainLayout_->addWidget(new HorizontalLine(this));
|
||||
mainLayout_->addWidget(avatarViewLayout);
|
||||
mainLayout_->addWidget(new HorizontalLine(this));
|
||||
mainLayout_->addLayout(typingLayout);
|
||||
mainLayout_->addLayout(receiptsLayout);
|
||||
mainLayout_->addLayout(desktopLayout);
|
||||
@ -448,6 +464,10 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
|
||||
settings_->setGroupView(!isDisabled);
|
||||
});
|
||||
|
||||
connect(groupViewToggle_, &Toggle::toggled, this, [this](bool isDisabled) {
|
||||
settings_->setRounded(!isDisabled);
|
||||
});
|
||||
|
||||
connect(typingNotifications_, &Toggle::toggled, this, [this](bool isDisabled) {
|
||||
settings_->setTypingNotifications(!isDisabled);
|
||||
});
|
||||
|
@ -86,6 +86,12 @@ public:
|
||||
save();
|
||||
}
|
||||
|
||||
void setAvatarCircles(bool state)
|
||||
{
|
||||
avatarCircles_ = state;
|
||||
save();
|
||||
}
|
||||
|
||||
QString theme() const { return !theme_.isEmpty() ? theme_ : defaultTheme_; }
|
||||
bool isTrayEnabled() const { return isTrayEnabled_; }
|
||||
bool isStartInTrayEnabled() const { return isStartInTrayEnabled_; }
|
||||
@ -93,6 +99,7 @@ public:
|
||||
bool isTypingNotificationsEnabled() const { return isTypingNotificationsEnabled_; }
|
||||
bool isReadReceiptsEnabled() const { return isReadReceiptsEnabled_; }
|
||||
bool hasDesktopNotifications() const { return hasDesktopNotifications_; }
|
||||
bool hasRoundedAvatars() const { return avatarCircles_; }
|
||||
double fontSize() const { return baseFontSize_; }
|
||||
QString font() const { return font_; }
|
||||
QString emojiFont() const { return emojiFont_; }
|
||||
@ -113,6 +120,7 @@ private:
|
||||
bool isTypingNotificationsEnabled_;
|
||||
bool isReadReceiptsEnabled_;
|
||||
bool hasDesktopNotifications_;
|
||||
bool avatarCircles_;
|
||||
double baseFontSize_;
|
||||
QString font_;
|
||||
QString emojiFont_;
|
||||
@ -162,6 +170,7 @@ private:
|
||||
Toggle *typingNotifications_;
|
||||
Toggle *readReceipts_;
|
||||
Toggle *desktopNotifications_;
|
||||
Toggle *avatarCircles_;
|
||||
QLabel *deviceFingerprintValue_;
|
||||
QLabel *deviceIdValue_;
|
||||
|
||||
|
1852
src/cscope.out
1852
src/cscope.out
File diff suppressed because it is too large
Load Diff
@ -104,11 +104,12 @@ Avatar::setIcon(const QIcon &icon)
|
||||
}
|
||||
|
||||
void
|
||||
Avatar::rounded(bool setting)
|
||||
Avatar::setRounded(bool setting)
|
||||
{
|
||||
rounded_ = setting;
|
||||
}
|
||||
|
||||
void
|
||||
Avatar::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
@ -45,5 +45,5 @@ private:
|
||||
QImage image_;
|
||||
QPixmap pixmap_;
|
||||
int size_;
|
||||
bool rounded_;
|
||||
bool rounded_ = true;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user