Keyboard: special-case, pc+latin interpreted as us,

instead of as unknown which selects the first layout in the list.
This commit is contained in:
Adriaan de Groot 2017-06-19 11:11:08 -04:00 committed by Philip
parent 7f08ea9d15
commit e57579c92f

View File

@ -37,6 +37,21 @@
#include <QProcess> #include <QProcess>
#include <QPushButton> #include <QPushButton>
static QPersistentModelIndex
findLayout( const KeyboardLayoutModel* klm, const QString& currentLayout )
{
QPersistentModelIndex currentLayoutItem;
for ( int i = 0; i < klm->rowCount(); ++i )
{
QModelIndex idx = klm->index( i );
if ( idx.isValid() &&
idx.data( KeyboardLayoutModel::KeyboardLayoutKeyRole ).toString() == currentLayout )
currentLayoutItem = idx;
}
return currentLayoutItem;
}
KeyboardPage::KeyboardPage( QWidget* parent ) KeyboardPage::KeyboardPage( QWidget* parent )
: QWidget() : QWidget()
@ -160,14 +175,13 @@ KeyboardPage::init()
// Block signals // Block signals
ui->listLayout->blockSignals( true ); ui->listLayout->blockSignals( true );
QPersistentModelIndex currentLayoutItem; QPersistentModelIndex currentLayoutItem = findLayout( klm, currentLayout );
if ( !currentLayoutItem.isValid() && (
for ( int i = 0; i < klm->rowCount(); ++i ) ( currentLayout == "latin" )
|| ( currentLayout == "pc" ) ) )
{ {
QModelIndex idx = klm->index( i ); currentLayout = "us";
if ( idx.isValid() && currentLayoutItem = findLayout( klm, currentLayout );
idx.data( KeyboardLayoutModel::KeyboardLayoutKeyRole ).toString() == currentLayout )
currentLayoutItem = idx;
} }
// Set current layout and variant // Set current layout and variant
@ -341,4 +355,3 @@ KeyboardPage::onListVariantCurrentItemChanged( QListWidgetItem* current, QListWi
m_selectedLayout = layout; m_selectedLayout = layout;
m_selectedVariant = variant; m_selectedVariant = variant;
} }