void MythUIVirtualKeyboard::updateKeys(bool connectSignals) { QList<MythUIType *> *children = GetAllChildren(); for (int i = 0; i < children->size(); ++i) { MythUIButton *button = dynamic_cast<MythUIButton *>(children->at(i)); if (button) { if (m_keyMap.contains(button->objectName())) { KeyDefinition key = m_keyMap.value(button->objectName()); button->SetText(getKeyText(key)); if (connectSignals) { if (key.type == "shift") { if (!m_shiftLButton) m_shiftLButton = button; else if (!m_shiftRButton) m_shiftRButton = button; button->SetLockable(true); connect(button, SIGNAL(Clicked()), SLOT(shiftClicked())); } else if (key.type == "char") connect(button, SIGNAL(Clicked()), SLOT(charClicked())); else if (key.type == "done") connect(button, SIGNAL(Clicked()), SLOT(returnClicked())); else if (key.type == "del") connect(button, SIGNAL(Clicked()), SLOT(delClicked())); else if (key.type == "lock") { m_lockButton = button; m_lockButton->SetLockable(true); connect(m_lockButton, SIGNAL(Clicked()), SLOT(lockClicked())); } else if (key.type == "alt") { m_altButton = button; m_altButton->SetLockable(true); connect(m_altButton, SIGNAL(Clicked()), SLOT(altClicked())); } else if (key.type == "comp") { m_compButton = button; m_compButton->SetLockable(true); connect(m_compButton, SIGNAL(Clicked()), SLOT(compClicked())); } else if (key.type == "moveleft") connect(button, SIGNAL(Clicked()), SLOT(moveleftClicked())); else if (key.type == "moveright") connect(button, SIGNAL(Clicked()), SLOT(moverightClicked())); else if (key.type == "back") connect(button, SIGNAL(Clicked()), SLOT(backClicked())); } } else LOG(VB_GENERAL, LOG_WARNING, QString("WARNING - Key '%1' not found in map") .arg(button->objectName())); } } }
KKeyChooser::KKeyChooser( QDict<KKeyEntry> *aKeyDict, QWidget *parent ) : QWidget( parent ) { bKeyIntercept = FALSE; kbMode = NoKey; aKeyIt = new QDictIterator<KKeyEntry> ( *aKeyDict ); // TOP LAYOUT MANAGER // The following layout is used for the dialog // LIST LABELS LAYOUT // SPLIT LIST BOX WIDGET // CHOOSE KEY GROUP BOX WIDGET // BUTTONS LAYOUT // Items are added to topLayout as they are created. QBoxLayout *topLayout = new QVBoxLayout( this, 0, 10 ); // CREATE LIST LABELS QGridLayout *stackLayout = new QGridLayout( 2, 2, 2); topLayout->addLayout( stackLayout, 50 ); stackLayout->setRowStretch(1,10); keyLabel = new QLabel(this); stackLayout->addWidget(keyLabel, 0, 1); keyLabel->setText( i18n("Current key") ); keyLabel->setFixedHeight( keyLabel->sizeHint().height() ); // CREATE SPLIT LIST BOX // Copy all currentKeyCodes to configKeyCodes // and fill up the split list box with the action/key pairs. wList = new KSplitList( this ); stackLayout->addMultiCellWidget( wList, 1, 1, 0, 1 ); actLabel = new QLabel( wList, i18n("&Action"), this ); stackLayout->addWidget( actLabel, 0, 0 ); actLabel->setFixedHeight( actLabel->sizeHint().height() ); wList->setAutoUpdate(FALSE); wList->setFocus(); aIt = aKeyIt; aIt->toFirst(); while ( aIt->current() ) { aIt->current()->aConfigKeyCode = aIt->current()->aCurrentKeyCode; KSplitListItem *sli = new KSplitListItem( item( aIt->current()->aConfigKeyCode, aIt->currentKey() ) ); connect( wList, SIGNAL( newWidth( int ) ), sli, SLOT( setWidth( int ) ) ); wList->insertItem( sli ); ++ ( *aIt ); } if ( wList->count() == 0 ) wList->setEnabled( FALSE ); //connect( wList, SIGNAL( selected( int ) ), SLOT( toChange( int ) ) ); connect( wList, SIGNAL( highlighted( int ) ), SLOT( updateAction( int ) ) ); // CREATE CHOOSE KEY GROUP fCArea = new QGroupBox( this ); topLayout->addWidget( fCArea, 1 ); fCArea->setTitle( i18n("Choose a key for the selected action") ); fCArea->setFrameStyle( QFrame::Box | QFrame::Sunken ); // CHOOSE KEY GROUP LAYOUT MANAGER QGridLayout *grid = new QGridLayout( fCArea, 6, 4, 5 ); grid->setRowStretch(0,10); grid->setRowStretch(1,10); grid->setRowStretch(2,10); grid->setRowStretch(3,10); grid->setRowStretch(4,10); grid->setRowStretch(5,10); grid->setColStretch(0,0); grid->setColStretch(1,10); grid->setColStretch(2,90); grid->setColStretch(3,0); grid->addRowSpacing(0,15); grid->addRowSpacing(5,1); kbGroup = new QButtonGroup( fCArea ); kbGroup->hide(); kbGroup->setExclusive( true ); QRadioButton *rb = new QRadioButton( i18n("&No key"), fCArea ); rb->adjustSize(); rb->setFixedHeight( rb->height() ); rb->setMinimumWidth( rb->width() ); kbGroup->insert( rb, NoKey ); grid->addMultiCellWidget( rb, 1, 1, 1, 2 ); rb = new QRadioButton( i18n("&Default key"), fCArea ); rb->adjustSize(); rb->setFixedHeight( rb->height() ); rb->setMinimumWidth( rb->width() ); kbGroup->insert( rb, DefaultKey ); grid->addMultiCellWidget( rb, 2, 2, 1, 2 ); rb = new QRadioButton( i18n("&Custom key"), fCArea ); rb->adjustSize(); rb->setFixedHeight( rb->height() ); rb->setMinimumWidth( rb->width() ); kbGroup->insert( rb, CustomKey ); connect( kbGroup, SIGNAL( clicked( int ) ), SLOT( keyMode( int ) ) ); grid->addMultiCellWidget( rb, 3, 3, 1, 2 ); QBoxLayout *pushLayout = new QHBoxLayout( 2 ); grid->addLayout( pushLayout, 4, 2 ); cShift = new QCheckBox( fCArea ); cShift->setText( "SHIFT" ); cShift->setEnabled( FALSE ); connect( cShift, SIGNAL( clicked() ), SLOT( shiftClicked() ) ); cCtrl = new QCheckBox( fCArea ); cCtrl->setText( "CTRL" ); cCtrl->setEnabled( FALSE ); connect( cCtrl, SIGNAL( clicked() ), SLOT( ctrlClicked() ) ); cAlt = new QCheckBox( fCArea ); cAlt->setText( "ALT" ); cAlt->setEnabled( FALSE ); connect( cAlt, SIGNAL( clicked() ), SLOT( altClicked() ) ); bChange = new KKeyButton("key", fCArea); bChange->setEnabled( FALSE ); connect( bChange, SIGNAL( clicked() ), SLOT( changeKey() ) ); // Set height of checkboxes to basic key button height. // Basic key button height = push button height. cAlt->adjustSize(); cAlt->setFixedHeight( bChange->sizeHint().height() ); cAlt->setMinimumWidth( cAlt->width() ); cShift->adjustSize(); cShift->setFixedHeight( bChange->sizeHint().height() ); cShift->setMinimumWidth( cShift->width() ); cCtrl->adjustSize(); cCtrl->setFixedHeight( bChange->sizeHint().height() ); cCtrl->setMinimumWidth( cCtrl->width() ); fCArea->setMinimumHeight( bChange->sizeHint().height() + 20 + 3*rb->height() + 4*10); // Add widgets to the geometry manager pushLayout->addWidget( cShift ); pushLayout->addSpacing( 8 ); pushLayout->addWidget( cCtrl ); pushLayout->addSpacing( 8 ); pushLayout->addWidget( cAlt ); pushLayout->addSpacing( 18 ); pushLayout->addWidget( bChange ); pushLayout->addStretch( 10 ); lNotConfig = new QLabel(fCArea); lNotConfig->resize(0,0); lNotConfig->setFont( QFont("Helvetica", 14, QFont::Bold) ); lNotConfig->setAlignment( AlignCenter ); lNotConfig->setFrameStyle( QFrame::Panel | QFrame::Sunken ); if ( wList->count()==0 ) lNotConfig->setText(i18n("No keys defined")); else { lNotConfig->setText(i18n("Not configurable")); lNotConfig->hide(); } lNotConfig->hide(); lInfo = new QLabel(fCArea); resize(0,0); lInfo->setAlignment( AlignCenter ); lInfo->setEnabled( FALSE ); lInfo->hide(); wList->setAutoUpdate(TRUE); wList->update(); globalDict = new QDict<int> ( 37, false ); globalDict->setAutoDelete( true ); readGlobalKeys(); topLayout->activate(); }