void MainWindow::loadMedia(){ // mime database to detect file type QMimeDatabase db; // the mime type (to test if it is an audio file QMimeType type; // file list to be inserted into playlist QStringList filelist; // audio file to be opened QFileDialog d; filelist = d.getOpenFileNames(this,tr("Open File"), "/home", tr("Audio (*.wav *.mp3 *.ogg *.flac)")); // retrieve mime type for(QList<QString>::const_iterator it=filelist.begin(); it!= filelist.end(); it++){ type = db.mimeTypeForFile(*it); // test if the file is an audio file // if yes, send it to the playlist if(type.name().startsWith("audio")){ playlist->addMedia(QUrl::fromLocalFile(*it)); } } }
void MainWindow2::importImageSequence() { QFileDialog w; w.setFileMode( QFileDialog::AnyFile ); QSettings settings( PENCIL2D, PENCIL2D ); QString initialPath = settings.value( "lastImportPath", QVariant( QDir::homePath() ) ).toString(); if ( initialPath.isEmpty() ) { initialPath = QDir::homePath(); } QStringList files = w.getOpenFileNames( this, "Select one or more files to open", initialPath, "Images (*.png *.jpg *.jpeg *.bmp)" ); for ( QString strImgFile : files ) { if ( strImgFile.endsWith( ".png" ) || strImgFile.endsWith( ".jpg" ) || strImgFile.endsWith( ".jpeg" ) || strImgFile.endsWith( ".bmp" ) ) { mEditor->importImage( strImgFile ); mEditor->scrubForward(); } } }
void MainWindow::on_addFileButton_clicked(){ QFileDialog dialog; SETTINGS(); QStringList files=dialog.getOpenFileNames( this, QString("Choose files to add"), settings.value("main-window-add-files").toString(), QString::null ); if(files.empty()) return; settings.setValue("main-window-add-files",files.at(0)); for(int i=0;i<files.count();i++){ addFile(files.at(i)); } }
void ImageFactory::exportImg() { QFileDialog *dial = new QFileDialog(this, Qt::Dialog); QString dir = dial->getExistingDirectory(this, "Select the destination folder", QDir::currentPath(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); QStringList listPicture = dial->getOpenFileNames(this, "Select one or more files", QDir::currentPath(), "Image Files (*.png *.jpg *.jpeg *.bmp)"); if (!listPicture.isEmpty()) { QString file; QStringList::Iterator it = listPicture.begin(); while (it != listPicture.end()) { QString dest = *it; int index = dest.lastIndexOf("/"); std::cout << index << std::endl; dest.remove(0, index); file = "cp " + *it + " " + dir + dest; const char *str = file.toStdString().c_str(); std::cout << str << std::endl; system(str); ++it; } } }
int main(int argc, char *argv[]) { // QGuiApplication a(argc, argv); QApplication a(argc, argv); QwtPlot *plot = new QwtPlot(); QwtPlotCanvas *canvas = new QwtPlotCanvas(); canvas->setBorderRadius(10); plot->setCanvas(canvas); plot->setCanvasBackground(QColor("LIGHTGRAY")); plot->enableAxis(QwtPlot::yRight); plot->enableAxis(QwtPlot::xTop); plot->setAxisTitle(QwtPlot::xBottom, "Xline"); plot->setAxisTitle(QwtPlot::xTop, "Xline"); plot->setAxisTitle(QwtPlot::yLeft, "Inline"); plot->setAxisTitle(QwtPlot::yRight, "Inline"); // float minx = srv->getStations().first().x(); // float maxx = srv->getStations().last().x(); plot->setAxisScale( QwtPlot::xBottom,3500,300); // plot->setAxisScale( QwtPlot::xTop,minx,maxx ); // QwtScaleDraw *sd = axisScaleDraw( QwtPlot::yLeft ); // sd->setMinimumExtent( sd->extent( axisWidget( QwtPlot::yLeft )->font() ) ); plot->plotLayout()->setAlignCanvasToScales( true ); QFileDialog custDialog; QStringList names = custDialog.getOpenFileNames(NULL, ("Open Files..."),QString(), ("UKOOA Files (*.p190 *.p90);;All Files (*)")); // handle if the dialog was "Cancelled" if(names.isEmpty()) { return 0; } qSort(names.begin(), names.end()); QVector <QwtPlotCurve *> curves; foreach (QString name, names) { QwtPlotCurve *vCurve = new QwtPlotCurve; if(name.contains(QString( "NS1763")) || name.contains(QString("NS2029"))) { QColor c = Qt::red; vCurve->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, Qt::red,c , QSize( 2, 2 ) ) ); } else { QColor c = Qt::green; vCurve->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, Qt::green,c , QSize( 2, 2 ) ) ); } vCurve->setStyle( QwtPlotCurve::NoCurve ); vCurve->setPen( Qt::gray ); cout << name.toStdString() << endl; QVector<QPointF> curveData; // m_nameLineLable->setText(m_names.at(0)); QFile *ukFile = new QFile(QString(name)); bool rt = ukFile->open(QIODevice::ReadOnly); cout << "return " << rt << endl; qint64 icount = 0; qint64 fileSize = ukFile->size(); char *data = new char[fileSize]; ukFile->read(data,fileSize); QString sData = data; QString shot = "SNS"; while (true) { ukFile->seek(icount); ukFile->read(data,fileSize); sData = data;; if(icount>=fileSize) { break; } auto sPos = sData.indexOf(shot,0,Qt::CaseInsensitive); QString cr = sData.mid(sPos,19); if(cr.contains("\n")) { sPos +=2; } // auto shotNo = sData.mid(sPos+20,sPos+5); QString shotNo = sData.mid(sPos+19,6); int shotNos; if(shotNo.contains("\n") || shotNo.contains("\r")) { shotNo = sData.mid(sPos+19,8); int shift1 = shotNo.indexOf("\r"); int shift = shotNo.indexOf("\n"); // cout << shift1 << " " << shift << endl; QString tmp = shotNo.mid(0,shift1); tmp.append(shotNo.mid(shift+1,3)); shotNos = tmp.toInt(); } else { shotNos = sData.mid(sPos+19,6).toInt(); } float shotYs; sPos = sData.indexOf(shot,0,Qt::CaseInsensitive); cr = sData.mid(sPos,55); if(cr.contains("\n")) { // cout << " cr " << sPos << endl; sPos +=2; } QString shotY = sData.mid(sPos+55,10); // cout << "shotx " << shotX.toStdString() << endl; if(shotY.contains("\n") || shotY.contains("\r")) { shotY = sData.mid(sPos+55,12); int shift1 = shotY.indexOf("\r"); int shift = shotY.indexOf("\n"); // cout << shift1 << " " << shift << endl; QString tmp = shotY.mid(0,shift1); tmp.append(shotY.mid(shift+1,12)); shotYs = tmp.toFloat(); } else { shotYs = shotY.toFloat(); } float shotXs; sPos = sData.indexOf(shot,0,Qt::CaseInsensitive); cr = sData.mid(sPos,46); if(cr.contains("\n")) { // cout << " cr " << sPos << endl; sPos +=2; } QString shotX = sData.mid(sPos+46,10); // cout << "shotx " << shotX.toStdString() << endl; if(shotX.contains("\n") || shotX.contains("\r")) { shotX = sData.mid(sPos+46,12); int shift1 = shotX.indexOf("\r"); int shift = shotX.indexOf("\n"); // cout << shift1 << " " << shift << endl; QString tmp = shotX.mid(0,shift1); tmp.append(shotX.mid(shift+1,12)); shotXs = tmp.toFloat(); } else { shotXs = shotX.toFloat(); } icount +=sPos+1; // cout << shotNos << endl; float shotXt = shotXs - 757551.46; float shotYt = shotYs - 978769.0; float shotYr = shotYt * cosf(13.661f * M_PI/180.0f) + shotXt * sinf(13.661f * M_PI/180.0f); int shotYy = 981 + shotYr/25.0; float shotXr = shotXt * cosf(13.661f * M_PI/180.0f) - shotYt * sinf(13.661f * M_PI/180.0f); int shotXx = 2570 - shotXr/25.0; // if(shotXx>0 && shotYy>0) // { QPointF shotPoint(shotXx,shotYy); curveData.append(shotPoint); // cout << " shot " << shotNos << " " << shotXs << " " << shotYs << " " << shotXx << " " << shotYy << endl; // } } vCurve->setSamples(curveData); curves.append(vCurve); ukFile->close(); }