2012-12-24 11:30:03 +00:00
|
|
|
/* This file is (c) 2012 Tvangeste <i.4m.l33t@yandex.ru>
|
|
|
|
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
|
|
|
|
|
|
|
#ifndef TRANSLATEBOX_HH
|
|
|
|
#define TRANSLATEBOX_HH
|
|
|
|
|
2013-01-25 15:42:44 +00:00
|
|
|
#include "extlineedit.hh"
|
|
|
|
#include "wordlist.hh"
|
2017-09-08 13:43:41 +00:00
|
|
|
#include "mutex.hh"
|
2012-12-24 11:30:03 +00:00
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QListWidget>
|
|
|
|
#include <QFocusEvent>
|
|
|
|
|
2013-01-28 12:18:13 +00:00
|
|
|
class TranslateBox;
|
|
|
|
|
2013-01-25 15:42:44 +00:00
|
|
|
class CompletionList : public WordList
|
2012-12-24 11:30:03 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2013-01-28 12:18:13 +00:00
|
|
|
CompletionList(TranslateBox * parent);
|
2012-12-24 11:30:03 +00:00
|
|
|
int preferredHeight() const;
|
2013-01-28 20:31:28 +00:00
|
|
|
virtual void setTranslateLine(QLineEdit * line)
|
|
|
|
{
|
|
|
|
WordList::setTranslateLine( line );
|
|
|
|
setFocusProxy( line );
|
|
|
|
}
|
2012-12-24 11:30:03 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
bool acceptCurrentEntry();
|
2013-01-25 15:42:44 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
virtual bool eventFilter( QObject *, QEvent * );
|
2013-01-28 12:18:13 +00:00
|
|
|
TranslateBox * translateBox;
|
2012-12-24 11:30:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class TranslateBox : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit TranslateBox(QWidget * parent = 0);
|
|
|
|
void setPlaceholderText(const QString &text);
|
|
|
|
QLineEdit * translateLine();
|
2013-01-25 15:42:44 +00:00
|
|
|
WordList * wordList();
|
2013-01-27 22:12:00 +00:00
|
|
|
void setText(QString text, bool showPopup=true);
|
2013-02-07 18:15:34 +00:00
|
|
|
void setSizePolicy(QSizePolicy policy);
|
|
|
|
inline void setSizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver)
|
|
|
|
{ setSizePolicy(QSizePolicy(hor, ver)); }
|
2012-12-24 11:30:03 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
|
|
public slots:
|
2013-01-17 09:08:53 +00:00
|
|
|
void setPopupEnabled(bool enable);
|
2012-12-24 11:30:03 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void showPopup();
|
|
|
|
void rightButtonClicked();
|
2013-01-27 22:12:00 +00:00
|
|
|
void onTextEdit();
|
2012-12-24 11:30:03 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool eventFilter(QObject *obj, QEvent *event);
|
|
|
|
CompletionList * word_list;
|
|
|
|
ExtLineEdit * translate_line;
|
2013-01-17 09:08:53 +00:00
|
|
|
bool m_popupEnabled;
|
2017-09-08 13:43:41 +00:00
|
|
|
Mutex translateBoxMutex;
|
2012-12-24 11:30:03 +00:00
|
|
|
// QCompleter * completer; // disabled for now
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TRANSLATEBOX_HH
|