Class: KIconCollection
- Defined in:
- ext/ruby/qtruby/examples/base/kicons.rb
Defined Under Namespace
Classes: IconInfo
Instance Method Summary collapse
- #dims ⇒ Object
- #get_icon_path(icon_type) ⇒ Object
- #get_icon_set(icon_type) ⇒ Object
-
#initialize(icon_collections) ⇒ KIconCollection
constructor
A new instance of KIconCollection.
- #kdedir ⇒ Object
- #make_qt_action(parent, text_with_accel, icon_type) ⇒ Object
Constructor Details
#initialize(icon_collections) ⇒ KIconCollection
Returns a new instance of KIconCollection.
3 4 5 6 7 8 9 10 11 12 13 |
# File 'ext/ruby/qtruby/examples/base/kicons.rb', line 3 def initialize(icon_collections) @icon_info = {} icon_collections.each_pair { |collection_name, collection| collection.each_pair { |key, value| info = IconInfo.new(collection_name, value, "png") @icon_info[key] = info } } end |
Instance Method Details
#dims ⇒ Object
14 15 16 |
# File 'ext/ruby/qtruby/examples/base/kicons.rb', line 14 def dims "32x32" end |
#get_icon_path(icon_type) ⇒ Object
20 21 22 23 |
# File 'ext/ruby/qtruby/examples/base/kicons.rb', line 20 def get_icon_path(icon_type) info = @icon_info[icon_type] "#{kdedir}/share/icons/default.kde/#{dims}/#{info.collection}/#{info.id}.#{info.filetype}" end |
#get_icon_set(icon_type) ⇒ Object
24 25 26 27 28 29 30 |
# File 'ext/ruby/qtruby/examples/base/kicons.rb', line 24 def get_icon_set(icon_type) path = get_icon_path(icon_type) pixmap = Qt::Pixmap.new(path) icon_set = Qt::IconSet.new icon_set.setPixmap(pixmap, Qt::IconSet.Small) icon_set end |
#kdedir ⇒ Object
17 18 19 |
# File 'ext/ruby/qtruby/examples/base/kicons.rb', line 17 def kdedir ENV["KDEDIR"] end |
#make_qt_action(parent, text_with_accel, icon_type) ⇒ Object
31 32 33 34 35 36 |
# File 'ext/ruby/qtruby/examples/base/kicons.rb', line 31 def make_qt_action(parent, text_with_accel, icon_type) act = Qt::Action.new(parent) act.setIconSet(get_icon_set(icon_type)) act.setMenuText(text_with_accel) act end |