⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 input.cpp

📁 ezxterm for motorola rokr e2
💻 CPP
字号:
/*************************************************************************** *   Copyright (C) 2007 by Motorola Commnunity around the World            * *   lahu3672@googlemail.com                                               * *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * *   This program is distributed in the hope that it will be useful,       * *   but WITHOUT ANY WARRANTY; without even the implied warranty of        * *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * *   GNU General Public License for more details.                          * *                                                                         * *   You should have received a copy of the GNU General Public License     * *   along with this program; if not, write to the                         * *   Free Software Foundation, Inc.,                                       * *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * ***************************************************************************/#include "Input.h"Input::Input(): lastKey(-1), timer(this){	QObject::connect(&timer, SIGNAL(timeout()), this, SLOT(slotTimeout()));	kmap[EZX_KEY_1] = "-/.,1";	kmap[EZX_KEY_2] = "abcABC2";	kmap[EZX_KEY_3] = "defDEF3";	kmap[EZX_KEY_4] = "ghiGHI4";	kmap[EZX_KEY_5] = "jklJKL5";	kmap[EZX_KEY_6] = "mnoMNO6";	kmap[EZX_KEY_7] = "pqrsPQRS7";	kmap[EZX_KEY_8] = "tuvTUV8";	kmap[EZX_KEY_9] = "wxyzWXYZ9";	kmap[EZX_KEY_0] = " 0";	kmap[EZX_KEY_STAR] = "\t";	kmap[EZX_KEY_POUND] = "*_";	kmap[EZX_KEY_CENTER_SELECT] = "\n";	kmap[EZX_KEY_CLEAR] = "\x8";	timeout = 1000;	lastKeyProcessed = true;	for (QMap<int, QString>::ConstIterator it = kmap.begin(); it != kmap.end(); ++it)	{		indexes[it.key()] = -1;	}}void Input::processDigitalKey(const int key, const bool suggestion){	int &index = indexes[key];	const QString &cmap = kmap[key];		if (cmap.length() == 1)	{		emit charConfirmed(cmap[0]);		lastKeyProcessed = true;		return;	}	if (!suggestion)	{		emit charConfirmed(cmap[index]);		index = -1;	} else	{		lastKeyProcessed = false;		if (kmap[key].length() - index <= 1) index = 0; else index++;		emit charSuggested(cmap[index]);	}}bool Input::processKey(const int key, const bool suggestion){	bool accepted = true;	switch (key)	{		case EZX_KEY_0:		case EZX_KEY_1:		case EZX_KEY_2:		case EZX_KEY_3:		case EZX_KEY_4:		case EZX_KEY_5:		case EZX_KEY_6:		case EZX_KEY_7:		case EZX_KEY_8:		case EZX_KEY_9:		case EZX_KEY_STAR:		case EZX_KEY_CENTER_SELECT:		case EZX_KEY_CLEAR:			processDigitalKey(key, suggestion);			break;		default:			accepted = false;			break;	}	return accepted;}void Input::processLastKey(){	processKey(lastKey, false);	lastKeyProcessed = true;}bool Input::processEvent(const QKeyEvent *event){	bool suggestion = false;	int key = event->key();	if (timer.isActive())	{		suggestion = key == lastKey;		timer.stop();	}	if (!suggestion && !lastKeyProcessed) processLastKey(); else lastKeyProcessed = false;	lastKey = key;	timer.start(timeout, true);	return processKey(key, true);}void Input::slotTimeout(){	if (!lastKeyProcessed) processLastKey();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -