summaryrefslogtreecommitdiffstats
path: root/qtruby/rubylib/examples/textedit
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-12-05 15:55:57 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-12-05 15:55:57 -0600
commit9ba04742771370f59740e32e11c5f3a1e6a1b70a (patch)
treec81c34dae2b3b1ea73801bf18a960265dc4207f7 /qtruby/rubylib/examples/textedit
parent1a96c45b22d01378202d9dc7ed9c47acd30f966e (diff)
downloadtdebindings-9ba04742771370f59740e32e11c5f3a1e6a1b70a.tar.gz
tdebindings-9ba04742771370f59740e32e11c5f3a1e6a1b70a.zip
Initial TQt conversion
Diffstat (limited to 'qtruby/rubylib/examples/textedit')
-rw-r--r--qtruby/rubylib/examples/textedit/textedit.rb36
1 files changed, 18 insertions, 18 deletions
diff --git a/qtruby/rubylib/examples/textedit/textedit.rb b/qtruby/rubylib/examples/textedit/textedit.rb
index db905b4f..bf496383 100644
--- a/qtruby/rubylib/examples/textedit/textedit.rb
+++ b/qtruby/rubylib/examples/textedit/textedit.rb
@@ -1,18 +1,18 @@
#!/usr/bin/ruby -w
-require 'Qt'
-require 'rexml/document'
+retquire 'Qt'
+retquire 'rexml/document'
-require '../base/rui.rb'
+retquire '../base/rui.rb'
-class MyTextEditor < Qt::TextEdit
+class MyTextEditor < TQt::TextEdit
signals 'saved()'
slots 'insert_icon()', 'new()', 'open()', 'save_as()'
def initialize(w = nil)
@images = {}
@@next_image_id = 0
super(w)
- self.setTextFormat(Qt::RichText)
+ self.setTextFormat(TQt::RichText)
end
def insert_richtext(richtext)
# todo, use a rand string
@@ -25,21 +25,21 @@ class MyTextEditor < Qt::TextEdit
@@next_image_id += 1
end
def load_image(fname, image_id)
- pixmap = Qt::Pixmap.new(fname)
- msfactory = Qt::MimeSourceFactory.defaultFactory
+ pixmap = TQt::Pixmap.new(fname)
+ msfactory = TQt::MimeSourceFactory.defaultFactory
msfactory.setPixmap(image_id, pixmap)
@images[image_id] = fname
image_id
end
def insert_icon
- fname = Qt::FileDialog.getOpenFileName
+ fname = TQt::FileDialog.getOpenFileName
return if fname.nil?
image_id = "image_#{next_image_id}"
load_image(fname, image_id)
insert_richtext('<qt><img source="'+image_id+'"></qt>')
end
def createPopupMenu(pos) # virtual
- pm = Qt::PopupMenu.new
+ pm = TQt::PopupMenu.new
pm.insertItem("Insert Image!", self, SLOT('insert_icon()'))
pm
end
@@ -79,10 +79,10 @@ class MyTextEditor < Qt::TextEdit
self.setText(txt)
end
def open
- fname = Qt::FileDialog.getOpenFileName
+ fname = TQt::FileDialog.getOpenFileName
return if fname.nil?
unless File.exists?(fname)
- Qt::MessageBox.critical(self, "File Does Not Exist", "Sorry, unable to find the requested file!")
+ TQt::MessageBox.critical(self, "File Does Not Exist", "Sorry, unable to find the requested file!")
return
end
return if fname.nil?
@@ -92,10 +92,10 @@ class MyTextEditor < Qt::TextEdit
self.setText(txt)
end
def save_as
- fname = Qt::FileDialog.getSaveFileName
+ fname = TQt::FileDialog.getSaveFileName
return if fname.nil?
if File.exists?(fname)
- Qt::MessageBox.critical(self, "File Already Exists", "Sorry, file already exists. Please choose a non-existing filename!")
+ TQt::MessageBox.critical(self, "File Already Exists", "Sorry, file already exists. Please choose a non-existing filename!")
return save_as
end
file = File.new(fname, "w")
@@ -106,7 +106,7 @@ class MyTextEditor < Qt::TextEdit
end
end
-class MyWidget < Qt::MainWindow
+class MyWidget < TQt::MainWindow
slots 'text_changed()', 'saved()'
def initialize()
super
@@ -114,8 +114,8 @@ class MyWidget < Qt::MainWindow
connect(@editor, SIGNAL('textChanged()'), self, SLOT('text_changed()'))
connect(@editor, SIGNAL('saved()'), self, SLOT('saved()'))
- fileTools = Qt::ToolBar.new(self, "file operations")
- fileMenu = Qt::PopupMenu.new(self)
+ fileTools = TQt::ToolBar.new(self, "file operations")
+ fileMenu = TQt::PopupMenu.new(self)
actions = [
RAction.new("&New", Icons::FILE_NEW, @editor, SLOT('new()'), [fileTools, fileMenu]),
@@ -127,7 +127,7 @@ class MyWidget < Qt::MainWindow
build_actions(actions)
- menubar = Qt::MenuBar.new(self)
+ menubar = TQt::MenuBar.new(self)
menubar.insertItem("&File", fileMenu)
self.setCentralWidget(@editor)
@@ -140,7 +140,7 @@ class MyWidget < Qt::MainWindow
end
end
-a = Qt::Application.new(ARGV)
+a = TQt::Application.new(ARGV)
w = MyWidget.new
w.show