summaryrefslogtreecommitdiffstats
path: root/qtruby/rubylib/designer/examples
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit90825e2392b2d70e43c7a25b8a3752299a933894 (patch)
treee33aa27f02b74604afbfd0ea4f1cfca8833d882a /qtruby/rubylib/designer/examples
downloadtdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz
tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'qtruby/rubylib/designer/examples')
-rw-r--r--qtruby/rubylib/designer/examples/colortool/Makefile30
-rw-r--r--qtruby/rubylib/designer/examples/colortool/README8
-rw-r--r--qtruby/rubylib/designer/examples/colortool/colornameform.ui168
-rw-r--r--qtruby/rubylib/designer/examples/colortool/colornameform.ui.rb19
-rw-r--r--qtruby/rubylib/designer/examples/colortool/findform.ui141
-rw-r--r--qtruby/rubylib/designer/examples/colortool/findform.ui.rb11
-rw-r--r--qtruby/rubylib/designer/examples/colortool/images/editcopybin0 -> 268 bytes
-rw-r--r--qtruby/rubylib/designer/examples/colortool/images/editcopy.pngbin0 -> 187 bytes
-rw-r--r--qtruby/rubylib/designer/examples/colortool/images/editcutbin0 -> 214 bytes
-rw-r--r--qtruby/rubylib/designer/examples/colortool/images/editcut.pngbin0 -> 179 bytes
-rw-r--r--qtruby/rubylib/designer/examples/colortool/images/editraise.pngbin0 -> 489 bytes
-rw-r--r--qtruby/rubylib/designer/examples/colortool/images/filenewbin0 -> 184 bytes
-rw-r--r--qtruby/rubylib/designer/examples/colortool/images/filenew.pngbin0 -> 128 bytes
-rw-r--r--qtruby/rubylib/designer/examples/colortool/images/fileopenbin0 -> 231 bytes
-rw-r--r--qtruby/rubylib/designer/examples/colortool/images/fileopen.pngbin0 -> 178 bytes
-rw-r--r--qtruby/rubylib/designer/examples/colortool/images/filesavebin0 -> 230 bytes
-rw-r--r--qtruby/rubylib/designer/examples/colortool/images/filesave.pngbin0 -> 158 bytes
-rw-r--r--qtruby/rubylib/designer/examples/colortool/images/iconview.pngbin0 -> 898 bytes
-rw-r--r--qtruby/rubylib/designer/examples/colortool/images/richtextedit.pngbin0 -> 878 bytes
-rw-r--r--qtruby/rubylib/designer/examples/colortool/images/searchfindbin0 -> 658 bytes
-rw-r--r--qtruby/rubylib/designer/examples/colortool/images/searchfind.pngbin0 -> 554 bytes
-rw-r--r--qtruby/rubylib/designer/examples/colortool/images/table.pngbin0 -> 407 bytes
-rw-r--r--qtruby/rubylib/designer/examples/colortool/images/tabwidget.pngbin0 -> 545 bytes
-rw-r--r--qtruby/rubylib/designer/examples/colortool/images/widgetstack.pngbin0 -> 664 bytes
-rw-r--r--qtruby/rubylib/designer/examples/colortool/main.rb20
-rw-r--r--qtruby/rubylib/designer/examples/colortool/mainform.ui601
-rw-r--r--qtruby/rubylib/designer/examples/colortool/mainform.ui.rb530
-rw-r--r--qtruby/rubylib/designer/examples/colortool/optionsform.ui153
28 files changed, 1681 insertions, 0 deletions
diff --git a/qtruby/rubylib/designer/examples/colortool/Makefile b/qtruby/rubylib/designer/examples/colortool/Makefile
new file mode 100644
index 00000000..df79b963
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/Makefile
@@ -0,0 +1,30 @@
+RBUIC=rbuic
+
+RBUICIMPLS=mainform.rb optionsform.rb colornameform.rb \
+ findform.rb qmake_image_collection.rb
+
+all: $(RBUICIMPLS)
+
+mainform.rb:
+ $(RBUIC) mainform.ui -o mainform.rb
+
+optionsform.rb: optionsform.ui
+ $(RBUIC) optionsform.ui -o optionsform.rb
+
+colornameform.rb: colornameform.ui
+ $(RBUIC) colornameform.ui -o colornameform.rb
+
+findform.rb: findform.ui
+ $(RBUIC) findform.ui -o findform.rb
+
+qmake_image_collection.rb:
+ $(RBUIC) -embed colortool images/filenew.png images/fileopen.png \
+ images/filesave.png images/editcut.png images/editcopy.png \
+ images/searchfind.png images/tabwidget.png images/table.png \
+ images/iconview.png images/richtextedit.png images/widgetstack.png \
+ images/editraise.png -o qmake_image_collection.rb
+
+clean:
+ rm -f $(RBUICIMPLS)
+
+
diff --git a/qtruby/rubylib/designer/examples/colortool/README b/qtruby/rubylib/designer/examples/colortool/README
new file mode 100644
index 00000000..99d2174b
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/README
@@ -0,0 +1,8 @@
+This is the Qt Designer Tutorial 'Creating Dialogs' translated into QtRuby. It
+shows how you can combine ruby code generated from .ui files with the rbuic
+tool, with your own code.
+
+The .ui files and images are identical to the original C++ versions.
+
+It features a simple Makefile to run rbuic when you change the .ui files, and
+regenerate the ruby sources.
diff --git a/qtruby/rubylib/designer/examples/colortool/colornameform.ui b/qtruby/rubylib/designer/examples/colortool/colornameform.ui
new file mode 100644
index 00000000..50f2d6de
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/colornameform.ui
@@ -0,0 +1,168 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>ColorNameForm</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>ColorNameForm</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>348</width>
+ <height>105</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Color Tool - Color Name</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>colorLabel</cstring>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="pixmap">
+ <pixmap>editraise.png</pixmap>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout4</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Name:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>colorLineEdit</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit">
+ <property name="name">
+ <cstring>colorLineEdit</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout4</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>0</width>
+ <height>11</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>okPushButton</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>cancelPushButton</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ </hbox>
+</widget>
+<connections>
+ <connection>
+ <sender>cancelPushButton</sender>
+ <signal>clicked()</signal>
+ <receiver>ColorNameForm</receiver>
+ <slot>reject()</slot>
+ </connection>
+ <connection>
+ <sender>okPushButton</sender>
+ <signal>clicked()</signal>
+ <receiver>ColorNameForm</receiver>
+ <slot>validate()</slot>
+ </connection>
+</connections>
+<includes>
+ <include location="local" impldecl="in implementation">colornameform.ui.h</include>
+</includes>
+<slots>
+ <slot>validate()</slot>
+</slots>
+<functions>
+ <function>setColors( const QMap&lt;QString, QColor&gt; &amp; colors )</function>
+</functions>
+<pixmapinproject/>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/qtruby/rubylib/designer/examples/colortool/colornameform.ui.rb b/qtruby/rubylib/designer/examples/colortool/colornameform.ui.rb
new file mode 100644
index 00000000..db671b77
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/colornameform.ui.rb
@@ -0,0 +1,19 @@
+class ColorNameForm
+
+@colors = {}
+
+def setColors( colors )
+ @colors = colors
+end
+
+def validate()
+ name = @colorLineEdit.text()
+ if ! name.empty? &&
+ ( @colors.empty? || ! @colors.has_key?( name ) )
+ accept()
+ else
+ @colorLineEdit.selectAll()
+ end
+end
+
+end
diff --git a/qtruby/rubylib/designer/examples/colortool/findform.ui b/qtruby/rubylib/designer/examples/colortool/findform.ui
new file mode 100644
index 00000000..3e627945
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/findform.ui
@@ -0,0 +1,141 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>FindForm</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>FindForm</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>301</width>
+ <height>99</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Color Tool - Find Color</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout11</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Look for:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>findLineEdit</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit">
+ <property name="name">
+ <cstring>findLineEdit</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout10</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer7</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>0</width>
+ <height>9</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>findPushButton</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Find</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>closePushButton</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Close</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+</widget>
+<connections>
+ <connection>
+ <sender>closePushButton</sender>
+ <signal>clicked()</signal>
+ <receiver>FindForm</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>findPushButton</sender>
+ <signal>clicked()</signal>
+ <receiver>FindForm</receiver>
+ <slot>find()</slot>
+ </connection>
+</connections>
+<includes>
+ <include location="local" impldecl="in implementation">findform.ui.h</include>
+</includes>
+<signals>
+ <signal>lookfor(const QString&amp;)</signal>
+</signals>
+<slots>
+ <slot>find()</slot>
+</slots>
+<functions>
+ <function>notfound()</function>
+</functions>
+<pixmapinproject/>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/qtruby/rubylib/designer/examples/colortool/findform.ui.rb b/qtruby/rubylib/designer/examples/colortool/findform.ui.rb
new file mode 100644
index 00000000..6bfb4f0a
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/findform.ui.rb
@@ -0,0 +1,11 @@
+class FindForm
+
+def find()
+ emit lookfor( @findLineEdit.text() )
+end
+
+def notfound()
+ @findLineEdit.selectAll()
+end
+
+end
diff --git a/qtruby/rubylib/designer/examples/colortool/images/editcopy b/qtruby/rubylib/designer/examples/colortool/images/editcopy
new file mode 100644
index 00000000..7b334ca4
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/images/editcopy
Binary files differ
diff --git a/qtruby/rubylib/designer/examples/colortool/images/editcopy.png b/qtruby/rubylib/designer/examples/colortool/images/editcopy.png
new file mode 100644
index 00000000..abfe86e2
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/images/editcopy.png
Binary files differ
diff --git a/qtruby/rubylib/designer/examples/colortool/images/editcut b/qtruby/rubylib/designer/examples/colortool/images/editcut
new file mode 100644
index 00000000..60abc586
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/images/editcut
Binary files differ
diff --git a/qtruby/rubylib/designer/examples/colortool/images/editcut.png b/qtruby/rubylib/designer/examples/colortool/images/editcut.png
new file mode 100644
index 00000000..98efe27a
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/images/editcut.png
Binary files differ
diff --git a/qtruby/rubylib/designer/examples/colortool/images/editraise.png b/qtruby/rubylib/designer/examples/colortool/images/editraise.png
new file mode 100644
index 00000000..02415689
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/images/editraise.png
Binary files differ
diff --git a/qtruby/rubylib/designer/examples/colortool/images/filenew b/qtruby/rubylib/designer/examples/colortool/images/filenew
new file mode 100644
index 00000000..9de6e839
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/images/filenew
Binary files differ
diff --git a/qtruby/rubylib/designer/examples/colortool/images/filenew.png b/qtruby/rubylib/designer/examples/colortool/images/filenew.png
new file mode 100644
index 00000000..8577f068
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/images/filenew.png
Binary files differ
diff --git a/qtruby/rubylib/designer/examples/colortool/images/fileopen b/qtruby/rubylib/designer/examples/colortool/images/fileopen
new file mode 100644
index 00000000..a21f9466
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/images/fileopen
Binary files differ
diff --git a/qtruby/rubylib/designer/examples/colortool/images/fileopen.png b/qtruby/rubylib/designer/examples/colortool/images/fileopen.png
new file mode 100644
index 00000000..85dab435
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/images/fileopen.png
Binary files differ
diff --git a/qtruby/rubylib/designer/examples/colortool/images/filesave b/qtruby/rubylib/designer/examples/colortool/images/filesave
new file mode 100644
index 00000000..f6d9af92
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/images/filesave
Binary files differ
diff --git a/qtruby/rubylib/designer/examples/colortool/images/filesave.png b/qtruby/rubylib/designer/examples/colortool/images/filesave.png
new file mode 100644
index 00000000..21309aa6
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/images/filesave.png
Binary files differ
diff --git a/qtruby/rubylib/designer/examples/colortool/images/iconview.png b/qtruby/rubylib/designer/examples/colortool/images/iconview.png
new file mode 100644
index 00000000..d755399d
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/images/iconview.png
Binary files differ
diff --git a/qtruby/rubylib/designer/examples/colortool/images/richtextedit.png b/qtruby/rubylib/designer/examples/colortool/images/richtextedit.png
new file mode 100644
index 00000000..9f75c258
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/images/richtextedit.png
Binary files differ
diff --git a/qtruby/rubylib/designer/examples/colortool/images/searchfind b/qtruby/rubylib/designer/examples/colortool/images/searchfind
new file mode 100644
index 00000000..7aaefe22
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/images/searchfind
Binary files differ
diff --git a/qtruby/rubylib/designer/examples/colortool/images/searchfind.png b/qtruby/rubylib/designer/examples/colortool/images/searchfind.png
new file mode 100644
index 00000000..8f7d8adb
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/images/searchfind.png
Binary files differ
diff --git a/qtruby/rubylib/designer/examples/colortool/images/table.png b/qtruby/rubylib/designer/examples/colortool/images/table.png
new file mode 100644
index 00000000..663b32f0
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/images/table.png
Binary files differ
diff --git a/qtruby/rubylib/designer/examples/colortool/images/tabwidget.png b/qtruby/rubylib/designer/examples/colortool/images/tabwidget.png
new file mode 100644
index 00000000..3a160446
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/images/tabwidget.png
Binary files differ
diff --git a/qtruby/rubylib/designer/examples/colortool/images/widgetstack.png b/qtruby/rubylib/designer/examples/colortool/images/widgetstack.png
new file mode 100644
index 00000000..979409cf
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/images/widgetstack.png
Binary files differ
diff --git a/qtruby/rubylib/designer/examples/colortool/main.rb b/qtruby/rubylib/designer/examples/colortool/main.rb
new file mode 100644
index 00000000..9ebe84cb
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/main.rb
@@ -0,0 +1,20 @@
+require 'Qt'
+
+require 'mainform.rb'
+require 'mainform.ui.rb'
+
+require 'colornameform.rb'
+require 'colornameform.ui.rb'
+
+require 'optionsform.rb'
+
+require 'findform.rb'
+require 'findform.ui.rb'
+
+require 'qmake_image_collection.rb'
+
+a = Qt::Application.new(ARGV)
+w = MainForm.new
+a.mainWidget = w
+w.show
+a.exec
diff --git a/qtruby/rubylib/designer/examples/colortool/mainform.ui b/qtruby/rubylib/designer/examples/colortool/mainform.ui
new file mode 100644
index 00000000..6c89baca
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/mainform.ui
@@ -0,0 +1,601 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>MainForm</class>
+<widget class="QMainWindow">
+ <property name="name">
+ <cstring>MainForm</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>600</width>
+ <height>480</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Color Tool</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QWidgetStack">
+ <property name="name">
+ <cstring>colorWidgetStack</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tablePage</cstring>
+ </property>
+ <attribute name="id">
+ <number>0</number>
+ </attribute>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QTable">
+ <column>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Hex</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Web</string>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>colorTable</cstring>
+ </property>
+ <property name="numRows">
+ <number>0</number>
+ </property>
+ <property name="numCols">
+ <number>3</number>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>iconsPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>1</number>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QIconView">
+ <property name="name">
+ <cstring>colorIconView</cstring>
+ </property>
+ <property name="gridX">
+ <number>100</number>
+ </property>
+ <property name="resizeMode">
+ <enum>Adjust</enum>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </widget>
+ </hbox>
+</widget>
+<menubar>
+ <property name="name">
+ <cstring>menubar</cstring>
+ </property>
+ <item text="&amp;File" name="fileMenu">
+ <action name="fileNewAction"/>
+ <action name="fileOpenAction"/>
+ <action name="fileSaveAction"/>
+ <action name="fileSaveAsAction"/>
+ <separator/>
+ <action name="fileExitAction"/>
+ </item>
+ <item text="&amp;Edit" name="editMenu">
+ <action name="editAddAction"/>
+ <action name="editCutAction"/>
+ <action name="editCopyAction"/>
+ <separator/>
+ <action name="editFindAction"/>
+ <separator/>
+ <action name="optionsAction"/>
+ </item>
+ <item text="&amp;View" name="viewMenu">
+ <action name="viewTableAction"/>
+ <action name="viewIconsAction"/>
+ </item>
+ <item text="&amp;Help" name="helpMenu">
+ <action name="helpContentsAction"/>
+ <action name="helpIndexAction"/>
+ <separator/>
+ <action name="helpAboutAction"/>
+ </item>
+</menubar>
+<toolbars>
+ <toolbar dock="2">
+ <property name="name">
+ <cstring>toolBar</cstring>
+ </property>
+ <property name="label">
+ <string>Tools</string>
+ </property>
+ <action name="fileNewAction"/>
+ <action name="fileOpenAction"/>
+ <action name="fileSaveAction"/>
+ <separator/>
+ <action name="editAddAction"/>
+ <action name="editCutAction"/>
+ <action name="editCopyAction"/>
+ <action name="editFindAction"/>
+ <separator/>
+ <action name="optionsAction"/>
+ <separator/>
+ <action name="viewTableAction"/>
+ <action name="viewIconsAction"/>
+ </toolbar>
+</toolbars>
+<actions>
+ <action>
+ <property name="name">
+ <cstring>fileNewAction</cstring>
+ </property>
+ <property name="iconSet">
+ <iconset>filenew.png</iconset>
+ </property>
+ <property name="text">
+ <string>New</string>
+ </property>
+ <property name="menuText">
+ <string>&amp;New</string>
+ </property>
+ <property name="accel">
+ <string>Ctrl+N</string>
+ </property>
+ </action>
+ <action>
+ <property name="name">
+ <cstring>fileOpenAction</cstring>
+ </property>
+ <property name="iconSet">
+ <iconset>fileopen.png</iconset>
+ </property>
+ <property name="text">
+ <string>Open</string>
+ </property>
+ <property name="menuText">
+ <string>&amp;Open...</string>
+ </property>
+ <property name="accel">
+ <string>Ctrl+O</string>
+ </property>
+ </action>
+ <action>
+ <property name="name">
+ <cstring>fileSaveAction</cstring>
+ </property>
+ <property name="iconSet">
+ <iconset>filesave.png</iconset>
+ </property>
+ <property name="text">
+ <string>Save</string>
+ </property>
+ <property name="menuText">
+ <string>&amp;Save</string>
+ </property>
+ <property name="accel">
+ <string>Ctrl+S</string>
+ </property>
+ </action>
+ <action>
+ <property name="name">
+ <cstring>fileSaveAsAction</cstring>
+ </property>
+ <property name="text">
+ <string>Save As</string>
+ </property>
+ <property name="menuText">
+ <string>Save &amp;As...</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ </action>
+ <action>
+ <property name="name">
+ <cstring>fileExitAction</cstring>
+ </property>
+ <property name="text">
+ <string>Exit</string>
+ </property>
+ <property name="menuText">
+ <string>E&amp;xit</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ </action>
+ <action>
+ <property name="name">
+ <cstring>editCutAction</cstring>
+ </property>
+ <property name="iconSet">
+ <iconset>editcut.png</iconset>
+ </property>
+ <property name="text">
+ <string>Delete</string>
+ </property>
+ <property name="menuText">
+ <string>&amp;Delete</string>
+ </property>
+ <property name="accel">
+ <string>Ctrl+X</string>
+ </property>
+ </action>
+ <action>
+ <property name="name">
+ <cstring>editCopyAction</cstring>
+ </property>
+ <property name="iconSet">
+ <iconset>editcopy.png</iconset>
+ </property>
+ <property name="text">
+ <string>Copy</string>
+ </property>
+ <property name="menuText">
+ <string>&amp;Copy</string>
+ </property>
+ <property name="accel">
+ <string>Ctrl+C</string>
+ </property>
+ </action>
+ <action>
+ <property name="name">
+ <cstring>editFindAction</cstring>
+ </property>
+ <property name="iconSet">
+ <iconset>searchfind.png</iconset>
+ </property>
+ <property name="text">
+ <string>Find</string>
+ </property>
+ <property name="menuText">
+ <string>&amp;Find...</string>
+ </property>
+ <property name="accel">
+ <string>Ctrl+F</string>
+ </property>
+ </action>
+ <action>
+ <property name="name">
+ <cstring>helpContentsAction</cstring>
+ </property>
+ <property name="text">
+ <string>Contents</string>
+ </property>
+ <property name="menuText">
+ <string>&amp;Contents...</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ </action>
+ <action>
+ <property name="name">
+ <cstring>helpIndexAction</cstring>
+ </property>
+ <property name="text">
+ <string>Index</string>
+ </property>
+ <property name="menuText">
+ <string>&amp;Index...</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ </action>
+ <action>
+ <property name="name">
+ <cstring>helpAboutAction</cstring>
+ </property>
+ <property name="text">
+ <string>About</string>
+ </property>
+ <property name="menuText">
+ <string>&amp;About</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ </action>
+ <action>
+ <property name="name">
+ <cstring>optionsAction</cstring>
+ </property>
+ <property name="iconSet">
+ <iconset>tabwidget.png</iconset>
+ </property>
+ <property name="text">
+ <string>Options</string>
+ </property>
+ <property name="menuText">
+ <string>&amp;Options...</string>
+ </property>
+ </action>
+ <actiongroup>
+ <property name="name">
+ <cstring>viewActionGroup</cstring>
+ </property>
+ <property name="text">
+ <string>View</string>
+ </property>
+ <property name="menuText">
+ <string>View</string>
+ </property>
+ <property name="usesDropDown">
+ <bool>false</bool>
+ </property>
+ <action>
+ <property name="name">
+ <cstring>viewTableAction</cstring>
+ </property>
+ <property name="toggleAction">
+ <bool>true</bool>
+ </property>
+ <property name="on">
+ <bool>true</bool>
+ </property>
+ <property name="iconSet">
+ <iconset>table.png</iconset>
+ </property>
+ <property name="text">
+ <string>View Table</string>
+ </property>
+ <property name="menuText">
+ <string>View &amp;Table</string>
+ </property>
+ <property name="toolTip">
+ <string>View Table (Ctrl+T)</string>
+ </property>
+ <property name="accel">
+ <string>Ctrl+T</string>
+ </property>
+ </action>
+ <action>
+ <property name="name">
+ <cstring>viewIconsAction</cstring>
+ </property>
+ <property name="toggleAction">
+ <bool>true</bool>
+ </property>
+ <property name="iconSet">
+ <iconset>iconview.png</iconset>
+ </property>
+ <property name="text">
+ <string>View Icons</string>
+ </property>
+ <property name="menuText">
+ <string>View &amp;Icons</string>
+ </property>
+ <property name="toolTip">
+ <string>View Icons (Ctrl+I)</string>
+ </property>
+ <property name="accel">
+ <string>Ctrl+I</string>
+ </property>
+ </action>
+ </actiongroup>
+ <action>
+ <property name="name">
+ <cstring>editAddAction</cstring>
+ </property>
+ <property name="iconSet">
+ <iconset>widgetstack.png</iconset>
+ </property>
+ <property name="text">
+ <string>Add</string>
+ </property>
+ <property name="menuText">
+ <string>&amp;Add...</string>
+ </property>
+ <property name="accel">
+ <string>Ctrl+A</string>
+ </property>
+ </action>
+</actions>
+<connections>
+ <connection>
+ <sender>fileNewAction</sender>
+ <signal>activated()</signal>
+ <receiver>MainForm</receiver>
+ <slot>fileNew()</slot>
+ </connection>
+ <connection>
+ <sender>fileOpenAction</sender>
+ <signal>activated()</signal>
+ <receiver>MainForm</receiver>
+ <slot>fileOpen()</slot>
+ </connection>
+ <connection>
+ <sender>fileSaveAction</sender>
+ <signal>activated()</signal>
+ <receiver>MainForm</receiver>
+ <slot>fileSave()</slot>
+ </connection>
+ <connection>
+ <sender>fileSaveAsAction</sender>
+ <signal>activated()</signal>
+ <receiver>MainForm</receiver>
+ <slot>fileSaveAs()</slot>
+ </connection>
+ <connection>
+ <sender>fileExitAction</sender>
+ <signal>activated()</signal>
+ <receiver>MainForm</receiver>
+ <slot>fileExit()</slot>
+ </connection>
+ <connection>
+ <sender>editCutAction</sender>
+ <signal>activated()</signal>
+ <receiver>MainForm</receiver>
+ <slot>editCut()</slot>
+ </connection>
+ <connection>
+ <sender>editCopyAction</sender>
+ <signal>activated()</signal>
+ <receiver>MainForm</receiver>
+ <slot>editCopy()</slot>
+ </connection>
+ <connection>
+ <sender>editFindAction</sender>
+ <signal>activated()</signal>
+ <receiver>MainForm</receiver>
+ <slot>editFind()</slot>
+ </connection>
+ <connection>
+ <sender>helpIndexAction</sender>
+ <signal>activated()</signal>
+ <receiver>MainForm</receiver>
+ <slot>helpIndex()</slot>
+ </connection>
+ <connection>
+ <sender>helpContentsAction</sender>
+ <signal>activated()</signal>
+ <receiver>MainForm</receiver>
+ <slot>helpContents()</slot>
+ </connection>
+ <connection>
+ <sender>helpAboutAction</sender>
+ <signal>activated()</signal>
+ <receiver>MainForm</receiver>
+ <slot>helpAbout()</slot>
+ </connection>
+ <connection>
+ <sender>colorTable</sender>
+ <signal>currentChanged(int,int)</signal>
+ <receiver>MainForm</receiver>
+ <slot>changedTableColor(int,int)</slot>
+ </connection>
+ <connection>
+ <sender>colorIconView</sender>
+ <signal>currentChanged(QIconViewItem*)</signal>
+ <receiver>MainForm</receiver>
+ <slot>changedIconColor(QIconViewItem*)</slot>
+ </connection>
+ <connection>
+ <sender>viewActionGroup</sender>
+ <signal>selected(QAction*)</signal>
+ <receiver>MainForm</receiver>
+ <slot>changeView(QAction*)</slot>
+ </connection>
+ <connection>
+ <sender>editAddAction</sender>
+ <signal>activated()</signal>
+ <receiver>MainForm</receiver>
+ <slot>editAdd()</slot>
+ </connection>
+ <connection>
+ <sender>optionsAction</sender>
+ <signal>activated()</signal>
+ <receiver>MainForm</receiver>
+ <slot>editOptions()</slot>
+ </connection>
+ <connection>
+ <sender>colorWidgetStack</sender>
+ <signal>aboutToShow(int)</signal>
+ <receiver>MainForm</receiver>
+ <slot>aboutToShow()</slot>
+ </connection>
+</connections>
+<includes>
+ <include location="local" impldecl="in declaration">findform.h</include>
+ <include location="local" impldecl="in implementation">qsettings.h</include>
+ <include location="local" impldecl="in implementation">qradiobutton.h</include>
+ <include location="local" impldecl="in implementation">qcheckbox.h</include>
+ <include location="local" impldecl="in implementation">colornameform.h</include>
+ <include location="local" impldecl="in implementation">qcolordialog.h</include>
+ <include location="local" impldecl="in implementation">qregexp.h</include>
+ <include location="local" impldecl="in implementation">qfile.h</include>
+ <include location="local" impldecl="in implementation">qfiledialog.h</include>
+ <include location="local" impldecl="in implementation">qapplication.h</include>
+ <include location="local" impldecl="in implementation">qcolor.h</include>
+ <include location="local" impldecl="in implementation">qstring.h</include>
+ <include location="local" impldecl="in implementation">qpainter.h</include>
+ <include location="local" impldecl="in implementation">qstatusbar.h</include>
+ <include location="local" impldecl="in implementation">qmessagebox.h</include>
+ <include location="local" impldecl="in implementation">qclipboard.h</include>
+ <include location="local" impldecl="in implementation">qlabel.h</include>
+ <include location="local" impldecl="in implementation">qlineedit.h</include>
+ <include location="local" impldecl="in implementation">optionsform.h</include>
+ <include location="local" impldecl="in implementation">mainform.ui.h</include>
+</includes>
+<forwards>
+ <forward>class QString;</forward>
+ <forward>class QColor;</forward>
+</forwards>
+<variables>
+ <variable>QStringList m_comments;</variable>
+ <variable>QString m_filename;</variable>
+ <variable>bool m_changed;</variable>
+ <variable>bool m_table_dirty;</variable>
+ <variable>bool m_icons_dirty;</variable>
+ <variable>int m_clip_as;</variable>
+ <variable>bool m_show_web;</variable>
+ <variable>QClipboard *clipboard;</variable>
+ <variable>FindForm *findForm;</variable>
+ <variable>QMap&lt;QString,QColor&gt; m_colors;</variable>
+</variables>
+<slots>
+ <slot>fileNew()</slot>
+ <slot>fileOpen()</slot>
+ <slot>fileSave()</slot>
+ <slot>fileSaveAs()</slot>
+ <slot>closeEvent( QCloseEvent * )</slot>
+ <slot>fileExit()</slot>
+ <slot>editCut()</slot>
+ <slot>editCopy()</slot>
+ <slot>editFind()</slot>
+ <slot>lookfor( const QString &amp; text )</slot>
+ <slot>helpIndex()</slot>
+ <slot>helpContents()</slot>
+ <slot>helpAbout()</slot>
+ <slot>changedTableColor( int row, int )</slot>
+ <slot>changedIconColor( QIconViewItem * item )</slot>
+ <slot>changeView( QAction * action )</slot>
+ <slot>editAdd()</slot>
+ <slot>editOptions()</slot>
+ <slot>aboutToShow()</slot>
+</slots>
+<functions>
+ <function access="private">init()</function>
+ <function>clearData( bool fillWithDefaults )</function>
+ <function>populate()</function>
+ <function returnType="QPixmap">colorSwatch( const QColor color )</function>
+ <function>load( const QString &amp; filename )</function>
+ <function returnType="bool">okToClear()</function>
+ <function>changedColor( const QString &amp; name )</function>
+ <function returnType="bool">isWebColor( QColor color )</function>
+ <function>loadSettings()</function>
+ <function>saveSettings()</function>
+</functions>
+<pixmapinproject/>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/qtruby/rubylib/designer/examples/colortool/mainform.ui.rb b/qtruby/rubylib/designer/examples/colortool/mainform.ui.rb
new file mode 100644
index 00000000..471233bd
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/mainform.ui.rb
@@ -0,0 +1,530 @@
+class MainForm
+
+ CLIP_AS_HEX = 0
+ CLIP_AS_NAME = 1
+ CLIP_AS_RGB = 2
+ COL_NAME = 0
+ COL_HEX = 1
+ COL_WEB = 2
+ WINDOWS_REGISTRY = "/QtExamples"
+ APP_KEY = "/ColorTool/"
+
+def init()
+ @clipboard = Qt::Application.clipboard()
+ if @clipboard.supportsSelection()
+ @clipboard.selectionMode = true
+ end
+
+ findForm = 0
+ loadSettings()
+ @filename = nil
+ @changed = false
+ @table_dirty = true
+ @icons_dirty = true
+ @colors = {}
+ @comments = {}
+ clearData( true )
+end
+
+def clearData( fillWithDefaults )
+ setCaption( "Color Tool" )
+
+ @colors.clear()
+ @comments.clear()
+
+ if fillWithDefaults
+ @colors["black"] = Qt::black
+ @colors["blue"] = Qt::blue
+ @colors["cyan"] = Qt::cyan
+ @colors["darkblue"] = Qt::darkBlue
+ @colors["darkcyan"] = Qt::darkCyan
+ @colors["darkgray"] = Qt::darkGray
+ @colors["darkgreen"] = Qt::darkGreen
+ @colors["darkmagenta"] = Qt::darkMagenta
+ @colors["darkred"] = Qt::darkRed
+ @colors["darkyellow"] = Qt::darkYellow
+ @colors["gray"] = Qt::gray
+ @colors["green"] = Qt::green
+ @colors["lightgray"] = Qt::lightGray
+ @colors["magenta"] = Qt::magenta
+ @colors["red"] = Qt::red
+ @colors["white"] = Qt::white
+ @colors["yellow"] = Qt::yellow
+ end
+
+ populate()
+end
+
+def populate()
+ if @table_dirty
+ (0...@colorTable.numRows).each do |r|
+ (0...@colorTable.numCols).each do |c|
+ @colorTable.clearCell( r, c )
+ end
+ end
+
+ @colorTable.numRows = @colors.length
+ if ! @colors.empty?
+ pixmap = Qt::Pixmap.new( 22, 22 )
+ row = 0
+ @colors.sort.each do |pair|
+ key = pair[0]
+ color = pair[1]
+ pixmap.fill( color )
+ @colorTable.setText( row, COL_NAME, key )
+ @colorTable.setPixmap( row, COL_NAME, pixmap );
+ @colorTable.setText( row, COL_HEX, color.name().upcase() )
+ if @show_web
+ item = Qt::CheckTableItem.new( @colorTable, "" )
+ item.checked = webColor?( color )
+ @colorTable.setItem( row, COL_WEB, item )
+ end
+ row += 1
+ end
+ @colorTable.setCurrentCell( 0, 0 )
+ end
+ @colorTable.adjustColumn( COL_NAME )
+ @colorTable.adjustColumn( COL_HEX )
+ if @show_web
+ @colorTable.showColumn( COL_WEB )
+ @colorTable.adjustColumn( COL_WEB )
+ else
+ @colorTable.hideColumn( COL_WEB )
+ end
+ @table_dirty = FALSE;
+ end
+
+ if @icons_dirty
+ @colorIconView.clear()
+
+ @colors.each do |key, data|
+ Qt::IconViewItem.new( @colorIconView, key, colorSwatch(data) )
+ end
+ @icons_dirty = false
+ end
+end
+
+def colorSwatch( color )
+ pixmap = Qt::Pixmap.new( 80, 80 )
+ pixmap.fill( white )
+ painter = Qt::Painter.new
+ painter.begin( pixmap )
+ painter.pen = NoPen
+ painter.brush = color
+ painter.drawEllipse( 0, 0, 80, 80 )
+ painter.end()
+ return pixmap
+end
+
+def fileNew()
+ if okToClear()
+ @filename = nil
+ @changed = false
+ @table_dirty = true
+ @icons_dirty = true
+ clearData( false )
+ end
+end
+
+def fileOpen()
+ if ! okToClear()
+ return
+ end
+
+ filename = Qt::FileDialog.getOpenFileName(
+ nil, "Colors (*.txt)", self,
+ "file open", "Color Tool -- File Open" )
+ if ! filename.nil?
+ load( filename )
+ else
+ statusBar().message( "File Open abandoned", 2000 )
+ end
+end
+
+def fileSave()
+ if @filename.nil?
+ fileSaveAs()
+ return
+ end
+
+ file = Qt::File.new( @filename )
+ if file.open( Qt::IO_WriteOnly )
+ stream = Qt::TextStream.new( file )
+ if ! @comments.empty?
+ stream << @comments + "\n" << "\n"
+ end
+
+ @colors.each do |key, color|
+ stream << "%3d %3d %3d \t\t#{key}" % [color.red, color.green, color.blue] << "\n"
+ end
+ file.close()
+ setCaption( "Color Tool -- #{@filename}" )
+ statusBar().message( "Saved #{@colors.length} colors to '#{@filename}'", 3000 )
+ @changed = false;
+ else
+ statusBar().message( "Failed to save '#{@filename}'", 3000 )
+ end
+end
+
+def fileSaveAs()
+ filename = Qt::FileDialog.getSaveFileName(
+ nil, "Colors (*.txt)", self,
+ "file save as", "Color Tool -- File Save As" )
+ if ! filename.nil?
+ ans = 0
+ if Qt::File.exists( filename )
+ ans = Qt::MessageBox.warning(
+ self, "Color Tool -- Overwrite File",
+ "Overwrite\n'#{filename}'?" ,
+ "&Yes", "&No", nil, 1, 1 )
+ end
+ if ans == 0
+ @filename = filename
+ fileSave()
+ return
+ end
+ end
+ statusBar().message( "Saving abandoned", 2000 )
+end
+
+def load( filename )
+ clearData( false )
+ @filename = filename
+ regex = Regexp.new( "^\\s*(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\S+.*)$" )
+ file = Qt::File.new( filename )
+ if file.open( Qt::IO_ReadOnly )
+ statusBar().message( "Loading '#{filename}'..." )
+ stream = Qt::TextStream.new( file )
+ while ! stream.eof()
+ line = stream.readLine()
+ m = regex.match( line )
+ if m.nil?
+ @comments += line
+ else
+ @colors[m[4]] = Qt::Color.new(m[1].to_i,m[2].to_i,m[3].to_i )
+ end
+ end
+ file.close()
+ @filename = filename
+ setCaption( "Color Tool -- #{@filename}" )
+ statusBar().message( "Loaded '#{@filename}'", 3000 )
+ visible = @colorWidgetStack.visibleWidget()
+ @icons_dirty = ! ( @table_dirty = ( visible == @tablePage ) )
+ populate()
+ @icons_dirty = ! ( @table_dirty = ( visible != @tablePage ) )
+ @changed = false
+ else
+ statusBar().message( "Failed to load '#{@filename}'", 3000 )
+ end
+end
+
+
+def okToClear()
+ if @changed
+ if @filename.nil?
+ msg = "Unnamed colors "
+ else
+ msg = "Colors '#{@filename}'\n"
+ end
+ msg += "has been changed."
+ ans = Qt::MessageBox.information(
+ self,
+ "Color Tool -- Unsaved Changes",
+ msg, "&Save", "Cancel", "&Abandon",
+ 0, 1 )
+ if ans == 0
+ fileSave()
+ elsif ans == 1
+ return false
+ end
+ end
+
+ return true
+end
+
+def closeEvent( e )
+ fileExit()
+end
+
+def fileExit()
+ if okToClear()
+ saveSettings()
+ Qt::Application.exit( 0 )
+ end
+end
+
+def editCut()
+ visible = @colorWidgetStack.visibleWidget()
+ statusBar().message( "Deleting '#{name}'" )
+
+ if visible == @tablePage && @colorTable.numRows() > 0
+ row = @colorTable.currentRow()
+ name = @colorTable.text( row, 0 )
+ @colorTable.removeRow( @colorTable.currentRow() )
+ if row < @colorTable.numRows()
+ @colorTable.setCurrentCell( row, 0 )
+ elsif @colorTable.numRows() > 0
+ @colorTable.setCurrentCell( @colorTable.numRows() - 1, 0 )
+ end
+ @icons_dirty = true
+ elsif visible == @iconsPage && @colorIconView.currentItem()
+ item = colorIconView.currentItem()
+ name = item.text()
+ if @colorIconView.count() == 1
+ @colorIconView.clear()
+ else
+ current = item.nextItem()
+ if ! current
+ current = item.prevItem()
+ end
+ item.dispose
+ if current
+ @colorIconView.currentItem = current
+ end
+ @colorIconView.arrangeItemsInGrid()
+ end
+ @table_dirty = true
+ end
+
+ if ! name.nil?
+ @colors.delete( name )
+ @changed = true
+ statusBar().message( "Deleted '#{name}'", 5000 )
+ else
+ statusBar().message( "Failed to delete '#{name}'", 5000 )
+ end
+end
+
+def editCopy()
+ visible = @colorWidgetStack.visibleWidget()
+
+ if visible == @tablePage && @colorTable.numRows()
+ row = @colorTable.currentRow()
+ text = @colorTable.text( row, 0 )
+ elsif visible == @iconsPage && ! @colorIconView.currentItem().nil?
+ item = @colorIconView.currentItem()
+ text = item.text()
+ end
+ if ! text.nil?
+ color = @colors[text]
+ case @clip_as
+ when CLIP_AS_HEX then text = color.name()
+ when CLIP_AS_NAME then
+ when CLIP_AS_RGB
+ text = "#{color.red},#{color.green},#{color.blue}"
+ end
+ @clipboard.text = text
+ statusBar().message( "Copied '" + text + "' to the clipboard" )
+ end
+end
+
+def editFind()
+ if ! @findForm
+ @findForm = FindForm.new( self )
+ connect( @findForm, SIGNAL( 'lookfor(const QString&)' ),
+ self, SLOT( 'lookfor(const QString&)' ) )
+ end
+ @findForm.show()
+end
+
+def lookfor( text )
+ if text.empty?
+ return
+ end
+ ltext = text.downcase()
+ visible = colorWidgetStack.visibleWidget()
+ found = false
+
+ if visible == @tablePage && @colorTable.numRows() > 0
+ row = @colorTable.currentRow()
+ (row+1...@colorTable.numRows).each do |i|
+ if @colorTable.text( i, 0 ).downcase().include?( ltext )
+ @colorTable.setCurrentCell( i, 0 )
+ @colorTable.clearSelection()
+ @colorTable.selectRow( i )
+ found = true
+ break
+ end
+ end
+ if ! found
+ @colorTable.setCurrentCell( row, 0 )
+ end
+ elsif visible == @iconsPage
+ start = @colorIconView.currentItem()
+ item = start.nextItem() unless start.nil?
+ while !item.nil?
+ if item.text().downcase().include?( ltext )
+ @colorIconView.currentItem = item
+ @colorIconView.ensureItemVisible( item )
+ found = true
+ break
+ end
+ item = item.nextItem()
+ end
+ if ! found && !start.nil?
+ @colorIconView.currentItem = start
+ end
+ end
+ if ! found
+ statusBar().message( "Could not find '#{text}' after here" )
+ @findForm.notfound()
+ end
+end
+
+
+
+def helpIndex()
+end
+
+def helpContents()
+end
+
+def helpAbout()
+end
+
+
+def changedTableColor( row, i )
+ changedColor( @colorTable.text( row, COL_NAME ) )
+end
+
+def changedIconColor( item )
+ changedColor( item.text() )
+end
+
+def changedColor( name )
+ color = @colors[name]
+ r = color.red()
+ g = color.green()
+ b = color.blue()
+ statusBar().message( "%s \"%s\" (%d,%d,%d) %s {%.3f %.3f %.3f}" %
+ [name, color.name.upcase,
+ r, g, b, webColor?( color ) ? ' web' : '',
+ r / 255.0, g / 255.0, b / 255.0] )
+end
+
+def changeView(action)
+ if action == @viewTableAction
+ @colorWidgetStack.raiseWidget( @tablePage )
+ else
+ @colorWidgetStack.raiseWidget( @iconsPage )
+ end
+end
+
+def webColor?( color )
+ r = color.red()
+ g = color.green()
+ b = color.blue()
+
+ return ( ( r == 0 || r == 51 || r == 102 ||
+ r == 153 || r == 204 || r == 255 ) &&
+ ( g == 0 || g == 51 || g == 102 ||
+ g == 153 || g == 204 || g == 255 ) &&
+ ( b == 0 || b == 51 || b == 102 ||
+ b == 153 || b == 204 || b == 255 ) )
+end
+
+
+def editAdd()
+ color = Qt::white
+ if ! @colors.empty?
+ visible = @colorWidgetStack.visibleWidget()
+ if visible == @tablePage
+ color = Qt::Color.new(@colorTable.text( @colorTable.currentRow(),
+ @colorTable.currentColumn() ))
+ else
+ color = Qt::Color.new(@colorIconView.currentItem().text())
+ end
+ end
+ color = Qt::ColorDialog.getColor( color, self )
+ if color.valid?
+ pixmap = Qt::Pixmap.new( 80, 10 )
+ pixmap.fill( color )
+ colorForm = ColorNameForm.new( self, "color", true )
+ colorForm.setColors( @colors )
+ colorForm.colorLabel.setPixmap( pixmap )
+ if colorForm.exec()
+ name = colorForm.colorLineEdit.text()
+ @colors[name] = color
+ pixmap = Qt::Pixmap.new( 22, 22 )
+ pixmap.fill( color )
+ row = @colorTable.currentRow()
+ @colorTable.insertRows( row, 1 )
+ @colorTable.setText( row, COL_NAME, name )
+ @colorTable.setPixmap( row, COL_NAME, pixmap )
+ @colorTable.setText( row, COL_HEX, color.name().upcase() )
+ if @show_web
+ item = Qt::CheckTableItem.new( @colorTable, "" )
+ item.checked = webColor?( color )
+ @colorTable.setItem( row, COL_WEB, item )
+ end
+ @colorTable.setCurrentCell( row, 0 )
+
+ Qt::IconViewItem.new( @colorIconView, name,
+ colorSwatch( color ) )
+ @changed = true
+ end
+ end
+end
+
+def editOptions()
+ options = OptionsForm.new( self, "options", true )
+ case @clip_as
+ when CLIP_AS_HEX
+ options.hexRadioButton.checked = true
+ when CLIP_AS_NAME
+ options.nameRadioButton.checked = true
+ when CLIP_AS_RGB
+ options.rgbRadioButton.checked = true
+ end
+ options.webCheckBox.checked = @show_web
+
+ if options.exec()
+ if options.hexRadioButton.checked?
+ @clip_as = CLIP_AS_HEX
+ elsif options.nameRadioButton.checked?
+ @clip_as = CLIP_AS_NAME
+ elsif options.rgbRadioButton.checked?
+ @clip_as = CLIP_AS_RGB
+ end
+ @table_dirty = @show_web != options.webCheckBox.checked?
+ @show_web = options.webCheckBox.checked?
+ populate()
+ end
+end
+
+def loadSettings()
+ settings = Qt::Settings.new
+ settings.insertSearchPath( Qt::Settings::Windows, WINDOWS_REGISTRY )
+ windowWidth = settings.readNumEntry( APP_KEY + "WindowWidth", 550 )
+ windowHeight = settings.readNumEntry( APP_KEY + "WindowHeight", 500 )
+ windowX = settings.readNumEntry( APP_KEY + "WindowX", 0 )
+ windowY = settings.readNumEntry( APP_KEY + "WindowY", 0 )
+ @clip_as = settings.readNumEntry( APP_KEY + "ClipAs", CLIP_AS_HEX )
+ @show_web = settings.readBoolEntry( APP_KEY + "ShowWeb", true )
+ if ! settings.readBoolEntry( APP_KEY + "View", true )
+ @colorWidgetStack.raiseWidget( @iconsPage )
+ @viewIconsAction.on = true
+ end
+
+ resize( windowWidth, windowHeight )
+ move( windowX, windowY )
+end
+
+def saveSettings()
+ settings = Qt::Settings.new
+ settings.insertSearchPath( Qt::Settings::Windows, WINDOWS_REGISTRY )
+ settings.writeEntry( APP_KEY + "WindowWidth", width() )
+ settings.writeEntry( APP_KEY + "WindowHeight", height() )
+ settings.writeEntry( APP_KEY + "WindowX", x() )
+ settings.writeEntry( APP_KEY + "WindowY", y() )
+ settings.writeEntry( APP_KEY + "ClipAs", @clip_as )
+ settings.writeEntry( APP_KEY + "ShowWeb", @show_web )
+ settings.writeEntry( APP_KEY + "View", @colorWidgetStack.visibleWidget() == @tablePage )
+end
+
+
+def aboutToShow()
+ populate()
+end
+
+end
diff --git a/qtruby/rubylib/designer/examples/colortool/optionsform.ui b/qtruby/rubylib/designer/examples/colortool/optionsform.ui
new file mode 100644
index 00000000..1bb7e8ef
--- /dev/null
+++ b/qtruby/rubylib/designer/examples/colortool/optionsform.ui
@@ -0,0 +1,153 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>OptionsForm</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>OptionsForm</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>306</width>
+ <height>226</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Color Tool - Options</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>GroupBox2</cstring>
+ </property>
+ <property name="title">
+ <string>Table View</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>webCheckBox</cstring>
+ </property>
+ <property name="text">
+ <string>Indicate &amp;Web colors</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QButtonGroup">
+ <property name="name">
+ <cstring>ButtonGroup1</cstring>
+ </property>
+ <property name="title">
+ <string>Copy to Clipboard As</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>hexRadioButton</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Hex, e.g. #AB347F</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>nameRadioButton</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Name, e.g. light blue</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>rgbRadioButton</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;RGB, e.g. 51,255,102</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout5</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>0</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>okPushButton</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>cancelPushButton</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+</widget>
+<connections>
+ <connection>
+ <sender>okPushButton</sender>
+ <signal>clicked()</signal>
+ <receiver>OptionsForm</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>cancelPushButton</sender>
+ <signal>clicked()</signal>
+ <receiver>OptionsForm</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<includes>
+ <include location="local" impldecl="in implementation">optionsform.ui.h</include>
+</includes>
+<pixmapinproject/>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>