Class: Cosmos::Splash::SplashDialogBox
- Defined in:
- lib/cosmos/gui/dialogs/splash.rb
Overview
Creates a dialog with a message box and a progress bar.
Instance Method Summary collapse
-
#initialize(parent) ⇒ SplashDialogBox
constructor
A new instance of SplashDialogBox.
-
#keyPressEvent(event) ⇒ Object
Override keyPressEvent to prevent Esc from closing the splash dialog.
- #message=(message) ⇒ Object
-
#message_callback ⇒ Method
Message= method.
- #progress=(progress) ⇒ Object
-
#progress_callback ⇒ Method
Progress= method.
Constructor Details
#initialize(parent) ⇒ SplashDialogBox
Returns a new instance of SplashDialogBox.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/cosmos/gui/dialogs/splash.rb', line 24 def initialize(parent) super(parent, Qt::WindowTitleHint | Qt::CustomizeWindowHint) setWindowTitle(parent.windowTitle) setModal(true) layout = Qt::VBoxLayout.new splash_image_filename = File.join(::Cosmos::USERPATH, 'config', 'data', 'splash.gif') splash_image_filename = File.join(::Cosmos::PATH, 'data', 'splash.gif') unless File.exist?(splash_image_filename) image = Qt::Pixmap.new(splash_image_filename) label = Qt::Label.new label.setPixmap(image) layout.addWidget(label) = Qt::LineEdit.new .setReadOnly(true) layout.addWidget() = Qt::ProgressBar.new layout.addWidget() setLayout(layout) @progress = 0 @complete = false end |
Instance Method Details
#keyPressEvent(event) ⇒ Object
Override keyPressEvent to prevent Esc from closing the splash dialog
81 82 83 84 85 86 87 88 |
# File 'lib/cosmos/gui/dialogs/splash.rb', line 81 def keyPressEvent(event) # Don't allow the Escape key to close this dialog if event.key == Qt::Key_Escape event.ignore else super(event) end end |
#message=(message) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/cosmos/gui/dialogs/splash.rb', line 50 def () unless @complete Qt.execute_in_main_thread(false) do .setText() end end end |
#message_callback ⇒ Method
Returns message= method.
70 71 72 |
# File 'lib/cosmos/gui/dialogs/splash.rb', line 70 def method(:message=) end |
#progress=(progress) ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/cosmos/gui/dialogs/splash.rb', line 59 def progress=(progress) progress_int = (progress * 100).to_i if !@complete && (@progress != progress_int) @progress = progress_int Qt.execute_in_main_thread(false) do .setValue(progress_int) end end end |
#progress_callback ⇒ Method
Returns progress= method.
75 76 77 |
# File 'lib/cosmos/gui/dialogs/splash.rb', line 75 def progress_callback method(:progress=) end |