diff --git a/CMakeLists.txt b/CMakeLists.txt index db09bce..9fbc3c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,8 +25,8 @@ set(SRCS src/appearance.cpp src/volume.cpp src/processprovider.cpp + src/activity.cpp - src/systemtray/statusnotifieritemjob.cpp src/systemtray/statusnotifieritemsource.cpp src/systemtray/systemtraytypes.cpp src/systemtray/systemtraytypedefs.h diff --git a/qml/main.qml b/qml/main.qml index 0da7904..bb11970 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -37,6 +37,24 @@ Item { anchors.rightMargin: Meui.Units.smallSpacing spacing: 0 + StandardItem { + id: acticityItem + Layout.fillHeight: true + + width: acticityLayout.implicitWidth + Meui.Units.largeSpacing + + RowLayout { + id: acticityLayout + anchors.fill: parent + anchors.leftMargin: Meui.Units.smallSpacing + anchors.rightMargin: Meui.Units.smallSpacing + + Label { + text: acticity.title + } + } + } + Item { Layout.fillWidth: true } diff --git a/src/activity.cpp b/src/activity.cpp new file mode 100644 index 0000000..3208f97 --- /dev/null +++ b/src/activity.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: cutefishos + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "activity.h" + +#include +#include +#include + +Activity::Activity(QObject *parent) + : QObject(parent) +{ + onActiveWindowChanged(); + + connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged, this, &Activity::onActiveWindowChanged); + connect(KWindowSystem::self(), static_cast(&KWindowSystem::windowChanged), + this, &Activity::onActiveWindowChanged); +} + +QString Activity::title() const +{ + return m_title; +} + +void Activity::close() +{ + NETRootInfo(QX11Info::connection(), NET::CloseWindow).closeWindowRequest(KWindowSystem::activeWindow()); +} + +void Activity::onActiveWindowChanged() +{ + KWindowInfo info(KWindowSystem::activeWindow(), NET::WMState | NET::WMVisibleName); + + QString title = info.visibleName(); + if (title != m_title) { + m_title = title; + emit titleChanged(); + } +} diff --git a/src/activity.h b/src/activity.h new file mode 100644 index 0000000..b8482ac --- /dev/null +++ b/src/activity.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: cutefishos + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef ACTIVITY_H +#define ACTIVITY_H + +#include + +class Activity : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString title READ title NOTIFY titleChanged) + +public: + explicit Activity(QObject *parent = nullptr); + + QString title() const; + + Q_INVOKABLE void close(); + +private slots: + void onActiveWindowChanged(); + +signals: + void titleChanged(); + +private: + QString m_title; +}; + +#endif // ACTIVITY_H diff --git a/src/appearance.cpp b/src/appearance.cpp index c0eea45..e2025fe 100644 --- a/src/appearance.cpp +++ b/src/appearance.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2021 CutefishOS Team. * - * Author: revenmartin + * Author: cutefishos * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/appearance.h b/src/appearance.h index c495bf2..5b7fd51 100644 --- a/src/appearance.h +++ b/src/appearance.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2021 CutefishOS Team. * - * Author: revenmartin + * Author: cutefishos * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/battery.cpp b/src/battery.cpp index 1f93406..a935035 100644 --- a/src/battery.cpp +++ b/src/battery.cpp @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: cutefishos + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include "battery.h" static const QString s_sServer = "org.cutefish.Settings"; diff --git a/src/battery.h b/src/battery.h index 349e2b6..408a8cc 100644 --- a/src/battery.h +++ b/src/battery.h @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: cutefishos + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifndef BATTERY_H #define BATTERY_H diff --git a/src/brightness.cpp b/src/brightness.cpp index c04a491..cdebadd 100644 --- a/src/brightness.cpp +++ b/src/brightness.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2021 CutefishOS Team. * - * Author: revenmartin + * Author: cutefishos * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/brightness.h b/src/brightness.h index 6a80554..253ea68 100644 --- a/src/brightness.h +++ b/src/brightness.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2021 CutefishOS Team. * - * Author: revenmartin + * Author: cutefishos * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/controlcenterdialog.cpp b/src/controlcenterdialog.cpp index efac8df..f879dd1 100644 --- a/src/controlcenterdialog.cpp +++ b/src/controlcenterdialog.cpp @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: cutefishos + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include "controlcenterdialog.h" #include diff --git a/src/controlcenterdialog.h b/src/controlcenterdialog.h index adeb18e..b456c7a 100644 --- a/src/controlcenterdialog.h +++ b/src/controlcenterdialog.h @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: cutefishos + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifndef CONTROLCENTERDIALOG_H #define CONTROLCENTERDIALOG_H diff --git a/src/main.cpp b/src/main.cpp index 2e879b8..6907528 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: cutefishos + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include #include #include diff --git a/src/processprovider.cpp b/src/processprovider.cpp index 90003b2..ca3e456 100644 --- a/src/processprovider.cpp +++ b/src/processprovider.cpp @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: cutefishos + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include "processprovider.h" #include diff --git a/src/processprovider.h b/src/processprovider.h index 8d07bc1..818704b 100644 --- a/src/processprovider.h +++ b/src/processprovider.h @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: cutefishos + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifndef PROCESSPROVIDER_H #define PROCESSPROVIDER_H diff --git a/src/statusbar.cpp b/src/statusbar.cpp index 49a3e10..a7b4fc2 100644 --- a/src/statusbar.cpp +++ b/src/statusbar.cpp @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: cutefishos + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include "statusbar.h" #include "processprovider.h" @@ -13,6 +32,7 @@ StatusBar::StatusBar(QQuickView *parent) : QQuickView(parent) + , m_acticity(new Activity) { setFlags(Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus); setColor(Qt::transparent); @@ -21,6 +41,7 @@ StatusBar::StatusBar(QQuickView *parent) KWindowSystem::setType(winId(), NET::Dock); KWindowEffects::slideWindow(winId(), KWindowEffects::TopEdge); + engine()->rootContext()->setContextProperty("acticity", m_acticity); engine()->rootContext()->setContextProperty("process", new ProcessProvider); setSource(QUrl(QStringLiteral("qrc:/qml/main.qml"))); diff --git a/src/statusbar.h b/src/statusbar.h index 9a709c8..6f0a8ec 100644 --- a/src/statusbar.h +++ b/src/statusbar.h @@ -1,7 +1,27 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: cutefishos + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifndef STATUSBAR_H #define STATUSBAR_H #include +#include "activity.h" class StatusBar : public QQuickView { @@ -12,6 +32,9 @@ public: void updateGeometry(); void updateViewStruts(); + +private: + Activity *m_acticity; }; #endif // STATUSBAR_H diff --git a/src/systemtray/statusnotifieritemjob.cpp b/src/systemtray/statusnotifieritemjob.cpp deleted file mode 100644 index e198a65..0000000 --- a/src/systemtray/statusnotifieritemjob.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "statusnotifieritemjob.h" - -StatusNotifierItemJob::StatusNotifierItemJob(StatusNotifierItemSource *source, QObject *parent) - : QObject(parent) - , m_source(source) -{ - // Queue connection, so that all 'deleteLater' are performed before we use updated menu. - connect(source, SIGNAL(contextMenuReady(QMenu *)), this, SLOT(contextMenuReady(QMenu *)), Qt::QueuedConnection); - connect(source, &StatusNotifierItemSource::activateResult, this, &StatusNotifierItemJob::activateCallback); -} - -void StatusNotifierItemJob::start() -{ - -} - -void StatusNotifierItemJob::activateCallback(bool success) -{ - -} - -void StatusNotifierItemJob::contextMenuReady(QMenu *menu) -{ - -} diff --git a/src/systemtray/statusnotifieritemjob.h b/src/systemtray/statusnotifieritemjob.h deleted file mode 100644 index 19bb572..0000000 --- a/src/systemtray/statusnotifieritemjob.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef STATUSNOTIFIERITEMJOB_H -#define STATUSNOTIFIERITEMJOB_H - -#include -#include - -#include "statusnotifieritemsource.h" - -class StatusNotifierItemJob : public QObject -{ - Q_OBJECT - -public: - explicit StatusNotifierItemJob(StatusNotifierItemSource *source, QObject *parent = nullptr); - -protected: - void start(); - -private Q_SLOTS: - void activateCallback(bool success); - void contextMenuReady(QMenu *menu); - -private: - StatusNotifierItemSource *m_source; -}; - -#endif // STATUSNOTIFIERITEMJOB_H diff --git a/src/volume.cpp b/src/volume.cpp index 183cc35..b89c67b 100644 --- a/src/volume.cpp +++ b/src/volume.cpp @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: cutefishos + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include "volume.h" #include diff --git a/src/volume.h b/src/volume.h index f1e31f1..4a25a01 100644 --- a/src/volume.h +++ b/src/volume.h @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: cutefishos + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifndef VOLUMEMANAGER_H #define VOLUMEMANAGER_H