Add View::setWindowOpacity()

This commit is contained in:
Sergio Martins
2022-04-21 22:22:50 +01:00
parent 8015e49bee
commit 2c162630f4
7 changed files with 28 additions and 6 deletions

View File

@@ -170,6 +170,7 @@ public:
virtual void releaseKeyboard() = 0;
virtual QScreen *screen() const = 0;
virtual void setFocus(Qt::FocusReason) = 0;
virtual void setWindowOpacity(double) = 0;
// TODOv2: Check if these two should be in the controller or on view
virtual void onLayoutRequest()

View File

@@ -181,3 +181,13 @@ void ViewWrapper::setFixedHeight(int)
{
qFatal("Not implemented");
}
void ViewWrapper::setWindowOpacity(double)
{
qFatal("Not implemented");
}
void ViewWrapper::releaseKeyboard()
{
qFatal("Not implemented");
}

View File

@@ -59,9 +59,8 @@ public:
bool isActiveWindow() const override;
void setFixedWidth(int) override;
void setFixedHeight(int) override;
void releaseKeyboard() override
{
}
void setWindowOpacity(double) override;
void releaseKeyboard() override;
/// TODOv2: Remove
virtual DropArea *asDropArea() const

View File

@@ -114,5 +114,5 @@ void MDILayoutWidget::resizeDockWidget(Controllers::Frame *frame, QSize size)
return;
}
item->setSize(size.expandedTo(frame->view()->asQWidget()->minimumSize()));
item->setSize(size.expandedTo(frame->view()->minSize()));
}

View File

@@ -67,7 +67,7 @@ WindowBeingDragged::WindowBeingDragged(Controllers::FloatingWindow *fw, Draggabl
// Set opacity while dragging, if needed
const qreal opacity = Config::self().draggedWindowOpacity();
if (!qIsNaN(opacity) && !qFuzzyCompare(1.0, opacity))
fw->view()->asQWidget()->setWindowOpacity(opacity);
fw->view()->setWindowOpacity(opacity);
}
}
@@ -102,7 +102,7 @@ WindowBeingDragged::~WindowBeingDragged()
// Restore opacity to fully opaque if needed
const qreal opacity = Config::self().draggedWindowOpacity();
if (!qIsNaN(opacity) && !qFuzzyCompare(1.0, opacity))
m_floatingWindow->view()->asQWidget()->setWindowOpacity(1);
m_floatingWindow->view()->setWindowOpacity(1);
}
}

View File

@@ -20,6 +20,7 @@
#include <QResizeEvent>
#include <QSizePolicy>
#include <QQuickItem>
#include <QQuickWindow>
#include <memory>
@@ -184,6 +185,12 @@ public:
return {};
}
void setWindowOpacity(double v) override
{
if (QWindow *w = QQuickItem::window())
w->setOpacity(v);
}
void setSizePolicy(QSizePolicy) override
{
}

View File

@@ -240,6 +240,11 @@ public:
return {};
}
void setWindowOpacity(double v) override
{
QWidget::setWindowOpacity(v);
}
virtual QSize parentSize() const override
{
if (auto p = QWidget::parentWidget())