mirror of
https://github.com/edisionnano/QDiskInfo.git
synced 2026-03-07 20:09:55 +03:00
Move source to src folder
This commit is contained in:
71
src/custombutton.cpp
Normal file
71
src/custombutton.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
#include "custombutton.h"
|
||||
#include <QFontMetrics>
|
||||
|
||||
CustomButton::CustomButton(const QString &text1, const QString &text2, const QString &text3, const QColor &lineColor, QWidget *parent)
|
||||
: QPushButton(parent), text1(text1), text2(text2), text3(text3), lineColor(lineColor) {
|
||||
setMinimumHeight(60);
|
||||
adjustWidthToFitText();
|
||||
}
|
||||
|
||||
void CustomButton::adjustWidthToFitText() {
|
||||
QFont font = this->font();
|
||||
QFontMetrics fm(font);
|
||||
|
||||
int maxWidth = 0;
|
||||
QString lines[] = {text1, text2, text3};
|
||||
|
||||
for (const QString &line : lines) {
|
||||
int lineWidth = fm.horizontalAdvance(line);
|
||||
if (lineWidth > maxWidth) {
|
||||
maxWidth = lineWidth;
|
||||
}
|
||||
}
|
||||
|
||||
int desiredWidth = maxWidth + 30;
|
||||
setMinimumWidth(desiredWidth);
|
||||
setMaximumWidth(desiredWidth);
|
||||
}
|
||||
|
||||
void CustomButton::paintEvent(QPaintEvent *event) {
|
||||
QPushButton::paintEvent(event);
|
||||
QPainter painter(this);
|
||||
QPalette pal = palette();
|
||||
QColor textColor = pal.color(QPalette::ButtonText);
|
||||
|
||||
QPen pen(lineColor, 5);
|
||||
painter.setPen(pen);
|
||||
painter.drawLine(10, 9, 10, 50);
|
||||
|
||||
QRect rect(20, 0, width() - 25, height());
|
||||
painter.setPen(textColor);
|
||||
painter.drawText(rect, Qt::AlignVCenter | Qt::AlignLeft, text1 + "\n" + text2 + "\n" + text3);
|
||||
}
|
||||
|
||||
void CustomButton::resizeEvent(QResizeEvent *event) {
|
||||
QPushButton::resizeEvent(event);
|
||||
adjustWidthToFitText();
|
||||
}
|
||||
|
||||
void CustomButton::setText1(const QString &newText1) {
|
||||
if (text1 != newText1) {
|
||||
text1 = newText1;
|
||||
adjustWidthToFitText();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void CustomButton::setText2(const QString &newText2) {
|
||||
if (text2 != newText2) {
|
||||
text2 = newText2;
|
||||
adjustWidthToFitText();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void CustomButton::setText3(const QString &newText3) {
|
||||
if (text3 != newText3) {
|
||||
text3 = newText3;
|
||||
adjustWidthToFitText();
|
||||
update();
|
||||
}
|
||||
}
|
||||
29
src/custombutton.h
Normal file
29
src/custombutton.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef CUSTOMBUTTON_H
|
||||
#define CUSTOMBUTTON_H
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QPainter>
|
||||
|
||||
class CustomButton : public QPushButton {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CustomButton(const QString &text1, const QString &text2, const QString &text3, const QColor &lineColor, QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void setText1(const QString &newText1);
|
||||
void setText2(const QString &newText2);
|
||||
void setText3(const QString &newText3);
|
||||
void adjustWidthToFitText();
|
||||
|
||||
|
||||
private:
|
||||
QString text1;
|
||||
QString text2;
|
||||
QString text3;
|
||||
QColor lineColor;
|
||||
};
|
||||
|
||||
#endif
|
||||
373
src/icon.svg
Normal file
373
src/icon.svg
Normal file
@@ -0,0 +1,373 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
viewBox="0 0 48 48"
|
||||
version="1.1"
|
||||
id="svg40"
|
||||
sodipodi:docname="org.kde.partitionmanager.svg"
|
||||
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<defs
|
||||
id="defs40" />
|
||||
<sodipodi:namedview
|
||||
id="namedview40"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="false"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
showgrid="false"
|
||||
inkscape:zoom="11.166667"
|
||||
inkscape:cx="23.955224"
|
||||
inkscape:cy="24"
|
||||
inkscape:window-width="1366"
|
||||
inkscape:window-height="740"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg40" />
|
||||
<linearGradient
|
||||
id="a"
|
||||
x1="6"
|
||||
x2="6"
|
||||
y1="58"
|
||||
y2="6"
|
||||
gradientUnits="userSpaceOnUse">
|
||||
<stop
|
||||
stop-color="#98a7b0"
|
||||
offset="0"
|
||||
id="stop1" />
|
||||
<stop
|
||||
stop-color="#dde1e3"
|
||||
offset="1"
|
||||
id="stop2" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="b">
|
||||
<stop
|
||||
stop-color="#292c2f"
|
||||
offset="0"
|
||||
id="stop3" />
|
||||
<stop
|
||||
stop-opacity="0"
|
||||
offset="1"
|
||||
id="stop4" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="c"
|
||||
x1=".593691"
|
||||
x2="76.196591"
|
||||
y1="36.119742"
|
||||
y2="36.119742"
|
||||
gradientTransform="matrix(.99166665 0 0 1 .029538 -.046272)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
xlink:href="#b" />
|
||||
<linearGradient
|
||||
id="d"
|
||||
x1="388.423"
|
||||
x2="388.423"
|
||||
y1="557.79797"
|
||||
y2="505.798"
|
||||
gradientTransform="matrix(.83152667 0 0 .76922858 -321.64966 -385.07572)"
|
||||
gradientUnits="userSpaceOnUse">
|
||||
<stop
|
||||
stop-color="#7f8c8d"
|
||||
offset="0"
|
||||
id="stop5" />
|
||||
<stop
|
||||
stop-color="#afb0b3"
|
||||
offset="1"
|
||||
id="stop6" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="e"
|
||||
x1="-421.44699"
|
||||
x2="-410.44699"
|
||||
y1="-504.20401"
|
||||
y2="-493.20401"
|
||||
gradientTransform="matrix(1.4166667 0 0 1.4285715 1.333333 1.142857)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
xlink:href="#b" />
|
||||
<linearGradient
|
||||
id="f"
|
||||
x1="1.333"
|
||||
x2="1.333"
|
||||
y1="48.714001"
|
||||
y2="9.714"
|
||||
gradientTransform="matrix(.73913167 0 0 .76922858 .347333 -.614286)"
|
||||
gradientUnits="userSpaceOnUse">
|
||||
<stop
|
||||
stop-color="#eef1f2"
|
||||
offset="0"
|
||||
id="stop7" />
|
||||
<stop
|
||||
stop-color="#f9fafb"
|
||||
offset="1"
|
||||
id="stop8" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="g"
|
||||
x1="6"
|
||||
x2="6"
|
||||
y1="58"
|
||||
y2="6"
|
||||
gradientTransform="matrix(.41954831 0 0 .42307393 10.574493 8.318726)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
xlink:href="#a" />
|
||||
<linearGradient
|
||||
id="h"
|
||||
x1="32"
|
||||
x2="32"
|
||||
y1="58"
|
||||
y2="32"
|
||||
gradientTransform="matrix(-.41954831 0 0 .42307393 37.425586 8.318726)"
|
||||
gradientUnits="userSpaceOnUse">
|
||||
<stop
|
||||
stop-color="#8e44ad"
|
||||
offset="0"
|
||||
id="stop9" />
|
||||
<stop
|
||||
stop-color="#af7ac4"
|
||||
offset="1"
|
||||
id="stop10" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="i"
|
||||
x1="32"
|
||||
x2="32"
|
||||
y1="58"
|
||||
y2="32"
|
||||
gradientTransform="matrix(.41954831 0 0 .42307393 10.574493 8.318726)"
|
||||
gradientUnits="userSpaceOnUse">
|
||||
<stop
|
||||
stop-color="#fdad23"
|
||||
offset="0"
|
||||
id="stop11" />
|
||||
<stop
|
||||
stop-color="#fdc96f"
|
||||
offset="1"
|
||||
id="stop12" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="j"
|
||||
x1="32"
|
||||
x2="32"
|
||||
y1="32"
|
||||
y2="6"
|
||||
gradientTransform="matrix(.41954831 0 0 .42307393 10.574493 8.318726)"
|
||||
gradientUnits="userSpaceOnUse">
|
||||
<stop
|
||||
stop-color="#27ad60"
|
||||
offset="0"
|
||||
id="stop13" />
|
||||
<stop
|
||||
stop-color="#58d68d"
|
||||
offset="1"
|
||||
id="stop14" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="k"
|
||||
x1="32"
|
||||
x2="32"
|
||||
y1="32"
|
||||
y2="6"
|
||||
gradientTransform="matrix(.41954831 0 0 .42307393 10.574493 8.318726)"
|
||||
gradientUnits="userSpaceOnUse">
|
||||
<stop
|
||||
stop-color="#1190d9"
|
||||
offset="0"
|
||||
id="stop15" />
|
||||
<stop
|
||||
stop-color="#73c4ef"
|
||||
offset="1"
|
||||
id="stop16" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="l"
|
||||
x1="32"
|
||||
x2="32"
|
||||
y1="41"
|
||||
y2="23"
|
||||
gradientTransform="matrix(.41954831 0 0 .42307393 10.574493 8.318726)"
|
||||
gradientUnits="userSpaceOnUse">
|
||||
<stop
|
||||
stop-color="#cecece"
|
||||
offset="0"
|
||||
id="stop17" />
|
||||
<stop
|
||||
stop-color="#ececec"
|
||||
offset="1"
|
||||
id="stop18" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="m"
|
||||
x1="32"
|
||||
x2="32"
|
||||
y1="36"
|
||||
y2="28"
|
||||
gradientTransform="matrix(.41954831 0 0 .42307393 10.574493 8.318726)"
|
||||
gradientUnits="userSpaceOnUse">
|
||||
<stop
|
||||
stop-color="#5c7274"
|
||||
offset="0"
|
||||
id="stop19" />
|
||||
<stop
|
||||
stop-color="#a4a4a4"
|
||||
offset="1"
|
||||
id="stop20" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="n"
|
||||
x1="32"
|
||||
x2="32"
|
||||
y1="35"
|
||||
y2="29"
|
||||
gradientTransform="matrix(.41954831 0 0 .42307393 10.574493 8.318726)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
xlink:href="#a" />
|
||||
<g
|
||||
stroke-width="1"
|
||||
id="g28">
|
||||
<path
|
||||
d="m6.9999999 3.9999995h34v40h-34z"
|
||||
fill="url(#d)"
|
||||
id="path20" />
|
||||
<path
|
||||
d="m11.25 39.714286h25.499999v4.285714h-25.499999z"
|
||||
fill="#292c2e"
|
||||
id="path21" />
|
||||
<path
|
||||
d="m14.083333 41.142857h12.75v1.428572h-12.75zm14.166667 0h5.666667v1.428572h-5.666667z"
|
||||
fill="#f6b44d"
|
||||
id="path22" />
|
||||
<path
|
||||
d="m35.333332 39.714286h5.666668v4.285714h-5.666668zm-28.333332 0h5.6666661v4.285714h-5.6666661z"
|
||||
fill="#292c2f"
|
||||
opacity=".2"
|
||||
id="path23" />
|
||||
<path
|
||||
d="m6.9999999 39.714286h5.6666661v4.285714h-1.416666zm28.333332 0h5.666668v4.285714h-5.666668z"
|
||||
fill="#292c2f"
|
||||
opacity=".2"
|
||||
id="path24" />
|
||||
<path
|
||||
d="m36.09125 8.9499995 4.90875 4.9471435v30.102857h-19.833334l-11.333333-11.428571z"
|
||||
fill="url(#e)"
|
||||
opacity=".2"
|
||||
id="path25" />
|
||||
<path
|
||||
d="m16.916665 6.8571424a7.0833333 7.1428572 0 0 0 -7.0833318 7.1428576v6.811429a4.25 4.2857144 0 0 1 1.4109998 3.024284 2.8333333 2.8571429 0 0 1 .0058.164288 2.8333333 2.8571429 0 0 1 -.01417.285713 4.25 4.2857144 0 0 1 0 .0072 4.25 4.2857144 0 0 1 -1.4025004 2.892858v5.385714l4.2499504 4.285714h19.833334l4.25-4.285714v-5.382858a4.25 4.2857144 0 0 1 -1.411-3.024286 2.8333333 2.8571429 0 0 1 -.0058-.164284 2.8333333 2.8571429 0 0 1 .01417-.292858 4.25 4.2857144 0 0 1 1.402501-2.892857v-6.814343a7.0833333 7.1428572 0 0 0 -7.083285-7.1428576z"
|
||||
fill="url(#f)"
|
||||
id="path26" />
|
||||
<path
|
||||
d="m6.9999999 42.571429h4.2500001v1.428571h-4.2500001zm29.749999 0h4.250001v1.428571h-4.250001z"
|
||||
fill="#292c2f"
|
||||
opacity=".2"
|
||||
id="path27" />
|
||||
<path
|
||||
d="m24.00004 18.049429a3.7759347 3.8076653 0 0 0 -3.775934 3.807664 3.7759347 3.8076653 0 0 0 3.775934 3.807665 3.7759347 3.8076653 0 0 0 3.775934-3.807665 3.7759347 3.8076653 0 0 0 -3.775934-3.807664zm0 2.538442c.697289 0 1.258644.566073 1.258644 1.269222s-.561355 1.269223-1.258644 1.269223c-.69729 0-1.258646-.566074-1.258646-1.269223s.561356-1.269222 1.258646-1.269222z"
|
||||
fill="url(#g)"
|
||||
id="path28" />
|
||||
</g>
|
||||
<path
|
||||
d="m32.504427 14.953125c.179262.226924.353924.458075.515201.699219.195629.292506.378668.594476.546191.90625.167526.311772.319477.633667.457097.96289.13762.329224.260149.664907.366065 1.009766.105915.344859.196811.697962.269222 1.056641.07241.358677.127527.723067.164632 1.09375.02318.231512.02603.469457.03487.705078h.0097c.0021.05695.0021.114754.0039.171875.000992-.0303.007-.05949.0077-.08984.0021.09223 0 .182311 0 .275391 0 .0079-.0019.01553-.002.02344-.000007.0033.00001.0065 0 .0098.000064.01111.002.02209.002.0332 0 .380871-.01906.755462-.05617 1.123047-.03711.367583-.09222.727183-.164633 1.080078-.07241.352894-.16137.698354-.267284 1.035156-.105915.336803-.228446.665067-.366065.984375-.13762.319308-.291509.629276-.459034.929688-.167523.30041-.348624.590982-.544254.871093-.136229.195061-.28861.377861-.437728.5625-.0785.101842-.14859.209544-.230485.308594-.224324.271314-.462398.532075-.710824.78125-.248423.249175-.508073.487603-.778613.712891-.270539.225288-.551862.437067-.842529.636719-.290668.199652-.589889.386325-.898698.558593-.308811.172269-.626027.331473-.950993.47461-.324965.143135-.658342.270557-.997477.382812-.339136.112256-.684895.209436-1.036214.289063-.351319.07963-.707625.142251-1.069141.1875-.361516.04525-.728466.07291-1.098193.08203-.458958-.02115-.903066-.06428-1.332552-.126953-.429549-.06267-.843339-.145083-1.243457-.246094s-.785444-.221242-1.156299-.357422c-.370854-.13618-.727443-.288858-1.069141-.457031-.341695-.168173-.669337-.351837-.981982-.548828s-.611127-.406274-.894824-.628907c-.283696-.222633-.552812-.458023-.807666-.703124l14.115755 14.257775h10.398942v-20.482422l-8.493083-8.564453z"
|
||||
fill="url(#c)"
|
||||
opacity=".2"
|
||||
id="path29" />
|
||||
<g
|
||||
stroke-width="1"
|
||||
id="g40">
|
||||
<path
|
||||
d="m24.000878 32.433941v-8.461479a2.0977416 2.1153697 0 0 0 2.097742-2.115369h8.809676c0 6.093956-4.864661 10.576848-10.907418 10.576848z"
|
||||
fill="url(#h)"
|
||||
id="path30" />
|
||||
<path
|
||||
d="m23.999201 32.433941v-8.461479a2.0977416 2.1153697 0 0 1-2.097743-2.115369h-8.809674c0 6.093956 4.864664 10.576848 10.907417 10.576848z"
|
||||
fill="url(#i)"
|
||||
id="path31" />
|
||||
<path
|
||||
d="m24.00004 10.857171v8.884553a2.0977416 2.1153697 0 0 0-2.097741 2.115369h-8.809677c0-6.093958 4.864665-10.999922 10.907418-10.999922z"
|
||||
fill="url(#j)"
|
||||
id="path32" />
|
||||
<path
|
||||
d="m13.102273 21.434018c-.005.140461-.01054.281344-.01054.423075h7.551867v-.423075z"
|
||||
fill="#292c2f"
|
||||
opacity=".2"
|
||||
id="path33" />
|
||||
<path
|
||||
d="m13.092622 21.514826c-.0021.09223 0 .18446 0 .277113 0 4.87085 3.564066 10.726844 10.907418 11.065232v-.5c-6.893768-.314464-10.789523-5.939766-10.907418-10.842769z"
|
||||
fill="#ca902a"
|
||||
id="path34" />
|
||||
<path
|
||||
d="m24.00004 10.857171v8.884553a2.0977416 2.1153697 0 0 1 2.097741 2.115369h8.809677c0-6.093958-4.864663-10.999922-10.907418-10.999922z"
|
||||
fill="url(#k)"
|
||||
id="path35" />
|
||||
<path
|
||||
d="m27.356426 21.434018v.423075h7.551032c0-.141731-.0055-.282614-.01054-.423075zm-3.356386-1.692294a2.0977416 2.1153697 0 1 0 0 4.230738 2.0977416 2.1153697 0 0 0 0-4.230738zm0 .846147c.697289 0 1.258644.566073 1.258644 1.269222s-.561355 1.269223-1.258644 1.269223c-.69729 0-1.258646-.566074-1.258646-1.269223s.561356-1.269222 1.258646-1.269222z"
|
||||
fill="#292c2f"
|
||||
opacity=".2"
|
||||
id="path36" />
|
||||
<path
|
||||
d="m24.00004 18.049429a3.7759347 3.8076653 0 1 0 0 7.615329 3.7759347 3.8076653 0 0 0 0-7.615329zm0 1.692295a2.0977416 2.1153697 0 1 1 0 4.230738 2.0977416 2.1153697 0 0 1 0-4.230738z"
|
||||
fill="url(#l)"
|
||||
id="path37" />
|
||||
<path
|
||||
d="m24.00004 20.164797a1.6781935 1.692296 0 1 0 0 3.384592 1.6781935 1.692296 0 0 0 0-3.384592zm0 .423074a1.2586456 1.2692225 0 1 1 0 2.538445 1.2586456 1.2692225 0 0 1 0-2.538445z"
|
||||
fill="url(#m)"
|
||||
id="path38" />
|
||||
<path
|
||||
d="m27.767165 22.036475a3.7759347 3.8076653 0 0 1 -3.767125 3.628283 3.7759347 3.8076653 0 0 1 -3.767124-3.563975 3.7759347 3.8076653 0 0 0 -.0088.179383 3.7759347 3.8076653 0 0 0 3.775934 3.807665 3.7759347 3.8076653 0 0 0 3.775937-3.807665 3.7759347 3.8076653 0 0 0 -.0088-.243691z"
|
||||
fill="#7f8c8d"
|
||||
id="path39" />
|
||||
<ellipse
|
||||
cx="24.000038"
|
||||
cy="21.857094"
|
||||
rx="1.258645"
|
||||
ry="1.269222"
|
||||
fill="url(#n)"
|
||||
id="ellipse39" />
|
||||
<path
|
||||
d="m34.907458 21.514826c-.139711 5.803305-5.22883 10.533079-10.907418 10.842345v.5c5.915631-.14596 10.907418-5.027966 10.907418-11.065232 0-.09308.0021-.184881 0-.277113z"
|
||||
fill="#6e3e86"
|
||||
id="path40" />
|
||||
</g>
|
||||
<circle
|
||||
style="fill:#289cde;fill-opacity:1;stroke-width:1.11661"
|
||||
id="path41"
|
||||
cx="24"
|
||||
cy="22.658934"
|
||||
r="11" />
|
||||
<circle
|
||||
style="fill:#59b6e9;fill-opacity:1;stroke-width:1.11661"
|
||||
id="path41-3"
|
||||
cx="24"
|
||||
cy="21.752449"
|
||||
r="11" />
|
||||
<circle
|
||||
style="fill:#f0f2f3;fill-opacity:1;stroke-width:1.34769"
|
||||
id="path42"
|
||||
cx="24"
|
||||
cy="21.752449"
|
||||
r="8.5" />
|
||||
<circle
|
||||
style="fill:#59b6e9;fill-opacity:1;stroke-width:1.18913"
|
||||
id="path42-6"
|
||||
cx="24"
|
||||
cy="21.752449"
|
||||
r="7.5" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-variant:normal;font-weight:600;font-stretch:normal;font-size:16px;font-family:'Noto Sans';-inkscape-font-specification:'Noto Sans Semi-Bold';fill:#f0f2f3;fill-opacity:1"
|
||||
x="21.695999"
|
||||
y="27.760448"
|
||||
id="text43"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan43"
|
||||
x="21.695999"
|
||||
y="27.760448">i</tspan></text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 13 KiB |
55
src/jsonparser.cpp
Normal file
55
src/jsonparser.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "jsonparser.h"
|
||||
|
||||
JsonParser::JsonParser()
|
||||
{
|
||||
}
|
||||
|
||||
QVector<QPair<QString, int>> JsonParser::parse(const QString &json)
|
||||
{
|
||||
QVector<QPair<QString, int>> data;
|
||||
QStringList lines = json.split('\n');
|
||||
bool found = false;
|
||||
bool skip = false;
|
||||
|
||||
for (const QString &line : lines) {
|
||||
QString trimmedLine = line.trimmed();
|
||||
if (trimmedLine.contains("[")) {
|
||||
skip = true;
|
||||
continue;
|
||||
}
|
||||
if (trimmedLine.contains("]")) {
|
||||
skip = false;
|
||||
continue;
|
||||
}
|
||||
if (skip) {
|
||||
continue;
|
||||
}
|
||||
if (trimmedLine.contains("nvme_smart_health_information_log")) {
|
||||
found = true;
|
||||
continue;
|
||||
}
|
||||
if (found) {
|
||||
if (trimmedLine.contains("}")) {
|
||||
break;
|
||||
}
|
||||
int colon_pos = trimmedLine.indexOf(":");
|
||||
if (colon_pos != -1) {
|
||||
QString key = removeQuotes(trimmedLine.left(colon_pos));
|
||||
QString valueString = trimmedLine.mid(colon_pos + 1).trimmed();
|
||||
valueString.chop(1);
|
||||
int value = valueString.toInt();
|
||||
data.append(qMakePair(key, value));
|
||||
}
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
QString JsonParser::removeQuotes(const QString &s)
|
||||
{
|
||||
QString result = s.trimmed();
|
||||
if (result.length() >= 2 && result.front() == '"' && result.back() == '"') {
|
||||
return result.mid(1, result.size() - 2);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
20
src/jsonparser.h
Normal file
20
src/jsonparser.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef JSONPARSER_H
|
||||
#define JSONPARSER_H
|
||||
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <QStringList>
|
||||
#include <QPair>
|
||||
|
||||
class JsonParser
|
||||
{
|
||||
public:
|
||||
JsonParser();
|
||||
|
||||
QVector<QPair<QString, int>> parse(const QString &json);
|
||||
|
||||
private:
|
||||
QString removeQuotes(const QString &s);
|
||||
};
|
||||
|
||||
#endif
|
||||
12
src/main.cpp
Normal file
12
src/main.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.setWindowIcon(QIcon(":/icons/icon.svg"));
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
1013
src/mainwindow.cpp
Normal file
1013
src/mainwindow.cpp
Normal file
File diff suppressed because it is too large
Load Diff
98
src/mainwindow.h
Normal file
98
src/mainwindow.h
Normal file
@@ -0,0 +1,98 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QProcess>
|
||||
#include <QWidget>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QButtonGroup>
|
||||
#include <QAction>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
#include <QTimer>
|
||||
#include <QSettings>
|
||||
#include <QMouseEvent>
|
||||
#include <cmath>
|
||||
|
||||
#include "statusdot.h"
|
||||
#include "custombutton.h"
|
||||
#include "jsonparser.h"
|
||||
#include "./ui_mainwindow.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
bool initializing;
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
private slots:
|
||||
void on_actionQuit_triggered();
|
||||
|
||||
void on_actionSave_JSON_triggered();
|
||||
|
||||
void on_actionGitHub_triggered();
|
||||
|
||||
void on_actionRescan_Refresh_triggered();
|
||||
|
||||
void on_actionAbout_triggered();
|
||||
|
||||
void on_actionIgnore_C4_Reallocation_Event_Count_toggled(bool enabled);
|
||||
|
||||
void on_actionHEX_toggled(bool enabled);
|
||||
|
||||
void on_actionUse_Fahrenheit_toggled(bool enabled);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
QButtonGroup *buttonGroup;
|
||||
QHBoxLayout *horizontalLayout;
|
||||
QLabel *diskName, *temperatureValue, *healthStatusValue;
|
||||
QLineEdit *firmwareLineEdit, *serialNumberLineEdit, *typeLineEdit, *protocolLineEdit, *deviceNodeLineEdit;
|
||||
QLineEdit *totalReadsLineEdit, *totalWritesLineEdit, *rotationRateLineEdit, *powerOnCountLineEdit, *powerOnHoursLineEdit;
|
||||
QTableWidget *tableWidget;
|
||||
QPushButton *prevButton, *nextButton;
|
||||
QColor goodColor, cautionColor, badColor, naColor;
|
||||
QJsonObject deviceJson;
|
||||
QSpacerItem *buttonStretch;
|
||||
QSettings settings;
|
||||
|
||||
QMenu *menuDisk;
|
||||
QMenu *toolMenu;
|
||||
|
||||
QJsonArray devices;
|
||||
QStringList deviceOutputs;
|
||||
QJsonObject globalObj;
|
||||
QString globalHealth;
|
||||
bool globalIsNvme;
|
||||
QVector<QPair<QString, int>> globalNvmeSmartOrdered;
|
||||
|
||||
void onNextButtonClicked();
|
||||
void onPrevButtonClicked();
|
||||
void updateNavigationButtons(int currentIndex);
|
||||
void scanDevices();
|
||||
void updateUI();
|
||||
void selfTestHandler(const QString &mode, const QString &name, const QString &minutes);
|
||||
void populateWindow(const QJsonObject &tempObj, const QString &health, const QVector<QPair<QString, int>>& nvmeLogOrdered = QVector<QPair<QString, int>>());
|
||||
void addNvmeLogTable(const QVector<QPair<QString, int>>& nvmeLogOrdered);
|
||||
void addSmartAttributesTable(const QJsonArray &attributes);
|
||||
QString getSmartctlOutput(const QStringList &arguments, bool root);
|
||||
QString toTitleCase(const QString& sentence);
|
||||
void clearButtonGroup();
|
||||
QString initiateSelfTest(const QString &testType, const QString &deviceNode);
|
||||
void cancelSelfTest(const QString &deviceNode);
|
||||
void mousePressEvent(QMouseEvent*);
|
||||
};
|
||||
#endif
|
||||
449
src/mainwindow.ui
Normal file
449
src/mainwindow.ui
Normal file
@@ -0,0 +1,449 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::NonModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>KDiskInfo</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="resources.qrc">
|
||||
<normaloff>:/icons/icon.svg</normaloff>:/icons/icon.svg</iconset>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="disks">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QTableWidget" name="dataTable">
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="navigation">
|
||||
<item>
|
||||
<widget class="QPushButton" name="previousButton">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="go-previous">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="diskName">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p align="center"><span style=" font-size:14pt; font-weight:700;">Hard Drive Name</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="nextButton">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="go-next">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="info">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="healthStatusLabel">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p align="center">Health Status</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="healthStatusValueLabel">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(0, 255, 0);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p align="center"><span style=" font-size:12pt; font-weight:700; color:#000000;">Good</span></p><p align="center"><span style=" font-size:12pt; font-weight:700; color:#000000;">100 %</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="temperatureLabel">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p align="center">Temperature</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="temperatureValueLabel">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(0, 255, 0);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p align="center"><span style=" font-size:12pt; font-weight:700; color:#000000;">23° C</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="firmwareLabel">
|
||||
<property name="text">
|
||||
<string>Firmware</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="firmwareLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="serialNumberLabel">
|
||||
<property name="text">
|
||||
<string>Serial Number</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="serialNumberLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="protocolLabel">
|
||||
<property name="text">
|
||||
<string>Protocol</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="protocolLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="deviceNodeLabel">
|
||||
<property name="text">
|
||||
<string>Device Node</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="deviceNodeLineEdit">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="typeLabel">
|
||||
<property name="text">
|
||||
<string>Type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="typeLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="totalReadsLabel">
|
||||
<property name="text">
|
||||
<string>Total Host Reads</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="totalReadsLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="totalWritesLabel">
|
||||
<property name="text">
|
||||
<string>Total Host Writes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="totalWritesLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="rotationRateLabel">
|
||||
<property name="text">
|
||||
<string>Rotation Rate</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="rotationRateLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="powerOnCountLabel">
|
||||
<property name="text">
|
||||
<string>Power On Count</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="powerOnCountLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="powerOnHoursLabel">
|
||||
<property name="text">
|
||||
<string>Power On Hours</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="powerOnHoursLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
<property name="title">
|
||||
<string>File</string>
|
||||
</property>
|
||||
<addaction name="actionSave_JSON"/>
|
||||
<addaction name="actionQuit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuSettings">
|
||||
<property name="title">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<addaction name="actionIgnore_C4_Reallocation_Event_Count"/>
|
||||
<addaction name="actionHEX"/>
|
||||
<addaction name="actionUse_Fahrenheit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuHelp">
|
||||
<property name="title">
|
||||
<string>&Help</string>
|
||||
</property>
|
||||
<addaction name="actionGitHub"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionAbout"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuDisk">
|
||||
<property name="title">
|
||||
<string>De&vice</string>
|
||||
</property>
|
||||
<addaction name="actionRescan_Refresh"/>
|
||||
<addaction name="separator"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuDisk"/>
|
||||
<addaction name="menuSettings"/>
|
||||
<addaction name="menuHelp"/>
|
||||
</widget>
|
||||
<action name="actionSave_JSON">
|
||||
<property name="icon">
|
||||
<iconset theme="document-save">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Save JSON</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionQuit">
|
||||
<property name="icon">
|
||||
<iconset theme="application-exit">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Quit</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRescan_Refresh">
|
||||
<property name="icon">
|
||||
<iconset theme="view-refresh">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Refresh Devices</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionGitHub">
|
||||
<property name="icon">
|
||||
<iconset theme="applications-internet">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&GitHub</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAbout">
|
||||
<property name="icon">
|
||||
<iconset theme="help-about">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&About</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionIgnore_C4_Reallocation_Event_Count">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Ignore C4 (Reallocated Event Count)</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionHEX">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Convert Raw values to HEX</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionUse_Fahrenheit">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Use Fahrenheit</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSelf_Test">
|
||||
<property name="text">
|
||||
<string>Self Test</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
5
src/resources.qrc
Normal file
5
src/resources.qrc
Normal file
@@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/icons">
|
||||
<file>icon.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
17
src/statusdot.cpp
Normal file
17
src/statusdot.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "statusdot.h"
|
||||
|
||||
void StatusDot::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QStyleOptionViewItem opt = option;
|
||||
initStyleOption(&opt, index);
|
||||
int dotSize = 15;
|
||||
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
QRect dotRect(opt.rect.center().x() - dotSize / 2, opt.rect.center().y() - dotSize / 2, dotSize, dotSize);
|
||||
QColor color = QColor(index.data(Qt::BackgroundRole).value<QColor>());
|
||||
painter->setBrush(color);
|
||||
painter->setPen(Qt::NoPen);
|
||||
painter->drawEllipse(dotRect);
|
||||
painter->restore();
|
||||
}
|
||||
20
src/statusdot.h
Normal file
20
src/statusdot.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef STATUSDOT_H
|
||||
#define STATUSDOT_H
|
||||
|
||||
#include <QPainter>
|
||||
#include <QStyleOptionViewItem>
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
class StatusDot : public QStyledItemDelegate
|
||||
{
|
||||
public:
|
||||
StatusDot(QObject *parent = nullptr)
|
||||
: QStyledItemDelegate(parent)
|
||||
{}
|
||||
|
||||
void paint(QPainter *painter,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const override;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user