42 #include "AddressBar.h" |
42 #include "AddressBar.h" |
43 |
43 |
44 #include <QtCore> |
44 #include <QtCore> |
45 #include <QtGui> |
45 #include <QtGui> |
46 |
46 |
47 class LineEdit: public QLineEdit |
|
48 { |
|
49 public: |
|
50 LineEdit(QWidget *parent = 0): QLineEdit(parent) {} |
|
51 |
|
52 void paintEvent(QPaintEvent *event) { |
|
53 QLineEdit::paintEvent(event); |
|
54 if (text().isEmpty()) { |
|
55 QPainter p(this); |
|
56 int flags = Qt::AlignLeft | Qt::AlignVCenter; |
|
57 p.setPen(palette().color(QPalette::Disabled, QPalette::Text)); |
|
58 p.drawText(rect().adjusted(10, 0, 0, 0), flags, "Enter address or search terms"); |
|
59 p.end(); |
|
60 } |
|
61 } |
|
62 }; |
|
63 |
|
64 AddressBar::AddressBar(QWidget *parent) |
47 AddressBar::AddressBar(QWidget *parent) |
65 : QWidget(parent) |
48 : QWidget(parent) |
66 { |
49 { |
67 m_lineEdit = new LineEdit(parent); |
50 m_lineEdit = new QLineEdit(parent); |
|
51 m_lineEdit->setPlaceholderText("Enter address or search terms"); |
68 connect(m_lineEdit, SIGNAL(returnPressed()), SLOT(processAddress())); |
52 connect(m_lineEdit, SIGNAL(returnPressed()), SLOT(processAddress())); |
69 m_toolButton = new QToolButton(parent); |
53 m_toolButton = new QToolButton(parent); |
70 m_toolButton->setText("Go"); |
54 m_toolButton->setText("Go"); |
71 connect(m_toolButton, SIGNAL(clicked()), SLOT(processAddress())); |
55 connect(m_toolButton, SIGNAL(clicked()), SLOT(processAddress())); |
72 } |
56 } |