forked from quickshell/quickshell
global: add Quickshell.processId and rename Process.pid
This commit is contained in:
parent
b720dfa165
commit
a35d3f9584
4 changed files with 15 additions and 6 deletions
|
@ -15,6 +15,7 @@
|
|||
#include <qtmetamacros.h>
|
||||
#include <qtypes.h>
|
||||
#include <qvariant.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "qmlscreen.hpp"
|
||||
#include "rootwrapper.hpp"
|
||||
|
@ -67,6 +68,10 @@ QuickshellGlobal::QuickshellGlobal(QObject* parent): QObject(parent) {
|
|||
}
|
||||
}
|
||||
|
||||
qint32 QuickshellGlobal::processId() const { // NOLINT
|
||||
return getpid();
|
||||
}
|
||||
|
||||
qsizetype QuickshellGlobal::screensCount(QQmlListProperty<QuickshellScreenInfo>* prop) {
|
||||
return static_cast<QuickshellGlobal*>(prop->object)->mScreens.size(); // NOLINT
|
||||
}
|
||||
|
|
|
@ -46,6 +46,8 @@ private:
|
|||
class QuickshellGlobal: public QObject {
|
||||
Q_OBJECT;
|
||||
// clang-format off
|
||||
/// Quickshell's process id.
|
||||
Q_PROPERTY(qint32 processId READ processId CONSTANT);
|
||||
/// All currently connected screens.
|
||||
///
|
||||
/// This property updates as connected screens change.
|
||||
|
@ -77,6 +79,8 @@ class QuickshellGlobal: public QObject {
|
|||
QML_NAMED_ELEMENT(Quickshell);
|
||||
|
||||
public:
|
||||
[[nodiscard]] qint32 processId() const;
|
||||
|
||||
QuickshellGlobal(QObject* parent = nullptr);
|
||||
|
||||
QQmlListProperty<QuickshellScreenInfo> screens();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue