Пример #1
0
void editReminderAction(char c)
{
	if(c == 0) return;
	
	setPressedChar(c);
	
	if(c == CLEAR_KEY)
	{
		memset(reminder, 0, REM_SIZE);
		resetKBCursor();
		return;
	}
	if(c == CAP)
	{
		toggleCaps();
		return;
	}
	
	char *tmpBuffer = (char *)trackMalloc(REM_SIZE,"reminder kbd");
	memcpy(tmpBuffer,reminder,REM_SIZE);
	int oldCursor = getKBCursor();
	
	genericAction(tmpBuffer, REM_SIZE - 1, c);
	
	int *pts = NULL;
	int numPts = getWrapPoints(0, -3, tmpBuffer, 3, 41, 252, 190, &pts, font_arial_9);
	free(pts);
	
	if(numPts <= MAX_LINES_REMINDER)
		memcpy(reminder,tmpBuffer,REM_SIZE);
	else
		moveKBCursorAbsolute(oldCursor);
	
	trackFree(tmpBuffer);
}
Пример #2
0
char executeClick(int px, int py)
{
	if(py >= DEFAULT_TOP)
	{
		if(py <= DEFAULT_BOTTOM)
		{
			if(px >= INS_LEFT && px <= INS_RIGHT)
			{
				toggleIns();
			}

			if(px >= CTRL_LEFT && px <= CTRL_RIGHT)
			{
				toggleControl();
			}

			if(px >= SELECT_LEFT && px <= SELECT_RIGHT)
			{
				toggleSelect();
			}

			if(px >= CLEAR_LEFT && px <= CLEAR_RIGHT)
			{
				return CLEAR_KEY;
			}
		}

		return 0;
	}

	if(activeKeyboard() == KB_MESSAGEASE)
	{
		downX = px;
		downY = py;
		upX = px;
		upY = py;

		px -= 32;
		py -= 37;

		if(px >= 1 && py >= 1 && px <= 31 && py <= 31) // caps
		{
			toggleCaps();
			downX = 0;
			downY = 0;
		}

		if(px >= 1 && py >= 33 && px <= 31 && py <= 62) // shift
		{
			toggleShift();
			downX = 0;
			downY = 0;
		}

		if(px >= 1 && py >= 64 && px <= 31 && py <= 94) // special
		{
			toggleSpecial();
			downX = 0;
			downY = 0;
		}

		if(px >= 160 && py >= 1 && px <= 190 && py <= 31) // backspace
		{
			return translateCode(K_B, SYMBOLS);
		}

		if(px >= 160 && py >= 33 && px <= 190 && py <= 62) // return
		{
			return translateCode(K_R, SYMBOLS);
		}

		if(px >= 129 && py >= 1 && px <= 158 && py <= 31) // delete
		{
			return translateCode(K_D, SYMBOLS);
		}

		if(px >= 129 && py >= 33 && px <= 158 && py <= 62) // space
		{
			shift = 0;
			return translateCode(K_W, SYMBOLS);
		}

		if(px >= 129 && py >= 64 && px <= 158 && py <= 94) // number toggle
		{
			isNumbers = 1 - isNumbers;
			downX = 0;
			downY = 0;
		}

		curChar = 0;
		return 0;
	}

	py -= 37;

	if(py < 0)
		return 0;

	int tilex = 0;
	int tiley = py / 19;

	if(tiley < 0 || tiley > 4)
		return 0;

	switch(tiley)
	{
		case 0: // first row
			if(px < 13)
				return 0;
			px -= 13;
			tilex = px / 19;
			break;
		case 1: // second row
			if(px < 23)
				return 0;
			if(px >= 213 && px <= 242) // backspace
				return translateCode(K_B, SYMBOLS);

			px -= 23;
			tilex = px / 19;
			break;
		case 2: // third row
			if(px < 13)
				return 0;
			if(px >= 203 && px <= 242) // return
				return translateCode(K_R, SYMBOLS);

			px -= 13;
			tilex = px / 19;
			break;
		case 3: // fourth row
			if(px < 13)
				return 0;
			if(px < 42) // shift
			{
				toggleShift();
				curChar = 0;
				return 0;
			}

			px -= 42;
			tilex = px / 19;
			break;
		case 4: // fifth row
			if(px < 13)
				return 0;
			if(px >= 89 && px < 184) // space
				return translateCode(K_W, SYMBOLS);

			px -= 13;
			tilex = px / 19;
			break;
	}

	if(tilex < 0 || tilex > 11)
		return 0;

	char c = 0; // capture character.

	if(tiley == 0) // this is the numbers
	{
		if(shift == 1)
			c = translateCode(keyboard_Hit[tilex], SYMBOLS);
		else
			c = translateCode(keyboard_Hit[tilex], NUMBERS);
	}
	else // this is letters
	{
		if((caps == 0 && shift == 0) || (caps == 1 && shift == 1))
		{
			if(special == 0)
				c = translateCode(keyboard_Hit[tilex+(tiley*12)],LOWERCASE);
			else
				c = translateCode(keyboard_Hit[tilex+(tiley*12)],SPECIAL0);
		}
		else
		{
			if(special == 0)
				c = translateCode(keyboard_Hit[tilex+(tiley*12)],UPPERCASE);
			else
				c = translateCode(keyboard_Hit[tilex+(tiley*12)],SPECIAL1);
		}
	}

	if(c==DEL) // Return
	{
		// to ensure we dont lowercase on a delete
	}
	else if(c == CAP)
	{
		toggleCaps();
		curChar = 0;
		c = 0;
	}
	else if(c == SPL)
	{
		toggleSpecial();
		curChar = 0;
		c = 0;
	}
	else
	{
		shift = 0;
	}

	return c;
}
Пример #3
0
EtaKeyboard::EtaKeyboard(QWidget *parent)
    : QMainWindow(parent)
{
    setWindowFlags(Qt::WindowStaysOnTopHint |
                   Qt::FramelessWindowHint |
                   Qt::WindowSystemMenuHint |
                   Qt::WindowDoesNotAcceptFocus |
                   Qt::X11BypassWindowManagerHint);

    QDesktopWidget dw;
    screenWidth = dw.screenGeometry(dw.primaryScreen()).width();
    screenHeight = dw.screenGeometry(dw.primaryScreen()).height();

    key_height = screenHeight / 16;
    key_width = screenWidth / 26;
    dock_height = screenHeight / 30;
    m_width = 13*key_width;
    m_height = key_height*4+dock_height;

    configpath = QDir::homePath() + "/.config/etak/config.ini";
    color = "gray";
    Settings::setLanguage("trq");
    Settings::setAutoShowBool(true);

    QFileInfo checkConfig(configpath);

    if (checkConfig.exists() && checkConfig.isFile()) {
        preferences = new QSettings(configpath,QSettings::IniFormat);
        preferences->beginGroup("etak");
        Settings::setLanguage(preferences->value("Language").toString());
        color= preferences->value("Color").toString();
        Settings::setAutoShowBool(preferences->value("AutoShow").toBool());
        preferences->endGroup();
    }

    Settings::setColors(color); // 'blue' or 'gray'
    Helpers::langChange(Settings::getLanguage()); // intialization of X keyboard layout as trq



    setStyleSheet("background-color: "+Settings::getBackgroundColor()+";");

    setGeometry(screenWidth/2+m_width,0,m_width,0);



    out = LabelInstance::Instance();  // Output text right up to keyboard
    out->setParent(this);
    out->setGeometry(0,0,m_width,dock_height);
    out->setStyleSheet("QLabel{color: white; qproperty-alignment: AlignCenter;}");
    QFont f;
    f.setPointSize(key_height / 5);
    out->setFont(f);


    settingsRectangle = new QDialog(this,Qt::X11BypassWindowManagerHint);
    settingsRectangle->setStyleSheet("background-color: "+Settings::getBackgroundColor()+";");
    settingsRectangle->hide();

    toggleAuto = new QPushButton(settingsRectangle);
    toggleAuto->setGeometry(0,0,key_width*2,dock_height);
    toggleAuto->setCheckable(true);
    toggleAuto->setChecked(Settings::getAutoShowBool());
    if(Settings::getAutoShowBool()) {
        toggleAuto->setText(QString::fromUtf8("Otomatik çıkma : Kapat"));
    } else {
        toggleAuto->setText(QString::fromUtf8("Otomatik çıkma : Aç"));
    }
    toggleAuto->setStyleSheet(Settings::getStyleSheet()+Settings::getStyleSheetExtra());
    QFont g;
    g.setPointSize(key_height / 9);
    toggleAuto->setFont(g);

    connect(toggleAuto,SIGNAL(clicked()),this,SLOT(toggleAutoShow()));

    passwordButton = new QPushButton(this);
    passwordButton->setGeometry(1,1,dock_height,dock_height);
    passwordButton->setStyleSheet(Settings::getStyleSheet()+Settings::getStyleSheetExtra());
    passwordButton->setCheckable(true);
    passwordButton->setChecked(false);
    passwordButton->setText("P");
    g.setBold(true);
    g.setPointSize(key_height/4);
    passwordButton->setFont(g);
    QRegion *region = new QRegion(*(new QRect(passwordButton->x()+2,passwordButton->y()+2,dock_height-6,dock_height-6)),QRegion::Ellipse);
    passwordButton->setMask(*region);
    connect(passwordButton,SIGNAL(clicked()),this,SLOT(togglePassword()));


    QHash<int, QList<unsigned int> > hash;
    QList<unsigned int> listtmp;
    for ( int i = 24 ; i < 36 ; ++i) {
        listtmp.append(i);
    }
    hash.insert(1,listtmp);
    listtmp.clear();
    for ( int j = 38 ; j < 49 ; ++j) {
        listtmp.append(j);
    }
    hash.insert(2,listtmp);
    listtmp.clear();
    for ( int k = 52 ; k < 61 ; ++k) {
        listtmp.append(k);
    }
    hash.insert(3,listtmp);
    listtmp.clear();
    Key *tmp;
    int posrow = key_width;
    int posy = dock_height;
    int posx;

    AlphaKey *tmp2;

    QString tmpLanguageLayout ="";
    if (Settings::getLanguage() == "trq") {
        tmpLanguageLayout = "TRQ";
    } else if (Settings::getLanguage() == "trf") {
        tmpLanguageLayout = "TRF";
    } else if (Settings::getLanguage() == "arabic") {
        tmpLanguageLayout = QString::fromUtf8("العربئة");
    }

    lang = new SpecialKey(settingsRectangle,0,dock_height,key_width,key_height,tmpLanguageLayout);
    connect(lang,SIGNAL(clicked()),this,SLOT(changeLanguage()));

    tmp2 = new AlphaKey(this,0,dock_height,key_width,key_height,9,"Esc"); //Escape
    alpha_keys.append(tmp2);

    change = new SpecialKey(this,0,key_height+dock_height,key_width*3/2,key_height,"?123+");
    connect(change,SIGNAL(clicked()),this,SLOT(toggleAlterns()));
    leftshift = new AlphaKey(this,0,key_height*2+dock_height,key_width*2,key_height,50,QString::fromUtf8("↑")); //caps
    alpha_keys.append(leftshift);
    connect(leftshift,SIGNAL(clicked()),this,SLOT(toggleCaps()));
    for (int y = 1 ; y<=3 ; ++y) {
        posx=posrow;
        for (int x =0; x < hash[y].length(); ++x) {
            if (y==2 && x==10) {
                tmp = new Key(this,posx,posy,key_width*3/2,key_height,hash[y].at(x));
            } else {
                tmp = new Key(this,posx,posy,key_width,key_height,hash[y].at(x));
            }
            keys.append(tmp);
            posx += key_width;
        }
        posy += key_height;
        posrow += key_width / 2;
    }
    tmp2 = new AlphaKey(this, posx, posy - key_height, key_width * 2, key_height, 22, QString::fromUtf8("⌫")); //backspace
    alpha_keys.append(tmp2);

    settingsButton = new QPushButton(this);
    settingsButton->setGeometry(0,posy,key_width,key_height);
    settingsButton->setStyleSheet(Settings::getStyleSheet());

    QPixmap pm(":/icons/gear.png");
    settingsButton->setIcon(QIcon(pm));
    settingsButton->setIconSize(QSize(settingsButton->width()*2/3,settingsButton->height()*2/3));

    connect(settingsButton,SIGNAL(clicked()),this,SLOT(toggleSettings()));

    hideButton = new QPushButton(this);
    hideButton->setGeometry(m_width-dock_height-1,1,dock_height,dock_height);
    QPixmap pm2(":/icons/window-close.png");
    hideButton->setIcon(QIcon(pm2));
    hideButton->setIconSize(QSize(hideButton->width(),hideButton->height()));

    connect(hideButton,SIGNAL(clicked()),this,SLOT(animationToggle()));

    colorButton = new QPushButton(settingsRectangle);
    colorButton->setGeometry(key_width,dock_height,key_width,key_height);
    colorButton->setStyleSheet(Settings::getStyleSheet());

    connect(colorButton,SIGNAL(clicked()),this,SLOT(toggleColor()));

    tmp = new Key(this,key_width,posy,key_width,key_height,20); //asterix
    bottom_keys.append(tmp);
    tmp = new Key(this,key_width*2,posy,key_width*13/2,key_height,65); // space
    bottom_keys.append(tmp);
    tmp = new Key(this,key_width*17/2,posy,key_width,key_height,51); // comma
    bottom_keys.append(tmp);
    tmp = new Key(this,key_width*19/2,posy,key_width,key_height,61); // dot
    bottom_keys.append(tmp);

    tmp2 = new AlphaKey(this,key_width*21/2,posy,key_width*5/2,key_height,36,QString::fromUtf8("↵")); // enter
    alpha_keys.append(tmp2);

    server = new EtaLocalServer(this);
    Q_CHECK_PTR(server);
    const QString fullServerName =  QString(QDir::homePath()+"/"+SERVER_NAME);

    QFile file(fullServerName);
    if (file.exists()) {
         file.remove();
    }
    if (server->listen(QDir::homePath()+"/"+SERVER_NAME)) {
        //qDebug() << "Listenning";
    } else {
        //qDebug() << "Failed to listen";
    }
    connect(server, SIGNAL(newCommand(char*)), this, SLOT(onNewCommand(char*)));
    anime = new QPropertyAnimation(this, "geometry");
    tog =  false;
    QList<QString> alternatives;

    alternatives.append("1");
    alternatives.append("2");
    alternatives.append("3");
    alternatives.append("4");
    alternatives.append("5");
    alternatives.append("6");
    alternatives.append("7");
    alternatives.append("8");
    alternatives.append("9");
    alternatives.append("0");
    alternatives.append("braceleft");
    alternatives.append("braceright");

    alternatives.append("at");
    alternatives.append("numbersign");
    alternatives.append("dollar");
    alternatives.append("percent");
    alternatives.append("ampersand");
    alternatives.append("parenleft");
    alternatives.append("parenright");
    alternatives.append("minus");
    alternatives.append("less");
    alternatives.append("greater");
    alternatives.append("exclam");

    alternatives.append("semicolon");
    alternatives.append("colon");
    alternatives.append("apostrophe");
    alternatives.append("quotedbl");
    alternatives.append("question");
    alternatives.append("slash");
    alternatives.append("plus");
    alternatives.append("equal");
    alternatives.append("underscore");

     for (int cnt = 0; cnt < keys.size(); ++cnt) {
         keys.at(cnt)->setAlternString(alternatives.at(cnt));
     }
}