CSD icons in SVG
This commit is contained in:
+3
-3
@@ -44,11 +44,11 @@ constexpr ActionDef kDefs[] = {
|
||||
{kMenu, {N_("_New Window")}, {}, {{Qt::Key_N, kCtrl}}, {}},
|
||||
// It's a bit strange that the CSD buttons get actions and custom icons,
|
||||
// though so far it makes things simpler.
|
||||
{kMenu, {N_("_Close Window")}, {"window-close"},
|
||||
{kMenu, {N_("_Close Window")}, {"dn-window-close-symbolic"},
|
||||
{{Qt::Key_W, kCtrl}, {Qt::Key_Q}}, {}},
|
||||
{0, {N_("_Minimise")}, {"window-minimize"}, {}, {}},
|
||||
{0, {N_("_Minimise")}, {"dn-window-minimize-symbolic"}, {}, {}},
|
||||
{kToggle, {N_("_Maximise"), N_("Res_tore")},
|
||||
{"window-maximize", "window-restore"}, {}, {}},
|
||||
{"dn-window-maximize-symbolic", "dn-window-restore-symbolic"}, {}, {}},
|
||||
{kMenu, {N_("_Quit")}, {}, {{Qt::Key_Q, kCtrl}}, {}},
|
||||
{kToggle, {N_("Enter _Full Screen"), N_("Exit _Full Screen")},
|
||||
{"view-fullscreen-symbolic", "view-restore-symbolic"}, {
|
||||
|
||||
+1
-61
@@ -19,8 +19,6 @@
|
||||
#include <QImage>
|
||||
#include <QKeyEvent>
|
||||
#include <QMimeData>
|
||||
#include <QPainter>
|
||||
#include <QPen>
|
||||
#include <QTextBoundaryFinder>
|
||||
|
||||
#include <qnamespace.h>
|
||||
@@ -31,7 +29,6 @@
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
@@ -131,61 +128,6 @@ raster_symbolic(const char *name, int px)
|
||||
return image;
|
||||
}
|
||||
|
||||
static QImage
|
||||
raster_window_button(const char *name, int px)
|
||||
{
|
||||
enum class Kind : uint8_t { None, Min, Max, Rest, Close };
|
||||
Kind kind = Kind::None;
|
||||
if (name && strcmp(name, "window-minimize") == 0)
|
||||
kind = Kind::Min;
|
||||
else if (name && strcmp(name, "window-maximize") == 0)
|
||||
kind = Kind::Max;
|
||||
else if (name && strcmp(name, "window-restore") == 0)
|
||||
kind = Kind::Rest;
|
||||
else if (name && strcmp(name, "window-close") == 0)
|
||||
kind = Kind::Close;
|
||||
if (kind == Kind::None || px < 1)
|
||||
return {};
|
||||
|
||||
QImage image(px, px, QImage::Format_ARGB32_Premultiplied);
|
||||
image.fill(Qt::transparent);
|
||||
QPainter painter(&image);
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
const qreal sw = max(1.25, qreal(px) / 12.0);
|
||||
painter.setPen(
|
||||
QPen(Qt::white, sw, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin));
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
const qreal m = qreal(px) * 0.22;
|
||||
const QRectF box(m, m, qreal(px) - 2.0 * m, qreal(px) - 2.0 * m);
|
||||
switch (kind) {
|
||||
case Kind::Min:
|
||||
painter.drawLine(QPointF(m, qreal(px) * 0.55),
|
||||
QPointF(qreal(px) - m, qreal(px) * 0.55));
|
||||
break;
|
||||
case Kind::Max:
|
||||
painter.drawRect(box);
|
||||
break;
|
||||
case Kind::Rest: {
|
||||
const qreal s = box.width() * 0.68;
|
||||
const QRectF back(box.right() - s, box.top(), s, s);
|
||||
const QRectF front(box.left(), box.bottom() - s, s, s);
|
||||
painter.drawRect(back);
|
||||
painter.setCompositionMode(QPainter::CompositionMode_Source);
|
||||
painter.fillRect(front.adjusted(-sw, -sw, sw, sw), Qt::transparent);
|
||||
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
|
||||
painter.drawRect(front);
|
||||
break;
|
||||
}
|
||||
case Kind::Close:
|
||||
painter.drawLine(box.topLeft(), box.bottomRight());
|
||||
painter.drawLine(box.topRight(), box.bottomLeft());
|
||||
break;
|
||||
case Kind::None:
|
||||
break;
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
static Qt::CursorShape
|
||||
resize_cursor(Qt::Edges edges)
|
||||
{
|
||||
@@ -4347,9 +4289,7 @@ Kit::draw_icon(int x, int y, int size, const char *name, Colour colour)
|
||||
const auto key = make_pair(string(name), size);
|
||||
auto it = this->icons_.find(key);
|
||||
if (it == this->icons_.end()) {
|
||||
QImage image = raster_symbolic(name, size);
|
||||
if (image.isNull())
|
||||
image = raster_window_button(name, size);
|
||||
const QImage image = raster_symbolic(name, size);
|
||||
if (image.isNull())
|
||||
return;
|
||||
const Packed packed = pack_bitmap(image, true);
|
||||
|
||||
@@ -3,3 +3,5 @@ The authors have disclaimed most of their rights to the works under CC0 1.0[1].
|
||||
|
||||
[0] https://gitlab.gnome.org/Teams/Design/icon-development-kit/
|
||||
[1] https://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
dn-* icons are local inventions.
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
|
||||
<path d="M 4 4 L 12 12 M 12 4 L 4 12" fill="none" stroke="rgb(0,0,0)" stroke-width="2" stroke-linecap="square"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 186 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
|
||||
<rect x="4" y="4" width="8" height="8" fill="none" stroke="rgb(0,0,0)" stroke-width="2"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 163 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
|
||||
<rect x="3" y="8" width="10" height="2" fill="rgb(0,0,0)"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 133 B |
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
|
||||
<path d="M 6 4 H 12 V 10" fill="none" stroke="rgb(0,0,0)" stroke-width="2"/>
|
||||
<rect x="4" y="7" width="5" height="5" fill="none" stroke="rgb(0,0,0)" stroke-width="2"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 242 B |
@@ -61,5 +61,9 @@
|
||||
<file alias="view-sort-descending-symbolic.svg">view-sort-descending-symbolic.svg</file>
|
||||
<file alias="x-symbolic.svg">x-symbolic.svg</file>
|
||||
<file alias="zoom-fit-symbolic.svg">zoom-fit-symbolic.svg</file>
|
||||
<file alias="dn-window-close-symbolic.svg">dn-window-close-symbolic.svg</file>
|
||||
<file alias="dn-window-maximize-symbolic.svg">dn-window-maximize-symbolic.svg</file>
|
||||
<file alias="dn-window-minimize-symbolic.svg">dn-window-minimize-symbolic.svg</file>
|
||||
<file alias="dn-window-restore-symbolic.svg">dn-window-restore-symbolic.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
Reference in New Issue
Block a user