mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
Everywhere: Move the Ladybird folder to UI
This commit is contained in:
parent
93712b24bf
commit
db47cc41f8
Notes:
github-actions[bot]
2024-11-10 11:51:45 +00:00
Author: https://github.com/trflynn89
Commit: db47cc41f8
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
203 changed files with 266 additions and 244 deletions
44
UI/Qt/Icon.cpp
Normal file
44
UI/Qt/Icon.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibCore/Resource.h>
|
||||
#include <UI/Qt/Icon.h>
|
||||
#include <UI/Qt/StringUtils.h>
|
||||
#include <UI/Qt/TVGIconEngine.h>
|
||||
|
||||
#include <QPalette>
|
||||
|
||||
namespace Ladybird {
|
||||
|
||||
QIcon load_icon_from_uri(StringView uri)
|
||||
{
|
||||
auto resource = MUST(Core::Resource::load_from_uri(uri));
|
||||
auto path = qstring_from_ak_string(resource->filesystem_path());
|
||||
|
||||
return QIcon { path };
|
||||
}
|
||||
|
||||
QIcon create_tvg_icon_with_theme_colors(QString const& name, QPalette const& palette)
|
||||
{
|
||||
auto path = QString(":/Icons/%1.tvg").arg(name);
|
||||
|
||||
auto* icon_engine = TVGIconEngine::from_file(path);
|
||||
VERIFY(icon_engine);
|
||||
|
||||
auto icon_filter = [](QColor color) {
|
||||
return [color = Color::from_argb(color.rgba64().toArgb32())](Gfx::Color icon_color) {
|
||||
return color.with_alpha((icon_color.alpha() * color.alpha()) / 255);
|
||||
};
|
||||
};
|
||||
icon_engine->add_filter(QIcon::Mode::Normal, icon_filter(palette.color(QPalette::ColorGroup::Normal, QPalette::ColorRole::ButtonText)));
|
||||
icon_engine->add_filter(QIcon::Mode::Disabled, icon_filter(palette.color(QPalette::ColorGroup::Disabled, QPalette::ColorRole::ButtonText)));
|
||||
icon_engine->add_filter(QIcon::Mode::Active, icon_filter(palette.color(QPalette::ColorGroup::Active, QPalette::ColorRole::ButtonText)));
|
||||
icon_engine->add_filter(QIcon::Mode::Selected, icon_filter(palette.color(QPalette::ColorGroup::Normal, QPalette::ColorRole::ButtonText)));
|
||||
|
||||
return QIcon(icon_engine);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue