예제 #1
0
SpellChecker::SpellChecker(Editor* document)
	: QDialog(document->parentWidget(), Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint),
	m_document(document)
{
	setWindowTitle(tr("Check Spelling"));
	setWindowModality(Qt::WindowModal);
	setAttribute(Qt::WA_DeleteOnClose);
	m_dictionary = new Dictionary(this);

	// Create widgets
        m_context = new Editor(this);
	m_context->setReadOnly(true);
	m_context->setTabStopWidth(50);
	QPushButton* add_button = new QPushButton(tr("Add"), this);
	add_button->setAutoDefault(false);
	connect(add_button, SIGNAL(clicked()), this, SLOT(add()));
	QPushButton* ignore_button = new QPushButton(tr("Ignore"), this);
	ignore_button->setAutoDefault(false);
	connect(ignore_button, SIGNAL(clicked()), this, SLOT(ignore()));
	QPushButton* ignore_all_button = new QPushButton(tr("Ignore All"), this);
	ignore_all_button->setAutoDefault(false);
	connect(ignore_all_button, SIGNAL(clicked()), this, SLOT(ignoreAll()));

	m_suggestion = new QLineEdit(this);
	QPushButton* change_button = new QPushButton(tr("Change"), this);
	change_button->setAutoDefault(false);
	connect(change_button, SIGNAL(clicked()), this, SLOT(change()));
	QPushButton* change_all_button = new QPushButton(tr("Change All"), this);
	change_all_button->setAutoDefault(false);
	connect(change_all_button, SIGNAL(clicked()), this, SLOT(changeAll()));
	m_suggestions = new QListWidget(this);
	connect(m_suggestions, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(suggestionChanged(QListWidgetItem*)));

	QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this);
	connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));

	// Lay out dialog
	QGridLayout* layout = new QGridLayout(this);
	layout->setMargin(12);
	layout->setSpacing(6);
	layout->setColumnMinimumWidth(2, 6);

	layout->addWidget(new QLabel(tr("Not in dictionary:"), this), 0, 0, 1, 2);
	layout->addWidget(m_context, 1, 0, 3, 2);
	layout->addWidget(add_button, 1, 3);
	layout->addWidget(ignore_button, 2, 3);
	layout->addWidget(ignore_all_button, 3, 3);

	layout->setRowMinimumHeight(4, 12);

	layout->addWidget(new QLabel(tr("Change to:"), this), 5, 0);
	layout->addWidget(m_suggestion, 5, 1);
	layout->addWidget(m_suggestions, 6, 0, 1, 2);
	layout->addWidget(change_button, 5, 3);
	layout->addWidget(change_all_button, 6, 3, Qt::AlignTop);

	layout->setRowMinimumHeight(7, 12);
	layout->addWidget(buttons, 8, 3);
}
예제 #2
0
KSpellDlg::KSpellDlg( QWidget * parent, const char * name, bool _progressbar, bool _modal )
  : KDialogBase(
      parent, name, _modal, i18n("Check Spelling"), Help|Cancel|User1,
      Cancel, true, i18n("&Finished")
    ),
    progressbar( false )
{
  Q_UNUSED( _progressbar );
  d = new KSpellDlgPrivate;
  d->ui = new KSpellUI( this );
  setMainWidget( d->ui );

  connect( d->ui->m_replaceBtn, SIGNAL(clicked()),
           this, SLOT(replace()));
  connect( this, SIGNAL(ready(bool)),
           d->ui->m_replaceBtn, SLOT(setEnabled(bool)) );

  connect( d->ui->m_replaceAllBtn, SIGNAL(clicked()), this, SLOT(replaceAll()));
  connect(this, SIGNAL(ready(bool)), d->ui->m_replaceAllBtn, SLOT(setEnabled(bool)));

  connect( d->ui->m_skipBtn, SIGNAL(clicked()), this, SLOT(ignore()));
  connect( this, SIGNAL(ready(bool)), d->ui->m_skipBtn, SLOT(setEnabled(bool)));

  connect( d->ui->m_skipAllBtn, SIGNAL(clicked()), this, SLOT(ignoreAll()));
  connect( this, SIGNAL(ready(bool)), d->ui->m_skipAllBtn, SLOT(setEnabled(bool)));

  connect( d->ui->m_addBtn, SIGNAL(clicked()), this, SLOT(add()));
  connect( this, SIGNAL(ready(bool)), d->ui->m_addBtn, SLOT(setEnabled(bool)));

  connect( d->ui->m_suggestBtn, SIGNAL(clicked()), this, SLOT(suggest()));
  connect( this, SIGNAL(ready(bool)), d->ui->m_suggestBtn, SLOT(setEnabled(bool)) );
  d->ui->m_suggestBtn->hide();

  connect(this, SIGNAL(user1Clicked()), this, SLOT(stop()));

  connect( d->ui->m_replacement, SIGNAL(textChanged(const QString &)),
           SLOT(textChanged(const QString &)) );

  connect( d->ui->m_replacement, SIGNAL(returnPressed()),   SLOT(replace()) );
  connect( d->ui->m_suggestions, SIGNAL(selectionChanged(QListViewItem*)),
           SLOT(slotSelectionChanged(QListViewItem*)) );

  connect( d->ui->m_suggestions, SIGNAL( doubleClicked ( QListViewItem *, const QPoint &, int ) ),
           SLOT( replace() ) );
  d->spellConfig = new KSpellConfig( 0, 0 ,0, false );
  d->spellConfig->fillDicts( d->ui->m_language );
  connect( d->ui->m_language, SIGNAL(activated(int)),
	   d->spellConfig, SLOT(sSetDictionary(int)) );
  connect( d->spellConfig, SIGNAL(configChanged()),
           SLOT(slotConfigChanged()) );

  setHelp( "spelldlg", "kspell" );
  setMinimumSize( sizeHint() );
  emit ready( false );
}