Class: QT3::SubmitSongDialog

Inherits:
BaseDialog
  • Object
show all
Defined in:
lib/wiki_lyrics/gui/gui-qt3.rb

Instance Attribute Summary

Attributes inherited from BaseDialog

#values

Instance Method Summary collapse

Methods inherited from BaseDialog

#accepted

Constructor Details

#initialize(values) ⇒ SubmitSongDialog

Returns a new instance of SubmitSongDialog.



352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
# File 'lib/wiki_lyrics/gui/gui-qt3.rb', line 352

def initialize( values )
	super( values )

	edit_mode = @values["edit_mode"].to_s() == "true"
	setCaption( I18n.get( "gui.submitsong.title." + (edit_mode ? "edit" : "submit"), values["site_name"] ) )

	artist_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.artist" )}</b>", self )
	@artist_lineedit = Qt::LineEdit.new( values["artist"], self )

	title_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.song" )}</b>", self )
	@title_lineedit = Qt::LineEdit.new( values["title"], self )

	credits_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.credits" )}</b>", self )
	@credits_lineedit = Qt::LineEdit.new( values["credits"], self )

	lyricist_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.lyricist" )}</b>", self )
	@lyricist_lineedit = Qt::LineEdit.new( values["lyricist"], self )

	year_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.year" )}</b>", self )
	@year_spinbox = Qt::SpinBox.new( self )
	@year_spinbox.setMinValue( 1900 )
	@year_spinbox.setMaxValue( Date.today().year )
	@year_spinbox.setValue( values["year"] )

	album_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.album" )}</b>", self )
	@album_lineedit = Qt::LineEdit.new( values["album"], self )

	@instrumental_checkbox = Qt::CheckBox.new( self )
	@instrumental_checkbox.setChecked( @values["instrumental"].to_s() == "true" )
	@instrumental_checkbox.setText( I18n.get( "gui.submitsong.instrumental" ) )

	@lyrics_text = Qt::TextEdit.new( self )
	@lyrics_text.setTextFormat( Qt::TextEdit::PlainText )
	@lyrics_text.setText( values["lyrics"] )
	@lyrics_text.setDisabled( @instrumental_checkbox.isChecked() )

	@reviewed_checkbox = Qt::CheckBox.new( self )
	@reviewed_checkbox.setChecked( false )
	@reviewed_checkbox.setText( I18n.get( "gui.common.reviewed" ) )

	buttons = create_action_buttons( "split", I18n.get( "gui.common.submit" ) )

	grid_layout = Qt::GridLayout.new( self, 9, 5, 5 )
	grid_layout.addColSpacing( 2, 15 )
	grid_layout.addWidget( artist_label, 0, 0, Qt::AlignRight )
	grid_layout.addWidget( @artist_lineedit, 0, 1 )
	grid_layout.addWidget( title_label, 0, 3, Qt::AlignRight )
	grid_layout.addWidget( @title_lineedit, 0, 4 )
	grid_layout.addWidget( credits_label, 1, 0, Qt::AlignRight )
	grid_layout.addWidget( @credits_lineedit, 1, 1 )
	grid_layout.addWidget( lyricist_label, 1, 3, Qt::AlignRight )
	grid_layout.addWidget( @lyricist_lineedit, 1, 4 )
	grid_layout.addWidget( year_label, 2, 0, Qt::AlignRight )
	grid_layout.addWidget( @year_spinbox, 2, 1 )
	grid_layout.addWidget( album_label, 2, 3, Qt::AlignRight )
	grid_layout.addWidget( @album_lineedit, 2, 4 )
	grid_layout.addMultiCellWidget( @instrumental_checkbox, 3, 3, 0, 4 )
	grid_layout.addMultiCellWidget( @lyrics_text, 4, 4, 0, 4 )
	grid_layout.addMultiCellWidget( @reviewed_checkbox, 5, 5, 0, 4 )
	grid_layout.addMultiCellLayout( buttons, 6, 6, 0, 4 )

	resize( 600, 400 )

	connect( @instrumental_checkbox, SIGNAL( "toggled(bool)" ), self, SLOT( "toggle_instrumental_checked(bool)" ) )

end

Instance Method Details

#acceptObject



423
424
425
426
427
428
429
430
431
432
433
434
435
436
# File 'lib/wiki_lyrics/gui/gui-qt3.rb', line 423

def accept()
	@values = {
		"artist"		=> @artist_lineedit.text(),
		"year"			=> @year_spinbox.value(),
		"album"			=> @album_lineedit.text(),
		"title"			=> @title_lineedit.text(),
		"lyrics"		=> @lyrics_text.text(),
		"instrumental"	=> @instrumental_checkbox.isChecked(),
		"lyricist"		=> @lyricist_lineedit.text(),
		"credits"		=> @credits_lineedit.text(),
		"reviewed"		=> @reviewed_checkbox.isChecked()
	}
	super()
end

#toggle_instrumental_checked(checked) ⇒ Object



419
420
421
# File 'lib/wiki_lyrics/gui/gui-qt3.rb', line 419

def toggle_instrumental_checked( checked )
	@lyrics_text.setDisabled( checked )
end