Class: Depot::GUI::SandboxDialog

Inherits:
RubyQt6::Bando::QDialog
  • Object
show all
Defined in:
lib/depot/gui/main_window.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, manifest, settings) ⇒ SandboxDialog

Returns a new instance of SandboxDialog.



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
# File 'lib/depot/gui/main_window.rb', line 64

def initialize(parent, manifest, settings)
  super(parent)
  @manifest = Sandbox.normalize(manifest, settings)
  sandbox = @manifest.fetch("sandbox", {})

  set_window_title("Sandbox")
  set_modal(true)
  resize(430, 260)

  layout = QVBoxLayout.new
  title = QLabel.new("Sandbox #{manifest.fetch("display_name")}")
  title.set_style_sheet("font-size: 18px; font-weight: 700;")
  layout.add_widget(title)

  note = QLabel.new(description_text)
  note.set_word_wrap(true)
  note.set_object_name("depotInstallSubtitle")
  layout.add_widget(note)

  form = QFormLayout.new
  @mode_combo = QComboBox.new
  %w[inherit enabled disabled].each { |value| @mode_combo.add_item(value) }
  @profile_combo = QComboBox.new
  %w[relaxed balanced strict].each { |value| @profile_combo.add_item(value) }
  @home_combo = QComboBox.new
  %w[isolated documents full].each { |value| @home_combo.add_item(value) }
  @network_check = QCheckBox.new("Allow network access")

  set_combo(@mode_combo, sandbox.fetch("mode", "inherit"))
  set_combo(@profile_combo, sandbox.fetch("profile", "balanced"))
  set_combo(@home_combo, sandbox.fetch("home_access", "documents"))
  @network_check.set_checked(sandbox.fetch("network", true))

  form.add_row(QString.new("Mode"), @mode_combo)
  form.add_row(QString.new("Profile"), @profile_combo)
  form.add_row(QString.new("Home access"), @home_combo)
  form.add_row(QString.new("Network"), @network_check)
  layout.add_layout(form)

  buttons = QHBoxLayout.new
  save = QPushButton.new("Save")
  cancel = QPushButton.new("Cancel")
  save.clicked.connect(self, :accept)
  cancel.clicked.connect(self, :reject)
  buttons.add_stretch
  buttons.add_widget(save)
  buttons.add_widget(cancel)
  layout.add_layout(buttons)
  set_layout(layout)
end

Instance Attribute Details

#home_comboObject (readonly)

Returns the value of attribute home_combo.



62
63
64
# File 'lib/depot/gui/main_window.rb', line 62

def home_combo
  @home_combo
end

#mode_comboObject (readonly)

Returns the value of attribute mode_combo.



62
63
64
# File 'lib/depot/gui/main_window.rb', line 62

def mode_combo
  @mode_combo
end

#network_checkObject (readonly)

Returns the value of attribute network_check.



62
63
64
# File 'lib/depot/gui/main_window.rb', line 62

def network_check
  @network_check
end

#profile_comboObject (readonly)

Returns the value of attribute profile_combo.



62
63
64
# File 'lib/depot/gui/main_window.rb', line 62

def profile_combo
  @profile_combo
end

Instance Method Details

#valuesObject



115
116
117
118
119
120
121
122
# File 'lib/depot/gui/main_window.rb', line 115

def values
  {
    "mode" => @mode_combo.current_text.to_s,
    "profile" => @profile_combo.current_text.to_s,
    "home_access" => @home_combo.current_text.to_s,
    "network" => @network_check.checked?
  }
end