mirror of
https://github.com/NohamR/Reclass.git
synced 2026-05-10 19:59:21 +00:00
fix: Linux menu popups and SVG icon rendering
- Guard FramelessWindowHint + WA_TranslucentBackground on QMenu to Windows only — breaks popup submenus on Linux/Wayland compositors - Render SVG icons via QSvgRenderer to QPixmap explicitly, avoiding dependency on the qsvgicon image format plugin which may not be deployed on Linux
This commit is contained in:
15
src/main.cpp
15
src/main.cpp
@@ -241,14 +241,13 @@ class MenuBarStyle : public QProxyStyle {
|
|||||||
public:
|
public:
|
||||||
using QProxyStyle::QProxyStyle;
|
using QProxyStyle::QProxyStyle;
|
||||||
void polish(QWidget* w) override {
|
void polish(QWidget* w) override {
|
||||||
|
#ifdef _WIN32
|
||||||
if (qobject_cast<QMenu*>(w)) {
|
if (qobject_cast<QMenu*>(w)) {
|
||||||
w->setWindowFlag(Qt::FramelessWindowHint, true);
|
w->setWindowFlag(Qt::FramelessWindowHint, true);
|
||||||
// Layered window — gives full pixel control; DWM won't clip edges.
|
// Layered window — gives full pixel control; DWM won't clip edges.
|
||||||
// (The DwmSetWindowAttribute conflict noted in RcxTooltip doesn't
|
|
||||||
// apply here: DarkApp::notify only fires on WindowActivate, which
|
|
||||||
// popups never receive.)
|
|
||||||
w->setAttribute(Qt::WA_TranslucentBackground);
|
w->setAttribute(Qt::WA_TranslucentBackground);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
QProxyStyle::polish(w);
|
QProxyStyle::polish(w);
|
||||||
}
|
}
|
||||||
using QProxyStyle::polish;
|
using QProxyStyle::polish;
|
||||||
@@ -676,7 +675,15 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QIcon MainWindow::makeIcon(const QString& svgPath) {
|
QIcon MainWindow::makeIcon(const QString& svgPath) {
|
||||||
return QIcon(svgPath);
|
// Render SVG to pixmap explicitly — avoids dependency on qsvgicon plugin
|
||||||
|
// which may not be deployed on Linux.
|
||||||
|
QSvgRenderer renderer(svgPath);
|
||||||
|
if (!renderer.isValid()) return QIcon(svgPath);
|
||||||
|
QPixmap pm(32, 32);
|
||||||
|
pm.fill(Qt::transparent);
|
||||||
|
QPainter p(&pm);
|
||||||
|
renderer.render(&p);
|
||||||
|
return QIcon(pm);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename...Args >
|
template < typename...Args >
|
||||||
|
|||||||
Reference in New Issue
Block a user