forked from quickshell/quickshell
hyprland/ipc: handle renameworkspace
This commit is contained in:
parent
b336129c34
commit
3c7dfcb220
3 changed files with 28 additions and 1 deletions
|
@ -352,6 +352,22 @@ void HyprlandIpc::onEvent(HyprlandIpcEvent* event) {
|
|||
auto* monitor = this->findMonitorByName(monitorName, true);
|
||||
|
||||
workspace->setMonitor(monitor);
|
||||
} else if (event->name == "renameworkspace") {
|
||||
auto args = event->parseView(2);
|
||||
auto id = args.at(0).toInt();
|
||||
auto name = QString::fromUtf8(args.at(1));
|
||||
|
||||
const auto& mList = this->mWorkspaces.valueList();
|
||||
|
||||
auto workspaceIter =
|
||||
std::ranges::find_if(mList, [id](const HyprlandWorkspace* m) { return m->id() == id; });
|
||||
|
||||
if (workspaceIter == mList.end()) return;
|
||||
|
||||
qCDebug(logHyprlandIpc) << "Workspace with id" << id << "renamed from"
|
||||
<< (*workspaceIter)->name() << "to" << name;
|
||||
|
||||
(*workspaceIter)->setName(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,15 @@
|
|||
namespace qs::hyprland::ipc {
|
||||
|
||||
qint32 HyprlandWorkspace::id() const { return this->mId; }
|
||||
|
||||
QString HyprlandWorkspace::name() const { return this->mName; }
|
||||
|
||||
void HyprlandWorkspace::setName(QString name) {
|
||||
if (name == this->mName) return;
|
||||
this->mName = std::move(name);
|
||||
emit this->nameChanged();
|
||||
}
|
||||
|
||||
QVariantMap HyprlandWorkspace::lastIpcObject() const { return this->mLastIpcObject; }
|
||||
|
||||
void HyprlandWorkspace::updateInitial(qint32 id, QString name) {
|
||||
|
|
|
@ -32,11 +32,14 @@ public:
|
|||
void updateFromObject(QVariantMap object);
|
||||
|
||||
[[nodiscard]] qint32 id() const;
|
||||
|
||||
[[nodiscard]] QString name() const;
|
||||
void setName(QString name);
|
||||
|
||||
[[nodiscard]] QVariantMap lastIpcObject() const;
|
||||
|
||||
void setMonitor(HyprlandMonitor* monitor);
|
||||
[[nodiscard]] HyprlandMonitor* monitor() const;
|
||||
void setMonitor(HyprlandMonitor* monitor);
|
||||
|
||||
signals:
|
||||
void idChanged();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue