MultiLineEdit::MultiLineEdit(QWidget *parent)
    : MultiLineEditParent(parent),
    _idx(0),
    _mode(SingleLine),
    _singleLine(true),
    _minHeight(1),
    _maxHeight(5),
    _scrollBarsEnabled(true),
    _pasteProtectionEnabled(true),
    _emacsMode(false),
    _completionSpace(0),
    _lastDocumentHeight(-1)
{
    document()->setDocumentMargin(0);

    setAcceptRichText(false);
#ifdef HAVE_KDE
    enableFindReplace(false);
#endif

#ifdef HAVE_SONNET
    new Sonnet::SpellCheckDecorator(this);
#endif

    setMode(SingleLine);
    setLineWrapEnabled(false);
    reset();

    // Prevent QTextHtmlImporter::appendNodeText from eating whitespace
    document()->setDefaultStyleSheet("span { white-space: pre-wrap; }");

    connect(this, SIGNAL(textChanged()), this, SLOT(on_textChanged()));

    _mircColorMap["00"] = "#ffffff";
    _mircColorMap["01"] = "#000000";
    _mircColorMap["02"] = "#000080";
    _mircColorMap["03"] = "#008000";
    _mircColorMap["04"] = "#ff0000";
    _mircColorMap["05"] = "#800000";
    _mircColorMap["06"] = "#800080";
    _mircColorMap["07"] = "#ffa500";
    _mircColorMap["08"] = "#ffff00";
    _mircColorMap["09"] = "#00ff00";
    _mircColorMap["10"] = "#008080";
    _mircColorMap["11"] = "#00ffff";
    _mircColorMap["12"] = "#4169e1";
    _mircColorMap["13"] = "#ff00ff";
    _mircColorMap["14"] = "#808080";
    _mircColorMap["15"] = "#c0c0c0";
}
Beispiel #2
0
MultiLineEdit::MultiLineEdit(QWidget *parent)
    : MultiLineEditParent(parent),
    _idx(0),
    _mode(SingleLine),
    _singleLine(true),
    _minHeight(1),
    _maxHeight(5),
    _scrollBarsEnabled(true),
    _pasteProtectionEnabled(true),
    _emacsMode(false),
    _lastDocumentHeight(-1)
{
#if QT_VERSION >= 0x040500
    document()->setDocumentMargin(0); // new in Qt 4.5 and we really don't want it here
#endif

    setAcceptRichText(false);
#ifdef HAVE_KDE
    enableFindReplace(false);
#endif

    setMode(SingleLine);
    setLineWrapEnabled(false);
    reset();

    connect(this, SIGNAL(textChanged()), this, SLOT(on_textChanged()));

    _mircColorMap["00"] = "#ffffff";
    _mircColorMap["01"] = "#000000";
    _mircColorMap["02"] = "#000080";
    _mircColorMap["03"] = "#008000";
    _mircColorMap["04"] = "#ff0000";
    _mircColorMap["05"] = "#800000";
    _mircColorMap["06"] = "#800080";
    _mircColorMap["07"] = "#ffa500";
    _mircColorMap["08"] = "#ffff00";
    _mircColorMap["09"] = "#00ff00";
    _mircColorMap["10"] = "#008080";
    _mircColorMap["11"] = "#00ffff";
    _mircColorMap["12"] = "#4169e1";
    _mircColorMap["13"] = "#ff00ff";
    _mircColorMap["14"] = "#808080";
    _mircColorMap["15"] = "#c0c0c0";
}
Beispiel #3
0
MultiLineEdit::MultiLineEdit(QWidget* parent)
    : MultiLineEditParent(parent)
{
    document()->setDocumentMargin(0);

    setAcceptRichText(false);
#ifdef HAVE_KDE
    enableFindReplace(false);
#endif

#if defined HAVE_SONNET && !defined HAVE_KDE
    _spellCheckDecorator = new Sonnet::SpellCheckDecorator(this);
    highlighter()->setActive(highlighter()->checkerEnabledByDefault());
#endif

    setMode(SingleLine);
    setLineWrapEnabled(false);
    reset();

    // Prevent QTextHtmlImporter::appendNodeText from eating whitespace
    document()->setDefaultStyleSheet("span { white-space: pre-wrap; }");

    connect(this, &QTextEdit::textChanged, this, &MultiLineEdit::on_textChanged);

    _mircColorMap["00"] = "#ffffff";
    _mircColorMap["01"] = "#000000";
    _mircColorMap["02"] = "#000080";
    _mircColorMap["03"] = "#008000";
    _mircColorMap["04"] = "#ff0000";
    _mircColorMap["05"] = "#800000";
    _mircColorMap["06"] = "#800080";
    _mircColorMap["07"] = "#ffa500";
    _mircColorMap["08"] = "#ffff00";
    _mircColorMap["09"] = "#00ff00";
    _mircColorMap["10"] = "#008080";
    _mircColorMap["11"] = "#00ffff";
    _mircColorMap["12"] = "#4169e1";
    _mircColorMap["13"] = "#ff00ff";
    _mircColorMap["14"] = "#808080";
    _mircColorMap["15"] = "#c0c0c0";
}
Beispiel #4
0
InputWidget::InputWidget(QWidget *parent)
    : AbstractItemView(parent),
    _networkId(0)
{
    ui.setupUi(this);
    connect(ui.ownNick, SIGNAL(activated(QString)), this, SLOT(changeNick(QString)));

    layout()->setAlignment(ui.ownNick, Qt::AlignBottom);
    layout()->setAlignment(ui.inputEdit, Qt::AlignBottom);
    layout()->setAlignment(ui.showStyleButton, Qt::AlignBottom);
    layout()->setAlignment(ui.styleFrame, Qt::AlignBottom);

    ui.styleFrame->setVisible(false);

    setFocusProxy(ui.inputEdit);
    ui.ownNick->setFocusProxy(ui.inputEdit);

    ui.ownNick->setSizeAdjustPolicy(QComboBox::AdjustToContents);
    ui.ownNick->installEventFilter(new MouseWheelFilter(this));
    ui.inputEdit->installEventFilter(this);

    ui.inputEdit->setMinHeight(1);
    ui.inputEdit->setMaxHeight(5);
    ui.inputEdit->setMode(MultiLineEdit::MultiLine);
    ui.inputEdit->setPasteProtectionEnabled(true);

    ui.boldButton->setIcon(SmallIcon("format-text-bold"));
    ui.italicButton->setIcon(SmallIcon("format-text-italic"));
    ui.underlineButton->setIcon(SmallIcon("format-text-underline"));
    ui.textcolorButton->setIcon(SmallIcon("format-text-color"));
    ui.highlightcolorButton->setIcon(SmallIcon("format-fill-color"));
    ui.encryptionIconLabel->hide();

    _colorMenu = new QMenu();
    _colorFillMenu = new QMenu();

    QStringList names;
    names << tr("White") << tr("Black") << tr("Dark blue") << tr("Dark green") << tr("Red") << tr("Dark red") << tr("Dark magenta")  << tr("Orange")
          << tr("Yellow") << tr("Green") << tr("Dark cyan") << tr("Cyan") << tr("Blue") << tr("Magenta") << tr("Dark gray") << tr("Light gray");

    QPixmap pix(16, 16);
    for (int i = 0; i < inputLine()->mircColorMap().count(); i++) {
        pix.fill(inputLine()->mircColorMap().values()[i]);
        _colorMenu->addAction(pix, names[i])->setData(inputLine()->mircColorMap().keys()[i]);
        _colorFillMenu->addAction(pix, names[i])->setData(inputLine()->mircColorMap().keys()[i]);
    }

    pix.fill(Qt::transparent);
    _colorMenu->addAction(pix, tr("Clear Color"))->setData("");
    _colorFillMenu->addAction(pix, tr("Clear Color"))->setData("");

    ui.textcolorButton->setMenu(_colorMenu);
    connect(_colorMenu, SIGNAL(triggered(QAction *)), this, SLOT(colorChosen(QAction *)));
    ui.highlightcolorButton->setMenu(_colorFillMenu);
    connect(_colorFillMenu, SIGNAL(triggered(QAction *)), this, SLOT(colorHighlightChosen(QAction *)));

    new TabCompleter(ui.inputEdit);

    UiStyleSettings fs("Fonts");
    fs.notify("UseCustomInputWidgetFont", this, SLOT(setUseCustomFont(QVariant)));
    fs.notify("InputWidget", this, SLOT(setCustomFont(QVariant)));
    if (fs.value("UseCustomInputWidgetFont", false).toBool())
        setCustomFont(fs.value("InputWidget", QFont()));

    UiSettings s("InputWidget");

#ifdef HAVE_KDE
    s.notify("EnableSpellCheck", this, SLOT(setEnableSpellCheck(QVariant)));
    setEnableSpellCheck(s.value("EnableSpellCheck", false));
#endif

    s.notify("EnableEmacsMode", this, SLOT(setEnableEmacsMode(QVariant)));
    setEnableEmacsMode(s.value("EnableEmacsMode", false));

    s.notify("ShowNickSelector", this, SLOT(setShowNickSelector(QVariant)));
    setShowNickSelector(s.value("ShowNickSelector", true));

    s.notify("ShowStyleButtons", this, SLOT(setShowStyleButtons(QVariant)));
    setShowStyleButtons(s.value("ShowStyleButtons", true));

    s.notify("EnablePerChatHistory", this, SLOT(setEnablePerChatHistory(QVariant)));
    setEnablePerChatHistory(s.value("EnablePerChatHistory", false));

    s.notify("MaxNumLines", this, SLOT(setMaxLines(QVariant)));
    setMaxLines(s.value("MaxNumLines", 5));

    s.notify("EnableScrollBars", this, SLOT(setScrollBarsEnabled(QVariant)));
    setScrollBarsEnabled(s.value("EnableScrollBars", true));

    s.notify("EnableLineWrap", this, SLOT(setLineWrapEnabled(QVariant)));
    setLineWrapEnabled(s.value("EnableLineWrap", false));

    s.notify("EnableMultiLine", this, SLOT(setMultiLineEnabled(QVariant)));
    setMultiLineEnabled(s.value("EnableMultiLine", true));

    ActionCollection *coll = QtUi::actionCollection();

    Action *activateInputline = coll->add<Action>("FocusInputLine");
    connect(activateInputline, SIGNAL(triggered()), SLOT(setFocus()));
    activateInputline->setText(tr("Focus Input Line"));
    activateInputline->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L));

    connect(inputLine(), SIGNAL(textEntered(QString)), SLOT(onTextEntered(QString)), Qt::QueuedConnection); // make sure the line is already reset, bug #984
    connect(inputLine(), SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(currentCharFormatChanged(QTextCharFormat)));
}