kcm/edges: Draw the ratio of the monitor we are on
At the moment it's showing whatever is QGuiApplication::primaryScreen(), which on Wayland is random.
This commit is contained in:
parent
b7f3db5aca
commit
9c41ec461e
2 changed files with 12 additions and 2 deletions
|
@ -53,8 +53,6 @@ static QScreen *screenFromWidget(const QWidget *widget)
|
|||
Monitor::Monitor(QWidget *parent)
|
||||
: ScreenPreviewWidget(parent)
|
||||
{
|
||||
QRect avail = screenFromWidget(this)->geometry();
|
||||
setRatio((qreal)avail.width() / (qreal)avail.height());
|
||||
for (int i = 0;
|
||||
i < 8;
|
||||
++i) {
|
||||
|
@ -97,6 +95,17 @@ void Monitor::resizeEvent(QResizeEvent *e)
|
|||
checkSize();
|
||||
}
|
||||
|
||||
bool Monitor::event(QEvent *event)
|
||||
{
|
||||
const bool r = ScreenPreviewWidget::event(event);
|
||||
if (event->type() == QEvent::ScreenChangeInternal) {
|
||||
QRect avail = screenFromWidget(this)->geometry();
|
||||
setRatio((qreal)avail.width() / (qreal)avail.height());
|
||||
checkSize();
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
void Monitor::checkSize()
|
||||
{
|
||||
QRect contentsRect = previewRect();
|
||||
|
|
|
@ -65,6 +65,7 @@ Q_SIGNALS:
|
|||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
bool event(QEvent *event) override;
|
||||
|
||||
private:
|
||||
class Corner;
|
||||
|
|
Loading…
Reference in a new issue