Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skins: transform qss icon urls into absolute paths #3877

Merged
merged 1 commit into from
May 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
skin parser: transform relative into absolute icon paths...
to work around missing SVG icons when broken libKF5IconThemes5 5.80
is installed
ronso0 committed May 19, 2021
commit cbfada1bfcedd3941257022e9224a85308123ed5
20 changes: 18 additions & 2 deletions src/skin/legacyskinparser.cpp
Original file line number Diff line number Diff line change
@@ -427,7 +427,9 @@ LaunchImage* LegacySkinParser::parseLaunchImage(const QString& skinPath, QWidget
QDir::setSearchPaths("skin", skinPaths);

QString styleSheet = parseLaunchImageStyle(skinDocument);
LaunchImage* pLaunchImage = new LaunchImage(pParent, styleSheet);
// Transform relative 'skin:' urls into absolute paths.
// See stylesheetAbsIconPaths() for details.
LaunchImage* pLaunchImage = new LaunchImage(pParent, stylesheetAbsIconPaths(styleSheet));
setupSize(skinDocument, pLaunchImage);
return pLaunchImage;
}
@@ -2030,7 +2032,9 @@ void LegacySkinParser::setupWidget(const QDomNode& node,
m_style.clear(); // only apply color scheme to the first widget
}
if (!style.isEmpty()) {
pWidget->setStyleSheet(style);
// Transform relative 'skin:' urls into absolute paths.
// See stylesheetAbsIconPaths() for details.
pWidget->setStyleSheet(stylesheetAbsIconPaths(style));
}
}

@@ -2262,3 +2266,15 @@ void LegacySkinParser::addShortcutToToolTip(WBaseWidget* pWidget,
QString LegacySkinParser::parseLaunchImageStyle(const QDomNode& node) {
return m_pContext->selectString(node, "LaunchImageStyle");
}

QString LegacySkinParser::stylesheetAbsIconPaths(QString& style) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mutable references are confusing IMHO, but in this case it's okay I guess.

// Workaround for https://bugs.kde.org/show_bug.cgi?id=434451 which renders
// relative SVG icon paths in external stylesheets unusable:
// Replaces relative icon urls in stylesheets (external qss or inline
// <Style> nodes) with absolute file paths.
// TODO Can be removed/disabled as soon as all target distros have the fixed
// package in their repo.
// Note: It's safe to use the base path after parseSkin() has updated it
// (parseLaunchImage() appends "/" earlier)
return style.replace("url(skin:", "url(" + m_pContext->getSkinBasePath());
}
1 change: 1 addition & 0 deletions src/skin/legacyskinparser.h
Original file line number Diff line number Diff line change
@@ -143,6 +143,7 @@ class LegacySkinParser : public QObject, public SkinParser {
bool* pCreated = nullptr);

QString parseLaunchImageStyle(const QDomNode& node);
QString stylesheetAbsIconPaths(QString& style);
void parseChildren(const QDomElement& node, WWidgetGroup* pGroup);

UserSettingsPointer m_pConfig;
4 changes: 4 additions & 0 deletions src/skin/skincontext.h
Original file line number Diff line number Diff line change
@@ -261,6 +261,10 @@ class SkinContext {
return m_pConfig;
}

QString getSkinBasePath() const {
return m_skinBasePath;
}

private:
PixmapSource getPixmapSourceInner(const QString& filename) const;