generic: drop stylesheet support

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-04-16 04:31:21 +03:00
parent ce983caed6
commit f4c2f5c84e
4 changed files with 0 additions and 141 deletions

View file

@ -268,7 +268,6 @@ KCmdLineArgsStatic::KCmdLineArgsStatic () {
qt_options.add("sync", ki18n("switches to synchronous mode for debugging"));
qt_options.add("title <title>", ki18n("sets the application title (caption)"));
qt_options.add("reverse", ki18n("mirrors the whole layout of widgets"));
qt_options.add("stylesheet <file.qss>", ki18n("applies the Katie stylesheet to the application widgets"));
qt_options.add("style <style>", ki18n("sets the application GUI style"));
// KDE options
kde_options.add("caption <caption>", ki18n("Use 'caption' as name in the titlebar"));

View file

@ -251,11 +251,6 @@ bool NativeTabBar::isTabHighlighted(int index) const
}
void NativeTabBar::paintEvent(QPaintEvent *event)
{
if (!styleSheet().isNull()) {
KTabBar::paintEvent(event);
return;
}
QPainter painter(this);
//int numTabs = count();
//bool ltr = painter.layoutDirection() == Qt::LeftToRight; // Not yet used

View file

@ -54,11 +54,6 @@ static const int DEFAULT_WALLPAPER_HEIGHT = 1200;
#define DEFAULT_WALLPAPER_THEME "default"
#define DEFAULT_WALLPAPER_SUFFIX ".png"
enum styles {
DEFAULTSTYLE,
SVGSTYLE
};
enum CacheType {
NoCache = 0,
PixmapCache = 1,
@ -141,8 +136,6 @@ public:
void setThemeName(const QString &themeName, bool writeSettings);
void processWallpaperSettings(KConfigBase *metadata);
QString processStyleSheet(const QString &css);
static const char *defaultTheme;
static const char *systemColorsTheme;
static const char *themeRcFile;
@ -167,7 +160,6 @@ public:
QHash<QString, QPixmap> pixmapsToCache;
QHash<QString, QString> keysToCache;
QHash<QString, QString> idsToCache;
QHash<styles, QString> cachedStyleSheets;
QHash<QString, QString> discoveries;
QTimer *saveTimer;
QTimer *updateNotificationTimer;
@ -281,8 +273,6 @@ void ThemePrivate::discardCache(CacheTypes caches)
pixmapCache->data()->clear();
}
cachedStyleSheets.clear();
if (caches & SvgElementsCache) {
discoveries.clear();
invalidElements.clear();
@ -327,86 +317,6 @@ void ThemePrivate::notifyOfChanged()
emit q->themeChanged();
}
QString ThemePrivate::processStyleSheet(const QString &css)
{
QString stylesheet;
if (css.isEmpty()) {
stylesheet = cachedStyleSheets.value(DEFAULTSTYLE);
if (stylesheet.isEmpty()) {
stylesheet = QString("\n\
body {\n\
color: %textcolor;\n\
font-size: %fontsize;\n\
font-family: %fontfamily;\n\
}\n\
a:active { color: %activatedlink; }\n\
a:link { color: %link; }\n\
a:visited { color: %visitedlink; }\n\
a:hover { color: %hoveredlink; text-decoration: none; }\n\
");
stylesheet = processStyleSheet(stylesheet);
cachedStyleSheets.insert(DEFAULTSTYLE, stylesheet);
}
return stylesheet;
} else if (css == "SVG") {
stylesheet = cachedStyleSheets.value(SVGSTYLE);
if (stylesheet.isEmpty()) {
QString skel = ".ColorScheme-%1{color:%2;}";
stylesheet += skel.arg("Text","%textcolor");
stylesheet += skel.arg("Background","%backgroundcolor");
stylesheet += skel.arg("ButtonText","%buttontextcolor");
stylesheet += skel.arg("ButtonBackground","%buttonbackgroundcolor");
stylesheet += skel.arg("ButtonHover","%buttonhovercolor");
stylesheet += skel.arg("ButtonFocus","%buttonfocuscolor");
stylesheet += skel.arg("ViewText","%viewtextcolor");
stylesheet += skel.arg("ViewBackground","%viewbackgroundcolor");
stylesheet += skel.arg("ViewHover","%viewhovercolor");
stylesheet += skel.arg("ViewFocus","%viewfocuscolor");
stylesheet = processStyleSheet(stylesheet);
cachedStyleSheets.insert(SVGSTYLE, stylesheet);
}
return stylesheet;
} else {
stylesheet = css;
}
QHash<QString, QString> elements;
// If you add elements here, make sure their names are sufficiently unique to not cause
// clashes between element keys
elements["%textcolor"] = q->color(Theme::TextColor).name();
elements["%backgroundcolor"] = q->color(Theme::BackgroundColor).name();
elements["%visitedlink"] = q->color(Theme::VisitedLinkColor).name();
elements["%activatedlink"] = q->color(Theme::HighlightColor).name();
elements["%hoveredlink"] = q->color(Theme::HighlightColor).name();
elements["%link"] = q->color(Theme::LinkColor).name();
elements["%buttontextcolor"] = q->color(Theme::ButtonTextColor).name();
elements["%buttonbackgroundcolor"] = q->color(Theme::ButtonBackgroundColor).name();
elements["%buttonhovercolor"] = q->color(Theme::ButtonHoverColor).name();
elements["%buttonfocuscolor"] = q->color(Theme::ButtonFocusColor).name();
elements["%viewtextcolor"] = q->color(Theme::ViewTextColor).name();
elements["%viewbackgroundcolor"] = q->color(Theme::ViewBackgroundColor).name();
elements["%viewhovercolor"] = q->color(Theme::ViewHoverColor).name();
elements["%viewfocuscolor"] = q->color(Theme::ViewFocusColor).name();
QFont font = q->font(Theme::DefaultFont);
elements["%fontsize"] = QString("%1pt").arg(font.pointSize());
elements["%fontfamily"] = font.family().split('[').first();
elements["%smallfontsize"] = QString("%1pt").arg(KGlobalSettings::smallestReadableFont().pointSize());
QHashIterator<QString, QString> it(elements);
while (it.hasNext()) {
it.next();
stylesheet.replace(it.key(), it.value());
}
return stylesheet;
}
class ThemeSingleton
{
public:
@ -691,11 +601,6 @@ QString Theme::imagePath(const QString &name) const
return path;
}
QString Theme::styleSheet(const QString &css) const
{
return d->processStyleSheet(css);
}
QString Theme::wallpaperPath(const QSize &size) const
{
QString fullPath;

View file

@ -214,46 +214,6 @@ class PLASMA_EXPORT Theme : public QObject
*/
bool useNativeWidgetStyle() const;
/**
* Provides a Plasma::Theme-themed stylesheet for hybrid (web / native Plasma) widgets.
*
* You can use this method to retrieve a basic default stylesheet, or to theme your
* custom stylesheet you use for example in Plasma::WebView. The QString you can pass
* into this method does not have to be a valid stylesheet, in fact you can use this
* method to replace color placeholders with the theme's color in any QString.
*
* In order to use this method with a custom stylesheet, just put for example %textcolor
* in your QString and it will be replaced with the theme's text (or foreground) color.
*
* Just like in many other methods for retrieving theme information, do not forget to
* update your stylesheet upon the themeChanged() signal.
*
* The following tags will be replaced by corresponding colors from Plasma::Theme:
*
* %textcolor
* %backgroundcolor
* %buttonbackgroundcolor
*
* %link
* %activatedlink
* %hoveredlink
* %visitedlink
*
* %fontfamily
* %fontsize
* %smallfontsize
*
* @param css a stylesheet to theme, leave empty for a default stylesheet containing
* theming for some commonly used elements, body text and links, for example.
*
* @return a piece of CSS that sets the most commonly used style elements to a theme
* matching Plasma::Theme.
*
* @since 4.5
*/
Q_INVOKABLE QString styleSheet(const QString &css = QString()) const;
/**
* Tries to load pixmap with the specified key from cache.
*