shift-shell/components/mobileshellstate/panelsettingsdbusclient.h
Devin Lin 839d5e2bff panels: Add support for defining device specific panel tweaks
This adds support for specifying options needed to deal with phone
display panel pecularities (ex. screen curves, notches, punch holes)

This is implemented as settings in ~/.config/plasmamobilerc, which can
set panel heights, paddings, and center spacings to duck display
cutouts. The pixel values are scaling independent, and so are not
affected when the display scaling is changed.

This is then exposed over DBus, so that components from outside of
plasmashell (ex. KWin) can access it easily without needing to connect to
kscreen themselves. Each screen is exposed as a single object.

Currently support is only added in the status bar and the navigation
panel.

Currently all screens have the settings applied. In the future, we may
want to limit this just to the internal screen (?)

---

This also adds a "devices" folder (in `devices/configs`) where per-device configs can be set.

This is installed to `/usr/share/plasma-mobile-device-configs`.
In `plasmamobilerc` (installed to `/etc/xdg/plasmamobilerc`, or
`~/.config/plasmamobilerc`), envmanager will read:

```toml
[Device]
device=oneplus-enchilada
```

for the device config to use and write its settings to
`~/.config/plasma-mobile/plasmamobilerc`.
2025-11-04 23:08:18 -05:00

83 lines
2.8 KiB
C++

// SPDX-FileCopyrightText: 2025 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "plasmashellmobilepanelsinterface.h"
#include <QDBusServiceWatcher>
#include <QObject>
#include <QString>
#include <qqmlregistration.h>
class PanelSettingsDBusClient : public QObject
{
Q_OBJECT
QML_ELEMENT
// Client must set the screen they want to get details for
Q_PROPERTY(QString screenName READ screenName WRITE setScreenName NOTIFY screenNameChanged)
Q_PROPERTY(qreal statusBarHeight READ statusBarHeight NOTIFY statusBarHeightChanged)
Q_PROPERTY(qreal statusBarLeftPadding READ statusBarLeftPadding NOTIFY statusBarLeftPaddingChanged)
Q_PROPERTY(qreal statusBarRightPadding READ statusBarRightPadding NOTIFY statusBarRightPaddingChanged)
Q_PROPERTY(qreal statusBarCenterSpacing READ statusBarCenterSpacing NOTIFY statusBarCenterSpacingChanged)
Q_PROPERTY(qreal navigationPanelHeight READ navigationPanelHeight NOTIFY navigationPanelHeightChanged)
Q_PROPERTY(qreal navigationPanelLeftPadding READ navigationPanelLeftPadding NOTIFY navigationPanelLeftPaddingChanged)
Q_PROPERTY(qreal navigationPanelRightPadding READ navigationPanelRightPadding NOTIFY navigationPanelRightPaddingChanged)
public:
explicit PanelSettingsDBusClient(QObject *parent = nullptr);
void connectToDBus();
QString screenName() const;
void setScreenName(const QString &screenName);
qreal statusBarHeight() const;
qreal statusBarLeftPadding() const;
qreal statusBarRightPadding() const;
qreal statusBarCenterSpacing() const;
qreal navigationPanelHeight() const;
qreal navigationPanelLeftPadding() const;
qreal navigationPanelRightPadding() const;
Q_SIGNALS:
void screenNameChanged();
void statusBarHeightChanged();
void statusBarLeftPaddingChanged();
void statusBarRightPaddingChanged();
void statusBarCenterSpacingChanged();
void navigationPanelHeightChanged();
void navigationPanelLeftPaddingChanged();
void navigationPanelRightPaddingChanged();
private Q_SLOTS:
void updateStatusBarHeight();
void updateStatusBarLeftPadding();
void updateStatusBarRightPadding();
void updateStatusBarCenterSpacing();
void updateNavigationPanelHeight();
void updateNavigationPanelLeftPadding();
void updateNavigationPanelRightPadding();
private:
void connectSignals();
OrgKdePlasmashellMobilePanelsInterface *m_interface;
QDBusServiceWatcher *m_watcher;
QString m_screenName;
qreal m_statusBarHeight = -1;
qreal m_statusBarLeftPadding = 0;
qreal m_statusBarRightPadding = 0;
qreal m_statusBarCenterSpacing = 0;
qreal m_navigationPanelHeight = -1;
qreal m_navigationPanelLeftPadding = 0;
qreal m_navigationPanelRightPadding = 0;
bool m_connected = false;
};