on bcbc40d help sign in
unity8/plugins/WindowManager/WindowManagerPlugin.cpp
66 lines 2.4 kB history raw
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 */
17#include "WindowManagerPlugin.h"
19#include "Screen.h"
20#include "ScreenAttached.h"
21#include "Screens.h"
22#include "ScreenWindow.h"
23#include "TopLevelWindowModel.h"
24#include "Window.h"
25#include "WorkspaceManager.h"
26#include "Workspace.h"
27#include "WorkspaceModel.h"
29#include <QtQml>
30#include <qtmir/qtmir.h>
32static const QString notInstantiatable = QStringLiteral("Not instantiatable");
34static QObject *workspace_manager(QQmlEngine *engine, QJSEngine *scriptEngine)
36 Q_UNUSED(engine)
37 Q_UNUSED(scriptEngine)
38 return WorkspaceManager::instance();
40QObject* screensSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
41 Q_UNUSED(engine);
42 Q_UNUSED(scriptEngine);
43 return new Screens(qtmir::get_screen_model());
46void WindowManagerPlugin::registerTypes(const char *uri)
48 qmlRegisterType<TopLevelWindowModel>(uri, 1, 0, "TopLevelWindowModel");
49 qmlRegisterSingletonType<WorkspaceManager>(uri, 1, 0, "WorkspaceManager", workspace_manager);
50 qmlRegisterUncreatableType<WorkspaceModel>(uri, 1, 0, "WorkspaceModel", notInstantiatable);
51 qmlRegisterSingletonType<Screens>(uri, 1, 0, "Screens", screensSingleton);
52 qmlRegisterUncreatableType<qtmir::ScreenMode>(uri, 1, 0, "ScreenMode", notInstantiatable);
53 qmlRegisterUncreatableType<Workspace>(uri, 1, 0, "Workspace", notInstantiatable);
55 qRegisterMetaType<Screen*>("Screen*");
56 qRegisterMetaType<ScreensProxy*>("ScreensProxy*");
57 qRegisterMetaType<Workspace*>("Workspace*");
59 qRegisterMetaType<Window*>("Window*");
60 qRegisterMetaType<QAbstractListModel*>("QAbstractListModel*");
62 qmlRegisterType<ScreenWindow>(uri, 1, 0, "ScreenWindow");
63 qmlRegisterRevision<QWindow,1>(uri, 1, 0);
65 qmlRegisterUncreatableType<WMScreen>(uri, 1, 0, "WMScreen", notInstantiatable);