KInlineObject *InsertTextReferenceAction::createInlineObject() { const QList<KTextLocator*> textLocators = m_manager->textLocators(); if (textLocators.isEmpty()) { KMessageBox::information(m_canvas->canvasWidget(), i18n("Please create an index to reference first.")); return 0; } QWidget *widget = new QWidget(); QVBoxLayout *lay = new QVBoxLayout(widget); widget->setLayout(lay); lay->setMargin(0); QLabel *label = new QLabel(i18n("Select the index you want to reference"), widget); lay->addWidget(label); QStringList selectionList; foreach(KTextLocator* locator, textLocators) selectionList << locator->word() + '(' + QString::number(locator->pageNumber()) + ')'; QListWidget *list = new QListWidget(widget); lay->addWidget(list); list->addItems(selectionList); QPointer<KPageDialog> dialog = new KPageDialog(m_canvas->canvasWidget()); dialog->setCaption(i18n("%1 Options", i18n("Text Reference"))); // reuse the text passed in the constructor dialog->addPage(widget, QString()); KVariable *variable = 0; if (dialog->exec() == KPageDialog::Accepted && list->currentRow() >= 0) { KTextLocator *locator = textLocators[list->currentRow()]; Q_ASSERT(locator); variable = new KTextReference(locator->id()); } delete dialog; return variable; }
void MainWindow::showConfigurationDialog() { QPointer<KConfigDialog> dialog = new KConfigDialog(this, "settings", Settings::self()); KTextEditor::Editor *editor = KTextEditor::Editor::instance(); for (int index = 0; index < editor->configPages(); ++index) { KTextEditor::ConfigPage *page = editor->configPage(index, dialog); dialog->addPage(page, page->name(), page->icon().name(), page->fullName()); } dialog->exec(); }
void KateGlobal::configDialog(QWidget *parent) { QPointer<KPageDialog> kd = new KPageDialog(parent); kd->setCaption( i18n("Configure") ); kd->setButtons( KDialog::Ok | KDialog::Cancel | KDialog::Apply | KDialog::Help ); kd->setFaceType( KPageDialog::List ); kd->setHelp( QString(), KGlobal::mainComponent().componentName() ); QList<KTextEditor::ConfigPage*> editorPages; for (int i = 0; i < configPages (); ++i) { const QString name = configPageName (i); QFrame *page = new QFrame(); KPageWidgetItem *item = kd->addPage( page, name ); item->setHeader( configPageFullName (i) ); item->setIcon( configPageIcon(i) ); QVBoxLayout *topLayout = new QVBoxLayout( page ); topLayout->setMargin( 0 ); KTextEditor::ConfigPage *cp = configPage(i, page); connect(kd, SIGNAL(applyClicked ( )), cp, SLOT(apply())); topLayout->addWidget( cp); editorPages.append (cp); } if (kd->exec() && kd) { KateGlobalConfig::global()->configStart (); KateDocumentConfig::global()->configStart (); KateViewConfig::global()->configStart (); KateRendererConfig::global()->configStart (); for (int i=0; i < editorPages.count(); ++i) { editorPages.at(i)->apply(); } KateGlobalConfig::global()->configEnd (); KateDocumentConfig::global()->configEnd (); KateViewConfig::global()->configEnd (); KateRendererConfig::global()->configEnd (); } delete kd; }
KInlineObject *InsertVariableAction::createInlineObject() { KInlineObject *io = m_factory->createInlineObject(m_properties); KVariable *variable = dynamic_cast<KVariable*>(io); Q_ASSERT(variable); QWidget *widget = variable->createOptionsWidget(); if (widget) { if (widget->layout()) { widget->layout()->setMargin(0); } QPointer<KPageDialog> dialog = new KPageDialog(m_canvas->canvasWidget()); dialog->setCaption(i18n("%1 Options", m_templateName)); dialog->addPage(widget, QString()); if (dialog->exec() != KPageDialog::Accepted) { delete variable; variable = 0; } delete dialog; } return variable; }