2 * Copyright (C) 2017 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18#include "WorkspaceModel.h"
19#include "WorkspaceManager.h"
20#include "TopLevelWindowModel.h"
22#include "wmpolicyinterface.h"
26Workspace::Workspace(QObject *parent)
28 , m_workspace(WMPolicyInterface::instance()->createWorkspace())
30 , m_windowModel(new TopLevelWindowModel(this))
33 setObjectName((QString("Wks%1").arg(nextWorkspace++)));
35 connect(WorkspaceManager::instance(), &WorkspaceManager::activeWorkspaceChanged, this, [this]() {
36 bool newActive = WorkspaceManager::instance()->activeWorkspace() == this;
37 if (newActive != m_active) {
39 Q_EMIT activeChanged(m_active);
42 WMPolicyInterface::instance()->setActiveWorkspace(m_workspace);
48Workspace::Workspace(const Workspace &other)
50 , m_workspace(other.m_workspace)
52 , m_windowModel(other.m_windowModel)
53 , m_active(other.m_active)
55 setObjectName(other.objectName());
57 connect(&other, &Workspace::activeChanged, this, [this](bool active) {
59 Q_EMIT activeChanged(m_active);
63Workspace::~Workspace()
66 m_model->remove(this);
70void Workspace::activate()
72 WorkspaceManager::instance()->setActiveWorkspace(this);
75void Workspace::assign(WorkspaceModel *model, const QVariant& vIndex)
77 if (m_model == model) return;
80 disconnect(m_model, 0, this, 0);
81 m_model->remove(this);
87 int index = m_model->rowCount();
88 if (vIndex.isValid() && vIndex.canConvert(QVariant::Int)) {
89 index = vIndex.toInt();
91 m_model->insert(index, this);
93 connect(m_model, &QObject::destroyed, this, [this]() {
103void Workspace::unassign()
108void Workspace::release()
110 WMPolicyInterface::instance()->releaseWorkspace(m_workspace);
114bool Workspace::isAssigned() const
116 return m_model != nullptr;
119WorkspaceProxy::WorkspaceProxy(Workspace * const workspace)
120 : Workspace(*workspace)
121 , m_original(workspace)
125void WorkspaceProxy::assign(WorkspaceModel *model, const QVariant &index)
127 Workspace::assign(model, index);
130void WorkspaceProxy::unassign()
132 Workspace::unassign();
135bool WorkspaceProxy::isActive() const
137 return m_original ? m_original->isActive() : false;
140void WorkspaceProxy::activate()
142 if (m_original) m_original->activate();
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list