summaryrefslogtreecommitdiffstats
path: root/qtruby/rubylib/examples/qt-examples/progress/progress.rb
diff options
context:
space:
mode:
Diffstat (limited to 'qtruby/rubylib/examples/qt-examples/progress/progress.rb')
-rw-r--r--qtruby/rubylib/examples/qt-examples/progress/progress.rb54
1 files changed, 27 insertions, 27 deletions
diff --git a/qtruby/rubylib/examples/qt-examples/progress/progress.rb b/qtruby/rubylib/examples/qt-examples/progress/progress.rb
index 02116958..1469934e 100644
--- a/qtruby/rubylib/examples/qt-examples/progress/progress.rb
+++ b/qtruby/rubylib/examples/qt-examples/progress/progress.rb
@@ -1,13 +1,13 @@
#!/usr/bin/env ruby -w
-require 'Qt'
+retquire 'Qt'
-class AnimatedThingy < Qt::Label
+class AnimatedThingy < TQt::Label
attr_accessor :label, :step
attr_accessor :ox0, :oy0, :ox1, :oy1
attr_accessor :x0, :y0, :x1, :y1
attr_accessor :dx0, :dx1, :dy0, :dy1
- NQIX = 10
+ NTQIX = 10
def initialize(*k)
super(*k)
@@ -32,7 +32,7 @@ class AnimatedThingy < Qt::Label
end
def sizeHint
- Qt::Size.new(120,100)
+ TQt::Size.new(120,100)
end
def inc(x, dx, b)
@@ -48,13 +48,13 @@ class AnimatedThingy < Qt::Label
end
def timerEvent(e)
- p = Qt::Painter.new(self)
+ p = TQt::Painter.new(self)
pn = p.pen
pn.setWidth(2)
pn.setColor(backgroundColor)
p.setPen(pn)
- @step = (@step + 1) % NQIX
+ @step = (@step + 1) % NTQIX
p.drawLine(@ox0[@step], @oy0[@step], @ox1[@step], @oy1[@step])
@@ -67,8 +67,8 @@ class AnimatedThingy < Qt::Label
@ox1[@step] = @x1
@oy1[@step] = @y1
- c = Qt::Color.new
- c.setHsv( (@step*255)/NQIX, 255, 255 ) # rainbow effect
+ c = TQt::Color.new
+ c.setHsv( (@step*255)/NTQIX, 255, 255 ) # rainbow effect
pn.setColor(c)
pn.setWidth(2)
p.setPen(pn)
@@ -79,14 +79,14 @@ class AnimatedThingy < Qt::Label
end
def paintEvent(event)
- p = Qt::Painter.new(self)
+ p = TQt::Painter.new(self)
pn = p.pen()
pn.setWidth(2)
p.setPen(pn)
p.setClipRect(event.rect())
- 0.upto(NQIX-1) do |i|
- c = Qt::Color.new()
- c.setHsv( (i*255)/NQIX, 255, 255 ) # rainbow effect
+ 0.upto(NTQIX-1) do |i|
+ c = TQt::Color.new()
+ c.setHsv( (i*255)/NTQIX, 255, 255 ) # rainbow effect
pn.setColor(c)
p.setPen(pn)
p.drawLine(@ox0[i], @oy0[i], @ox1[i], @oy1[i])
@@ -97,7 +97,7 @@ class AnimatedThingy < Qt::Label
end
end
-class CPUWaster < Qt::Widget
+class CPUWaster < TQt::Widget
attr_accessor :menubar, :file, :options, :rects, :pb
attr_accessor :td_id , :ld_id, :dl_id, :cl_id, :md_id
attr_accessor :got_stop, :timer_driven, :default_label
@@ -110,10 +110,10 @@ class CPUWaster < Qt::Widget
def initialize(*k)
super(*k)
- @menubar = Qt::MenuBar.new(self, "menu")
+ @menubar = TQt::MenuBar.new(self, "menu")
@pb = nil
- @file = Qt::PopupMenu.new
+ @file = TQt::PopupMenu.new
@menubar.insertItem( "&File", file )
FIRST_DRAW_ITEM.upto(LAST_DRAW_ITEM) {
|i| file.insertItem( "#{drawItemRects(i)} Rectangles", i)
@@ -121,7 +121,7 @@ class CPUWaster < Qt::Widget
connect( menubar, SIGNAL('activated(int)'), self, SLOT('doMenuItem(int)') )
@file.insertSeparator
@file.insertItem("Quit", $qApp, SLOT('quit()'))
- @options = Qt::PopupMenu.new
+ @options = TQt::PopupMenu.new
@menubar.insertItem("&Options", options)
@td_id = options.insertItem("Timer driven", self, SLOT('timerDriven()'))
@ld_id = options.insertItem("Loop driven", self, SLOT('loopDriven()'))
@@ -189,26 +189,26 @@ class CPUWaster < Qt::Widget
@pb.setProgress( @pb.totalSteps - @rects ) if @rects % 100 == 0
@rects -= 1
- painter = Qt::Painter.new(self)
+ painter = TQt::Painter.new(self)
ww = width
wh = height
if ww > 8 and wh > 8
- c = Qt::Color.new(rand(255), rand(255), rand(255))
+ c = TQt::Color.new(rand(255), rand(255), rand(255))
x = rand(ww - 8)
y = rand(wh - 8)
w = rand(ww - x)
h = rand(wh - y)
- painter.fillRect(x, y, w, h, Qt::Brush.new(c))
+ painter.fillRect(x, y, w, h, TQt::Brush.new(c))
end
painter.end()
if @rects == 0 || @got_stop
@pb.setProgress(@pb.totalSteps)
- painter = Qt::Painter.new(self)
- painter.fillRect(0, 0, width(), height(), Qt::Brush.new(backgroundColor))
+ painter = TQt::Painter.new(self)
+ painter.fillRect(0, 0, width(), height(), TQt::Brush.new(backgroundColor))
painter.end()
enableDrawingItems(true)
killTimers()
@@ -217,7 +217,7 @@ class CPUWaster < Qt::Widget
end
def newProgressDialog(label, steps, modal)
- d = Qt::ProgressDialog.new(label, "Cancel", steps, self, "progress", modal)
+ d = TQt::ProgressDialog.new(label, "Cancel", steps, self, "progress", modal)
d.setMinimumDuration(0) if @options.isItemChecked(@md_id)
d.setLabel( AnimatedThingy.new(d, label) ) unless @default_label
d.show
@@ -247,28 +247,28 @@ class CPUWaster < Qt::Widget
lpb = newProgressDialog("Drawing rectangles.\nUsing loop.", n, true)
lpb.setCaption("Please Wait")
- painter = Qt::Painter.new(self)
+ painter = TQt::Painter.new(self)
0.upto(n) { |i|
if (i % 100) == 0
lpb.setProgress(i)
break if lpb.wasCancelled
end
cw, ch = width, height
- c = Qt::Color.new(rand(255), rand(255), rand(255))
+ c = TQt::Color.new(rand(255), rand(255), rand(255))
x = rand(cw - 8)
y = rand(cw - 8)
w = rand(cw - x)
h = rand(cw - y)
- painter.fillRect(x, y, w, h, Qt::Brush.new(c))
+ painter.fillRect(x, y, w, h, TQt::Brush.new(c))
}
lpb.cancel
- painter.fillRect(0, 0, width, height, Qt::Brush.new(backgroundColor))
+ painter.fillRect(0, 0, width, height, TQt::Brush.new(backgroundColor))
painter.end()
end
end
end
-a = Qt::Application.new(ARGV)
+a = TQt::Application.new(ARGV)
w = CPUWaster.new
w.show
a.setMainWidget(w)