Пример #1
0
void KeybindSettings::setKeybind(QString &profile, KeyName &key, ModKeys &mods, QString &command, bool &is_secondary)
{
    removeKeybind(profile,key,mods); // remove previous keybinds

    QString keystring = makeKeyString(key,mods); // Construct keystring from mods+key

    for(auto &p : m_keybind_profiles)
    {
        if(p.Name == profile)
            p.KeybindArr.push_back({key,mods,keystring,command,is_secondary});
    }

    qCDebug(logKeybinds) << "Setting keybind: " << profile << key << mods << keystring << command << is_secondary;

}
Пример #2
0
void KeybindSettings::removeKeybind(QString &profile, KeyName &key, ModKeys &mods)
{
    QString keystring = makeKeyString(key,mods); // Construct keystring from mods+key

    for(auto &p : m_keybind_profiles)
    {
        if(p.Name != profile)
            continue;

        for(auto iter=p.KeybindArr.begin(); iter!=p.KeybindArr.end(); /*incremented inside loop*/)
        {
          if(iter->Key==key && iter->Mods==mods)
              iter=p.KeybindArr.erase(iter);
          else
              ++iter;
        }
    }
    qCDebug(logKeybinds) << "Clearing keybind: " << profile << key << mods << keystring;
}
Пример #3
0
void OptionsHotKeys::reset( bool useOld )
{

	hotKeyList.removeAllItems( true );
	char shift[32];
	char control[32];
	char alt[32];
	char descText[128];
	char keysString[128];

	cLoadString( IDS_SHIFT, shift, 31 );
	cLoadString( IDS_CONTROL, control, 31 );
	cLoadString( IDS_ALT, alt, 31 );

	MissionInterfaceManager::Command* commands = MissionInterfaceManager::getCommands();
	long*	oldKeys = MissionInterfaceManager::getOldKeys();
	for ( int i = 0; i < MAX_COMMAND; i++ )
	{
		if ( commands[i].hotKeyDescriptionText != -1 )
		{
			keysString[0] = 0;
			cLoadString( commands[i].hotKeyDescriptionText, descText, 127 );
			long key = useOld ? oldKeys[i] : commands[i].key;
			makeKeyString( key, keysString );

			HotKeyListItem* item = new HotKeyListItem();
			item->setDescription( descText );
			item->setKey( keysString );		
			item->setHotKey( key );
			item->setCommand( i );
			hotKeyList.AddItem( item );
			


		}
	}
}
Пример #4
0
void OptionsHotKeys::update()
{

	if ( bShowDlg )
	{
		LogisticsOKDialog::instance()->update();
		if ( LogisticsOKDialog::instance()->isDone() )
		{
			bShowDlg = 0;
			if ( LogisticsDialog::YES == LogisticsOKDialog::instance()->getStatus() )
			{
				char keysString[256];
				keysString[0] = 0;

				makeKeyString( curHotKey, keysString );

				
				long index = hotKeyList.GetSelectedItem();
				long oldKey = -1;
				
				if ( index > -1 )
				{
					HotKeyListItem* pItemToSet = (HotKeyListItem*)hotKeyList.GetItem( index );
					// now I've got to find the other one with th new key and set it to the old key
					for ( int i = 0; i < hotKeyList.GetItemCount(); i++ )
					{
						HotKeyListItem* pTmpItem = (HotKeyListItem*)hotKeyList.GetItem( i );
						if ( pTmpItem->getHotKey() == curHotKey  && pTmpItem != pItemToSet )
						{

							// first we've got to see if we can set to the default
							long*	defaultKeys = MissionInterfaceManager::getOldKeys();
							int defaultKey = defaultKeys[pTmpItem->getCommand()];
							for ( int j = 0; j < hotKeyList.GetItemCount(); j++ )
							{
								HotKeyListItem* pCheckItem = (HotKeyListItem*)hotKeyList.GetItem( j );
								if ( pCheckItem->getHotKey() == defaultKey )
								{
									defaultKey = -1;
									break;
								}
							}			 			

							if ( defaultKey != -1 )
								oldKey = defaultKey;
							else if ( pItemToSet )
								oldKey = pItemToSet->getHotKey();

							char tmpKeyStr[256];
							tmpKeyStr[0] = 0;
							makeKeyString( oldKey, tmpKeyStr );
							pTmpItem->setHotKey( oldKey );
							pTmpItem->setKey( tmpKeyStr );
						}
					}
					pItemToSet->setKey( keysString );
					pItemToSet->setHotKey( curHotKey );
					hotKeyList.SelectItem( -1 );
				}



			}
		}

		return;
	}
	LogisticsScreen::update();
	
	hotKeyList.update();

	long tmpKey = 1;

	while( tmpKey ) // empty out keyboard buffers...
	{
		int index = hotKeyList.GetSelectedItem( );
		tmpKey = 0;

		if ( index > -1 )
		{
			HotKeyListItem* pItem = (HotKeyListItem*)hotKeyList.GetItem( index );
			tmpKey = gos_GetKey();

			if ( tmpKey )
			{
				char hotKeyString[256];
				hotKeyString[0] = 0;

				if ( 0 != makeInputKeyString( tmpKey, hotKeyString ) )
					return;

				curHotKey = tmpKey;
				// check and see if anyone else is using this one...
				for ( int i = 0; i < hotKeyList.GetItemCount(); i++ )
				{
					HotKeyListItem* pTmpItem = (HotKeyListItem*)hotKeyList.GetItem( i );
					if ( pTmpItem->getHotKey() == curHotKey  && pTmpItem != pItem )
					{
						LogisticsOKDialog::instance()->setText( IDS_OPTIONS_HOTKEY_ERROR, IDS_DIALOG_NO, IDS_DIALOG_YES  );
						LogisticsOKDialog::instance()->begin();
						bShowDlg = true;
					}

				}
				
				if ( !bShowDlg )
				{
					pItem->setHotKey( tmpKey );
					pItem->setKey( hotKeyString );
					hotKeyList.SelectItem( -1 );
				}
			}

		}
	}
}