void KDocumentTextBuffer::checkConsistency() { QString bufferContents = codec()->toUnicode( slice(0, length())->text() ); QString documentContents = kDocument()->text(); if ( bufferContents != documentContents ) { KUrl url = kDocument()->url(); kDocument()->setModified(false); kDocument()->setReadWrite(false); m_aboutToClose = true; QTemporaryFile f; f.setAutoRemove(false); f.open(); f.close(); kDocument()->saveAs(f.fileName()); KDialog* dialog = new KDialog; dialog->setButtons(KDialog::Ok | KDialog::Cancel); QLabel* label = new QLabel(i18n("Sorry, an internal error occurred in the text synchronization component.<br>" "You can try to reload the document or disconnect.")); label->setWordWrap(true); dialog->setMainWidget(label); dialog->button(KDialog::Ok)->setText(i18n("Reload document")); dialog->button(KDialog::Cancel)->setText(i18n("Disconnect")); DocumentReopenHelper* helper = new DocumentReopenHelper(url, kDocument()); connect(dialog, SIGNAL(accepted()), helper, SLOT(reopen())); // We must not use exec() here, since that will create a nested event loop, // which might handle incoming network events. This can easily get very messy. dialog->show(); } }
QDialog* SemanticMarkupEdition::newLinkDialog( //krazy:exclude=qclasses const QString& url) const { KDialog* dialog = new KDialog(mTextEdit); dialog->setModal(true); dialog->setButtons(KDialog::Ok | KDialog::Cancel); dialog->button(KDialog::Ok)->setObjectName("okButton"); dialog->button(KDialog::Cancel)->setObjectName("cancelButton"); SemanticMarkupLinkWidget* linkWidget = new SemanticMarkupLinkWidget(dialog); linkWidget->setUrl(url); dialog->setMainWidget(linkWidget); dialog->setWindowTitle(linkWidget->windowTitle()); return dialog; }
void ExpressionLineEdit::insertComponent() { if (!m_clock) { return; } ComponentWidget *componentWidget = new ComponentWidget(NULL, m_clock); KDialog *dialog = new KDialog(this); dialog->setMainWidget(componentWidget); dialog->setModal(false); dialog->setWindowTitle(i18n("Insert Clock Component")); dialog->setButtons(KDialog::Apply | KDialog::Close); dialog->button(KDialog::Apply)->setText(i18n("Insert")); dialog->button(KDialog::Apply)->setEnabled(false); dialog->show(); connect(dialog->button(KDialog::Apply), SIGNAL(clicked()), componentWidget, SLOT(insertComponent())); connect(componentWidget, SIGNAL(componentChanged(bool)), dialog->button(KDialog::Apply), SLOT(setEnabled(bool))); connect(componentWidget, SIGNAL(insertComponent(QString,QString)), this, SLOT(insertComponent(QString,QString))); }
void KDocumentTextBuffer::checkLineEndings() { QString bufferContents = kDocument()->text(); if ( bufferContents.contains("\r\n") || bufferContents.contains("\r") ) { KDialog* dlg = new KDialog(kDocument()->activeView()); dlg->setAttribute(Qt::WA_DeleteOnClose); dlg->setButtons(KDialog::Ok | KDialog::Cancel); dlg->button(KDialog::Ok)->setText(i18n("Continue")); QLabel* l = new QLabel(i18n("The document you opened contains non-standard line endings. " "Do you want to convert them to the standard \"\\n\" format?<br><br>" "<i>Note: This change will be synchronized to the server.</i>"), dlg); l->setWordWrap(true); dlg->setMainWidget(l); connect(dlg, SIGNAL(okClicked()), this, SLOT(replaceLineEndings())); dlg->show(); } }
void ManagedDocument::unrecoverableError(Document* document, QString error) { Q_ASSERT(document == m_infDocument); if ( m_document ) { QTemporaryFile file; file.setAutoRemove(false); file.open(); file.close(); m_document->saveAs(KUrl(file.fileName())); } if ( ! error.isEmpty() ) { // We must not use exec() here (so no KMessageBox!) or we will run into // nested-event-loop-network-code trouble. KDialog* dlg = new KDialog(); dlg->setCaption(i18n("Collaborative text editing")); QLabel* message = new QLabel(error); message->setWordWrap(true); dlg->setMainWidget(message); dlg->setButtons(KDialog::Cancel); dlg->button(KDialog::Cancel)->setText(i18n("Disconnect")); dlg->setAttribute(Qt::WA_DeleteOnClose); dlg->show(); } }