use svg icons for editor gutter

This commit is contained in:
Roy Qu 2021-12-20 12:53:35 +08:00
parent 74fdf1ebef
commit 6f73ccff2f
13 changed files with 253 additions and 20 deletions

View File

@ -450,10 +450,6 @@
<file>images/newlook64/087-update.png</file>
<file>images/newlook64/088-watch.png</file>
<file>images/newlook64/089-watch-tm.png</file>
<file>images/editor/breakpoint.png</file>
<file>images/editor/currentline.png</file>
<file>images/editor/syntaxerror.png</file>
<file>images/editor/syntaxwarning.png</file>
<file>images/associations/c.ico</file>
<file>images/associations/cpp.ico</file>
<file>images/associations/dev.ico</file>
@ -486,10 +482,13 @@
<file>images/classparser/var_private.ico</file>
<file>images/classparser/var_protected.ico</file>
<file>images/classparser/var_public.ico</file>
<file>images/editor/bookmark.png</file>
<file>images/newlook24/091-openproblemanswer.png</file>
<file>images/newlook24/092-runallproblemcases.png</file>
<file>images/newlook24/093-pause.png</file>
<file>images/editor/breakpoint.svg</file>
<file>images/editor/bookmark.svg</file>
<file>images/editor/currentline.svg</file>
<file>images/editor/syntaxerror.svg</file>
<file>images/editor/syntaxwarning.svg</file>
</qresource>
</RCC>

View File

@ -7,23 +7,18 @@ IconsManager* pIconsManager;
IconsManager::IconsManager(QObject *parent) : QObject(parent)
{
updateIcons(24);
updateEditorGuttorIcons(24);
mFolder = std::make_shared<QPixmap>(":/icons/images/newlook24/090-explorer.png");
}
void IconsManager::updateIcons(int size)
void IconsManager::updateEditorGuttorIcons(int size)
{
QSvgRenderer renderer(QString(":/icons/images/editor/breakpoint.svg"));
mBreakpoint = std::make_shared<QPixmap>(size,size);
mBreakpoint->fill(Qt::transparent);
QPainter painter(mBreakpoint.get());
renderer.render(&painter,mBreakpoint->rect());
mSyntaxError = std::make_shared<QPixmap>(":/icons/images/editor/syntaxerror.png");
mSyntaxWarning = std::make_shared<QPixmap>(":/icons/images/editor/syntaxwarning.png");
mActiveBreakpoint = std::make_shared<QPixmap>(":/icons/images/editor/currentline.png");
mBookmark = std::make_shared<QPixmap>(":/icons/images/editor/bookmark.png");
mFolder = std::make_shared<QPixmap>(":/icons/images/newlook24/090-explorer.png");
mBreakpoint = createSVGIcon(":/icons/images/editor/breakpoint.svg",size,size);
mSyntaxError = createSVGIcon(":/icons/images/editor/syntaxerror.svg",size,size);
mSyntaxWarning = createSVGIcon(":/icons/images/editor/syntaxwarning.svg",size,size);
mActiveBreakpoint = createSVGIcon(":/icons/images/editor/currentline.svg",size,size);
mBookmark = createSVGIcon(":/icons/images/editor/bookmark.svg",size,size);
}
const PIcon &IconsManager::syntaxError() const
@ -55,3 +50,13 @@ const PIcon &IconsManager::folder() const
{
return mFolder;
}
PIcon IconsManager::createSVGIcon(const QString &filename, int width, int height)
{
QSvgRenderer renderer(filename);
PIcon icon = std::make_shared<QPixmap>(width,height);
icon->fill(Qt::transparent);
QPainter painter(icon.get());
renderer.render(&painter,icon->rect());
return icon;
}

View File

@ -12,7 +12,7 @@ class IconsManager : public QObject
public:
explicit IconsManager(QObject *parent = nullptr);
void updateIcons(int size);
void updateEditorGuttorIcons(int size);
const PIcon &syntaxError() const;
@ -25,6 +25,8 @@ public:
const PIcon &bookmark() const;
const PIcon &folder() const;
PIcon createSVGIcon(const QString& filename, int width, int height);
private:
PIcon mSyntaxError;
PIcon mSyntaxWarning;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="100mm"
height="100mm"
viewBox="0 0 100 100"
version="1.1"
id="svg5"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
sodipodi:docname="bookmark.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="px"
showgrid="false"
inkscape:zoom="0.72337262"
inkscape:cx="217.0389"
inkscape:cy="230.17183"
inkscape:window-width="1120"
inkscape:window-height="991"
inkscape:window-x="-8"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:current-layer="layer1" />
<defs
id="defs2" />
<g
inkscape:label="图层 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="fill:#fe6407;stroke:#000000;stroke-width:2.64583331;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
d="m 12.43596,8.7783248 0,84.4913792 37.673646,-35.113301 38.770935,35.113301 V 9.1440885 Z"
id="path890"
sodipodi:nodetypes="cccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="100"
height="100"
viewBox="0 0 26.458333 26.458334"
version="1.1"
id="svg5"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
sodipodi:docname="currentline.svg"
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">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="px"
showgrid="false"
inkscape:zoom="2.8934904"
inkscape:cx="137.20453"
inkscape:cy="69.293473"
inkscape:window-width="1920"
inkscape:window-height="1001"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="layer1"
units="px" />
<defs
id="defs2">
<linearGradient
inkscape:collect="always"
id="linearGradient1991">
<stop
style="stop-color:#5cc1ff;stop-opacity:1;"
offset="0"
id="stop1987" />
<stop
style="stop-color:#5cc1ff;stop-opacity:0.5"
offset="1"
id="stop1989" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient1991"
id="linearGradient1993"
x1="17.190887"
y1="15.54495"
x2="16.288605"
y2="7.9697156"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,0,0,1.3723604,0.09144089,-3.8469823)" />
</defs>
<g
inkscape:label="图层 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="fill:url(#linearGradient1993);fill-opacity:1;stroke:#000000;stroke-width:0.929861;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 1.0058496,9.5804319 H 15.636392 l -0.914409,-4.3921447 9.875616,6.9019418 -10.24138,8.031351 1.188732,-4.392145 -14.4476604,0.125489 z"
id="path1016"
sodipodi:nodetypes="cccccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="100"
height="100"
viewBox="0 0 26.458333 26.458334"
version="1.1"
id="svg5"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
sodipodi:docname="syntaxerror.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="px"
showgrid="false"
inkscape:zoom="2.8934904"
inkscape:cx="137.20453"
inkscape:cy="69.293473"
inkscape:window-width="1920"
inkscape:window-height="1001"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="layer1"
units="px" />
<defs
id="defs2" />
<g
inkscape:label="图层 1"
inkscape:groupmode="layer"
id="layer1">
<ellipse
style="fill:#ff0000;fill-opacity:1;stroke:#000000;stroke-width:0.60914;stroke-miterlimit:4;stroke-dasharray:none"
id="path927"
cx="13.076049"
cy="13.350369"
rx="12.487414"
ry="12.670298" />
<path
style="fill:none;stroke:#f4f117;stroke-width:2.64583335;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
d="M 5.669335,4.846367 20.482759,21.945813"
id="path936" />
<path
style="fill:none;stroke:#f4f117;stroke-width:2.64583;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 20.299878,4.8920877 5.4864537,21.991533"
id="path936-6" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="100"
height="100"
viewBox="0 0 26.458333 26.458334"
version="1.1"
id="svg5"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
sodipodi:docname="syntaxwarning.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="px"
showgrid="false"
inkscape:zoom="2.8934904"
inkscape:cx="137.20453"
inkscape:cy="69.293473"
inkscape:window-width="1920"
inkscape:window-height="1001"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="layer1"
units="px" />
<defs
id="defs2" />
<g
inkscape:label="图层 1"
inkscape:groupmode="layer"
id="layer1">
<ellipse
style="fill:#b0b0b0;fill-opacity:1;stroke:#000096;stroke-width:0.60914;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path927"
cx="13.076049"
cy="13.350369"
rx="12.487414"
ry="12.670298" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -321,7 +321,7 @@ void MainWindow::updateForEncodingInfo() {
void MainWindow::updateEditorSettings()
{
pIconsManager->updateIcons(pointToPixel(pSettings->editor().fontSize()));
pIconsManager->updateEditorGuttorIcons(pointToPixel(pSettings->editor().fontSize()));
mEditorList->applySettings();
}