summaryrefslogtreecommitdiffstats
path: root/src/plugins/platformthemes/gtk3/qgtk3interface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platformthemes/gtk3/qgtk3interface.cpp')
-rw-r--r--src/plugins/platformthemes/gtk3/qgtk3interface.cpp36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/plugins/platformthemes/gtk3/qgtk3interface.cpp b/src/plugins/platformthemes/gtk3/qgtk3interface.cpp
index 2789645fe0..a35e211fbf 100644
--- a/src/plugins/platformthemes/gtk3/qgtk3interface.cpp
+++ b/src/plugins/platformthemes/gtk3/qgtk3interface.cpp
@@ -289,15 +289,17 @@ QImage QGtk3Interface::qt_convert_gdk_pixbuf(GdkPixbuf *buf) const
const guint8 *gdata = gdk_pixbuf_read_pixels(buf);
static_assert(std::is_same<decltype(gdata), const uchar *>::value,
"guint8 has diverted from uchar. Code needs fixing.");
- Q_ASSUME(gdk_pixbuf_get_bits_per_sample(buf) == 8);
- Q_ASSUME(gdk_pixbuf_get_n_channels(buf) == 4);
+ Q_ASSERT(gdk_pixbuf_get_bits_per_sample(buf) == 8);
+ Q_ASSERT(gdk_pixbuf_get_n_channels(buf) == 4);
const uchar *data = static_cast<const uchar *>(gdata);
const int width = gdk_pixbuf_get_width(buf);
const int height = gdk_pixbuf_get_height(buf);
const int bpl = gdk_pixbuf_get_rowstride(buf);
- QImage converted(data, width, height, bpl, QImage::Format_ARGB32);
- return converted.copy(); // detatch to survive lifetime of buf
+ QImage converted(data, width, height, bpl, QImage::Format_RGBA8888);
+
+ // convert to more optimal format and detach to survive lifetime of buf
+ return converted.convertToFormat(QImage::Format_ARGB32_Premultiplied);
}
/*!
@@ -475,15 +477,18 @@ QBrush QGtk3Interface::brush(QGtkWidget wtype, QGtkColorSource source, GtkStateF
\internal
\brief Returns the name of the current GTK theme.
*/
-const QString QGtk3Interface::themeName() const
+QString QGtk3Interface::themeName() const
{
- gchar *theme_name;
- GtkSettings *settings = gtk_settings_get_default();
- if (!settings)
- return QString();
+ QString name;
+
+ if (GtkSettings *settings = gtk_settings_get_default()) {
+ gchar *theme_name;
+ g_object_get(settings, "gtk-theme-name", &theme_name, nullptr);
+ name = QLatin1StringView(theme_name);
+ g_free(theme_name);
+ }
- g_object_get(settings, "gtk-theme-name", &theme_name, nullptr);
- return QLatin1StringView(theme_name);
+ return name;
}
/*!
@@ -608,7 +613,8 @@ QFont QGtk3Interface::font(QPlatformTheme::Font type) const
GtkCssProvider *cssProvider = nullptr;
if (type == QPlatformTheme::FixedFont) {
cssProvider = gtk_css_provider_new();
- const char *fontSpec = "{font-family: monospace;}";
+ gtk_style_context_add_class (con, GTK_STYLE_CLASS_MONOSPACE);
+ const char *fontSpec = "* {font-family: monospace;}";
gtk_css_provider_load_from_data(cssProvider, fontSpec, -1, NULL);
gtk_style_context_add_provider(con, GTK_STYLE_PROVIDER(cssProvider),
GTK_STYLE_PROVIDER_PRIORITY_USER);
@@ -662,7 +668,7 @@ QIcon QGtk3Interface::fileIcon(const QFileInfo &fileInfo) const
if (!file)
return QIcon();
- GFileInfo *info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+ GFileInfo *info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_ICON,
G_FILE_QUERY_INFO_NONE, nullptr, nullptr);
if (!info) {
g_object_unref(file);
@@ -677,12 +683,11 @@ QIcon QGtk3Interface::fileIcon(const QFileInfo &fileInfo) const
}
GtkIconTheme *theme = gtk_icon_theme_get_default();
- GtkIconInfo *iconInfo = gtk_icon_theme_lookup_by_gicon(theme, icon, GTK_ICON_SIZE_BUTTON,
+ GtkIconInfo *iconInfo = gtk_icon_theme_lookup_by_gicon(theme, icon, 16,
GTK_ICON_LOOKUP_FORCE_SIZE);
if (!iconInfo) {
g_object_unref(file);
g_object_unref(info);
- g_object_unref(icon);
return QIcon();
}
@@ -690,7 +695,6 @@ QIcon QGtk3Interface::fileIcon(const QFileInfo &fileInfo) const
QImage image = qt_convert_gdk_pixbuf(buf);
g_object_unref(file);
g_object_unref(info);
- g_object_unref(icon);
g_object_unref(buf);
return QIcon(QPixmap::fromImage(image));
}