Changeset 12421 in osm for applications/editors
- Timestamp:
- 2008-12-19T12:14:11+01:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wmsplugin/webkit-image.cpp
r12093 r12421 8 8 */ 9 9 #include <QtGui/QApplication> 10 #include <QtGui/QPainter> 10 11 #include <QtCore/QFile> 11 12 #include <QtCore/QString> 12 #include <QtWebKit/QWebView> 13 #include <QtWebKit/QWebPage> 14 #include <QtWebKit/QWebFrame> 13 15 14 16 /* using mingw to set binary mode */ … … 27 29 Q_OBJECT 28 30 public: 29 Save(QWeb View *v) : view(v) {};31 Save(QWebPage *p) : page(p) {}; 30 32 31 33 public slots: 32 void setGeometry(const QRect &r)33 {34 view->setGeometry(r);35 }36 34 void loaded(bool ok) 37 35 { 38 36 if(ok) 39 37 { 40 QImage im = QPixmap::grabWidget(view).toImage(); 38 page->setViewportSize(page->mainFrame()->contentsSize()); 39 QImage im(page->viewportSize(), QImage::Format_ARGB32); 40 QPainter painter(&im); 41 page->mainFrame()->render(&painter); 41 42 42 43 QFile f; … … 56 57 57 58 private: 58 QWeb View *view;59 QWebPage * page; 59 60 }; 60 61 … … 67 68 QString url = QString(argv[1]); 68 69 69 QApplication a( argc, argv ); 70 QWebView *view = new QWebView(); 71 Save *s = new Save(view); 72 view->resize(WIDTH,WIDTH); 70 QApplication a(argc, argv); 71 QWebPage * page = new QWebPage(); 72 Save * s = new Save(page); 73 73 74 QObject::connect( view, SIGNAL(loadFinished(bool)), s, SLOT(loaded(bool)));74 QObject::connect(page, SIGNAL(loadFinished(bool)), s, SLOT(loaded(bool))); 75 75 QObject::connect(s, SIGNAL(finish(void)), &a, SLOT(quit())); 76 QObject::connect(view->page(), SIGNAL(geometryChangeRequested(const QRect &)), s, SLOT(setGeometry(const QRect &))); 77 view->load(QUrl(url)); 76 page->mainFrame()->load (QUrl(url)); 78 77 return a.exec(); 79 78 }
Note:
See TracChangeset
for help on using the changeset viewer.