X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fuisupport%2Finputline.h;h=66742b63ef7d14a8f7c53484a7fede89415d69aa;hb=3bff1ddf7f5f5816b1392f526ef77c051bd34763;hp=313a8b8e9eb0e70e5d0f90e6935a16eadc410c0f;hpb=dc9de5af386f61e6dc5537d04ccc8aceb8126b21;p=quassel.git diff --git a/src/uisupport/inputline.h b/src/uisupport/inputline.h index 313a8b8e..66742b63 100644 --- a/src/uisupport/inputline.h +++ b/src/uisupport/inputline.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * + * Copyright (C) 2005-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -23,15 +23,36 @@ #include +#ifdef HAVE_KDE +#include +#endif + class TabCompleter; -class InputLine : public QLineEdit { +class InputLine : public +#ifdef HAVE_KDE + KTextEdit +#else + QLineEdit +#endif +{ Q_OBJECT public: InputLine(QWidget *parent = 0); ~InputLine(); + void setCustomFont(const QFont &); // should be used instead setFont(), so we can set our size correctly + +#ifdef HAVE_KDE +//Compatibility methods with the rest of the classes which expects this to be a QLineEdit + QString text() { return toPlainText(); }; + int cursorPosition() { return textCursor().position(); }; + void insert(const QString &newText) { insertPlainText(newText); }; + void backspace() { keyPressEvent(new QKeyEvent(QEvent::KeyPress, Qt::Key_Backspace, Qt::NoModifier)); }; + bool hasSelectedText() { return textCursor().hasSelection(); }; +#endif + protected: // virtual bool event(QEvent *); virtual void keyPressEvent(QKeyEvent * event); @@ -40,11 +61,20 @@ protected: private slots: void on_returnPressed(); void on_textChanged(QString newText); +#ifdef HAVE_KDE +//Needed to emulate the signal that QLineEdit has + void on_textChanged() { emit textChanged(toPlainText()); }; +#endif bool addToHistory(const QString &text, bool temporary = false); signals: void sendText(QString text); +#ifdef HAVE_KDE +//KTextEdit does not provide this signal, so we manually emit it in keyPressEvent() + void returnPressed(); + void textChanged(QString newText); +#endif private: QStringList history;