diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-12-05 15:55:57 -0600 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-12-05 15:55:57 -0600 |
commit | 9ba04742771370f59740e32e11c5f3a1e6a1b70a (patch) | |
tree | c81c34dae2b3b1ea73801bf18a960265dc4207f7 /qtruby/bin/rbqtsh | |
parent | 1a96c45b22d01378202d9dc7ed9c47acd30f966e (diff) | |
download | tdebindings-9ba04742771370f59740e32e11c5f3a1e6a1b70a.tar.gz tdebindings-9ba04742771370f59740e32e11c5f3a1e6a1b70a.zip |
Initial TQt conversion
Diffstat (limited to 'qtruby/bin/rbqtsh')
-rwxr-xr-x | qtruby/bin/rbqtsh | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/qtruby/bin/rbqtsh b/qtruby/bin/rbqtsh index 0ee674bd..90bf9cae 100755 --- a/qtruby/bin/rbqtsh +++ b/qtruby/bin/rbqtsh @@ -7,13 +7,13 @@ # license: GNU Public License v2 # -require 'stringio' +retquire 'stringio' case File.basename $0 when "rbqtsh" - require 'Qt' + retquire 'Qt' when "rbkdesh" - require 'Korundum' + retquire 'Korundum' end include Qt @@ -224,23 +224,23 @@ $image3_data = "QtQt.d#r#s#s#t#p.T.T.T#u#u.z#e#e#v.o.kQtQtQt"] -class QtShellControl < Qt::MainWindow +class QtShellControl < TQt::MainWindow attr_accessor :menubar, :fileMenu, :helpMenu, :toolBar, :fileName, :fileOpenAction attr_accessor :fileSaveAction, :fileSaveAsAction, :filePrintAction, :fileExitAction attr_accessor :helpExampleAction, :comboBox, :sessionLog, :executedLines, :printer slots 'fileOpen()', 'fileOpen()', 'fileSave()', 'fileSaveAs()' slots 'filePrint()', 'fileExit()', 'runSelection()', 'helpExample()' - signals 'fileNeedsEval(QString)', 'selection(QString)' + signals 'fileNeedsEval(TQString)', 'selection(TQString)' def initialize(*k) super(*k) - image0 = Qt::Pixmap.new($image0_data) - image1 = Qt::Pixmap.new($image1_data) - image2 = Qt::Pixmap.new($image2_data) - image3 = Qt::Pixmap.new($image3_data) + image0 = TQt::Pixmap.new($image0_data) + image1 = TQt::Pixmap.new($image1_data) + image2 = TQt::Pixmap.new($image2_data) + image3 = TQt::Pixmap.new($image3_data) box = VBox.new(self) @sessionLog = TextEdit.new(box, "sessionLog") - @sessionLog.setTextFormat(Qt::RichText) + @sessionLog.setTextFormat(TQt::RichText) @sessionLog.setReadOnly(true) @comboBox = ComboBox.new(box, "comboBox") @comboBox.setEditable(true) @@ -252,50 +252,50 @@ class QtShellControl < Qt::MainWindow def trUtf8(k) return k end - @fileOpenAction = Qt::Action.new(self, "fileOpenAction") - @fileOpenAction.setIconSet(Qt::IconSet.new(image1)) + @fileOpenAction = TQt::Action.new(self, "fileOpenAction") + @fileOpenAction.setIconSet(TQt::IconSet.new(image1)) @fileOpenAction.setText(trUtf8("Open")) @fileOpenAction.setMenuText(trUtf8("&Open...")) @fileOpenAction.setAccel(KeySequence.new(trUtf8("Ctrl+O"))) - @fileSaveAction = Qt::Action.new(self, "fileSaveAction") - @fileSaveAction.setIconSet(Qt::IconSet.new(image2)) + @fileSaveAction = TQt::Action.new(self, "fileSaveAction") + @fileSaveAction.setIconSet(TQt::IconSet.new(image2)) @fileSaveAction.setText(trUtf8("Save")) @fileSaveAction.setMenuText(trUtf8("&Save")) @fileSaveAction.setAccel(KeySequence.new(trUtf8("Ctrl+S"))) - @fileSaveAsAction = Qt::Action.new(self, "fileSaveAsAction") + @fileSaveAsAction = TQt::Action.new(self, "fileSaveAsAction") @fileSaveAsAction.setText(trUtf8("Save As")) @fileSaveAsAction.setMenuText(trUtf8("Save &As...")) @fileSaveAsAction.setAccel(KeySequence.new(trUtf8("Ctrl+A"))) - @filePrintAction = Qt::Action.new(self, "filePrintAction") - @filePrintAction.setIconSet(Qt::IconSet.new(image3)) + @filePrintAction = TQt::Action.new(self, "filePrintAction") + @filePrintAction.setIconSet(TQt::IconSet.new(image3)) @filePrintAction.setText(trUtf8("Print")) @filePrintAction.setMenuText(trUtf8("&Print...")) @filePrintAction.setAccel(KeySequence.new(trUtf8("Ctrl+P"))) - @fileExitAction = Qt::Action.new(self, "fileExitAction") + @fileExitAction = TQt::Action.new(self, "fileExitAction") @fileExitAction.setText(trUtf8("Exit")) @fileExitAction.setMenuText(trUtf8("E&xit")) @fileExitAction.setAccel(KeySequence.new(trUtf8("Ctrl+E"))) - @runAction = Qt::Action.new(self, "runAction"); + @runAction = TQt::Action.new(self, "runAction"); @runAction.setText(trUtf8("Run Selection")); @runAction.setMenuText(trUtf8("&Run Selection")); @runAction.setAccel(KeySequence.new(trUtf8("Ctrl+R"))); - @helpExampleAction = Qt::Action.new(self, "helpExampleAction"); + @helpExampleAction = TQt::Action.new(self, "helpExampleAction"); @helpExampleAction.setText(trUtf8("Example")); @helpExampleAction.setMenuText(trUtf8("Examp&le")); @helpExampleAction.setAccel(KeySequence.new(trUtf8("Ctrl+L"))); - @toolBar = Qt::ToolBar.new("", self, DockTop) + @toolBar = TQt::ToolBar.new("", self, DockTop) @toolBar.setLabel(trUtf8("Tools")) @fileOpenAction.addTo(toolBar) @fileSaveAction.addTo(toolBar) @filePrintAction.addTo(toolBar) - @menubar= Qt::MenuBar.new(self, "menubar") + @menubar= TQt::MenuBar.new(self, "menubar") - @fileMenu= Qt::PopupMenu.new(self) + @fileMenu= TQt::PopupMenu.new(self) @fileOpenAction.addTo(fileMenu) @fileSaveAction.addTo(fileMenu) @fileSaveAsAction.addTo(fileMenu) @@ -307,13 +307,13 @@ class QtShellControl < Qt::MainWindow @menubar.insertSeparator - @runMenu= Qt::PopupMenu.new(self) + @runMenu= TQt::PopupMenu.new(self) @runAction.addTo(@runMenu) @menubar.insertItem(trUtf8("Run"), @runMenu) @menubar.insertSeparator - @helpMenu= Qt::PopupMenu.new(self) + @helpMenu= TQt::PopupMenu.new(self) @helpExampleAction.addTo(helpMenu) @menubar.insertItem(trUtf8("&Help"), helpMenu) @@ -329,7 +329,7 @@ class QtShellControl < Qt::MainWindow end def fileOpen - fname = Qt::FileDialog::getOpenFileName( + fname = TQt::FileDialog::getOpenFileName( ".", "Rbqtsh Session (*.rbqts)", self, @@ -340,7 +340,7 @@ class QtShellControl < Qt::MainWindow end def getFileName - @fileName = Qt::FileDialog::getSaveFileName( + @fileName = TQt::FileDialog::getSaveFileName( ".", "Rbqtsh Session (*.rbqts)", self, @@ -356,12 +356,12 @@ class QtShellControl < Qt::MainWindow file = File.new(fname, "w") if file.nil # TODO fix ": unknown" to give a reason - Qt::MessageBox::critical( + TQt::MessageBox::critical( self, "Error" , "Couldn't open #{fname} for writing: unknown", - Qt::MessageBox::Ok, - Qt::MessageBox::NoButton ) + TQt::MessageBox::Ok, + TQt::MessageBox::NoButton ) return end @executedLines.each { @@ -388,16 +388,16 @@ class QtShellControl < Qt::MainWindow ret = nil if File.exists(fname) cond += 1 - ret = Qt::MessageBox::warning( + ret = TQt::MessageBox::warning( self, "Warning" , "File exists, overwrite ?", - Qt::MessageBox::Yes, - Qt::MessageBox::No ) + TQt::MessageBox::Yes, + TQt::MessageBox::No ) else cond = 0 end - fileSaveAs(cond) if (cond == 0) and ret == Qt::MessageBox::No + fileSaveAs(cond) if (cond == 0) and ret == TQt::MessageBox::No save(fname) end @@ -405,10 +405,10 @@ class QtShellControl < Qt::MainWindow margin = 10 pageNo = 1 emptySession() and return - printer = Qt::Printer.new() + printer = TQt::Printer.new() if printer.setup(self) statusBar().message( "Printing..." ) - p = Qt::Painter.new() + p = TQt::Painter.new() if ! p.begin( printer ) statusBar().message( "An error occured..." ) return @@ -417,7 +417,7 @@ class QtShellControl < Qt::MainWindow p.setFont( sessionLog.font() ) yPos = 0 fm = p.fontMetrics - metrics = Qt::PaintDeviceMetrics.new( printer ) + metrics = TQt::PaintDeviceMetrics.new( printer ) for i in 0..@executedLines.length-1 if margin + yPos > metrics.height() - margin @@ -454,13 +454,13 @@ class QtShellControl < Qt::MainWindow def confirmExit ret = 0 return true if @executedLines.empty? - ret = Qt::MessageBox::warning( + ret = TQt::MessageBox::warning( self, "Warning" , "A session is opened, quit anyway ?", - Qt::MessageBox::Yes, - Qt::MessageBox::No) - return ret != Qt::MessageBox::No + TQt::MessageBox::Yes, + TQt::MessageBox::No) + return ret != TQt::MessageBox::No end def emptySession @@ -479,8 +479,8 @@ class QtShellControl < Qt::MainWindow end -class QtShell < Qt::MainWindow - slots 'evalInput()', 'evalFile(QString)', 'evalSelection(QString)' +class QtShell < TQt::MainWindow + slots 'evalInput()', 'evalFile(TQString)', 'evalSelection(TQString)' attr_accessor :shellWindow @@binding = binding def bind @@ -502,8 +502,8 @@ def initialize(*k) @prompt = '<b><font color="blue">$></font></b>' self.setCaption("MainWindow - this") @shellWindow.sessionLog.setText("Ready.<br>") - connect(@shellWindow, SIGNAL('fileNeedsEval(QString)'), self, SLOT('evalFile(QString)')) - connect(@shellWindow, SIGNAL('selection(QString)'), self, SLOT('evalSelection(QString)')) + connect(@shellWindow, SIGNAL('fileNeedsEval(TQString)'), self, SLOT('evalFile(TQString)')) + connect(@shellWindow, SIGNAL('selection(TQString)'), self, SLOT('evalSelection(TQString)')) end def logAppend(str) @@ -532,8 +532,8 @@ sub PRINT { $me->{widg}->setText( $me->{widg}->text . "<font color=\"$color\">$printed</font>" ); } -#tie *STDOUT, 'Qt::TextHandle', $shw->sessionLog, 'black'; -#tie *STDERR, 'Qt::TextHandle', $shw->sessionLog, 'red'; +#tie *STDOUT, 'TQt::TextHandle', $shw->sessionLog, 'black'; +#tie *STDERR, 'TQt::TextHandle', $shw->sessionLog, 'red'; =end @@ -579,12 +579,12 @@ def evalFile(fname) file = File.open(fname, "r") if file.nil? # TODO use $! -> error message! - Qt::MessageBox::warning( + TQt::MessageBox::warning( self, "Error" , "Couldn't open @{$fn}: $!", - Qt::MessageBox::Ok, - Qt::MessageBox::NoButton) + TQt::MessageBox::Ok, + TQt::MessageBox::NoButton) return end indata = file @@ -602,7 +602,7 @@ end end -app = Qt::Application.new(ARGV) +app = TQt::Application.new(ARGV) w = QtShell.new(nil, "mainWindow") app.setMainWidget(w.shellWindow) app.exec @@ -618,7 +618,7 @@ statusBar.message("Hello World !") self.setCentralWidget(vbox) self.resize(220,240) @vbox.show -@sample = Qt::PopupMenu.new(self) +@sample = TQt::PopupMenu.new(self) $ slots 'there()' @sample.insertItem("&There", self, SLOT('there()')) self.menuBar.insertItem("&Here", sample) |