7 has_qt4 = require 'Qt4'
10 puts "ruby qt4 is required!"
15 def self.restart_server(host, port)
17 settings = Qt::Settings.new("dashd", "dashd")
18 settings.beginGroup("Connection")
20 settings.setValue("host", Qt::Variant.new(host) )
21 settings.setValue("port", Qt::Variant.new(port) )
29 `pkill dashd` # Restart the server
36 settings = Qt::Settings.new("dashd", "dashd");
37 settings.beginGroup("Connection")
39 server = settings.value("host").toString
40 port = settings.value("port").toInt
55 class Control < Qt::Frame
59 @layout = Qt::VBoxLayout.new(self)
61 server, port = Manager.server_port
63 @grid = Qt::GridLayout.new
65 @host = Qt::LineEdit.new
66 @host.setText server.to_s
68 @port = Qt::SpinBox.new
69 @port.setMaximum(65000)
70 @port.setValue port.to_i
72 @grid.addWidget(Qt::Label.new(tr("Host")), 0, 0)
73 @grid.addWidget(@host, 0, 1)
75 @grid.addWidget(Qt::Label.new(tr("Port")), 1, 0)
76 @grid.addWidget(@port, 1, 1)
79 @layout.addLayout @grid
81 @buttons = Qt::HBoxLayout.new
82 restart = Qt::PushButton.new(tr("Restart"))
83 connect(restart, SIGNAL('clicked()'), self, SLOT('restart()'))
84 @buttons.addWidget(restart)
86 @layout.addLayout @buttons
90 Manager.restart_server(@host.text, @port.value)
94 class MainWindow < Qt::MainWindow
98 @control = Control.new
99 setCentralWidget(@control)
104 app = Qt::Application.new(ARGV)