Class: QT4::SubmitAlbumDialog

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) ⇒ SubmitAlbumDialog

Returns a new instance of SubmitAlbumDialog.



473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
# File 'lib/wiki_lyrics/gui/gui-qt4.rb', line 473

def initialize( values )
	super( values )

	@values = values

	setWindowTitle( I18n.get( "gui.submitalbum.title", values["site_name"] ) )

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

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

	month_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.month" )}</b>", self )
	@month_spinbox = Qt::SpinBox.new( self )
	@month_spinbox.setRange( 0, 12 )
	@month_spinbox.setValue( values["month"].to_i() )

	day_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.day" )}</b>", self )
	@day_spinbox = Qt::SpinBox.new( self )
	@day_spinbox.setRange( 0, 31 )
	@day_spinbox.setValue( values["day"].to_i() )

	image_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.image" )}</b>", self )
	@image_path_lineedit = Qt::LineEdit.new( values["image_path"], self )
	if ! values.include?( "image_path" )
		@image_path_lineedit.setEnabled( false )
		@image_path_lineedit.setText( I18n.get( "gui.submitalbum.coverfound" ) )
	else
		@image_button = Qt::PushButton.new( "...", self )
		@image_button.setMaximumWidth( 40 )
		connect( @image_button, SIGNAL( "clicked()" ), self, SLOT( "browse_image()" ) )
	end

	@tracks_text = Qt::TextEdit.new( self )
	@tracks_text.setLineWrapMode( Qt::TextEdit::NoWrap )
	@tracks_text.setPlainText( values["tracks"] )

	@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" ) )

	image_layout = Qt::HBoxLayout.new()
	image_layout.addWidget( @image_path_lineedit )
	image_layout.addWidget( @image_button ) if @values.include?( "image_path" )

	grid_layout = Qt::GridLayout.new( self )
	grid_layout.margin = 4
	grid_layout.spacing = 4
	grid_layout.setColumnStretch( 1, 2 )
	grid_layout.setColumnStretch( 3, 2 )
	grid_layout.setColumnStretch( 5, 2 )
	grid_layout.addWidget( artist_label, 0, 0, Qt::AlignRight )
	grid_layout.addWidget( @artist_lineedit, 0, 1, 1, 5 )
	grid_layout.addWidget( album_label, 1, 0, Qt::AlignRight )
	grid_layout.addWidget( @album_lineedit, 1, 1, 1, 5 )
	grid_layout.addWidget( year_label, 2, 0, Qt::AlignRight )
	grid_layout.addWidget( @year_spinbox, 2, 1 )
	grid_layout.addWidget( month_label, 2, 2, Qt::AlignRight )
	grid_layout.addWidget( @month_spinbox, 2, 3 )
	grid_layout.addWidget( day_label, 2, 4, Qt::AlignRight )
	grid_layout.addWidget( @day_spinbox, 2, 5 )
	grid_layout.addWidget( image_label, 3, 0, Qt::AlignRight )
	grid_layout.addLayout( image_layout, 3, 1, 1, 5 )
	grid_layout.addWidget( @tracks_text, 4, 0, 1, 6 )
	grid_layout.addWidget( @reviewed_checkbox, 5, 0, 1, 6 )
	grid_layout.addLayout( buttons, 6, 0, 1, 6 )

	resize( 600, 400 )
end

Instance Method Details

#acceptObject



568
569
570
571
572
573
574
575
576
577
578
579
580
581
# File 'lib/wiki_lyrics/gui/gui-qt4.rb', line 568

def accept()
	aux = {
		"artist"	=> @artist_lineedit.text(),
		"album"		=> @album_lineedit.text(),
		"year"		=> @year_spinbox.value(),
		"month"		=> @month_spinbox.value(),
		"day"		=> @day_spinbox.value(),
		"tracks"	=> @tracks_text.toPlainText(),
		"reviewed"	=> @reviewed_checkbox.isChecked()
	}
	aux["image_path"] = @image_path_lineedit.text() if @values.include?( "image_path" )
	@values = aux
	super()
end

#browse_imageObject



551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
# File 'lib/wiki_lyrics/gui/gui-qt4.rb', line 551

def browse_image()
	dirname = @image_path_lineedit.text().strip()
	dirname = QT4.empty_string?( dirname ) ? (ENV["HOME"] ? ENV["HOME"] : ".") : File.dirname( dirname )
	dialog = Qt::FileDialog.new()
	dialog.setWindowTitle( I18n.get( "gui.uploadcover.browseimage.title" ) )
	dialog.setFilters( [
		I18n.get( "gui.uploadcover.browseimage.images" ) + " (*.jpg *.JPG *.png *.PNG *.bmp *.BMP)",
		I18n.get( "gui.uploadcover.browseimage.allfiles" ) + " (*)"
	] )
	dialog.setDirectory( dirname )
	dialog.setFileMode( Qt::FileDialog::ExistingFile )
	 if dialog.exec() == Qt::Dialog::Accepted
      		image_path = dialog.selectedFiles()[0]
		@image_path_lineedit.setText( image_path.strip() ) if ! QT4.empty_string?( image_path )
	end
end