mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-17 16:28:06 +03:00
Ladybird: Replace forward/back/reload SVGs with TVGs
Doing this removes the qt6-svg dependency and allows our rasterizer to be used for these little icons (and happens to be a fair bit smaller than the old SVGs).
This commit is contained in:
parent
bb5db0835d
commit
dfcd7b3ca5
Notes:
sideshowbarker
2024-07-17 05:41:34 +09:00
Author: https://github.com/MacDue Commit: https://github.com/SerenityOS/serenity/commit/dfcd7b3ca5 Pull-request: https://github.com/SerenityOS/serenity/pull/19765 Reviewed-by: https://github.com/LucasChollet Reviewed-by: https://github.com/gmta ✅
@ -7,7 +7,7 @@ Qt6 development packages and a C++20 capable compiler are required. gcc-12 or cl
|
||||
On Debian/Ubuntu required packages include, but are not limited to:
|
||||
|
||||
```
|
||||
sudo apt install build-essential cmake libgl1-mesa-dev ninja-build qt6-base-dev libqt6svg6-dev qt6-tools-dev-tools qt6-multimedia-dev
|
||||
sudo apt install build-essential cmake libgl1-mesa-dev ninja-build qt6-base-dev qt6-tools-dev-tools qt6-multimedia-dev
|
||||
```
|
||||
|
||||
For Ubuntu 20.04 and above, ensure that the Qt6 Wayland packages are available:
|
||||
@ -19,12 +19,12 @@ sudo apt install qt6-wayland
|
||||
On Arch Linux/Manjaro:
|
||||
|
||||
```
|
||||
sudo pacman -S --needed base-devel cmake libgl ninja qt6-base qt6-svg qt6-tools qt6-wayland qt6-multimedia
|
||||
sudo pacman -S --needed base-devel cmake libgl ninja qt6-base qt6-tools qt6-wayland qt6-multimedia
|
||||
```
|
||||
|
||||
On Fedora or derivatives:
|
||||
```
|
||||
sudo dnf install cmake libglvnd-devel ninja-build qt6-qtbase-devel qt6-qtsvg-devel qt6-qttools-devel qt6-qtwayland-devel qt6-qtmultimedia-devel
|
||||
sudo dnf install cmake libglvnd-devel ninja-build qt6-qtbase-devel qt6-qttools-devel qt6-qtwayland-devel qt6-qtmultimedia-devel
|
||||
```
|
||||
|
||||
On openSUSE:
|
||||
|
@ -73,7 +73,7 @@ add_compile_options(-Wno-user-defined-literals)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Widgets Network Svg Multimedia)
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Widgets Network Multimedia)
|
||||
|
||||
set(BROWSER_SOURCE_DIR ${SERENITY_SOURCE_DIR}/Userland/Applications/Browser/)
|
||||
|
||||
@ -100,7 +100,7 @@ set(SOURCES
|
||||
qt_add_executable(ladybird ${SOURCES}
|
||||
MANUAL_FINALIZATION
|
||||
)
|
||||
target_link_libraries(ladybird PRIVATE Qt::Core Qt::Gui Qt::Network Qt::Widgets Qt::Svg LibCore LibFileSystem LibGfx LibGUI LibIPC LibJS LibMain LibWeb LibWebView LibSQL)
|
||||
target_link_libraries(ladybird PRIVATE Qt::Core Qt::Gui Qt::Network Qt::Widgets LibCore LibFileSystem LibGfx LibGUI LibIPC LibJS LibMain LibWeb LibWebView LibSQL)
|
||||
|
||||
target_include_directories(ladybird PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_include_directories(ladybird PRIVATE ${SERENITY_SOURCE_DIR}/Userland/)
|
||||
|
@ -1,44 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
width="16"
|
||||
height="16"
|
||||
viewBox="0 0 16 16"
|
||||
version="1.1"
|
||||
id="svg5"
|
||||
sodipodi:docname="back.svg"
|
||||
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
|
||||
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="32"
|
||||
inkscape:cx="29.5625"
|
||||
inkscape:cy="16.484375"
|
||||
inkscape:window-width="2560"
|
||||
inkscape:window-height="1376"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="layer1" />
|
||||
<defs
|
||||
id="defs2" />
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<path
|
||||
id="path859-3"
|
||||
style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 1.5289043,7.2483442 4.640287,4.7137268 m -0.0094,-8.2921718 C 4.6606103,5.1690804 3.1614293,6.6682616 1.6622483,8.1674428 M 15.620723,7.8185797 c -4.501666,0 -9.003333,0 -13.5049997,0" />
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 1.5 KiB |
BIN
Ladybird/Icons/back.tvg
Normal file
BIN
Ladybird/Icons/back.tvg
Normal file
Binary file not shown.
@ -1,53 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
width="16"
|
||||
height="16"
|
||||
viewBox="0 0 16 16"
|
||||
version="1.1"
|
||||
id="svg5"
|
||||
sodipodi:docname="forward.svg"
|
||||
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
|
||||
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="32"
|
||||
inkscape:cx="29.5625"
|
||||
inkscape:cy="16.484375"
|
||||
inkscape:window-width="2560"
|
||||
inkscape:window-height="1376"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="layer1" />
|
||||
<defs
|
||||
id="defs2" />
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="m 0.99442699,7.8185797 c 4.50166671,0 9.00333331,0 13.50500001,0"
|
||||
id="path2176" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="m 10.455359,3.6698992 c 1.499181,1.4991812 2.998362,2.9983624 4.497543,4.4975436"
|
||||
id="path2174" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 15.086246,7.2483442 10.445959,11.962071"
|
||||
id="path859-3"
|
||||
sodipodi:nodetypes="cc" />
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 1.9 KiB |
BIN
Ladybird/Icons/forward.tvg
Normal file
BIN
Ladybird/Icons/forward.tvg
Normal file
Binary file not shown.
@ -1,52 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
width="16"
|
||||
height="16"
|
||||
viewBox="0 0 16 16"
|
||||
version="1.1"
|
||||
id="svg5"
|
||||
sodipodi:docname="reload.svg"
|
||||
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
|
||||
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="11.313709"
|
||||
inkscape:cx="2.7400388"
|
||||
inkscape:cy="-0.13258252"
|
||||
inkscape:window-width="1540"
|
||||
inkscape:window-height="1088"
|
||||
inkscape:window-x="414"
|
||||
inkscape:window-y="121"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="layer1" />
|
||||
<defs
|
||||
id="defs2" />
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 13.864001,2.0313971 13.864,5.9645124"
|
||||
id="path3866" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 14.612807,5.2101315 -3.933116,1e-7"
|
||||
id="path859-3" />
|
||||
<path
|
||||
id="path3568"
|
||||
style="fill:none;stroke:#000000;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="M 14.063077 9.0934891 A 6.1322012 6.1322012 0 0 1 8.0587416 13.979959 A 6.1322012 6.1322012 0 0 1 1.9265404 7.8477583 A 6.1322012 6.1322012 0 0 1 8.0587416 1.7155571 A 6.1322012 6.1322012 0 0 1 13.352215 4.7521116 " />
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 1.9 KiB |
BIN
Ladybird/Icons/reload.tvg
Normal file
BIN
Ladybird/Icons/reload.tvg
Normal file
Binary file not shown.
@ -13,6 +13,7 @@
|
||||
#include "Utilities.h"
|
||||
#include <Browser/History.h>
|
||||
#include <LibGfx/ImageFormats/BMPWriter.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <QClipboard>
|
||||
#include <QCoreApplication>
|
||||
#include <QCursor>
|
||||
@ -27,30 +28,31 @@
|
||||
#include <QPlainTextEdit>
|
||||
#include <QPoint>
|
||||
#include <QResizeEvent>
|
||||
#include <QSvgRenderer>
|
||||
|
||||
extern DeprecatedString s_serenity_resource_root;
|
||||
extern Browser::Settings* s_settings;
|
||||
|
||||
static QIcon render_svg_icon_with_theme_colors(QString name, QPalette const& palette)
|
||||
static QIcon render_tvg_icon_with_theme_colors(QString name, QPalette const& palette)
|
||||
{
|
||||
auto path = QString(":/Icons/%1.svg").arg(name);
|
||||
auto path = QString(":/Icons/%1.tvg").arg(name);
|
||||
Gfx::IntSize icon_size(16, 16);
|
||||
|
||||
QSize icon_size(16, 16);
|
||||
QFile icon_resource(path);
|
||||
VERIFY(icon_resource.open(QIODeviceBase::ReadOnly));
|
||||
auto icon_data = icon_resource.readAll();
|
||||
ReadonlyBytes icon_bytes { icon_data.data(), static_cast<size_t>(icon_data.size()) };
|
||||
auto icon_raster = MUST(Gfx::Bitmap::load_from_bytes(icon_bytes, icon_size));
|
||||
|
||||
QIcon icon;
|
||||
|
||||
auto render = [&](QColor color) -> QPixmap {
|
||||
QImage image(icon_size, QImage::Format_ARGB32);
|
||||
image.fill(Qt::transparent);
|
||||
|
||||
QPainter painter(&image);
|
||||
QSvgRenderer renderer(path);
|
||||
renderer.render(&painter);
|
||||
painter.setBrush(color);
|
||||
painter.setCompositionMode(QPainter::CompositionMode_SourceAtop);
|
||||
painter.fillRect(image.rect(), color);
|
||||
return QPixmap::fromImage(image);
|
||||
auto image = MUST(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, icon_size));
|
||||
Gfx::Painter painter { image };
|
||||
auto icon_color = Color::from_argb(color.rgba64().toArgb32());
|
||||
painter.blit_filtered({ 0, 0 }, *icon_raster, icon_raster->rect(), [&](auto color) {
|
||||
return icon_color.with_alpha((icon_color.alpha() * color.alpha()) / 255);
|
||||
});
|
||||
QImage qimage { image->scanline_u8(0), image->width(), image->height(), QImage::Format::Format_ARGB32 };
|
||||
return QPixmap::fromImage(qimage);
|
||||
};
|
||||
|
||||
icon.addPixmap(render(palette.color(QPalette::ColorGroup::Normal, QPalette::ColorRole::ButtonText)), QIcon::Mode::Normal);
|
||||
@ -622,9 +624,9 @@ bool Tab::event(QEvent* event)
|
||||
|
||||
void Tab::rerender_toolbar_icons()
|
||||
{
|
||||
m_window->go_back_action().setIcon(render_svg_icon_with_theme_colors("back", palette()));
|
||||
m_window->go_forward_action().setIcon(render_svg_icon_with_theme_colors("forward", palette()));
|
||||
m_window->reload_action().setIcon(render_svg_icon_with_theme_colors("reload", palette()));
|
||||
m_window->go_back_action().setIcon(render_tvg_icon_with_theme_colors("back", palette()));
|
||||
m_window->go_forward_action().setIcon(render_tvg_icon_with_theme_colors("forward", palette()));
|
||||
m_window->reload_action().setIcon(render_tvg_icon_with_theme_colors("reload", palette()));
|
||||
}
|
||||
|
||||
void Tab::show_inspector_window(InspectorTarget inspector_target)
|
||||
|
@ -1,8 +1,8 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource>
|
||||
<file>Icons/ladybird.png</file>
|
||||
<file>Icons/back.svg</file>
|
||||
<file>Icons/forward.svg</file>
|
||||
<file>Icons/reload.svg</file>
|
||||
<file>Icons/back.tvg</file>
|
||||
<file>Icons/forward.tvg</file>
|
||||
<file>Icons/reload.tvg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Loading…
Reference in New Issue
Block a user