mainwindow.cpp
上传用户:dsfsafq
上传日期:2022-06-05
资源大小:47k
文件大小:3k
- #include <QtGui>
- #include <QtCore>
- #include "mainwindow.h"
- #include "ui_mainwindow.h"
- MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindowClass)
- {
- ui->setupUi(this);
- QDirModel *dir_model = new QDirModel;
- QCompleter *completer = new QCompleter(dir_model, this);
- ui->lineInputFile->setCompleter(completer);
- ui->lineOutputFile->setCompleter(completer);
- }
- MainWindow::~MainWindow()
- {
- delete ui;
- }
- void MainWindow::on_btnLoadInput_clicked()
- {
- inputfile = QFileDialog::getOpenFileName(this, tr("Select .rmvb file to convert"), QDir::homePath(), tr("Real Media Video (*.rmvb *.*)"));
- ui->lineInputFile->setText(inputfile);
- }
- void MainWindow::on_btnSelectOutput_clicked()
- {
- outputfile = QFileDialog::getSaveFileName(this, tr("Select .avi file"), QDir::homePath(), tr("AVI (*.avi *.*)"));
- ui->lineOutputFile->setText(outputfile);
- }
- void MainWindow::on_btnConvert_clicked()
- {
- inputfile = ui->lineInputFile->text();
- outputfile = ui->lineOutputFile->text();
- QString framerate = "25";
- if (ui->radioNTSC->isChecked())
- framerate = "29.97";
- TranscodingThread *process = new TranscodingThread(inputfile, outputfile, framerate);
- connect(process, SIGNAL(updateProgress(QString)), this, SLOT(updateProgress(QString)));
- process->run();
- progress = new QProgressDialog("Please wait while the file is transcoded.", "Cancel", 0, 100, this);
- progress->setWindowModality(Qt::WindowModal);
- progress->setWindowTitle("Transcoding .rmvb file...");
- connect(this, SIGNAL(updateProgress(int)), progress, SLOT(setValue(int)));
- }
- void MainWindow::on_lineOutputFile_textChanged(QString )
- {
- if (!ui->lineInputFile->text().isEmpty())
- {
- ui->btnConvert->setEnabled(true);
- ui->btnConvert->setToolTip("Start the conversion process");
- }
- }
- void MainWindow::on_lineInputFile_textChanged(QString )
- {
- if (!ui->lineOutputFile->text().isEmpty())
- {
- ui->btnConvert->setEnabled(true);
- ui->btnConvert->setToolTip("Start the conversion process");
- }
- }
- void MainWindow::updateProgress(QString percentage)
- {
- if(percentage == "finished")
- {
- emit updateProgress(100);
- return;
- }
- percentage.replace("(", "");
- percentage.replace("%", "");
- percentage.replace(")", "");
- emit updateProgress(percentage.toInt());
- // QMessageBox msgBox;
- // msgBox.setText("The conversion process is complete. Thanks for using rmvb2avi! :)");
- // msgBox.setInformativeText("Convert another file?");
- // msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
- // msgBox.setDefaultButton(QMessageBox::No);
- // int ret = msgBox.exec();
- // if (ret == QMessageBox::No || ret == QMessageBox::Cancel)
- // this->close();
- }