Files
plasma-keyboard/kcm/enabledkeyboardlayoutmodel.h
Devin Lin 22a7261147 kcm: Introduce "enabled layouts" page with option to sort
Currently the layout selection only allows for toggling on and off
keyboard layouts.

This MR moves this page into being an "add keyboard layout page", and
introduces a new page that is just the list of enabled keyboard layouts,
with buttons to sort and delete.
2026-10-28 17:21:46 -04:00

43 lines
1.0 KiB
C++

/*
SPDX-FileCopyrightText: 2026 Devin Lin <devin@kde.org>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#pragma once
#include "keyboardlayoutmodel.h"
#include <QAbstractListModel>
#include <QHash>
#include <QStringList>
/**
* Model to list the enabled keyboard layouts that are shown to the user.
*/
class EnabledKeyboardLayoutModel : public QAbstractListModel
{
Q_OBJECT
public:
enum Role {
LayoutIdRole = Qt::UserRole + 1,
NameRole,
};
Q_ENUM(Role)
explicit EnabledKeyboardLayoutModel(QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = {}) const override;
QVariant data(const QModelIndex &index, int role) const override;
QHash<int, QByteArray> roleNames() const override;
QStringList layoutIds() const;
void setLayoutIds(const QStringList &layoutIds);
bool move(int fromRow, int destRow);
private:
QHash<QString, KeyboardLayoutModel::Layout> m_installedLayouts;
QStringList m_layoutIds;
};