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
}
Exemplo n.º 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();
}
Exemplo n.º 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;
}
Exemplo n.º 4
0
void CertificateInfoWidgetImpl::slotShowCertPathDetails( QListViewItem * item ) {
  if ( !item )
    return;

  // find the key corresponding to "item". This hack would not be
  // necessary if pathView was a Kleo::KeyListView, but it's
  // Qt-Designer-generated and I don't feel like creating a custom
  // widget spec for Kleo::KeyListView.
  unsigned int totalCount = 0;
  int itemIndex = -1;
  for ( const QListViewItem * i = pathView->firstChild() ; i ; i = i->firstChild() ) {
    if ( i == item )
      itemIndex = totalCount;
    ++totalCount;
  }

  assert( totalCount == mChain.size() || totalCount == mChain.size() + 1 );

  // skip pseudo root item with "not found message":
  if ( totalCount == mChain.size() + 1 )
    --itemIndex;

  assert( itemIndex >= 0 );

  KDialogBase * dialog =
    new KDialogBase( this, "dialog", false, i18n("Additional Information for Key"),
		     KDialogBase::Close, KDialogBase::Close );
  CertificateInfoWidgetImpl * top =
    new CertificateInfoWidgetImpl( mChain[itemIndex], mExternal, dialog );
  dialog->setMainWidget( top );
  // proxy the signal to our receiver:
  connect( top, SIGNAL(requestCertificateDownload(const QString&, const QString&)),
	   SIGNAL(requestCertificateDownload(const QString&, const QString&)) );
  dialog->show();
}
Exemplo n.º 5
0
    void editDynamicPlaylist( QWidget* parent, DynamicMode* mode )
    {
        DEBUG_BLOCK
        KDialogBase* dialog = basicDialog( parent );
        NewDynamic*  nd     = static_cast<NewDynamic*>(dialog->mainWidget());

        nd->m_name->setText( mode->title() );
        nd->m_cycleTracks->setChecked( mode->cycleTracks() );
        nd->m_markHistory->setChecked( mode->markHistory() );
        nd->m_upcomingIntSpinBox->setValue( mode->upcomingCount() );
        nd->m_previousIntSpinBox->setValue( mode->previousCount() );
        nd->m_appendCountIntSpinBox->setValue( mode->appendCount() );

        if( mode->appendType() == DynamicMode::CUSTOM )
        {
            //check items in the custom playlist
            nd->m_mixLabel->setText( i18n("Edit Dynamic Playlist") );
            QStringList items = mode->items();
            foreach( items )
            {
                QCheckListItem* current = static_cast<QCheckListItem*>( nd->selectPlaylist->findItem((*it),0) );
                if( current )
                    current->setOn(true);
            }
        }
Exemplo n.º 6
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;
}
Exemplo n.º 7
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 );
    }
Exemplo n.º 8
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;
}
Exemplo n.º 10
0
 KDialogBase* basicDialog( QWidget* parent )
 {
     KDialogBase* dialog = new KDialogBase( parent, "new dynamic", true,
                           i18n("Create Dynamic Playlist"),
                           KDialogBase::Ok | KDialogBase::Cancel,
                           KDialogBase::Ok, true );
     kapp->setTopWidget( dialog );
     dialog->setCaption( i18n("Dynamic Mode") );
     NewDynamic* nd = new NewDynamic( dialog, "new dynamic");
     //QSizePolicy policy;
     //policy.setHorData(QSizePolicy::Maximum);
     //dialog->setSizePolicy(policy);
     dialog->setMainWidget( nd );
     return dialog;
 }
Exemplo n.º 11
0
// static
void MessageBox::make(QWidget *parent, QMessageBox::Icon icon, const QString &text, const Job *job, const QString &caption, int options)
{
    KDialogBase *dialog = GpgME::hasFeature(GpgME::AuditLogFeature)
                          ? new KDialogBase(caption, KDialogBase::Yes | KDialogBase::No,
                                            KDialogBase::Yes, KDialogBase::Yes,
                                            parent, "error", true, true,
                                            KStdGuiItem::ok(), KGuiItem_showAuditLog())
                          : new KDialogBase(caption, KDialogBase::Yes,
                                            KDialogBase::Yes, KDialogBase::Yes,
                                            parent, "error", true, true,
                                            KStdGuiItem::ok()) ;
    if(options & KMessageBox::PlainCaption)
        dialog->setPlainCaption(caption);

    if(KDialogBase::No == KMessageBox::createKMessageBox(dialog, icon, text, QStringList(), QString::null, 0, options))
        auditLog(0, job);
}
Exemplo n.º 12
0
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();
}
Exemplo n.º 13
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());
  }
}
Exemplo n.º 14
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;
}