Changeset 12421 in osm for applications/editors


Ignore:
Timestamp:
2008-12-19T12:14:11+01:00 (16 years ago)
Author:
stoecker
Message:

fixed large picture problem

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/wmsplugin/webkit-image.cpp

    r12093 r12421  
    88*/
    99#include <QtGui/QApplication>
     10#include <QtGui/QPainter>
    1011#include <QtCore/QFile>
    1112#include <QtCore/QString>
    12 #include <QtWebKit/QWebView>
     13#include <QtWebKit/QWebPage>
     14#include <QtWebKit/QWebFrame>
    1315
    1416/* using mingw to set binary mode */
     
    2729Q_OBJECT
    2830public:
    29   Save(QWebView *v) : view(v) {};
     31  Save(QWebPage *p) : page(p) {};
    3032
    3133public slots:
    32   void setGeometry(const QRect &r)
    33   {
    34     view->setGeometry(r);
    35   }
    3634  void loaded(bool ok)
    3735  {
    3836    if(ok)
    3937    {
    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);
    4142
    4243      QFile f;
     
    5657
    5758private:
    58   QWebView *view;
     59  QWebPage * page;
    5960};
    6061
     
    6768  QString url = QString(argv[1]);
    6869
    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);
    7373
    74   QObject::connect(view, SIGNAL(loadFinished(bool)), s, SLOT(loaded(bool)));
     74  QObject::connect(page, SIGNAL(loadFinished(bool)), s, SLOT(loaded(bool)));
    7575  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));
    7877  return a.exec();
    7978}
Note: See TracChangeset for help on using the changeset viewer.