Improved multi-screen display

pull/7/head
reionwong 4 years ago
parent e1c45b0ec4
commit afd4f65786

@ -53,8 +53,8 @@ ControlCenterDialog {
var posX = control.position.x
var posY = control.position.y
if (posX + control.width >= Screen.width)
posX = Screen.width - control.width - control.margin
if (posX + control.width >= StatusBar.screenRect.x + StatusBar.screenRect.width)
posX = StatusBar.screenRect.x + StatusBar.screenRect.width - control.width - control.margin
posY = rootItem.y + rootItem.height + control.margin

@ -279,7 +279,7 @@ Item {
// Alt
controlCenter.position = Qt.point(0, 0)
controlCenter.visible = true
controlCenter.position = Qt.point(mapToGlobal(0, 0).x, mapToGlobal(0, 0).y)
controlCenter.position = mapToGlobal(0, 0)
}
}

@ -148,7 +148,7 @@ void AppMenuModel::onActiveWindowChanged()
setVisible(true);
emit modelNeedsUpdate();
} else {
setMenuAvailable(false);
// setMenuAvailable(false);
setVisible(false);
}
}

@ -47,6 +47,7 @@ StatusBar::StatusBar(QQuickView *parent)
new StatusbarAdaptor(this);
new AppMenu(this);
engine()->rootContext()->setContextProperty("StatusBar", this);
engine()->rootContext()->setContextProperty("acticity", m_acticity);
engine()->rootContext()->setContextProperty("process", new ProcessProvider);
engine()->rootContext()->setContextProperty("battery", Battery::self());
@ -59,6 +60,14 @@ StatusBar::StatusBar(QQuickView *parent)
connect(qApp->primaryScreen(), &QScreen::virtualGeometryChanged, this, &StatusBar::updateGeometry);
connect(qApp->primaryScreen(), &QScreen::geometryChanged, this, &StatusBar::updateGeometry);
// Always show on the main screen
connect(qApp, &QApplication::primaryScreenChanged, this, &StatusBar::onPrimaryScreenChanged);
}
QRect StatusBar::screenRect()
{
return m_screenRect;
}
void StatusBar::setBatteryPercentage(bool enabled)
@ -69,6 +78,12 @@ void StatusBar::setBatteryPercentage(bool enabled)
void StatusBar::updateGeometry()
{
const QRect rect = qApp->primaryScreen()->geometry();
if (m_screenRect != rect) {
m_screenRect = rect;
emit screenRectChanged();
}
QRect windowRect = QRect(rect.x(), rect.y(), rect.width(), 28);
setGeometry(windowRect);
updateViewStruts();
@ -81,7 +96,7 @@ void StatusBar::updateViewStruts()
const QRect windowRect = geometry();
NETExtendedStrut strut;
strut.top_width = windowRect.height();
strut.top_width = windowRect.height() - 1;
strut.top_start = x();
strut.top_end = x() + windowRect.width();
@ -99,3 +114,9 @@ void StatusBar::updateViewStruts()
strut.bottom_start,
strut.bottom_end);
}
void StatusBar::onPrimaryScreenChanged(QScreen *screen)
{
setScreen(screen);
updateGeometry();
}

@ -26,19 +26,27 @@
class StatusBar : public QQuickView
{
Q_OBJECT
Q_PROPERTY(QRect screenRect READ screenRect NOTIFY screenRectChanged)
public:
explicit StatusBar(QQuickView *parent = nullptr);
QRect screenRect();
void setBatteryPercentage(bool enabled);
void updateGeometry();
void updateViewStruts();
signals:
void screenRectChanged();
void launchPadChanged();
private slots:
void onPrimaryScreenChanged(QScreen *screen);
private:
QRect m_screenRect;
Activity *m_acticity;
};

Loading…
Cancel
Save