Exemple #1
0
void KNewFileMenuPrivate::confirmCreatingHiddenDir(const QString& name)
{
    if(!KMessageBox::shouldBeShownContinue("confirm_create_hidden_dir")){
	_k_slotCreateHiddenDirectory();
	return;
    }
  
    KGuiItem continueGuiItem(KStandardGuiItem::cont());
    continueGuiItem.setText(i18nc("@action:button", "Create directory"));
    KGuiItem cancelGuiItem(KStandardGuiItem::cancel());
    cancelGuiItem.setText(i18nc("@action:button", "Enter a different name"));
    
    KDialog* confirmDialog = new KDialog(m_parentWidget);
    confirmDialog->setCaption(i18n("Create hidden directory?"));
    confirmDialog->setModal(m_modal);
    confirmDialog->setAttribute(Qt::WA_DeleteOnClose);
    KMessageBox::createKMessageBox(confirmDialog, QMessageBox::Warning, 
	  i18n("The name \"%1\" starts with a dot, so the directory will be hidden by default.", name),
	  QStringList(),
	  i18n("Do not ask again"),
	  0,
	  KMessageBox::NoExec,
	  QString());
    confirmDialog->setButtonGuiItem(KDialog::Ok, continueGuiItem);
    confirmDialog->setButtonGuiItem(KDialog::Cancel, cancelGuiItem);
    
    QObject::connect(confirmDialog, SIGNAL(accepted()), q, SLOT(_k_slotCreateHiddenDirectory()));
    QObject::connect(confirmDialog, SIGNAL(rejected()), q, SLOT(createDirectory()));
    
    m_fileDialog = confirmDialog;
    confirmDialog->show();
    
}
void ConfigurationDialog::showDmesg()
{
	KDialog *dialog = new DmesgDialog(this);
	dialog->setAttribute(Qt::WA_DeleteOnClose, true);
	dialog->setModal(true);
	dialog->show();
}
Exemple #3
0
void KNewFileMenuPrivate::executeOtherDesktopFile(const KNewFileMenuSingleton::Entry& entry)
{
    if (!checkSourceExists(entry.templatePath)) {
        return;
    }

    KUrl::List::const_iterator it = m_popupFiles.constBegin();
    for (; it != m_popupFiles.constEnd(); ++it)
    {
        QString text = entry.text;
        text.remove("..."); // the ... is fine for the menu item but not for the default filename
        text = text.trimmed(); // In some languages, there is a space in front of "...", see bug 268895
        // KDE5 TODO: remove the "..." from link*.desktop files and use i18n("%1...") when making
        // the action.

        KUrl defaultFile(*it);
        defaultFile.addPath(KIO::encodeFileName(text));
        if (defaultFile.isLocalFile() && QFile::exists(defaultFile.toLocalFile()))
            text = KIO::RenameDialog::suggestName(*it, text);

        const KUrl templateUrl(entry.templatePath);
	
	KDialog* dlg = new KPropertiesDialog(templateUrl, *it, text, m_parentWidget);
	dlg->setModal(q->isModal());
	dlg->setAttribute(Qt::WA_DeleteOnClose);
        QObject::connect(dlg, SIGNAL(applied()), q, SLOT(_k_slotOtherDesktopFile()));
	dlg->show();
    }
    // We don't set m_src here -> there will be no copy, we are done.
}
Exemple #4
0
void Klipper::slotEditData()
{
    const HistoryStringItem* item = dynamic_cast<const HistoryStringItem*>(m_history->first());

    KDialog dlg;
    dlg.setModal( true );
    dlg.setCaption( i18n("Edit Contents") );
    dlg.setButtons( KDialog::Ok | KDialog::Cancel );

    KTextEdit *edit = new KTextEdit( &dlg );
    if (item) {
        edit->setText( item->text() );
    }
    edit->setFocus();
    edit->setMinimumSize( 300, 40 );
    dlg.setMainWidget( edit );
    dlg.adjustSize();

    if ( dlg.exec() == KDialog::Accepted ) {
        QString text = edit->toPlainText();
        if (item) {
            m_history->remove( item );
        }
        m_history->insert( new HistoryStringItem(text) );
        if (m_myURLGrabber) {
            m_myURLGrabber->checkNewData( m_history->first() );
        }
    }

}
Exemple #5
0
void RKCaughtX11Window::copyDeviceToRObject () {
	RK_TRACE (MISC);

// TODO: not very pretty, yet
	KDialog *dialog = new KDialog (this);
	dialog->setButtons (KDialog::Ok|KDialog::Cancel);
	dialog->setCaption (i18n ("Specify R object"));
	dialog->setModal (true);
	KVBox *page = new KVBox (dialog);
	dialog->setMainWidget (page);

	new QLabel (i18n ("Specify the R object name, you want to save the graph to"), page);
	RKSaveObjectChooser *chooser = new RKSaveObjectChooser (page, "my.plot");
	connect (chooser, SIGNAL (changed(bool)), dialog, SLOT (enableButtonOk(bool)));
	if (!chooser->isOk ()) dialog->enableButtonOk (false);

	dialog->exec ();

	if (dialog->result () == QDialog::Accepted) {
		RK_ASSERT (chooser->isOk ());

		QString name = chooser->currentFullName ();

		RKGlobals::rInterface ()->issueCommand ("dev.set (" + QString::number (device_number) + ")\n" + name + " <- recordPlot ()", RCommand::App | RCommand::ObjectListUpdate, i18n ("Save contents of graphics device number %1 to object '%2'", device_number, name), error_dialog);
	}

	delete dialog;
}
Exemple #6
0
void RKCaughtX11Window::setFixedSizeManual () {
	RK_TRACE (MISC);

// TODO: not very pretty, yet
	KDialog *dialog = new KDialog (this);
	dialog->setButtons (KDialog::Ok|KDialog::Cancel);
	dialog->setCaption (i18n ("Specify fixed size"));
	dialog->setModal (true);

	KVBox *page = new KVBox (dialog);
	dialog->setMainWidget (page);

	new QLabel (i18n ("Width"), page);
	KIntSpinBox *width = new KIntSpinBox (5, 32767, 1, xembed_container->width (), page, 10);
	width->setEditFocus (true);

	new QLabel (i18n ("Height"), page);
	KIntSpinBox *height = new KIntSpinBox (5, 32767, 1, xembed_container->height (), page, 10);

	dialog->exec ();

	if (dialog->result () == QDialog::Accepted) {
		dynamic_size_action->setChecked (false);
		fixedSizeToggled ();		// see setFixedSize1 () above

		xembed_container->setFixedSize (width->value (), height->value ());
	}

	delete dialog;
}
Exemple #7
0
void Klipper::slotShowBarcode()
{
    using namespace prison;
    const HistoryStringItem* item = dynamic_cast<const HistoryStringItem*>(m_history->first());

    KDialog dlg;
    dlg.setModal( true );
    dlg.setCaption( i18n("Mobile Barcode") );
    dlg.setButtons( KDialog::Ok );

    QWidget* mw = new QWidget(&dlg);
    QHBoxLayout* layout = new QHBoxLayout(mw);

    BarcodeWidget* qrcode = new BarcodeWidget(new QRCodeBarcode());
    BarcodeWidget* datamatrix = new BarcodeWidget(new DataMatrixBarcode());

    if (item) {
        qrcode->setData( item->text() );
        datamatrix->setData( item->text() );
    }

    layout->addWidget(qrcode);
    layout->addWidget(datamatrix);

    mw->setFocus();
    dlg.setMainWidget( mw );
    dlg.adjustSize();

    dlg.exec();
}
Exemple #8
0
bool KNewFileMenuPrivate::checkSourceExists(const QString& src)
{
    if (!QFile::exists(src)) {
        kWarning(1203) << src << "doesn't exist" ;
	
	KDialog* dialog = new KDialog(m_parentWidget);
	dialog->setCaption( i18n("Sorry") );
	dialog->setButtons( KDialog::Ok );
	dialog->setObjectName( "sorry" );
	dialog->setModal(q->isModal());
	dialog->setAttribute(Qt::WA_DeleteOnClose);
	dialog->setDefaultButton( KDialog::Ok );
	dialog->setEscapeButton( KDialog::Ok );
	
	KMessageBox::createKMessageBox(dialog, QMessageBox::Warning, 
	  i18n("<qt>The template file <b>%1</b> does not exist.</qt>", src), 
	  QStringList(), QString(), 0, KMessageBox::NoExec,
	  QString());
	
	dialog->show();
	
        return false;
    }
    return true;
}
Exemple #9
0
void MainWindow::errorOccurred(const QString &message)
{
    QString completeMessage = i18n("Installation failed! The following error has been reported: %1.\n"
                                   "Tribe will now quit, please check the installation logs in /tmp\n"
                                   "or ask for help in our forums.", message);

    KDialog *dialog = new KDialog(this, Qt::FramelessWindowHint);
    dialog->setButtons(KDialog::Ok);
    dialog->setModal(true);
    bool retbool;

    KMessageBox::createKMessageBox(dialog, QMessageBox::Warning, completeMessage,
                                   QStringList(), QString(), &retbool, KMessageBox::Notify);

    quitToChakra();
}
void NotifyCollection::displayCollection( QWidget *p ) const
{
  //KMessageBox::information(p,collection(),i18n("Collected Notes"));
  KDialog *dlg = new KDialog( p );
  dlg->setCaption( i18n( "Collected Notes" ) );
  dlg->setButtons( KDialog::Close );
  dlg->setDefaultButton( KDialog::Close );
  dlg->setModal( false );
  KTextEdit *text = new KTextEdit( dlg );
  text->setReadOnly( true );
  text->setText( collection() );
  dlg->setMainWidget( text );
  dlg->setMinimumWidth( 300 );
  dlg->setMinimumHeight( 300 );
  dlg->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;
}
Exemple #12
0
  void CDInfoDialog::slotChangeEncoding()
  {
      KDialog* dialog = new KDialog(this);
      dialog->setCaption(i18n("Change Encoding"));
      dialog->setButtons( KDialog::Ok | KDialog::Cancel);
      dialog->setModal( true );


      QStringList songTitles;
        for (int t = 0; t < m_trackModel->rowCount(); ++t) {
              QString title = m_trackModel->index(t, Private::TRACK_ARTIST).data().toString().trimmed();
              if (!title.isEmpty())
              title.append(Private::SEPARATOR);
              title.append(m_trackModel->index(t, Private::TRACK_TITLE).data().toString().trimmed());
              songTitles << title;
          }

      KCDDB::CDInfoEncodingWidget* encWidget = new KCDDB::CDInfoEncodingWidget(
          dialog, d->ui->m_artist->text(),d->ui->m_title->text(), songTitles);

      dialog->setMainWidget(encWidget);

      if (dialog->exec())
      {
        KCharsets* charsets = KGlobal::charsets();
        QTextCodec* codec = charsets->codecForName(charsets->encodingForName(encWidget->selectedEncoding()));

        d->ui->m_artist->setText(codec->toUnicode(d->ui->m_artist->text().toLatin1()));
        d->ui->m_title->setText(codec->toUnicode(d->ui->m_title->text().toLatin1()));
        d->ui->m_genre->setItemText(d->ui->m_genre->currentIndex(), codec->toUnicode(d->ui->m_genre->currentText().toLatin1()));
        d->ui->m_comment->setText(codec->toUnicode(d->ui->m_comment->text().toLatin1()));

        QModelIndex trackIndex = m_trackModel->index(0, 0, QModelIndex());
        int trackRows = m_trackModel->rowCount(trackIndex);
        for (int t = 0; t < trackRows; ++t) {
            QString artist = m_trackModel->index(t, Private::TRACK_ARTIST, trackIndex).data().toString();
            m_trackModel->setData(m_trackModel->index(t, Private::TRACK_ARTIST, trackIndex), codec->toUnicode(artist.toLatin1()));
            QString title = m_trackModel->index(t, Private::TRACK_TITLE, trackIndex).data().toString();
            m_trackModel->setData(m_trackModel->index(t, Private::TRACK_TITLE, trackIndex), codec->toUnicode(title.toLatin1()));
            QString comment = m_trackModel->index(t, Private::TRACK_COMMENT, trackIndex).data().toString();
            m_trackModel->setData(m_trackModel->index(t, Private::TRACK_COMMENT, trackIndex), codec->toUnicode(comment.toLatin1()));
        }
      }
  }
Exemple #13
0
void KNewFileMenuPrivate::executeRealFileOrDir(const KNewFileMenuSingleton::Entry& entry)
{
    // The template is not a desktop file
    // Show the small dialog for getting the destination filename
    QString text = entry.text;
    text.remove("..."); // the ... is fine for the menu item but not for the default filename
    text = text.trimmed(); // In some languages, there is a space in front of "...", see bug 268895
    m_strategy.m_src = entry.templatePath;

    KUrl defaultFile(m_popupFiles.first());
    defaultFile.addPath(KIO::encodeFileName(text));
    if (defaultFile.isLocalFile() && QFile::exists(defaultFile.toLocalFile()))
        text = KIO::RenameDialog::suggestName(m_popupFiles.first(), text);
    
    KDialog* fileDialog = new KDialog(m_parentWidget);
    fileDialog->setAttribute(Qt::WA_DeleteOnClose);
    fileDialog->setModal(q->isModal());
    fileDialog->setButtons(KDialog::Ok | KDialog::Cancel);
    
    QWidget* mainWidget = new QWidget(fileDialog);
    QVBoxLayout *layout = new QVBoxLayout(mainWidget);
    QLabel *label = new QLabel(entry.comment);

    // We don't set the text of lineEdit in its constructor because the clear button would not be shown then.
    // It seems that setClearButtonShown(true) must be called *before* the text is set to make it work.
    // TODO: should probably be investigated and fixed in KLineEdit.
    KLineEdit *lineEdit = new KLineEdit;
    lineEdit->setClearButtonShown(true);
    lineEdit->setText(text);

    _k_slotTextChanged(text);
    QObject::connect(lineEdit, SIGNAL(textChanged(const QString &)), q, SLOT(_k_slotTextChanged(const QString &)));
    
    layout->addWidget(label);
    layout->addWidget(lineEdit);
    
    fileDialog->setMainWidget(mainWidget);
    QObject::connect(fileDialog, SIGNAL(accepted()), q, SLOT(_k_slotRealFileOrDir()));
    QObject::connect(fileDialog, SIGNAL(rejected()), q, SLOT(_k_slotAbortDialog()));
 
    fileDialog->show();
    lineEdit->selectAll();
    lineEdit->setFocus();
}
// static
void MessageBox::make( QWidget * parent, QMessageBox::Icon icon, const QString & text, const Job * job, const QString & caption, KMessageBox::Options options ) {
    KDialog * dialog = new KDialog( parent );
    dialog->setCaption( caption );
    dialog->setButtons( showAuditLogButton( job ) ? ( KDialog::Yes | KDialog::No ) : KDialog::Yes );
    dialog->setDefaultButton( KDialog::Yes );
    dialog->setEscapeButton( KDialog::Yes );
    dialog->setObjectName( "error" );
    dialog->setModal( true );
    dialog->showButtonSeparator( true );
    dialog->setButtonGuiItem( KDialog::Yes, KStandardGuiItem::ok() );
    if ( GpgME::hasFeature( GpgME::AuditLogFeature ) )
      dialog->setButtonGuiItem( KDialog::No, KGuiItem_showAuditLog() );

    if ( options & KMessageBox::PlainCaption )
        dialog->setPlainCaption( caption );

    if ( KDialog::No == KMessageBox::createKMessageBox( dialog, icon, text, QStringList(), QString::null, 0, options ) )
        auditLog( 0, job );
}
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)));
}
Exemple #16
0
void RKErrorDialog::reportableErrorMessage (QWidget* parent_widget, const QString& user_message, const QString &details, const QString& caption, const QString& message_code) {
	RK_TRACE (APP);

	if (!parent_widget) parent_widget = RKWardMainWindow::getMain ();
	// adjusted from KMessageBox::detailedError
	KDialog *dialog = new KDialog (parent_widget, Qt::Dialog);
	dialog->setCaption (caption);
	if (details.isEmpty ()) dialog->setButtons (KDialog::Ok | KDialog::No);
	else dialog->setButtons (KDialog::Ok | KDialog::No | KDialog::Details);
	dialog->setButtonText (KDialog::No, i18n ("Report As Bug"));
	dialog->setObjectName ("error");
	dialog->setDefaultButton (KDialog::Ok);
	dialog->setEscapeButton (KDialog::Ok);
	KMessageBox::Options options = KMessageBox::Notify | KMessageBox::AllowLink;
	dialog->setModal (true);

	int ret = KMessageBox::createKMessageBox (dialog, QMessageBox::Critical, user_message, QStringList(), QString(), 0, options, details);

	if (ret == KDialog::No) {
		reportBug (parent_widget, (message_code.isEmpty () ? QString () : i18n ("Message code: %1\n", message_code)) + user_message);
	}
}
Exemple #17
0
void KstVectorDialogI::configureSource() {
  bool isNew = false;
  KST::dataSourceList.lock().readLock();
  KstDataSourcePtr ds = *KST::dataSourceList.findReusableFileName(_w->FileName->url().url());
  KST::dataSourceList.lock().unlock();
  if (!ds) {
    isNew = true;
    ds = KstDataSource::loadSource(_w->FileName->url().url());
    if (!ds || !ds->isValid()) {
      _w->_configure->setEnabled(false);
      return;
    }
  }

  assert(_configWidget);
  KDialog *dlg = new KDialog(this);
  dlg->setObjectName("Data Config Dialog");
  dlg->setModal(true);
  dlg->setCaption(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->setParent(dlg);
  dlg->setMainWidget(_configWidget);
  _configWidget->setInstance(ds);
  _configWidget->load();
  dlg->exec();
  _configWidget->setParent(0L);
  dlg->setMainWidget(0L);
  delete dlg;
  updateCompletion(); // could be smarter by only running if Ok/Apply clicked
}
void ParagraphBulletsNumbers::customCharButtonPressed()
{
    KDialog *dialog = new KDialog(this);
    dialog->setModal(true);
    dialog->setButtons(KDialog::Ok | KDialog::Cancel);
    dialog->setDefaultButton(KDialog::Ok);

    KCharSelect *kcs = new KCharSelect(dialog, 0,
            KCharSelect::SearchLine | KCharSelect::FontCombo | KCharSelect::BlockCombos
            | KCharSelect::CharacterTable | KCharSelect::DetailBrowser);

    dialog->setMainWidget(kcs);
    if (dialog->exec() == KDialog::Accepted) {
        QChar character = kcs->currentChar();
        widget.customCharacter->setText(character);

        // also switch to the custom list style.
        foreach(int row, m_mapping.keys()) {
            if (m_mapping[row] == KoListStyle::CustomCharItem) {
                widget.listTypes->setCurrentRow(row);
                break;
            }
        }
    }
Exemple #19
0
/**
 * Authenticate using OAuth
 *
 * TODO (Dirk): There's some GUI code slipped in here,
 * that really doesn't feel like it's belonging here.
 */
void FbTalker::doOAuth()
{
    // just in case
    m_loginInProgress = true;

    // TODO (Dirk): 
    // Find out whether this signalBusy is used here appropriately.
    emit signalBusy(true);
    KUrl url("https://www.facebook.com/dialog/oauth");
    url.addQueryItem("client_id", m_appID);
    url.addQueryItem("redirect_uri", "https://www.facebook.com/connect/login_success.html");
    // TODO (Dirk): Check which of these permissions can be optional.
    url.addQueryItem("scope", "photo_upload,user_photos,friends_photos,user_photo_video_tags,friends_photo_video_tags,offline_access");
    url.addQueryItem("response_type", "token");
    kDebug() << "OAuth URL: " << url;
    KToolInvocation::invokeBrowser(url.url());
    emit signalBusy(false);
    KDialog* window         = new KDialog(kapp->activeWindow(), 0);
    window->setModal(true);
    window->setWindowTitle( i18n("Facebook Application Authorization") );
    window->setButtons(KDialog::Ok | KDialog::Cancel);
    QWidget* main           = new QWidget(window, 0);
    QLineEdit* textbox      = new QLineEdit( );
    QPlainTextEdit* infobox = new QPlainTextEdit( i18n(
        "Please follow the instructions in the browser window. "
        "When done, copy the Internet address from your browser into the textbox below and press \"OK\"."
    ) );
    infobox->setReadOnly(true);
    QVBoxLayout* layout = new QVBoxLayout;
    layout->addWidget(infobox);
    layout->addWidget(textbox);
    main->setLayout(layout);
    window->setMainWidget(main);

    if( window->exec()  == QDialog::Accepted )
    {
        // Error code and reason from the Facebook service
        QString errorReason;
        QString errorCode;

        url = KUrl( textbox->text() );
        QString fragment = url.fragment();
        kDebug() << "Split out the fragment from the URL: " << fragment;
        QStringList params = fragment.split('&');
        QList<QString>::iterator i = params.begin();
        while( i != params.end() )
        {
            QStringList keyvalue = (*i).split('=');
            if( keyvalue.size() == 2 )
            {
                if( ! keyvalue[0].compare( "access_token" ) )
                {
                    m_accessToken = keyvalue[1];
                }
                else if( ! keyvalue[0].compare( "expires_in" ) )
                {
                    m_sessionExpires = keyvalue[1].toUInt();
                    if( m_sessionExpires != 0 ) {
#if QT_VERSION >= 0x40700
                        m_sessionExpires += QDateTime::currentMSecsSinceEpoch() / 1000;
#else
                        m_sessionExpires += QDateTime::currentDateTime().toTime_t();
#endif
                    }
                }
                else if( ! keyvalue[0].compare( "error_reason" ) )
                {
                    errorReason = keyvalue[1];
                }
                else if( ! keyvalue[0].compare( "error" ) )
                {
                    errorCode = keyvalue[1];
                }
            }
            ++i;
        }
        if( !m_accessToken.isEmpty() && errorCode.isEmpty() && errorReason.isEmpty() )
        {
            return getLoggedInUser();
        }
    }

    authenticationDone(-1, i18n("Canceled by user."));

    // TODO (Dirk): Correct?
    emit signalBusy(false);
}
Exemple #20
0
static mpdm_t kde4_drv_form(mpdm_t a, mpdm_t ctxt)
{
    int n;
    mpdm_t widget_list;
    QWidget *qlist[100];
    mpdm_t r;

    KDialog *dialog = new KDialog(window);

    dialog->setModal(true);
    dialog->setButtons(KDialog::Ok | KDialog::Cancel);

    widget_list = mpdm_aget(a, 0);

    KVBox *vb = new KVBox(dialog);
    dialog->setMainWidget(vb);

    for (n = 0; n < mpdm_size(widget_list); n++) {
        mpdm_t w = mpdm_aget(widget_list, n);
        wchar_t *type;
        mpdm_t t;
        KHBox *hb = new KHBox(vb);

        type = mpdm_string(mpdm_hget_s(w, L"type"));

        if ((t = mpdm_hget_s(w, L"label")) != NULL) {
            QLabel *ql = new QLabel(hb);
            ql->setText(str_to_qstring(mpdm_gettext(t)));
        }

        t = mpdm_hget_s(w, L"value");

        if (wcscmp(type, L"text") == 0) {
            mpdm_t h;
            QComboBox *ql = new QComboBox(hb);

            ql->setEditable(true);
            ql->setMinimumContentsLength(30);
            ql->setMaxVisibleItems(8);

            if (t != NULL)
                ql->setEditText(str_to_qstring(t));

            qlist[n] = ql;

            if ((h = mpdm_hget_s(w, L"history")) != NULL) {
                int i;

                /* has history; fill it */
                h = mp_get_history(h);

                for (i = mpdm_size(h) - 1; i >= 0; i--)
                    ql->addItem(str_to_qstring(mpdm_aget(h, i)));
            }
        }
        else
        if (wcscmp(type, L"password") == 0) {
            QLineEdit *ql = new QLineEdit(hb);

            ql->setEchoMode(QLineEdit::Password);

            qlist[n] = ql;
        }
        else
        if (wcscmp(type, L"checkbox") == 0) {
            QCheckBox *qc = new QCheckBox(hb);

            if (mpdm_ival(t))
                qc->setCheckState(Qt::Checked);

            qlist[n] = qc;
        }
        else
        if (wcscmp(type, L"list") == 0) {
            int i;
            QListWidget *ql = new QListWidget(hb);
            ql->setMinimumWidth(480);

            /* use a monospaced font */
            ql->setFont(QFont(QString("Mono")));

            mpdm_t l = mpdm_hget_s(w, L"list");

            for (i = 0; i < mpdm_size(l); i++)
                ql->addItem(str_to_qstring(mpdm_aget(l, i)));

            ql->setCurrentRow(mpdm_ival(t));

            qlist[n] = ql;
        }

        if (n == 0)
            qlist[n]->setFocus(Qt::OtherFocusReason);
    }

    n = dialog->exec();

    if (!n)
        return NULL;

    r = MPDM_A(mpdm_size(widget_list));

    /* fill the return values */
    for (n = 0; n < mpdm_size(widget_list); n++) {
        mpdm_t w = mpdm_aget(widget_list, n);
        mpdm_t v = NULL;
        wchar_t *type;

        type = mpdm_string(mpdm_hget_s(w, L"type"));

        if (wcscmp(type, L"text") == 0) {
            mpdm_t h;
            QComboBox *ql = (QComboBox *) qlist[n];

            v = qstring_to_str(ql->currentText());

            /* if it has history, add to it */
            if ((h = mpdm_hget_s(w, L"history")) != NULL &&
                v != NULL && mpdm_cmp_s(v, L"") != 0) {
                h = mp_get_history(h);

                if (mpdm_cmp(v, mpdm_aget(h, -1)) != 0)
                    mpdm_push(h, v);
            }
        }
        else
        if (wcscmp(type, L"password") == 0) {
            QLineEdit *ql = (QLineEdit *) qlist[n];

            v = qstring_to_str(ql->text());
        }
        else
        if (wcscmp(type, L"checkbox") == 0) {
            QCheckBox *qb = (QCheckBox *) qlist[n];

            v = MPDM_I(qb->checkState() == Qt::Checked);
        }
        else
        if (wcscmp(type, L"list") == 0) {
            QListWidget *ql = (QListWidget *) qlist[n];

            v = MPDM_I(ql->currentRow());
        }

        mpdm_aset(r, v, n);
    }

    return r;
}
Exemple #21
0
bool Item::mouseDoubleClickEvent( const EventInfo & eventInfo )
{
	Q_UNUSED(eventInfo);
	
	Property * property = 0l;
	Variant::Type::Value type = Variant::Type::None;
	
	const VariantDataMap::iterator variantDataEnd = m_variantData.end();
	for ( VariantDataMap::iterator it = m_variantData.begin(); it != variantDataEnd; ++it )
	{
		Property * current = *it;
		
		if ( current->type() == Variant::Type::Multiline ||
				   current->type() == Variant::Type::RichText )
		{
			property = current;
			type = current->type();
			break;
		}
	}
	if ( !property )
		return false;
	
	if ( type == Variant::Type::Multiline )
	{
		//KDialog * dlg = new KDialog( 0l, "", true, property->editorCaption(), KDialog::Ok|KDialog::Cancel|KDialog::User1, KDialog::Ok,
        //                             false, KStandardGuiItem::clear() );
        KDialog * dlg = new KDialog( 0 );
        dlg->setModal(true);
        dlg->setCaption( property->editorCaption() );
        dlg->setButtons(KDialog::Ok|KDialog::Cancel|KDialog::User1);
        dlg->setDefaultButton(KDialog::Ok);
        dlg->showButtonSeparator(false);
        dlg->setButtonText(KDialog::User1, KStandardGuiItem::clear().text());
        //QFrame *frame = dlg->makeMainWidget();
		QFrame *frame = new QFrame(dlg);
        dlg->setMainWidget(frame);
		QVBoxLayout *layout = new QVBoxLayout( frame );
        layout->setMargin(0);
        layout->setSpacing(dlg->spacingHint());
		KTextEdit *textEdit = new KTextEdit( frame );
		//textEdit->setTextFormat( Qt::PlainText ); // 2018.12.02
        textEdit->setAcceptRichText(false);
		textEdit->setText( property->value().toString() );
		layout->addWidget( textEdit, 10 );
		textEdit->setFocus();
		connect( dlg, SIGNAL( user1Clicked() ), textEdit, SLOT( clear() ) );
		dlg->setMinimumWidth( 600 );
		
		if ( dlg->exec() == KDialog::Accepted )
		{
			property->setValue( textEdit->toPlainText() );
			dataChanged();
			p_itemDocument->setModified(true);
		}
		delete dlg;
	}
	else
	{
		// Is rich text
		RichTextEditorDlg * dlg = new RichTextEditorDlg( 0l, property->editorCaption() );
		dlg->setText( property->value().toString() );
		
		if ( dlg->exec() == KDialog::Accepted )
		{
			property->setValue( dlg->text() );
			dataChanged();
			p_itemDocument->setModified(true);
		}
		delete dlg;
	}
	
	return true;
}