mirror of
https://invent.kde.org/plasma/plasma-desktop.git
synced 2026-11-03 22:59:45 -09:00
kcms/keyboard: port LayoutModel to QML declarative
This commit is contained in:
parent
af50724aea
commit
af5db79abc
6 changed files with 8 additions and 17 deletions
|
|
@ -76,7 +76,6 @@ set( kcm_keyboard_PART_SRCS
|
|||
xkb_rules.cpp
|
||||
shortcuthelper.cpp
|
||||
xkboptionsmodel.cpp
|
||||
layoutmodel.cpp
|
||||
userlayoutmodel.cpp
|
||||
layoutsearchmodel.cpp
|
||||
)
|
||||
|
|
@ -140,6 +139,7 @@ ecm_add_qml_module(kcm_keyboard_declarative
|
|||
GENERATE_PLUGIN_SOURCE
|
||||
SOURCES
|
||||
keyboardmodel.cpp
|
||||
layoutmodel.cpp
|
||||
types.h
|
||||
DEPENDENCIES
|
||||
QtCore
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
#include "keyboardmiscsettings.h"
|
||||
#include "keyboardsettings.h"
|
||||
#include "keyboardsettingsdata.h"
|
||||
#include "layoutmodel.h"
|
||||
#include "shortcuthelper.h"
|
||||
#include "tastenbrett.h"
|
||||
#include "userlayoutmodel.h"
|
||||
|
|
@ -33,7 +32,6 @@ KCMKeyboard::KCMKeyboard(QObject *parent, const KPluginMetaData &data)
|
|||
: KQuickManagedConfigModule(parent, data)
|
||||
, m_data(new KeyboardSettingsData(this))
|
||||
, m_config(new KeyboardConfig(m_data->keyboardSettings(), this))
|
||||
, m_layoutModel(new LayoutModel(this))
|
||||
, m_userLayoutModel(new UserLayoutModel(m_config, this))
|
||||
, m_shortcutHelper(new ShortcutHelper(this))
|
||||
, m_xkbOptionsModel(new XkbOptionsModel(this))
|
||||
|
|
@ -96,11 +94,6 @@ KeyboardSettings *KCMKeyboard::keyboardSettings() const
|
|||
return m_data->keyboardSettings();
|
||||
}
|
||||
|
||||
LayoutModel *KCMKeyboard::layouts() const
|
||||
{
|
||||
return m_layoutModel;
|
||||
}
|
||||
|
||||
UserLayoutModel *KCMKeyboard::userLayoutModel() const
|
||||
{
|
||||
return m_userLayoutModel;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ class KeyboardMiscSettings;
|
|||
class KeyboardSettings;
|
||||
class KeyboardConfig;
|
||||
class ShortcutHelper;
|
||||
class LayoutModel;
|
||||
class UserLayoutModel;
|
||||
class XkbOptionsModel;
|
||||
|
||||
|
|
@ -38,7 +37,6 @@ class KCMKeyboard final : public KQuickManagedConfigModule
|
|||
Q_PROPERTY(WorkspaceOptions *workspaceOptions READ workspaceOptions CONSTANT)
|
||||
Q_PROPERTY(KeyboardMiscSettings *miscSettings READ miscSettings CONSTANT)
|
||||
Q_PROPERTY(KeyboardSettings *keyboardSettings READ keyboardSettings CONSTANT)
|
||||
Q_PROPERTY(LayoutModel *layouts READ layouts CONSTANT)
|
||||
Q_PROPERTY(UserLayoutModel *userLayoutModel READ userLayoutModel CONSTANT)
|
||||
Q_PROPERTY(ShortcutHelper *shortcutHelper READ shortcutHelper CONSTANT)
|
||||
Q_PROPERTY(XkbOptionsModel *xkbOptionsModel READ xkbOptionsModel CONSTANT)
|
||||
|
|
@ -52,7 +50,6 @@ public:
|
|||
WorkspaceOptions *workspaceOptions() const;
|
||||
KeyboardMiscSettings *miscSettings() const;
|
||||
KeyboardSettings *keyboardSettings() const;
|
||||
LayoutModel *layouts() const;
|
||||
UserLayoutModel *userLayoutModel() const;
|
||||
ShortcutHelper *shortcutHelper() const;
|
||||
XkbOptionsModel *xkbOptionsModel() const;
|
||||
|
|
@ -78,7 +75,6 @@ private:
|
|||
KeyboardSettingsData *const m_data;
|
||||
KeyboardConfig *const m_config;
|
||||
|
||||
LayoutModel *const m_layoutModel;
|
||||
UserLayoutModel *const m_userLayoutModel;
|
||||
ShortcutHelper *const m_shortcutHelper;
|
||||
XkbOptionsModel *const m_xkbOptionsModel;
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
#include "x11_helper.h"
|
||||
#include "xkb_rules.h"
|
||||
|
||||
LayoutModel::LayoutModel(QObject *parent) noexcept
|
||||
: QAbstractListModel(parent)
|
||||
LayoutModel::LayoutModel() noexcept
|
||||
: QAbstractListModel()
|
||||
{
|
||||
for (const LayoutInfo &layoutInfo : std::as_const(Rules::self().layoutInfos)) {
|
||||
m_data.append(Data(layoutInfo.name, layoutInfo.description, QStringLiteral("")));
|
||||
|
|
|
|||
|
|
@ -7,10 +7,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <qqmlintegration.h>
|
||||
|
||||
class LayoutModel final : public QAbstractListModel
|
||||
class LayoutModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
|
||||
struct Data {
|
||||
explicit Data(const QString &_name, const QString &_description, const QString &_variantName)
|
||||
|
|
@ -26,7 +28,7 @@ class LayoutModel final : public QAbstractListModel
|
|||
};
|
||||
|
||||
public:
|
||||
explicit LayoutModel(QObject *parent) noexcept;
|
||||
explicit LayoutModel() noexcept;
|
||||
|
||||
Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
Q_INVOKABLE QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ Kirigami.Dialog {
|
|||
|
||||
KCMKeyboard.LayoutSearchModel {
|
||||
id: layoutSearchProxy
|
||||
sourceModel: kcm?.layouts ?? undefined
|
||||
sourceModel: KCMKeyboard.LayoutModel {}
|
||||
searchString: ""
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue