Exemplo n.º 1
0
void ShortcutManager::Load() {
	unsigned char *key;
	unsigned char *command;
	ClearShortcuts();
	int count = 0;
	while (command = config.GetConfigStringAndKey((unsigned char *)"Shortcuts", key, count)) {
		count++;
		if (command || key) {
			if (key && command && srealloc(shortcuts, sizeof(Shortcut) * (numShortcuts+1))) {
				unsigned int modifiers = 0;
				unsigned int vkey = 0;
				int i = 0;
				while (1) {
					if (key[i] == '@') modifiers |= MOD_WIN;
					else if (key[i] == '!') modifiers |= MOD_ALT;
					else if (key[i] == '^') modifiers |= MOD_CONTROL;
					else if (key[i] == '+') modifiers |= MOD_SHIFT;
					else break;
					i++;
				}
				if (key[i+1] == 0) {
					short code = VkKeyScan(key[i]);
					if (code != 0xFFFF) {
						vkey = code & 0xFF;
					}
					/*if ((UCASE(key[i] >= 'A') && UCASE(key[i] <= 'Z')) || (key[i] >= '0' && key[i] <= '9'))
						vkey = UCASE(key[i]);
					if ((UCASE(key[i] >= 'A') && UCASE(key[i] <= 'Z')) || (key[i] >= '0' && key[i] <= '9'))
					//*/
				}
				else if (CompareSubstringNoCase(key+i, (unsigned char*)"num") == 0) {
					if (CompareSubstringNoCase(key+i, (unsigned char*)"pad") == 0)
						i+=3;
					if (key[i+1] == 0 && '0' <= key[i] && key[i] <= '9') {
						vkey = VK_NUMPAD0 + key[i] - '0';
					}
					else if (stricmp(key+i, (unsigned char*) "*") == 0 || stricmp(key+i, (unsigned char*) "multiply") == 0 || stricmp(key+i, (unsigned char*) "mul") == 0 || stricmp(key+i, (unsigned char*) "times") == 0 || stricmp(key+i, (unsigned char*) "star") == 0)
						vkey = VK_ADD;
					else if (stricmp(key+i, (unsigned char*) "+") == 0 || stricmp(key+i, (unsigned char*) "plus") == 0 || stricmp(key+i, (unsigned char*) "add") == 0)
						vkey = VK_ADD;
					else if (stricmp(key+i, (unsigned char*) "-") == 0 || stricmp(key+i, (unsigned char*) "minus") == 0 || stricmp(key+i, (unsigned char*) "sub") == 0 || stricmp(key+i, (unsigned char*) "subtract") == 0)
						vkey = VK_SUBTRACT;
					else if (stricmp(key+i, (unsigned char*) "/") == 0 || stricmp(key+i, (unsigned char*) "divide") == 0 || stricmp(key+i, (unsigned char*) "div") == 0 || stricmp(key+i, (unsigned char*) "slash") == 0)
						vkey = VK_DIVIDE;
					else if (stricmp(key+i, (unsigned char*) ".") == 0 || stricmp(key+i, (unsigned char*) "dec") == 0 || stricmp(key+i, (unsigned char*) "decimal") == 0)
						vkey = VK_DECIMAL;
					else if (stricmp(key+i, (unsigned char*) ".") == 0 || stricmp(key+i, (unsigned char*) "dec") == 0 || stricmp(key+i, (unsigned char*) "decimal") == 0)
						vkey = VK_DECIMAL;
					else if (stricmp(key+i, (unsigned char*) "lock") == 0 || key[i] == 0)
						vkey = VK_NUMLOCK;
				}
				else if (key[i] == 'f' || key[i] == 'F') {
					i++;
					if ('0' <= key[i] && key[i] <= '9' && (key[i+1] == 0 || (key[i+2] == 0 && '0' <= key[i+1] && key[i+1] <= '9'))) {
						int w = (int) strtoi64((char*)key+i, 0, 0);
						if (w > 0 && w <=24) {
							// 24 f keys?  There are key codes for them...apparently.
							vkey = VK_F1 + w;
						}
					}
				}
				else if (stricmp(key+i, (unsigned char*) "space") == 0)
					vkey = VK_SPACE;
				else if (stricmp(key+i, (unsigned char*) "esc") == 0 || stricmp(key+i, (unsigned char*) "escape") == 0)
					vkey = VK_ESCAPE;
				else if (stricmp(key+i, (unsigned char*) "pgup") == 0 || stricmp(key+i, (unsigned char*) "pageup") == 0)
					vkey = VK_PRIOR;
				else if (stricmp(key+i, (unsigned char*) "pgdn") == 0 || stricmp(key+i, (unsigned char*) "pagedn") == 0 || stricmp(key+i, (unsigned char*) "pagedown") == 0)
					vkey = VK_NEXT;
				else if (stricmp(key+i, (unsigned char*) "end") == 0)
					vkey = VK_END;
				else if (stricmp(key+i, (unsigned char*) "home") == 0)
					vkey = VK_HOME;
				else if (stricmp(key+i, (unsigned char*) "left") == 0)
					vkey = VK_LEFT;
				else if (stricmp(key+i, (unsigned char*) "right") == 0)
					vkey = VK_RIGHT;
				else if (stricmp(key+i, (unsigned char*) "down") == 0)
					vkey = VK_DOWN;
				else if (stricmp(key+i, (unsigned char*) "up") == 0)
					vkey = VK_UP;
				else if (stricmp(key+i, (unsigned char*) "print") == 0 || stricmp(key+i, (unsigned char*) "printscreen") == 0)
					vkey = VK_SNAPSHOT;
				else if (stricmp(key+i, (unsigned char*) "ins") == 0 || stricmp(key+i, (unsigned char*) "insert") == 0)
					vkey = VK_INSERT;
				else if (stricmp(key+i, (unsigned char*) "del") == 0 || stricmp(key+i, (unsigned char*) "delete") == 0)
					vkey = VK_DELETE;
				else if (stricmp(key+i, (unsigned char*) "help") == 0)
					vkey = VK_HELP;
				else if (stricmp(key+i, (unsigned char*) "pause") == 0)
					vkey = VK_PAUSE;
				else if (stricmp(key+i, (unsigned char*) "caps") == 0 || stricmp(key+i, (unsigned char*) "capslock") == 0)
					vkey = VK_CAPITAL;
				else if (stricmp(key+i, (unsigned char*) "tab") == 0)
					vkey = VK_TAB;
				else if (stricmp(key+i, (unsigned char*) "scroll") == 0 || stricmp(key+i, (unsigned char*) "scrolllock") == 0)
					vkey = VK_SCROLL;
				else if (stricmp(key+i, (unsigned char*) "back") == 0 || stricmp(key+i, (unsigned char*) "backspace") == 0)
					vkey = VK_BACK;
				else if (stricmp(key+i, (unsigned char*) "clear") == 0 || stricmp(key+i, (unsigned char*) "cls") == 0 || stricmp(key+i, (unsigned char*) "clearscreen") == 0)
					vkey = VK_CLEAR;
				else if (stricmp(key+i, (unsigned char*) "enter") == 0 || stricmp(key+i, (unsigned char*) "resturn") == 0)
					vkey = VK_RETURN;
				else if (stricmp(key+i, (unsigned char*) "shift") == 0)
					vkey = VK_SHIFT;
				else if (stricmp(key+i, (unsigned char*) "control") == 0 || stricmp(key+i, (unsigned char*) "ctrl") == 0)
					vkey = VK_MENU;
				if (vkey) {
					if (RegisterHotKey(ghWnd, numShortcuts, modifiers, vkey)) {
						shortcuts[numShortcuts].flags = modifiers;
						shortcuts[numShortcuts].vkey = vkey;
						shortcuts[numShortcuts++].command = command;
						LeftJustify(command);
						continue;
					}
				}
			}
			if (command)
				free(command);
			continue;
		}
		break;
	}
}
Exemplo n.º 2
0
QString MenuCommands::Get(int ind, What w) const
{
    int cur = 0;

    if (cur++ == ind)
        return (w == Key ? FileKey() : (w == Title? FileTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? NewWinKey() : (w == Title? NewWinTitle() : GetStr(NewWinShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OpenFileKey() : (w == Title? OpenFileTitle() : GetStr(OpenFileShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OpenLocKey() : (w == Title? OpenLocTitle() : GetStr(OpenLocShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SaveAsKey() : (w == Title? SaveAsTitle() : GetStr(SaveAsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SavePdfKey() : (w == Title? SavePdfTitle() : GetStr(SavePdfShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ImportKey() : (w == Title? ImportTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? ImportIEKey() : (w == Title? ImportIETitle() : GetStr(ImportIEShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ImportFFKey() : (w == Title? ImportFFTitle() : GetStr(ImportFFShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ImportHtmlKey() : (w == Title? ImportHtmlTitle() : GetStr(ImportHtmlShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ImportXmlKey() : (w == Title? ImportXmlTitle() : GetStr(ImportXmlShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ExportKey() : (w == Title? ExportTitle() : GetStr(ExportShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PrintKey() : (w == Title? PrintTitle() : GetStr(PrintShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PreviewKey() : (w == Title? PreviewTitle() : GetStr(PreviewShortcuts())));

    if (cur++ == ind)
        return (w == Key ? QuitKey() : (w == Title? QuitTitle() : GetStr(QuitShortcuts())));

    if (cur++ == ind)
        return (w == Key ? EditKey() : (w == Title? EditTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? UndoKey() : (w == Title? UndoTitle() : GetStr(UndoShortcuts())));

    if (cur++ == ind)
        return (w == Key ? RedoKey() : (w == Title? RedoTitle() : GetStr(RedoShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CutKey() : (w == Title? CutTitle() : GetStr(CutShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CopyKey() : (w == Title? CopyTitle() : GetStr(CopyShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PasteKey() : (w == Title? PasteTitle() : GetStr(PasteShortcuts())));

    if (cur++ == ind)
        return (w == Key ? FindKey() : (w == Title? FindTitle() : GetStr(FindShortcuts())));

    if (cur++ == ind)
        return (w == Key ? NextKey() : (w == Title? NextTitle() : GetStr(NextShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PrevKey() : (w == Title? PrevTitle() : GetStr(PrevShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PrefsKey() : (w == Title? PrefsTitle() : GetStr(PrefsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ViewKey() : (w == Title? ViewTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? AppStylesKey() : (w == Title? AppStylesTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? StatusKey() : (w == Title? StatusTitle() : GetStr(StatusShortcuts())));

    if (cur++ == ind)
        return (w == Key ? MenuKey() : (w == Title? MenuTitle() : GetStr(MenuShortcuts())));

    if (cur++ == ind)
        return (w == Key ? TabKey() : (w == Title? TabTitle() : GetStr(TabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? NavKey() : (w == Title? NavTitle() : GetStr(NavShortcuts())));

    if (cur++ == ind)
        return (w == Key ? BooksKey() : (w == Title? BooksTitle() : GetStr(BooksShortcuts())));

//  if (cur++ == ind)
//      return (w == Key ? Key() : (w == Title? Title() : GetStr(Shortcuts())));

    if (cur++ == ind)
        return (w == Key ? StopKey() : (w == Title? StopTitle() : GetStr(StopShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ReloadKey() : (w == Title? ReloadTitle() : GetStr(ReloadShortcuts())));

    if (cur++ == ind)
        return (w == Key ? LargerKey() : (w == Title? LargerTitle() : GetStr(LargerShortcuts())));

    if (cur++ == ind)
        return (w == Key ? NormalKey() : (w == Title? NormalTitle() : GetStr(NormalShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SmallerKey() : (w == Title? SmallerTitle() : GetStr(SmallerShortcuts())));

    if (cur++ == ind)
        return (w == Key ? TextOnlyKey() : (w == Title? TextOnlyTitle() : GetStr(TextOnlyShortcuts())));

    if (cur++ == ind)
        return (w == Key ? EncodeKey() : (w == Title? EncodeTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? SourceKey() : (w == Title? SourceTitle() : GetStr(SourceShortcuts())));

    if (cur++ == ind)
        return (w == Key ? FullKey() : (w == Title? FullTitle() : GetStr(FullShortcuts())));

    if (cur++ == ind)
        return (w == Key ? HistoryKey() : (w == Title? HistoryTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? BackKey() : (w == Title? BackTitle() : GetStr(BackShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ForwKey() : (w == Title? ForwTitle() : GetStr(ForwShortcuts())));

    if (cur++ == ind)
        return (w == Key ? HomeKey() : (w == Title? HomeTitle() : GetStr(HomeShortcuts())));

    if (cur++ == ind)
        return (w == Key ? LastTabKey() : (w == Title? LastTabTitle() : GetStr(LastTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? LastTabsKey() : (w == Title? LastTabsTitle() : GetStr(LastTabsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SessionKey() : (w == Title? SessionTitle() : GetStr(SessionShortcuts())));

    if (cur++ == ind)
        return (w == Key ? AllHistKey() : (w == Title? AllHistTitle() : GetStr(AllHistShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ClearKey() : (w == Title? ClearTitle() : GetStr(ClearShortcuts())));

    if (cur++ == ind)
        return (w == Key ? BookmarksKey() : (w == Title? BookmarksTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? AllBooksKey() : (w == Title? AllBooksTitle() : GetStr(AllBooksShortcuts())));

    if (cur++ == ind)
        return (w == Key ? AddBookKey() : (w == Title? AddBookTitle() : GetStr(AddBookShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? PrivacyKey() : (w == Title? PrivacyTitle() : ""));
    
    if (cur++ == ind)
        return (w == Key ? PrivateKey() : (w == Title? PrivateTitle() : GetStr(PrivateShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? JavaScriptKey() : (w == Title? JavaScriptTitle() : GetStr(JavaScriptShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? ImagesKey() : (w == Title? ImagesTitle() : GetStr(ImagesShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? CookiesKey() : (w == Title? CookiesTitle() : GetStr(CookiesShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? PlugInsKey() : (w == Title? PlugInsTitle() : GetStr(PlugInsShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? AgentKey() : (w == Title? AgentTitle() : GetStr(AgentShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? PopUpsKey() : (w == Title? PopUpsTitle() : GetStr(PopUpsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ProxyKey() : (w == Title? ProxyTitle() : GetStr(ProxyShortcuts())));

    if (cur++ == ind)
        return (w == Key ? EmptyKey() : (w == Title? EmptyTitle() : GetStr(EmptyShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ResetKey() : (w == Title? ResetTitle() : GetStr(ResetShortcuts())));

    if (cur++ == ind)
        return (w == Key ? FullResetKey() : (w == Title? FullResetTitle() : GetStr(FullResetShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ToolsKey() : (w == Title? ToolsTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? CompatKey() : (w == Title? CompatTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? SearchKey() : (w == Title? SearchTitle() : GetStr(SearchShortcuts())));

    if (cur++ == ind)
        return (w == Key ? KeyboardKey() : (w == Title? KeyboardTitle() : GetStr(KeyboardShortcuts())));

    if (cur++ == ind)
        return (w == Key ? InspectorKey() : (w == Title? InspectorTitle() : GetStr(InspectorShortcuts())));

    if (cur++ == ind)
        return (w == Key ? InspectKey() : (w == Title? InspectTitle() : GetStr(InspectShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OptionsKey() : (w == Title? OptionsTitle() : GetStr(OptionsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? WindowKey() : (w == Title? WindowTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? NextTabKey() : (w == Title? NextTabTitle() : GetStr(NextTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PrevTabKey() : (w == Title? PrevTabTitle() : GetStr(PrevTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? NewTabKey() : (w == Title? NewTabTitle() : GetStr(NewTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CloseTabKey() : (w == Title? CloseTabTitle() : GetStr(CloseTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CloseOtherKey() : (w == Title? CloseOtherTitle() : GetStr(CloseOtherShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CloneTabKey() : (w == Title? CloneTabTitle() : GetStr(CloneTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ReloadTabKey() : (w == Title? ReloadTabTitle() : GetStr(ReloadTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ReloadAllKey() : (w == Title? ReloadAllTitle() : GetStr(ReloadAllShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OpenNewTabKey() : (w == Title? OpenNewTabTitle() : GetStr(OpenNewTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OpenAdBlockKey() : (w == Title? OpenAdBlockTitle() : GetStr(OpenAdBlockShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SwapFocusKey() : (w == Title? SwapFocusTitle() : GetStr(SwapFocusShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CopyAddrKey() : (w == Title? CopyAddrTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? DownsKey() : (w == Title? DownsTitle() : GetStr(DownsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? TorrentsKey() : (w == Title? TorrentsTitle() : GetStr(TorrentsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? HelpKey() : (w == Title? HelpTitle() : GetStr(HelpShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OnlineKey() : (w == Title? OnlineTitle() : GetStr(OnlineShortcuts())));

    if (cur++ == ind)
        return (w == Key ? UpdatesKey() : (w == Title? UpdatesTitle() : GetStr(UpdatesShortcuts())));

    if (cur++ == ind)
        return (w == Key ? AboutKey() : (w == Title? AboutTitle() : GetStr(AboutShortcuts())));

    return "";
}