void KstVectorDialogI::configureSource() {
  bool isNew = false;
  KST::dataSourceList.lock().readLock();
  KstDataSourcePtr ds = *KST::dataSourceList.findReusableFileName(_w->FileName->url());
  KST::dataSourceList.lock().unlock();
  if (!ds) {
    isNew = true;
    ds = KstDataSource::loadSource(_w->FileName->url());
    if (!ds || !ds->isValid()) {
      _w->_configure->setEnabled(false);
      return;
    }
  }

  assert(_configWidget);
  KDialogBase *dlg = new KDialogBase(this, "Data Config Dialog", true, i18n("Configure Data Source"));
  if (isNew) {
    connect(dlg, SIGNAL(okClicked()), _configWidget, SLOT(save()));
    connect(dlg, SIGNAL(applyClicked()), _configWidget, SLOT(save()));
  } else {
    connect(dlg, SIGNAL(okClicked()), this, SLOT(markSourceAndSave()));
    connect(dlg, SIGNAL(applyClicked()), this, SLOT(markSourceAndSave()));
  }
  _configWidget->reparent(dlg, QPoint(0, 0));
  dlg->setMainWidget(_configWidget);
  _configWidget->setInstance(ds);
  _configWidget->load();
  dlg->exec();
  _configWidget->reparent(0L, QPoint(0, 0));
  dlg->setMainWidget(0L);
  delete dlg;
  updateCompletion(); // could be smarter by only running if Ok/Apply clicked
}
Beispiel #2
0
void KMMainView::slotToolSelected(int ID)
{
    KMTimer::self()->hold();

    QString libname = m_toollist[ID];
    libname.prepend("kdeprint_tool_");
    if(m_current && !m_current->device().isEmpty() && !libname.isEmpty())
    {
        KLibFactory *factory = KLibLoader::self()->factory(libname.local8Bit());
        if(factory)
        {
            QStringList args;
            args << m_current->device() << m_current->printerName();
            KDialogBase *dlg = static_cast< KDialogBase * >(factory->create(this, "Tool", 0, args));
            if(dlg)
                dlg->exec();
            delete dlg;
        }
    }
    else
        KMessageBox::error(this, i18n("Unable to start printer tool. Possible reasons are: "
                                      "no printer selected, the selected printer doesn't have "
                                      "any local device defined (printer port), or the tool library "
                                      "could not be found."));

    KMTimer::self()->release();
}
Beispiel #3
0
// **** keyboard selection dialog *********************************************
int KNHelper::selectDialog(QWidget *parent, const QString &caption, const QStringList &options, int initialValue)
{
    KDialogBase *dlg = new KDialogBase(KDialogBase::Plain, caption, KDialogBase::Ok | KDialogBase::Cancel,
                                       KDialogBase::Ok, parent);
    QFrame *page = dlg->plainPage();
    QHBoxLayout *pageL = new QHBoxLayout(page, 8, 5);

    KNDialogListBox *list = new KNDialogListBox(true, page);
    pageL->addWidget(list);

    QString s;
    for(QStringList::ConstIterator it = options.begin(); it != options.end(); ++it)
    {
        s = (*it);
        s.replace(QRegExp("&"), "");  // remove accelerators
        list->insertItem(s);
    }

    list->setCurrentItem(initialValue);
    list->setFocus();
    restoreWindowSize("selectBox", dlg, QSize(247, 174));

    int ret;
    if(dlg->exec())
        ret = list->currentItem();
    else
        ret = -1;

    saveWindowSize("selectBox", dlg->size());
    delete dlg;
    return ret;
}
Beispiel #4
0
void K3bDataView::editBootImages()
{
  KDialogBase* d = new KDialogBase( this, "", true, i18n("Edit Boot Images"),
				    KDialogBase::Ok, KDialogBase::Ok, true );
  d->setMainWidget( new K3bBootImageView( m_doc, d ) );
  d->exec();
  delete d;
}
Beispiel #5
0
    void dynamicDialog( QWidget* parent )
    {
        KDialogBase* dialog = basicDialog( parent );
        NewDynamic*  nd     = static_cast<NewDynamic*>(dialog->mainWidget());
        nd->m_mixLabel->setText( i18n("Add Dynamic Playlist") );

        if( dialog->exec() == QDialog::Accepted )
            addDynamic( nd );
    }
Beispiel #6
0
void KstVectorDialogI::configureSource() {
  assert(_configWidget);
  KDialogBase *dlg = new KDialogBase(this, "Data Config Dialog", true, i18n("Configure Data Source"));
  connect(dlg, SIGNAL(okClicked()), _configWidget, SLOT(save()));
  connect(dlg, SIGNAL(applyClicked()), _configWidget, SLOT(save()));
  _configWidget->reparent(dlg, QPoint(0, 0));
  dlg->setMainWidget(_configWidget);
  dlg->exec();
  _configWidget->reparent(0L, QPoint(0, 0));
  dlg->setMainWidget(0L);
  delete dlg;
}
void KstSettingsDlgI::configureSource()
{
  KstDataSourceConfigWidget *cw = KstDataSource::configWidgetForPlugin(_source->currentText());
  if (!cw) {
    return;
  }
  KDialogBase *dlg = new KDialogBase(this, "Data Config Dialog", true, i18n("Configure Data Source"));
  connect(dlg, SIGNAL(okClicked()), cw, SLOT(save()));
  cw->reparent(dlg, QPoint(0, 0));
  dlg->setMainWidget(cw);
  cw->load();
  dlg->exec();
  delete dlg;
}
void KopeteAccountConfig::slotEditAccount()
{
	KopeteAccountLVI *lvi = static_cast<KopeteAccountLVI*>( m_view->mAccountList->selectedItem() );
	if ( !lvi || !lvi->account() )
		return;

	Kopete::Account *ident = lvi->account();
	Kopete::Protocol *proto = ident->protocol();

	KDialogBase *editDialog = new KDialogBase( this, "KopeteAccountConfig::editDialog", true,
		i18n( "Edit Account" ), KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, true );

	KopeteEditAccountWidget *m_accountWidget = proto->createEditAccountWidget( ident, editDialog );
	if ( !m_accountWidget )
		return;

	// FIXME: Why the #### is EditAccountWidget not a QWidget?!? This sideways casting
	//        is braindead and error-prone. Looking at MSN the only reason I can see is
	//        because it allows direct subclassing of designer widgets. But what is
	//        wrong with embedding the designer widget in an empty QWidget instead?
	//        Also, if this REALLY has to be a pure class and not a widget, then the
	//        class should at least be renamed to EditAccountIface instead - Martijn
	QWidget *w = dynamic_cast<QWidget *>( m_accountWidget );
	if ( !w )
		return;

	editDialog->setMainWidget( w );
	if ( editDialog->exec() == QDialog::Accepted )
	{
		if( m_accountWidget->validateData() )
			m_accountWidget->apply();
	}

	// FIXME: Why deleteLater? It shouldn't be in use anymore at this point - Martijn
	editDialog->deleteLater();
	load();
	Kopete::AccountManager::self()->save();
}
Beispiel #9
0
void KstChangeFileDialog::configureSource()
{
  bool isNew = false;
  KST::dataSourceList.lock().readLock();
  KstDataSourcePtr ds = *KST::dataSourceList.findReusableFileName(_file);
  KST::dataSourceList.lock().unlock();
  if (!ds) {
    isNew = true;
    ds = KstDataSource::loadSource(_file);
    if (!ds || !ds->isValid()) {
      _configureSource->setEnabled(false);
      return;
    }
  }

  if (_configWidget) {
    KDialogBase *dlg = new KDialogBase(this, "Data Config Dialog", true, tr("Configure Data Source"));
    if (isNew) {
      connect(dlg, SIGNAL(okClicked()), _configWidget, SLOT(save()));
      connect(dlg, SIGNAL(applyClicked()), _configWidget, SLOT(save()));
    } else {
      connect(dlg, SIGNAL(okClicked()), this, SLOT(markSourceAndSave()));
      connect(dlg, SIGNAL(applyClicked()), this, SLOT(markSourceAndSave()));
    }

    _configWidget->reparent(dlg, QPoint(0, 0));
    dlg->setMainWidget(_configWidget);
    static_cast<KstDataSourceConfigWidget*>((QWidget*)_configWidget)->setInstance(ds);
    static_cast<KstDataSourceConfigWidget*>((QWidget*)_configWidget)->load();
    dlg->exec();
    _configWidget->reparent(0L, QPoint(0, 0));
    dlg->setMainWidget(0L);
    delete dlg;
    sourceChanged(_dataFile->url());
  }
}
Beispiel #10
0
int main(int argc, char** argv)
{
  KApplication app(argc, argv, "DialogBaseTest");
  // -----
  QString text= // the explanation shown by the example dialog
    "<center><h1>DialogBase Example</h1></center><hr><br>"
    "This example shows the usage of the <i>DialogBase</i>  class. "
    "<i>DialogBase</i> is the KDE user interface class used to create "
    "dialogs with unique layout without having to define an own dialog "
    "style for your application. <br>"
    "It provides three standard buttons (<b>OK</b>, <b>Apply</b>, and "
    "<b>Cancel</b>) that are needed in most dialogs. Each one may be "
    "hidden, enabled or disabled, and tooltips and quickhelp texts might be"
    " added. And you do not need to bother about geometry management, this "
    "is all done automatically.<br>"
    "To polish your user interface even further, you might want to add "
    "textures to the inner and the outer frame of the dialog (the frame is "
    "created by the dialog object). This is done "
    "using the <tt>setMainFrameTile</tt> and the <tt>setBaseFrameTile</tt> "
    "methods. These tiles are added application-wide, so each dialog "
    "of you application uses the same tiles. This is a tribute to a "
    "comprehensable user interface.<br>"
    "The class supports the creation of dialogs without being forced "
    "to derive an own class for it, but you may derive your own class "
    "for a better code structure.<br>"
    "If you wrote a help chapter explaining what your dialog does, you "
    "should add a link to it to the dialog using <tt>setHelp</tt>. You do "
    "not have to take care about launching the help viewer, just set the "
    "help file and topic and of course copy it to your documentation "
    "directory during the program installation.";
  /* Create the dialog object. DialogBase is derived from QDialog, but
     you do not need to derive it to create a nice-looking dialog. Mostly,
     you already have a widget class representing the core of your dialog,
     and you only need to add a frame around it and the default buttons.

     If you want to derive it, you still can, moving all code shown here
     inside of your new class. */
  KDialogBase dialog;
  /* Set a help chapter. If you do not set one, the link is not shown, and the
     upper part of the frame shrinks as much as possible. The help window "
     "will of course only pop up if you correctly installed kdebase. */
  // I disabled it, as khcclient did not run for me.
  // dialog.setHelp("kdehelp/intro.html", "", "");
  /* This QTextView is intended to be the main widget of our dialog. The
     main widget is placed inside the dialogs frame, with the buttons below
     it. You do not have to take care about the size handling, but it is a
     good idea to set the main wigdets minimum size, since the sizes Qt and
     the DialogBase class guess are sometimes ugly.

     It is important that your main widget is created with the dialog object
     as its parent! */
  QTextView view(text, QString::null, &dialog);
  //view.setMinimumSize(400, view.heightForWidth(400)+20);
  view.setMinimumSize( 250, 300 );
  dialog.setMainWidget(&view);
  /* After finishing the setup of your main widget, the dialog needs to be
     adjusted. It is not done automatically, since the layout of the main
     widget may change before the dialog is shown. Additionally, setting a
     help chapter may cause a need for adjustment since it modifies the height
     of the upper frame. */
  dialog.resize(dialog.minimumSize());
  /* The dialog object is used just as any other QDialog: */
  if(dialog.exec())
    {
      qDebug("Accepted.");
    } else {
      qDebug("Rejected.");
    }
  return 0;
}