diff options
Diffstat (limited to 'WebKitTools/MiniBrowser/qt')
-rw-r--r-- | WebKitTools/MiniBrowser/qt/BrowserWindow.cpp | 38 | ||||
-rw-r--r-- | WebKitTools/MiniBrowser/qt/BrowserWindow.h | 3 |
2 files changed, 40 insertions, 1 deletions
diff --git a/WebKitTools/MiniBrowser/qt/BrowserWindow.cpp b/WebKitTools/MiniBrowser/qt/BrowserWindow.cpp index 1196cc4..09ac737 100644 --- a/WebKitTools/MiniBrowser/qt/BrowserWindow.cpp +++ b/WebKitTools/MiniBrowser/qt/BrowserWindow.cpp @@ -65,7 +65,11 @@ void BrowserView::resizeEvent(QResizeEvent* event) void BrowserView::load(const QUrl& url) { - m_item->load(url); +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + return m_item->load(QUrl::fromUserInput(url.toString())); +#else + return m_item->load(url); +#endif } QGraphicsWKView* BrowserView::view() const @@ -84,6 +88,9 @@ BrowserWindow::BrowserWindow() m_browser->setFocus(Qt::OtherFocusReason); connect(m_addressBar, SIGNAL(returnPressed()), SLOT(changeLocation())); + connect(m_browser->view(), SIGNAL(loadProgress(int)), SLOT(loadProgress(int))); + connect(m_browser->view(), SIGNAL(titleChanged(const QString&)), SLOT(titleChanged(const QString&))); + connect(m_browser->view(), SIGNAL(urlChanged(const QUrl&)), SLOT(urlChanged(const QUrl&))); QToolBar* bar = addToolBar("Navigation"); bar->addAction(m_browser->view()->page()->action(QWKPage::Back)); @@ -110,6 +117,35 @@ void BrowserWindow::changeLocation() m_browser->load(string); } +void BrowserWindow::loadProgress(int progress) +{ + QColor backgroundColor = QApplication::palette().color(QPalette::Base); + QColor progressColor = QColor(120, 180, 240); + QPalette pallete = m_addressBar->palette(); + + if (progress <= 0 || progress >= 100) + pallete.setBrush(QPalette::Base, backgroundColor); + else { + QLinearGradient gradient(0, 0, width(), 0); + gradient.setColorAt(0, progressColor); + gradient.setColorAt(((double) progress) / 100, progressColor); + if (progress != 100) + gradient.setColorAt((double) progress / 100 + 0.001, backgroundColor); + pallete.setBrush(QPalette::Base, gradient); + } + m_addressBar->setPalette(pallete); +} + +void BrowserWindow::titleChanged(const QString& title) +{ + setWindowTitle(title); +} + +void BrowserWindow::urlChanged(const QUrl& url) +{ + m_addressBar->setText(url.toString()); +} + BrowserWindow::~BrowserWindow() { delete m_addressBar; diff --git a/WebKitTools/MiniBrowser/qt/BrowserWindow.h b/WebKitTools/MiniBrowser/qt/BrowserWindow.h index 30c5122..fa11390 100644 --- a/WebKitTools/MiniBrowser/qt/BrowserWindow.h +++ b/WebKitTools/MiniBrowser/qt/BrowserWindow.h @@ -64,6 +64,9 @@ public: protected slots: void changeLocation(); + void loadProgress(int progress); + void titleChanged(const QString&); + void urlChanged(const QUrl&); private: BrowserView* m_browser; |