Skip to content

Commit 188a99d

Browse files
committed
made simple preview for userpic roundness (WIP)
1 parent 2e40fc0 commit 188a99d

File tree

5 files changed

+69
-1
lines changed

5 files changed

+69
-1
lines changed

Telegram/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,8 @@ PRIVATE
13361336
rabbit/settings_menu/rabbit_settings_menu.h
13371337
rabbit/ui/settings/icon_picker.cpp
13381338
rabbit/ui/settings/icon_picker.h
1339+
rabbit/ui/settings/previews.cpp
1340+
rabbit/ui/settings/previews.h
13391341
rabbit/ui/rabbit_assets.cpp
13401342
rabbit/ui/rabbit_assets.h
13411343
rabbit/utils/quiet_mode.cpp

Telegram/SourceFiles/rabbit/settings_menu/sections/rabbit_appearance.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ For license and copyright information please follow this link:
1111
#include "rabbit/lang/rabbit_lang.h"
1212
#include "rabbit/settings_menu/sections/rabbit_appearance.h"
1313
#include "rabbit/ui/settings/icon_picker.h"
14+
#include "rabbit/ui/settings/previews.h"
1415

1516
#include "lang_auto.h"
1617
#include "mainwindow.h"
@@ -73,6 +74,10 @@ namespace Settings {
7374

7475
void RabbitAppearance::SetupAppearance(not_null<Ui::VerticalLayout *> container) {
7576
Ui::AddSubsectionTitle(container, rktr("rtg_settings_appearance"));
77+
78+
const auto roundnessPreview = container->add(
79+
object_ptr<RoundnessPreview>(container),
80+
st::defaultSubsectionTitlePadding);
7681

7782
const auto userpicRoundnessLabel = container->add(
7883
object_ptr<Ui::LabelSimple>(
@@ -90,6 +95,8 @@ namespace Settings {
9095
};
9196
const auto updateUserpicRoundness = [=](int value) {
9297
updateUserpicRoundnessLabel(value);
98+
roundnessPreview->repaint();
99+
// NOTE: need to define roundnessPreview before repaint command?
93100
::RabbitSettings::JsonSettings::Set("userpic_roundness", value);
94101
::RabbitSettings::JsonSettings::Write();
95102
};
@@ -101,6 +108,10 @@ namespace Settings {
101108
updateUserpicRoundness);
102109
updateUserpicRoundnessLabel(::RabbitSettings::JsonSettings::GetInt("userpic_roundness"));
103110

111+
// const auto roundnessPreview = container->add(
112+
// object_ptr<RoundnessPreview>(container),
113+
// st::defaultSubsectionTitlePadding);
114+
104115
SettingsMenuJsonSwitch(rtg_general_roundness, general_roundness);
105116
}
106117

Telegram/SourceFiles/rabbit/ui/rabbit_styles.style

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ cpPenSize: 2px;
1818
cpImagePadding: 4px;
1919
cpSpacingX: 16px;
2020
cpSpacingY: 8px;
21-
cpIconSize: 64px;
21+
cpIconSize: 64px;
22+
23+
rndPreviewSize: 48px;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
This file is part of rabbitGram Desktop,
3+
the unofficial app based on Telegram Desktop.
4+
5+
For license and copyright information please follow this link:
6+
https://github.com/rabbitgramdesktop/rabbitgramdesktop/blob/dev/LEGAL
7+
*/
8+
#include "previews.h"
9+
#include "rabbit/settings/rabbit_settings.h"
10+
#include "core/application.h"
11+
#include "styles/style_layers.h"
12+
13+
#include "main/main_domain.h"
14+
#include "styles/style_rabbit_styles.h"
15+
#include "ui/painter.h"
16+
#include "window/main_window.h"
17+
18+
RoundnessPreview::RoundnessPreview(QWidget *parent) : RpWidget(parent) {
19+
auto size = st::rndPreviewSize + (2 * st::cpPenSize);
20+
setMinimumSize(st::boxWidth, size);
21+
}
22+
23+
void RoundnessPreview::paintEvent(QPaintEvent *e) {
24+
Painter p(this);
25+
PainterHighQualityEnabler hq(p);
26+
27+
auto radius = RabbitSettings::JsonSettings::GetInt("userpic_roundness") / 100.0 * st::rndPreviewSize;
28+
29+
p.setPen(QPen(st::iconPreviewStroke, st::cpPenSize));
30+
p.drawRoundedRect(
31+
st::cpPenSize, st::cpPenSize,
32+
st::rndPreviewSize, st::rndPreviewSize,
33+
radius, radius);
34+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
This file is part of rabbitGram Desktop,
3+
the unofficial app based on Telegram Desktop.
4+
5+
For license and copyright information please follow this link:
6+
https://github.com/rabbitgramdesktop/rabbitgramdesktop/blob/dev/LEGAL
7+
*/
8+
#pragma once
9+
10+
#include "ui/rp_widget.h"
11+
12+
class RoundnessPreview : public Ui::RpWidget
13+
{
14+
public:
15+
RoundnessPreview(QWidget *parent);
16+
17+
protected:
18+
void paintEvent(QPaintEvent *e) override;
19+
};

0 commit comments

Comments
 (0)