45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/cosmos/tools/launcher/launcher_tool.rb', line 45
def parameters_dialog
dialog = Qt::Dialog.new(parent)
dialog.window_title = "#{@button_text} Options"
layout = Qt::VBoxLayout.new
dialog.layout = layout
widgets = []
@variable_parameters.each do |parameter_name, parameter_value|
hlayout = Qt::HBoxLayout.new
hlayout.addWidget(Qt::Label.new(parameter_name))
parameter_options = parameter_value.split('|')
if parameter_options.length > 1
combo_box = Qt::ComboBox.new
combo_box.setEditable(true)
idx = 0
parameter_options.each do |option|
combo_box.insertItem(idx, option)
idx += 1
end
combo_box.setCurrentIndex(0) hlayout.addWidget(combo_box)
widgets << combo_box
else
line_edit = Qt::LineEdit.new
line_edit.setText(parameter_value)
hlayout.addWidget(line_edit)
widgets << line_edit
end
layout.addLayout(hlayout)
end
ok_button = Qt::PushButton.new('Ok')
connect(ok_button, SIGNAL('clicked()'), dialog, SLOT('accept()'))
cancel_button = Qt::PushButton.new('Cancel')
connect(cancel_button, SIGNAL('clicked()'), dialog, SLOT('reject()'))
hlayout = Qt::HBoxLayout.new
hlayout.addWidget(ok_button, 0, Qt::AlignLeft)
hlayout.addWidget(cancel_button, 0, Qt::AlignRight)
layout.addLayout(hlayout)
dialog.resize(400, 0)
cursor_pos = Qt::Cursor.pos
x_pos = cursor_pos.x - 200
y_pos = cursor_pos.y - 50
if x_pos < 0
x_pos = 0
elsif x_pos > (Qt::Application.desktop.width - dialog.frameGeometry.width)
x_pos = Qt::Application.desktop.width - dialog.frameGeometry.width
end
dialog.move(x_pos, y_pos)
result = dialog.exec
if result == Qt::Dialog::Accepted
parameters = ''
index = 0
@variable_parameters.each do |parameter_name, _parameter_value|
parameters << parameter_name
parameters << ' '
parameters << widgets[index].text
parameters << ' '
index += 1
end
dialog.dispose
return parameters
else
dialog.dispose
return nil
end
end
|