예제 #1
0
bool ImageViewer::saveAsLabelledResult(QString &pathResult)
{
    if(!_srcOcvImage) return false;
    if(!_displayImage) return false;
    if(!_result_display) return false;

    QFileDialog *fDlg = new QFileDialog(this);
    fDlg->setWindowTitle(tr("保存标注结果"));
    fDlg->setAcceptMode(QFileDialog::AcceptSave);
    fDlg->setFileMode(QFileDialog::AnyFile);
    fDlg->setViewMode(QFileDialog::Detail);
    fDlg->setDirectory(QDir::currentPath());

    fDlg->setFilter(MOLI_IMAGE_FILTER);
    fDlg->setDefaultSuffix("png");

    if(fDlg->exec() == QDialog::Accepted)
    {
        QString filename = fDlg->selectedFiles()[0];
        if(_result_display->save(filename))
        {
            pathResult = filename;
            return true;
        }
        else return false;
    }
    else return true;
}
예제 #2
0
void MainWindow::save_as()

{
  QFileDialog dialog;

  dialog.setAcceptMode(QFileDialog::AcceptSave);
  dialog.setFileMode(QFileDialog::AnyFile);
  dialog.setDefaultSuffix("xml");
  dialog.setNameFilter(tr("xml files (*.xml)"));

  if (dialog.exec() == QDialog::Accepted)
    {
      this->filename = dialog.selectedFiles().at(0);

      if (!this->save(this->filename))
        {
          this->filename = "";

          QMessageBox message;

          message.setText("Could not save the file.");
          message.exec();
        }
      else  // set the new window title
        {
          this->update_title();
          this->change_happened = false; // reset the change watcher
        }
    }
}
예제 #3
0
void Main_win::save_clicked()
{
  try
  {
    QFileDialog fd;
    fd.setDefaultSuffix(".mat"); // not working under linux?!

    QString q_form = fd.getSaveFileName(this, tr("Save Matrix"));

    std::ofstream target(q_form.toStdString(), std::ios::trunc);

    if(target.fail()) throw std::ios_base::failure("cannot save matrix");

    for(int i = 0; i < mat_dim_.first; ++i)
    {
      for(int j = 0; j < mat_dim_.second; ++j)
      {
        auto item = qobject_cast< Field* >(ui_->mat_layout->itemAtPosition(i,
                                           j)->widget());
        if(item)
          target << item->get_text() << " ";
      }
      target << "\n";
    }

    target.close();
  }
  catch(std::exception& e)
  {
    to_display(e.what());
  }
}
예제 #4
0
파일: MainWindow.cpp 프로젝트: tehme/Outlaw
void MainWindow::onSaveChat()
{
    QFileDialog * saveChatDialog = new QFileDialog(this, "Save chat", QString(), "*.html");
    saveChatDialog->setAcceptMode(QFileDialog::AcceptSave);
    saveChatDialog->setFileMode(QFileDialog::AnyFile);
    saveChatDialog->setDefaultSuffix("html");
    connect(saveChatDialog, SIGNAL(finished(int)), this, SLOT(onSaveChatFinished(int)));

    saveChatDialog->show();
}
예제 #5
0
void ProjectHandle::saveProject(){

    if(this->projPath==""){
        QFileDialog dlg;
        dlg.setDefaultSuffix("fproj");
        QString path = dlg.getSaveFileName(NULL,tr("Project location"), ".",tr("Project files (*.fproj)"));
        if(path.isEmpty()){
            return;
        }
        QFileInfo inf(path);
        if(inf.suffix()!="fproj"){
            QString tmp=inf.baseName();
            tmp+=".fproj";
            path=inf.absolutePath()+"/"+tmp;
        }
        this->projPath=path;
    }


    QFileInfo inf(projPath);
    QDomDocument doc(inf.baseName());
    QDomElement root =  doc.createElement("Project");
    doc.appendChild(root);
    root.setAttribute("appVersion",version);
    root.setAttribute("Name",projName);

    QHash<QString,PObject>::iterator iter;

    iter=projObjects.begin();
    for(int i=0;i<projObjects.size();i++){
        PObject tmp=iter.value();
        QDomElement obj = doc.createElement("Object");
        root.appendChild(obj);
        obj.setAttribute("Path",tmp.path);
        obj.setAttribute("Material",tmp.material);
        obj.setAttribute("Height",tmp.height);
        obj.setAttribute("Width",tmp.width);

        iter++;
    }

    QFile pfile(projPath);
    if(pfile.open(QIODevice::WriteOnly)){
        QTextStream stream(&pfile);
        stream << doc.toString();
        pfile.close();
        projName=inf.baseName();
    }
}
예제 #6
0
bool ImageViewer::saveAsMask(QString &pathMask)
{
    if(_mask.empty()) return false;

    QFileDialog *fDlg = new QFileDialog(this);
    fDlg->setWindowTitle(tr("保存掩码"));
    fDlg->setAcceptMode(QFileDialog::AcceptSave);
    fDlg->setFileMode(QFileDialog::AnyFile);
    fDlg->setViewMode(QFileDialog::Detail);
    fDlg->setDirectory(QDir::currentPath());

    fDlg->setFilter(MOLI_IMAGE_FILTER);
    fDlg->setDefaultSuffix("bmp");

    if(fDlg->exec() == QDialog::Accepted)
    {
        QString filename = fDlg->selectedFiles()[0];
        if(m_method == 0)
        {
            if(saveLabelMap(filename))
            {
                pathMask = filename;

                return true;
            }
            else return false;
        }
        else
        {
            _mask = _mask * 255;
            IplImage* temp = new IplImage(_mask);
            QImage* temp2 = IplImageToQImage(temp);
            if(temp2->save(filename))
            {
                pathMask = filename;
                if(temp2) delete temp2;
                return true;
            }
            else return false;
        }
    }
    else
    {
        return true;
    }
}
예제 #7
0
void SyntroReview::saveButtonClicked(QAbstractButton *button)
{
	QFileDialog *fileDialog;

	if (m_CFSState != SYNTROREVIEW_CFS_STATE_OPEN)
		return;												// no open file anyway

	if (button == m_saveFrame){
		fileDialog = new QFileDialog(this, "JPEG (.jpg) file name");
		fileDialog->setAcceptMode(QFileDialog::AcceptSave);
		fileDialog->setFileMode(QFileDialog::AnyFile);
		fileDialog->selectFile(m_saveFilePath);
		fileDialog->setNameFilter("*.jpg");
		fileDialog->setDefaultSuffix("jpg");
		if (fileDialog->exec()) {
			m_saveFilePath = fileDialog->selectedFiles().at(0);
			saveCurrentFrame();
		}
	}
}
void CalculationWizard::wizardFinished()
{
    QFileDialog *fd = new QFileDialog ( this, tr ( "Select file for saving calculation results" ) );
    fd->setDefaultSuffix ( ".txt" );
    fd->setNameFilter ( "Text Documents (*.txt)" );
    fd->setAcceptMode ( QFileDialog::AcceptSave );
    if ( fd->exec() == true )
    {
        Data::UserInput input;
        input.resultsFilePath = fd->selectedFiles().at ( 0 );
        input.maximumValue = qobject_cast<WizardSettingsPage *> ( ui->wizard->wizardPages[0] )->getMaximumValue();
        input.ipComparison = qobject_cast<WizardSettingsPage *> ( ui->wizard->wizardPages[0] )->getIpComparison();
        input.log = qobject_cast<WizardSettingsPage *> ( ui->wizard->wizardPages[0] )->getLogarithmicBase();
        input.maximumCalculations = qobject_cast<WizardAutoStopPage *> ( ui->wizard->wizardPages[2] )->getMaximumCalculations();
        input.maximumCoincidences = qobject_cast<WizardAutoStopPage *> ( ui->wizard->wizardPages[2] )->getMaximumCoincidences();
        input.extendedIpSearch = qobject_cast<WizardIpSearchPage *> ( ui->wizard->wizardPages[1] )->getExtendedIpSearch();
        input.search = qobject_cast<WizardIpSearchPage *> ( ui->wizard->wizardPages[1] )->getIpSearch();
        fd->deleteLater();
        emit userInputCompleted ( input );
    }
}
예제 #9
0
void Results::on_pushButton_clicked()
{
    QFileDialog *saveFileDialog = new QFileDialog(this,
                                      tr("Export Data"), "", tr("Excel Import (*.csv)"));
    saveFileDialog->setDefaultSuffix("csv");
    saveFileDialog->setViewMode(QFileDialog::Detail);
    if(saveFileDialog->exec())
    {
        QStringList fileName = saveFileDialog->selectedFiles();
        FILE* file = fopen(fileName[0].toAscii().data(), "w");
        fprintf(file, "Pn (kip),Mn (kip-ft),phi-Pn (kip),phi-Mn (kip-ft)\n");
        for(int i = 0; i < data->graphCount; i++)
        {
            fprintf(file, "%lf,%lf,%lf,%lf\n",data->unfactoredPoints[i][0]/1000,data->unfactoredPoints[i][1]/1000/12,
                    data->factoredPoints[i][0]/1000, data->factoredPoints[i][1]/1000/12);
        }

        fclose(file);
    }
    delete saveFileDialog;
}
예제 #10
0
파일: itemwindow.cpp 프로젝트: amof/Doger
static void initializeImageFileDialog(QFileDialog &dialog, QFileDialog::AcceptMode acceptMode)
{
    static bool firstDialog = true;

    if (firstDialog) {
        firstDialog = false;
        const QStringList picturesLocations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
        dialog.setDirectory(picturesLocations.isEmpty() ? QDir::currentPath() : picturesLocations.last());
    }

    QStringList mimeTypeFilters;
    const QByteArrayList supportedMimeTypes = acceptMode == QFileDialog::AcceptOpen
        ? QImageReader::supportedMimeTypes() : QImageWriter::supportedMimeTypes();
    foreach (const QByteArray &mimeTypeName, supportedMimeTypes)
        mimeTypeFilters.append(mimeTypeName);
    mimeTypeFilters.sort();
    dialog.setMimeTypeFilters(mimeTypeFilters);
    dialog.selectMimeTypeFilter("image/jpeg");
    if (acceptMode == QFileDialog::AcceptSave)
        dialog.setDefaultSuffix("jpg");
}
예제 #11
0
void MainWindow::on_actionOpen_triggered()

{
  QFileDialog dialog;
  QString selected_file;

  dialog.setAcceptMode(QFileDialog::AcceptOpen);
  dialog.setFileMode(QFileDialog::AnyFile);
  dialog.setDefaultSuffix("xml");
  dialog.setNameFilter(tr("xml files (*.xml)"));

  if (dialog.exec() == QDialog::Accepted)
    {
      selected_file = dialog.selectedFiles().at(0);

      if (!this->closing_file())   // prompt the user
        return;

      this->load(selected_file);
      this->update_graphics();
    }
}
예제 #12
0
void GLWidget::saveImage() {
  rgbImage temp;
  if ( rb!=0 ) {
    rb->lockRead();
    int idx=rb->curRead();
    FrameData * frame = rb->getPointer ( idx );

    VisualizationFrame * vis_frame=(VisualizationFrame *)(frame->map.get("vis_frame"));
    if (vis_frame !=0 && vis_frame->valid) {
      temp.copy ( vis_frame->data );
      rb->unlockRead();
    } else {
      rb->unlockRead();
      return;
    }
  }
  if ( temp.getWidth() > 1 && temp.getHeight() > 1 ) {
    QFileDialog dialog ( this,
                         "Export image to file...",
                         "",
                         "PNG (*.png)" );
    dialog.setConfirmOverwrite ( true );
    dialog.setDefaultSuffix ( "png" );
    dialog.setAcceptMode ( QFileDialog::AcceptSave );
    if ( dialog.exec() ) {
      if ( dialog.selectedFiles().size() > 0 ) {
        QString filename=dialog.selectedFiles().at ( 0 );
        if ( temp.save ( filename.toStdString() ) ) {
          QMessageBox::information ( this, "Success","PNG was saved successfully." );
        } else {
          QMessageBox::warning ( this, "Error","Unknown error while saving PNG." );
        }
      }
    }
  }
}
예제 #13
0
void ProjectHandle::newProject(){

    if(projPath!=""){
        if(closeProject()==1) return;
    }

    QFileDialog dlg;
    dlg.setDefaultSuffix("fproj");
    QString path = dlg.getSaveFileName(NULL,tr("Project location"), ".",tr("Project files (*.fproj)"));
    if(path.isEmpty()){
        return;
    }
    QFileInfo inf(path);
    if(inf.suffix()!="fproj"){
        QString tmp=inf.baseName();
        tmp+=".fproj";
        path=inf.absolutePath()+"/"+tmp;
    }
    this->projPath=path;

    QDomDocument doc("xml version=\"1.0\" encoding=\"UTF-8\"");
    QDomElement root =  doc.createElement(inf.baseName());
    doc.appendChild(root);
    root.setAttribute("appVersion",version);

    QFile pfile(path);
    if(pfile.open(QIODevice::WriteOnly)){
        QTextStream stream(&pfile);
        stream << doc.toString();
        pfile.close();
        projName=inf.baseName();
    }

    return;

}
예제 #14
0
/**
  * Open existing database
  */
void BursarApp::on_actionOpen_triggered()
{
    QString fileName;
    QFileDialog dialog;

    dialog.setDefaultSuffix("bdb");

    fileName = dialog.getOpenFileName(NULL, tr("Open Database"), "", tr("Bursar Files (*.bdb);;All Files (*.*)"));

    if (fileName != "") {
        if (m_doc->openDatabase(fileName)) {
            // create main window
            //if (m_mainWindow != NULL) {
            //    m_mainWindow = new MainWindow(m_db);

                // show main window
            //    m_mainWindow->show();
            //} else {
                // initialize main window
                //m_mainWindow->init();
            //}
        }
    }
}
예제 #15
0
void ContentViewer::addPlainTextTab()
{
  if(_entity->hasPlainText())
  {

    QWidget *plainTextTab=new QWidget(ui->tvFormats);
    plainTextTab->setObjectName("Plain Text");
    plainTextTab->setWindowTitle("Plain Text");

    QVBoxLayout *plainTextTabLayout=new QVBoxLayout();

    QPlainTextEdit *plainTextEdit=new QPlainTextEdit(plainTextTab);
    plainTextEdit->setPlainText(_entity->plainText(false,-1));
    plainTextEdit->setReadOnly(true);
    plainTextTabLayout->addWidget(plainTextEdit);

    QHBoxLayout *plainTextInfoLayout=new QHBoxLayout();
    QLabel *plainTextInfoLabel=new QLabel(plainTextTab);
    plainTextInfoLabel->setText(QString("<b>length :</b> %1").arg(plainTextEdit->toPlainText().count())
                               +"  "+QString("<b>size :</b> %1 KB").arg((double)_entity->formatSize("text/plain")/1024));
    plainTextInfoLayout->addWidget(plainTextInfoLabel);

    QPushButton *btnExport=new QPushButton(plainTextTab);
    connect(btnExport,&QPushButton::clicked,this,[this,plainTextEdit](){
      QFileDialog dialog;
      dialog.setAcceptMode(QFileDialog::AcceptSave);
      dialog.setWindowTitle("select a file to save text");
      dialog.setWindowIcon(QIcon(Resources::Export16));
      dialog.setFileMode(QFileDialog::AnyFile);
      dialog.setDefaultSuffix("txt");
      for(;;)
      {
        if(dialog.exec())
        {
          int length=dialog.selectedFiles().length();
          if(length>0 && length==1)
          {
            QFile file(dialog.selectedFiles().at(0));
            file.open(QIODevice::WriteOnly);
            if(file.isWritable())
            {
              qint64 i= file.write(plainTextEdit->toPlainText().toUtf8());
              if(i<0)
              {
                int messageResult= QMessageBox::critical(this,"cannot write to the file.","cannot write to the selected file.nothing saved. \ntry another file.",QMessageBox::Ok,QMessageBox::Cancel);
                if(messageResult==QMessageBox::Ok)
                  continue;
                else break;
              }
              else break;
            }
            else
            {
              int messageResult= QMessageBox::critical(this,"cannot write to the file.","cannot write selected file. \ntry another file.",QMessageBox::Ok,QMessageBox::Cancel);
              if(messageResult==QMessageBox::Ok)
                continue;
              else break;
            }
          }
        }
        else break;
      }
    });
    btnExport->setIcon(QIcon(Resources::Export16));
    btnExport->setText("export");
    plainTextInfoLayout->addStretch();
    plainTextInfoLayout->addWidget(btnExport);
    plainTextTabLayout->addLayout(plainTextInfoLayout);

    plainTextTab->setLayout(plainTextTabLayout);

    ui->tvFormats->addTab(plainTextTab,"Plain Text");
  }
}
예제 #16
0
void ContentViewer::addHTMLTab()
{
  if(_entity->hasHTML())
  {
    QWidget *tab=new QWidget(ui->tvFormats);
    tab->setObjectName("HTML");
    tab->setWindowTitle("HTML");

    QVBoxLayout *tabLayout=new QVBoxLayout();

    QTabWidget *innerTabWidget=new QTabWidget(tab);
    QWidget *previewTab=new QWidget(innerTabWidget);
    previewTab->setObjectName("preview");
    previewTab->setWindowTitle("preview");

    QVBoxLayout *previewTabLayout=new QVBoxLayout();


    QTextBrowser *previewTextBorowser=new QTextBrowser(tab);
    previewTextBorowser->setText(_entity->HTMLText(false,-1));
    previewTextBorowser->setReadOnly(true);

    QHBoxLayout *previewTabOptionsLayout=new QHBoxLayout();
    previewTabOptionsLayout->addStretch();

    QLabel *previewCBLabel=new QLabel(previewTab);
    previewCBLabel->setText("background color : ");
    previewTabOptionsLayout->addWidget(previewCBLabel);

    QPushButton *previewBCButton=new QPushButton(previewTab);
    previewBCButton->setText("white");
    previewBCButton->setStyleSheet("background-color : white ;");
    connect(previewBCButton,&QPushButton::clicked,this,[this,previewTextBorowser,previewBCButton](){
      QColorDialog CD(this);
      if(CD.exec())
      {
        QColor color=CD.selectedColor();
        previewTextBorowser->setStyleSheet("background-color :  "+color.name()+";");
        previewBCButton->setText(color.name());
        previewBCButton->setStyleSheet("background-color :  "+color.name()+";");
      }
    });

    previewTabOptionsLayout->addWidget(previewBCButton);
    previewTabLayout->addLayout(previewTabOptionsLayout);

    previewTabLayout->addWidget(previewTextBorowser);
    previewTab->setLayout(previewTabLayout);
    innerTabWidget->addTab(previewTab,"preview");

    QWidget *codeTab=new QWidget(innerTabWidget);
    codeTab->setObjectName("code");
    codeTab->setWindowTitle("code");

    QVBoxLayout *codeTabLayout=new QVBoxLayout();
    QPlainTextEdit *codeTextEdit=new QPlainTextEdit(codeTab);
    codeTextEdit->setPlainText(_entity->HTMLText(false,-1));
    codeTextEdit->setReadOnly(true);
    codeTabLayout->addWidget(codeTextEdit);

    codeTab->setLayout(codeTabLayout);

    innerTabWidget->addTab(codeTab,"code");


    tabLayout->addWidget(innerTabWidget);

    QHBoxLayout *infoLayout=new QHBoxLayout();
    QLabel *infoLabel=new QLabel(tab);
    infoLabel->setText(QString("<b>length :</b> %1").arg(previewTextBorowser->toPlainText().count())
                               +"  "+QString("<b>size :</b> %1 KB").arg((double)_entity->formatSize("text/html")/1024));
    infoLayout->addWidget(infoLabel);

    QPushButton *btnExport=new QPushButton(tab);
    connect(btnExport,&QPushButton::clicked,this,[this](){
      QFileDialog dialog;
      dialog.setAcceptMode(QFileDialog::AcceptSave);
      dialog.setWindowTitle("select a file to save HTML");
      dialog.setWindowIcon(QIcon(Resources::Export16));
      dialog.setFileMode(QFileDialog::AnyFile);
      dialog.setDefaultSuffix("html");
      for(;;)
      {
        if(dialog.exec())
        {
          int length=dialog.selectedFiles().length();
          if(length>0 && length==1)
          {
            QFile file(dialog.selectedFiles().at(0));
            file.open(QIODevice::WriteOnly);
            if(file.isWritable())
            {
              qint64 i= file.write(this->_entity->HTMLText(false,-1).toUtf8());
              if(i<0)
              {
                int messageResult= QMessageBox::critical(this,"cannot write to the file.","cannot write to the selected file.nothing saved. \ntry another file.",QMessageBox::Ok,QMessageBox::Cancel);
                if(messageResult==QMessageBox::Ok)
                  continue;
                else break;
              }
              else break;
            }
            else
            {
              int messageResult= QMessageBox::critical(this,"cannot write to the file.","cannot write selected file. \ntry another file.",QMessageBox::Ok,QMessageBox::Cancel);
              if(messageResult==QMessageBox::Ok)
                continue;
              else break;
            }
          }
        }
        else break;
      }
    });
    btnExport->setIcon(QIcon(Resources::Export16));
    btnExport->setText("export");
    infoLayout->addStretch();
    infoLayout->addWidget(btnExport);
    tabLayout->addLayout(infoLayout);

    tab->setLayout(tabLayout);

    ui->tvFormats->addTab(tab,"HTML");
  }
}