Class: HtmlConverter::WebRenderer
- Inherits:
-
Qt::Object
- Object
- Qt::Object
- HtmlConverter::WebRenderer
- Defined in:
- lib/htmlconverter/base.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
Instance Method Summary collapse
-
#initialize(renderer) ⇒ WebRenderer
constructor
A new instance of WebRenderer.
- #onLoadFinished(ok) ⇒ Object
- #render ⇒ Object
- #render_content(content) ⇒ Object
- #render_url(url) ⇒ Object
Constructor Details
#initialize(renderer) ⇒ WebRenderer
Returns a new instance of WebRenderer.
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/htmlconverter/base.rb', line 61 def initialize(renderer) super() @app = Qt::Application.new([]) @page = Qt::WebPage.new @renderer = renderer Qt::Object.connect(@page, SIGNAL("loadFinished(bool)"), self, SLOT("onLoadFinished(bool)")) Qt::Object.connect(self, SIGNAL("readyToRender()"), self, SLOT("render()")) end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
59 60 61 |
# File 'lib/htmlconverter/base.rb', line 59 def content @content end |
Instance Method Details
#onLoadFinished(ok) ⇒ Object
74 75 76 |
# File 'lib/htmlconverter/base.rb', line 74 def onLoadFinished(ok) Qt::Timer::singleShot(0, self, SIGNAL("readyToRender()")) end |
#render ⇒ Object
90 91 92 93 94 95 |
# File 'lib/htmlconverter/base.rb', line 90 def render raise "Already rendered" if @app.nil? @content = @renderer.render(@page) cleanup end |
#render_content(content) ⇒ Object
84 85 86 87 88 |
# File 'lib/htmlconverter/base.rb', line 84 def render_content(content) @page.mainFrame.setContent(Qt::ByteArray.new(content)) @app.exec @content end |
#render_url(url) ⇒ Object
78 79 80 81 82 |
# File 'lib/htmlconverter/base.rb', line 78 def render_url(url) @page.mainFrame.load(Qt::Url.new(url)) @app.exec @content end |