Example #1
0
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;
}
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)));
}
Example #3
0
void Task::showPropertiesDialog()
{
    if (m_taskType != GroupType || !(m_applet->groupManager()->taskGrouper()->editableGroupProperties() & TaskManager::AbstractGroupingStrategy::Name))
    {
        return;
    }

    QWidget *groupWidget = new QWidget;

    m_groupUi.setupUi(groupWidget);
    m_groupUi.icon->setIcon(m_group->icon());
    m_groupUi.name->setText(m_group->name());

    KDialog *groupDialog = new KDialog;
    groupDialog->setMainWidget(groupWidget);
    groupDialog->setButtons(KDialog::Cancel | KDialog::Ok);

    connect(groupDialog, SIGNAL(okClicked()), this, SLOT(setProperties()));

    groupDialog->setWindowTitle(i18n("%1 Settings", m_group->name()));
    groupDialog->show();
}
Example #4
0
File: ppplog.cpp Project: 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;
}
Example #5
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);
}