Class: Depot::GUI::DropPanel
- Inherits:
-
RubyQt6::Bando::QFrame
- Object
- RubyQt6::Bando::QFrame
- Depot::GUI::DropPanel
- Defined in:
- lib/depot/gui/drop_panel.rb
Instance Method Summary collapse
- #drag_enter_event(event) ⇒ Object
- #drag_leave_event(event) ⇒ Object
- #drag_move_event(event) ⇒ Object
- #drop_event(event) ⇒ Object
-
#initialize(&on_file) ⇒ DropPanel
constructor
A new instance of DropPanel.
Constructor Details
#initialize(&on_file) ⇒ DropPanel
Returns a new instance of DropPanel.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/depot/gui/drop_panel.rb', line 6 def initialize(&on_file) super() @on_file = on_file set_accept_drops(true) set_object_name("depotDropPanel") set_frame_shape(QFrame::StyledPanel) set_minimum_height(280) @label = QLabel.new("Drop software here") @label.set_alignment(Qt::AlignCenter) @label.set_word_wrap(true) @label.set_object_name("depotDropTitle") @label.set_attribute(Qt::WA_TransparentForMouseEvents) @hint = QLabel.new("or choose a package with the file picker") @hint.set_alignment(Qt::AlignCenter) @hint.set_object_name("depotDropHint") @hint.set_attribute(Qt::WA_TransparentForMouseEvents) layout = QVBoxLayout.new layout.add_stretch layout.(@label) layout.(@hint) layout.add_stretch set_layout(layout) end |
Instance Method Details
#drag_enter_event(event) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/depot/gui/drop_panel.rb', line 32 def drag_enter_event(event) if file_from_event(event) @hint.set_text("Release to inspect this software") event.accept_proposed_action else event.ignore end end |
#drag_leave_event(event) ⇒ Object
41 42 43 |
# File 'lib/depot/gui/drop_panel.rb', line 41 def drag_leave_event(event) @hint.set_text("or choose a package with the file picker") end |
#drag_move_event(event) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/depot/gui/drop_panel.rb', line 45 def drag_move_event(event) if file_from_event(event) event.accept_proposed_action else event.ignore end end |
#drop_event(event) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/depot/gui/drop_panel.rb', line 53 def drop_event(event) path = file_from_event(event) return event.ignore unless path @hint.set_text("or choose a package with the file picker") @on_file.call(path) event.accept_proposed_action end |