kwin/src/scripting/tilemodel.h
Marco Martin e4507861f7 Custom quick tiling with configuration ui
* Allow to do quick tiling to custom tile geometries, windows will be snapped to tiles when dragged with the shift modifier pressed.
* Tile geometries are screen specific.
* The global shortcut Meta+T will trigger a fullscreen configuration ui as a QML effect for the tiles which allows to add, remove and resize tiles
* UI and behavior is a bit similar to the Windows Fancy Zones addon: https://docs.microsoft.com/en-us/windows/powertoys/fancyzones
* Its main scope is to help the workflow with very big monitors, especially ultra wide ones, where most application don't make sense maximized to the full screen (eventually also support games to be full screened to a given tile instead of the whole screen)
* it should get also some bindings for scripting, as its ain goal is not to replicate other popular tiling window managers, but should give the popular kwin tiling scripts to have a more robust infrastructure
* it will eventually get support for a set of predefined layouts, but this is for a second phase

BUG: 438788
2022-12-01 14:39:22 +00:00

70 lines
1.7 KiB
C++

/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2022 Marco Martin <mart@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include "tiles/customtile.h"
#include "tiles/quicktile.h"
#include "tiles/tile.h"
#include "utils/common.h"
#include <kwin_export.h>
#include <QAbstractItemModel>
#include <QObject>
#include <QRectF>
#include <QJsonValue>
class QTimer;
namespace KWin
{
class Output;
class CustomTile;
class TileManager;
/**
* Custom tiling zones management per output.
*/
class KWIN_EXPORT TileModel : public QAbstractItemModel
{
Q_OBJECT
public:
enum Roles {
TileRole = Qt::UserRole + 1
};
explicit TileModel(TileManager *parent = nullptr);
~TileModel() override;
// QAbstractItemModel overrides
QHash<int, QByteArray> roleNames() const override;
QVariant data(const QModelIndex &index, int role) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &index) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
private:
void beginInsertTile(CustomTile *tile, int position);
void endInsertTile();
void beginRemoveTile(CustomTile *tile);
void endRemoveTile();
// Not an uinique_pointer as the model is child of the manager so would cause a cyclic delete
TileManager *m_tileManager;
friend class CustomTile;
Q_DISABLE_COPY(TileModel)
};
} // namespace KWin