Skip to content

Commit

Permalink
Decapitalize meta-data files
Browse files Browse the repository at this point in the history
  • Loading branch information
bartkessels committed Sep 22, 2018
1 parent 91559d6 commit 8352d99
Show file tree
Hide file tree
Showing 18 changed files with 117 additions and 94 deletions.
6 changes: 4 additions & 2 deletions SimpleConvert.pro
Expand Up @@ -21,13 +21,15 @@ SOURCES += \
src/mainwindow.cpp \
src/listitemfile.cpp \
src/preferencesdialog.cpp \
src/preferences.cpp
src/preferences.cpp \
src/conversioncontroller.cpp

HEADERS += \
src/mainwindow.h \
src/listitemfile.h \
src/preferencesdialog.h \
src/preferences.h
src/preferences.h \
src/conversioncontroller.h

FORMS += \
src/ui/mainwindow.ui \
Expand Down
6 changes: 3 additions & 3 deletions data/packaging/RPM/simpleconvert.spec
Expand Up @@ -37,9 +37,9 @@ make install
%files
%{_bindir}/simpleconvert
%{_datarootdir}/net.bartkessels.simpleconvert/translations/*
%{_datarootdir}/appdata/net.bartkessels.SimpleConvert.appdata.xml
%{_datarootdir}/applications/net.bartkessels.SimpleConvert.desktop
%{_datarootdir}/icons/hicolor/*/apps/net.bartkessels.SimpleConvert.*
%{_datarootdir}/appdata/net.bartkessels.simpleconvert.appdata.xml
%{_datarootdir}/applications/net.bartkessels.simpleconvert.desktop
%{_datarootdir}/icons/hicolor/*/apps/net.bartkessels.simpleconvert.*

%changelog
* Wed Jul 11 2018 Bart Kessels <bartkessels@bk-mail.com> 3.2
Expand Down
39 changes: 0 additions & 39 deletions data/packaging/flatpak/net.bartkessels.SimpleConvert.json

This file was deleted.

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2018 Bart Kessels <bartkessels@bk-mail.com> -->
<component type="desktop">
<id>net.bartkessels.SimpleConvert.desktop</id>
<id>net.bartkessels.simpleconvert.desktop</id>
<metadata_licence>CC0</metadata_licence>
<project_license>GPL-3.0+</project_license>
<name>SimpleConvert</name>
Expand Down
Expand Up @@ -6,5 +6,5 @@ Terminal=false
Type=Application
Categories=Qt;Multimedia;
StartupNotify=true
Icon=net.bartkessels.SimpleConvert
Name[en_US]=net.bartkessels.SimpleConvert.desktop
Icon=net.bartkessels.simpleconvert
Name[en_US]=SimpleConvert
17 changes: 17 additions & 0 deletions src/conversioncontroller.cpp
@@ -0,0 +1,17 @@
#include "conversioncontroller.h"

ConversionController::ConversionController(QObject *parent):
QObject(parent)
{

}

ConversionController::~ConversionController()
{
/* Kill current process if there
* are files being converted
*/
if (filesConverted > 0) {
ffmpegProcess->kill();
}
}
27 changes: 27 additions & 0 deletions src/conversioncontroller.h
@@ -0,0 +1,27 @@
#pragma once

#include <QObject>
#include <QProcess>

class ConversionController: public QObject
{
Q_OBJECT

public:
explicit ConversionController(QObject *parent = 0);
~ConversionController();

void convertFiles();

signals:
void missingFFMPEGBinary();
void noOutputDirectory();
void on_fileConverted(int filesConverted, int totalFiles);

private:
QProcess *ffmpegProcess;
int totalFiles = 0;
int filesConverted = 0;
bool canceled = false;
};

102 changes: 59 additions & 43 deletions src/mainwindow.cpp
Expand Up @@ -20,9 +20,9 @@ MainWindow::~MainWindow()
/* Kill current process if there
* are files being converted
*/
if (filesConverted > 0) {
ffmpegProcess->kill();
}
// if (filesConverted > 0) {
// ffmpegProcess->kill();
// }

delete movie;
delete ui;
Expand Down Expand Up @@ -131,8 +131,8 @@ void MainWindow::on_actionStop_conversion_triggered()
}

if (messageBoxReply == QMessageBox::Yes) {
ffmpegProcess->kill();
canceled = true;
// ffmpegProcess->kill();
// canceled = true;
}
}

Expand Down Expand Up @@ -180,31 +180,31 @@ void MainWindow::on_actionAbout_SimpleConvert_triggered()
*
* @param int exitCode the code with which the process is exited
*/
void MainWindow::on_fileConverted(int exitCode)
{
Q_UNUSED (exitCode)
//void MainWindow::on_fileConverted(int exitCode)
//{
// Q_UNUSED (exitCode)

int totalFilesToConvert = ui->lvFiles->count();
filesConverted++;
// int totalFilesToConvert = ui->lvFiles->count();
// filesConverted++;

ui->pbStatus->setValue(filesConverted);
// ui->pbStatus->setValue(filesConverted);

if (filesConverted >= totalFilesToConvert || canceled) {
updateUI(false, 0);
ffmpegProcess->deleteLater();
// if (filesConverted >= totalFilesToConvert || canceled) {
// updateUI(false, 0);
// ffmpegProcess->deleteLater();

/* Check if we need to show a notification */
if (Preferences::getShowNotificationWhenConverted() && !canceled) {
QMessageBox::information(this, tr("Converting Finished"),
tr("All your files are converted"));
}

filesConverted = 0;
canceled = false;
} else {
processNextFile();
}
}
// if (Preferences::getShowNotificationWhenConverted() && !canceled) {
// QMessageBox::information(this, tr("Converting Finished"),
// tr("All your files are converted"));
// }

// filesConverted = 0;
// canceled = false;
// } else {
// processNextFile();
// }
//}

/**
* @brief MainWindow::processNextFile
Expand All @@ -213,26 +213,42 @@ void MainWindow::on_fileConverted(int exitCode)
*/
void MainWindow::processNextFile()
{
QString ffmpegBinary = Preferences::getFFmpegBinary();
int nextFileIndex = filesConverted;
ListItemFile *currentFile = dynamic_cast<ListItemFile*>(ui->lvFiles->item(nextFileIndex));

QStringList ffmpegArguments;
ffmpegArguments.append("-i");
ffmpegArguments.append(currentFile->getFilePath());
ffmpegArguments.append(getOutputFilePath(currentFile->getFileName()));

/* Check if we should overwrite the output file if it exists */
if (Preferences::getOverwriteOutput()) {
ffmpegArguments.append("-y");
} else {
ffmpegArguments.append("-n");
// QString ffmpegBinary = Preferences::getFFmpegBinary();
// int nextFileIndex = filesConverted;
// QList files= dynamic_cast<QList<ListItemFile*>>(ui->lvFiles->items());

QList<QListWidgetItem*> files = ui->lvFiles->findItems("*", Qt::MatchWildcard);

if (files.size() < 1) {
qInfo() << "files.size < 1";
return;
}

ffmpegProcess = new QProcess(this);
connect (ffmpegProcess, SIGNAL(finished(int)), this, SLOT(on_fileConverted(int)));
ffmpegProcess->setProcessChannelMode(QProcess::MergedChannels);
ffmpegProcess->start(ffmpegBinary, ffmpegArguments);
qInfo() << dynamic_cast<ListItemFile*>(files.at(0))->getFileName();

// check if output of cast is not NULL, of it is null
// the cast went wrong https://stackoverflow.com/questions/2253168/dynamic-cast-and-static-cast-in-c


// ListItemFile *file = dynamic_cast<ListItemFile*>(files.at(0));
// file->getFileName();

// QStringList ffmpegArguments;
// ffmpegArguments.append("-i");
// ffmpegArguments.append(currentFile->getFilePath());
// ffmpegArguments.append(getOutputFilePath(currentFile->getFileName()));

// /* Check if we should overwrite the output file if it exists */
// if (Preferences::getOverwriteOutput()) {
// ffmpegArguments.append("-y");
// } else {
// ffmpegArguments.append("-n");
// }

// ffmpegProcess = new QProcess(this);
// connect (ffmpegProcess, SIGNAL(finished(int)), this, SLOT(on_fileConverted(int)));
// ffmpegProcess->setProcessChannelMode(QProcess::MergedChannels);
// ffmpegProcess->start(ffmpegBinary, ffmpegArguments);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/mainwindow.h
Expand Up @@ -35,7 +35,10 @@ private slots:
void on_actionPreferences_triggered();
void on_actionAbout_Qt_triggered();
void on_actionAbout_SimpleConvert_triggered();
void on_fileConverted(int exitCode);
// -------------------------------
// void on_NoFFMPEGBinary_triggered();
// void on_NoOutputDirectory_triggered();
// void on_UpdateUI_triggered(int filesConverted, int totalFiles);

private:
void disableLayout(QLayoutItem *obj, bool enabled, bool visible);
Expand All @@ -45,7 +48,4 @@ private slots:

Ui::MainWindow *ui;
QMovie *movie;
QProcess *ffmpegProcess;
int filesConverted = 0;
bool canceled = false;
};

0 comments on commit 8352d99

Please sign in to comment.