diff --git a/src/modules/keyboard/KeyboardLayoutModel.cpp b/src/modules/keyboard/KeyboardLayoutModel.cpp index f0393ba6c..ab7dbd37f 100644 --- a/src/modules/keyboard/KeyboardLayoutModel.cpp +++ b/src/modules/keyboard/KeyboardLayoutModel.cpp @@ -19,11 +19,17 @@ KeyboardModelsModel::KeyboardModelsModel( QObject* parent ) { // The models map is from human-readable names (!) to xkb identifier const auto models = KeyboardGlobal::getKeyboardModels(); + int index = 0; for ( const auto& key : models.keys() ) { // So here *key* is the key in the map, which is the human-readable thing, // while the struct fields are xkb-id, and human-readable m_list << ModelInfo { models[ key ], key }; + if ( models[ key ] == "pc105" ) + { + m_defaultPC105 = index; + } + index++; } cDebug() << "Loaded" << m_list.count() << "keyboard models"; diff --git a/src/modules/keyboard/KeyboardLayoutModel.h b/src/modules/keyboard/KeyboardLayoutModel.h index a7075b798..d0edac2d1 100644 --- a/src/modules/keyboard/KeyboardLayoutModel.h +++ b/src/modules/keyboard/KeyboardLayoutModel.h @@ -54,6 +54,8 @@ public: QHash< int, QByteArray > roleNames() const override; void setCurrentIndex( int index ); + /// @brief Set the index back to PC105 (the default physical model) + void setCurrentIndex() { setCurrentIndex( m_defaultPC105 ); } int currentIndex() const { return m_currentIndex; } signals: @@ -68,7 +70,8 @@ private: QString label; }; QVector< ModelInfo > m_list; - int m_currentIndex; + int m_currentIndex = -1; + int m_defaultPC105 = -1; ///< The index of pc105, if there is one }; class KeyboardLayoutModel : public QAbstractListModel