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
c431eee4
Commit
c431eee4
authored
8 years ago
by
Konstantinos Sideris
Browse files
Options
Downloads
Patches
Plain Diff
Use a single nick to color map
parent
5c964f32
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/HistoryView.h
+0
-5
0 additions, 5 deletions
include/HistoryView.h
include/HistoryViewManager.h
+4
-0
4 additions, 0 deletions
include/HistoryViewManager.h
src/HistoryView.cc
+4
-41
4 additions, 41 deletions
src/HistoryView.cc
src/HistoryViewManager.cc
+41
-1
41 additions, 1 deletion
src/HistoryViewManager.cc
with
49 additions
and
47 deletions
include/HistoryView.h
+
0
−
5
View file @
c431eee4
...
...
@@ -44,12 +44,8 @@ public slots:
void
sliderRangeChanged
(
int
min
,
int
max
);
private:
static
const
QList
<
QString
>
COLORS
;
void
init
();
QString
chooseRandomColor
();
QVBoxLayout
*
top_layout_
;
QVBoxLayout
*
scroll_layout_
;
...
...
@@ -57,7 +53,6 @@ private:
QWidget
*
scroll_widget_
;
QString
last_sender_
;
QMap
<
QString
,
QString
>
nick_colors_
;
};
#endif // HISTORY_VIEW_H
This diff is collapsed.
Click to expand it.
include/HistoryViewManager.h
+
4
−
0
View file @
c431eee4
...
...
@@ -38,6 +38,10 @@ public:
void
sync
(
const
Rooms
&
rooms
);
void
clearAll
();
static
QString
chooseRandomColor
();
static
QMap
<
QString
,
QString
>
NICK_COLORS
;
static
const
QList
<
QString
>
COLORS
;
public
slots
:
void
setHistoryView
(
const
RoomInfo
&
info
);
...
...
This diff is collapsed.
Click to expand it.
src/HistoryView.cc
+
4
−
41
View file @
c431eee4
...
...
@@ -15,8 +15,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include
<random>
#include
<QDebug>
#include
<QScrollBar>
#include
<QtWidgets/QLabel>
...
...
@@ -24,31 +22,7 @@
#include
"HistoryView.h"
#include
"HistoryViewItem.h"
const
QList
<
QString
>
HistoryView
::
COLORS
({
"#FFF46E"
,
"#A58BFF"
,
"#50C9BA"
,
"#9EE6CF"
,
"#FFDD67"
,
"#2980B9"
,
"#FC993C"
,
"#2772DB"
,
"#CB8589"
,
"#DDE8B9"
,
"#55A44E"
,
"#A9EEE6"
,
"#53B759"
,
"#9E3997"
,
"#5D89D5"
,
"#BB86B7"
,
"#50a0cf"
,
"#3C989F"
,
"#5A4592"
,
"#235e5b"
,
"#d58247"
,
"#e0a729"
,
"#a2b636"
,
"#4BBE2E"
});
#include
"HistoryViewManager.h"
HistoryView
::
HistoryView
(
const
QList
<
Event
>
&
events
,
QWidget
*
parent
)
:
QWidget
(
parent
)
...
...
@@ -65,8 +39,6 @@ HistoryView::HistoryView(QWidget *parent)
void
HistoryView
::
clear
()
{
nick_colors_
.
clear
();
for
(
const
auto
msg
:
scroll_layout_
->
children
())
msg
->
deleteLater
();
}
...
...
@@ -77,15 +49,6 @@ void HistoryView::sliderRangeChanged(int min, int max)
scroll_area_
->
verticalScrollBar
()
->
setValue
(
max
);
}
QString
HistoryView
::
chooseRandomColor
()
{
std
::
random_device
random_device
;
std
::
mt19937
engine
{
random_device
()};
std
::
uniform_int_distribution
<
int
>
dist
(
0
,
HistoryView
::
COLORS
.
size
()
-
1
);
return
HistoryView
::
COLORS
[
dist
(
engine
)];
}
void
HistoryView
::
addEvents
(
const
QList
<
Event
>
&
events
)
{
for
(
const
auto
&
event
:
events
)
{
...
...
@@ -94,11 +57,11 @@ void HistoryView::addEvents(const QList<Event> &events)
if
(
msg_type
==
"m.text"
||
msg_type
==
"m.notice"
)
{
auto
with_sender
=
last_sender_
!=
event
.
sender
();
auto
color
=
nick_colors_
.
value
(
event
.
sender
());
auto
color
=
HistoryViewManager
::
NICK_COLORS
.
value
(
event
.
sender
());
if
(
color
.
isEmpty
())
{
color
=
chooseRandomColor
();
nick_colors_
.
insert
(
event
.
sender
(),
color
);
color
=
HistoryViewManager
::
chooseRandomColor
();
HistoryViewManager
::
NICK_COLORS
.
insert
(
event
.
sender
(),
color
);
}
addHistoryItem
(
event
,
color
,
with_sender
);
...
...
This diff is collapsed.
Click to expand it.
src/HistoryViewManager.cc
+
41
−
1
View file @
c431eee4
...
...
@@ -15,6 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include
<random>
#include
<QDebug>
#include
<QStackedWidget>
#include
<QWidget>
...
...
@@ -39,7 +41,9 @@ HistoryViewManager::~HistoryViewManager()
void
HistoryViewManager
::
clearAll
()
{
for
(
const
auto
&
view
:
views_
)
{
NICK_COLORS
.
clear
();
for
(
const
auto
&
view
:
views_
)
{
view
->
clear
();
removeWidget
(
view
);
view
->
deleteLater
();
...
...
@@ -92,3 +96,39 @@ void HistoryViewManager::setHistoryView(const RoomInfo &info)
setCurrentWidget
(
widget
);
}
QMap
<
QString
,
QString
>
HistoryViewManager
::
NICK_COLORS
;
const
QList
<
QString
>
HistoryViewManager
::
COLORS
({
"#FFF46E"
,
"#A58BFF"
,
"#50C9BA"
,
"#9EE6CF"
,
"#FFDD67"
,
"#2980B9"
,
"#FC993C"
,
"#2772DB"
,
"#CB8589"
,
"#DDE8B9"
,
"#55A44E"
,
"#A9EEE6"
,
"#53B759"
,
"#9E3997"
,
"#5D89D5"
,
"#BB86B7"
,
"#50a0cf"
,
"#3C989F"
,
"#5A4592"
,
"#235e5b"
,
"#d58247"
,
"#e0a729"
,
"#a2b636"
,
"#4BBE2E"
});
QString
HistoryViewManager
::
chooseRandomColor
()
{
std
::
random_device
random_device
;
std
::
mt19937
engine
{
random_device
()};
std
::
uniform_int_distribution
<
int
>
dist
(
0
,
HistoryViewManager
::
COLORS
.
size
()
-
1
);
return
HistoryViewManager
::
COLORS
[
dist
(
engine
)];
}
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