mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-07-05 20:42:08 -07:00
Add new Console Icons to GUI
This commit is contained in:
parent
673a2de9c1
commit
7dd26f974f
13 changed files with 222 additions and 110 deletions
|
@ -1,6 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
|
@ -14,7 +12,7 @@
|
|||
viewBox="0 0 135.46666 22.754167"
|
||||
version="1.1"
|
||||
id="svg965"
|
||||
inkscape:version="0.92.4 5da689c313, 2019-01-14"
|
||||
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
|
||||
sodipodi:docname="console.svg">
|
||||
<defs
|
||||
id="defs959" />
|
||||
|
@ -25,18 +23,19 @@
|
|||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="1.4"
|
||||
inkscape:cx="300.0445"
|
||||
inkscape:cy="77.810757"
|
||||
inkscape:zoom="1.979899"
|
||||
inkscape:cx="277.12099"
|
||||
inkscape:cy="63.078394"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
units="px"
|
||||
inkscape:window-width="1918"
|
||||
inkscape:window-height="1048"
|
||||
inkscape:window-width="1916"
|
||||
inkscape:window-height="1031"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="15"
|
||||
inkscape:window-maximized="1" />
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:document-rotation="0" />
|
||||
<metadata
|
||||
id="metadata962">
|
||||
<rdf:RDF>
|
||||
|
@ -45,7 +44,7 @@
|
|||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
|
@ -54,21 +53,26 @@
|
|||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(0,-274.24582)">
|
||||
<g
|
||||
id="g956"
|
||||
transform="matrix(1.3273345,0,0,1.3071608,-53.478391,126.49438)">
|
||||
<path
|
||||
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:12.74962807;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 50.489042,113.03234 -4.224384,7.21001 h 91.860192 l 4.22439,-7.21001 z m -5.975155,10.19787 -4.223824,7.20945 h 91.860187 l 4.22384,-7.20945 z"
|
||||
id="path950"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccccccccc" />
|
||||
<path
|
||||
sodipodi:nodetypes="ccccc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path952"
|
||||
d="m 46.264658,120.24235 -1.750771,2.98786 h 91.860193 l 1.75078,-2.98786 z"
|
||||
style="fill:#ffae2f;fill-opacity:1;stroke:none;stroke-width:12.74962807;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
</g>
|
||||
<path
|
||||
sodipodi:nodetypes="ccccc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path952"
|
||||
d="m 7.9302857,283.67047 -2.3238588,3.90561 c 40.8387811,5.10156 81.4752601,4.92996 121.9292031,0 l 2.32387,-3.90561 c -41.598755,-4.20777 -82.184535,-3.9555 -121.9292143,0 z"
|
||||
style="fill:#ffae2f;fill-opacity:1;stroke:none;stroke-width:16.7939;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
inkscape:label="light_standby" />
|
||||
<path
|
||||
sodipodi:nodetypes="ccccc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path1483"
|
||||
d="m 7.9302857,283.67047 -2.3238588,3.90561 c 40.8387811,5.10156 81.4752601,4.92996 121.9292031,0 l 2.32387,-3.90561 c -41.598755,-4.20777 -82.184535,-3.9555 -121.9292143,0 z"
|
||||
style="fill:#00a7ff;fill-opacity:1;stroke:none;stroke-width:16.7939;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
inkscape:label="light_on" />
|
||||
<path
|
||||
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:16.7939;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 13.537456,274.24582 -5.6071703,9.42465 H 129.85949 l 5.60718,-9.42465 z M 5.6064269,287.57608 -3.729265e-7,296.99999 H 121.9292 l 5.60644,-9.42391 z"
|
||||
id="path950"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccccccccc"
|
||||
inkscape:label="console" />
|
||||
</g>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.9 KiB |
|
@ -23,11 +23,11 @@
|
|||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.7"
|
||||
inkscape:cx="87.618933"
|
||||
inkscape:cy="14.057308"
|
||||
inkscape:zoom="0.98994949"
|
||||
inkscape:cx="162.87247"
|
||||
inkscape:cy="106.01511"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="g1675"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
units="px"
|
||||
inkscape:window-width="1916"
|
||||
|
@ -50,32 +50,22 @@
|
|||
</metadata>
|
||||
<g
|
||||
inkscape:label="Ebene 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(0,-274.24582)">
|
||||
<g
|
||||
id="g1675"
|
||||
transform="matrix(1.0026035,0,0,0.99664897,-9.3412507,46.056879)">
|
||||
<path
|
||||
style="fill:#ffae2f;stroke:none;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1"
|
||||
d="m 11.220544,240.75925 v -2.98372 L 136.62064,230.7693 v 27.82703 L 11.220544,251.93507 v -3.16856 l 6.67386,-3.65773 z"
|
||||
id="path990"
|
||||
sodipodi:nodetypes="cccccccc" />
|
||||
<path
|
||||
style="fill:#000000;stroke:none;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 10.279685,239.4829 c 64.247406,-0.83221 116.019365,-8.74624 123.672605,-7.58225 1.33323,0.20277 1.57026,0.6362 2.27116,3.2822 0.83,3.13337 0.43085,0.15877 0.57571,0.0308 2.56938,-2.26884 4.79824,-5.03149 6.77978,-5.00883 0.47796,0.005 1.37988,-1.32939 0.44684,-1.24478 -29.60266,2.68444 -65.128658,6.73719 -127.091451,2.24108 -5.25552,-0.38135 -9.6223366,8.32017 -6.654644,8.28173 z"
|
||||
id="path966"
|
||||
sodipodi:nodetypes="ssssssss" />
|
||||
<path
|
||||
style="fill:#000000;stroke:none;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 10.708866,250.21495 c 64.247417,0.83221 115.507454,8.64031 123.160694,7.47632 1.33323,-0.20277 1.57026,-0.63621 2.27116,-3.2822 0.83,-3.13338 0.43085,-0.15878 0.57571,-0.0309 2.56938,2.26884 4.79824,5.03149 6.77978,5.00883 0.47796,-0.005 1.37799,1.34816 0.44684,1.24479 -14.63784,-1.62499 -26.98018,-2.91351 -48.456119,-1.67781 -11.54302,0.66417 -25.72951,3.3332 -44.386733,5.40793 -10.226009,1.13715 -31.339423,0.54703 -40.666983,0.53417 -0.6809731,-9.3e-4 -0.8176661,-9.48626 -1.0468581,-13.46985 -0.04249,-0.73852 0.8187891,-1.21784 1.3225091,-1.21132 z"
|
||||
id="path986"
|
||||
sodipodi:nodetypes="sssssssssss" />
|
||||
<path
|
||||
id="path957"
|
||||
style="fill:#000000;stroke:none;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 136.11376,235.311 c -15.95178,-0.0643 -84.311467,5.96599 -124.893216,5.44825 0,2.66908 0,5.33817 0,8.00726 44.779861,-0.57131 122.876826,6.83105 128.151936,5.21932 v -8.92917 -0.58705 -8.92917 c -0.49454,-0.1511 -1.60853,-0.22279 -3.25872,-0.22944 z"
|
||||
sodipodi:nodetypes="sccccccs" />
|
||||
</g>
|
||||
inkscape:groupmode="layer">
|
||||
<path
|
||||
style="display:inline;fill:#ffae2f;fill-opacity:1;stroke:none;stroke-width:0.264483;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="M 1.90851,11.7633 V 8.78962 L 127.635,1.80686 V 29.5406 L 1.90851,22.9017 v -3.1579 l 6.69123,-3.6455 z"
|
||||
id="path990"
|
||||
inkscape:label="light_standby" />
|
||||
<path
|
||||
style="display:inline;fill:#00a7ff;fill-opacity:1;stroke:none;stroke-width:0.264483;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="M 1.90851,11.7633 V 8.78962 L 127.635,1.80686 V 29.5406 L 1.90851,22.9017 v -3.1579 l 6.69123,-3.6455 z"
|
||||
id="path848"
|
||||
inkscape:label="light_on" />
|
||||
<path
|
||||
id="path966"
|
||||
style="display:inline;fill:#000000;stroke:none;stroke-width:0.264483;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="M 135.059,0.00361735 C 105.38,2.67905 69.7613,6.71862 7.63725,2.23759 2.36805,1.85752 -2.0101,10.5297 0.965315,10.4913 65.3799,9.66192 117.287,1.77461 124.96,2.9347 c 1.336,0.20209 1.574,0.63399 2.277,3.27111 0.014,0.05608 0.023,0.07751 0.037,0.12971 C 127.222,6.33518 127.18,6.33367 127.127,6.33346 111.134,6.26936 42.5958,12.2796 1.90841,11.7636 V 19.744 C 42.7269,19.2263 111.141,25.2757 127.21,25.1721 c -0.021,0.0757 -0.034,0.1108 -0.056,0.1953 -0.703,2.6371 -0.941,3.069 -2.278,3.2711 C 117.203,29.7986 65.8099,22.0167 1.39526,21.1873 0.890231,21.1808 0.0271625,21.6584 0.0697631,22.3945 0.299552,26.3647 0.436565,35.8186 1.11931,35.8195 c 9.35179,0.0128 30.51999,0.601 40.77269,-0.5323 18.7057,-2.0678 32.929,-4.7279 44.5021,-5.3898 21.5319,-1.2316 33.9069,0.0527 48.5829,1.6722 0.933,0.103 0.031,-1.2457 -0.448,-1.2407 -1.987,0.0225 -4.222,-2.7307 -6.798,-4.992 -0.019,-0.0164 -0.028,-0.0822 -0.032,-0.1741 1.321,-0.0216 2.268,-0.0875 2.695,-0.2171 V 16.0465 15.4616 6.56238 c -0.424,-0.12876 -1.327,-0.19659 -2.607,-0.21859 0.006,-0.05334 0.013,-0.09568 0.027,-0.10749 2.576,-2.26123 4.811,-5.01452 6.797,-4.99193 0.479,0.005 1.384,-1.3250825 0.448,-1.24075265 z"
|
||||
inkscape:label="path966" />
|
||||
</g>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.6 KiB |
|
@ -12,6 +12,7 @@
|
|||
|
||||
struct DiscoveryHost
|
||||
{
|
||||
bool ps5;
|
||||
ChiakiDiscoveryHostState state;
|
||||
uint16_t host_request_port;
|
||||
#define STRING_MEMBER(name) QString name;
|
||||
|
|
|
@ -22,6 +22,8 @@ struct DisplayServer
|
|||
bool registered;
|
||||
|
||||
QString GetHostAddr() const { return discovered ? discovery_host.host_addr : manual_host.GetHost(); }
|
||||
bool IsPS5() const { return discovered ? discovery_host.ps5 :
|
||||
(registered ? chiaki_target_is_ps5(registered_host.GetTarget()) : false); }
|
||||
};
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
|
|
|
@ -6,13 +6,18 @@
|
|||
#include <chiaki/discovery.h>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QSvgRenderer>
|
||||
|
||||
class ServerIconWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
bool ps5 = false;
|
||||
ChiakiDiscoveryHostState state = CHIAKI_DISCOVERY_HOST_STATE_UNKNOWN;
|
||||
QSvgRenderer svg_renderer;
|
||||
|
||||
void LoadSvg();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
@ -20,7 +25,7 @@ class ServerIconWidget : public QWidget
|
|||
public:
|
||||
explicit ServerIconWidget(QWidget *parent = nullptr);
|
||||
|
||||
void SetState(ChiakiDiscoveryHostState state) { this->state = state; update(); }
|
||||
void SetState(bool ps5, ChiakiDiscoveryHostState state);
|
||||
};
|
||||
|
||||
#endif // CHIAKI_SERVERICONWIDGET_H
|
||||
|
|
43
gui/res/console-ps4.svg
Normal file
43
gui/res/console-ps4.svg
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?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"
|
||||
width="512"
|
||||
height="86"
|
||||
viewBox="0 0 135.46666 22.754167"
|
||||
version="1.1"
|
||||
id="svg965">
|
||||
<defs
|
||||
id="defs959" />
|
||||
<metadata
|
||||
id="metadata962">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
id="layer1"
|
||||
transform="translate(0,-274.24582)">
|
||||
<path
|
||||
id="light_standby"
|
||||
d="m 7.9302857,283.67047 -2.3238588,3.90561 c 40.8387811,5.10156 81.4752601,4.92996 121.9292031,0 l 2.32387,-3.90561 c -41.598755,-4.20777 -82.184535,-3.9555 -121.9292143,0 z"
|
||||
style="fill:#ffae2f;fill-opacity:1;stroke:none;stroke-width:16.7939;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<path
|
||||
id="light_on"
|
||||
d="m 7.9302857,283.67047 -2.3238588,3.90561 c 40.8387811,5.10156 81.4752601,4.92996 121.9292031,0 l 2.32387,-3.90561 c -41.598755,-4.20777 -82.184535,-3.9555 -121.9292143,0 z"
|
||||
style="fill:#00a7ff;fill-opacity:1;stroke:none;stroke-width:16.7939;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<path
|
||||
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:16.7939;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 13.537456,274.24582 -5.6071703,9.42465 H 129.85949 l 5.60718,-9.42465 z M 5.6064269,287.57608 -3.729265e-7,296.99999 H 121.9292 l 5.60644,-9.42391 z"
|
||||
id="console" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.8 KiB |
42
gui/res/console-ps5.svg
Normal file
42
gui/res/console-ps5.svg
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?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"
|
||||
width="512"
|
||||
height="136"
|
||||
viewBox="0 0 135.46666 35.983334"
|
||||
version="1.1"
|
||||
id="svg965">
|
||||
<defs
|
||||
id="defs959" />
|
||||
<metadata
|
||||
id="metadata962">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
id="layer1">
|
||||
<path
|
||||
style="display:inline;fill:#ffae2f;fill-opacity:1;stroke:none;stroke-width:0.264483;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="M 1.90851,11.7633 V 8.78962 L 127.635,1.80686 V 29.5406 L 1.90851,22.9017 v -3.1579 l 6.69123,-3.6455 z"
|
||||
id="light_standby" />
|
||||
<path
|
||||
style="display:inline;fill:#00a7ff;fill-opacity:1;stroke:none;stroke-width:0.264483;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="M 1.90851,11.7633 V 8.78962 L 127.635,1.80686 V 29.5406 L 1.90851,22.9017 v -3.1579 l 6.69123,-3.6455 z"
|
||||
id="light_on" />
|
||||
<path
|
||||
id="console"
|
||||
style="display:inline;fill:#000000;stroke:none;stroke-width:0.264483;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="M 135.059,0.00361735 C 105.38,2.67905 69.7613,6.71862 7.63725,2.23759 2.36805,1.85752 -2.0101,10.5297 0.965315,10.4913 65.3799,9.66192 117.287,1.77461 124.96,2.9347 c 1.336,0.20209 1.574,0.63399 2.277,3.27111 0.014,0.05608 0.023,0.07751 0.037,0.12971 C 127.222,6.33518 127.18,6.33367 127.127,6.33346 111.134,6.26936 42.5958,12.2796 1.90841,11.7636 V 19.744 C 42.7269,19.2263 111.141,25.2757 127.21,25.1721 c -0.021,0.0757 -0.034,0.1108 -0.056,0.1953 -0.703,2.6371 -0.941,3.069 -2.278,3.2711 C 117.203,29.7986 65.8099,22.0167 1.39526,21.1873 0.890231,21.1808 0.0271625,21.6584 0.0697631,22.3945 0.299552,26.3647 0.436565,35.8186 1.11931,35.8195 c 9.35179,0.0128 30.51999,0.601 40.77269,-0.5323 18.7057,-2.0678 32.929,-4.7279 44.5021,-5.3898 21.5319,-1.2316 33.9069,0.0527 48.5829,1.6722 0.933,0.103 0.031,-1.2457 -0.448,-1.2407 -1.987,0.0225 -4.222,-2.7307 -6.798,-4.992 -0.019,-0.0164 -0.028,-0.0822 -0.032,-0.1741 1.321,-0.0216 2.268,-0.0875 2.695,-0.2171 V 16.0465 15.4616 6.56238 c -0.424,-0.12876 -1.327,-0.19659 -2.607,-0.21859 0.006,-0.05334 0.013,-0.09568 0.027,-0.10749 2.576,-2.26123 4.811,-5.01452 6.797,-4.99193 0.479,0.005 1.384,-1.3250825 0.448,-1.24075265 z" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.6 KiB |
|
@ -5,5 +5,7 @@
|
|||
<file>discover-24px.svg</file>
|
||||
<file>discover-off-24px.svg</file>
|
||||
<file>chiaki.svg</file>
|
||||
<file>console-ps4.svg</file>
|
||||
<file>console-ps5.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -129,6 +129,7 @@ static void DiscoveryServiceHostsCallback(ChiakiDiscoveryHost *hosts, size_t hos
|
|||
{
|
||||
ChiakiDiscoveryHost *h = hosts + i;
|
||||
DiscoveryHost o = {};
|
||||
o.ps5 = chiaki_discovery_host_is_ps5(h);
|
||||
o.state = h->state;
|
||||
o.host_request_port = o.host_request_port;
|
||||
#define CONVERT_STRING(name) if(h->name) { o.name = QString::fromLocal8Bit(h->name); }
|
||||
|
|
|
@ -7,73 +7,87 @@
|
|||
|
||||
ServerIconWidget::ServerIconWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
LoadSvg();
|
||||
}
|
||||
|
||||
void ServerIconWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
static const float icon_aspect = 100.0f / 17.0f;
|
||||
static const float coolness = 0.585913713f;
|
||||
|
||||
if(width() == 0 || height() == 0)
|
||||
QRectF view_box = svg_renderer.viewBoxF();
|
||||
if(view_box.width() < 0.00001f || view_box.height() < 0.00001f)
|
||||
return;
|
||||
float icon_aspect = view_box.width() / view_box.height();
|
||||
float widget_aspect = (float)width() / (float)height();
|
||||
QRectF icon_rect;
|
||||
if(widget_aspect > icon_aspect)
|
||||
{
|
||||
icon_rect.setHeight(height());
|
||||
icon_rect.setWidth((float)height() * icon_aspect);
|
||||
icon_rect.moveTop(0.0f);
|
||||
icon_rect.moveLeft(((float)width() - icon_rect.width()) * 0.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
icon_rect.setWidth(width());
|
||||
icon_rect.setHeight((float)width() / icon_aspect);
|
||||
icon_rect.moveLeft(0.0f);
|
||||
icon_rect.moveTop(((float)height() - icon_rect.height()) * 0.5f);
|
||||
}
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
QRectF icon_rect;
|
||||
float widget_aspect = (float)width() / (float)height();
|
||||
if(widget_aspect > icon_aspect)
|
||||
{
|
||||
icon_rect.setHeight(height());
|
||||
icon_rect.setWidth((float)height() * icon_aspect);
|
||||
icon_rect.moveTop(0.0f);
|
||||
icon_rect.moveLeft(((float)width() - icon_rect.width()) * 0.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
icon_rect.setWidth(width());
|
||||
icon_rect.setHeight((float)width() / icon_aspect);
|
||||
icon_rect.moveLeft(0.0f);
|
||||
icon_rect.moveTop(((float)height() - icon_rect.height()) * 0.5f);
|
||||
}
|
||||
|
||||
|
||||
auto XForY = [&icon_rect](float y, bool right)
|
||||
{
|
||||
float r = (icon_rect.height() - y) * coolness;
|
||||
if(right)
|
||||
r += icon_rect.width() - icon_rect.height() * coolness;
|
||||
return r;
|
||||
auto render_element = [&view_box, &icon_rect, this](QPainter &painter, const QString &id) {
|
||||
QRectF src = svg_renderer.transformForElement(id).mapRect(svg_renderer.boundsOnElement(id));
|
||||
QRectF dst = src.translated(-view_box.left(), -view_box.top());
|
||||
dst = QRectF(
|
||||
icon_rect.width() * dst.left() / view_box.width(),
|
||||
icon_rect.height() * dst.top() / view_box.height(),
|
||||
icon_rect.width() * dst.width() / view_box.width(),
|
||||
icon_rect.height() * dst.height() / view_box.height());
|
||||
dst = dst.translated(icon_rect.left(), icon_rect.top());
|
||||
svg_renderer.render(&painter, id, dst);
|
||||
};
|
||||
|
||||
auto SectionPath = [&XForY, &icon_rect](float y0, float y1)
|
||||
{
|
||||
QPainterPath path;
|
||||
path.moveTo(XForY(y0, false), y0);
|
||||
path.lineTo(XForY(y1, false), y1);
|
||||
path.lineTo(XForY(y1, true), y1);
|
||||
path.lineTo(XForY(y0, true), y0);
|
||||
path.translate(icon_rect.topLeft());
|
||||
return path;
|
||||
};
|
||||
|
||||
auto color = palette().color(QPalette::Text);
|
||||
|
||||
QColor bar_color;
|
||||
switch(state)
|
||||
{
|
||||
case CHIAKI_DISCOVERY_HOST_STATE_STANDBY:
|
||||
bar_color = QColor(255, 174, 47);
|
||||
break;
|
||||
case CHIAKI_DISCOVERY_HOST_STATE_READY:
|
||||
bar_color = QColor(0, 167, 255);
|
||||
render_element(painter, "light_on");
|
||||
break;
|
||||
case CHIAKI_DISCOVERY_HOST_STATE_STANDBY:
|
||||
render_element(painter, "light_standby");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(bar_color.isValid())
|
||||
painter.fillPath(SectionPath(icon_rect.height() * 0.41f - 1.0f, icon_rect.height() * 0.59f + 1.0f), bar_color);
|
||||
painter.fillPath(SectionPath(0, icon_rect.height() * 0.41f), color);
|
||||
painter.fillPath(SectionPath(icon_rect.height() * 0.59f, icon_rect.height()), color);
|
||||
}
|
||||
auto color = palette().color(QPalette::Text);
|
||||
|
||||
QImage temp_image((int)(devicePixelRatioF() * width()),
|
||||
(int)(devicePixelRatioF() * height()),
|
||||
QImage::Format_ARGB32_Premultiplied);
|
||||
{
|
||||
temp_image.fill(QColor(0, 0, 0, 0));
|
||||
QPainter temp_painter(&temp_image);
|
||||
render_element(temp_painter, "console");
|
||||
temp_painter.setCompositionMode(QPainter::CompositionMode_SourceAtop);
|
||||
temp_painter.fillRect(icon_rect, color);
|
||||
}
|
||||
painter.drawImage(QRectF(0.0f, 0.0f, width(), height()), temp_image);
|
||||
}
|
||||
|
||||
void ServerIconWidget::LoadSvg()
|
||||
{
|
||||
QString path = ps5 ? ":/icons/console-ps5.svg" : ":/icons/console-ps4.svg";
|
||||
svg_renderer.load(path);
|
||||
update();
|
||||
}
|
||||
|
||||
void ServerIconWidget::SetState(bool ps5, ChiakiDiscoveryHostState state)
|
||||
{
|
||||
bool reload = this->ps5 != ps5;
|
||||
this->ps5 = ps5;
|
||||
this->state = state;
|
||||
if(reload)
|
||||
LoadSvg();
|
||||
update();
|
||||
}
|
||||
|
|
|
@ -70,7 +70,8 @@ void ServerItemWidget::Update(const DisplayServer &display_server)
|
|||
delete_action->setEnabled(!display_server.discovered);
|
||||
wake_action->setEnabled(display_server.registered);
|
||||
|
||||
icon_widget->SetState(display_server.discovered ? display_server.discovery_host.state : CHIAKI_DISCOVERY_HOST_STATE_UNKNOWN);
|
||||
icon_widget->SetState(display_server.IsPS5(),
|
||||
display_server.discovered ? display_server.discovery_host.state : CHIAKI_DISCOVERY_HOST_STATE_UNKNOWN);
|
||||
|
||||
QString top_text = "";
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ typedef struct chiaki_discovery_host_t
|
|||
#undef STRING_MEMBER
|
||||
} ChiakiDiscoveryHost;
|
||||
|
||||
CHIAKI_EXPORT bool chiaki_discovery_host_is_ps5(ChiakiDiscoveryHost *host);
|
||||
|
||||
CHIAKI_EXPORT int chiaki_discovery_packet_fmt(char *buf, size_t buf_size, ChiakiDiscoveryPacket *packet);
|
||||
|
||||
|
|
|
@ -32,6 +32,12 @@ const char *chiaki_discovery_host_state_string(ChiakiDiscoveryHostState state)
|
|||
}
|
||||
}
|
||||
|
||||
CHIAKI_EXPORT bool chiaki_discovery_host_is_ps5(ChiakiDiscoveryHost *host)
|
||||
{
|
||||
return host->device_discovery_protocol_version
|
||||
&& !strcmp(host->device_discovery_protocol_version, CHIAKI_DISCOVERY_PROTOCOL_VERSION_PS5);
|
||||
}
|
||||
|
||||
CHIAKI_EXPORT int chiaki_discovery_packet_fmt(char *buf, size_t buf_size, ChiakiDiscoveryPacket *packet)
|
||||
{
|
||||
if(!packet->protocol_version)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue