Class: QT4::SubmitSongDialog

Inherits:
BaseDialog
  • Object
show all
Defined in:
lib/wiki_lyrics/gui/gui-qt4.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.



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
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
# File 'lib/wiki_lyrics/gui/gui-qt4.rb', line 381

def initialize( values )
	super( values )

	edit_mode = @values["edit_mode"].to_s() == "true"
	setWindowTitle( 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.setRange( 1900, 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.setLineWrapMode( Qt::TextEdit::NoWrap )
	@lyrics_text.setPlainText( 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 )
	grid_layout.margin = 4
	grid_layout.spacing = 4
	grid_layout.addWidget( artist_label, 0, 0, Qt::AlignRight )
	grid_layout.addWidget( @artist_lineedit, 0, 1 )
	grid_layout.addWidget( title_label, 0, 2, Qt::AlignRight )
	grid_layout.addWidget( @title_lineedit, 0, 3 )
	grid_layout.addWidget( credits_label, 1, 0, Qt::AlignRight )
	grid_layout.addWidget( @credits_lineedit, 1, 1 )
	grid_layout.addWidget( lyricist_label, 1, 2, Qt::AlignRight )
	grid_layout.addWidget( @lyricist_lineedit, 1, 3 )
	grid_layout.addWidget( year_label, 2, 0, Qt::AlignRight )
	grid_layout.addWidget( @year_spinbox, 2, 1 )
	grid_layout.addWidget( album_label, 2, 2, Qt::AlignRight )
	grid_layout.addWidget( @album_lineedit, 2, 3 )
	grid_layout.addWidget( @instrumental_checkbox, 3, 0, 1, 4 )
	grid_layout.addWidget( @lyrics_text, 4, 0, 1, 4 )
	grid_layout.addWidget( @reviewed_checkbox, 5, 0, 1, 4 )
	grid_layout.addLayout( buttons, 6, 0, 1, 4 )

	resize( 600, 400 )

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

end

Instance Method Details

#acceptObject



452
453
454
455
456
457
458
459
460
461
462
463
464
465
# File 'lib/wiki_lyrics/gui/gui-qt4.rb', line 452

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

#toggle_instrumental_checked(checked) ⇒ Object



448
449
450
# File 'lib/wiki_lyrics/gui/gui-qt4.rb', line 448

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