/**
 Method  : void LoadWeightsDialog::OnOK()
 Purpose : Load the network weights.
 Version : 1.0.0
*/
void LoadWeightsDialog::OnOK() {
	CString filename =	filenameBox.GetFileName();

	if (filename.IsEmpty()) {
		WarnUser(_TEXT("You must specify the weights filename."), _TEXT("Invalid Weight file"));
		filenameBox.SetFocus();
	} else {
		if (parent->LoadWeights(filenameBox.GetFileName())) LoadSaveDialog::OnOK();
	}
}
Esempio n. 2
0
CForwardDlg::CForwardDlg(CSignalManager *sigMan, CUserEvent *e, QWidget *p)
  : LicqDialog(p, "UserForwardDialog", false, WDestructiveClose | WType_TopLevel)
{
  sigman = sigMan;

  m_nEventType = e->SubCommand();
  m_nUin = 0;
  m_szId = 0;
  m_nPPID = 0;

  QString t;
  switch (e->SubCommand())
  {
    case ICQ_CMDxSUB_MSG:
      t = tr("Message");
      s1 = QString::fromLocal8Bit(((CEventMsg *)e)->Message());
      break;
    case ICQ_CMDxSUB_URL:
      t = tr("URL");
      s1 = QString::fromLocal8Bit(((CEventUrl *)e)->Url());
      s2 = QString::fromLocal8Bit(((CEventUrl *)e)->Description());
      break;
    default:
      WarnUser(this, tr("Unable to forward this message type (%d).").arg(e->SubCommand()));
      return;
  }

  setCaption(tr("Forward %1 To User").arg(t));
  setAcceptDrops(true);

  QGridLayout *lay = new QGridLayout(this, 3, 5, 10, 5);
  QLabel *lbl = new QLabel(tr("Drag the user to forward to here:"), this);
  lay->addMultiCellWidget(lbl, 0, 0, 0, 4);
  edtUser = new CInfoField(this, true);
  edtUser->setAcceptDrops(false);
  lay->addMultiCellWidget(edtUser, 1, 1, 0, 4);

  lay->setColStretch(0, 2);
  btnOk = new QPushButton(tr("&Forward"), this);
  lay->addWidget(btnOk, 2, 1);

  lay->addColSpacing(2, 10);
  btnCancel = new QPushButton(tr("&Cancel"), this);
  lay->addWidget(btnCancel, 2, 3);
  lay->setColStretch(4, 2);

  int bw = 75;
  bw = QMAX(bw, btnOk->sizeHint().width());
  bw = QMAX(bw, btnCancel->sizeHint().width());
  btnOk->setFixedWidth(bw);
  btnCancel->setFixedWidth(bw);

  connect(btnOk, SIGNAL(clicked()), SLOT(slot_ok()));
  connect(btnCancel, SIGNAL(clicked()), SLOT(close()));
}
Esempio n. 3
0
// ****************************************************************************
//
//  Function Name:	RAlert::WarnUser( )
//
//  Description:		Warn the user of a problem with an Alert and an OK
//							and Cancel button.
//							Retrieve the message from a resource file.
//
//  Returns:			kAlertOk or kAlertCancel
//
//  Exceptions:		None
//
// ****************************************************************************
//
YAlertValues	RAlert::WarnUser( YResourceId warningId )
	{
	RMBCString	string = GetResourceManager().GetResourceString( warningId );
#ifdef	TPSDEBUG
	char	buffer[128];
	buffer[0] = '\0';
	WinCode( wsprintf( buffer, " - %d", warningId ) );
	string += buffer;
#endif
	return WarnUser( (LPCSZ)string );
	}
Esempio n. 4
0
File: png.c Progetto: ncareol/ncplot
/* -------------------------------------------------------------------- */
void confirmPNG(Widget w, XtPointer client, XtPointer call)
{
  FileCancel((Widget)NULL, (XtPointer)NULL, (XtPointer)NULL);
  ExtractFileName(((XmFileSelectionBoxCallbackStruct *)call)->value, &outFile);

  if (strstr(outFile, ".png") == NULL)
    strcat(outFile, ".png");

  if (access(outFile, F_OK) == 0)
    {
    sprintf(buffer, "Overwrite file %s", outFile);
    WarnUser(buffer, savePNG, NULL);
    }
  else
    savePNG((Widget)NULL, (XtPointer)NULL, (XtPointer)NULL);

}
Esempio n. 5
0
//-----CFileDlg::slot_ft-----------------------------------------------------
void CFileDlg::slot_ft()
{
  // Read out any pending events
  char buf[32];
  read(ftman->Pipe(), buf, 32);

  QTextCodec *codec = UserCodec::codecForProtoUser(m_szId, m_nPPID);

  CFileTransferEvent *e = NULL;
  while ( (e = ftman->PopFileTransferEvent()) != NULL)
  {
    switch(e->Command())
    {
      case FT_STARTxBATCH:
      {
        setCaption(QString(tr("Licq - File Transfer (%1)")).arg(codec->toUnicode(ftman->RemoteName())));
        nfoTotalFiles->setText(QString("%1 / %2").arg(1).arg(ftman->BatchFiles()));
        nfoBatchSize->setText(encodeFSize(ftman->BatchSize()));
        barBatchTransfer->setTotalSteps(ftman->BatchSize() / 1024);
        barBatchTransfer->setProgress(0);
        break;
      }

      case FT_CONFIRMxFILE:
      {
        // Use this opportunity to encode the filename
        ftman->StartReceivingFile(QFile::encodeName(codec->toUnicode(ftman->FileName())).data());
        break;
      }

      case FT_STARTxFILE:
      {
        nfoTotalFiles->setText(QString("%1 / %2").arg(ftman->CurrentFile()).arg(ftman->BatchFiles()));
        nfoTransferFileName->setText(QFile::decodeName(ftman->FileName()));
        nfoLocalFileName->setText(QFile::decodeName(ftman->PathName()));
        nfoFileSize->setText(encodeFSize(ftman->FileSize()));
        barTransfer->setTotalSteps(ftman->FileSize() / 1024);
        if (ftman->Direction() == D_RECEIVER)
          mleStatus->append(tr("Receiving file..."));
        else
          mleStatus->append(tr("Sending file..."));
        break;
      }

      case FT_UPDATE:
      {
        slot_update();
        break;
      }

      case FT_DONExFILE:
      {
        slot_update();
        if (ftman->Direction() == D_RECEIVER)
          mleStatus->append(tr("Received %1 from %2 successfully.").arg(QFile::decodeName(e->Data())).arg(codec->toUnicode(ftman->RemoteName())));
        else
          mleStatus->append(tr("Sent %1 to %2 successfully.").arg(QFile::decodeName(e->Data())).arg(codec->toUnicode(ftman->RemoteName())));
        break;
      }

      case FT_DONExBATCH:
      {
        mleStatus->append(tr("File transfer complete."));
        btnCancel->setText(tr("OK"));
        if( btnOpen && btnOpenDir && ftman->Direction() == D_RECEIVER)
        {
          btnOpen->show();
          btnOpenDir->show();
        }

        ftman->CloseFileTransfer();
        break;
      }

      case FT_ERRORxCLOSED:
      {
        btnCancel->setText(tr("Close"));
        mleStatus->append(tr("Remote side disconnected."));
        ftman->CloseFileTransfer();
        WarnUser(this, tr("Remote side disconnected."));
        break;
      }

      case FT_ERRORxFILE:
      {
        btnCancel->setText(tr("Close"));
        mleStatus->append(tr("File I/O error: %1.").arg(QFile::decodeName(ftman->PathName())));
        ftman->CloseFileTransfer();
        WarnUser(this, tr("File I/O Error:\n%1\n\nSee Network Window for details.")
           .arg(QFile::decodeName(ftman->PathName())));
        break;
      }

      case FT_ERRORxHANDSHAKE:
      {
        btnCancel->setText(tr("Close"));
        mleStatus->appendNoNewLine(tr("Handshaking error.\n"));
        ftman->CloseFileTransfer();
        WarnUser(this, tr("Handshake Error.\nSee Network Window for details."));
        break;
      }

      case FT_ERRORxCONNECT:
      {
        btnCancel->setText(tr("Close"));
        mleStatus->appendNoNewLine(tr("Connection error.\n"));
        ftman->CloseFileTransfer();
        WarnUser(this,
          tr("Unable to reach remote host.\nSee Network Window for details."));
        break;
      }

      case FT_ERRORxBIND:
      {
        btnCancel->setText(tr("Close"));
        mleStatus->appendNoNewLine(tr("Bind error.\n"));
        ftman->CloseFileTransfer();
        WarnUser(this,
          tr("Unable to bind to a port.\nSee Network Window for details."));
        break;
      }
      
      case FT_ERRORxRESOURCES:
      {
        btnCancel->setText(tr("Close"));
        mleStatus->appendNoNewLine(tr("Not enough resources.\n"));
        ftman->CloseFileTransfer();
        WarnUser(this,
          tr("Unable to create a thread.\nSee Network Window for details."));
        break;
      }
    }

    delete e;
  }
}