diff options
Diffstat (limited to 'korundum/rubylib/tutorials')
-rw-r--r-- | korundum/rubylib/tutorials/p1/p1.rb | 13 | ||||
-rw-r--r-- | korundum/rubylib/tutorials/p2/p2.rb | 12 | ||||
-rw-r--r-- | korundum/rubylib/tutorials/p3/p3.rb | 61 | ||||
-rw-r--r-- | korundum/rubylib/tutorials/p4/p4.rb | 67 | ||||
-rw-r--r-- | korundum/rubylib/tutorials/p5/p5.rb | 82 | ||||
-rw-r--r-- | korundum/rubylib/tutorials/p6/addurl.sh | 3 | ||||
-rw-r--r-- | korundum/rubylib/tutorials/p6/p6.rb | 26 | ||||
-rw-r--r-- | korundum/rubylib/tutorials/p7/p7.rb | 127 | ||||
-rw-r--r-- | korundum/rubylib/tutorials/p8/p8.rb | 39 | ||||
-rw-r--r-- | korundum/rubylib/tutorials/p9/p9.rb | 110 | ||||
-rw-r--r-- | korundum/rubylib/tutorials/p9/p9ui.rc | 14 |
11 files changed, 554 insertions, 0 deletions
diff --git a/korundum/rubylib/tutorials/p1/p1.rb b/korundum/rubylib/tutorials/p1/p1.rb new file mode 100644 index 00000000..87e5e1b9 --- /dev/null +++ b/korundum/rubylib/tutorials/p1/p1.rb @@ -0,0 +1,13 @@ +require 'Qt'
+
+ a = Qt::Application.new( ARGV )
+
+ hello = Qt::PushButton.new( "Hello world!", nil )
+ hello.resize( 100, 30 )
+
+ Qt::Object::connect( hello, SIGNAL('clicked()'), a, SLOT('quit()') )
+
+ a.setMainWidget( hello )
+ hello.show()
+
+ a.exec()
\ No newline at end of file diff --git a/korundum/rubylib/tutorials/p2/p2.rb b/korundum/rubylib/tutorials/p2/p2.rb new file mode 100644 index 00000000..b2c6d03c --- /dev/null +++ b/korundum/rubylib/tutorials/p2/p2.rb @@ -0,0 +1,12 @@ +require 'Korundum'
+
+ about = KDE::AboutData.new("p2", "Hello World", "0.1")
+ KDE::CmdLineArgs.init(ARGV, about)
+ a = KDE::Application.new()
+ hello = Qt::PushButton.new( a.i18n("Hello World !"), nil )
+ hello.autoResize = true
+
+ a.mainWidget = hello
+ hello.show
+
+ a.exec
\ No newline at end of file diff --git a/korundum/rubylib/tutorials/p3/p3.rb b/korundum/rubylib/tutorials/p3/p3.rb new file mode 100644 index 00000000..fc575878 --- /dev/null +++ b/korundum/rubylib/tutorials/p3/p3.rb @@ -0,0 +1,61 @@ +require 'Korundum'
+
+class MainWindow < KDE::MainWindow
+ slots 'fileOpen()', 'fileSave()'
+
+ def initialize( name )
+ super(nil, name)
+ setCaption("KDE Tutorial - p3")
+
+ filemenu = Qt::PopupMenu.new
+ filemenu.insertItem( i18n( "&Open" ), self, SLOT('fileOpen()') )
+ filemenu.insertItem( i18n( "&Save" ), self, SLOT('fileSave()') )
+ filemenu.insertItem( i18n( "&Quit" ), $kapp, SLOT('quit()') )
+
+ about =
+ i18n("p3 1.0\n\n" +
+ "(C) 1999-2002 Antonio Larrosa Jimenez\n" +
+ "larrosa@kde.org\t\tantlarr@supercable.es\n" +
+ "Malaga (Spain)\n\n" +
+ "Simple KDE Tutorial\n" +
+ "This tutorial comes with ABSOLUTELY NO WARRANTY\n" +
+ "This is free software, and you are welcome to redistribute it\n" +
+ "under certain conditions\n")
+ helpmenu = helpMenu( about )
+
+ menu = menuBar()
+ menu.insertItem( i18n( "&File" ), filemenu )
+ menu.insertSeparator()
+ menu.insertItem( i18n( "&Help" ), helpmenu )
+
+ hello = Qt::TextEdit.new(
+ i18n("<H2>Hello World !</H2><BR>This is a simple" +
+ " window with <I><font size=5><B>R<font color=red" +
+ " size=5>ich </font><font color=blue size=5>Text" +
+ "</font></B></I> capabilities<BR>Try to resize" +
+ " this window, all this is automatic !"), "", self )
+ setCentralWidget(hello)
+ end
+
+ def fileOpen()
+ filename = KDE::FileDialog.getOpenURL( nil, "*", self )
+ msg = i18n("Now this app should open the url #{filename.url()}")
+ KDE::MessageBox.information( nil, msg, i18n( "Information" ),
+ "fileOpenInformationDialog" )
+ end
+
+ def fileSave()
+ filename = KDE::FileDialog.getSaveURL( nil, "*", self )
+ end
+end
+
+ about = KDE::AboutData.new("p3", "Tutorial - p3", "0.1")
+ KDE::CmdLineArgs.init(ARGV, about)
+ a = KDE::Application.new()
+ window = MainWindow.new( "Tutorial - p3" )
+ window.resize( 400, 300 )
+
+ a.mainWidget = window
+ window.show
+
+ a.exec
diff --git a/korundum/rubylib/tutorials/p4/p4.rb b/korundum/rubylib/tutorials/p4/p4.rb new file mode 100644 index 00000000..63777872 --- /dev/null +++ b/korundum/rubylib/tutorials/p4/p4.rb @@ -0,0 +1,67 @@ +require 'Korundum'
+
+class MainWindow < KDE::MainWindow
+ slots 'changeLocation()',
+ 'openURLRequest(const KURL &, const KParts::URLArgs & )'
+
+ def initialize( name )
+ super(nil, name)
+ setCaption("KDE Tutorial - p4")
+
+ filemenu = Qt::PopupMenu.new
+ filemenu.insertItem( i18n( "&Quit" ), $kapp, SLOT( 'quit()' ) )
+ about =
+ i18n("p4 1.0\n\n" +
+ "(C) 1999-2002 Antonio Larrosa Jimenez\n" +
+ "larrosa@kde.org\t\tantlarr@supercable.es\n" +
+ "Malaga (Spain)\n\n" +
+ "Simple KDE Tutorial\n" +
+ "This tutorial comes with ABSOLUTELY NO WARRANTY \n" +
+ "This is free software, and you are welcome to redistribute it\n" +
+ "under certain conditions\n");
+
+ helpmenu = helpMenu(about)
+ menu = menuBar()
+ menu.insertItem( i18n( "&File" ), filemenu)
+ menu.insertSeparator()
+ menu.insertItem(i18n("&Help"), helpmenu)
+
+ vbox = Qt::VBox.new( self )
+
+ @location = Qt::LineEdit.new( vbox )
+ @location.setText( "http://localhost" )
+
+ @browser = KDE::HTMLPart.new( vbox )
+ @browser.openURL( KDE::URL.new(@location.text()) )
+
+ connect( @location , SIGNAL( 'returnPressed()' ),
+ self, SLOT( 'changeLocation()' ) )
+
+ connect( @browser.browserExtension(),
+ SIGNAL( 'openURLRequest( const KURL &, const KParts::URLArgs & )' ),
+ self, SLOT( 'openURLRequest(const KURL &, const KParts::URLArgs & )' ) )
+
+ setCentralWidget(vbox)
+ end
+
+ def changeLocation()
+ @browser.openURL( KDE::URL.new(@location.text()) )
+ end
+
+ def openURLRequest(url, part)
+ @location.text = url.url()
+ changeLocation()
+ end
+end
+
+ about = KDE::AboutData.new("p4", "Tutorial - p4", "0.1")
+ KDE::CmdLineArgs.init(ARGV, about)
+ a = KDE::Application.new()
+
+ window = MainWindow.new( "Tutorial - p4" )
+ window.resize( 300, 200 )
+
+ a.mainWidget = window
+ window.show
+
+ a.exec
\ No newline at end of file diff --git a/korundum/rubylib/tutorials/p5/p5.rb b/korundum/rubylib/tutorials/p5/p5.rb new file mode 100644 index 00000000..8e16c2c8 --- /dev/null +++ b/korundum/rubylib/tutorials/p5/p5.rb @@ -0,0 +1,82 @@ +require 'Korundum'
+
+class MainWindow < KDE::MainWindow
+ slots 'changeLocation()',
+ 'openURLRequest(const KURL &, const KParts::URLArgs & )',
+ 'bookLocation()'
+
+ def initialize( name )
+ super(nil, name)
+ setCaption("KDE Tutorial - p5")
+
+ filemenu = Qt::PopupMenu.new
+ filemenu.insertItem( i18n( "&Quit" ), $kapp, SLOT( 'quit()' ) )
+ about =
+ i18n("p5 1.0\n\n" +
+ "(C) 1999-2002 Antonio Larrosa Jimenez\n" +
+ "larrosa@kde.org\t\tantlarr@supercable.es\n" +
+ "Malaga (Spain)\n\n" +
+ "Simple KDE Tutorial\n" +
+ "This tutorial comes with ABSOLUTELY NO WARRANTY \n" +
+ "This is free software, and you are welcome to redistribute it\n" +
+ "under certain conditions\n");
+
+ helpmenu = helpMenu(about)
+ menu = menuBar()
+ menu.insertItem( i18n( "&File" ), filemenu)
+ menu.insertSeparator()
+ menu.insertItem(i18n("&Help"), helpmenu)
+
+ vbox = Qt::VBox.new( self )
+
+ @location = Qt::LineEdit.new( vbox )
+ @location.setText( "http://localhost" )
+
+ connect( @location , SIGNAL( 'returnPressed()' ),
+ self, SLOT( 'changeLocation()' ) )
+
+ split = Qt::Splitter.new( vbox )
+ split.setOpaqueResize()
+
+ bookmark = Qt::PushButton.new( i18n("Add to Bookmarks"), split );
+
+ connect( bookmark, SIGNAL( 'clicked()' ), self, SLOT( 'bookLocation()' ) )
+
+ @browser = KDE::HTMLPart.new( split )
+ @browser.openURL( KDE::URL.new(@location.text()) )
+
+ connect( @browser.browserExtension(),
+ SIGNAL( 'openURLRequest( const KURL &, const KParts::URLArgs & )' ),
+ self, SLOT( 'openURLRequest(const KURL &, const KParts::URLArgs & )' ) )
+ setCentralWidget(vbox)
+ end
+
+
+ def changeLocation()
+ @browser.openURL( KDE::URL.new(@location.text()) )
+ end
+
+ def openURLRequest(url, part)
+ @location.text = url.url()
+ changeLocation()
+ end
+
+ def bookLocation()
+ dcopRef = KDE::DCOPRef.new("p6", "BookMarkList")
+ if ! dcopRef.add(@location.text())
+ qWarning("Error with DCOP\n")
+ end
+ end
+end
+
+ about = KDE::AboutData.new("p5", "Tutorial - p5", "0.1")
+ KDE::CmdLineArgs.init(ARGV, about)
+ a = KDE::Application.new()
+
+ window = MainWindow.new( "Tutorial - p5" )
+ window.resize( 300, 200 )
+
+ a.mainWidget = window
+ window.show
+
+ a.exec
diff --git a/korundum/rubylib/tutorials/p6/addurl.sh b/korundum/rubylib/tutorials/p6/addurl.sh new file mode 100644 index 00000000..6163dad4 --- /dev/null +++ b/korundum/rubylib/tutorials/p6/addurl.sh @@ -0,0 +1,3 @@ +#!/usr/bin/bash + +dcop p6 BookMarkList add "http://www.kde.org" diff --git a/korundum/rubylib/tutorials/p6/p6.rb b/korundum/rubylib/tutorials/p6/p6.rb new file mode 100644 index 00000000..ea7b2b1e --- /dev/null +++ b/korundum/rubylib/tutorials/p6/p6.rb @@ -0,0 +1,26 @@ +require 'Korundum'
+
+class BookMarkList < KDE::ListView
+ k_dcop 'void add( QString )'
+
+ def initialize()
+ super(nil, "Bookmarks")
+ addColumn( i18n("My Bookmarks") );
+ end
+
+ def add( s )
+ insertItem( KDE::ListViewItem.new( self , s ) )
+ end
+end
+
+ about = KDE::AboutData.new("p6", "Tutorial - p6", "0.1")
+ KDE::CmdLineArgs.init(ARGV, about)
+ a = KDE::UniqueApplication.new()
+
+ mylist = BookMarkList.new
+ mylist.resize( 300, 200 )
+
+ a.mainWidget = mylist
+ mylist.show
+
+ a.exec
\ No newline at end of file diff --git a/korundum/rubylib/tutorials/p7/p7.rb b/korundum/rubylib/tutorials/p7/p7.rb new file mode 100644 index 00000000..650f4db5 --- /dev/null +++ b/korundum/rubylib/tutorials/p7/p7.rb @@ -0,0 +1,127 @@ +require 'Korundum'
+
+class Browser < KDE::MainWindow
+ k_dcop 'void setURL(QString)'
+
+ slots 'fileSetDefaultPage()',
+ 'changeLocation()',
+ 'bookLocation()',
+ 'gotoPreviousPage()',
+ 'openURLRequest(const KURL&, const KParts::URLArgs&)'
+
+ TOOLBAR_ID_ADDBOOKMARK = 1
+ TOOLBAR_ID_BACK = 2
+ TOOLBAR_ID_QUIT = 3
+
+ def initialize( name )
+ super(nil, name)
+ setCaption("KDE Tutorial - p7")
+ @history = []
+
+ filemenu = Qt::PopupMenu.new
+ filemenu.insertItem( i18n( "&Set default page" ),
+ self, SLOT( 'fileSetDefaultPage()' ) )
+ filemenu.insertItem(i18n( "&Quit" ), $kapp, SLOT( 'quit()' ))
+ about =
+ i18n("p7 1.0\n\n" +
+ "(C) 1999-2002 Antonio Larrosa Jimenez\n" +
+ "larrosa@kde.org\t\tantlarr@supercable.es\n" +
+ "Malaga (Spain)\n\n" +
+ "Simple KDE Tutorial\n" +
+ "This tutorial comes with ABSOLUTELY NO WARRANTY \n" +
+ "This is free software, and you are welcome to redistribute it\n" +
+ "under certain conditions\n");
+
+ helpmenu = helpMenu(about)
+ menu = menuBar()
+ menu.insertItem( i18n( "&File" ), filemenu)
+ menu.insertSeparator()
+ menu.insertItem(i18n("&Help"), helpmenu)
+
+ toolbar = KDE::ToolBar.new(self)
+
+ icons = KDE::IconLoader.new()
+ toolbar.insertButton(icons.loadIcon("reload", KDE::Icon::Toolbar), TOOLBAR_ID_ADDBOOKMARK,
+ SIGNAL('clicked(int)'),self,SLOT('bookLocation()'),true,
+ i18n("Add to Bookmarks"))
+ toolbar.insertButton(icons.loadIcon("back", KDE::Icon::Toolbar), TOOLBAR_ID_BACK,
+ SIGNAL('clicked(int)'),self,SLOT('gotoPreviousPage()'),
+ false, i18n("Back to previous page"))
+ toolbar.insertButton(icons.loadIcon("exit", KDE::Icon::Toolbar), TOOLBAR_ID_QUIT,
+ SIGNAL('clicked(int)'),$kapp,SLOT('quit()'),true,
+ i18n("Quit the application"))
+ addToolBar(toolbar)
+
+ vbox = Qt::VBox.new( self )
+
+ @location = Qt::LineEdit.new( vbox )
+
+ config = $kapp.config()
+ config.setGroup("Settings")
+ @location.text = config.readEntry( "defaultPage", "http://localhost")
+
+ connect( @location , SIGNAL( 'returnPressed()' ),
+ self, SLOT( 'changeLocation()' ) )
+
+ split = Qt::Splitter.new( vbox )
+ split.setOpaqueResize()
+
+ @browser = KDE::HTMLPart.new( split )
+ @browser.openURL( KDE::URL.new(@location.text()) )
+
+ connect( @browser.browserExtension(),
+ SIGNAL( 'openURLRequest( const KURL&, const KParts::URLArgs& )' ),
+ self, SLOT( 'openURLRequest(const KURL&, const KParts::URLArgs& )' ) )
+ setCentralWidget(vbox)
+ end
+
+ def changeLocation()
+ @history.push( @browser.url().url() );
+ toolBar().setItemEnabled( TOOLBAR_ID_BACK, true)
+ @browser.openURL( KDE::URL.new(@location.text()) )
+ end
+
+ def setURL( url )
+ @location.text = url
+ changeLocation()
+ end
+
+ def openURLRequest(url, part)
+ setURL( url.url() )
+ end
+
+ def gotoPreviousPage()
+ @location.text = @history.pop()
+ if @history.empty?
+ toolBar().setItemEnabled(TOOLBAR_ID_BACK, false)
+ end
+ @browser.openURL( KDE::URL.new(@location.text()) )
+ end
+
+ def bookLocation()
+ dcopRef = KDE::DCOPRef.new("p8", "BookMarkList")
+ if ! dcopRef.add(@location.text())
+ qWarning("Error with DCOP\n")
+ end
+ end
+
+ def fileSetDefaultPage()
+ config = $kapp.config()
+
+ config.group = "Settings"
+ config.writeEntry( "defaultPage", @browser.url().url() )
+ end
+end
+
+ about = KDE::AboutData.new("p7", "Tutorial - p7", "0.1")
+ KDE::CmdLineArgs.init(ARGV, about)
+ a = KDE::UniqueApplication.new()
+
+ window = Browser.new( "Tutorial - p7" )
+ window.resize( 300, 200 )
+
+ a.mainWidget = window
+ window.show
+
+ a.exec
+
diff --git a/korundum/rubylib/tutorials/p8/p8.rb b/korundum/rubylib/tutorials/p8/p8.rb new file mode 100644 index 00000000..711fe021 --- /dev/null +++ b/korundum/rubylib/tutorials/p8/p8.rb @@ -0,0 +1,39 @@ +require 'Korundum'
+
+class BookMarkList < KDE::ListView
+ k_dcop 'void add(QString)'
+
+ slots 'setURLInBrowser(QListViewItem *)'
+
+ def initialize()
+ super(nil, "Bookmarks")
+ addColumn( i18n("My Bookmarks") );
+ connect( self, SIGNAL('clicked(QListViewItem *)'),
+ self, SLOT('setURLInBrowser(QListViewItem *)'))
+ end
+
+ def add( s )
+ insertItem( KDE::ListViewItem.new( self , s ) )
+ end
+
+ def setURLInBrowser( item )
+ if item.nil? then return end
+ dcopRef = KDE::DCOPRef.new("p7", "Browser")
+ if ! dcopRef.setURL(item.text(0))
+ qWarning("Error with DCOP\n")
+ end
+ end
+end
+
+ about = KDE::AboutData.new("p8", "Tutorial - p8", "0.1")
+ KDE::CmdLineArgs.init(ARGV, about)
+ a = KDE::UniqueApplication.new()
+
+ mylist = BookMarkList.new
+ mylist.resize( 300, 200 )
+
+ a.mainWidget = mylist
+ mylist.show
+
+ a.exec
+
diff --git a/korundum/rubylib/tutorials/p9/p9.rb b/korundum/rubylib/tutorials/p9/p9.rb new file mode 100644 index 00000000..98bb9d0e --- /dev/null +++ b/korundum/rubylib/tutorials/p9/p9.rb @@ -0,0 +1,110 @@ +require 'Korundum'
+
+class Browser < KDE::MainWindow
+ k_dcop 'void setURL(QString)'
+
+ slots 'fileSetDefaultPage()',
+ 'changeLocation()',
+ 'bookLocation()',
+ 'gotoPreviousPage()',
+ 'openURLRequest(const KURL&, const KParts::URLArgs&)'
+
+ def initialize( name )
+ super(nil, name)
+ @history = []
+
+ KDE::StdAction.quit(self, SLOT('close()'), actionCollection())
+
+ KDE::Action.new(i18n("&Set default page"), "gohome", KDE::Shortcut.new(0), self,
+ SLOT('fileSetDefaultPage()'), actionCollection(), "set_default_page")
+
+ KDE::Action.new(i18n("Add to Bookmarks"), "reload", KDE::Shortcut.new(0), self,
+ SLOT('bookLocation()'), actionCollection(), "add_to_bookmarks")
+
+ KDE::Action.new(i18n("Back to previous page"), "back", KDE::Shortcut.new(0), self,
+ SLOT('gotoPreviousPage()'), actionCollection(), "back")
+
+ actionCollection().action("back").setEnabled(false)
+
+ createGUI(Dir.getwd + "/p9ui.rc")
+
+ vbox = Qt::VBox.new( self )
+
+ @location = Qt::LineEdit.new( vbox )
+
+ config = $kapp.config()
+ config.setGroup("Settings")
+ @location.text = config.readEntry( "defaultPage", "http://localhost")
+
+ connect( @location , SIGNAL( 'returnPressed()' ),
+ self, SLOT( 'changeLocation()' ) )
+
+ @browser = KDE::HTMLPart.new( vbox )
+ @browser.openURL( KDE::URL.new(@location.text()) )
+
+ connect( @browser.browserExtension(),
+ SIGNAL( 'openURLRequest( const KURL&, const KParts::URLArgs& )' ),
+ self, SLOT( 'openURLRequest(const KURL&, const KParts::URLArgs& )' ) )
+ setCentralWidget(vbox)
+ end
+
+
+ def changeLocation()
+ @history.push( @browser.url().url() );
+ actionCollection().action("back").setEnabled(true)
+ @browser.openURL( KDE::URL.new(@location.text()) )
+ end
+
+ def setURL( url )
+ @location.text = url
+ changeLocation()
+ end
+
+ def openURLRequest(url, part)
+ setURL( url.url() )
+ end
+
+ def gotoPreviousPage()
+ @location.text = @history.pop()
+ if @history.empty?
+ actionCollection().action("back").setEnabled(false)
+ end
+ @browser.openURL( KDE::URL.new(@location.text()) )
+ end
+
+ def bookLocation()
+ dcopRef = KDE::DCOPRef.new("p8", "BookMarkList")
+ if ! dcopRef.add(@location.text())
+ qWarning("Error with DCOP\n")
+ end
+ end
+
+ def fileSetDefaultPage()
+ config = $kapp.config()
+
+ config.group = "Settings"
+ config.writeEntry( "defaultPage", @browser.url().url() )
+ end
+end
+
+ aboutdata = KDE::AboutData.new("p9", "Tutorial - p9",
+ "1.0", "Step 9 of a simple tutorial", KDE::AboutData::License_GPL,
+ "(C) 2000, 2001 Antonio Larrosa Jimenez","",
+ "http://devel-home.kde.org/~larrosa/tutorial.html")
+ aboutdata.addAuthor("Antonio Larrosa Jimenez",
+ "Original Developer/Mantainer","larrosa@kde.org",
+ "http://devel-home.kde.org/~larrosa/index.html")
+ aboutdata.addAuthor("Richard Dale",
+ "Ruby port","Richard_Dale@tipitina.demon.co.uk",
+ "")
+ KDE::CmdLineArgs.init(ARGV, aboutdata)
+
+ a = KDE::UniqueApplication.new()
+
+ window = Browser.new( "Tutorial - p9" )
+ window.resize( 300, 200 )
+
+ a.mainWidget = window
+ window.show
+
+ a.exec
diff --git a/korundum/rubylib/tutorials/p9/p9ui.rc b/korundum/rubylib/tutorials/p9/p9ui.rc new file mode 100644 index 00000000..9e194c20 --- /dev/null +++ b/korundum/rubylib/tutorials/p9/p9ui.rc @@ -0,0 +1,14 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd" >
+<kpartgui name="p9" version="1">
+<MenuBar>
+ <Menu name="file"><text>&File</text>
+ <Action name="set_default_page"/>
+ </Menu>
+</MenuBar>
+<ToolBar fullWidth="true" name="mainToolBar">
+ <Action name="add_to_bookmarks"/>
+ <Action name="back"/>
+ <Separator/>
+ <Action name="file_quit"/>
+</ToolBar>
+</kpartgui>
\ No newline at end of file |