[keyboard] Restore the notion of PC105 default index

This commit is contained in:
Adriaan de Groot 2020-10-28 13:52:30 +01:00
parent 6aedf4401f
commit 193efe1710
2 changed files with 10 additions and 1 deletions

View File

@ -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";

View File

@ -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