Mercurial > projects > qtd
comparison demos/browser/urllineedit.d @ 94:87bb4e622f9e
more porting
author | mandel |
---|---|
date | Thu, 28 May 2009 22:11:52 +0000 |
parents | 5c8c9c5d9ee1 |
children |
comparison
equal
deleted
inserted
replaced
93:55fd7080c4b9 | 94:87bb4e622f9e |
---|---|
41 | 41 |
42 module urllineedit; | 42 module urllineedit; |
43 | 43 |
44 import qt.core.QUrl; | 44 import qt.core.QUrl; |
45 import qt.core.QEvent; | 45 import qt.core.QEvent; |
46 import qt.core.QDebug; | 46 //import qt.core.QDebug; |
47 | 47 |
48 import qt.gui.QWidget; | 48 import qt.gui.QWidget; |
49 import qt.gui.QStyleOptionFrame; | 49 import qt.gui.QStyleOptionFrame; |
50 import qt.gui.QApplication; | 50 import qt.gui.QApplication; |
51 import qt.gui.QCompleter; | 51 import qt.gui.QCompleter; |
54 import qt.gui.QLabel; | 54 import qt.gui.QLabel; |
55 import qt.gui.QLineEdit; | 55 import qt.gui.QLineEdit; |
56 import qt.gui.QPainter; | 56 import qt.gui.QPainter; |
57 import qt.gui.QStyle; | 57 import qt.gui.QStyle; |
58 import qt.gui.QStyleOptionFrameV2; | 58 import qt.gui.QStyleOptionFrameV2; |
59 import qt.gui.QLinearGradient; | |
60 | |
59 | 61 |
60 import browserapplication; | 62 import browserapplication; |
61 import searchlineedit; | 63 import searchlineedit; |
62 import webview; | 64 import webview; |
63 | 65 |
251 if (event.buttons() == Qt.LeftButton | 253 if (event.buttons() == Qt.LeftButton |
252 && (event.pos() - m_dragStartPos).manhattanLength() > QApplication.startDragDistance() | 254 && (event.pos() - m_dragStartPos).manhattanLength() > QApplication.startDragDistance() |
253 && m_webView) { | 255 && m_webView) { |
254 QDrag drag = new QDrag(this); | 256 QDrag drag = new QDrag(this); |
255 QMimeData mimeData = new QMimeData; | 257 QMimeData mimeData = new QMimeData; |
256 mimeData.setText(QString.fromUtf8(m_webView.url().toEncoded())); | 258 mimeData.setText(QString.fromUtf8(m_webView.getUrl().toEncoded())); |
257 QUrl[] urls; | 259 QUrl[] urls; |
258 urls ~= m_webView.url(); | 260 urls ~= m_webView.getUrl(); |
259 mimeData.setUrls(urls); | 261 mimeData.setUrls(urls); |
260 drag.setMimeData(mimeData); | 262 drag.setMimeData(mimeData); |
261 drag.exec(); | 263 drag.exec(); |
262 } | 264 } |
263 } | 265 } |
300 protected: | 302 protected: |
301 | 303 |
302 void paintEvent(QPaintEvent event) | 304 void paintEvent(QPaintEvent event) |
303 { | 305 { |
304 QPalette p = palette(); | 306 QPalette p = palette(); |
305 if (m_webView && m_webView.url().scheme() == "https") { | 307 if (m_webView && m_webView.getUrl().scheme() == "https") { |
306 auto lightYellow = new QColor(248, 248, 210); | 308 auto lightYellow = new QColor(248, 248, 210); |
307 p.setBrush(QPalette.Base, generateGradient(lightYellow)); | 309 p.setBrush(QPalette.Base, generateGradient(lightYellow)); |
308 } else { | 310 } else { |
309 p.setBrush(QPalette.Base, m_defaultBaseColor); | 311 p.setBrush(QPalette.Base, m_defaultBaseColor); |
310 } | 312 } |
327 } | 329 } |
328 | 330 |
329 void focusOutEvent(QFocusEvent event) | 331 void focusOutEvent(QFocusEvent event) |
330 { | 332 { |
331 if (m_lineEdit.text().isEmpty() && m_webView) | 333 if (m_lineEdit.text().isEmpty() && m_webView) |
332 m_lineEdit.setText(QString.fromUtf8(m_webView.url().toEncoded())); | 334 m_lineEdit.setText(QString.fromUtf8(m_webView.getUrl().toEncoded())); |
333 ExLineEdit.focusOutEvent(event); | 335 ExLineEdit.focusOutEvent(event); |
334 } | 336 } |
335 | 337 |
336 private: | 338 private: |
337 | 339 |
341 m_lineEdit.setCursorPosition(0); | 343 m_lineEdit.setCursorPosition(0); |
342 } | 344 } |
343 | 345 |
344 void webViewIconChanged() | 346 void webViewIconChanged() |
345 { | 347 { |
346 QUrl url = m_webView ? m_webView.url() : new QUrl(); | 348 QUrl url = m_webView ? m_webView.getUrl() : new QUrl(); |
347 QIcon icon = BrowserApplication.instance().icon(url); | 349 QIcon icon = BrowserApplication.instance().icon(url); |
348 auto pixmap = new QPixmap(icon.pixmap(16, 16)); | 350 auto pixmap = new QPixmap(icon.pixmap(16, 16)); |
349 m_iconLabel.setPixmap(pixmap); | 351 m_iconLabel.setPixmap(pixmap); |
350 } | 352 } |
351 | 353 |