void FloatyWnd::leaveEvent(QEvent *e)
{
    hideTip();
    QWidget::leaveEvent(e);
}
TooltipWindow::~TooltipWindow()
{
    hideTip();
}
void TooltipWindow::mouseEnter (const MouseEvent&)
{
    hideTip();
}
Beispiel #4
0
void CCharTip::showTip()
{
    if(!itsParent->underMouse())
        return;

    EUnicodeCategory cat(getCategory(itsItem.ucs4));
    QString          details("<table>");

    details+="<tr><td><b>"+i18n("Category")+"</b></td><td>"+
             toStr(cat)+"</td></tr>";
    details+="<tr><td><b>"+i18n("UCS-4")+"</b></td><td>"+
             QString().sprintf("U+%4.4X", itsItem.ucs4)+"</td></tr>";

    QString str(QString::fromUcs4(&(itsItem.ucs4), 1));
    details+="<tr><td><b>"+i18n("UTF-16")+"</b></td><td>";

    const ushort *utf16(str.utf16());

    for(int i=0; utf16[i]; ++i)
    {
        if(i)
            details+=' ';
        details+=QString().sprintf("0x%4.4X",  utf16[i]);
    }
    details+="</td></tr>";
    details+="<tr><td><b>"+i18n("UTF-8")+"</b></td><td>";

    QByteArray utf8(str.toUtf8());

    for(int i=0; i<utf8.size(); ++i)
    {
        if(i)
            details+=' ';
        details+=QString().sprintf("0x%2.2X", (unsigned char)(utf8.constData()[i]));
    }
    details+="</td></tr>";

    // Note: the "<b></b> below is just to stop Qt converting the xml entry into
    // a character!
    if ((0x0001 <= itsItem.ucs4 && itsItem.ucs4 <= 0xD7FF) ||
        (0xE000 <= itsItem.ucs4 && itsItem.ucs4 <= 0xFFFD) ||
        (0x10000 <= itsItem.ucs4 && itsItem.ucs4 <= 0x10FFFF))
        details+="<tr><td><b>"+i18n("XML Decimal Entity")+"</b></td><td>"+
                 QString().sprintf("&#<b></b>%d;", itsItem.ucs4)+"</td></tr>";

    details+="</table>";
    itsLabel->setText(details);

    QPixmap pix((int)(itsItem.width()*2.5), (int)(itsItem.height()*2.5));
    QList<CFcEngine::TRange> range;
    range.append(CFcEngine::TRange(itsItem.ucs4, 0));

    QColor prevBgndCol(CFcEngine::bgndCol());

    CFcEngine::setBgndCol(palette().color(QPalette::Active, QPalette::Background));
    if(CFcEngine::instance()->draw(itsParent->itsCurrentUrl, pix.width(), pix.height(), pix,
                                   itsParent->itsCurrentFace-1, false, range,
                                   NULL, itsParent->itsFontName, itsParent->itsStyleInfo))
        itsPixmapLabel->setPixmap(pix);
    else
        itsPixmapLabel->setPixmap(QPixmap());
    CFcEngine::setBgndCol(prevBgndCol);
    itsTimer->disconnect(this);
    connect(itsTimer, SIGNAL(timeout()), this, SLOT(hideTip()));
    itsTimer->setSingleShot(true);
    itsTimer->start(15000);

    kapp->installEventFilter(this);
    reposition();
    show();
}
Beispiel #5
0
void PsiTipLabel::enterEvent(QEvent*)
{
    hideTip();
}
Beispiel #6
0
void ExprShortTextEdit::keyPressEvent(QKeyEvent* e) {

    // If the completer is active pass keys it needs down
    if (completer && completer->popup()->isVisible()) {
        switch (e->key()) {
            case Qt::Key_Enter:
            case Qt::Key_Return:
            case Qt::Key_Escape:
            case Qt::Key_Tab:
            case Qt::Key_Backtab:
                e->ignore();
                return;
            default:
                break;
        }
    }

    // Accept expression
    if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
        selectAll();
        finishEdit();
        return;
    } else if (e->key() == Qt::Key_Escape) {
        setText(savedText);
        selectAll();
        finishEdit();
        return;
    } else if (e->key() == Qt::Key_Tab) {
        QWidget::keyPressEvent(e);
        return;
    } else if (!editing) {
        editing = true;
        setColor(true);
        savedText = toPlainText();
    }

    // use the values here as long as we are not using the shortcut to bring up the editor
    bool isShortcut = ((e->modifiers() & Qt::ControlModifier) && e->key() == Qt::Key_E);  // CTRL+E
    if (!isShortcut)  // dont process the shortcut when we have a completer
        QTextEdit::keyPressEvent(e);

    const bool ctrlOrShift = e->modifiers() & (Qt::ControlModifier | Qt::ShiftModifier);
    if (!completer || (ctrlOrShift && e->text().isEmpty())) return;

    bool hasModifier = (e->modifiers() != Qt::NoModifier) && !ctrlOrShift;

    // grab the line we're on
    QTextCursor tc = textCursor();
    tc.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
    QString line = tc.selectedText();

    // matches the last prefix of a completable variable or function and extract as completionPrefix
    static QRegExp completion("^(?:.*[^A-Za-z0-9_$])?((?:\\$[A-Za-z0-9_]*)|[A-Za-z]+[A-Za-z0-9_]*)$");
    int index = completion.indexIn(line);
    QString completionPrefix;
    if (index != -1 && !line.contains('#')) {
        completionPrefix = completion.cap(1);
        // std::cout<<"we have completer prefix '"<<completionPrefix.toStdString()<<"'"<<std::endl;
    }

    // hide the completer if we have too few characters, we are at end of word
    if (!isShortcut && (hasModifier || e->text().isEmpty() || completionPrefix.length() < 1 || index == -1)) {
        completer->popup()->hide();
    } else {

        // copy the completion prefix in if we don't already have it in the completer
        if (completionPrefix != completer->completionPrefix()) {
            completer->setCompletionPrefix(completionPrefix);
            completer->popup()->setCurrentIndex(completer->completionModel()->index(0, 0));
        }

        // display the completer
        QRect cr = cursorRect();
        cr.setWidth(2 * (completer->popup()->sizeHintForColumn(0) + completer->popup()->sizeHintForColumn(1) +
                         completer->popup()->verticalScrollBar()->sizeHint().width()));
        completer->complete(cr);
        hideTip();
        return;
    }

    // documentation completion
    static QRegExp inFunction("^(?:.*[^A-Za-z0-9_$])?([A-Za-z0-9_]+)\\([^()]*$");
    int index2 = inFunction.indexIn(line);
    if (index2 != -1) {
        QString functionName = inFunction.cap(1);
        QStringList tips = completionModel->getDocString(functionName).split("\n");
        QString tip = "<b>" + tips[0] + "</b>";
        for (int i = 1; i < tips.size(); i++) {
            tip += "<br>" + tips[i];
        }
        showTip(tip);
    } else {
        hideTip();
    }
}
Beispiel #7
0
void ExprShortTextEdit::mouseDoubleClickEvent(QMouseEvent* event) {
    hideTip();
    QTextEdit::mouseDoubleClickEvent(event);
}
Beispiel #8
0
void ExprShortTextEdit::mousePressEvent(QMouseEvent* event) {
    hideTip();
    QTextEdit::mousePressEvent(event);
}
	void enterEvent(QEvent*){ hideTip(); }
Beispiel #10
0
void ExprTextEdit::focusOutEvent(QFocusEvent* e)
{
    hideTip();
    QTextEdit::focusInEvent(e);
}