Class: KDE::Application

Inherits:
Object show all
Defined in:
lib/rui/toolkits/kde/kde.rb

Class Method Summary collapse

Class Method Details

.init(data) ⇒ Object

Initialize an application.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/rui/toolkits/kde/kde.rb', line 31

def self.init(data)
  data = { :id => data } unless data.is_a?(Hash)
  about = KDE::AboutData.new(
    data[:id],
    data[:id],
    data[:name] || KDE::LocalizedString.new,
    data[:version] || '0.0',
    data[:description] || KDE::LocalizedString.new,
    KDE::AboutData::License_GPL,
    data[:copyright] || KDE::LocalizedString.new)
  (data[:authors] || []).each do |name, email|
    about.addAuthor(name, KDE::LocalizedString.new, email)
  end
  (data[:contributors] || []).each do |name, contribution|
    about.addCredit(name, contribution)
  end
  about.bug_address = Qt::ByteArray.new(data[:bug_tracker] || "")
  
  KDE::CmdLineArgs.init(ARGV, about)
  opts = KDE::CmdLineOptions.new
  (data[:options] || []).each do |args|
    case args.size
    when 2
      opts.add(args[0], args[1])
    when 3
      opts.add(args[0], args[1], args[2])
    end
  end
  KDE::CmdLineArgs.add_cmd_line_options opts
  opts

  app = KDE::Application.new
  if block_given?
    yield app
    app.exec
  end
  app
end