mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-12 13:00:01 -08:00
Buddy stars
Buddies will show as a star in the chat. Please test. Does the chat feel slower? Mine feels slow, though I am overseas.
This commit is contained in:
parent
739ca6a02e
commit
748e8ce75f
12 changed files with 501 additions and 92 deletions
|
|
@ -322,6 +322,10 @@
|
||||||
<file>resources/userlevels/registered.svg</file>
|
<file>resources/userlevels/registered.svg</file>
|
||||||
<file>resources/userlevels/moderator.svg</file>
|
<file>resources/userlevels/moderator.svg</file>
|
||||||
<file>resources/userlevels/admin.svg</file>
|
<file>resources/userlevels/admin.svg</file>
|
||||||
|
|
||||||
|
<file>resources/userlevels/registered_buddy.svg</file>
|
||||||
|
<file>resources/userlevels/admin_buddy.svg</file>
|
||||||
|
<file>resources/userlevels/moderator_buddy.svg</file>
|
||||||
|
|
||||||
<file>resources/news/exclamation_mark.svg</file>
|
<file>resources/news/exclamation_mark.svg</file>
|
||||||
<file>resources/news/question_mark.svg</file>
|
<file>resources/news/question_mark.svg</file>
|
||||||
|
|
|
||||||
125
cockatrice/resources/userlevels/admin_buddy.svg
Normal file
125
cockatrice/resources/userlevels/admin_buddy.svg
Normal file
|
|
@ -0,0 +1,125 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
viewBox="0 0 64 64"
|
||||||
|
enable-background="new 0 0 64 64"
|
||||||
|
id="svg2"
|
||||||
|
version="1.1"
|
||||||
|
inkscape:version="0.48.5 r10040"
|
||||||
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
sodipodi:docname="admin_buddy.svg">
|
||||||
|
<metadata
|
||||||
|
id="metadata12">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<defs
|
||||||
|
id="defs10">
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient5225">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#ffffff;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop5227" />
|
||||||
|
<stop
|
||||||
|
style="stop-color:#ffffff;stop-opacity:0;"
|
||||||
|
offset="1"
|
||||||
|
id="stop5229" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient5219"
|
||||||
|
osb:paint="solid">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#ffffff;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop5221" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient3758">
|
||||||
|
<stop
|
||||||
|
id="stop3760"
|
||||||
|
offset="0"
|
||||||
|
style="stop-color:#0fbb00;stop-opacity:1;" />
|
||||||
|
<stop
|
||||||
|
id="stop3762"
|
||||||
|
offset="1"
|
||||||
|
style="stop-color:#064400;stop-opacity:1;" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient3750">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#ece400;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop3752" />
|
||||||
|
<stop
|
||||||
|
style="stop-color:#ece400;stop-opacity:0;"
|
||||||
|
offset="1"
|
||||||
|
id="stop3754" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#linearGradient3758-7"
|
||||||
|
id="linearGradient3756-1"
|
||||||
|
x1="1.960216"
|
||||||
|
y1="31.261461"
|
||||||
|
x2="60.456024"
|
||||||
|
y2="31.261461"
|
||||||
|
gradientUnits="userSpaceOnUse" />
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient3758-7">
|
||||||
|
<stop
|
||||||
|
id="stop3760-4"
|
||||||
|
offset="0"
|
||||||
|
style="stop-color:#ece400;stop-opacity:1;" />
|
||||||
|
<stop
|
||||||
|
id="stop3762-0"
|
||||||
|
offset="1"
|
||||||
|
style="stop-color:#ec8b00;stop-opacity:1;" />
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
<sodipodi:namedview
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1"
|
||||||
|
objecttolerance="10"
|
||||||
|
gridtolerance="10"
|
||||||
|
guidetolerance="10"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="1028"
|
||||||
|
id="namedview8"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:zoom="5.2149125"
|
||||||
|
inkscape:cx="21.988178"
|
||||||
|
inkscape:cy="51.245759"
|
||||||
|
inkscape:window-x="-8"
|
||||||
|
inkscape:window-y="-8"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="svg2" />
|
||||||
|
<path
|
||||||
|
d="M 61.442826,23.621762 38.532402,23.515555 31.556101,0.331013 24.578789,23.515555 1.6673502,23.621765 20.267785,38.422001 10.863888,63.668987 31.556101,47.626631 52.258426,63.668987 42.843404,38.422001 z"
|
||||||
|
id="path4-9"
|
||||||
|
style="fill:#000000;fill-opacity:1"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
d="M 57.150089,25.064396 37.504323,24.973324 31.522122,5.092503 25.539054,24.973324 5.8924192,25.064399 21.842354,37.75565 13.778482,59.405024 31.522122,45.64865 49.274434,59.405024 41.201022,37.75565 z"
|
||||||
|
id="path4"
|
||||||
|
style="fill:#ff0000;fill-opacity:1;fill-rule:nonzero"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 3.8 KiB |
147
cockatrice/resources/userlevels/moderator_buddy.svg
Normal file
147
cockatrice/resources/userlevels/moderator_buddy.svg
Normal file
|
|
@ -0,0 +1,147 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
viewBox="0 0 64 64"
|
||||||
|
enable-background="new 0 0 64 64"
|
||||||
|
id="svg2"
|
||||||
|
version="1.1"
|
||||||
|
inkscape:version="0.48.5 r10040"
|
||||||
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
sodipodi:docname="registered_buddy - Copy.svg">
|
||||||
|
<metadata
|
||||||
|
id="metadata12">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<defs
|
||||||
|
id="defs10">
|
||||||
|
<pattern
|
||||||
|
inkscape:stockid="Stripes 1:1 white"
|
||||||
|
id="Strips1_1white"
|
||||||
|
patternTransform="translate(0,0) scale(10,10)"
|
||||||
|
height="1"
|
||||||
|
width="2"
|
||||||
|
patternUnits="userSpaceOnUse"
|
||||||
|
inkscape:collect="always">
|
||||||
|
<rect
|
||||||
|
id="rect4484"
|
||||||
|
height="2"
|
||||||
|
width="1"
|
||||||
|
y="-0.5"
|
||||||
|
x="0"
|
||||||
|
style="fill:white;stroke:none" />
|
||||||
|
</pattern>
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient5225">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#ffffff;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop5227" />
|
||||||
|
<stop
|
||||||
|
style="stop-color:#ffffff;stop-opacity:0;"
|
||||||
|
offset="1"
|
||||||
|
id="stop5229" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient5219"
|
||||||
|
osb:paint="solid">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#ffffff;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop5221" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient3758">
|
||||||
|
<stop
|
||||||
|
id="stop3760"
|
||||||
|
offset="0"
|
||||||
|
style="stop-color:#0fbb00;stop-opacity:1;" />
|
||||||
|
<stop
|
||||||
|
id="stop3762"
|
||||||
|
offset="1"
|
||||||
|
style="stop-color:#064400;stop-opacity:1;" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient3750">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#ece400;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop3752" />
|
||||||
|
<stop
|
||||||
|
style="stop-color:#ece400;stop-opacity:0;"
|
||||||
|
offset="1"
|
||||||
|
id="stop3754" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#linearGradient3758-7"
|
||||||
|
id="linearGradient3756-1"
|
||||||
|
x1="1.960216"
|
||||||
|
y1="31.261461"
|
||||||
|
x2="60.456024"
|
||||||
|
y2="31.261461"
|
||||||
|
gradientUnits="userSpaceOnUse" />
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient3758-7">
|
||||||
|
<stop
|
||||||
|
id="stop3760-4"
|
||||||
|
offset="0"
|
||||||
|
style="stop-color:#ece400;stop-opacity:1;" />
|
||||||
|
<stop
|
||||||
|
id="stop3762-0"
|
||||||
|
offset="1"
|
||||||
|
style="stop-color:#ec8b00;stop-opacity:1;" />
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
<sodipodi:namedview
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1"
|
||||||
|
objecttolerance="10"
|
||||||
|
gridtolerance="10"
|
||||||
|
guidetolerance="10"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="1028"
|
||||||
|
id="namedview8"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:zoom="5.2149125"
|
||||||
|
inkscape:cx="51.90239"
|
||||||
|
inkscape:cy="51.245759"
|
||||||
|
inkscape:window-x="-8"
|
||||||
|
inkscape:window-y="-8"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="svg2" />
|
||||||
|
<path
|
||||||
|
d="M 61.442826,23.621762 38.532402,23.515555 31.556101,0.331013 24.578789,23.515555 1.6673502,23.621765 20.267785,38.422001 10.863888,63.668987 31.556101,47.626631 52.258426,63.668987 42.843404,38.422001 z"
|
||||||
|
id="path4-9"
|
||||||
|
style="fill:#000000;fill-opacity:1"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
d="M 57.150089,25.064396 37.504323,24.973324 31.522122,5.092503 25.539054,24.973324 5.8924192,25.064399 21.842354,37.75565 13.778482,59.405024 31.522122,45.64865 49.274434,59.405024 41.201022,37.75565 z"
|
||||||
|
id="path4"
|
||||||
|
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
d="M 57.165891,25.072777 37.520125,24.981707 31.537924,5.1008868 c 0.05101,40.5880862 0.05344,-0.1118618 0,40.5561512 L 49.290236,59.413412 41.216824,37.764038 z"
|
||||||
|
id="path4-1"
|
||||||
|
style="fill:#000000;fill-opacity:1;fill-rule:nonzero"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="ccccccc" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 4.5 KiB |
115
cockatrice/resources/userlevels/registered_buddy.svg
Normal file
115
cockatrice/resources/userlevels/registered_buddy.svg
Normal file
|
|
@ -0,0 +1,115 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
viewBox="0 0 64 64"
|
||||||
|
enable-background="new 0 0 64 64"
|
||||||
|
id="svg2"
|
||||||
|
version="1.1"
|
||||||
|
inkscape:version="0.48.5 r10040"
|
||||||
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
sodipodi:docname="buddy_icon.svg">
|
||||||
|
<metadata
|
||||||
|
id="metadata12">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<defs
|
||||||
|
id="defs10">
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient3758">
|
||||||
|
<stop
|
||||||
|
id="stop3760"
|
||||||
|
offset="0"
|
||||||
|
style="stop-color:#0fbb00;stop-opacity:1;" />
|
||||||
|
<stop
|
||||||
|
id="stop3762"
|
||||||
|
offset="1"
|
||||||
|
style="stop-color:#064400;stop-opacity:1;" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient3750">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#ece400;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop3752" />
|
||||||
|
<stop
|
||||||
|
style="stop-color:#ece400;stop-opacity:0;"
|
||||||
|
offset="1"
|
||||||
|
id="stop3754" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#linearGradient3758"
|
||||||
|
id="linearGradient3756"
|
||||||
|
x1="1.960216"
|
||||||
|
y1="31.261461"
|
||||||
|
x2="60.456024"
|
||||||
|
y2="31.261461"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
gradientTransform="matrix(0.87626222,0,0,0.87626222,4.174756,4.8555263)" />
|
||||||
|
<linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#linearGradient3758-7"
|
||||||
|
id="linearGradient3756-1"
|
||||||
|
x1="1.960216"
|
||||||
|
y1="31.261461"
|
||||||
|
x2="60.456024"
|
||||||
|
y2="31.261461"
|
||||||
|
gradientUnits="userSpaceOnUse" />
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient3758-7">
|
||||||
|
<stop
|
||||||
|
id="stop3760-4"
|
||||||
|
offset="0"
|
||||||
|
style="stop-color:#ece400;stop-opacity:1;" />
|
||||||
|
<stop
|
||||||
|
id="stop3762-0"
|
||||||
|
offset="1"
|
||||||
|
style="stop-color:#ec8b00;stop-opacity:1;" />
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
<sodipodi:namedview
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1"
|
||||||
|
objecttolerance="10"
|
||||||
|
gridtolerance="10"
|
||||||
|
guidetolerance="10"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:window-width="1600"
|
||||||
|
inkscape:window-height="1178"
|
||||||
|
id="namedview8"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:zoom="7.375"
|
||||||
|
inkscape:cx="-14.986549"
|
||||||
|
inkscape:cy="23.31428"
|
||||||
|
inkscape:window-x="1912"
|
||||||
|
inkscape:window-y="227"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="svg2" />
|
||||||
|
<path
|
||||||
|
d="M 61.442826,23.621762 38.532402,23.515555 31.556101,0.331013 24.578789,23.515555 1.6673502,23.621765 20.267785,38.422001 10.863888,63.668987 31.556101,47.626631 52.258426,63.668987 42.843404,38.422001 z"
|
||||||
|
id="path4-9"
|
||||||
|
style="fill:#000000;fill-opacity:1"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
d="M 57.150089,25.064396 37.504323,24.973324 31.522122,5.092503 25.539054,24.973324 5.8924192,25.064399 21.842354,37.75565 13.778482,59.405024 31.522122,45.64865 49.274434,59.405024 41.201022,37.75565 z"
|
||||||
|
id="path4"
|
||||||
|
style="fill:url(#linearGradient3756);fill-opacity:1"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 3.6 KiB |
|
|
@ -9,8 +9,10 @@
|
||||||
#include "pixmapgenerator.h"
|
#include "pixmapgenerator.h"
|
||||||
#include "settingscache.h"
|
#include "settingscache.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "userlist.h"
|
||||||
#include "tab_userlists.h"
|
#include "tab_userlists.h"
|
||||||
|
|
||||||
|
const QColor OTHER_USER_MENTION_COLOR = QColor(145, 210, 255); // light blue
|
||||||
const QColor MENTION_COLOR = QColor(190, 25, 85); // maroon
|
const QColor MENTION_COLOR = QColor(190, 25, 85); // maroon
|
||||||
const QColor OTHER_USER_COLOR = QColor(0, 65, 255); // dark blue
|
const QColor OTHER_USER_COLOR = QColor(0, 65, 255); // dark blue
|
||||||
|
|
||||||
|
|
@ -20,7 +22,7 @@ ChatView::ChatView(const TabSupervisor *_tabSupervisor, TabGame *_game, bool _sh
|
||||||
document()->setDefaultStyleSheet("a { text-decoration: none; color: blue; }");
|
document()->setDefaultStyleSheet("a { text-decoration: none; color: blue; }");
|
||||||
userContextMenu = new UserContextMenu(tabSupervisor, this, game);
|
userContextMenu = new UserContextMenu(tabSupervisor, this, game);
|
||||||
connect(userContextMenu, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool)));
|
connect(userContextMenu, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool)));
|
||||||
|
|
||||||
userName = QString::fromStdString(tabSupervisor->getUserInfo()->name());
|
userName = QString::fromStdString(tabSupervisor->getUserInfo()->name());
|
||||||
mention = "@" + userName.toLower();
|
mention = "@" + userName.toLower();
|
||||||
|
|
||||||
|
|
@ -30,6 +32,7 @@ ChatView::ChatView(const TabSupervisor *_tabSupervisor, TabGame *_game, bool _sh
|
||||||
|
|
||||||
mentionFormatOtherUser.setFontWeight(QFont::Bold);
|
mentionFormatOtherUser.setFontWeight(QFont::Bold);
|
||||||
mentionFormatOtherUser.setForeground(Qt::blue);
|
mentionFormatOtherUser.setForeground(Qt::blue);
|
||||||
|
mentionFormatOtherUser.setBackground(QBrush(OTHER_USER_MENTION_COLOR));
|
||||||
mentionFormatOtherUser.setAnchor(true);
|
mentionFormatOtherUser.setAnchor(true);
|
||||||
|
|
||||||
viewport()->setCursor(Qt::IBeamCursor);
|
viewport()->setCursor(Qt::IBeamCursor);
|
||||||
|
|
@ -47,7 +50,7 @@ void ChatView::retranslateUi()
|
||||||
QTextCursor ChatView::prepareBlock(bool same)
|
QTextCursor ChatView::prepareBlock(bool same)
|
||||||
{
|
{
|
||||||
lastSender.clear();
|
lastSender.clear();
|
||||||
|
|
||||||
QTextCursor cursor(document()->lastBlock());
|
QTextCursor cursor(document()->lastBlock());
|
||||||
cursor.movePosition(QTextCursor::End);
|
cursor.movePosition(QTextCursor::End);
|
||||||
if (!same) {
|
if (!same) {
|
||||||
|
|
@ -58,7 +61,7 @@ QTextCursor ChatView::prepareBlock(bool same)
|
||||||
cursor.insertBlock(blockFormat);
|
cursor.insertBlock(blockFormat);
|
||||||
} else
|
} else
|
||||||
cursor.insertHtml("<br>");
|
cursor.insertHtml("<br>");
|
||||||
|
|
||||||
return cursor;
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,7 +80,7 @@ void ChatView::appendCardTag(QTextCursor &cursor, const QString &cardName)
|
||||||
anchorFormat.setForeground(Qt::blue);
|
anchorFormat.setForeground(Qt::blue);
|
||||||
anchorFormat.setAnchor(true);
|
anchorFormat.setAnchor(true);
|
||||||
anchorFormat.setAnchorHref("card://" + cardName);
|
anchorFormat.setAnchorHref("card://" + cardName);
|
||||||
|
|
||||||
cursor.setCharFormat(anchorFormat);
|
cursor.setCharFormat(anchorFormat);
|
||||||
cursor.insertText(cardName);
|
cursor.insertText(cardName);
|
||||||
cursor.setCharFormat(oldFormat);
|
cursor.setCharFormat(oldFormat);
|
||||||
|
|
@ -87,7 +90,7 @@ void ChatView::appendUrlTag(QTextCursor &cursor, QString url)
|
||||||
{
|
{
|
||||||
if (!url.contains("://"))
|
if (!url.contains("://"))
|
||||||
url.prepend("http://");
|
url.prepend("http://");
|
||||||
|
|
||||||
QTextCharFormat oldFormat = cursor.charFormat();
|
QTextCharFormat oldFormat = cursor.charFormat();
|
||||||
QTextCharFormat anchorFormat = oldFormat;
|
QTextCharFormat anchorFormat = oldFormat;
|
||||||
anchorFormat.setForeground(Qt::blue);
|
anchorFormat.setForeground(Qt::blue);
|
||||||
|
|
@ -95,7 +98,7 @@ void ChatView::appendUrlTag(QTextCursor &cursor, QString url)
|
||||||
anchorFormat.setAnchorHref(url);
|
anchorFormat.setAnchorHref(url);
|
||||||
anchorFormat.setUnderlineColor(Qt::blue);
|
anchorFormat.setUnderlineColor(Qt::blue);
|
||||||
anchorFormat.setFontUnderline(true);
|
anchorFormat.setFontUnderline(true);
|
||||||
|
|
||||||
cursor.setCharFormat(anchorFormat);
|
cursor.setCharFormat(anchorFormat);
|
||||||
cursor.insertText(url);
|
cursor.insertText(url);
|
||||||
cursor.setCharFormat(oldFormat);
|
cursor.setCharFormat(oldFormat);
|
||||||
|
|
@ -107,14 +110,14 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
|
||||||
bool sameSender = (sender == lastSender) && !lastSender.isEmpty();
|
bool sameSender = (sender == lastSender) && !lastSender.isEmpty();
|
||||||
QTextCursor cursor = prepareBlock(sameSender);
|
QTextCursor cursor = prepareBlock(sameSender);
|
||||||
lastSender = sender;
|
lastSender = sender;
|
||||||
|
|
||||||
if (showTimestamps && !sameSender) {
|
if (showTimestamps && !sameSender) {
|
||||||
QTextCharFormat timeFormat;
|
QTextCharFormat timeFormat;
|
||||||
timeFormat.setForeground(Qt::black);
|
timeFormat.setForeground(Qt::black);
|
||||||
cursor.setCharFormat(timeFormat);
|
cursor.setCharFormat(timeFormat);
|
||||||
cursor.insertText(QDateTime::currentDateTime().toString("[hh:mm:ss] "));
|
cursor.insertText(QDateTime::currentDateTime().toString("[hh:mm:ss] "));
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextCharFormat senderFormat;
|
QTextCharFormat senderFormat;
|
||||||
if (tabSupervisor && tabSupervisor->getUserInfo() && (sender == QString::fromStdString(tabSupervisor->getUserInfo()->name()))) {
|
if (tabSupervisor && tabSupervisor->getUserInfo() && (sender == QString::fromStdString(tabSupervisor->getUserInfo()->name()))) {
|
||||||
senderFormat.setFontWeight(QFont::Bold);
|
senderFormat.setFontWeight(QFont::Bold);
|
||||||
|
|
@ -129,7 +132,8 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
|
||||||
if (!sameSender) {
|
if (!sameSender) {
|
||||||
if (!sender.isEmpty()) {
|
if (!sender.isEmpty()) {
|
||||||
const int pixelSize = QFontInfo(cursor.charFormat().font()).pixelSize();
|
const int pixelSize = QFontInfo(cursor.charFormat().font()).pixelSize();
|
||||||
cursor.insertImage(UserLevelPixmapGenerator::generatePixmap(pixelSize, userLevel).toImage(), QString::number(pixelSize) + "_" + QString::number((int) userLevel));
|
QMap<QString, UserListTWI *> buddyList = tabSupervisor->getUserListsTab()->getBuddyList()->getUsers();
|
||||||
|
cursor.insertImage(UserLevelPixmapGenerator::generatePixmap(pixelSize, userLevel, buddyList.contains(sender)).toImage(), QString::number(pixelSize) + "_" + QString::number((int) userLevel));
|
||||||
cursor.insertText(" ");
|
cursor.insertText(" ");
|
||||||
}
|
}
|
||||||
cursor.setCharFormat(senderFormat);
|
cursor.setCharFormat(senderFormat);
|
||||||
|
|
@ -138,12 +142,12 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
|
||||||
cursor.insertText(sender);
|
cursor.insertText(sender);
|
||||||
} else
|
} else
|
||||||
cursor.insertText(" ");
|
cursor.insertText(" ");
|
||||||
|
|
||||||
QTextCharFormat messageFormat;
|
QTextCharFormat messageFormat;
|
||||||
if (sender.isEmpty())
|
if (sender.isEmpty())
|
||||||
messageFormat.setForeground(Qt::darkGreen);
|
messageFormat.setForeground(Qt::darkGreen);
|
||||||
cursor.setCharFormat(messageFormat);
|
cursor.setCharFormat(messageFormat);
|
||||||
|
|
||||||
int from = 0, index = 0;
|
int from = 0, index = 0;
|
||||||
while ((index = message.indexOf('[', from)) != -1) {
|
while ((index = message.indexOf('[', from)) != -1) {
|
||||||
cursor.insertText(message.left(index));
|
cursor.insertText(message.left(index));
|
||||||
|
|
@ -159,7 +163,7 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
|
||||||
message.clear();
|
message.clear();
|
||||||
else
|
else
|
||||||
message = message.mid(closeTagIndex + 7);
|
message = message.mid(closeTagIndex + 7);
|
||||||
|
|
||||||
appendCardTag(cursor, cardName);
|
appendCardTag(cursor, cardName);
|
||||||
} else if (message.startsWith("[[")) {
|
} else if (message.startsWith("[[")) {
|
||||||
message = message.mid(2);
|
message = message.mid(2);
|
||||||
|
|
@ -169,7 +173,7 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
|
||||||
message.clear();
|
message.clear();
|
||||||
else
|
else
|
||||||
message = message.mid(closeTagIndex + 2);
|
message = message.mid(closeTagIndex + 2);
|
||||||
|
|
||||||
appendCardTag(cursor, cardName);
|
appendCardTag(cursor, cardName);
|
||||||
} else if (message.startsWith("[url]")) {
|
} else if (message.startsWith("[url]")) {
|
||||||
message = message.mid(5);
|
message = message.mid(5);
|
||||||
|
|
@ -179,7 +183,7 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
|
||||||
message.clear();
|
message.clear();
|
||||||
else
|
else
|
||||||
message = message.mid(closeTagIndex + 6);
|
message = message.mid(closeTagIndex + 6);
|
||||||
|
|
||||||
appendUrlTag(cursor, url);
|
appendUrlTag(cursor, url);
|
||||||
} else
|
} else
|
||||||
from = 1;
|
from = 1;
|
||||||
|
|
@ -187,7 +191,8 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
|
||||||
|
|
||||||
if (settingsCache->getChatMention()) {
|
if (settingsCache->getChatMention()) {
|
||||||
index = 0;
|
index = 0;
|
||||||
while((index = message.indexOf('@')) != -1) {
|
from = 0;
|
||||||
|
while((index = message.indexOf('@', from)) != -1) {
|
||||||
cursor.insertText(message.left(index), defaultFormat);
|
cursor.insertText(message.left(index), defaultFormat);
|
||||||
message = message.mid(index);
|
message = message.mid(index);
|
||||||
if (message.isEmpty())
|
if (message.isEmpty())
|
||||||
|
|
@ -205,40 +210,24 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
|
||||||
QString userMention = message.left(mentionEndIndex);
|
QString userMention = message.left(mentionEndIndex);
|
||||||
QString userName = userMention.right(userMention.size()-1).normalized(QString::NormalizationForm_D);
|
QString userName = userMention.right(userMention.size()-1).normalized(QString::NormalizationForm_D);
|
||||||
QMap<QString, UserListTWI *> userList = tabSupervisor->getUserListsTab()->getAllUsersList()->getUsers();
|
QMap<QString, UserListTWI *> userList = tabSupervisor->getUserListsTab()->getAllUsersList()->getUsers();
|
||||||
QString correctUserName = getNameFromUserList(userList, userName);
|
if (userList.contains(userName)) {
|
||||||
if (!correctUserName.isEmpty()) {
|
UserListTWI *vlu = userList.value(userName);
|
||||||
UserListTWI *vlu = userList.value(correctUserName);
|
mentionFormatOtherUser.setAnchorHref("user://" + QString::number(vlu->getUserInfo().user_level()) + "_" + userName);
|
||||||
mentionFormatOtherUser.setAnchorHref("user://" + QString::number(vlu->getUserInfo().user_level()) + "_" + correctUserName);
|
cursor.insertText("@" + userName, mentionFormatOtherUser);
|
||||||
cursor.insertText("@" + correctUserName, mentionFormatOtherUser);
|
|
||||||
} else
|
} else
|
||||||
cursor.insertText("@" + userName, defaultFormat);
|
cursor.insertText("@" + userName, defaultFormat);
|
||||||
message = message.mid(userName.size() + 1);
|
message = message.mid(userName.size() + 1);
|
||||||
}
|
}
|
||||||
cursor.setCharFormat(defaultFormat); // reset format after each itteration
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!message.isEmpty())
|
if (!message.isEmpty())
|
||||||
cursor.insertText(message);
|
cursor.insertText(message, defaultFormat);
|
||||||
|
|
||||||
if (atBottom)
|
if (atBottom)
|
||||||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Returns the correct case version of the provided username, if no correct casing version
|
|
||||||
was found then the provided name is not available and will return an empty QString.
|
|
||||||
*/
|
|
||||||
QString ChatView::getNameFromUserList(QMap<QString, UserListTWI *> &userList, QString &userName) {
|
|
||||||
QMap<QString, UserListTWI *>::iterator i;
|
|
||||||
QString lowerUserName = userName.toLower();
|
|
||||||
for (i = userList.begin(); i != userList.end(); ++i) {
|
|
||||||
if (i.key().toLower() == lowerUserName)
|
|
||||||
return i.key();
|
|
||||||
}
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChatView::clearChat() {
|
void ChatView::clearChat() {
|
||||||
document()->clear();
|
document()->clear();
|
||||||
}
|
}
|
||||||
|
|
@ -290,41 +279,41 @@ void ChatView::mouseMoveEvent(QMouseEvent *event)
|
||||||
hoveredItemType = HoveredNothing;
|
hoveredItemType = HoveredNothing;
|
||||||
viewport()->setCursor(Qt::IBeamCursor);
|
viewport()->setCursor(Qt::IBeamCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextBrowser::mouseMoveEvent(event);
|
QTextBrowser::mouseMoveEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatView::mousePressEvent(QMouseEvent *event)
|
void ChatView::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
switch (hoveredItemType) {
|
switch (hoveredItemType) {
|
||||||
case HoveredCard: {
|
case HoveredCard: {
|
||||||
if ((event->button() == Qt::MidButton) || (event->button() == Qt::LeftButton))
|
if ((event->button() == Qt::MidButton) || (event->button() == Qt::LeftButton))
|
||||||
emit showCardInfoPopup(event->globalPos(), hoveredContent);
|
emit showCardInfoPopup(event->globalPos(), hoveredContent);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case HoveredUser: {
|
case HoveredUser: {
|
||||||
if (event->button() != Qt::MidButton) {
|
if (event->button() != Qt::MidButton) {
|
||||||
const int delimiterIndex = hoveredContent.indexOf("_");
|
const int delimiterIndex = hoveredContent.indexOf("_");
|
||||||
const QString userName = hoveredContent.mid(delimiterIndex + 1);
|
const QString userName = hoveredContent.mid(delimiterIndex + 1);
|
||||||
switch(event->button()) {
|
switch(event->button()) {
|
||||||
case Qt::RightButton :{
|
case Qt::RightButton :{
|
||||||
UserLevelFlags userLevel(hoveredContent.left(delimiterIndex).toInt());
|
UserLevelFlags userLevel(hoveredContent.left(delimiterIndex).toInt());
|
||||||
userContextMenu->showContextMenu(event->globalPos(), userName, userLevel);
|
userContextMenu->showContextMenu(event->globalPos(), userName, userLevel);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Qt::LeftButton :{
|
case Qt::LeftButton :{
|
||||||
emit addMentionTag("@" + userName);
|
emit addMentionTag("@" + userName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
QTextBrowser::mousePressEvent(event);
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
QTextBrowser::mousePressEvent(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -332,7 +321,7 @@ void ChatView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if ((event->button() == Qt::MidButton) || (event->button() == Qt::LeftButton))
|
if ((event->button() == Qt::MidButton) || (event->button() == Qt::LeftButton))
|
||||||
emit deleteCardInfoPopup(QString("_"));
|
emit deleteCardInfoPopup(QString("_"));
|
||||||
|
|
||||||
QTextBrowser::mouseReleaseEvent(event);
|
QTextBrowser::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -340,6 +329,6 @@ void ChatView::openLink(const QUrl &link)
|
||||||
{
|
{
|
||||||
if ((link.scheme() == "card") || (link.scheme() == "user"))
|
if ((link.scheme() == "card") || (link.scheme() == "user"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QDesktopServices::openUrl(link);
|
QDesktopServices::openUrl(link);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return QString::fromStdString(g.creator_info().name());
|
return QString::fromStdString(g.creator_info().name());
|
||||||
case Qt::DecorationRole: {
|
case Qt::DecorationRole: {
|
||||||
QPixmap avatarPixmap = UserLevelPixmapGenerator::generatePixmap(13, (UserLevelFlags)g.creator_info().user_level());
|
QPixmap avatarPixmap = UserLevelPixmapGenerator::generatePixmap(13, (UserLevelFlags)g.creator_info().user_level(), false);
|
||||||
return QIcon(avatarPixmap);
|
return QIcon(avatarPixmap);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@ QPixmap PhasePixmapGenerator::generatePixmap(int height, QString name)
|
||||||
QString key = name + QString::number(height);
|
QString key = name + QString::number(height);
|
||||||
if (pmCache.contains(key))
|
if (pmCache.contains(key))
|
||||||
return pmCache.value(key);
|
return pmCache.value(key);
|
||||||
|
|
||||||
QSvgRenderer svg(QString(":/resources/phases/icon_phase_" + name + ".svg"));
|
QSvgRenderer svg(QString(":/resources/phases/icon_phase_" + name + ".svg"));
|
||||||
|
|
||||||
QPixmap pixmap(height, height);
|
QPixmap pixmap(height, height);
|
||||||
pixmap.fill(Qt::transparent);
|
pixmap.fill(Qt::transparent);
|
||||||
QPainter painter(&pixmap);
|
QPainter painter(&pixmap);
|
||||||
|
|
@ -35,16 +35,16 @@ QPixmap CounterPixmapGenerator::generatePixmap(int height, QString name, bool hi
|
||||||
QString key = name + QString::number(height);
|
QString key = name + QString::number(height);
|
||||||
if (pmCache.contains(key))
|
if (pmCache.contains(key))
|
||||||
return pmCache.value(key);
|
return pmCache.value(key);
|
||||||
|
|
||||||
QSvgRenderer svg(QString(":/resources/counters/" + name + ".svg"));
|
QSvgRenderer svg(QString(":/resources/counters/" + name + ".svg"));
|
||||||
|
|
||||||
if (!svg.isValid()) {
|
if (!svg.isValid()) {
|
||||||
name = "general";
|
name = "general";
|
||||||
if (highlight)
|
if (highlight)
|
||||||
name.append("_highlight");
|
name.append("_highlight");
|
||||||
svg.load(QString(":/resources/counters/" + name + ".svg"));
|
svg.load(QString(":/resources/counters/" + name + ".svg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
int width = (int) round(height * (double) svg.defaultSize().width() / (double) svg.defaultSize().height());
|
int width = (int) round(height * (double) svg.defaultSize().width() / (double) svg.defaultSize().height());
|
||||||
QPixmap pixmap(width, height);
|
QPixmap pixmap(width, height);
|
||||||
pixmap.fill(Qt::transparent);
|
pixmap.fill(Qt::transparent);
|
||||||
|
|
@ -59,7 +59,7 @@ QPixmap PingPixmapGenerator::generatePixmap(int size, int value, int max)
|
||||||
int key = size * 1000000 + max * 1000 + value;
|
int key = size * 1000000 + max * 1000 + value;
|
||||||
if (pmCache.contains(key))
|
if (pmCache.contains(key))
|
||||||
return pmCache.value(key);
|
return pmCache.value(key);
|
||||||
|
|
||||||
QPixmap pixmap(size, size);
|
QPixmap pixmap(size, size);
|
||||||
pixmap.fill(Qt::transparent);
|
pixmap.fill(Qt::transparent);
|
||||||
QPainter painter(&pixmap);
|
QPainter painter(&pixmap);
|
||||||
|
|
@ -68,12 +68,12 @@ QPixmap PingPixmapGenerator::generatePixmap(int size, int value, int max)
|
||||||
color = Qt::black;
|
color = Qt::black;
|
||||||
else
|
else
|
||||||
color.setHsv(120 * (1.0 - ((double) value / max)), 255, 255);
|
color.setHsv(120 * (1.0 - ((double) value / max)), 255, 255);
|
||||||
|
|
||||||
QRadialGradient g(QPointF((double) pixmap.width() / 2, (double) pixmap.height() / 2), qMin(pixmap.width(), pixmap.height()) / 2.0);
|
QRadialGradient g(QPointF((double) pixmap.width() / 2, (double) pixmap.height() / 2), qMin(pixmap.width(), pixmap.height()) / 2.0);
|
||||||
g.setColorAt(0, color);
|
g.setColorAt(0, color);
|
||||||
g.setColorAt(1, Qt::transparent);
|
g.setColorAt(1, Qt::transparent);
|
||||||
painter.fillRect(0, 0, pixmap.width(), pixmap.height(), QBrush(g));
|
painter.fillRect(0, 0, pixmap.width(), pixmap.height(), QBrush(g));
|
||||||
|
|
||||||
pmCache.insert(key, pixmap);
|
pmCache.insert(key, pixmap);
|
||||||
|
|
||||||
return pixmap;
|
return pixmap;
|
||||||
|
|
@ -86,25 +86,25 @@ QPixmap GenderPixmapGenerator::generatePixmap(int height, int _gender)
|
||||||
ServerInfo_User::Gender gender = static_cast<ServerInfo_User::Gender>(_gender);
|
ServerInfo_User::Gender gender = static_cast<ServerInfo_User::Gender>(_gender);
|
||||||
if ((gender != ServerInfo_User::Male) && (gender != ServerInfo_User::Female))
|
if ((gender != ServerInfo_User::Male) && (gender != ServerInfo_User::Female))
|
||||||
gender = ServerInfo_User::GenderUnknown;
|
gender = ServerInfo_User::GenderUnknown;
|
||||||
|
|
||||||
int key = gender * 100000 + height;
|
int key = gender * 100000 + height;
|
||||||
if (pmCache.contains(key))
|
if (pmCache.contains(key))
|
||||||
return pmCache.value(key);
|
return pmCache.value(key);
|
||||||
|
|
||||||
QString genderStr;
|
QString genderStr;
|
||||||
switch (gender) {
|
switch (gender) {
|
||||||
case ServerInfo_User::Male: genderStr = "male"; break;
|
case ServerInfo_User::Male: genderStr = "male"; break;
|
||||||
case ServerInfo_User::Female: genderStr = "female"; break;
|
case ServerInfo_User::Female: genderStr = "female"; break;
|
||||||
default: genderStr = "unknown";
|
default: genderStr = "unknown";
|
||||||
};
|
};
|
||||||
|
|
||||||
QSvgRenderer svg(QString(":/resources/genders/" + genderStr + ".svg"));
|
QSvgRenderer svg(QString(":/resources/genders/" + genderStr + ".svg"));
|
||||||
int width = (int) round(height * (double) svg.defaultSize().width() / (double) svg.defaultSize().height());
|
int width = (int) round(height * (double) svg.defaultSize().width() / (double) svg.defaultSize().height());
|
||||||
QPixmap pixmap(width, height);
|
QPixmap pixmap(width, height);
|
||||||
pixmap.fill(Qt::transparent);
|
pixmap.fill(Qt::transparent);
|
||||||
QPainter painter(&pixmap);
|
QPainter painter(&pixmap);
|
||||||
svg.render(&painter, QRectF(0, 0, width, height));
|
svg.render(&painter, QRectF(0, 0, width, height));
|
||||||
|
|
||||||
pmCache.insert(key, pixmap);
|
pmCache.insert(key, pixmap);
|
||||||
return pixmap;
|
return pixmap;
|
||||||
}
|
}
|
||||||
|
|
@ -118,7 +118,7 @@ QPixmap CountryPixmapGenerator::generatePixmap(int height, const QString &countr
|
||||||
QString key = countryCode + QString::number(height);
|
QString key = countryCode + QString::number(height);
|
||||||
if (pmCache.contains(key))
|
if (pmCache.contains(key))
|
||||||
return pmCache.value(key);
|
return pmCache.value(key);
|
||||||
|
|
||||||
QSvgRenderer svg(QString(":/resources/countries/" + countryCode + ".svg"));
|
QSvgRenderer svg(QString(":/resources/countries/" + countryCode + ".svg"));
|
||||||
int width = (int) round(height * (double) svg.defaultSize().width() / (double) svg.defaultSize().height());
|
int width = (int) round(height * (double) svg.defaultSize().width() / (double) svg.defaultSize().height());
|
||||||
QPixmap pixmap(width, height);
|
QPixmap pixmap(width, height);
|
||||||
|
|
@ -127,19 +127,20 @@ QPixmap CountryPixmapGenerator::generatePixmap(int height, const QString &countr
|
||||||
svg.render(&painter, QRectF(0, 0, width, height));
|
svg.render(&painter, QRectF(0, 0, width, height));
|
||||||
painter.setPen(Qt::black);
|
painter.setPen(Qt::black);
|
||||||
painter.drawRect(0, 0, width - 1, height - 1);
|
painter.drawRect(0, 0, width - 1, height - 1);
|
||||||
|
|
||||||
pmCache.insert(key, pixmap);
|
pmCache.insert(key, pixmap);
|
||||||
return pixmap;
|
return pixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, QPixmap> CountryPixmapGenerator::pmCache;
|
QMap<QString, QPixmap> CountryPixmapGenerator::pmCache;
|
||||||
|
|
||||||
QPixmap UserLevelPixmapGenerator::generatePixmap(int height, UserLevelFlags userLevel)
|
QPixmap UserLevelPixmapGenerator::generatePixmap(int height, UserLevelFlags userLevel, bool isBuddy)
|
||||||
{
|
{
|
||||||
|
|
||||||
int key = height * 10000 + (int) userLevel;
|
int key = height * 10000 + (int) userLevel;
|
||||||
if (pmCache.contains(key))
|
if (pmCache.contains(key))
|
||||||
return pmCache.value(key);
|
return pmCache.value(key);
|
||||||
|
|
||||||
QString levelString;
|
QString levelString;
|
||||||
if (userLevel.testFlag(ServerInfo_User::IsAdmin))
|
if (userLevel.testFlag(ServerInfo_User::IsAdmin))
|
||||||
levelString = "admin";
|
levelString = "admin";
|
||||||
|
|
@ -149,15 +150,35 @@ QPixmap UserLevelPixmapGenerator::generatePixmap(int height, UserLevelFlags user
|
||||||
levelString = "registered";
|
levelString = "registered";
|
||||||
else
|
else
|
||||||
levelString = "normal";
|
levelString = "normal";
|
||||||
|
|
||||||
|
if (isBuddy)
|
||||||
|
levelString.append("_buddy");
|
||||||
|
|
||||||
QSvgRenderer svg(QString(":/resources/userlevels/" + levelString + ".svg"));
|
QSvgRenderer svg(QString(":/resources/userlevels/" + levelString + ".svg"));
|
||||||
int width = (int) round(height * (double) svg.defaultSize().width() / (double) svg.defaultSize().height());
|
int width = (int) round(height * (double) svg.defaultSize().width() / (double) svg.defaultSize().height());
|
||||||
QPixmap pixmap(width, height);
|
QPixmap pixmap(width, height);
|
||||||
pixmap.fill(Qt::transparent);
|
pixmap.fill(Qt::transparent);
|
||||||
QPainter painter(&pixmap);
|
QPainter painter(&pixmap);
|
||||||
svg.render(&painter, QRectF(0, 0, width, height));
|
svg.render(&painter, QRectF(0, 0, width, height));
|
||||||
|
|
||||||
pmCache.insert(key, pixmap);
|
pmCache.insert(key, pixmap);
|
||||||
return pixmap;
|
return pixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QMap<QString, QPixmap> PixmapGenerator::pmCache;
|
||||||
|
QPixmap PixmapGenerator::generatePixmap(int height, QString resourceName) {
|
||||||
|
if (pmCache.contains(resourceName))
|
||||||
|
return pmCache.value(resourceName);
|
||||||
|
|
||||||
|
QSvgRenderer svg(resourceName);
|
||||||
|
int width = (int) round(height * (double) svg.defaultSize().width() / (double) svg.defaultSize().height());
|
||||||
|
QPixmap pixmap(width, height);
|
||||||
|
pixmap.fill(Qt::transparent);
|
||||||
|
QPainter painter(&pixmap);
|
||||||
|
svg.render(&painter, QRectF(0, 0, width, height));
|
||||||
|
|
||||||
|
pmCache.insert(resourceName, pixmap);
|
||||||
|
return pixmap;
|
||||||
|
}
|
||||||
|
|
||||||
QMap<int, QPixmap> UserLevelPixmapGenerator::pmCache;
|
QMap<int, QPixmap> UserLevelPixmapGenerator::pmCache;
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,15 @@ class UserLevelPixmapGenerator {
|
||||||
private:
|
private:
|
||||||
static QMap<int, QPixmap> pmCache;
|
static QMap<int, QPixmap> pmCache;
|
||||||
public:
|
public:
|
||||||
static QPixmap generatePixmap(int height, UserLevelFlags userLevel);
|
static QPixmap generatePixmap(int height, UserLevelFlags userLevel, bool isBuddy);
|
||||||
|
static void clear() { pmCache.clear(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
class PixmapGenerator {
|
||||||
|
private:
|
||||||
|
static QMap<QString, QPixmap> pmCache;
|
||||||
|
public:
|
||||||
|
static QPixmap generatePixmap(int height, QString resourceName);
|
||||||
static void clear() { pmCache.clear(); }
|
static void clear() { pmCache.clear(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ void PlayerListWidget::updatePlayerProperties(const ServerInfo_PlayerProperties
|
||||||
player->setIcon(2, gameStarted ? (prop.conceded() ? concededIcon : QIcon()) : (prop.ready_start() ? readyIcon : notReadyIcon));
|
player->setIcon(2, gameStarted ? (prop.conceded() ? concededIcon : QIcon()) : (prop.ready_start() ? readyIcon : notReadyIcon));
|
||||||
if (prop.has_user_info()) {
|
if (prop.has_user_info()) {
|
||||||
player->setData(3, Qt::UserRole, prop.user_info().user_level());
|
player->setData(3, Qt::UserRole, prop.user_info().user_level());
|
||||||
player->setIcon(3, QIcon(UserLevelPixmapGenerator::generatePixmap(12, UserLevelFlags(prop.user_info().user_level()))));
|
player->setIcon(3, QIcon(UserLevelPixmapGenerator::generatePixmap(12, UserLevelFlags(prop.user_info().user_level()), false)));
|
||||||
player->setText(4, QString::fromStdString(prop.user_info().name()));
|
player->setText(4, QString::fromStdString(prop.user_info().name()));
|
||||||
const QString country = QString::fromStdString(prop.user_info().country());
|
const QString country = QString::fromStdString(prop.user_info().country());
|
||||||
if (!country.isEmpty())
|
if (!country.isEmpty())
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ void PlayerTarget::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*o
|
||||||
|
|
||||||
QPixmap tempPixmap;
|
QPixmap tempPixmap;
|
||||||
if (fullPixmap.isNull())
|
if (fullPixmap.isNull())
|
||||||
tempPixmap = UserLevelPixmapGenerator::generatePixmap(translatedSize.height(), UserLevelFlags(info->user_level()));
|
tempPixmap = UserLevelPixmapGenerator::generatePixmap(translatedSize.height(), UserLevelFlags(info->user_level()), false);
|
||||||
else
|
else
|
||||||
tempPixmap = fullPixmap.scaled(translatedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
tempPixmap = fullPixmap.scaled(translatedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,14 +59,14 @@ void UserInfoBox::updateInfo(const ServerInfo_User &user)
|
||||||
QPixmap avatarPixmap;
|
QPixmap avatarPixmap;
|
||||||
const std::string bmp = user.avatar_bmp();
|
const std::string bmp = user.avatar_bmp();
|
||||||
if (!avatarPixmap.loadFromData((const uchar *) bmp.data(), bmp.size()))
|
if (!avatarPixmap.loadFromData((const uchar *) bmp.data(), bmp.size()))
|
||||||
avatarPixmap = UserLevelPixmapGenerator::generatePixmap(64, userLevel);
|
avatarPixmap = UserLevelPixmapGenerator::generatePixmap(64, userLevel, false);
|
||||||
avatarLabel.setPixmap(avatarPixmap);
|
avatarLabel.setPixmap(avatarPixmap);
|
||||||
|
|
||||||
nameLabel.setText(QString::fromStdString(user.name()));
|
nameLabel.setText(QString::fromStdString(user.name()));
|
||||||
realNameLabel2.setText(QString::fromStdString(user.real_name()));
|
realNameLabel2.setText(QString::fromStdString(user.real_name()));
|
||||||
genderLabel2.setPixmap(GenderPixmapGenerator::generatePixmap(15, user.gender()));
|
genderLabel2.setPixmap(GenderPixmapGenerator::generatePixmap(15, user.gender()));
|
||||||
countryLabel2.setPixmap(CountryPixmapGenerator::generatePixmap(15, QString::fromStdString(user.country())));
|
countryLabel2.setPixmap(CountryPixmapGenerator::generatePixmap(15, QString::fromStdString(user.country())));
|
||||||
userLevelLabel2.setPixmap(UserLevelPixmapGenerator::generatePixmap(15, userLevel));
|
userLevelLabel2.setPixmap(UserLevelPixmapGenerator::generatePixmap(15, userLevel, false));
|
||||||
QString userLevelText;
|
QString userLevelText;
|
||||||
if (userLevel.testFlag(ServerInfo_User::IsAdmin))
|
if (userLevel.testFlag(ServerInfo_User::IsAdmin))
|
||||||
userLevelText = tr("Administrator");
|
userLevelText = tr("Administrator");
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ void UserListTWI::setUserInfo(const ServerInfo_User &_userInfo)
|
||||||
userInfo = _userInfo;
|
userInfo = _userInfo;
|
||||||
|
|
||||||
setData(0, Qt::UserRole, userInfo.user_level());
|
setData(0, Qt::UserRole, userInfo.user_level());
|
||||||
setIcon(0, QIcon(UserLevelPixmapGenerator::generatePixmap(12, UserLevelFlags(userInfo.user_level()))));
|
setIcon(0, QIcon(UserLevelPixmapGenerator::generatePixmap(12, UserLevelFlags(userInfo.user_level()), false)));
|
||||||
setIcon(1, QIcon(CountryPixmapGenerator::generatePixmap(12, QString::fromStdString(userInfo.country()))));
|
setIcon(1, QIcon(CountryPixmapGenerator::generatePixmap(12, QString::fromStdString(userInfo.country()))));
|
||||||
setData(2, Qt::UserRole, QString::fromStdString(userInfo.name()));
|
setData(2, Qt::UserRole, QString::fromStdString(userInfo.name()));
|
||||||
setData(2, Qt::DisplayRole, QString::fromStdString(userInfo.name()));
|
setData(2, Qt::DisplayRole, QString::fromStdString(userInfo.name()));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue