X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Finputline.h;h=dddf8d5ea4093a2253eaa74e794c1d0663ff7f42;hp=dc6d691ceeb1dd3c1285af8dfd04c125b6c3299d;hb=c21696b07427a43b305dfbfddef73fcf274dfddf;hpb=3d16580493b0bba9323d081fd0fa3d6c020f94a1 diff --git a/src/uisupport/inputline.h b/src/uisupport/inputline.h index dc6d691c..dddf8d5e 100644 --- a/src/uisupport/inputline.h +++ b/src/uisupport/inputline.h @@ -23,15 +23,34 @@ #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(); +#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 +59,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;