Esempio n. 1
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);
	}
}
Esempio n. 2
0
File: ppplog.cpp Progetto: KDE/kppp
void PPPL_ShowLog() {
  QStringList sl, result;

  PPPL_MakeLog(sl);

  bool foundConnect = false;
  bool foundLCP = gpppdata.getPPPDebug();
  QString lcp = QLatin1String("[LCP");
  QString conn = QLatin1String("Connect:");
  QStringList::ConstIterator it = sl.constBegin();
  for( ; it != sl.constEnd(); it++) {
    if((*it).indexOf(lcp) >= 0) {
      foundLCP = true;
      break;
    }
    if((*it).contains(conn))
      foundConnect = true;
  }
  if(foundConnect && !foundLCP) {
    int result = KMessageBox::warningYesNo(0,
				i18n("KPPP could not prepare a PPP log. It is very likely "
				     "that pppd was started without the \"debug\" option.\n"
				     "Without this option it is difficult to find out PPP "
				     "problems, so in general the debug option should be used.\n"
				     "Enable debug now, and restart pppd?"), QString(), KGuiItem(i18n("Restart pppd")), KGuiItem(i18n("Do Not Restart")));

    if(result == KMessageBox::Yes) {
      gpppdata.setPPPDebug(true);
      KMessageBox::information(0,
		       i18n("The \"debug\" option has been added. You "
			    "should now try to reconnect. If that fails "
			    "again, you will get a PPP log that may help "
					"you to track down the connection problem."));
      //      return;
    }

    //    return;
  }

  PPPL_AnalyseLog(sl, result);

  KDialog *dlg = new KDialog();
  dlg->setButtons(KDialog::Close | KDialog::Ok);
  dlg->setWindowTitle(i18n("PPP Log"));
  dlg->setButtonText(KDialog::Ok,i18n("Write to File"));

  KVBox* v = new KVBox(dlg);
  QTextEdit *edit = new QTextEdit(v);
  edit->setReadOnly(true);
  QLabel *label = new QLabel(i18n("kppp's diagnosis (just guessing):"), v);
  QTextEdit *diagnosis = new QTextEdit(v);
  diagnosis->setReadOnly(true);
  edit->setMinimumSize(600, 250);
  label->setMinimumSize(600, 15);
  diagnosis->setMinimumSize(600, 60);

  dlg->setMainWidget(v);

  for(int i = 0; i < sl.count(); i++)
    edit->append(sl.at(i));
  for(int i = 0; i < result.count(); i++)
    diagnosis->append(result.at(i));

  if(dlg->exec()) {
    QDir d = QDir::home();
    QString s = d.absolutePath() + "/PPP-logfile";
    int old_umask = umask(0077);

    FILE *f = fopen(QFile::encodeName(s), "w");
    for(int i = 0; i < sl.count(); i++)
      fprintf(f, "%s\n", sl.at(i).toLocal8Bit().data());
    fclose(f);
    umask(old_umask);

    QString msg = i18n("The PPP log has been saved\nas \"%1\".\n\nIf you want to send a bug report, or have\nproblems connecting to the Internet, please\nattach this file. It will help the maintainers\nto find the bug and to improve KPPP", s);
    KMessageBox::information(0, msg);
  }
  delete dlg;
}
Esempio n. 3
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;
}