forked from goldendict/goldendict
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtranslatebox.hh
69 lines (54 loc) · 1.48 KB
/
translatebox.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* This file is (c) 2012 Tvangeste <[email protected]>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#ifndef TRANSLATEBOX_HH
#define TRANSLATEBOX_HH
#include "extlineedit.hh"
#include "wordlist.hh"
#include <QWidget>
#include <QListWidget>
#include <QFocusEvent>
class TranslateBox;
class CompletionList : public WordList
{
Q_OBJECT
public:
CompletionList(TranslateBox * parent);
int preferredHeight() const;
virtual void setTranslateLine(QLineEdit * line)
{
WordList::setTranslateLine( line );
setFocusProxy( line );
}
public slots:
bool acceptCurrentEntry();
private:
virtual bool eventFilter( QObject *, QEvent * );
TranslateBox * translateBox;
};
class TranslateBox : public QWidget
{
Q_OBJECT
public:
explicit TranslateBox(QWidget * parent = 0);
void setPlaceholderText(const QString &text);
QLineEdit * translateLine();
WordList * wordList();
void setText(QString text, bool showPopup=true);
void setSizePolicy(QSizePolicy policy);
inline void setSizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver)
{ setSizePolicy(QSizePolicy(hor, ver)); }
signals:
public slots:
void setPopupEnabled(bool enable);
private slots:
void showPopup();
void rightButtonClicked();
void onTextEdit();
private:
bool eventFilter(QObject *obj, QEvent *event);
CompletionList * word_list;
ExtLineEdit * translate_line;
bool m_popupEnabled;
// QCompleter * completer; // disabled for now
};
#endif // TRANSLATEBOX_HH