unison-watch/lib/unison/ui/preferences.rb

61 lines
1.9 KiB
Ruby
Raw Permalink Normal View History

2012-05-07 22:21:03 +00:00
module Unison
module UI
class Preferences < Qt::Widget
def initialize(config, *args)
super(*args)
@config = config
generate
end
def show
super
self.raise
end
2012-05-07 22:21:03 +00:00
def generate
layout = Qt::GridLayout.new
profile_group = Qt::GroupBox.new("Profiles")
profile_group_layout = Qt::VBoxLayout.new
profile_group.setLayout(profile_group_layout)
Unison::Profile.available.each do |profile|
radio = Qt::CheckBox.new(profile)
radio.checked = @config.active?(profile)
radio.connect(SIGNAL "toggled(bool)") { |checked| @config.set_profile(profile, checked) }
profile_group_layout.addWidget(radio)
end
2012-05-09 00:11:35 +00:00
performance_group = Qt::GroupBox.new("Performance")
performance_group_layout = Qt::VBoxLayout.new
performance_group.setLayout(performance_group_layout)
fields = Qt::Widget.new
fields_layout = Qt::GridLayout.new
fields.setLayout(fields_layout)
count_label = Qt::Label.new("Seconds between checks (min 10s):")
count_field = Qt::LineEdit.new(@config.time_between_checks.to_s)
count_field.connect(SIGNAL "textChanged(QString)") { |string| @config.time_between_checks = string.to_i }
binary_label = Qt::Label.new("Unison binary:")
binary_field = Qt::LineEdit.new(@config.unison_binary)
binary_field.connect(SIGNAL "textChanged(QString)") { |string| @config.unison_binary = string }
2012-05-09 00:11:35 +00:00
fields_layout.addWidget(count_label, 0, 0)
fields_layout.addWidget(count_field, 0, 1)
fields_layout.addWidget(binary_label, 1, 0)
fields_layout.addWidget(binary_field, 1, 1)
2012-05-09 00:11:35 +00:00
performance_group_layout.addWidget(fields)
layout.addWidget(profile_group, 0, 0)
layout.addWidget(performance_group, 0, 1)
2012-05-07 22:21:03 +00:00
setLayout(layout)
end
end
end
end