Class: QT3::FixPagesDialog
- Inherits:
-
BaseDialog
- Object
- Qt::Dialog
- BaseDialog
- QT3::FixPagesDialog
- Defined in:
- lib/wiki_lyrics/gui/gui-qt3.rb
Instance Attribute Summary
Attributes inherited from BaseDialog
Instance Method Summary collapse
- #fetch_page ⇒ Object
- #fix_page ⇒ Object
-
#initialize(values) ⇒ FixPagesDialog
constructor
A new instance of FixPagesDialog.
- #setText(text_edit, text) ⇒ Object
- #submit_page ⇒ Object
Methods inherited from BaseDialog
Constructor Details
#initialize(values) ⇒ FixPagesDialog
Returns a new instance of FixPagesDialog.
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 |
# File 'lib/wiki_lyrics/gui/gui-qt3.rb', line 647 def initialize( values ) super( values ) @fetch_func = eval( @values["fetch_func"] ) @fix_func = eval( @values["fix_func"] ) @submit_func = eval( @values["submit_func"] ) setCaption( "#{values["site_name"]} - #{values["title"]}" ) url_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.url" )}</b>", self ) @url_lineedit = Qt::LineEdit.new( values["url"], self ) @page_text = Qt::TextEdit.new( self ) @page_text.setWordWrap( Qt::TextEdit::NoWrap ) @page_text.setTextFormat( Qt::PlainText ) @page_text.setFamily( "Monospace" ) @fetch_button = Qt::PushButton.new( I18n.get( "gui.common.load" ), self ) @fix_button = Qt::PushButton.new( I18n.get( "gui.common.fix" ), self ) @submit_button = Qt::PushButton.new( I18n.get( "gui.common.submit" ), self ) url_layout = Qt::HBoxLayout.new( 4 ) url_layout.setDirection( Qt::BoxLayout::LeftToRight ) url_layout.addWidget( url_label ) url_layout.addWidget( @url_lineedit ) = Qt::HBoxLayout.new( 4 ) .addStretch() .addWidget( @fetch_button ) .addWidget( @fix_button ) .addWidget( @submit_button ) layout = Qt::GridLayout.new( self, 9, 5, 5 ) layout.addLayout( url_layout, 0, 0 ) layout.addWidget( @page_text, 1, 0 ) layout.addLayout( , 2, 0 ) connect( @fetch_button, SIGNAL( "clicked()" ), self, SLOT( "fetch_page()" ) ) connect( @fix_button, SIGNAL( "clicked()" ), self, SLOT( "fix_page()" ) ) connect( @submit_button, SIGNAL( "clicked()" ), self, SLOT( "submit_page()" ) ) resize( 600, 400 ) end |
Instance Method Details
#fetch_page ⇒ Object
691 692 693 694 695 696 697 |
# File 'lib/wiki_lyrics/gui/gui-qt3.rb', line 691 def fetch_page() if (page_content = @fetch_func.call( @url_lineedit.text() )) @original_content = page_content @original_url = @url_lineedit.text() setText( @page_text, page_content ) end end |
#fix_page ⇒ Object
699 700 701 |
# File 'lib/wiki_lyrics/gui/gui-qt3.rb', line 699 def fix_page() setText( @page_text, @fix_func.call( @page_text.text() ) ) if @original_content end |
#setText(text_edit, text) ⇒ Object
642 643 644 645 |
# File 'lib/wiki_lyrics/gui/gui-qt3.rb', line 642 def setText( text_edit, text ) text_edit.clear() text_edit.append( text ) end |
#submit_page ⇒ Object
703 704 705 706 707 708 709 710 711 712 |
# File 'lib/wiki_lyrics/gui/gui-qt3.rb', line 703 def submit_page() if @original_content != nil && @original_content != (page_content = @page_text.text()) if @submit_func.call( @original_url, page_content ) @original_content = page_content puts I18n.get( "gui.fixpages.success", @original_url ) else puts I18n.get( "gui.fixpages.error", @original_url ) end end end |