Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nheko
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nheko Reborn
nheko
Commits
8a329d65
Commit
8a329d65
authored
3 years ago
by
Loren Burkholder
Browse files
Options
Downloads
Patches
Plain Diff
Remove Avatar class
RIP
parent
0d42909e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
CMakeLists.txt
+0
-2
0 additions, 2 deletions
CMakeLists.txt
src/MemberList.cpp
+0
-1
0 additions, 1 deletion
src/MemberList.cpp
src/MemberList.h
+2
-1
2 additions, 1 deletion
src/MemberList.h
src/ui/Avatar.cpp
+0
-168
0 additions, 168 deletions
src/ui/Avatar.cpp
src/ui/Avatar.h
+0
-48
0 additions, 48 deletions
src/ui/Avatar.h
with
2 additions
and
220 deletions
CMakeLists.txt
+
0
−
2
View file @
8a329d65
...
...
@@ -304,7 +304,6 @@ set(SRC_FILES
src/timeline/RoomlistModel.cpp
# UI components
src/ui/Avatar.cpp
src/ui/Badge.cpp
src/ui/DropShadow.cpp
src/ui/FlatButton.cpp
...
...
@@ -516,7 +515,6 @@ qt5_wrap_cpp(MOC_HEADERS
src/timeline/RoomlistModel.h
# UI components
src/ui/Avatar.h
src/ui/Badge.h
src/ui/FlatButton.h
src/ui/FloatingButton.h
...
...
This diff is collapsed.
Click to expand it.
src/MemberList.cpp
+
0
−
1
View file @
8a329d65
...
...
@@ -20,7 +20,6 @@
#include
"Logging.h"
#include
"Utils.h"
#include
"timeline/TimelineViewManager.h"
#include
"ui/Avatar.h"
MemberList
::
MemberList
(
const
QString
&
room_id
,
QObject
*
parent
)
:
QAbstractListModel
{
parent
}
...
...
This diff is collapsed.
Click to expand it.
src/MemberList.h
+
2
−
1
View file @
8a329d65
...
...
@@ -4,9 +4,10 @@
#pragma once
#include
"CacheStructs.h"
#include
<QAbstractListModel>
#include
"CacheStructs.h"
class
MemberList
:
public
QAbstractListModel
{
Q_OBJECT
...
...
This diff is collapsed.
Click to expand it.
src/ui/Avatar.cpp
deleted
100644 → 0
+
0
−
168
View file @
0d42909e
// SPDX-FileCopyrightText: 2021 Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include
<QPainter>
#include
<QPainterPath>
#include
<QSettings>
#include
"AvatarProvider.h"
#include
"Utils.h"
#include
"ui/Avatar.h"
Avatar
::
Avatar
(
QWidget
*
parent
,
int
size
)
:
QWidget
(
parent
)
,
size_
(
size
)
{
type_
=
ui
::
AvatarType
::
Letter
;
letter_
=
"A"
;
QFont
_font
(
font
());
_font
.
setPointSizeF
(
ui
::
FontSize
);
setFont
(
_font
);
QSizePolicy
policy
(
QSizePolicy
::
MinimumExpanding
,
QSizePolicy
::
MinimumExpanding
);
setSizePolicy
(
policy
);
}
QColor
Avatar
::
textColor
()
const
{
if
(
!
text_color_
.
isValid
())
return
QColor
(
"black"
);
return
text_color_
;
}
QColor
Avatar
::
backgroundColor
()
const
{
if
(
!
text_color_
.
isValid
())
return
QColor
(
"white"
);
return
background_color_
;
}
QSize
Avatar
::
sizeHint
()
const
{
return
QSize
(
size_
+
2
,
size_
+
2
);
}
void
Avatar
::
setTextColor
(
const
QColor
&
color
)
{
text_color_
=
color
;
}
void
Avatar
::
setBackgroundColor
(
const
QColor
&
color
)
{
background_color_
=
color
;
}
void
Avatar
::
setLetter
(
const
QString
&
letter
)
{
letter_
=
letter
;
type_
=
ui
::
AvatarType
::
Letter
;
update
();
}
void
Avatar
::
setImage
(
const
QString
&
avatar_url
)
{
avatar_url_
=
avatar_url
;
AvatarProvider
::
resolve
(
avatar_url
,
static_cast
<
int
>
(
size_
*
pixmap_
.
devicePixelRatio
()),
this
,
[
this
,
requestedRatio
=
pixmap_
.
devicePixelRatio
()](
QPixmap
pm
)
{
if
(
pm
.
isNull
())
return
;
type_
=
ui
::
AvatarType
::
Image
;
pixmap_
=
pm
;
pixmap_
.
setDevicePixelRatio
(
requestedRatio
);
update
();
});
}
void
Avatar
::
setImage
(
const
QString
&
room
,
const
QString
&
user
)
{
room_
=
room
;
user_
=
user
;
AvatarProvider
::
resolve
(
room
,
user
,
static_cast
<
int
>
(
size_
*
pixmap_
.
devicePixelRatio
()),
this
,
[
this
,
requestedRatio
=
pixmap_
.
devicePixelRatio
()](
QPixmap
pm
)
{
if
(
pm
.
isNull
())
return
;
type_
=
ui
::
AvatarType
::
Image
;
pixmap_
=
pm
;
pixmap_
.
setDevicePixelRatio
(
requestedRatio
);
update
();
});
}
void
Avatar
::
setDevicePixelRatio
(
double
ratio
)
{
if
(
type_
==
ui
::
AvatarType
::
Image
&&
abs
(
pixmap_
.
devicePixelRatio
()
-
ratio
)
>
0.01
)
{
pixmap_
=
pixmap_
.
scaled
(
QSize
(
size_
,
size_
)
*
ratio
);
pixmap_
.
setDevicePixelRatio
(
ratio
);
if
(
!
avatar_url_
.
isEmpty
())
setImage
(
avatar_url_
);
else
setImage
(
room_
,
user_
);
}
}
void
Avatar
::
paintEvent
(
QPaintEvent
*
)
{
bool
rounded
=
QSettings
().
value
(
QStringLiteral
(
"user/avatar_circles"
),
true
).
toBool
();
QPainter
painter
(
this
);
painter
.
setRenderHints
(
QPainter
::
Antialiasing
|
QPainter
::
SmoothPixmapTransform
|
QPainter
::
TextAntialiasing
);
QRectF
r
=
rect
();
const
int
hs
=
size_
/
2
;
if
(
type_
!=
ui
::
AvatarType
::
Image
)
{
QBrush
brush
;
brush
.
setStyle
(
Qt
::
SolidPattern
);
brush
.
setColor
(
backgroundColor
());
painter
.
setPen
(
Qt
::
NoPen
);
painter
.
setBrush
(
brush
);
rounded
?
painter
.
drawEllipse
(
r
)
:
painter
.
drawRoundedRect
(
r
,
3
,
3
);
}
else
if
(
painter
.
isActive
())
{
setDevicePixelRatio
(
painter
.
device
()
->
devicePixelRatioF
());
}
switch
(
type_
)
{
case
ui
::
AvatarType
::
Image
:
{
QPainterPath
ppath
;
rounded
?
ppath
.
addEllipse
(
width
()
/
2
-
hs
,
height
()
/
2
-
hs
,
size_
,
size_
)
:
ppath
.
addRoundedRect
(
r
,
3
,
3
);
painter
.
setClipPath
(
ppath
);
painter
.
drawPixmap
(
QRect
(
width
()
/
2
-
hs
,
height
()
/
2
-
hs
,
size_
,
size_
),
pixmap_
);
break
;
}
case
ui
::
AvatarType
::
Letter
:
{
painter
.
setPen
(
textColor
());
painter
.
setBrush
(
Qt
::
NoBrush
);
painter
.
drawText
(
r
.
translated
(
0
,
-
1
),
Qt
::
AlignCenter
,
letter_
);
break
;
}
default
:
break
;
}
}
This diff is collapsed.
Click to expand it.
src/ui/Avatar.h
deleted
100644 → 0
+
0
−
48
View file @
0d42909e
// SPDX-FileCopyrightText: 2021 Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include
<QImage>
#include
<QPixmap>
#include
<QWidget>
#include
"Theme.h"
class
Avatar
:
public
QWidget
{
Q_OBJECT
Q_PROPERTY
(
QColor
textColor
WRITE
setTextColor
READ
textColor
)
Q_PROPERTY
(
QColor
backgroundColor
WRITE
setBackgroundColor
READ
backgroundColor
)
public:
explicit
Avatar
(
QWidget
*
parent
=
nullptr
,
int
size
=
ui
::
AvatarSize
);
void
setBackgroundColor
(
const
QColor
&
color
);
void
setImage
(
const
QString
&
avatar_url
);
void
setImage
(
const
QString
&
room
,
const
QString
&
user
);
void
setLetter
(
const
QString
&
letter
);
void
setTextColor
(
const
QColor
&
color
);
void
setDevicePixelRatio
(
double
ratio
);
QColor
backgroundColor
()
const
;
QColor
textColor
()
const
;
QSize
sizeHint
()
const
override
;
protected:
void
paintEvent
(
QPaintEvent
*
event
)
override
;
private:
void
init
();
ui
::
AvatarType
type_
;
QString
letter_
;
QString
avatar_url_
,
room_
,
user_
;
QColor
background_color_
;
QColor
text_color_
;
QPixmap
pixmap_
;
int
size_
;
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment