Class: QT3::WikiPluginDialog

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

Returns a new instance of WikiPluginDialog.



242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/wiki_lyrics/gui/gui-qt3.rb', line 242

def initialize( values )
	super( values )

	setCaption( I18n.get( "gui.wikiplugin.title", values["site_name"] ) )

	general_group = Qt::GroupBox.new( I18n.get( "gui.wikiplugin.general" ), self )
	general_group.setColumnLayout( 0, Qt::Vertical )
	general_group.layout().setSpacing( 5 )

	@submit_checkbox = Qt::CheckBox.new( general_group )
	@submit_checkbox.setChecked( values["submit"].to_s() == "true" )
	@submit_checkbox.setText( I18n.get( "gui.wikiplugin.general.submit", values["site_name"] ) )

	@review_checkbox = Qt::CheckBox.new( general_group )
	@review_checkbox.setEnabled( @submit_checkbox.isChecked() )
	@review_checkbox.setChecked( @review_checkbox.isEnabled() && values["review"].to_s() == "true" )
	@review_checkbox.setText( I18n.get( "gui.wikiplugin.general.review" ) )

	@prompt_autogen_checkbox = Qt::CheckBox.new( general_group )
	@prompt_autogen_checkbox.setEnabled( @review_checkbox.isChecked() )
	@prompt_autogen_checkbox.setChecked( @prompt_autogen_checkbox.isEnabled() && values["prompt_autogen"].to_s() == "true" )
	@prompt_autogen_checkbox.setText( I18n.get( "gui.wikiplugin.general.autogen" ) )

	@prompt_no_lyrics_checkbox = Qt::CheckBox.new( general_group )
	@prompt_no_lyrics_checkbox.setEnabled( @review_checkbox.isChecked() )
	@prompt_no_lyrics_checkbox.setChecked( @prompt_no_lyrics_checkbox.isEnabled() && values["prompt_no_lyrics"].to_s() == "true" )
	@prompt_no_lyrics_checkbox.setText( I18n.get( "gui.wikiplugin.general.nolyrics" ) )

	 = Qt::GroupBox.new( I18n.get( "gui.wikiplugin.login" ), self )
	.setColumnLayout( 0, Qt::Vertical )
	.layout().setSpacing( 5 )

	username_label = Qt::Label.new( I18n.get( "gui.wikiplugin.login.username" ),  )
	@username_lineedit = Qt::LineEdit.new( values["username"],  )

	password_label = Qt::Label.new( I18n.get( "gui.wikiplugin.login.password" ),  )
	@password_lineedit = Qt::LineEdit.new( values["password"],  )
	@password_lineedit.setEchoMode( Qt::LineEdit::Password )

	buttons = create_action_buttons()
	update_accept_button_state()

	general_group_layout = Qt::GridLayout.new( general_group.layout() )
	general_group_layout.setAlignment( Qt::AlignTop )
	general_group_layout.addMultiCellWidget( @submit_checkbox, 0, 0, 0, 1 )
	general_group_layout.addMultiCellWidget( @review_checkbox, 1, 1, 0, 1 )
	general_group_layout.addMultiCellWidget( @prompt_autogen_checkbox, 2, 2, 0, 1 )
	general_group_layout.addMultiCellWidget( @prompt_no_lyrics_checkbox, 3, 3, 0, 1 )

	 = Qt::GridLayout.new( .layout() )
	.setAlignment( Qt::AlignTop )
	.addWidget( username_label, 1, 0 );
	.addWidget( @username_lineedit, 1, 1 );
	.addWidget( password_label, 2, 0 )
	.addWidget( @password_lineedit, 2, 1 )

	layout = Qt::GridLayout.new( self, 1, 1, 5 )
	layout.addMultiCellWidget( general_group, 0, 0, 0, 2 )
	layout.addMultiCellWidget( , 1, 1, 0, 2 )
	layout.addItem( Qt::SpacerItem.new( 81, 20, Qt::SizePolicy::Expanding, Qt::SizePolicy::Minimum ), 2, 0 );
	layout.addMultiCellLayout( buttons, 2, 2, 0, 2 )

	connect( @username_lineedit, SIGNAL( "textChanged(const QString&)" ), self, SLOT( "update_accept_button_state()" ) )
	connect( @submit_checkbox, SIGNAL( "toggled(bool)" ), self, SLOT( "toggle_submit_checked(bool)" ) )
	connect( @review_checkbox, SIGNAL( "toggled(bool)" ), self, SLOT( "toggle_review_checked(bool)" ) )

	resize( 300, 50 )
end

Instance Method Details

#acceptObject



334
335
336
337
338
339
340
341
342
343
344
# File 'lib/wiki_lyrics/gui/gui-qt3.rb', line 334

def accept()
	@values = {
		"submit"			=> @submit_checkbox.isChecked(),
		"review"			=> @review_checkbox.isChecked(),
		"prompt_autogen"	=> @prompt_autogen_checkbox.isChecked(),
		"prompt_no_lyrics"	=> @prompt_no_lyrics_checkbox.isChecked(),
		"username"			=> @username_lineedit.text(),
		"password"			=> @password_lineedit.text(),
	}
	super()
end

#toggle_review_checked(checked) ⇒ Object



321
322
323
324
325
326
327
328
# File 'lib/wiki_lyrics/gui/gui-qt3.rb', line 321

def toggle_review_checked( checked )
	@prompt_autogen_checkbox.setEnabled( checked )
	@prompt_no_lyrics_checkbox.setEnabled( checked )
	if ! checked
		@prompt_autogen_checkbox.setChecked( false )
		@prompt_no_lyrics_checkbox.setChecked( false )
	end
end

#toggle_submit_checked(checked) ⇒ Object



311
312
313
314
315
316
317
318
319
# File 'lib/wiki_lyrics/gui/gui-qt3.rb', line 311

def toggle_submit_checked( checked )
	@review_checkbox.setEnabled( checked )
	if ! checked
		@review_checkbox.setChecked( false )
		@prompt_autogen_checkbox.setChecked( false )
		@prompt_no_lyrics_checkbox.setChecked( false )
	end
	update_accept_button_state()
end

#update_accept_button_stateObject



330
331
332
# File 'lib/wiki_lyrics/gui/gui-qt3.rb', line 330

def update_accept_button_state()
	@accept_button.setEnabled( ! @submit_checkbox.isChecked() || ! @username_lineedit.text().empty? )
end