Esempio n. 1
0
void Autocorrect::finishedWord(QTextDocument *document, int cursorPosition)
{
    if (!m_enabled->isChecked()) return;

    m_cursor = QTextCursor(document);
    selectWord(m_cursor, cursorPosition);
    m_word = m_cursor.selectedText();
    if (m_word.isEmpty()) return;

    emit startMacro(i18n("Autocorrection"));

    bool done = autoFormatURLs();
    if (!done) done = singleSpaces();
    if (!done) done = autoBoldUnderline();
    if (!done) done = autoFractions();
    if (!done) advancedAutocorrect();
    if (!done) uppercaseFirstCharOfSentence();
    if (!done) fixTwoUppercaseChars();
    if (!done) autoNumbering();
    if (!done) superscriptAppendix();
    if (!done) capitalizeWeekDays();
    if (!done) autoFormatBulletList();
    if (!done) replaceTypographicQuotes();

    if (m_cursor.selectedText() != m_word)
        m_cursor.insertText(m_word);

    emit stopMacro();
}
Esempio n. 2
0
void FontDia::slotApply()
{
    emit startMacro(i18n("Font"));
    KoCharacterStyle chosenStyle;
    m_characterGeneral->save(&chosenStyle);
    chosenStyle.applyStyle(m_cursor);
    emit stopMacro();
}
Esempio n. 3
0
void Thesaurus::process()
{
    QString replacement = m_replaceLineEdit->text().trimmed();
    if (replacement == m_word.trimmed()) return;

    emit startMacro(i18n("Replace Word"));
    QTextCursor cursor(m_document);
    cursor.setPosition(m_startPosition);
    cursor.setPosition(m_startPosition + m_word.trimmed().length(), QTextCursor::KeepAnchor);
    cursor.insertText(replacement);
    emit stopMacro();
}
Esempio n. 4
0
void Changecase::process()
{
    emit startMacro(i18n("Change case"));

    if (m_sentenceCaseRadio->isChecked())
        sentenceCase();
    else if (m_lowerCaseRadio->isChecked())
        lowerCase();
    else if (m_upperCaseRadio->isChecked())
        upperCase();
    else if (m_initialCapsRadio->isChecked())
        initialCaps();
    else if (m_toggleCaseRadio->isChecked())
        toggleCase();

    emit stopMacro();
}
Esempio n. 5
0
void ParagraphSettingsDialog::slotApply()
{
    emit startMacro(i18n("Paragraph Settings\n"));
    KoParagraphStyle chosenStyle;
    m_paragraphGeneral->save(&chosenStyle);
    QTextBlockFormat format;
    chosenStyle.applyStyle(format);
    m_cursor->mergeBlockFormat(format);
    if (chosenStyle.listStyle()) {
        ChangeListCommand *cmd = new ChangeListCommand(*m_cursor, chosenStyle.listStyle(), 0, ChangeListCommand::MergeWithAdjacentList);
        m_tool->addCommand(cmd);
    } else {
        QTextList *list = m_cursor->block().textList();
        if (list) { // then remove it.
            list->remove(m_cursor->block());
        }
    }
    emit stopMacro();
}
Esempio n. 6
0
Input GetNextInput(Input input)
{
    unsigned char leftSlider = input.LeftButt;
    unsigned char rightSlider = input.RightButt;
    unsigned char xJoy = input.JoyX;
    unsigned char yJoy = input.JoyY;
    unsigned char macrobutton;
    Input output = {0};

    // If in echo mode
    if (!Mode)
    {
        // Check which button is the macro button
        if (macroButton)
        {
            macrobutton = input.Y;
        }
        else
        {
            macrobutton = input.X;
        }

        // If the macro button is pressed
        if (macrobutton)
        {
            // Find the first valid macro and return the first frame of it.
            if (input.R) {
                return startMacro(ActiveScheme->RightTrigger, &input);
            }
            if (input.L) {
                return startMacro(ActiveScheme->LeftTrigger, &input);
            }
            if (input.JoyX > 150) {
                return startMacro(ActiveScheme->RightArrow, &input);
            }
            if (input.JoyY < 96) {
                return startMacro(ActiveScheme->DownArrow, &input);
            }
            if (input.JoyY > 150) {
                return startMacro(ActiveScheme->UpArrow, &input);
            }
            if (input.JoyX < 96) {
                return startMacro(ActiveScheme->LeftArrow, &input);
            }
            if (input.Z) {
                return startMacro(ActiveScheme->ZButton, &input);
            }

            leftSlider = 0;
            rightSlider = 0;
            xJoy = 128;
            yJoy = 128;
        }

        // If a D-Pad button is pressed, switch the scheme
        if (input.DUp) {
            ActiveScheme = &Scheme1;
        }
        else if (input.DDown) {
            macroButton = !macroButton; // SCHEME 3 IS CURRENTLY NOT USED. MACRO BUTTON SWITCH IS!!
            // ActiveScheme = &Scheme3;
        }
        else if (input.DRight) {
            ActiveScheme = &Scheme2;
        }
        else if (input.DLeft) {
            ActiveScheme = &Scheme4;
        }

        // Return current state of inputs from the controller masking the D-Pad and the MacroButton
        reorganizeInput(&input, &output, leftSlider, rightSlider, xJoy, yJoy);
        return output;
    }

    // If in macro mode
    else
    {
        // Get frame of Macro
        // If last frame enter echo mode
        if (GetMacroInput(CurrentFrame, &output, &input)) {
            Mode = 0;
        }

        // Increment the frame
        CurrentFrame.Frame++;

        return output;
    }
}