Monday, June 29, 2009

Qt 4.5.2 and Qt Creator 1.2 were released

In last Thursday, Qt 4.5.2 and Qt Creator 1.2 were released. I download and install Qt 4.5.2 SDK (LGPL) from here. It contains Qt 4.5.2 and Qt Creator 1.2 both.
#./qt-sdk-linux-x86_64-opensource-2009.03.bin
Release of Qt Creator 1.2 includes many UI changes like
  • Characters in menus and windows are well-translated.
  • Welcome screen indicates each Qt SDK samples.
  • and more...
Installation instructions of QtRuby are below:
>cmake \
> -DCMAKE_INSTALL_PREFIX=/opt/ruby-1.9.1 \
> -DRUBY_EXECUTABLE=/opt/ruby-1.9.1/bin/ruby \
> -DRUBY_LIBRARY=/opt/ruby-1.9.1/lib/libruby.so.1.9.1 \
> -DRUBY_INCLUDE_PATH=/opt/ruby-1.9.1/include/ruby-1.9.1 \
> -DQT_QMAKE_EXECUTABLE=/opt/qtsdk-2009.03/qt/bin/qmake \
> -DQT_MKSPECS_DIR=/opt/qtsdk-2009.03/qt/mkspecs \
> -Wno-dev \
> -DENABLE_SMOKE=on \
> -DENABLE_QTRUBY=on \
> -DENABLE_QTWEBKIT_SMOKE=on \
> -DENABLE_QTSCRIPT_SMOKE=on \
> -DENABLE_QTUITOOLS_SMOKE=on \
> -DENABLE_QTTEST_SMOKE=off \
> -DENABLE_PHONON_SMOKE=off \
> -DENABLE_QSCI_SMOKE=off \
> -DENABLE_QWT_SMOKE=off \
> -DENABLE_KDE_SMOKE=off \
> -DENABLE_KDEVPLATFORM_SMOKE=off \
> -DENABLE_KHTML_SMOKE=off \
> -DENABLE_KTEXTEDITOR_SMOKE=off \
> -DENABLE_SOLID_SMOKE=off \
> -DENABLE_PLASMA_SMOKE=off \
> -DENABLE_QTWEBKIT_RUBY=on \
> -DENABLE_QTUITOOLS_RUBY=on \
> -DENABLE_QTSCRIPT=on \
> -DENABLE_QTTEST=off \
> -DENABLE_PHONON_RUBY=off \
> -DENABLE_QSCINTILLA_RUBY=off \
> -DENABLE_QWT_RUBY=off \
> -DENABLE_SOPRANO_RUBY=off \
> -DENABLE_KDEVPLATFORM_RUBY=off \
> -DENABLE_KORUNDUM_RUBY=off \
> -DENABLE_KHTML_RUBY=off \
> -DENABLE_KTEXTEDITOR_RUBY=off \
> -DENABLE_SOLID_RUBY=off \
> -DENABLE_KROSSRUBY=off \
> -DENABLE_PLASMA_RUBY=off \
> -DENABLE_QIMAGEBLITZ_SMOKE=off
Then check QtRuby commands.
>/opt/ruby-1.9.1/bin/rbrcc -version
Ruby Resource Compiler for Qt version 4.5.2
>/opt/ruby-1.9.1/bin/rbuic4 -v
Qt User Interface Compiler version 4.5.2
>/opt/ruby-1.9.1/bin/rbqtapi -v
QtRuby 2.0.3 using Qt-4.5.2

Friday, June 26, 2009

Timetables of RubyKaigi2009 are revealed

2 days ago, timetables of RubyKaigi2009 are revealed.
In my opinion, it's unsatisfactory that ko1(Ruby 1.9 VM)'s session and Yehuda Katz(Merb/Rails3)'s one overlap.

Wednesday, June 24, 2009

QtWebkit HTML5 practice

At phosphorescence: QtWebKit practice and phosphorescence: QtWebkit practice with QtRuby, I wrote QtWebKit sample program with Qt and QtRuby. And I also mentioned QtWebkit suports HTML5 in the phosphorescence: HTML5 support in QtWebkit. Then, can HTML5 be rendered with QtWebKit?

First, access to the HTML5 demo: Canvas | Drawing Board by Qt program.
#include <QApplication>
#include <QUrl>
#include <QWebView>
int main(int argc, char *argv[]){
QApplication a(argc, argv);
QUrl url("http://htmlfive.appspot.com/static/draw.html");
QWebView* webView = new QWebView();
webView->load(url);
webView->show();
return a.exec();
}

This runs successfully:
and can draw lines in canvas by mouse successfully, too.

Second, access to the HTML5 demo: Canvas | 1st-Person Gifter by QtRuby program.
require 'Qt4'
require 'qtwebkit'

Qt::Application.new(ARGV) do
  Qt::WebView.new do
    self.load Qt::Url.new('http://htmlfive.appspot.com/static/gifter.html')
    show
  end
  exec
end

Of course. this runs successfully too and move in maze with arrow keys:

Note that canvas tag is rendered easily, but that video tag depends on environment like video format and codec in client. At least, in my environment (on openSUSE 11.1), video tag isn't rendered not only with QtWebkit but also with HTML5 support browsers(Firefox, Opera, Konqueror).

Monday, June 22, 2009

FizzBuzz with Object#tap

From Ruby 1.9.1, Object#tap is added. What's this? Let's train by FizzBuzz.

fizz_buzz = ->(i) do
case 0
when i % 15
puts 'FizzBuzz'
when i % 5
puts 'Buzz'
when i % 3
puts 'Fizz'
else
puts i
end
end
(1..40).collect do |i|
i.tap(&fizz_buzz)
end

1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
Fizz
22
23
Fizz
Buzz
26
Fizz
28
29
FizzBuzz
31
32
Fizz
34
Buzz
Fizz
37
38
Fizz
Buzz
=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]

Object#tap evaluates block with self as block-argument, and then return self.

Friday, June 19, 2009

HTML5 support in QtWebkit

A few weeks ago, each developer conference was held by Google and Apple. In each conference, most impressive topic is about HTML5. Google announces Google Wave and recommends Google Chrome 2. And Apple annoucnes Safari 4. All technologies are related with HTML5.

On the other, how Qt supports HTML5? The answer is... already! Several features of Webkit(As you know, it's original program of Google Chrome and Safari) were supported in Qt 4.4, Qt improves its support level in Qt 4.5. See the movie from here:



Of course, API is opened.

Tuesday, June 16, 2009

openSUSE mascot on demand

Let's build openSUSE's mascot as you like!

Geeko Builder is rich web application that can create "Geeko"(mascot of openSUSE) with clicking only. I has built my own Geeko, like this:

We can download wallpaper(above) and avator(beside) from this site. And more, can permalink to each Geeko(like this) and vote. Please join and vote.

Saturday, June 13, 2009

I keep on studying about Qt

As I said in phosphorescence: Qt newbie seminar in Tokyo, I'm nwebie about Qt, and now studying with book: "C++ GUI Programming with Qt 4", but it's 1st edition.
Why 1st editon, not 2nd edition?
Because I'm reading it with Japanese translation edition that is translated until 1st edition, not 2nd edition.

By the way, the cover of Japanese translation edition is different from original one. See the cover!
As you can see, it's O'Reilly-ish. There is no wonder about it, Japanese translation edition is published from O'Reilly Japan (written in Japanese).

Wednesday, June 10, 2009

QtWebkit practice with QtRuby

I wrote QtWebKit sample program with Qt in phosphorescence: QtWebKit practice. Next, let's write corresponding program with QtRuby.
require 'Qt4'
require 'qtwebkit'

Qt::Application.new(ARGV) do
Qt::WebView.new do
self.load Qt::Url.new('http://www.wolframalpha.com/')
show
end
exec
end

Then run, succeed.

Monday, June 8, 2009

openSUSE benkyoukai 2009/06

2 days ago, in Tokyo, openSUSE benkyoukai was held (What's benkyoukai? see the first part of past entry).

At this time, I attend in the venue. There were 2 sessions:
  1. Tips at exchanging HDD with dual boot win and linux
  2. Tips for Gimp
I learn many tips from each speakers, and attendees(of course, me too) advice additional techniques to each speakers.

On this place after all sessions, one attendee who volunteers translations called, so less people translate informations (weekly news, wiki, and so on) from English to Japanese that we need more voluntaries. His call aroused me to transrate some information. So I went back to home soon, translated Bluetooth page of openSUSE wiki until now from English to Japanese.

Friday, June 5, 2009

QtWebKit practice

Qt includes web-rendering engine: QtWebKit. By using QWebView class, we can build simple web-rendering widget.
#include <QApplication>
#include <QUrl>
#include <QWebView>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QUrl url("http://www.wolframalpha.com/");
QWebView* webView = new QWebView();
webView->load(url);
webView->show();
return a.exec();
}

When this program runs, widget with rendering area rises.


It's just only rendering area. i.e.
  • objects on the rendering area can work alone.
    (e.g. input to text box, submit a button, page transition, and so on.)
  • operations out of the rendering area can't work alone.
    (e.g. access over the proxy, bookmark, and so on.)

Tuesday, June 2, 2009

More refactoring "Refactoring QtRuby Example #1"

In previous post : phosphorescence: Refactoring "Refactoring QtRuby Example #1", I had wrote below :
require 'Qt4'
require 'default/ui'

class Default < Qt::MainWindow
attr_reader :ui

def initialize(parent=nil)
super(parent)
@ui = UI::DefaultClass.new
@ui.setup_ui(self)
yield(self) if block_given?
ObjectSpace.define_finalizer(self, Default.delete_ui(@ui))
end

private
def Default.delete_ui(ui_to_delete)
proc {ui_to_delete.dispose unless ui_to_delete.disposed?}
end
end

But, it's still redundant yet. Ruby's super has following specifications.
  1. if the argument of super are omitted, all the arguments of original method are passed.
  2. super doesn't have to be top of the code block.

Then I refactor code block to below :
require 'Qt4'
require 'default/ui'

class Default < Qt::MainWindow
attr_reader :ui

def initialize(parent=nil)
@ui = UI::DefaultClass.new
super
@ui.setup_ui(self)
ObjectSpace.define_finalizer(self, Default.delete_ui(@ui))
end

private
def Default.delete_ui(ui_to_delete)
proc {ui_to_delete.dispose unless ui_to_delete.disposed?}
end
end

Original post phosphorescence: Refactoring QtRuby Example #1 has been corrected already. Then let's check working correctly.
irb(main):001:0> require 'Qt4'
=> true
irb(main):002:0> require 'default/default'
=> true
irb(main):003:0> Qt::Application.new(ARGV) do
irb(main):004:1* window = Default.new do|w|
irb(main):005:2* puts w.class
irb(main):006:2> puts w.ui.class
irb(main):007:2> end
irb(main):008:1> end
Default
UI::DefaultClass
=> #<Qt::Application:0x00000000c0acb0 objectName="irb">