chore: connect workspace signals to cxx controller

This commit is contained in:
Mikhail Zolotukhin 2022-03-26 16:07:19 +03:00 committed by Genda
parent 0387c0f486
commit 805229a182
4 changed files with 64 additions and 0 deletions

View File

@ -27,6 +27,11 @@ Controller::Controller(PlasmaApi::Api &api, Engine &engine)
, m_engine(engine)
{
bindEvents();
// TODO: Bind shortcuts
loadExistingWindows();
m_engine.arrange();
}
void Controller::bindEvents()
@ -37,6 +42,25 @@ void Controller::bindEvents()
connect(&workspace, &PlasmaApi::Workspace::screenResized, this, &Controller::onSurfaceUpdate);
connect(&workspace, &PlasmaApi::Workspace::currentActivityChanged, this, &Controller::onCurrentSurfaceChanged);
connect(&workspace, &PlasmaApi::Workspace::clientAdded, this, &Controller::onClientAdded);
connect(&workspace, &PlasmaApi::Workspace::clientRemoved, this, &Controller::onClientRemoved);
connect(&workspace, &PlasmaApi::Workspace::clientMaximizeSet, this, [this](PlasmaApi::Client client, bool h, bool v) {
if (h == true && v == true) {
onClientMaximized(client);
} else if (h == false && v == false) {
onClientUnmaximized(client);
}
});
connect(&workspace, &PlasmaApi::Workspace::clientMinimized, this, &Controller::onClientMinimized);
connect(&workspace, &PlasmaApi::Workspace::clientUnminimized, this, &Controller::onClientUnminimized);
}
void Controller::loadExistingWindows()
{
auto clients = m_plasmaApi.workspace().clientList();
for (auto client : clients) {
m_engine.addWindow(client);
}
}
void Controller::registerAction(const Action &data)
@ -85,6 +109,26 @@ void Controller::onClientAdded(PlasmaApi::Client client)
m_engine.addWindow(client);
}
void Controller::onClientRemoved(PlasmaApi::Client)
{
}
void Controller::onClientMaximized(PlasmaApi::Client)
{
}
void Controller::onClientUnmaximized(PlasmaApi::Client)
{
}
void Controller::onClientMinimized(PlasmaApi::Client)
{
}
void Controller::onClientUnminimized(PlasmaApi::Client)
{
}
void Controller::setProxy(TSProxy *proxy)
{
m_proxy = proxy;

View File

@ -36,6 +36,7 @@ public:
Controller(PlasmaApi::Api &, Engine &);
void bindEvents();
void loadExistingWindows();
void registerAction(const Action &);
void setProxy(TSProxy *);
@ -44,6 +45,11 @@ public Q_SLOTS:
void onCurrentSurfaceChanged();
void onSurfaceUpdate();
void onClientAdded(PlasmaApi::Client);
void onClientRemoved(PlasmaApi::Client);
void onClientMaximized(PlasmaApi::Client);
void onClientUnmaximized(PlasmaApi::Client);
void onClientMinimized(PlasmaApi::Client);
void onClientUnminimized(PlasmaApi::Client);
private:
std::vector<QAction *> m_registeredShortcuts{};

View File

@ -14,4 +14,12 @@ void Engine::addWindow(PlasmaApi::Client client)
m_windows.add(client);
// Bind events of this window
}
void Engine::removeWindow(PlasmaApi::Client client)
{
}
void Engine::arrange()
{
}
}

View File

@ -14,6 +14,12 @@ public:
Engine();
void addWindow(PlasmaApi::Client);
void removeWindow(PlasmaApi::Client);
/**
* Arrange the windows on all visible surfaces
*/
void arrange();
private:
WindowsList m_windows{};