mirror of
https://github.com/RustyRaptor/plasma-keyboard.git
synced 2026-12-03 15:55:19 -07:00
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.
43 lines
1.0 KiB
C++
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;
|
|
};
|