void VirtualKeyboard::Update() { //TODO font set here imli_script_t script = imli_get_active_script(context_); if (script == SCRIPT_UNSUPPORTED) return; QFont font = styles_[script].font(); //font.setPointSize((script == SCRIPT_ASCII) ? 12 : 14); font.setPointSize(8); const QObjectList& objects = this->verticalLayoutWidget->children(); int index = (shifted_ ? 1 : 0); for (int i = 0; i < objects.size(); i++) { QPushButton* child = dynamic_cast<QPushButton*>(objects.at(i)); if (child) { child->setEnabled(true); QString name = getObjectName(child->objectName()); if (name.length() > 2){ continue; } child->setFont(font); char key = name.toAscii()[index]; if (script != SCRIPT_ASCII) { syl_t syl = SYL_INVALID; int del; syl = imli_process_key(context_, key, SCRIPT_UNSUPPORTED, SYL_INVALID, FLAG_NONE, &del); if (syl != SYL_INVALID) { QByteArray glyphs; glyphs.reserve(32); size_t len = 0; imli_status_t status = syl_to_glyphs(context_, syl, script, (byte_t*)glyphs.data(), glyphs.capacity(), &len); if (status == IMLI_STATUS_OK) { glyphs.resize(len); child->setText(QString::fromAscii(glyphs, glyphs.size())); } else { child->setText(""); } } else { child->setText(""); } } else { QString label(key); if (key == '&') label.append('&'); child->setText(label); } if(child->text().operator ==("")){ child->setDisabled(true); //Disable empty buttons } } } }
QString stringPrepare(const Stringprep_profile *AProfile, const QString &AString) { QByteArray buffer = AString.toUtf8(); if (!buffer.isEmpty() && buffer.size()<1024) { buffer.reserve(1024); if (stringprep(buffer.data(),buffer.capacity(),(Stringprep_profile_flags)0, AProfile) == STRINGPREP_OK) return QString::fromUtf8(buffer.constData()); } return QString::null; }
void tst_QByteArray::constByteArray() { const char *ptr = "abc"; QByteArray cba = QByteArray::fromRawData(ptr, 3); QVERIFY(cba.constData() == ptr); cba.squeeze(); QVERIFY(cba.constData() == ptr); cba.detach(); QVERIFY(cba.size() == 3); QVERIFY(cba.capacity() == 3); QVERIFY(cba.constData() != ptr); QVERIFY(cba.constData()[0] == 'a'); QVERIFY(cba.constData()[1] == 'b'); QVERIFY(cba.constData()[2] == 'c'); QVERIFY(cba.constData()[3] == '\0'); }
void Tracer::run() { QFile tracefile(QCoreApplication::applicationDirPath() + "/trace.bin"); tracefile.open(QFile::WriteOnly); while(!mStop) { sleep(2); mMutex.lock(); QByteArray* trace = mCurrentTrace; mCurrentTraceId = (mCurrentTraceId+1) % 2; mCurrentTrace = &mTraces[mCurrentTraceId]; mMutex.unlock(); tracefile.write(*trace); tracefile.flush(); int size = trace->capacity(); trace->resize(0); trace->reserve(size); } }
void ListItem::SylsToGlyphs() { QByteArray glyphs; imli_script_t script = imli_get_active_script(ctx_); glyphs.reserve(str_.size()*8); size_t len = 0; imli_status_t status = syls_to_glyphs(ctx_, str_.data(), str_.length(), script, (byte_t*)glyphs.data(), glyphs.capacity(), &len); if (status == IMLI_STATUS_OK) { glyphs.resize(len); setText(QString::fromAscii(glyphs, glyphs.size())); } }