Paint tray menu background as normal widget when shown as normal window

This commit is contained in:
Martchus 2022-12-10 12:07:06 +01:00
parent 24a9e63005
commit 4fc3777a9e
2 changed files with 13 additions and 0 deletions

View File

@ -8,6 +8,8 @@
#include <QApplication>
#include <QHBoxLayout>
#include <QPaintEvent>
#include <QPainter>
#include <QWindow>
using namespace QtUtilities;
@ -80,6 +82,16 @@ void TrayMenu::mousePressEvent(QMouseEvent *event)
}
}
void TrayMenu::paintEvent(QPaintEvent *event)
{
if (!m_windowed) {
QMenu::paintEvent(event);
} else {
QPainter(this).fillRect(event->rect(), palette().window());
QWidget::paintEvent(event);
}
}
void TrayMenu::mouseReleaseEvent(QMouseEvent *event)
{
if (!m_windowed) {

View File

@ -28,6 +28,7 @@ public Q_SLOTS:
protected:
void mouseReleaseEvent(QMouseEvent *) override;
void mousePressEvent(QMouseEvent *) override;
void paintEvent(QPaintEvent *) override;
private:
TrayWidget *m_trayWidget;