Exemplo n.º 1
0
void KKeyChooser::setKey( uint kCode)
{
	// uint kOldCode = pEntry->aConfigKeyCode;
	
	/* add the current modifier to the key */
	if ( kCode!=Key_Shift ) kCode |= (pEntry->aConfigKeyCode & SHIFT);
	if ( kCode!=Key_Control ) kCode |= (pEntry->aConfigKeyCode & CTRL);
	if ( kCode!=Key_Alt ) kCode |= (pEntry->aConfigKeyCode & ALT);
	
	/* set the list and the chande button */
	pEntry->aConfigKeyCode = kCode;
	
	if ( isKeyPresent() ) {
		lInfo->setText(i18n("Attention : key already used"));
		return;
	}
	
	KSplitListItem *sli = new KSplitListItem(
	 	item(pEntry->aConfigKeyCode, sEntryKey)
	);
		
	connect( wList, SIGNAL( newWidth( int ) ),
			 sli, SLOT( setWidth( int ) ) );
				 
				
	sli->setWidth( wList->width() );
	
	wList->changeItem( sli, wList->currentItem() );
	toChange(wList->currentItem());
}
Exemplo n.º 2
0
void KKeyChooser::setShortcut(const KShortcut &cut)
{
    kdDebug(125) << "KKeyChooser::setShortcut( " << cut.toString() << " )" << endl;
    KKeyChooserItem *pItem = dynamic_cast< KKeyChooserItem * >(d->pList->currentItem());
    if(!pItem)
        return;

    for(uint i = 0; i < cut.count(); i++)
    {
        const KKeySequence &seq = cut.seq(i);
        const KKey &key = seq.key(0);

        if(!d->bAllowLetterShortcuts && key.modFlags() == 0 && key.sym() < 0x3000 && QChar(key.sym()).isLetterOrNumber())
        {
            QString s = i18n(
                            "In order to use the '%1' key as a shortcut, "
                            "it must be combined with the "
                            "Win, Alt, Ctrl, and/or Shift keys.")
                            .arg(QChar(key.sym()));
            KMessageBox::sorry(this, s, i18n("Invalid Shortcut Key"));
            return;
        }
    }

    // If key isn't already in use,
    if(!isKeyPresent(cut))
    {
        // Set new key code
        pItem->setShortcut(cut);
        // Update display
        updateButtons();
        emit keyChange();
    }
}
std::shared_ptr<Material> MaterialFactory::getMaterial(
	ComPtr<ID3D11Device> const device,
	const char* const filename)
{
	if (isKeyPresent(filename))
	{
		return existingMaterials.at(filename);
	}

	std::shared_ptr<Material> newmat(new Material);

	if (!newmat->Initialize(device, filename))
	{
		MessageBox(NULL, "Material Factory failed to create new material", FATALERROR, FATALLAYOUT);
		return nullptr;
	}

	existingMaterials.insert(std::pair<std::string, std::shared_ptr<Material>>(std::string(filename), newmat));

	return newmat;
}
Exemplo n.º 4
0
void KKeyChooser::toChange( int index )
{
	bKeyIntercept = FALSE;
	
	/* get the entry */
	aIt->toFirst();
	(*aIt) += index;
	sEntryKey = aIt->currentKey();
	pEntry = aIt->current();
	
	//eKey->setEnabled( FALSE );
	
	/* Is the key configurable or has the user turned it off ? */
	if ( !pEntry->bConfigurable || kbMode == NoKey ) {
		lInfo->setEnabled( FALSE );
		cShift->setEnabled( FALSE ); cCtrl->setEnabled( FALSE ); cAlt->setEnabled( FALSE );
		bChange->setEnabled( FALSE );  //bDefault->setEnabled( FALSE );
		lNotConfig->setEnabled( TRUE );
		
		uint kCode = pEntry->aConfigKeyCode;
		uint kSCode = kCode & ~(SHIFT | CTRL | ALT);
		
		if ( kSCode == Key_Shift ) cShift->setChecked(FALSE);
		else cShift->setChecked( kCode & SHIFT );
		if ( kSCode == Key_Control ) cCtrl->setChecked(FALSE);
		else cCtrl->setChecked( kCode & CTRL );
		if ( kSCode == Key_Alt ) cAlt->setChecked(FALSE);
		else cAlt->setChecked( kCode & ALT );
		
		QString str = keyToString( kSCode );
		bChange->setText(str);
		
	} else {
		lNotConfig->setEnabled( FALSE );
		lInfo->setText(""); lInfo->setEnabled( TRUE );
		
		uint kCode = pEntry->aConfigKeyCode;
		uint kSCode = kCode & ~(SHIFT | CTRL | ALT);
		
		//cShift->setEnabled( TRUE ); cCtrl->setEnabled( TRUE ); cAlt->setEnabled( TRUE );
		if ( kSCode == Key_Shift ) cShift->setChecked(FALSE);
		else cShift->setChecked( kCode & SHIFT );
		if ( kSCode == Key_Control ) cCtrl->setChecked(FALSE);
		else cCtrl->setChecked( kCode & CTRL );
		if ( kSCode == Key_Alt ) cAlt->setChecked(FALSE);
		else cAlt->setChecked( kCode & ALT );
		
		QString str = keyToString( kSCode );
		bChange->setText(str); //eKey->setText(str);
		//bChange->setEnabled( TRUE ); //bDefault->setEnabled( TRUE );
		
		if ( isKeyPresent() ) {
			lInfo->setText(i18n("Attention : key already used"));
		}
		
		if ( kbMode == DefaultKey ) {
			cAlt->setEnabled( false );
			cShift->setEnabled( false );
			cCtrl->setEnabled( false );
			bChange->setEnabled( false );
		} else {
			cAlt->setEnabled( true );
			cShift->setEnabled( true );
			cCtrl->setEnabled( true );
			bChange->setEnabled( true );
		}
	}
		
	((QRadioButton *)kbGroup->find(NoKey))->setChecked( kbMode == NoKey );
	((QRadioButton *)kbGroup->find(DefaultKey))->setChecked( kbMode == DefaultKey );
	((QRadioButton *)kbGroup->find(CustomKey))->setChecked( kbMode == CustomKey );
	
	if ( !pEntry->bConfigurable ) {
		cAlt->setEnabled( false );
		cShift->setEnabled( false );
		cCtrl->setEnabled( false );
		bChange->setEnabled( false );
		((QRadioButton *)kbGroup->find(NoKey))->setEnabled( false );
		((QRadioButton *)kbGroup->find(DefaultKey))->setEnabled( false );
		((QRadioButton *)kbGroup->find(CustomKey))->setEnabled( false );
	} else {
		((QRadioButton *)kbGroup->find(NoKey))->setEnabled( true );
		((QRadioButton *)kbGroup->find(DefaultKey))->setEnabled( true );
		((QRadioButton *)kbGroup->find(CustomKey))->setEnabled( true );
	}	
}