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
6c65213c
Commit
6c65213c
authored
6 years ago
by
Konstantinos Sideris
Browse files
Options
Downloads
Patches
Plain Diff
Reuse the profile modal & adjust its spacing relative to the font size
parent
54c7eb37
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/MainWindow.cpp
+8
-4
8 additions, 4 deletions
src/MainWindow.cpp
src/dialogs/UserProfile.cpp
+47
-16
47 additions, 16 deletions
src/dialogs/UserProfile.cpp
src/dialogs/UserProfile.h
+4
-2
4 additions, 2 deletions
src/dialogs/UserProfile.h
with
59 additions
and
22 deletions
src/MainWindow.cpp
+
8
−
4
View file @
6c65213c
...
...
@@ -312,13 +312,17 @@ MainWindow::hasActiveUser()
void
MainWindow
::
openUserProfile
(
const
QString
&
user_id
,
const
QString
&
room_id
)
{
userProfileDialog_
=
QSharedPointer
<
dialogs
::
UserProfile
>
(
new
dialogs
::
UserProfile
(
this
));
if
(
!
userProfileDialog_
)
userProfileDialog_
=
QSharedPointer
<
dialogs
::
UserProfile
>
(
new
dialogs
::
UserProfile
(
this
));
userProfileDialog_
->
init
(
user_id
,
room_id
);
userProfileModal_
=
QSharedPointer
<
OverlayModal
>
(
new
OverlayModal
(
this
,
userProfileDialog_
.
data
()));
userProfileModal_
->
setContentAlignment
(
Qt
::
AlignTop
|
Qt
::
AlignHCenter
);
if
(
!
userProfileModal_
)
userProfileModal_
=
QSharedPointer
<
OverlayModal
>
(
new
OverlayModal
(
this
,
userProfileDialog_
.
data
())
);
userProfileModal_
->
setContentAlignment
(
Qt
::
AlignTop
|
Qt
::
AlignHCenter
);
userProfileModal_
->
show
();
}
...
...
This diff is collapsed.
Click to expand it.
src/dialogs/UserProfile.cpp
+
47
−
16
View file @
6c65213c
...
...
@@ -17,7 +17,13 @@
using
namespace
dialogs
;
constexpr
int
BUTTON_SIZE
=
36
;
constexpr
int
BUTTON_SIZE
=
36
;
constexpr
int
BUTTON_RADIUS
=
BUTTON_SIZE
/
2
;
constexpr
int
WIDGET_MARGIN
=
20
;
constexpr
int
TOP_WIDGET_MARGIN
=
2
*
WIDGET_MARGIN
;
constexpr
int
WIDGET_SPACING
=
15
;
constexpr
int
TEXT_SPACING
=
4
;
constexpr
int
DEVICE_SPACING
=
5
;
DeviceItem
::
DeviceItem
(
DeviceInfo
device
,
QWidget
*
parent
)
:
QWidget
(
parent
)
...
...
@@ -47,36 +53,36 @@ UserProfile::UserProfile(QWidget *parent)
banIcon
.
addFile
(
":/icons/icons/ui/do-not-disturb-rounded-sign.png"
);
banBtn_
=
new
FlatButton
(
this
);
banBtn_
->
setFixedSize
(
BUTTON_SIZE
,
BUTTON_SIZE
);
banBtn_
->
setCornerRadius
(
BUTTON_
SIZE
/
2
);
banBtn_
->
setCornerRadius
(
BUTTON_
RADIUS
);
banBtn_
->
setIcon
(
banIcon
);
banBtn_
->
setIconSize
(
QSize
(
BUTTON_
SIZE
/
2
,
BUTTON_
SIZE
/
2
));
banBtn_
->
setIconSize
(
QSize
(
BUTTON_
RADIUS
,
BUTTON_
RADIUS
));
banBtn_
->
setToolTip
(
tr
(
"Ban the user from the room"
));
banBtn_
->
setDisabled
(
true
);
// Not used yet.
ignoreIcon
.
addFile
(
":/icons/icons/ui/volume-off-indicator.png"
);
ignoreBtn_
=
new
FlatButton
(
this
);
ignoreBtn_
->
setFixedSize
(
BUTTON_SIZE
,
BUTTON_SIZE
);
ignoreBtn_
->
setCornerRadius
(
BUTTON_
SIZE
/
2
);
ignoreBtn_
->
setCornerRadius
(
BUTTON_
RADIUS
);
ignoreBtn_
->
setIcon
(
ignoreIcon
);
ignoreBtn_
->
setIconSize
(
QSize
(
BUTTON_
SIZE
/
2
,
BUTTON_
SIZE
/
2
));
ignoreBtn_
->
setIconSize
(
QSize
(
BUTTON_
RADIUS
,
BUTTON_
RADIUS
));
ignoreBtn_
->
setToolTip
(
tr
(
"Ignore messages from this user"
));
ignoreBtn_
->
setDisabled
(
true
);
// Not used yet.
kickIcon
.
addFile
(
":/icons/icons/ui/round-remove-button.png"
);
kickBtn_
=
new
FlatButton
(
this
);
kickBtn_
->
setFixedSize
(
BUTTON_SIZE
,
BUTTON_SIZE
);
kickBtn_
->
setCornerRadius
(
BUTTON_
SIZE
/
2
);
kickBtn_
->
setCornerRadius
(
BUTTON_
RADIUS
);
kickBtn_
->
setIcon
(
kickIcon
);
kickBtn_
->
setIconSize
(
QSize
(
BUTTON_
SIZE
/
2
,
BUTTON_
SIZE
/
2
));
kickBtn_
->
setIconSize
(
QSize
(
BUTTON_
RADIUS
,
BUTTON_
RADIUS
));
kickBtn_
->
setToolTip
(
tr
(
"Kick the user from the room"
));
kickBtn_
->
setDisabled
(
true
);
// Not used yet.
startChatIcon
.
addFile
(
":/icons/icons/ui/black-bubble-speech.png"
);
startChat_
=
new
FlatButton
(
this
);
startChat_
->
setFixedSize
(
BUTTON_SIZE
,
BUTTON_SIZE
);
startChat_
->
setCornerRadius
(
BUTTON_
SIZE
/
2
);
startChat_
->
setCornerRadius
(
BUTTON_
RADIUS
);
startChat_
->
setIcon
(
startChatIcon
);
startChat_
->
setIconSize
(
QSize
(
BUTTON_
SIZE
/
2
,
BUTTON_
SIZE
/
2
));
startChat_
->
setIconSize
(
QSize
(
BUTTON_
RADIUS
,
BUTTON_
RADIUS
));
startChat_
->
setToolTip
(
tr
(
"Start a conversation"
));
connect
(
startChat_
,
&
QPushButton
::
clicked
,
this
,
[
this
]()
{
...
...
@@ -120,14 +126,14 @@ UserProfile::UserProfile(QWidget *parent)
textLayout
->
addWidget
(
userIdLabel_
);
textLayout
->
setAlignment
(
displayNameLabel_
,
Qt
::
AlignCenter
|
Qt
::
AlignTop
);
textLayout
->
setAlignment
(
userIdLabel_
,
Qt
::
AlignCenter
|
Qt
::
AlignTop
);
textLayout
->
setSpacing
(
4
);
textLayout
->
setSpacing
(
TEXT_SPACING
);
textLayout
->
setMargin
(
0
);
devices_
=
new
QListWidget
{
this
};
devices_
->
setFrameStyle
(
QFrame
::
NoFrame
);
devices_
->
setSelectionMode
(
QAbstractItemView
::
NoSelection
);
devices_
->
setAttribute
(
Qt
::
WA_MacShowFocusRect
,
0
);
devices_
->
setSpacing
(
5
);
devices_
->
setSpacing
(
DEVICE_SPACING
);
devices_
->
hide
();
QFont
descriptionLabelFont
;
...
...
@@ -143,6 +149,7 @@ UserProfile::UserProfile(QWidget *parent)
vlayout
->
addLayout
(
btnLayout
);
vlayout
->
addWidget
(
devicesLabel_
,
Qt
::
AlignLeft
);
vlayout
->
addWidget
(
devices_
);
vlayout
->
addStretch
(
1
);
vlayout
->
setAlignment
(
avatar_
,
Qt
::
AlignCenter
|
Qt
::
AlignTop
);
vlayout
->
setAlignment
(
userIdLabel_
,
Qt
::
AlignCenter
|
Qt
::
AlignTop
);
...
...
@@ -151,20 +158,38 @@ UserProfile::UserProfile(QWidget *parent)
setWindowFlags
(
Qt
::
Tool
|
Qt
::
WindowStaysOnTopHint
);
setWindowModality
(
Qt
::
WindowModal
);
setMinimumWidth
(
340
);
QFont
doubleFont
;
doubleFont
.
setPointSizeF
(
doubleFont
.
pointSizeF
()
*
2
);
setMinimumWidth
(
std
::
max
(
devices_
->
sizeHint
().
width
()
+
4
*
WIDGET_MARGIN
,
QFontMetrics
(
doubleFont
).
averageCharWidth
()
*
30
-
2
*
WIDGET_MARGIN
));
setSizePolicy
(
QSizePolicy
::
Maximum
,
QSizePolicy
::
Maximum
);
vlayout
->
setSpacing
(
15
);
vlayout
->
setContentsMargins
(
20
,
40
,
20
,
20
);
vlayout
->
setSpacing
(
WIDGET_SPACING
);
vlayout
->
setContentsMargins
(
WIDGET_MARGIN
,
TOP_WIDGET_MARGIN
,
WIDGET_MARGIN
,
WIDGET_MARGIN
);
qRegisterMetaType
<
std
::
vector
<
DeviceInfo
>>
();
connect
(
this
,
&
UserProfile
::
devicesRetrieved
,
this
,
&
UserProfile
::
updateDeviceList
);
}
void
UserProfile
::
resetToDefaults
()
{
avatar_
->
setLetter
(
"X"
);
devices_
->
clear
();
ignoreBtn_
->
show
();
devices_
->
hide
();
devicesLabel_
->
hide
();
}
void
UserProfile
::
init
(
const
QString
&
userId
,
const
QString
&
roomId
)
{
resetToDefaults
();
auto
displayName
=
Cache
::
displayName
(
roomId
,
userId
);
userIdLabel_
->
setText
(
userId
);
...
...
@@ -184,6 +209,9 @@ UserProfile::init(const QString &userId, const QString &roomId)
if
(
!
hasMemberRights
)
{
kickBtn_
->
hide
();
banBtn_
->
hide
();
}
else
{
kickBtn_
->
show
();
banBtn_
->
show
();
}
}
catch
(
const
lmdb
::
error
&
e
)
{
nhlog
::
db
()
->
warn
(
"lmdb error: {}"
,
e
.
what
());
...
...
@@ -236,13 +264,16 @@ UserProfile::init(const QString &userId, const QString &roomId)
});
if
(
!
deviceInfo
.
empty
())
emit
devicesRetrieved
(
deviceInfo
);
emit
devicesRetrieved
(
QString
::
fromStdString
(
user_id
),
deviceInfo
);
});
}
void
UserProfile
::
updateDeviceList
(
const
std
::
vector
<
DeviceInfo
>
&
devices
)
UserProfile
::
updateDeviceList
(
const
QString
&
user_id
,
const
std
::
vector
<
DeviceInfo
>
&
devices
)
{
if
(
user_id
!=
userIdLabel_
->
text
())
return
;
for
(
const
auto
&
dev
:
devices
)
{
auto
deviceItem
=
new
DeviceItem
(
dev
,
this
);
auto
item
=
new
QListWidgetItem
;
...
...
This diff is collapsed.
Click to expand it.
src/dialogs/UserProfile.h
+
4
−
2
View file @
6c65213c
...
...
@@ -44,12 +44,14 @@ protected:
void
paintEvent
(
QPaintEvent
*
)
override
;
signals:
void
devicesRetrieved
(
const
std
::
vector
<
DeviceInfo
>
&
devices
);
void
devicesRetrieved
(
const
QString
&
user_id
,
const
std
::
vector
<
DeviceInfo
>
&
devices
);
private
slots
:
void
updateDeviceList
(
const
std
::
vector
<
DeviceInfo
>
&
devices
);
void
updateDeviceList
(
const
QString
&
user_id
,
const
std
::
vector
<
DeviceInfo
>
&
devices
);
private:
void
resetToDefaults
();
Avatar
*
avatar_
;
QLabel
*
userIdLabel_
;
...
...
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