Changeset 54065 in webkit
- Timestamp:
- Jan 29, 2010 8:49:39 AM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 4 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r54058 r54065 1 2010-01-29 Andreas Kling <andreas.kling@nokia.com> 2 3 Reviewed by Kenneth Rohde Christiansen. 4 5 [Qt] Display page loading progress inside the QtLauncher location bar 6 7 https://bugs.webkit.org/show_bug.cgi?id=34210 8 9 * QtLauncher/QtLauncher.pro: 10 * QtLauncher/locationedit.cpp: Added. 11 (LocationEdit::LocationEdit): 12 (LocationEdit::setProgress): 13 (LocationEdit::paintEvent): 14 * QtLauncher/locationedit.h: Added. 15 * QtLauncher/mainwindow.cpp: 16 (MainWindow::buildUI): 17 * QtLauncher/mainwindow.h: 18 1 19 2010-01-29 Andreas Kling <andreas.kling@nokia.com> 2 20 -
trunk/WebKitTools/QtLauncher/QtLauncher.pro
r53948 r54065 2 2 3 3 SOURCES += \ 4 locationedit.cpp \ 4 5 main.cpp \ 5 6 mainwindow.cpp \ … … 10 11 11 12 HEADERS += \ 13 locationedit.h \ 12 14 mainwindow.h \ 13 15 urlloader.h \ -
trunk/WebKitTools/QtLauncher/locationedit.cpp
r54064 r54065 1 1 /* 2 * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2009 Girish Ramakrishnan <girish@forwardbias.in> 4 * Copyright (C) 2006 George Staikos <staikos@kde.org> 5 * Copyright (C) 2006 Dirk Mueller <mueller@kde.org> 6 * Copyright (C) 2006 Zack Rusin <zack@kde.org> 7 * Copyright (C) 2006 Simon Hausmann <hausmann@kde.org> 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 8 3 * 9 4 * All rights reserved. … … 31 26 */ 32 27 33 #ifndef mainwindow_h 34 #define mainwindow_h 28 #include "locationedit.h" 35 29 36 #include <QtGui> 37 #include "webpage.h" 30 LocationEdit::LocationEdit(QWidget* parent) 31 : QLineEdit(parent), 32 m_progress(0) 33 { 34 } 38 35 39 class MainWindow : public QMainWindow { 40 Q_OBJECT 36 void LocationEdit::setProgress(int progress) 37 { 38 m_progress = progress; 39 update(); 40 } 41 41 42 public: 43 MainWindow(const QString& url = QString()); 42 void LocationEdit::paintEvent(QPaintEvent* ev) 43 { 44 QColor backgroundColor = QApplication::palette().color(QPalette::Base); 45 QColor progressColor = QColor(120, 180, 240); 46 QPalette p = palette(); 44 47 45 void setAddressUrl(const QString& url); 46 void addCompleterEntry(const QUrl& url); 48 if (!m_progress || m_progress == 100) 49 p.setBrush(QPalette::Base, backgroundColor); 50 else { 51 QLinearGradient gradient(0, 0, width(), 0); 52 gradient.setColorAt(0, progressColor); 53 gradient.setColorAt(((double)m_progress) / 100, progressColor); 54 gradient.setColorAt(((double)m_progress) / 100 + 0.001, backgroundColor); 55 p.setBrush(QPalette::Base, gradient); 56 } 57 setPalette(p); 47 58 48 void load(const QString& url); 49 void load(const QUrl& url); 50 51 WebPage* page(); 52 53 protected slots: 54 void openFile(); 55 void changeLocation(); 56 57 private: 58 void buildUI(); 59 60 QStringListModel urlModel; 61 QStringList urlList; 62 QLineEdit* urlEdit; 63 64 QProgressBar* progress; 65 66 WebPage* m_page; 67 }; 68 69 #endif 59 QLineEdit::paintEvent(ev); 60 } -
trunk/WebKitTools/QtLauncher/locationedit.h
r54064 r54065 1 1 /* 2 * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2009 Girish Ramakrishnan <girish@forwardbias.in> 4 * Copyright (C) 2006 George Staikos <staikos@kde.org> 5 * Copyright (C) 2006 Dirk Mueller <mueller@kde.org> 6 * Copyright (C) 2006 Zack Rusin <zack@kde.org> 7 * Copyright (C) 2006 Simon Hausmann <hausmann@kde.org> 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 8 3 * 9 4 * All rights reserved. … … 31 26 */ 32 27 33 #ifndef mainwindow_h34 #define mainwindow_h28 #ifndef locationedit_h 29 #define locationedit_h 35 30 36 31 #include <QtGui> 37 #include "webpage.h"38 32 39 class MainWindow : public QMainWindow{33 class LocationEdit : public QLineEdit { 40 34 Q_OBJECT 41 35 42 36 public: 43 MainWindow(const QString& url = QString());37 LocationEdit(QWidget* parent = 0); 44 38 45 void setAddressUrl(const QString& url); 46 void addCompleterEntry(const QUrl& url);39 public slots: 40 void setProgress(int progress); 47 41 48 void load(const QString& url); 49 void load(const QUrl& url); 50 51 WebPage* page(); 52 53 protected slots: 54 void openFile(); 55 void changeLocation(); 42 protected: 43 void paintEvent(QPaintEvent*); 56 44 57 45 private: 58 void buildUI(); 59 60 QStringListModel urlModel; 61 QStringList urlList; 62 QLineEdit* urlEdit; 63 64 QProgressBar* progress; 65 66 WebPage* m_page; 46 int m_progress; 67 47 }; 68 48 -
trunk/WebKitTools/QtLauncher/mainwindow.cpp
r53948 r54065 33 33 #include "mainwindow.h" 34 34 35 #include "locationedit.h" 35 36 #include "utils.h" 36 37 … … 55 56 bar->addAction(page()->action(QWebPage::Stop)); 56 57 57 urlEdit = new QLineEdit(this);58 urlEdit = new LocationEdit(this); 58 59 urlEdit->setSizePolicy(QSizePolicy::Expanding, urlEdit->sizePolicy().verticalPolicy()); 59 60 connect(urlEdit, SIGNAL(returnPressed()), SLOT(changeLocation())); … … 63 64 bar->addWidget(urlEdit); 64 65 65 progress = new QProgressBar(this);66 progress->setRange(0, 100);67 progress->setMinimumSize(100, 20);68 progress->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);69 progress->hide();70 statusBar()->addPermanentWidget(progress);71 72 66 connect(page()->mainFrame(), SIGNAL(titleChanged(const QString&)), 73 67 this, SLOT(setWindowTitle(const QString&))); 74 connect(page(), SIGNAL(loadProgress(int)), progress, SLOT(show())); 75 connect(page(), SIGNAL(loadProgress(int)), progress, SLOT(setValue(int))); 76 connect(page(), SIGNAL(loadFinished(bool)), progress, SLOT(hide())); 68 connect(page(), SIGNAL(loadProgress(int)), urlEdit, SLOT(setProgress(int))); 77 69 connect(page(), SIGNAL(windowCloseRequested()), this, SLOT(close())); 78 70 -
trunk/WebKitTools/QtLauncher/mainwindow.h
r53948 r54065 37 37 #include "webpage.h" 38 38 39 class LocationEdit; 40 39 41 class MainWindow : public QMainWindow { 40 42 Q_OBJECT … … 60 62 QStringListModel urlModel; 61 63 QStringList urlList; 62 QLineEdit* urlEdit; 63 64 QProgressBar* progress; 64 LocationEdit* urlEdit; 65 65 66 66 WebPage* m_page;
Note: See TracChangeset
for help on using the changeset viewer.