2
A tool for converting your media files to
3
all the popular formats
4
Copyright © 2012 by Alex Solanos and Leon Vytanos
6
This program is free software; you can redistribute it and/or
7
modify it under the terms of the GNU General Public License
8
as published by the Free Software Foundation; either version 3
9
of the License, or (at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*/
20
#define QT_NO_KEYWORDS
22
#include "mainwindow.h"
23
#include "ui_mainwindow.h"
27
#include <unity/unity/unity.h>
28
#include <libnotify/notify.h>
32
#include <QFileDialog>
33
#include <QDirIterator>
37
#include <QCloseEvent>
40
#include <QMessageBox>
42
#include <QGraphicsOpacityEffect>
43
#include <QPropertyAnimation>
44
#include <QDBusMessage>
45
#include <QDBusInterface>
50
QProcess *audio_converter=new QProcess(0);
51
QProcess *video_converter=new QProcess(0);
52
QProcess *image_converter=new QProcess(0);
53
QProcess *files_to_iso=new QProcess(0);
54
QProcess *iso_to_cso=new QProcess(0);
55
QProcess *cso_to_iso=new QProcess(0);
56
QProcess *sub_encoding=new QProcess(0);
57
float duration_secs=0;
58
QString input_file="";
59
QString output_file="";
60
//tmp file to be removed after the wav to m4r conversion
61
QString output_file_rm="";
64
QString file_exists="";
65
QString file_not_exists="";
66
//glob_pro_label is a string
67
//which is placed in a completed file
68
QString globpro_string="100%";
69
QString all_errors="";
70
QString current_file_errors="";
72
QString video_resize_value="hd720";
78
int image_conversion_result=0;
79
/*AUDIO PREFERENCES START*/
80
bool audio_bitrate=false;
81
bool audio_samplerate=false;
82
bool audio_channels=false;
83
bool audio_volume=false;
84
int audio_bitrate_value=198;
85
int audio_samplerate_value=44100;
86
int audio_channels_value=2;
87
int audio_volume_value=256;
90
int already_completed=0;
91
/*AUDIO PREFERENCES END*/
92
bool m4r_or_a_time=false;
93
bool m4r_or_a_previous_was_error=false;
94
bool faac_percent_found=false;
95
bool full_percent_instant=false;
96
bool overwrite_existing=false;
97
bool delete_original=false;
98
bool audio_stop_pressed=false;
99
bool video_stop_pressed=false;
100
bool image_stop_pressed=false;
101
bool sub_stop_pressed=false;
102
bool globpro_hasbeendeleted=false;
103
bool about_shown=false;
104
bool unity_progressbar=true;
105
bool unity_count=true;
106
bool desktop_notifications=true;
107
bool indicator=false;
108
bool image_width_height=false;
109
bool image_respect_ratio=false;
110
bool image_colors_number=false;
111
int image_colors_number_value=256;
112
bool video_crop=false;
113
int video_width_value=100;
114
int video_height_value=100;
117
bool video_resize=false;
118
bool video_bitrate=false;
119
bool video_framerate=false;
120
bool image_comment=false;
121
int video_bitrate_value=198;
122
int video_framerate_value=44100;
123
QString image_comment_value="";
124
bool image_crop=false;
125
bool indicator_has_been_created=false;
126
bool iso_to_cso_stop_pressed=false;
127
bool cso_to_iso_stop_pressed=false;
128
int image_width_value=100;
129
int image_height_value=100;
133
//variable to check if the program should proceed to
134
//faac conversion after converting to a temp file
135
//for converting to m4r and m4a files
136
//The variable becomes false when the return_code of
138
bool proceed_to_faac_conversion=true;
140
//notification specific...
141
bool first_notification=true;
142
NotifyNotification* notification;
144
GError* error = NULL;
146
//unity launcher integration
147
UnityLauncherEntry *unity_progress;
149
MainWindow::MainWindow(QWidget *parent) :
151
ui(new Ui::MainWindow)
159
ui->progressBar->hide();
160
ui->progressBar_2->hide();
161
ui->progressBar_3->hide();
162
ui->startBtn->setEnabled(false);
163
ui->startBtn_2->setEnabled(false);
164
ui->startBtn_3->setEnabled(false);
166
on_after_convertion2_currentIndexChanged(ui->after_convertion2->currentIndex());
168
//connecting audio...
169
QObject::connect(audio_converter, SIGNAL(readyReadStandardOutput()), this, SLOT(audio_read_output()));
170
QObject::connect(audio_converter, SIGNAL(readyReadStandardError()), this, SLOT(audio_read_output()));
171
QObject::connect(audio_converter, SIGNAL(finished(int)), this, SLOT(audio_conversion(int)));
173
//connecting video...
174
QObject::connect(video_converter, SIGNAL(readyReadStandardOutput()), this, SLOT(video_read_output()));
175
QObject::connect(video_converter, SIGNAL(readyReadStandardError()), this, SLOT(video_read_output()));
176
QObject::connect(video_converter, SIGNAL(finished(int)),this, SLOT(video_conversion(int)));
178
//connecting image...
179
QObject::connect(image_converter, SIGNAL(readyReadStandardOutput()), this, SLOT(image_read_output()));
180
QObject::connect(image_converter, SIGNAL(readyReadStandardError()), this, SLOT(image_read_output()));
181
QObject::connect(image_converter, SIGNAL(finished(int)),this, SLOT(image_conversion(int)));
183
//connection files_to_iso
184
QObject::connect(files_to_iso, SIGNAL(finished(int)),this, SLOT(files_to_iso_end(int)));
186
//connection iso_to_cso
187
QObject::connect(iso_to_cso, SIGNAL(finished(int)),this, SLOT(iso_to_cso_end(int)));
189
//connection cso_to_iso
190
QObject::connect(cso_to_iso, SIGNAL(finished(int)),this, SLOT(cso_to_iso_end(int)));
192
//connecting sub_encoding
193
QObject::connect(sub_encoding, SIGNAL(finished(int)),this, SLOT(sub_encoding_end(int)));
195
QSettings settings( "FormatJunkie", "MainWindow" );
196
ui->outputFormatComboBox->setCurrentIndex(settings.value("output_format_audio").toInt());
197
ui->outputFormatComboBox_2->setCurrentIndex(settings.value("output_format_video").toInt());
198
ui->outputFormatComboBox_3->setCurrentIndex(settings.value("output_format_image").toInt());
199
if(!add_audio && !add_video && !add_image){//<-we will head to the appropriate Index for each of these...
200
cur_index=settings.value("current_index",0).toInt();
201
ui->stackedWidget->setCurrentIndex(cur_index);
202
switch(settings.value("current_index",0).toInt()){
204
ui->musicButton->setChecked(true);
207
ui->videoButton->setChecked(true);
210
ui->imageButton->setChecked(true);
213
ui->rom_deviceButton->setChecked(true);
216
ui->advancedButton->setChecked(true);
219
ui->musicButton->setChecked(true);
225
//a command line argument is hereee (checked from main.cpp)!
237
QSettings settings2( "FormatJunkie", "Preferences" );
239
quality=settings2.value("quality", 100).toInt();
240
if (quality<0 || quality>100)
242
overwrite_existing=settings2.value("overwrite", false).toBool();
243
delete_original=settings2.value("deleteoriginal", false).toBool();
244
unity_progressbar=settings2.value("unity_progressbar", true).toBool();
245
unity_count=settings2.value("unity_count",true).toBool();
246
desktop_notifications=settings2.value("desktop_notifications", true).toBool();
247
indicator=settings2.value("indicator", false).toBool();
249
audio_bitrate=settings2.value("audio_bitrate", false).toBool();
250
audio_samplerate=settings2.value("audio_sample_rate", false).toBool();
251
audio_channels=settings2.value("audio_channels", false).toBool();
252
audio_volume=settings2.value("audio_volume", false).toBool();
253
audio_bitrate_value=settings2.value("audio_bitrate_spinbox", 198).toInt();
254
audio_samplerate_value=settings2.value("audio_sample_rate_spinbox", 44100).toInt();
255
audio_channels_value=settings2.value("audio_channels_spinbox", 2).toInt();
256
audio_volume_value=settings2.value("audio_volume_spinbox", 256).toInt();
258
video_bitrate=settings2.value("video_bitrate", false).toBool();
259
video_framerate=settings2.value("video_frame_rate", false).toBool();
260
video_crop=settings2.value("video_crop", false).toBool();
261
video_width_value=settings2.value("video_width_spinbox", 100).toInt();
262
video_height_value=settings2.value("video_height_spinbox", 100).toInt();
263
video_x_value=settings2.value("video_x_spinbox", 100).toInt();
264
video_y_value=settings2.value("video_y_spinbox", 100).toInt();
265
video_resize=settings2.value("video_resize", false).toBool();
267
set_video_resize_value(settings.value("video_resize_index",0).toInt());
270
image_width_height=settings2.value("image_width_height", false).toBool();
271
image_width=settings2.value("image_width", 300).toInt();
272
image_height=settings2.value("image_height", 300).toInt();
273
image_respect_ratio=settings2.value("image_respect_ratio", false).toBool();
274
image_colors_number=settings2.value("image_colors_number", false).toBool();
275
image_colors_number_value=settings2.value("image_colors_number_spinbox", 256).toBool();
276
image_comment=settings2.value("image_comment", false).toBool();
277
image_comment_value=settings2.value("image_comment_lineedit", "").toString();
278
image_crop=settings2.value("image_crop", false).toBool();
279
image_width_value=settings2.value("image_width_spinbox", 100).toInt();
280
image_height_value=settings2.value("image_height_spinbox", 100).toInt();
281
image_x_value=settings2.value("image_x_spinbox", 100).toInt();
282
image_y_value=settings2.value("image_y_spinbox", 100).toInt();
284
QString qoutput_folder=settings.value("output",QDir::homePath()+"/Documents/FJOutput").toString();
285
//crop the output folder if it doesn't fit...
286
crop_output_folder(qoutput_folder);
288
ui->tableWidget->setColumnWidth(0, 370);
289
ui->tableWidget->verticalHeader()->hide();
290
ui->tableWidget_2->setColumnWidth(0,370);
291
ui->tableWidget_2->verticalHeader()->hide();
292
ui->tableWidget_3->setColumnWidth(0,370);
293
ui->tableWidget_3->verticalHeader()->hide();
294
ui->tableWidget_6->setColumnWidth(0,380);
295
ui->tableWidget_6->verticalHeader()->hide();
297
globpro = new QProgressBar(this);
300
ui->show_errors->hide();
302
QDBusConnection::sessionBus().connect(QString(),QString(), "do.action", "formatjunkie_message", this, SLOT(dbus_action(QString)));
303
unity_progress = unity_launcher_entry_get_for_desktop_id("formatjunkie.desktop");
305
//accept drag en drop
306
setAcceptDrops(true);
308
//creating the indicator
313
MainWindow::~MainWindow()
318
void MainWindow::closeEvent( QCloseEvent * ){
319
QApplication::setQuitOnLastWindowClosed(true);
320
QSettings settings( "FormatJunkie", "MainWindow" );
321
settings.setValue( "output", ui->output_folder->toolTip() );
322
settings.setValue( "output_format_audio", ui->outputFormatComboBox->currentIndex() );
323
settings.setValue( "output_format_video", ui->outputFormatComboBox_2->currentIndex() );
324
settings.setValue( "output_format_image", ui->outputFormatComboBox_3->currentIndex() );
325
settings.setValue( "current_index", cur_index );
329
void MainWindow::setup_shortcuts(){
330
(void) new QShortcut(Qt::CTRL + Qt::Key_P, this, SLOT(on_actionPreferences_triggered()));
331
(void) new QShortcut(Qt::CTRL + Qt::Key_Q, this, SLOT(close()));
332
(void) new QShortcut(Qt::CTRL + Qt::Key_M, this, SLOT(add_audio_files()));
333
(void) new QShortcut(Qt::CTRL + Qt::Key_V, this, SLOT(add_video_files()));
334
(void) new QShortcut(Qt::CTRL + Qt::Key_I, this, SLOT(add_image_files()));
335
(void) new QShortcut(Qt::Key_F1, this, SLOT(on_actionContents_F1_triggered()));
336
(void) new QShortcut(Qt::Key_Delete, this, SLOT(on_removeBtn_clicked()));
340
void MainWindow::dragEnterEvent(QDragEnterEvent *event){
341
event->acceptProposedAction();
345
void MainWindow::dropEvent(QDropEvent *event)
347
QList<QUrl> urlList = event->mimeData()->urls();
348
QStringList audio,video,image;
350
for (QList<QUrl>::const_iterator i = urlList.begin(); i != urlList.end();i++)
352
QString received_file = (*i).toString();
353
received_file=received_file.mid(7,received_file.length()-2);
354
if(received_file.endsWith(".mp3") || received_file.endsWith(".MP3") || received_file.endsWith(".wav") || received_file.endsWith(".WAV") || received_file.endsWith(".ogg") || received_file.endsWith(".OGG") || received_file.endsWith(".wma") || received_file.endsWith(".WMA") || received_file.endsWith(".flac") || received_file.endsWith(".FLAC") || received_file.endsWith(".m4r") || received_file.endsWith(".M4R") || received_file.endsWith(".aac") || received_file.endsWith(".AAC") || received_file.endsWith(".m4a") || received_file.endsWith(".M4A") || received_file.endsWith(".mp2") || received_file.endsWith(".MP2")){
355
audio << received_file;
358
else if(received_file.endsWith(".avi") || received_file.endsWith(".AVI") || received_file.endsWith(".wmv") || received_file.endsWith(".WMV") || received_file.endsWith(".ogv") || received_file.endsWith(".OGV") || received_file.endsWith(".vob") || received_file.endsWith(".VOB") || received_file.endsWith(".3gp") || received_file.endsWith(".3GP") || received_file.endsWith(".mkv") || received_file.endsWith(".MKV") || received_file.endsWith(".mpg") || received_file.endsWith(".MPG") || received_file.endsWith(".flv") || received_file.endsWith(".FLV") || received_file.endsWith(".mov") || received_file.endsWith(".MOV")){
359
video << received_file;
361
else if(received_file.endsWith(".png") || received_file.endsWith(".gif") || received_file.endsWith(".bmp") || received_file.endsWith(".jpg") || received_file.endsWith(".jpeg") || received_file.endsWith(".svg") || received_file.endsWith(".PNG") || received_file.endsWith(".GIF") || received_file.endsWith(".BMP") || received_file.endsWith(".JPG") || received_file.endsWith(".JPEG") || received_file.endsWith(".SVG")){
362
image << received_file;
364
else if(QDir(received_file).exists()){
365
//a folder has been dropped, process it!
366
process_dir(received_file);
369
int audio_count=audio.count();
370
int video_count=video.count();
371
int image_count=image.count();
373
int old_r_count=ui->tableWidget->rowCount();
374
ui->tableWidget->setRowCount(ui->tableWidget->rowCount()+audio_count);
375
int new_r_count=ui->tableWidget->rowCount();
377
for(int i=old_r_count;i<new_r_count;i++){
378
QString file=audio.at(i-old_r_count);
380
QTableWidgetItem *qtitem = new QTableWidgetItem;
381
qtitem->setText(inf.completeBaseName()+"."+inf.suffix());
382
qtitem->setToolTip(file);
383
ui->tableWidget->setItem(i,0,qtitem);
384
QTableWidgetItem *qtsize = new QTableWidgetItem;
385
float size=(float)inf.size()/1048576;
386
qtsize->setText(QString::number(size, 'f', 2)+" MB");
387
ui->tableWidget->setItem(i,1,qtsize);
388
QTableWidgetItem *qtwait = new QTableWidgetItem;
389
qtwait->setText("Waiting");
390
ui->tableWidget->setItem(i,2,qtwait);
392
if(ui->outputFormatComboBox->isEnabled())
393
ui->startBtn->setEnabled(true);
394
else if(unity_progressbar)
395
update_unity_count_value(2);
398
int old_r_count=ui->tableWidget_2->rowCount();
399
ui->tableWidget_2->setRowCount(ui->tableWidget_2->rowCount()+video_count);
400
int new_r_count=ui->tableWidget_2->rowCount();
402
for(int i=old_r_count;i<new_r_count;i++){
403
QString file=video.at(i-old_r_count);
405
QTableWidgetItem *qtitem = new QTableWidgetItem;
406
qtitem->setText(inf.completeBaseName()+"."+inf.suffix());
407
qtitem->setToolTip(file);
408
ui->tableWidget_2->setItem(i,0,qtitem);
409
QTableWidgetItem *qtsize = new QTableWidgetItem;
410
float size=(float)inf.size()/1048576;
411
qtsize->setText(QString::number(size, 'f', 2)+" MB");
412
ui->tableWidget_2->setItem(i,1,qtsize);
413
QTableWidgetItem *qtwait = new QTableWidgetItem;
414
qtwait->setText("Waiting");
415
ui->tableWidget_2->setItem(i,2,qtwait);
417
if(ui->outputFormatComboBox_2->isEnabled())
418
ui->startBtn_2->setEnabled(true);
419
else if(unity_progressbar)
420
update_unity_count_value(2);
423
int old_r_count=ui->tableWidget_3->rowCount();
424
ui->tableWidget_3->setRowCount(ui->tableWidget_3->rowCount()+image_count);
425
int new_r_count=ui->tableWidget_3->rowCount();
427
for(int i=old_r_count;i<new_r_count;i++){
428
QString file=image.at(i-old_r_count);
430
QTableWidgetItem *qtitem = new QTableWidgetItem;
431
qtitem->setText(inf.completeBaseName()+"."+inf.suffix());
432
qtitem->setToolTip(file);
433
ui->tableWidget_3->setItem(i,0,qtitem);
434
QTableWidgetItem *qtsize = new QTableWidgetItem;
435
float size=(float)inf.size()/1048576;
436
qtsize->setText(QString::number(size, 'f', 3)+" MB");
437
ui->tableWidget_3->setItem(i,1,qtsize);
438
QTableWidgetItem *qtwait = new QTableWidgetItem;
439
qtwait->setText("Waiting");
440
ui->tableWidget_3->setItem(i,2,qtwait);
442
if(ui->outputFormatComboBox_3->isEnabled())
443
ui->startBtn_3->setEnabled(true);
444
else if(unity_progressbar)
445
update_unity_count_value(2);
449
void MainWindow::set_video_resize_value(int index_value){
453
video_resize_value="sqcif";
456
video_resize_value="qqvga";
459
video_resize_value="qcif";
462
video_resize_value="cga";
465
video_resize_value="qvga";
468
video_resize_value="cif";
471
video_resize_value="4cif";
474
video_resize_value="ega";
477
video_resize_value="vga";
480
video_resize_value="svga";
483
video_resize_value="hd480";
486
video_resize_value="wvga";
489
video_resize_value="xga";
492
video_resize_value="hd720";
495
video_resize_value="sxga";
498
video_resize_value="wxga";
501
video_resize_value="16cif";
504
video_resize_value="uxga";
507
video_resize_value="wsxga";
510
video_resize_value="hd1080";
513
video_resize_value="wuxga";
516
video_resize_value="qxga";
519
video_resize_value="woxga";
522
video_resize_value="qsxga";
525
video_resize_value="wqsxga";
528
video_resize_value="wquxga";
531
video_resize_value="hsxga";
534
video_resize_value="whsxga";
537
video_resize_value="whuxga";
542
void MainWindow::add_audio_files(){
544
ui->stackedWidget->setCurrentIndex(0);
545
ui->musicButton->setChecked(true);
549
void MainWindow::add_video_files(){
551
ui->stackedWidget->setCurrentIndex(1);
552
ui->videoButton->setChecked(true);
556
void MainWindow::add_image_files(){
558
ui->stackedWidget->setCurrentIndex(2);
559
ui->imageButton->setChecked(true);
563
void MainWindow::crop_output_folder(QString output_folder_location){
565
if(output_folder_location.count()>30){
566
QString print_to_btn=output_folder_location.left(12)+"..."+output_folder_location.right(13);
567
ui->output_folder->setText(print_to_btn);
570
ui->output_folder->setText(output_folder_location);
571
ui->output_folder->setToolTip(output_folder_location);
574
void MainWindow::audio_read_output(){
575
//read all possible output so as to calculate the percentages...
576
QByteArray newData_stdout=audio_converter->readAllStandardOutput();
577
QString stdout=QString::fromLocal8Bit(newData_stdout);
578
QByteArray newData_stderr=audio_converter->readAllStandardError();
579
QString stderr=QString::fromLocal8Bit(newData_stderr);
580
QString out=stdout+stderr;
581
current_file_errors+=out;
582
int format_index=ui->outputFormatComboBox->currentIndex();
583
if((format_index==5 || format_index==7) && m4r_or_a_time==false && out.contains("%)|")){
584
//M4R/M4A MUSIC FILES
585
faac_percent_found=true;
586
QRegExp regex("\\(.*%");//(" (.*%)|");
587
regex.setMinimal(true);
589
QString unformatted=regex.capturedTexts().at(0);
590
unformatted.replace("%","");
591
unformatted.replace("( ","");
592
int percentage=unformatted.toInt();
594
int simplified = 20+percentage/1.25;
595
globpro->setFormat(QString::number(simplified)+"%");
596
globpro->setValue(20+percentage/1.25);
597
ui->progressBar->setFormat(QString::number(simplified/(num_files-already_completed)+(current_file-1-already_completed)*(100/(num_files-already_completed)))+"%");
598
ui->progressBar->setValue(simplified/(num_files-already_completed)+(current_file-1-already_completed)*(100/(num_files-already_completed)));
603
//ALL OTHER MUSIC FILES
604
//duration has been checked
605
//Now process the output so as to get how much of the duration of
606
//the output file has been processed so as to print the percentage
607
if(out.contains("kB time=")){
608
QRegExp regex("time=.* ");
609
regex.setMinimal(true);
614
while ((pos = regex.indexIn(out, pos)) != -1)
616
list << regex.cap(0).remove(QChar(' '),Qt::CaseInsensitive);
617
pos += regex.matchedLength();
623
QString current=list.at(0);
624
current.replace("time=","");
625
float cur_time=current.toFloat();
627
if(format_index==5 || format_index==7)
628
percent=(cur_time*100/duration_secs)/5;
630
percent=cur_time*100/duration_secs;
632
globpro->setFormat(QString::number(percent)+"%");
633
globpro->setValue(percent);
634
if(format_index==5 || format_index==7){
635
ui->progressBar->setFormat(QString::number(percent/(num_files-already_completed)+(current_file-already_completed)*(100/(num_files-already_completed)))+"%");
636
ui->progressBar->setValue(percent/(num_files-already_completed)+(current_file-already_completed)*(100/(num_files-already_completed)));
638
ui->progressBar->setFormat(QString::number(percent/num_files+(current_file)*(100/num_files))+"%");
639
ui->progressBar->setValue(percent/num_files+(current_file)*(100/num_files));*/
643
ui->progressBar->setFormat(QString::number(percent/(num_files-already_completed)+(current_file-1-already_completed)*(100/(num_files-already_completed)))+"%");
644
ui->progressBar->setValue(percent/(num_files-already_completed)+(current_file-1-already_completed)*(100/(num_files-already_completed)));
646
ui->progressBar->setFormat(QString::number(percent/num_files+(current_file-1)*(100/num_files))+"%");
647
ui->progressBar->setValue(percent/num_files+(current_file-1)*(100/num_files));
654
//Change pages when one of the 5 buttons (Audio,video,Image..) are pressed
655
void MainWindow::on_musicButton_clicked()
657
ui->stackedWidget->setCurrentIndex(0);
660
void MainWindow::on_videoButton_clicked()
662
ui->stackedWidget->setCurrentIndex(1);
665
void MainWindow::on_imageButton_clicked()
667
ui->stackedWidget->setCurrentIndex(2);
670
void MainWindow::on_rom_deviceButton_clicked()
672
ui->stackedWidget->setCurrentIndex(3);
675
void MainWindow::on_advancedButton_clicked()
679
//mencoder has to be installed
680
int pr_index=cur_index;
681
if(QFile("/usr/bin/mencoder").exists()){
682
ui->stackedWidget->setCurrentIndex(4);
688
msgBox.setWindowTitle("Format Junkie");
689
msgBox.setInformativeText("This function (subtitle encoding) requires 'mencoder', while it isn't installed! Do you want to install mencoder now?");
690
msgBox.setText(tr("<b>Mencoder is not installed</b>"));
691
msgBox.addButton("No", QMessageBox::ActionRole);
692
Yes = msgBox.addButton("Yes", QMessageBox::ActionRole);
693
msgBox.setIconPixmap(QIcon::fromTheme("info").pixmap(QSize(60,60)));
695
if (msgBox.clickedButton() == Yes){
696
QMessageBox::information(this, "Mencoder Installation", "The software center will now launch. Once mencoder is installed, please try to use this function again!");
697
if(system("software-center apt://mencoder&"))
698
cerr << "Error while launching software-center! Please install mencoder manually using 'sudo apt-get install mencoder'\n";
699
//returning to the previous index, meanwhile...
702
ui->musicButton->setChecked(true);
705
ui->videoButton->setChecked(true);
708
ui->imageButton->setChecked(true);
711
ui->rom_deviceButton->setChecked(true);
714
ui->musicButton->setChecked(true);
720
//user chose not to install mencoder, return to the previous index...
723
ui->musicButton->setChecked(true);
726
ui->videoButton->setChecked(true);
729
ui->imageButton->setChecked(true);
732
ui->rom_deviceButton->setChecked(true);
735
ui->musicButton->setChecked(true);
742
void MainWindow::on_addfolder_clicked()
744
if (!ui->addfolder->isEnabled())
751
if(QDir(QDir::homePath()+"/Music").exists())
752
qpath= QFileDialog::getExistingDirectory(this, "Choose Folder", QDir::homePath()+"/Music");
754
qpath= QFileDialog::getExistingDirectory(this, "Choose Folder", QDir::homePath());
757
//getting all the subfolders of the folder specified...
758
QStringList all_folders = list_folders(qpath);
759
int all_folders_count=all_folders.count();
760
for(int i=0;i<all_folders_count;i++){
761
//adding the files of all subfolders...
762
add_files(all_folders.at(i), cur_index);
765
if (ui->tableWidget->rowCount())
766
ui->startBtn->setEnabled(true);
767
num_files=ui->tableWidget->rowCount();
768
if(!ui->outputFormatComboBox->isEnabled())
769
update_unity_count_value(1);
771
else if(cur_index==1){
776
if(QDir(QDir::homePath()+"/Videos").exists())
777
qpath= QFileDialog::getExistingDirectory(this, "Choose Folder", QDir::homePath()+"/Videos");
779
qpath= QFileDialog::getExistingDirectory(this, "Choose Folder", QDir::homePath());
782
//getting all the subfolders of the folder specified...
783
QStringList all_folders = list_folders(qpath);
784
int all_folders_count=all_folders.count();
785
for(int i=0;i<all_folders_count;i++){
786
//adding the files of all subfolders...
787
add_files(all_folders.at(i), cur_index);
790
if (ui->tableWidget_2->rowCount())
791
ui->startBtn_2->setEnabled(true);
792
num_files=ui->tableWidget_2->rowCount();
793
if(!ui->outputFormatComboBox_2->isEnabled())
794
update_unity_count_value(1);
796
else if(cur_index==2){
801
if(QDir(QDir::homePath()+"/Pictures").exists())
802
qpath= QFileDialog::getExistingDirectory(this, "Choose Folder", QDir::homePath()+"/Pictures");
804
qpath= QFileDialog::getExistingDirectory(this, "Choose Folder", QDir::homePath());
807
//getting all the subfolders of the folder specified...
808
QStringList all_folders = list_folders(qpath);
809
int all_folders_count=all_folders.count();
810
for(int i=0;i<all_folders_count;i++){
811
//adding the files of all subfolders...
812
add_files(all_folders.at(i), cur_index);
815
if (ui->tableWidget_3->rowCount())
816
ui->startBtn_3->setEnabled(true);
817
num_files=ui->tableWidget_3->rowCount();
818
if(!ui->outputFormatComboBox_3->isEnabled())
819
update_unity_count_value(1);
821
else if(cur_index==3){
822
/* ---ISO IMAGES AND STUFF--- */
824
if(QDir(QDir::homePath()+"/Documents").exists())
825
qpath= QFileDialog::getExistingDirectory(this, "Choose Folder", QDir::homePath()+"/Documents");
827
qpath= QFileDialog::getExistingDirectory(this, "Choose Folder", QDir::homePath());
830
//getting all the subfolders of the folder specified...
831
int old_r_count=ui->tableWidget_6->rowCount();
832
ui->tableWidget_6->setRowCount(old_r_count+1);
835
QTableWidgetItem *qtitem = new QTableWidgetItem;
836
qtitem->setText(dir.dirName());
837
qtitem->setToolTip(qpath);
838
ui->tableWidget_6->setItem(old_r_count,0,qtitem);
839
QTableWidgetItem *qtsize = new QTableWidgetItem;
840
qtsize->setText(QString::number(folder_size(qpath), 'f', 1)+" MB");
841
ui->tableWidget_6->setItem(old_r_count,1,qtsize);
842
ui->startBtn_8->setEnabled(true);
847
void MainWindow::on_addBtn_clicked()
849
if(!ui->addBtn->isEnabled())
856
if(QDir(QDir::homePath()+"/Music").exists())
857
path = QFileDialog::getOpenFileNames(this, "Choose Audio Files", QDir::homePath()+"/Music", "*.mp3 *.wav *.ogg *.flac *.wma *.aac");
859
path = QFileDialog::getOpenFileNames(this, "Choose Audio Files", QDir::homePath(), "*.mp3 *.wav *.ogg *.flac *.wma *.aac");
863
int path_count = path.count();
864
int old_r_count=ui->tableWidget->rowCount();
865
ui->tableWidget->setRowCount(ui->tableWidget->rowCount()+path_count);
867
for(int count=0; count < path_count; count++){
868
QString file=path[count];
870
QTableWidgetItem *qtitem = new QTableWidgetItem;
871
qtitem->setText(inf.completeBaseName()+"."+inf.suffix());
872
qtitem->setToolTip(file);
873
ui->tableWidget->setItem(old_r_count+count,0,qtitem);
874
QTableWidgetItem *qtsize = new QTableWidgetItem;
875
float size=(float)inf.size()/1048576;
876
qtsize->setText(QString::number(size, 'f', 2)+" MB");
877
ui->tableWidget->setItem(old_r_count+count,1,qtsize);
878
QTableWidgetItem *qtwait = new QTableWidgetItem;
879
qtwait->setText("Waiting");
880
ui->tableWidget->setItem(old_r_count+count,2,qtwait);
882
if (ui->tableWidget->rowCount())
883
ui->startBtn->setEnabled(true);
884
num_files=ui->tableWidget->rowCount();
885
if(!ui->outputFormatComboBox->isEnabled())
886
update_unity_count_value(0);
888
else if(cur_index==1){
892
if(QDir(QDir::homePath()+"/Videos").exists())
893
path = QFileDialog::getOpenFileNames(this, "Choose Video Files", QDir::homePath()+"/Videos", "*.avi *.ogv *.vob *.mp4 *.3gp *.wmv *.mkv *.mpg *.mov *.flv");
895
path = QFileDialog::getOpenFileNames(this, "Choose Video Files", QDir::homePath(), "*.avi *.ogv *.vob *.mp4 *.3gp *.wmv *.mkv *.mpg *.mov *.flv");
899
int path_count = path.count();
900
int old_r_count=ui->tableWidget_2->rowCount();
901
ui->tableWidget_2->setRowCount(ui->tableWidget_2->rowCount()+path_count);
903
for(int count=0; count < path_count; count++){
904
QString file=path[count];
906
QTableWidgetItem *qtitem = new QTableWidgetItem;
907
qtitem->setText(inf.completeBaseName()+"."+inf.suffix());
908
qtitem->setToolTip(file);
909
ui->tableWidget_2->setItem(old_r_count+count,0,qtitem);
910
QTableWidgetItem *qtsize = new QTableWidgetItem;
911
float size=(float)inf.size()/1048576;
912
qtsize->setText(QString::number(size, 'f', 2)+" MB");
913
ui->tableWidget_2->setItem(old_r_count+count,1,qtsize);
914
QTableWidgetItem *qtwait = new QTableWidgetItem;
915
qtwait->setText("Waiting");
916
ui->tableWidget_2->setItem(old_r_count+count,2,qtwait);
918
if (ui->tableWidget_2->rowCount())
919
ui->startBtn_2->setEnabled(true);
920
num_files=ui->tableWidget_2->rowCount();
921
if(!ui->outputFormatComboBox_2->isEnabled())
922
update_unity_count_value(0);
924
else if(cur_index==2){
928
if(QDir(QDir::homePath()+"/Pictures").exists())
929
path = QFileDialog::getOpenFileNames(this, "Choose Image Files", QDir::homePath()+"/Pictures", "*.png *.jpg *.jpeg *.gif *.bmp *.svg");
931
path = QFileDialog::getOpenFileNames(this, "Choose Image Files", QDir::homePath(), "*.png *.jpg *.jpeg *.gif *.bmp *.svg");
935
int path_count = path.count();
936
int old_r_count=ui->tableWidget_3->rowCount();
937
ui->tableWidget_3->setRowCount(ui->tableWidget_3->rowCount()+path_count);
939
for(int count=0; count < path_count; count++){
940
QString file=path[count];
942
QTableWidgetItem *qtitem = new QTableWidgetItem;
943
qtitem->setText(inf.completeBaseName()+"."+inf.suffix());
944
qtitem->setToolTip(file);
945
ui->tableWidget_3->setItem(old_r_count+count,0,qtitem);
946
QTableWidgetItem *qtsize = new QTableWidgetItem;
947
float size=(float)inf.size()/1048576;
948
qtsize->setText(QString::number(size, 'f', 3)+" MB");
949
ui->tableWidget_3->setItem(old_r_count+count,1,qtsize);
950
QTableWidgetItem *qtwait = new QTableWidgetItem;
951
qtwait->setText("Waiting");
952
ui->tableWidget_3->setItem(old_r_count+count,2,qtwait);
954
if (ui->tableWidget_3->rowCount())
955
ui->startBtn_3->setEnabled(true);
956
num_files=ui->tableWidget_3->rowCount();
957
if(unity_count && !ui->outputFormatComboBox_3->isEnabled())
958
update_unity_count_value(0);
960
else if(cur_index==3){
962
/* ---CSO/ISO AND STUFF--- */
964
path = QFileDialog::getOpenFileNames(this, "Choose Files", QDir::homePath());
967
int path_count = path.count();
968
int old_r_count=ui->tableWidget_6->rowCount();
969
ui->tableWidget_6->setRowCount(ui->tableWidget_6->rowCount()+path_count);
971
for(int count=0; count < path_count; count++){
972
QString file=path[count];
974
QTableWidgetItem *qtitem = new QTableWidgetItem;
975
qtitem->setText(inf.completeBaseName()+"."+inf.suffix());
976
qtitem->setToolTip(file);
977
ui->tableWidget_6->setItem(old_r_count+count,0,qtitem);
978
QTableWidgetItem *qtsize = new QTableWidgetItem;
979
float size=(float)inf.size()/1048576;
980
qtsize->setText(QString::number(size, 'f', 2)+" MB");
981
ui->tableWidget_6->setItem(old_r_count+count,1,qtsize);
982
QTableWidgetItem *qtwait = new QTableWidgetItem;
983
qtwait->setText("Waiting");
984
ui->tableWidget_6->setItem(old_r_count+count,2,qtwait);
986
if (ui->tableWidget_6->rowCount())
987
ui->startBtn_8->setEnabled(true);
991
void MainWindow::remove_complete(){
992
int r_count=ui->tableWidget->rowCount();
993
for(int i=0;i<r_count;i++){
994
if(ui->tableWidget->item(0,2)->toolTip()=="Completed"){
995
ui->tableWidget->removeRow(0);
999
Only files in a row can be 'Completed'. The 'Completed'
1000
files are not allowed to move in any possible way, thus
1001
it is logical to break this for loop after an item is to
1002
be found not labeled as 'Completed'...
1010
void MainWindow::clear_convertion(){
1012
QPushButton *Continue;
1013
msgBox.setWindowTitle("Format Junkie");
1014
msgBox.setInformativeText("By clearing the list the current process will stop. Are you sure you want to do so?");
1015
msgBox.setText(tr("<b>Clear while process is running.</b>"));
1016
msgBox.addButton("Cancel", QMessageBox::ActionRole);
1017
Continue = msgBox.addButton("Continue", QMessageBox::ActionRole);
1018
msgBox.setIconPixmap(QIcon::fromTheme("info").pixmap(QSize(60,60)));
1020
if (msgBox.clickedButton() == Continue){
1022
//stop the current conversion progress
1027
else if(cur_index==1){
1029
on_stop_2_clicked();
1031
else if(cur_index==2){
1033
on_stop_3_clicked();
1036
on_clearBtn_clicked();
1040
void MainWindow::on_clearBtn_clicked()
1044
if(ui->outputFormatComboBox->isEnabled()){
1045
//the conversion process is off!
1046
ui->tableWidget->setRowCount(0);
1047
ui->startBtn->setEnabled(false);
1051
//the conversion is running! Display an informative message!
1055
else if(cur_index==1){
1057
if(ui->outputFormatComboBox_2->isEnabled()){
1058
//the conversion process is off!
1059
ui->tableWidget_2->setRowCount(0);
1060
ui->startBtn_2->setEnabled(false);
1064
//the conversion is running! Display an informative message!
1068
else if(cur_index==2){
1070
if(ui->outputFormatComboBox_3->isEnabled()){
1071
//the conversion process is off!
1072
ui->tableWidget_3->setRowCount(0);
1073
ui->startBtn_3->setEnabled(false);
1077
//the conversion is running! Display an informative message!
1081
else if(cur_index==3){
1083
ui->tableWidget_6->setRowCount(0);
1084
ui->startBtn_8->setEnabled(false);
1089
void MainWindow::on_removeBtn_clicked()
1093
if(!ui->tableWidget->rowCount())
1095
int cur_row=ui->tableWidget->currentRow();
1096
if(ui->tableWidget->cellWidget(cur_row,2) && ui->tableWidget->item(cur_row,2)->toolTip()!="Completed"){
1097
//this file is being processed
1100
if(!ui->outputFormatComboBox->isEnabled()){
1101
if(ui->tableWidget->currentRow()<current_file)
1105
if(unity_progressbar)
1106
update_unity_count_value(2);
1110
if (ui->tableWidget->rowCount()==1)
1112
ui->tableWidget->setRowCount(0);
1113
ui->startBtn->setEnabled(false);
1118
if(ui->tableWidget->item(cur_row-1,2)->toolTip()=="Completed"){
1119
if((cur_row+1)==ui->tableWidget->rowCount())
1120
ui->startBtn->setEnabled(false);
1123
ui->tableWidget->removeRow(cur_row);
1126
else if(cur_index==1){
1129
if(!ui->tableWidget_2->rowCount())
1131
int cur_row=ui->tableWidget_2->currentRow();
1132
if(ui->tableWidget_2->cellWidget(cur_row,2) && ui->tableWidget_2->item(cur_row,2)->toolTip()!="Completed"){
1133
//this file is being processed
1136
if(!ui->outputFormatComboBox_2->isEnabled()){
1137
if(ui->tableWidget_2->currentRow()<current_file)
1142
update_unity_count_value(2);
1146
if (ui->tableWidget_2->rowCount()==1)
1148
ui->tableWidget_2->setRowCount(0);
1149
ui->startBtn_2->setEnabled(false);
1152
ui->tableWidget_2->removeRow(cur_row);
1154
else if(cur_index==2){
1157
if(!ui->tableWidget_3->rowCount())
1159
int cur_row=ui->tableWidget_3->currentRow();
1160
if(ui->tableWidget_3->cellWidget(cur_row,2) && ui->tableWidget_3->item(cur_row,2)->toolTip()!="Completed"){
1161
//this file is being processed
1164
if(!ui->outputFormatComboBox_3->isEnabled()){
1165
if(ui->tableWidget_3->currentRow()<current_file)
1170
update_unity_count_value(2);
1173
ui->progressBar_3->setValue((current_file-1)*100/num_files);
1174
ui->progressBar_3->setFormat(QString::number(ui->progressBar_3->value())+"%");
1176
if (ui->tableWidget_3->rowCount()==1)
1178
ui->tableWidget_3->setRowCount(0);
1179
ui->startBtn_3->setEnabled(false);
1184
if(ui->tableWidget_3->item(cur_row-1,2)->toolTip()=="Completed"){
1185
if((cur_row+1)==ui->tableWidget_3->rowCount())
1186
ui->startBtn_3->setEnabled(false);
1189
ui->tableWidget_3->removeRow(cur_row);
1192
else if(cur_index==3){
1193
if(!ui->tableWidget_6->rowCount())
1195
int cur_row=ui->tableWidget_6->currentRow();
1196
if (ui->tableWidget_6->rowCount()==1)
1198
ui->tableWidget_6->setRowCount(0);
1199
ui->startBtn_8->setEnabled(false);
1203
ui->tableWidget_6->removeRow(cur_row);
1208
void MainWindow::on_moveupButton_clicked()
1214
if(ui->tableWidget->rowCount()>1 && ui->tableWidget->selectionModel()->hasSelection() && ui->tableWidget->currentRow()!=0){
1215
if(ui->tableWidget->item(ui->tableWidget->currentRow(),2)->text()!="Waiting")
1217
if(ui->tableWidget->item(ui->tableWidget->currentRow()-1,2)->text()!="Waiting")
1219
if(ui->tableWidget->cellWidget(ui->tableWidget->currentRow(),2))
1221
if(ui->tableWidget->cellWidget(ui->tableWidget->currentRow()-1,2))
1224
QStringList item_up;
1225
item_up << ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row()-1,0)->text();
1226
item_up << ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row()-1,1)->text();
1227
item_up << ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row()-1,2)->text();
1228
item_up << ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row()-1,2)->toolTip();
1229
item_up << ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row()-1,0)->toolTip();
1230
ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row()-1,0)->setText(ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row(),0)->text());
1231
ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row()-1,1)->setText(ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row(),1)->text());
1232
ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row()-1,2)->setText(ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row(),2)->text());
1233
ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row()-1,2)->setToolTip(ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row(),2)->toolTip());
1234
ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row()-1,0)->setToolTip(ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row(),0)->toolTip());
1235
ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row(),0)->setText(item_up.at(0));
1236
ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row(),1)->setText(item_up.at(1));
1237
ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row(),2)->setText(item_up.at(2));
1238
ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row(),2)->setToolTip(item_up.at(3));
1239
ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row(),0)->setToolTip(item_up.at(4));
1240
ui->tableWidget->selectRow(ui->tableWidget->selectedItems().at(0)->row()-1);
1243
else if(cur_index==1){
1247
if(ui->tableWidget_2->rowCount()>1 && ui->tableWidget_2->selectionModel()->hasSelection() && ui->tableWidget_2->currentRow()!=0){
1248
if(ui->tableWidget_2->item(ui->tableWidget_2->currentRow(),2)->text()!="Waiting")
1250
if(ui->tableWidget_2->item(ui->tableWidget_2->currentRow()-1,2)->text()!="Waiting")
1252
if(ui->tableWidget_2->cellWidget(ui->tableWidget_2->currentRow(),2))
1254
if(ui->tableWidget_2->cellWidget(ui->tableWidget_2->currentRow()-1,2))
1257
QStringList item_up;
1258
item_up << ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row()-1,0)->text();
1259
item_up << ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row()-1,1)->text();
1260
item_up << ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row()-1,2)->text();
1261
item_up << ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row()-1,2)->toolTip();
1262
item_up << ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row()-1,0)->toolTip();
1263
ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row()-1,0)->setText(ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row(),0)->text());
1264
ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row()-1,1)->setText(ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row(),1)->text());
1265
ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row()-1,2)->setText(ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row(),2)->text());
1266
ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row()-1,2)->setToolTip(ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row(),2)->toolTip());
1267
ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row()-1,0)->setToolTip(ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row(),0)->toolTip());
1268
ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row(),0)->setText(item_up.at(0));
1269
ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row(),1)->setText(item_up.at(1));
1270
ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row(),2)->setText(item_up.at(2));
1271
ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row(),2)->setToolTip(item_up.at(3));
1272
ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row(),0)->setToolTip(item_up.at(4));
1273
ui->tableWidget_2->selectRow(ui->tableWidget_2->selectedItems().at(0)->row()-1);
1276
else if(cur_index==2){
1280
if(ui->tableWidget_3->rowCount()>1 && ui->tableWidget_3->selectionModel()->hasSelection() && ui->tableWidget_3->currentRow()!=0){
1281
if(ui->tableWidget_3->item(ui->tableWidget_3->currentRow(),2)->text()!="Waiting")
1283
if(ui->tableWidget_3->item(ui->tableWidget_3->currentRow()-1,2)->text()!="Waiting")
1285
if(ui->tableWidget_3->cellWidget(ui->tableWidget_3->currentRow(),2))
1287
if(ui->tableWidget_3->cellWidget(ui->tableWidget_3->currentRow()-1,2))
1290
QStringList item_up;
1291
item_up << ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row()-1,0)->text();
1292
item_up << ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row()-1,1)->text();
1293
item_up << ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row()-1,2)->text();
1294
item_up << ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row()-1,2)->toolTip();
1295
item_up << ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row()-1,0)->toolTip();
1296
ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row()-1,0)->setText(ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row(),0)->text());
1297
ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row()-1,1)->setText(ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row(),1)->text());
1298
ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row()-1,2)->setText(ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row(),2)->text());
1299
ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row()-1,2)->setToolTip(ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row(),2)->toolTip());
1300
ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row()-1,0)->setToolTip(ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row(),0)->toolTip());
1301
ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row(),0)->setText(item_up.at(0));
1302
ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row(),1)->setText(item_up.at(1));
1303
ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row(),2)->setText(item_up.at(2));
1304
ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row(),2)->setToolTip(item_up.at(3));
1305
ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row(),0)->setToolTip(item_up.at(4));
1306
ui->tableWidget_3->selectRow(ui->tableWidget_3->selectedItems().at(0)->row()-1);
1309
else if(cur_index==3){
1310
if(ui->tableWidget_6->rowCount()>1 && ui->tableWidget_6->selectionModel()->hasSelection() && ui->tableWidget_6->currentRow()!=0){
1311
QStringList item_up;
1312
item_up << ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row()-1,0)->text();
1313
item_up << ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row()-1,1)->text();
1314
item_up << ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row()-1,0)->toolTip();
1315
ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row()-1,0)->setText(ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row(),0)->text());
1316
ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row()-1,1)->setText(ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row(),1)->text());
1317
ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row()-1,0)->setToolTip(ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row(),0)->toolTip());
1318
ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row(),0)->setText(item_up.at(0));
1319
ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row(),1)->setText(item_up.at(1));
1320
ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row(),0)->setToolTip(item_up.at(2));
1321
ui->tableWidget_6->selectRow(ui->tableWidget_6->selectedItems().at(0)->row()-1);
1326
void MainWindow::on_movedownButton_clicked()
1332
if(ui->tableWidget->rowCount()>1 && ui->tableWidget->selectionModel()->hasSelection() && ui->tableWidget->currentRow()!=ui->tableWidget->rowCount()-1){
1333
if(ui->tableWidget->item(ui->tableWidget->currentRow(),2)->text()!="Waiting")
1335
if(ui->tableWidget->item(ui->tableWidget->currentRow()+1,2)->text()!="Waiting")
1337
if(ui->tableWidget->cellWidget(ui->tableWidget->currentRow(),2))
1339
if(ui->tableWidget->cellWidget(ui->tableWidget->currentRow()+1,2))
1341
QStringList item_down;
1342
item_down << ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row()+1,0)->text();
1343
item_down << ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row()+1,1)->text();
1344
item_down << ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row()+1,2)->text();
1345
item_down << ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row()+1,2)->toolTip();
1346
item_down << ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row()+1,0)->toolTip();
1347
ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row()+1,0)->setText(ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row(),0)->text());
1348
ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row()+1,1)->setText(ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row(),1)->text());
1349
ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row()+1,2)->setText(ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row(),2)->text());
1350
ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row()+1,2)->setToolTip(ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row(),2)->toolTip());
1351
ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row()+1,0)->setToolTip(ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row(),0)->toolTip());
1352
ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row(),0)->setText(item_down.at(0));
1353
ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row(),1)->setText(item_down.at(1));
1354
ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row(),2)->setText(item_down.at(2));
1355
ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row(),2)->setToolTip(item_down.at(3));
1356
ui->tableWidget->item(ui->tableWidget->selectedItems().at(0)->row(),0)->setToolTip(item_down.at(4));
1357
ui->tableWidget->selectRow(ui->tableWidget->selectedItems().at(0)->row()+1);
1360
else if(cur_index==1){
1364
if(ui->tableWidget_2->rowCount()>1 && ui->tableWidget_2->selectionModel()->hasSelection() && ui->tableWidget_2->currentRow()!=ui->tableWidget_2->rowCount()-1){
1365
if(ui->tableWidget_2->item(ui->tableWidget_2->currentRow(),2)->text()!="Waiting")
1367
if(ui->tableWidget_2->item(ui->tableWidget_2->currentRow()+1,2)->text()!="Waiting")
1369
if(ui->tableWidget_2->cellWidget(ui->tableWidget_2->currentRow(),2))
1371
if(ui->tableWidget_2->cellWidget(ui->tableWidget_2->currentRow()+1,2))
1373
QStringList item_down;
1374
item_down << ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row()+1,0)->text();
1375
item_down << ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row()+1,1)->text();
1376
item_down << ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row()+1,2)->text();
1377
item_down << ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row()+1,2)->toolTip();
1378
item_down << ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row()+1,0)->toolTip();
1379
ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row()+1,0)->setText(ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row(),0)->text());
1380
ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row()+1,1)->setText(ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row(),1)->text());
1381
ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row()+1,2)->setText(ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row(),2)->text());
1382
ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row()+1,2)->setToolTip(ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row(),2)->toolTip());
1383
ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row()+1,0)->setToolTip(ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row(),0)->toolTip());
1384
ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row(),0)->setText(item_down.at(0));
1385
ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row(),1)->setText(item_down.at(1));
1386
ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row(),2)->setText(item_down.at(2));
1387
ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row(),2)->setToolTip(item_down.at(3));
1388
ui->tableWidget_2->item(ui->tableWidget_2->selectedItems().at(0)->row(),0)->setToolTip(item_down.at(4));
1389
ui->tableWidget_2->selectRow(ui->tableWidget_2->selectedItems().at(0)->row()+1);
1392
else if(cur_index==2){
1396
if(ui->tableWidget_3->rowCount()>1 && ui->tableWidget_3->selectionModel()->hasSelection() && ui->tableWidget_3->currentRow()!=ui->tableWidget_3->rowCount()-1){
1397
if(ui->tableWidget_3->item(ui->tableWidget_3->currentRow(),2)->text()!="Waiting")
1399
if(ui->tableWidget_3->item(ui->tableWidget_3->currentRow()+1,2)->text()!="Waiting")
1401
if(ui->tableWidget_3->cellWidget(ui->tableWidget_3->currentRow(),2))
1403
if(ui->tableWidget_3->cellWidget(ui->tableWidget_3->currentRow()+1,2))
1405
QStringList item_down;
1406
item_down << ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row()+1,0)->text();
1407
item_down << ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row()+1,1)->text();
1408
item_down << ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row()+1,2)->text();
1409
item_down << ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row()+1,2)->toolTip();
1410
item_down << ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row()+1,0)->toolTip();
1411
ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row()+1,0)->setText(ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row(),0)->text());
1412
ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row()+1,1)->setText(ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row(),1)->text());
1413
ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row()+1,2)->setText(ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row(),2)->text());
1414
ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row()+1,2)->setToolTip(ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row(),2)->toolTip());
1415
ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row()+1,0)->setToolTip(ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row(),0)->toolTip());
1416
ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row(),0)->setText(item_down.at(0));
1417
ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row(),1)->setText(item_down.at(1));
1418
ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row(),2)->setText(item_down.at(2));
1419
ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row(),2)->setToolTip(item_down.at(3));
1420
ui->tableWidget_3->item(ui->tableWidget_3->selectedItems().at(0)->row(),0)->setToolTip(item_down.at(4));
1421
ui->tableWidget_3->selectRow(ui->tableWidget_3->selectedItems().at(0)->row()+1);
1425
if(ui->tableWidget_6->rowCount()>1 && ui->tableWidget_6->selectionModel()->hasSelection() && ui->tableWidget_6->currentRow()!=ui->tableWidget_6->rowCount()-1){
1426
QStringList item_down;
1427
item_down << ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row()+1,0)->text();
1428
item_down << ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row()+1,1)->text();
1429
item_down << ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row()+1,0)->toolTip();
1430
ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row()+1,0)->setText(ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row(),0)->text());
1431
ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row()+1,1)->setText(ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row(),1)->text());
1432
ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row()+1,0)->setToolTip(ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row(),0)->toolTip());
1433
ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row(),0)->setText(item_down.at(0));
1434
ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row(),1)->setText(item_down.at(1));
1435
ui->tableWidget_6->item(ui->tableWidget_6->selectedItems().at(0)->row(),0)->setToolTip(item_down.at(2));
1436
ui->tableWidget_6->selectRow(ui->tableWidget_6->selectedItems().at(0)->row()+1);
1441
void MainWindow::update_unity_count_value(int after){
1443
'after' handles the remove button.
1444
If after is 2, then the user has pressed the remove button
1445
(so, after it has been done current_file++), but this function
1446
is also called from audio_conversion(int) function, before the current_file++
1449
unity_launcher_entry_set_count (unity_progress, num_files-current_file-1);
1451
unity_launcher_entry_set_count (unity_progress, num_files-current_file);
1453
unity_launcher_entry_set_count (unity_progress,unity_launcher_entry_get_count(unity_progress)-1);
1456
void MainWindow::on_startBtn_clicked()
1458
if(!ui->tableWidget->rowCount())
1460
if(!QDir(ui->output_folder->toolTip()).exists()){
1462
if(!dir.mkpath(ui->output_folder->toolTip())){
1463
QMessageBox::warning(this, tr("Error"), tr("The output folder doesn't exist! Please specify an existent directory!"));
1467
audio_stop_pressed=false;
1468
num_files=ui->tableWidget->rowCount();
1470
unity_launcher_entry_set_count (unity_progress, num_files);
1471
ui->progressBar->setFormat("0%");
1472
ui->progressBar->setValue(0);
1474
progressbar_animation(0,0); //<< doesn't this look like an owl?
1476
already_completed=0;
1477
for(int i=0;i<num_files;i++){
1478
if(ui->tableWidget->item(i,2)->toolTip()!="Completed"){
1480
already_completed=i;
1484
if(current_file==0){
1485
//that's a completely new conversion
1488
ui->show_errors->hide();
1490
ui->outputFormatComboBox->setEnabled(false);
1491
globpro_string="100%";
1492
if(unity_progressbar)
1493
unity_launcher_entry_set_progress_visible(unity_progress, true);
1495
unity_launcher_entry_set_count_visible(unity_progress, true);
1496
audio_conversion(0);
1499
void MainWindow::actions_after_convert(){
1500
int conv2_index=ui->after_convertion2->currentIndex();
1503
else if(conv2_index!=0){
1510
QString after_convert_cmd="";
1511
switch(conv2_index){
1513
after_convert_cmd="dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop > /dev/null 2> /dev/null&";
1516
after_convert_cmd="dbus-send --system --print-reply --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend > /dev/null 2> /dev/null&";
1519
after_convert_cmd="dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart > /dev/null 2> /dev/null&";
1522
after_convert_cmd="gnome-screensaver-command --lock > /dev/null 2> /dev/null&";
1527
if(system(after_convert_cmd.toLocal8Bit().data()))
1528
cerr << QString("Error running command '"+after_convert_cmd+"'\n").toLocal8Bit().data();
1532
void MainWindow::audio_conversion(int return_code){
1534
This function is called like audio_conversion(0) the 1st time
1535
so as to begin the conversion. Then, it is called again
1536
when the 1st conversion has finished and launches the
1537
2nd conversion and so on, untill no files are left
1541
//current_file <-> 0 1 2
1542
//num_files <-> 1 2 3
1543
int format_index=ui->outputFormatComboBox->currentIndex();
1544
QString format_text=ui->outputFormatComboBox->currentText();
1545
//checking if the conversion is about m4(a/r) files or other
1546
if(format_index==5 || format_index==7){
1547
/*^^^^^^^^^^^^^^^^^^^^^^^^^^^M4A OR M4R FILES^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1548
if(audio_stop_pressed){
1549
if(ui->tableWidget->item(current_file-1,2)->toolTip()!="Completed")
1550
ui->tableWidget->removeCellWidget(current_file-1,2);
1552
ui->tableWidget->removeCellWidget(current_file,2);
1553
globpro_hasbeendeleted=true;
1555
inf.setFile(output_file);
1556
QString tmp_file_rm="/tmp/"+inf.completeBaseName()+".wav";
1557
QString output_file_rm=ui->output_folder->toolTip()+"/"+inf.completeBaseName()+"."+format_text;
1558
QFile::remove(tmp_file_rm);
1559
QFile::remove(output_file_rm);
1560
m4r_or_a_time=false;
1565
The conversion of the previous file wasn't successful!
1566
Print error and guide the user to see the error logs...
1568
if(all_errors.isEmpty())
1569
all_errors+="'<b>"+input_file+"</b>'<br>";
1571
all_errors+="\n'<b>"+input_file+"</b>'<br>";
1572
current_file_errors.replace("\n","<br>");
1574
//error while converting the input file to temp wav
1575
//current_file_errors=input_file+": File non-existent or bad filetype!<br>";
1576
proceed_to_faac_conversion=false;
1578
all_errors+="<font color=red>"+current_file_errors+"</font>";
1579
QTableWidgetItem *item_error1 = new QTableWidgetItem;
1580
item_error1->setText(ui->tableWidget->item(current_file,0)->text()+" - ERROR");
1581
item_error1->setToolTip(ui->tableWidget->item(current_file,0)->toolTip());
1582
item_error1->setBackgroundColor(Qt::red);
1583
item_error1->setTextColor(Qt::white);
1584
ui->tableWidget->setItem(current_file,0, item_error1);
1585
QTableWidgetItem *item_error2 = new QTableWidgetItem;
1586
item_error2->setText(ui->tableWidget->item(current_file,1)->text());
1587
item_error2->setToolTip(ui->tableWidget->item(current_file,1)->toolTip());
1588
item_error2->setBackgroundColor(Qt::red);
1589
item_error2->setTextColor(Qt::white);
1590
ui->tableWidget->setItem(current_file,1, item_error2);
1591
ui->show_errors->show();
1592
//take it like the percentage was found, so as to continue normally to the next file...
1593
m4r_or_a_previous_was_error=true;
1598
//IF NOT RETURN CODE
1600
//if it is to convert to m4r
1601
current_file_errors.clear();
1604
The conversion of the previous file was successful!
1605
Check if the original (source) file is to be deleted...
1607
if(delete_original){
1608
if(QFile(input_file).exists()){
1609
if(system(QString("rm -f \""+input_file+"\"").toLocal8Bit().data()))
1610
cerr << QString("Could not delete source file '"+input_file+"'\nDo I have the permissions to do so?\n").toLocal8Bit().data();
1614
if (current_file>num_files-1){
1616
!!!ALL FILES HAVE BEEN CONVERTED!!!
1617
Update the progressbars and do the actions
1618
that the user has chosen to do from bottom
1621
//just update the progressbar
1622
ui->progressBar->setFormat("100%");
1623
ui->progressBar->setValue(100);
1624
globpro->setFormat(globpro_string);
1625
globpro->setValue(100);
1626
QTableWidgetItem *item_progress = new QTableWidgetItem;
1627
item_progress->setToolTip("Completed");
1628
ui->tableWidget->setItem(current_file-1,2, item_progress);
1629
ui->startBtn->setEnabled(false);
1630
ui->startBtn->raise();
1631
progressbar_animation(1,0);
1632
//removing the last tmp file...
1633
QFile::remove(output_file_rm);
1634
ui->outputFormatComboBox->setEnabled(true);
1635
if(unity_progressbar)
1636
unity_launcher_entry_set_progress_visible(unity_progress, false);
1638
unity_launcher_entry_set_count_visible(unity_progress, false);
1639
if(desktop_notifications)
1640
show_desktop_notification(0);
1642
actions_after_convert();
1645
if(ui->tableWidget->item(current_file,2)->toolTip()=="Completed"){
1647
The file's conversion has been completed, proceed to the next file...
1648
The program goes through here if the user add more files after the
1649
previous conversion has finished and choose to start converting...
1652
audio_conversion(0);
1655
if(!m4r_or_a_time || globpro_string=="Already Exists"){
1657
The program always goes through there, unless
1658
the user has chosen to convert the file to m4r
1659
and this is the 2nd conversion that has to be
1660
done (audio files to m4r are being converted
1661
to wav first and then to m4r with faac)
1662
So, if(m4r_or_a_time) then the conversion is 50%,
1663
because a 2nd conversion has to be done...
1665
/*if(globpro_hasbeendeleted){
1666
globpro = new QProgressBar(this);
1667
globpro_hasbeendeleted=false;
1669
if(current_file!=0){
1670
if(globpro_hasbeendeleted){
1671
globpro = new QProgressBar(this);
1672
globpro_hasbeendeleted=false;
1674
if(globpro->format()!="Already Exists" && ui->tableWidget->item(current_file-1,2)->toolTip()!="Completed"){
1675
QProgressBar *qtpro=new QProgressBar(this);
1676
ui->tableWidget->setCellWidget(current_file-1, 2, qtpro);
1677
QTableWidgetItem *item_progress = new QTableWidgetItem;
1678
item_progress->setToolTip("Completed");
1679
ui->tableWidget->setItem(current_file-1,2, item_progress);
1680
qtpro->setFormat(globpro_string);
1681
globpro_string="100%";
1682
qtpro->setValue(100);
1685
if(!ui->tableWidget->cellWidget(current_file,2)){
1686
QProgressBar *qtpro=new QProgressBar(this);
1687
ui->tableWidget->setCellWidget(current_file, 2, qtpro);
1689
globpro = new QProgressBar(this);
1693
//Action starts here...
1694
input_file=ui->tableWidget->item(current_file,0)->toolTip();
1696
info.setFile(input_file);
1698
//Convert the input file to a temp wav file
1699
if(current_file!=0){
1700
//a tmp file has been created from the previous conversion. Delete this file...
1701
QFile::remove(output_file_rm);
1704
if(m4r_or_a_previous_was_error)
1705
faac_percent_found=true;
1706
if(!faac_percent_found && current_file!=0 && globpro_string!="Already Exists"){
1708
We couldn't find the percentage sent by
1709
faac, because the file was extremely small
1710
so, go instantly to 100%
1712
full_percent_instant=true;
1714
output_file=output_file_rm="/tmp/"+info.completeBaseName()+".wav";
1715
if(QFile(output_file).exists()){
1716
if(!QFile::remove(output_file))
1717
cerr << QString("Error removing temp file '"+output_file+"'\n").toLocal8Bit().data();
1719
command="avconv -i \""+input_file+"\" -aq "+QString::number(quality);
1721
command+=" -ab "+QString::number(audio_bitrate_value)+"k";//<- a custom bitrate has been selected!
1722
if(audio_samplerate)
1723
command+=" -ar "+QString::number(audio_samplerate_value);
1725
command+=" -ac "+QString::number(audio_channels_value);
1727
command+=" -vol "+QString::number(audio_volume_value);
1728
command+=" \""+output_file+"\"";
1731
if(!proceed_to_faac_conversion){
1732
proceed_to_faac_conversion=true;
1733
//next file PLEASE :D
1735
m4r_or_a_time=false;
1736
audio_conversion(0);
1739
m4r_or_a_time=false;
1740
faac_percent_found=false;
1741
output_file=ui->output_folder->toolTip()+"/"+info.completeBaseName()+"."+format_text;
1742
command="faac -b 192 -c 44100 \"/tmp/"+info.completeBaseName()+".wav\" --mpeg-vers 4 -o \""+output_file+"\"";
1745
Checking whether the output_file already exists. If it does, then
1746
overwrite it, if it checked so, or proceed to the next file, if not...
1748
//checking if the final file exists, not if the temp wav file exists...
1750
QString file_rm=ui->output_folder->toolTip()+"/"+info.completeBaseName()+"."+format_text;
1751
if(QFile(file_rm).exists()){
1752
if(overwrite_existing){
1753
if(!QFile::remove(file_rm)){
1754
cerr << QString("Couldn't remove the already existing file '"+output_file+"'\n").toLocal8Bit().data();
1756
globpro_string="Already Exists";
1757
faac_percent_found=true;
1758
m4r_or_a_time=false;
1759
audio_conversion(0);
1766
globpro_string="Already Exists";
1767
faac_percent_found=true;
1768
m4r_or_a_time=false;
1769
audio_conversion(0);
1774
//getting the duration of the input file...
1775
duration_secs=Global::duration(input_file);
1776
audio_converter->start(command);
1777
if(full_percent_instant){
1778
full_percent_instant=false;
1779
if(!m4r_or_a_previous_was_error){
1780
m4r_or_a_previous_was_error=false;
1781
globpro->setValue(100);
1782
globpro->setFormat(globpro_string);
1790
update_unity_count_value(0);
1796
/*^^^^^^^^^^^^^^^^^^^^^^^^^^^ALL OTHER AUDIO FILES^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1797
if(audio_stop_pressed){
1799
ui->tableWidget->removeCellWidget(current_file-1,2);
1801
ui->tableWidget->removeCellWidget(current_file,2);
1802
globpro_hasbeendeleted=true;
1803
if(!QFile::remove(output_file))
1804
cerr << QString("Error removing file '"+output_file+"'\n").toLocal8Bit().data();
1809
The conversion of the previous file wasn't successful!
1810
Print error and guide the user to see the error logs...
1812
if(all_errors.isEmpty())
1813
all_errors+="'<b>"+input_file+"</b>'<br>";
1815
all_errors+="\n'<b>"+input_file+"</b>'<br>";
1816
current_file_errors.replace("\n","<br>");
1817
all_errors+="<font color=red>"+current_file_errors+"</font><br>";
1818
int to_apply=current_file;
1821
QTableWidgetItem *item_error1 = new QTableWidgetItem;
1822
item_error1->setText(ui->tableWidget->item(to_apply,0)->text()+" - ERROR");
1823
item_error1->setToolTip(ui->tableWidget->item(to_apply,0)->toolTip());
1824
item_error1->setBackgroundColor(Qt::red);
1825
item_error1->setTextColor(Qt::white);
1826
ui->tableWidget->setItem(to_apply,0, item_error1);
1827
QTableWidgetItem *item_error2 = new QTableWidgetItem;
1828
item_error2->setText(ui->tableWidget->item(to_apply,1)->text());
1829
item_error2->setToolTip(ui->tableWidget->item(to_apply,1)->toolTip());
1830
item_error2->setBackgroundColor(Qt::red);
1831
item_error2->setTextColor(Qt::white);
1832
ui->tableWidget->setItem(to_apply,1, item_error2);
1833
ui->show_errors->show();
1834
current_file_errors.clear();
1839
//IF NOT RETURN CODE
1840
current_file_errors.clear();
1842
The conversion of the previous file was successful!
1843
Check if the original (source) file is to be deleted...
1845
if(delete_original){
1846
if(QFile(input_file).exists()){
1847
if(system(QString("rm -f \""+input_file+"\"").toLocal8Bit().data()))
1848
cerr << QString("Could not delete source file '"+input_file+"'\nDo I have the permissions to do so?\n").toLocal8Bit().data();
1852
if (current_file>num_files-1){
1854
!!!ALL FILES HAVE BEEN CONVERTED!!!
1855
Update the progressbars and do the actions
1856
that the user has chosen to do from bottom
1859
//all files have been converted!
1860
//just update the progressbar
1861
ui->progressBar->setFormat("100%");
1862
ui->progressBar->setValue(100);
1863
globpro->setFormat(globpro_string);
1864
globpro->setValue(100);
1865
QTableWidgetItem *item_progress = new QTableWidgetItem;
1866
item_progress->setToolTip("Completed");
1867
ui->tableWidget->setItem(current_file-1,2, item_progress);
1868
ui->startBtn->setEnabled(false);
1869
ui->startBtn->raise();
1870
progressbar_animation(1,0);
1871
ui->outputFormatComboBox->setEnabled(true);
1872
if(unity_progressbar)
1873
unity_launcher_entry_set_progress_visible(unity_progress, false);
1875
unity_launcher_entry_set_count_visible(unity_progress, false);
1876
if(desktop_notifications)
1877
show_desktop_notification(0);
1878
actions_after_convert();
1881
if(ui->tableWidget->item(current_file,2)->toolTip()=="Completed"){
1883
The file's conversion has been completed, proceed to the next file...
1884
The program goes through here if the user add more files after the
1885
previous conversion has finished and choose to start converting...
1888
audio_conversion(0);
1891
if(globpro_string=="Already Exists" || !m4r_or_a_time){
1893
The program always goes through there, unless
1894
the user has chosen to convert the file to m4r
1895
and this is the 2nd conversion that has to be
1896
done (audio files to m4r are being converted
1897
to wav first and then to m4r with faac)
1898
So, if(m4r_or_a_time) then the conversion is 50%,
1899
because a 2nd conversion has to be done...
1901
if(current_file!=0){
1902
if(globpro_hasbeendeleted){
1903
globpro = new QProgressBar(this);
1904
globpro_hasbeendeleted=false;
1906
if(globpro->format()!="Already Exists" && ui->tableWidget->item(current_file-1,2)->toolTip()!="Completed"){
1907
QProgressBar *qtpro=new QProgressBar(this);
1908
ui->tableWidget->setCellWidget(current_file-1, 2, qtpro);
1909
QTableWidgetItem *item_progress = new QTableWidgetItem;
1910
item_progress->setToolTip("Completed");
1911
ui->tableWidget->setItem(current_file-1,2, item_progress);
1912
qtpro->setFormat(globpro_string);
1913
qtpro->setValue(100);
1916
QProgressBar *qtpro=new QProgressBar(this);
1917
ui->tableWidget->setCellWidget(current_file, 2, qtpro);
1919
globpro = new QProgressBar(this);
1922
//Action starts here...
1923
input_file=ui->tableWidget->item(current_file,0)->toolTip();
1925
info.setFile(input_file);
1926
output_file=ui->output_folder->toolTip()+"/"+info.completeBaseName()+"."+format_text;
1927
command="avconv -i \""+input_file+"\" -aq "+QString::number(quality);
1928
if(format_text=="aac")
1929
command+=" -acodec aac -strict experimental";
1931
command+=" -ab "+QString::number(audio_bitrate_value)+"k";//<- a custom bitrate has been selected!
1932
if(audio_samplerate)
1933
command+=" -ar "+QString::number(audio_samplerate_value);
1935
command+=" -ac "+QString::number(audio_channels_value);
1937
command+=" -vol "+QString::number(audio_volume_value);
1938
command+=" \""+output_file+"\"";
1940
Checking whether the output_file already exists. If it does, then
1941
overwrite it, if it checked so, or proceed to the next file, if not...
1943
if(QFile(output_file).exists()){
1944
if(overwrite_existing){
1945
if(!QFile::remove(output_file)){
1946
cerr << QString("Couldn't remove the already existing file '"+output_file+"'\n").toLocal8Bit().data();
1948
globpro_string="Already Exists";
1949
audio_conversion(0);
1956
globpro_string="Already Exists";
1957
audio_conversion(0);
1961
//getting the duration of the input file...
1962
duration_secs=Global::duration(input_file);
1963
globpro_string="100%";
1964
audio_converter->start(command);
1965
if(full_percent_instant){
1966
full_percent_instant=false;
1967
globpro->setValue(100);
1968
globpro->setFormat(globpro_string);
1970
update_unity_count_value(0);
1977
void MainWindow::add_files(QString path, int type){
1978
//this function is for adding files from add-folder function or from drag-en-drop
1983
type 3 -> all of the above
1986
QDir dir_get_all_files;
1987
dir_get_all_files.setPath(path);
1988
dir_get_all_files.setFilter(QDir::Files);
1989
QStringList filters;
1991
filters << "*.mp3" << "*.MP3" << "*.wav" << "*.WAV" << "*.ogg" << "*.OGG" << "*.flac" << "*.FLAC" << "*.m4r" << "*.M4R" << "*.WMA" << "*.wma" << "*.AAC" << "*.aac";
1993
filters << "*.avi" << "*.AVI" << "*ogv" << "*OGV" << "*vob" << "*VOB" << "*.mp4" << "*.MP4" << "*3gp" << "*3GP" << "*wmv" << "*WMV" << "*.mkv" << "*.MKV" << "*mpg" << "*MPG" << "*mov" << "*MOV" << "*flv" << "*FLV";
1995
filters << "*.png" << "*.PNG" << "*.jpg" << "*.JPG" << "*.jpeg" << "*.JPEG" << "*.gif" << "*.GIF" << "*.bmp" << "*.BMP" << "*.svg" << "*.SVG";
1996
QStringList all_files=dir_get_all_files.entryList(filters);
1997
int all_files_count = all_files.count();
2001
old_r_count=ui->tableWidget->rowCount();
2002
ui->tableWidget->setRowCount(ui->tableWidget->rowCount()+all_files_count);
2005
old_r_count=ui->tableWidget_2->rowCount();
2006
ui->tableWidget_2->setRowCount(ui->tableWidget_2->rowCount()+all_files_count);
2009
old_r_count=ui->tableWidget_3->rowCount();
2010
ui->tableWidget_3->setRowCount(ui->tableWidget_3->rowCount()+all_files_count);
2017
for(int i=0; i<all_files_count; i++){
2018
temp=path+"/"+all_files.at(i);
2020
QTableWidgetItem *qtitem = new QTableWidgetItem;
2021
qtitem->setText(all_files.at(i));
2022
qtitem->setToolTip(temp);
2023
ui->tableWidget->setItem(old_r_count+i,0,qtitem);
2024
QTableWidgetItem *qtsize = new QTableWidgetItem;
2025
float size=(float)inf.size()/1048576;
2026
qtsize->setText(QString::number(size, 'f', 2)+" MB");
2027
ui->tableWidget->setItem(old_r_count+i,1,qtsize);
2028
QTableWidgetItem *qtwait = new QTableWidgetItem;
2029
qtwait->setText("Waiting");
2030
ui->tableWidget->setItem(old_r_count+i,2,qtwait);
2037
for(int i=0; i<all_files_count; i++){
2038
temp=path+"/"+all_files.at(i);
2040
QTableWidgetItem *qtitem = new QTableWidgetItem;
2041
qtitem->setText(all_files.at(i));
2042
qtitem->setToolTip(temp);
2043
ui->tableWidget_2->setItem(old_r_count+i,0,qtitem);
2044
QTableWidgetItem *qtsize = new QTableWidgetItem;
2045
float size=(float)inf.size()/1048576;
2046
qtsize->setText(QString::number(size, 'f', 2)+" MB");
2047
ui->tableWidget_2->setItem(old_r_count+i,1,qtsize);
2048
QTableWidgetItem *qtwait = new QTableWidgetItem;
2049
qtwait->setText("Waiting");
2050
ui->tableWidget_2->setItem(old_r_count+i,2,qtwait);
2057
for(int i=0; i<all_files_count; i++){
2058
temp=path+"/"+all_files.at(i);
2060
QTableWidgetItem *qtitem = new QTableWidgetItem;
2061
qtitem->setText(all_files.at(i));
2062
qtitem->setToolTip(temp);
2063
ui->tableWidget_3->setItem(old_r_count+i,0,qtitem);
2064
QTableWidgetItem *qtsize = new QTableWidgetItem;
2065
float size=(float)inf.size()/1048576;
2066
qtsize->setText(QString::number(size, 'f', 3)+" MB");
2067
ui->tableWidget_3->setItem(old_r_count+i,1,qtsize);
2068
QTableWidgetItem *qtwait = new QTableWidgetItem;
2069
qtwait->setText("Waiting");
2070
ui->tableWidget_3->setItem(old_r_count+i,2,qtwait);
2077
QDir dir_get_all_files;
2078
dir_get_all_files.setPath(path);
2079
dir_get_all_files.setFilter(QDir::Files);
2080
QStringList audio_filters, video_filters, image_filters;
2081
audio_filters << "*.mp3" << "*.MP3" << "*.wav" << "*.WAV" << "*.ogg" << "*.OGG" << "*.flac" << "*.FLAC" << "*.m4r" << "*.M4R" << "*.WMA" << "*.wma";
2082
video_filters << "*.avi" << "*.AVI" << "*ogv" << "*OGV" << "*vob" << "*VOB" << "*.mp4" << "*.MP4" << "*3gp" << "*3GP" << "*wmv" << "*WMV" << "*.mkv" << "*.MKV" << "*mpg" << "*MPG" << "*mov" << "*MOV" << "*flv" << "*FLV";
2083
image_filters << "*.png" << "*.PNG" << "*.jpg" << "*.JPG" << "*.jpeg" << "*.JPEG" << "*.gif" << "*.GIF" << "*.bmp" << "*.BMP" << "*.svg" << "*.SVG";
2084
QStringList audio_files=dir_get_all_files.entryList(audio_filters);
2085
QStringList video_files=dir_get_all_files.entryList(video_filters);
2086
QStringList image_files=dir_get_all_files.entryList(image_filters);
2087
int audio_files_count = audio_files.count();
2088
int video_files_count = video_files.count();
2089
int image_files_count = image_files.count();
2090
if(audio_files_count){
2092
int old_r_count=ui->tableWidget->rowCount();
2093
ui->tableWidget->setRowCount(ui->tableWidget->rowCount()+audio_files_count);
2095
for(int i=0; i<audio_files_count; i++){
2096
temp=path+"/"+audio_files.at(i);
2098
QTableWidgetItem *qtitem = new QTableWidgetItem;
2099
qtitem->setText(audio_files.at(i));
2100
qtitem->setToolTip(temp);
2101
ui->tableWidget->setItem(old_r_count+i,0,qtitem);
2102
QTableWidgetItem *qtsize = new QTableWidgetItem;
2103
float size=(float)inf.size()/1048576;
2104
qtsize->setText(QString::number(size, 'f', 2)+" MB");
2105
ui->tableWidget->setItem(old_r_count+i,1,qtsize);
2106
QTableWidgetItem *qtwait = new QTableWidgetItem;
2107
qtwait->setText("Waiting");
2108
ui->tableWidget->setItem(old_r_count+i,2,qtwait);
2111
if(video_files_count){
2113
int old_r_count=ui->tableWidget_2->rowCount();
2114
ui->tableWidget_2->setRowCount(ui->tableWidget_2->rowCount()+video_files_count);
2116
for(int i=0; i<video_files_count; i++){
2117
temp=path+"/"+video_files.at(i);
2119
QTableWidgetItem *qtitem = new QTableWidgetItem;
2120
qtitem->setText(video_files.at(i));
2121
qtitem->setToolTip(temp);
2122
ui->tableWidget_2->setItem(old_r_count+i,0,qtitem);
2123
QTableWidgetItem *qtsize = new QTableWidgetItem;
2124
float size=(float)inf.size()/1048576;
2125
qtsize->setText(QString::number(size, 'f', 2)+" MB");
2126
ui->tableWidget_2->setItem(old_r_count+i,1,qtsize);
2127
QTableWidgetItem *qtwait = new QTableWidgetItem;
2128
qtwait->setText("Waiting");
2129
ui->tableWidget_2->setItem(old_r_count+i,2,qtwait);
2132
if(image_files_count){
2134
int old_r_count=ui->tableWidget_3->rowCount();
2135
ui->tableWidget_3->setRowCount(ui->tableWidget_3->rowCount()+image_files_count);
2137
for(int i=0; i<image_files_count; i++){
2138
temp=path+"/"+image_files.at(i);
2140
QTableWidgetItem *qtitem = new QTableWidgetItem;
2141
qtitem->setText(image_files.at(i));
2142
qtitem->setToolTip(temp);
2143
ui->tableWidget_3->setItem(old_r_count+i,0,qtitem);
2144
QTableWidgetItem *qtsize = new QTableWidgetItem;
2145
float size=(float)inf.size()/1048576;
2146
qtsize->setText(QString::number(size, 'f', 3)+" MB");
2147
ui->tableWidget_3->setItem(old_r_count+i,1,qtsize);
2148
QTableWidgetItem *qtwait = new QTableWidgetItem;
2149
qtwait->setText("Waiting");
2150
ui->tableWidget_3->setItem(old_r_count+i,2,qtwait);
2156
float MainWindow::get_size(QString folder){
2158
This function returns the size of a specified folder in MB (non recursively)
2160
QDir dir_get_all_files;
2161
dir_get_all_files.setPath(folder);
2162
dir_get_all_files.setFilter(QDir::Files);
2163
QStringList all_files=dir_get_all_files.entryList();
2164
int all_files_count = all_files.count();
2165
float complete_size=0;
2166
if(all_files_count){
2169
for(int i=0; i<all_files_count; i++){
2170
temp=folder+"/"+all_files.at(i);
2172
complete_size+=(float)inf.size()/1048576;
2174
return complete_size;
2177
return complete_size;
2180
float MainWindow::folder_size(QString folder){
2182
this function returns a float number, which
2183
represents the size of the parent folder 'folder'
2187
//getting all the subfolders of the folder specified...
2188
QStringList all_folders = list_folders(folder);
2189
int all_folders_count=all_folders.count();
2190
float complete_size=0;
2191
for(int i=0;i<all_folders_count;i++){
2192
//getting the size of each of the subfolders
2193
float folder_size=get_size(all_folders.at(i));
2194
complete_size+=folder_size;
2196
return complete_size;
2199
QStringList MainWindow::list_folders(QString parent_folder){
2200
//this function return a QStringList with all the subdirectories
2201
//of a parent_folder, and the parent_folder itself.
2202
QStringList all_dirs;
2203
all_dirs << parent_folder;
2204
QDirIterator directories(parent_folder, QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
2206
while(directories.hasNext()){
2208
all_dirs << directories.filePath();
2213
void MainWindow::on_stop_clicked()
2215
audio_stop_pressed=true;
2216
progressbar_animation(1,0);
2217
ui->startBtn->raise();
2218
audio_converter->close();
2219
ui->outputFormatComboBox->setEnabled(true);
2220
if(unity_progressbar)
2221
unity_launcher_entry_set_progress_visible(unity_progress, false);
2223
unity_launcher_entry_set_count_visible(unity_progress, false);
2226
void MainWindow::on_output_folder_clicked()
2228
QString output_dir=ui->output_folder->toolTip();
2229
if(!QDir(output_dir).exists()){
2231
if(!dir.mkpath(output_dir)){
2232
QMessageBox::information(this, "Error", "Folder '"+output_dir+"' doesn't exist and I failed to create it, please choose another output_folder");
2236
if(system(QString("xdg-open \""+output_dir+"\"&").toLocal8Bit().data()))
2237
cerr << QString("Error opening folder '"+output_dir+"'\n").toLocal8Bit().data();
2240
void MainWindow::on_actionPreferences_triggered()
2242
pref =new Preferences;
2243
connect(this,SIGNAL(send_output_folder(QString)),pref,SLOT(put_output_folder_at_line(QString)));
2244
connect(pref,SIGNAL(send_new_output(QString)),this,SLOT(crop_output_folder(QString)));
2245
connect(pref, SIGNAL(create_indicator()), this, SLOT(make_indicator()));
2246
connect(pref, SIGNAL(remove_indicator()), this, SLOT(delete_indicator()));
2247
Q_EMIT send_output_folder(ui->output_folder->toolTip());
2251
void MainWindow::delete_indicator(){
2255
void MainWindow::progressbar_animation(int end_value, int type){
2257
If end_value is 1, then show the stop button
2258
0, show the start buttonS
2263
//animation for start button
2265
QGraphicsOpacityEffect* opacityEffect = new QGraphicsOpacityEffect(this);
2267
opacityEffect->setOpacity(0.0);
2269
opacityEffect->setOpacity(1.0);
2270
ui->startBtn->setGraphicsEffect(opacityEffect);
2271
QPropertyAnimation* anim = new QPropertyAnimation(this);
2272
anim->setTargetObject(opacityEffect);
2273
anim->setPropertyName("opacity");
2274
anim->setDuration(500);
2275
anim->setStartValue(opacityEffect->opacity());
2276
anim->setEndValue(end_value);
2277
anim->setEasingCurve(QEasingCurve::OutQuad);
2278
anim->start(QAbstractAnimation::DeleteWhenStopped);
2280
//animation for stop button
2281
QGraphicsOpacityEffect* opacityEffect2 = new QGraphicsOpacityEffect(this);
2283
opacityEffect2->setOpacity(1.0);
2285
opacityEffect2->setOpacity(0.0);
2286
ui->stop->setGraphicsEffect(opacityEffect2);
2287
QPropertyAnimation* anim2 = new QPropertyAnimation(this);
2288
anim2->setTargetObject(opacityEffect2);
2289
anim2->setPropertyName("opacity");
2290
anim2->setDuration(500);
2291
anim2->setStartValue(opacityEffect2->opacity());
2292
anim2->setEndValue(!end_value);
2293
anim2->setEasingCurve(QEasingCurve::OutQuad);
2294
anim2->start(QAbstractAnimation::DeleteWhenStopped);
2295
if(!end_value && ui->stop->isHidden())
2298
//animation for stop button
2299
QGraphicsOpacityEffect* opacityEffect3 = new QGraphicsOpacityEffect(this);
2301
opacityEffect3->setOpacity(1.0);
2303
opacityEffect3->setOpacity(0.0);
2304
ui->progressBar->setGraphicsEffect(opacityEffect3);
2305
QPropertyAnimation* anim3 = new QPropertyAnimation(this);
2306
anim3->setTargetObject(opacityEffect3);
2307
anim3->setPropertyName("opacity");
2308
anim3->setDuration(1500);
2309
anim3->setStartValue(opacityEffect3->opacity());
2310
anim3->setEndValue(!end_value);
2311
anim3->setEasingCurve(QEasingCurve::OutQuad);
2312
anim3->start(QAbstractAnimation::DeleteWhenStopped);
2313
if(!end_value && ui->progressBar->isHidden())
2314
ui->progressBar->show();
2317
QGraphicsOpacityEffect* opacityEffect = new QGraphicsOpacityEffect(this);
2319
opacityEffect->setOpacity(0.0);
2321
opacityEffect->setOpacity(1.0);
2322
ui->startBtn_2->setGraphicsEffect(opacityEffect);
2323
QPropertyAnimation* anim = new QPropertyAnimation(this);
2324
anim->setTargetObject(opacityEffect);
2325
anim->setPropertyName("opacity");
2326
anim->setDuration(500);
2327
anim->setStartValue(opacityEffect->opacity());
2328
anim->setEndValue(end_value);
2329
anim->setEasingCurve(QEasingCurve::OutQuad);
2330
anim->start(QAbstractAnimation::DeleteWhenStopped);
2332
//animation for stop button
2333
QGraphicsOpacityEffect* opacityEffect2 = new QGraphicsOpacityEffect(this);
2335
opacityEffect2->setOpacity(1.0);
2337
opacityEffect2->setOpacity(0.0);
2338
ui->stop_2->setGraphicsEffect(opacityEffect2);
2339
QPropertyAnimation* anim2 = new QPropertyAnimation(this);
2340
anim2->setTargetObject(opacityEffect2);
2341
anim2->setPropertyName("opacity");
2342
anim2->setDuration(500);
2343
anim2->setStartValue(opacityEffect2->opacity());
2344
anim2->setEndValue(!end_value);
2345
anim2->setEasingCurve(QEasingCurve::OutQuad);
2346
anim2->start(QAbstractAnimation::DeleteWhenStopped);
2347
if(!end_value && ui->stop_2->isHidden())
2350
//animation for stop button
2351
QGraphicsOpacityEffect* opacityEffect3 = new QGraphicsOpacityEffect(this);
2353
opacityEffect3->setOpacity(1.0);
2355
opacityEffect3->setOpacity(0.0);
2356
ui->progressBar_2->setGraphicsEffect(opacityEffect3);
2357
QPropertyAnimation* anim3 = new QPropertyAnimation(this);
2358
anim3->setTargetObject(opacityEffect3);
2359
anim3->setPropertyName("opacity");
2360
anim3->setDuration(1500);
2361
anim3->setStartValue(opacityEffect3->opacity());
2362
anim3->setEndValue(!end_value);
2363
anim3->setEasingCurve(QEasingCurve::OutQuad);
2364
anim3->start(QAbstractAnimation::DeleteWhenStopped);
2365
if(!end_value && ui->progressBar_2->isHidden())
2366
ui->progressBar_2->show();
2369
QGraphicsOpacityEffect* opacityEffect = new QGraphicsOpacityEffect(this);
2371
opacityEffect->setOpacity(0.0);
2373
opacityEffect->setOpacity(1.0);
2374
ui->startBtn_3->setGraphicsEffect(opacityEffect);
2375
QPropertyAnimation* anim = new QPropertyAnimation(this);
2376
anim->setTargetObject(opacityEffect);
2377
anim->setPropertyName("opacity");
2378
anim->setDuration(500);
2379
anim->setStartValue(opacityEffect->opacity());
2380
anim->setEndValue(end_value);
2381
anim->setEasingCurve(QEasingCurve::OutQuad);
2382
anim->start(QAbstractAnimation::DeleteWhenStopped);
2384
//animation for stop button
2385
QGraphicsOpacityEffect* opacityEffect2 = new QGraphicsOpacityEffect(this);
2387
opacityEffect2->setOpacity(1.0);
2389
opacityEffect2->setOpacity(0.0);
2390
ui->stop_3->setGraphicsEffect(opacityEffect2);
2391
QPropertyAnimation* anim2 = new QPropertyAnimation(this);
2392
anim2->setTargetObject(opacityEffect2);
2393
anim2->setPropertyName("opacity");
2394
anim2->setDuration(500);
2395
anim2->setStartValue(opacityEffect2->opacity());
2396
anim2->setEndValue(!end_value);
2397
anim2->setEasingCurve(QEasingCurve::OutQuad);
2398
anim2->start(QAbstractAnimation::DeleteWhenStopped);
2399
if(!end_value && ui->stop_3->isHidden())
2402
//animation for stop button
2403
QGraphicsOpacityEffect* opacityEffect3 = new QGraphicsOpacityEffect(this);
2405
opacityEffect3->setOpacity(1.0);
2407
opacityEffect3->setOpacity(0.0);
2408
ui->progressBar_3->setGraphicsEffect(opacityEffect3);
2409
QPropertyAnimation* anim3 = new QPropertyAnimation(this);
2410
anim3->setTargetObject(opacityEffect3);
2411
anim3->setPropertyName("opacity");
2412
anim3->setDuration(1500);
2413
anim3->setStartValue(opacityEffect3->opacity());
2414
anim3->setEndValue(!end_value);
2415
anim3->setEasingCurve(QEasingCurve::OutQuad);
2416
anim3->start(QAbstractAnimation::DeleteWhenStopped);
2417
if(!end_value && ui->progressBar_3->isHidden())
2418
ui->progressBar_3->show();
2422
void MainWindow::on_stackedWidget_currentChanged(int arg1)
2425
if(cur_index==3 && ui->stackedWidget_3->currentIndex()==1){
2427
ui->addfolder->hide();
2428
ui->clearBtn->hide();
2429
ui->removeBtn->hide();
2430
ui->movedownButton->hide();
2431
ui->moveupButton->hide();
2433
else if(ui->addBtn->isHidden()){
2435
ui->addfolder->show();
2436
ui->clearBtn->show();
2437
ui->removeBtn->show();
2438
ui->movedownButton->show();
2439
ui->moveupButton->show();
2443
void MainWindow::on_show_errors_clicked()
2445
showlogs =new error_logs(all_errors, this);
2449
void MainWindow::on_actionAbout_triggered()
2451
About = new about(this);
2455
About->activateWindow();
2465
void MainWindow::on_actionQuit_triggered()
2470
void MainWindow::on_actionGet_Help_Online_triggered()
2472
if(system("xdg-open https://answers.launchpad.net/format-junkie/+addquestion"))
2473
cerr << "Error opening https://answers.launchpad.net/format-junkie/+addquestion\n";
2475
void MainWindow::on_actionReport_A_Bug_triggered()
2477
if(system("xdg-open https://bugs.launchpad.net/format-junkie/+filebug"))
2478
cerr << "Error opening https://bugs.launchpad.net/format-junkie/+filebug\n";
2481
void MainWindow::dbus_action(QString msg){
2482
//this function checks for dbus messages!
2485
This 'this->stackUnder(parentWidget());' works but only for the 1st time :(
2486
I haven't found a solution on how to set strong focus and bring to front my
2489
this->setFocusPolicy(Qt::StrongFocus);
2492
this->activateWindow();
2496
this->stackUnder(0);
2498
else if(msg=="--add-audio"){
2500
ui->stackedWidget->setCurrentIndex(0);
2501
ui->musicButton->setChecked(true);
2502
on_addBtn_clicked();
2504
else if(msg=="--add-video"){
2506
ui->stackedWidget->setCurrentIndex(1);
2507
ui->videoButton->setChecked(true);
2508
on_addBtn_clicked();
2510
else if(msg=="--add-image"){
2512
ui->stackedWidget->setCurrentIndex(2);
2513
ui->imageButton->setChecked(true);
2514
on_addBtn_clicked();
2516
else if(msg=="--open-output"){
2517
on_output_folder_clicked();
2520
cerr << QString("Received message "+msg+" but it's not recognized as an argument!\nPlease give formatjunkie --help/-h for all available options!\n").toLocal8Bit().data();
2524
void MainWindow::update_unity_value(int value){
2525
unity_launcher_entry_set_progress(unity_progress, (float)value/100);
2528
void MainWindow::on_progressBar_valueChanged(int value)
2530
if(unity_progressbar)
2531
update_unity_value(value);
2534
void MainWindow::on_progressBar_2_valueChanged(int value)
2536
if(unity_progressbar)
2537
update_unity_value(value);
2540
void MainWindow::on_progressBar_3_valueChanged(int value)
2542
if(unity_progressbar)
2543
update_unity_value(value);
2546
void MainWindow::handle_it(){
2550
void MainWindow::show_desktop_notification(int noti_type){
2553
0->Notification about convertion complete
2554
1->Notification about a file that already exists
2555
2->Notification about successful ISO creation
2556
3->Notification about a file that doesn't exist while it should
2557
4->Notification about successful CSO creation
2558
5->Notification about unsuccessful ISO creation
2559
6->Notification about unsuccessful CSO creation
2560
7->Notification about already existent avi file (on subtitles encoding)
2561
8->Notification about encoding successful
2564
QString body1,body2,body3;
2565
body1="The conversion of "+QString::number(num_files-already_completed);
2566
if(num_files-already_completed>1)
2567
body2=" files has finished";
2569
body2=" file has finished";
2572
body3=" with "+QString::number(error_count)+" errors!";
2574
body3=" with 1 error!";
2579
body=body1+body2+body3;
2581
else if(noti_type==1)
2582
body="The file "+file_exists+" already exists.";
2583
else if(noti_type==2)
2584
body="ISO file has been created successfully";
2585
else if(noti_type==3)
2586
body="File "+file_not_exists+" doesn't exist.";
2587
else if(noti_type==4)
2588
body="CSO file has been created successfully";
2589
else if(noti_type==5)
2590
body="Error creating your ISO file!";
2591
else if(noti_type==6)
2592
body="Error creating your CSO file!";
2593
else if(noti_type==7)
2594
body="The file"+file_exists+" already exists!";
2595
else if(noti_type==8)
2596
body="Encoding has been completed successfully ";
2597
else if(noti_type==9)
2598
body="Error while trying to encode!";
2600
if (!notify_init ("update-notifications")){
2601
cerr << "Couldn't display notification, unknown error!\n";
2604
if(first_notification){
2605
first_notification=false;
2606
notification = notify_notification_new ( "Format Junkie", body.toLocal8Bit().data(), "/opt/extras.ubuntu.com/formatjunkie/pixmap/fjt.png");
2608
success = notify_notification_show (notification, &error);
2611
g_print ("The notification did not work ... \"%s\".\n", error->message);
2612
g_error_free (error);
2615
g_signal_connect (G_OBJECT (notification), "closed", G_CALLBACK (&handle_it), NULL);
2619
success = notify_notification_update (notification, "Format Junkie",body.toLocal8Bit().data(), "/opt/extras.ubuntu.com/formatjunkie/pixmap/fjt.png");
2621
success = notify_notification_show (notification, &error);
2624
g_print ("The notification did not work ... \"%s\".\n", error->message);
2625
g_error_free (error);
2628
g_signal_connect (G_OBJECT (notification), "closed", G_CALLBACK (&handle_it), NULL);
2631
void MainWindow::on_actionContents_F1_triggered()
2633
if(system("yelp file:///opt/extras.ubuntu.com/formatjunkie/help/C/formatjunkie.xml 2> /dev/null&"))
2634
cerr << "Error opening /opt/extras.ubuntu.com/formatjunkie/help/C/formatjunkie.xml with yelp! Check for file existence and/or for /usr/bin/yelp\n";
2637
void MainWindow::process_dir(QString dir){
2639
This function that takes a QString parent dir as an argument and process it.
2640
Specifically, it takes all the files from the subfolders of the 'dir' and
2641
adds them to the corresponding tableWidget of mainwindow.ui
2642
It is used from the drag and drop event (if a folder has been dropped)!
2644
QStringList all_folders=list_folders(dir);
2645
int all_folders_count=all_folders.count();
2646
for(int i=0;i<all_folders_count;i++){
2647
add_files(all_folders.at(i), 3);
2649
if(ui->tableWidget->rowCount() && ui->outputFormatComboBox->isEnabled())
2650
ui->startBtn->setEnabled(true);
2651
if(ui->tableWidget_2->rowCount() && ui->outputFormatComboBox_2->isEnabled())
2652
ui->startBtn_2->setEnabled(true);
2653
if(ui->tableWidget_3->rowCount() && ui->outputFormatComboBox_3->isEnabled())
2654
ui->startBtn_3->setEnabled(true);
2657
void MainWindow::on_actionAdd_Audio_Files_triggered()
2662
void MainWindow::on_actionAdd_Video_Files_triggered()
2667
void MainWindow::on_actionAdd_Image_Files_triggered()
2672
void MainWindow::show_me(){
2673
//this function gives strong focus to the application. It's called from the trayIcon
2674
this->setFocusPolicy(Qt::StrongFocus);
2677
this->activateWindow();
2681
this->stackUnder(0);
2684
void MainWindow::changeEvent(QEvent *e)
2687
case QEvent::LanguageChange:
2688
ui->retranslateUi(this);
2691
//see if the event is changing the window state
2693
case QEvent::WindowStateChange:
2694
//if it is, we need to see that this event is minimize
2705
QMainWindow::changeEvent(e);
2709
void MainWindow::make_indicator()
2711
QApplication::setQuitOnLastWindowClosed(false);
2712
if(indicator_has_been_created){
2716
indicator_has_been_created=true;
2717
trayIcon = new QSystemTrayIcon(this);
2718
trayIcon->setIcon(QIcon(":/pictures/Pictures/tray.png"));
2719
trayIcon->setToolTip("Format Junkie Tray Icon");
2721
QMenu *changer_menu = new QMenu;
2723
Show_action = new QAction("S&how",this);
2724
Show_action->setIconVisibleInMenu(true);
2725
connect(Show_action, SIGNAL(triggered()), this, SLOT(show_me()));
2726
changer_menu->addAction(Show_action);
2728
changer_menu->addSeparator();
2730
Show_audio = new QAction(QIcon::fromTheme("audio-x-generic"), "Add Audio files", this);
2731
Show_audio->setIconVisibleInMenu(true);
2732
connect(Show_audio, SIGNAL(triggered()), this, SLOT(add_audio_files()));
2733
changer_menu->addAction(Show_audio);
2735
Show_video = new QAction(QIcon::fromTheme("video-x-generic"), "Add Video files", this);
2736
Show_video->setIconVisibleInMenu(true);
2737
connect(Show_video, SIGNAL(triggered()), this, SLOT(add_video_files()));
2738
changer_menu->addAction(Show_video);
2740
Show_image = new QAction(QIcon::fromTheme("image-x-generic"), "Add Image files", this);
2741
Show_image->setIconVisibleInMenu(true);
2742
connect(Show_image, SIGNAL(triggered()), this, SLOT(add_image_files()));
2743
changer_menu->addAction(Show_image);
2745
Show_preferences = new QAction(QIcon::fromTheme("preferences-desktop"), "Preferences", this);
2746
Show_preferences->setIconVisibleInMenu(true);
2747
connect(Show_preferences, SIGNAL(triggered()), this, SLOT(on_actionPreferences_triggered()));
2748
changer_menu->addAction(Show_preferences);
2750
Show_outputfolder = new QAction(QIcon::fromTheme("folder"), "Open Output Folder", this);
2751
Show_outputfolder->setIconVisibleInMenu(true);
2752
connect(Show_outputfolder, SIGNAL(triggered()), this, SLOT(on_output_folder_clicked()));
2753
changer_menu->addAction(Show_outputfolder);
2755
Show_about = new QAction(QIcon::fromTheme("help-about"), "About", this);
2756
Show_about->setIconVisibleInMenu(true);
2757
connect(Show_about, SIGNAL(triggered()), this, SLOT(on_actionAbout_triggered()));
2758
changer_menu->addAction(Show_about);
2760
changer_menu->addSeparator();
2762
Quit_action = new QAction(QIcon::fromTheme("window-close"), "&Quit", this);
2763
Quit_action->setIconVisibleInMenu(true);
2764
connect(Quit_action, SIGNAL(triggered()), this, SLOT(close()));
2765
changer_menu->addAction(Quit_action);
2768
trayIcon->setContextMenu(changer_menu);
2772
void MainWindow::image_read_output(){
2773
//read all possible output so as to calculate the percentages...
2774
QByteArray newData_stdout=image_converter->readAllStandardOutput();
2775
QString stdout=QString::fromLocal8Bit(newData_stdout);
2776
QByteArray newData_stderr=image_converter->readAllStandardError();
2777
QString stderr=QString::fromLocal8Bit(newData_stderr);
2778
QString out=stdout+stderr;
2779
current_file_errors+=out;
2782
void MainWindow::image_conversion(int return_code){
2783
QString format_text=ui->outputFormatComboBox_3->currentText();
2785
if(image_stop_pressed){
2786
if(ui->tableWidget_3->item(current_file-1,2)->toolTip()!="Completed")
2787
ui->tableWidget_3->removeCellWidget(current_file-1,2);
2789
ui->tableWidget_3->removeCellWidget(current_file,2);
2790
ui->tableWidget_3->item(current_file-1,2)->setText("Waiting");
2792
inf.setFile(output_file);
2793
QString output_file_rm=ui->output_folder->toolTip()+"/"+inf.completeBaseName()+"."+format_text;
2794
QFile::remove(output_file_rm);
2798
//AN ERROR HAS OCCURED!
2799
image_conversion_result=2;
2800
image_conversion(0);
2805
//IF NOT RETURN CODE
2807
The conversion of the previous file was successful!
2808
Check if the original (source) file is to be deleted...
2810
if(delete_original){
2811
if(QFile(input_file).exists()){
2812
if(system(QString("rm -f \""+input_file+"\"").toLocal8Bit().data()))
2813
cerr << QString("Could not delete source file '"+input_file+"'\nDo I have the permissions to do so?\n").toLocal8Bit().data();
2818
if (current_file>num_files-1){
2820
!!!ALL IMAGE FILES HAVE BEEN CONVERTED!!!
2821
Update the progressbars and do the actions
2822
that the user has chosen to do from bottom
2825
//just set to the last file the appropriate icon!
2826
ui->startBtn_3->setEnabled(false);
2827
ui->startBtn_3->raise();
2828
ui->progressBar_3->setFormat("100%");
2829
ui->progressBar_3->setValue(100);
2830
progressbar_animation(1,2);
2831
if(ui->tableWidget_3->cellWidget(current_file-1, 2))
2832
ui->tableWidget_3->removeCellWidget(current_file-1, 2);
2833
if(image_conversion_result==0){
2834
if(ui->tableWidget_3->item(current_file-1,2)->toolTip()!="Completed"){
2835
current_file_errors.clear();
2836
QLabel *lab = new QLabel(this);
2838
ui->tableWidget_3->item(current_file-1, 2)->setText("");
2839
lab->setPixmap(QPixmap(":/pictures/Pictures/tick.png"));
2840
ui->tableWidget_3->setCellWidget(current_file-1, 2, lab);
2841
ui->tableWidget_3->item(current_file-1,2)->setToolTip("Completed");
2844
else if(image_conversion_result==1){
2845
image_conversion_result=0;
2846
if(ui->tableWidget_3->item(current_file-1,2)->toolTip()!="Completed"){
2847
current_file_errors.clear();
2848
if(ui->tableWidget_3->cellWidget(current_file-1, 2))
2849
ui->tableWidget_3->removeCellWidget(current_file-1, 2);
2850
ui->tableWidget_3->item(current_file-1, 2)->setText("Already Exists!");
2851
ui->tableWidget_3->item(current_file-1,2)->setToolTip("Completed");
2854
else if(image_conversion_result==2){
2855
image_conversion_result=0;
2856
if(ui->tableWidget_3->item(current_file-1,2)->toolTip()!="Completed"){
2858
QLabel *lab = new QLabel(this);
2860
ui->tableWidget_3->item(current_file-1, 2)->setText("");
2861
lab->setPixmap(QPixmap(":/pictures/Pictures/error.png"));
2862
ui->tableWidget_3->setCellWidget(current_file-1, 2, lab);
2863
if(all_errors.isEmpty())
2864
all_errors+="'<b>"+input_file+"</b>'<br>";
2866
all_errors+="\n'<b>"+input_file+"</b>'<br>";
2867
current_file_errors.replace("\n","<br>");
2868
all_errors+="<font color=red>"+current_file_errors+"</font>";
2869
QTableWidgetItem *item_error1 = new QTableWidgetItem;
2870
item_error1->setText(ui->tableWidget_3->item(current_file-1,0)->text()+" - ERROR");
2871
item_error1->setToolTip(ui->tableWidget_3->item(current_file-1,0)->toolTip());
2872
item_error1->setBackgroundColor(Qt::red);
2873
item_error1->setTextColor(Qt::white);
2874
ui->tableWidget_3->setItem(current_file-1,0, item_error1);
2875
QTableWidgetItem *item_error2 = new QTableWidgetItem;
2876
item_error2->setText(ui->tableWidget_3->item(current_file-1,1)->text());
2877
item_error2->setToolTip(ui->tableWidget_3->item(current_file-1,1)->toolTip());
2878
item_error2->setBackgroundColor(Qt::red);
2879
item_error2->setTextColor(Qt::white);
2880
ui->tableWidget_3->setItem(current_file-1,1, item_error2);
2881
QTableWidgetItem *item_error3 = new QTableWidgetItem;
2882
item_error3->setBackgroundColor(Qt::red);
2883
item_error3->setTextColor(Qt::white);
2884
ui->tableWidget_3->setItem(current_file-1,2, item_error3);
2885
ui->show_errors->show();
2886
ui->tableWidget_3->item(current_file-1,2)->setToolTip("Completed");
2889
ui->outputFormatComboBox_3->setEnabled(true);
2890
if(unity_progressbar)
2891
unity_launcher_entry_set_progress_visible(unity_progress, false);
2893
unity_launcher_entry_set_count_visible(unity_progress, false);
2894
if(desktop_notifications)
2895
show_desktop_notification(0);
2897
actions_after_convert();
2900
if(current_file!=0){
2902
Setting to the previous file the image_conversion_result.
2903
It will be OK (tick) if the previous conversion was OK
2904
,FAIL (x) if the previous conversion has failed
2905
and it will be 'Already Exists' if
2906
the previous file already existed. This has no sense
2907
if current_file==0, because there isn't any previous
2910
image_conversion_result==0 -> OK!
2911
image_conversion_result==1 -> Already Exists!
2912
image_conversion_result==2 -> ERROR!
2914
//removing the previous file's gif, unless it is already completed(the user has added more files after the conversion has finished)...
2915
if(ui->tableWidget_3->cellWidget(current_file-1, 2) && ui->tableWidget_3->item(current_file-1,2)->toolTip()!="Completed")
2916
ui->tableWidget_3->removeCellWidget(current_file-1, 2);
2917
//and setting the new...
2918
if(image_conversion_result==0){
2919
if(ui->tableWidget_3->item(current_file-1,2)->toolTip()!="Completed"){
2920
current_file_errors.clear();
2921
QLabel *lab = new QLabel(this);
2923
ui->tableWidget_3->item(current_file-1, 2)->setText("");
2924
lab->setPixmap(QPixmap(":/pictures/Pictures/tick.png"));
2925
ui->tableWidget_3->setCellWidget(current_file-1, 2, lab);
2926
ui->tableWidget_3->item(current_file-1,2)->setToolTip("Completed");
2929
else if(image_conversion_result==1){
2930
image_conversion_result=0;
2931
if(ui->tableWidget_3->item(current_file-1,2)->toolTip()!="Completed"){
2932
current_file_errors.clear();
2933
ui->tableWidget_3->item(current_file-1, 2)->setText("Already Exists!");
2934
ui->tableWidget_3->item(current_file-1,2)->setToolTip("Completed");
2937
else if(image_conversion_result==2){
2938
image_conversion_result=0;
2939
if(ui->tableWidget_3->item(current_file-1,2)->toolTip()!="Completed"){
2941
QLabel *lab = new QLabel(this);
2943
ui->tableWidget_3->item(current_file-1, 2)->setText("");
2944
lab->setPixmap(QPixmap(":/pictures/Pictures/error.png"));
2945
ui->tableWidget_3->setCellWidget(current_file-1, 2, lab);
2946
if(all_errors.isEmpty())
2947
all_errors+="'<b>"+input_file+"</b>'<br>";
2949
all_errors+="\n'<b>"+input_file+"</b>'<br>";
2950
current_file_errors.replace("\n","<br>");
2951
all_errors+="<font color=red>"+current_file_errors+"</font>";
2952
QTableWidgetItem *item_error1 = new QTableWidgetItem;
2953
item_error1->setText(ui->tableWidget_3->item(current_file-1,0)->text()+" - ERROR");
2954
item_error1->setToolTip(ui->tableWidget_3->item(current_file-1,0)->toolTip());
2955
item_error1->setBackgroundColor(Qt::red);
2956
item_error1->setTextColor(Qt::white);
2957
ui->tableWidget_3->setItem(current_file-1,0, item_error1);
2958
QTableWidgetItem *item_error2 = new QTableWidgetItem;
2959
item_error2->setText(ui->tableWidget_3->item(current_file-1,1)->text());
2960
item_error2->setToolTip(ui->tableWidget_3->item(current_file-1,1)->toolTip());
2961
item_error2->setBackgroundColor(Qt::red);
2962
item_error2->setTextColor(Qt::white);
2963
ui->tableWidget_3->setItem(current_file-1,1, item_error2);
2964
QTableWidgetItem *item_error3 = new QTableWidgetItem;
2965
item_error3->setBackgroundColor(Qt::red);
2966
item_error3->setTextColor(Qt::white);
2967
ui->tableWidget_3->setItem(current_file-1,2, item_error3);
2968
ui->show_errors->show();
2969
ui->tableWidget_3->item(current_file-1,2)->setToolTip("Completed");
2974
input_file=ui->tableWidget_3->item(current_file,0)->toolTip();
2977
inf.setFile(input_file);
2978
output_file=ui->output_folder->toolTip()+"/"+inf.completeBaseName()+"."+format_text;
2980
if(QFile(output_file).exists()){
2981
if(overwrite_existing){
2982
if(!QFile(output_file).remove())
2983
cerr << QString("Error while removing the already existing file '"+output_file+"'\n").toLocal8Bit().data();
2986
{//overwrite_existing is false, but the output file already exists!
2987
//continue to the next file...
2988
image_conversion_result=1;
2990
image_conversion(0);
2994
//making the command...
2995
QString command="convert \""+input_file+"\"";
2997
command+=" -crop "+QString::number(image_width_value)+"x"+QString::number(image_height_value)+"+"+QString::number(image_x_value)+"+"+QString::number(image_y_value)+" +repage";
2999
if(image_width_height){
3000
command+=" -resize "+QString::number(image_width)+"x"+QString::number(image_height);
3001
if(!image_respect_ratio)
3004
if(image_colors_number){
3005
command+=" -colors "+QString::number(image_colors_number_value);
3008
command+=" -comment \""+image_comment_value+"\"";
3010
command+=" -quality "+QString::number(quality)+" \""+output_file+"\"";
3011
//setting the looping gif to the current file...
3012
QMovie *mov= new QMovie(this);
3013
mov->setFileName(":/pictures/Pictures/c.gif");
3014
QLabel *lab = new QLabel(this);
3016
ui->tableWidget_3->item(current_file, 2)->setText("");
3018
ui->tableWidget_3->setCellWidget(current_file, 2, lab);
3020
image_converter->start(command);
3021
update_unity_count_value(0);
3022
ui->progressBar_3->setValue((current_file-already_completed)*100/(num_files-already_completed));
3023
ui->progressBar_3->setFormat(QString::number((current_file-already_completed)*100/(num_files-already_completed))+"%");
3027
void MainWindow::on_startBtn_3_clicked()
3029
if(!ui->tableWidget_3->rowCount())
3031
if(!QDir(ui->output_folder->toolTip()).exists()){
3033
if(!dir.mkpath(ui->output_folder->toolTip())){
3034
QMessageBox::warning(this, tr("Error"), tr("The output folder doesn't exist! Please specify an existent directory!"));
3038
image_stop_pressed=false;
3039
num_files=ui->tableWidget_3->rowCount();
3041
unity_launcher_entry_set_count (unity_progress, num_files);
3042
ui->progressBar_3->setFormat("0%");
3043
ui->progressBar_3->setValue(0);
3044
ui->stop_3->raise();
3045
progressbar_animation(0,2);
3046
already_completed=0;
3047
for(int i=0;i<num_files;i++){
3048
if(ui->tableWidget_3->item(i,2)->toolTip()!="Completed"){
3050
already_completed=i;
3054
if(current_file==0){
3055
//that's a completely new conversion
3056
current_file_errors.clear();
3059
ui->show_errors->hide();
3061
ui->outputFormatComboBox_3->setEnabled(false);
3062
if(unity_progressbar)
3063
unity_launcher_entry_set_progress_visible(unity_progress, true);
3065
unity_launcher_entry_set_count_visible(unity_progress, true);
3066
image_conversion(0);
3069
void MainWindow::on_stop_3_clicked()
3071
image_stop_pressed=true;
3072
progressbar_animation(1,2);
3073
ui->startBtn_3->raise();
3074
image_converter->close();
3075
ui->outputFormatComboBox_3->setEnabled(true);
3076
if(unity_progressbar)
3077
unity_launcher_entry_set_progress_visible(unity_progress, false);
3079
unity_launcher_entry_set_count_visible(unity_progress, false);
3082
void MainWindow::on_startBtn_2_clicked()
3084
if(!ui->tableWidget_2->rowCount())
3086
if(!QDir(ui->output_folder->toolTip()).exists()){
3088
if(!dir.mkpath(ui->output_folder->toolTip())){
3089
QMessageBox::warning(this, tr("Error"), tr("The output folder doesn't exist! Please specify an existent directory!"));
3093
video_stop_pressed=false;
3094
num_files=ui->tableWidget_2->rowCount();
3096
unity_launcher_entry_set_count (unity_progress, num_files);
3097
ui->progressBar_2->setFormat("0%");
3098
ui->progressBar_2->setValue(0);
3099
ui->stop_2->raise();
3100
progressbar_animation(0,1);
3101
already_completed=0;
3102
for(int i=0;i<num_files;i++){
3103
if(ui->tableWidget_2->item(i,2)->toolTip()!="Completed"){
3105
already_completed=i;
3109
if(current_file==0){
3110
//that's a completely new conversion
3113
ui->show_errors->hide();
3115
ui->outputFormatComboBox_2->setEnabled(false);
3116
globpro_string="100%";
3117
if(unity_progressbar)
3118
unity_launcher_entry_set_progress_visible(unity_progress, true);
3120
unity_launcher_entry_set_count_visible(unity_progress, true);
3121
video_conversion(0);
3124
void MainWindow::video_conversion(int return_code){
3126
This function is called like video_conversion(0) the 1st time
3127
so as to begin the conversion. Then, it is called again
3128
when the 1st conversion has finished and launches the
3129
2nd conversion and so on, untill no files are left
3133
//current_file <-> 0 1 2
3134
//num_files <-> 1 2 3
3135
QString format_text=ui->outputFormatComboBox_2->currentText();
3137
if(video_stop_pressed){
3139
ui->tableWidget_2->removeCellWidget(current_file-1,2);
3141
ui->tableWidget_2->removeCellWidget(current_file,2);
3142
globpro_hasbeendeleted=true;
3143
if(!QFile::remove(output_file))
3144
cerr << QString("Error removing file '"+output_file+"'\n").toLocal8Bit().data();
3149
The conversion of the previous file wasn't successful!
3150
Print error and guide the user to see the error logs...
3152
if(all_errors.isEmpty())
3153
all_errors+="'<b>"+input_file+"</b>'<br>";
3155
all_errors+="\n'<b>"+input_file+"</b>'<br>";
3156
current_file_errors.replace("\n","<br>");
3157
all_errors+="<font color=red>"+current_file_errors+"</font><br>";
3158
int to_apply=current_file;
3161
QTableWidgetItem *item_error1 = new QTableWidgetItem;
3162
item_error1->setText(ui->tableWidget_2->item(to_apply,0)->text()+" - ERROR");
3163
item_error1->setToolTip(ui->tableWidget_2->item(to_apply,0)->toolTip());
3164
item_error1->setBackgroundColor(Qt::red);
3165
item_error1->setTextColor(Qt::white);
3166
ui->tableWidget_2->setItem(to_apply,0, item_error1);
3167
QTableWidgetItem *item_error2 = new QTableWidgetItem;
3168
item_error2->setText(ui->tableWidget_2->item(to_apply,1)->text());
3169
item_error2->setToolTip(ui->tableWidget_2->item(to_apply,1)->toolTip());
3170
item_error2->setBackgroundColor(Qt::red);
3171
item_error2->setTextColor(Qt::white);
3172
ui->tableWidget_2->setItem(to_apply,1, item_error2);
3173
ui->show_errors->show();
3174
current_file_errors.clear();
3179
//IF NOT RETURN CODE
3180
current_file_errors.clear();
3182
The conversion of the previous file was successful!
3183
Check if the original (source) file is to be deleted...
3185
if(delete_original){
3186
if(QFile(input_file).exists()){
3187
if(system(QString("rm -f \""+input_file+"\"").toLocal8Bit().data()))
3188
cerr << QString("Could not delete source file '"+input_file+"'\nDo I have the permissions to do so?\n").toLocal8Bit().data();
3192
if (current_file>num_files-1){
3194
!!!ALL FILES HAVE BEEN CONVERTED!!!
3195
Update the progressbars and do the actions
3196
that the user has chosen to do from bottom
3199
//all files have been converted!
3200
//just update the progressbar
3201
ui->progressBar_2->setFormat("100%");
3202
ui->progressBar_2->setValue(100);
3203
globpro->setFormat(globpro_string);
3204
globpro->setValue(100);
3205
QTableWidgetItem *item_progress = new QTableWidgetItem;
3206
item_progress->setToolTip("Completed");
3207
ui->tableWidget_2->setItem(current_file-1,2, item_progress);
3208
ui->startBtn_2->setEnabled(false);
3209
ui->startBtn_2->raise();
3210
progressbar_animation(1,1);
3211
ui->outputFormatComboBox_2->setEnabled(true);
3212
if(unity_progressbar)
3213
unity_launcher_entry_set_progress_visible(unity_progress, false);
3215
unity_launcher_entry_set_count_visible(unity_progress, false);
3216
if(desktop_notifications)
3217
show_desktop_notification(0);
3219
actions_after_convert();
3222
if(ui->tableWidget_2->item(current_file,2)->toolTip()=="Completed"){
3224
The file's conversion has been completed, proceed to the next file...
3225
The program goes through here if the user add more files after the
3226
previous conversion has finished and choose to start converting...
3229
video_conversion(0);
3232
if(globpro_string=="Already Exists" || !m4r_or_a_time){
3233
if(current_file!=0){
3234
if(globpro_hasbeendeleted){
3235
globpro = new QProgressBar(this);
3236
globpro_hasbeendeleted=false;
3238
if(globpro->format()!="Already Exists" && ui->tableWidget_2->item(current_file-1,2)->toolTip()!="Completed"){
3239
QProgressBar *qtpro=new QProgressBar(this);
3240
ui->tableWidget_2->setCellWidget(current_file-1, 2, qtpro);
3241
QTableWidgetItem *item_progress = new QTableWidgetItem;
3242
item_progress->setToolTip("Completed");
3243
ui->tableWidget_2->setItem(current_file-1,2, item_progress);
3244
qtpro->setFormat(globpro_string);
3245
qtpro->setValue(100);
3248
QProgressBar *qtpro=new QProgressBar(this);
3249
ui->tableWidget_2->setCellWidget(current_file, 2, qtpro);
3251
globpro = new QProgressBar(this);
3254
//Action starts here...
3255
input_file=ui->tableWidget_2->item(current_file,0)->toolTip();
3257
info.setFile(input_file);
3258
output_file=ui->output_folder->toolTip()+"/"+info.completeBaseName()+"."+format_text;
3259
command="avconv -i \""+input_file+"\" -qscale 1 ";
3260
//Custom commands for the right extensions
3261
if(format_text=="mov" ||format_text=="vob" ||format_text=="mp4" ||format_text=="mpg" ||format_text=="wmv" ||format_text=="mkv"){
3262
if(info.completeSuffix()=="flv")
3263
command+="-ar 44100 -f flv";
3264
else if(info.completeSuffix()=="3gp"||info.completeSuffix()=="ogv")
3265
command+="-ar 44100 -strict experimental";
3267
command+="-strict experimental";
3269
else if(format_text=="3gp"){
3270
command+="-acodec aac -s qcif -ar 8000 -b 120000 -vcodec h263 -ab 10.2k -ac 1 -strict experimental";
3272
else if(format_text=="avi"){
3273
if(info.completeSuffix()=="flv")
3274
command+="-ar 44100 -f flv";
3275
else if(info.completeSuffix()=="ogv")
3276
command+="-vcodec mpeg4 -acodec copy";
3278
command+="-vcodec copy -acodec copy";
3280
else if(format_text=="flv" || format_text=="ogv")
3281
command+="-ar 44100 -f flv";
3284
command+=" -b:v "+QString::number(video_bitrate_value);
3286
command+=" -r "+QString::number(video_framerate_value);
3288
command+=" -vf crop="+QString::number(video_width_value)+":"+QString::number(video_height_value)+":"+QString::number(video_x_value)+":"+QString::number(video_y_value);
3290
command+=" -s "+video_resize_value;
3292
command+=" \""+output_file+"\"";
3294
Checking whether the output_file already exists. If it does, then
3295
overwrite it, if it checked so, or proceed to the next file, if not...
3297
if(QFile(output_file).exists()){
3298
if(overwrite_existing){
3299
if(!QFile::remove(output_file)){
3300
cerr << QString("Couldn't remove the already existing file '"+output_file+"'\n").toLocal8Bit().data();
3302
globpro_string="Already Exists";
3303
video_conversion(0);
3310
globpro_string="Already Exists";
3311
video_conversion(0);
3315
//getting the duration of the input file...
3316
duration_secs=Global::duration(input_file);
3317
globpro_string="100%";
3318
video_converter->start(command);
3319
if(full_percent_instant){
3320
full_percent_instant=false;
3321
globpro->setValue(100);
3322
globpro->setFormat(globpro_string);
3324
update_unity_count_value(0);
3328
void MainWindow::video_read_output(){
3329
//read all possible output so as to calculate the percentages...
3330
QByteArray newData_stdout=video_converter->readAllStandardOutput();
3331
QString stdout=QString::fromLocal8Bit(newData_stdout);
3332
QByteArray newData_stderr=video_converter->readAllStandardError();
3333
QString stderr=QString::fromLocal8Bit(newData_stderr);
3334
QString out=stdout+stderr;
3335
current_file_errors+=out;
3336
if(out.contains("kB time=")){
3338
QRegExp regex("time=.* ");
3339
regex.setMinimal(true);
3344
while ((pos = regex.indexIn(out, pos)) != -1)
3346
list << regex.cap(0).remove(QChar(' '),Qt::CaseInsensitive);
3347
pos += regex.matchedLength();
3353
QString current=list.at(0);
3354
current.replace("time=","");
3355
float cur_time=current.toFloat();
3357
percent=cur_time*100/duration_secs;
3359
globpro->setFormat(QString::number(percent)+"%");
3360
globpro->setValue(percent);
3361
ui->progressBar_2->setFormat(QString::number(percent/(num_files-already_completed)+(current_file-1-already_completed)*(100/(num_files-already_completed)))+"%");
3362
ui->progressBar_2->setValue(percent/(num_files-already_completed)+(current_file-1-already_completed)*(100/(num_files-already_completed)));
3366
void MainWindow::on_stop_2_clicked()
3368
video_stop_pressed=true;
3369
progressbar_animation(1,1);
3370
ui->startBtn_2->raise();
3371
video_converter->close();
3372
ui->outputFormatComboBox_2->setEnabled(true);
3373
if(unity_progressbar)
3374
unity_launcher_entry_set_progress_visible(unity_progress, false);
3376
unity_launcher_entry_set_count_visible(unity_progress, false);
3379
void MainWindow::on_radioButton_files_to_iso_clicked()
3381
ui->stackedWidget_3->setCurrentIndex(0);
3383
ui->addfolder->show();
3384
ui->clearBtn->show();
3385
ui->removeBtn->show();
3386
ui->movedownButton->show();
3387
ui->moveupButton->show();
3390
void MainWindow::on_radioButton_iso_cso_clicked()
3392
ui->stackedWidget_3->setCurrentIndex(1);
3394
ui->addfolder->hide();
3395
ui->clearBtn->hide();
3396
ui->removeBtn->hide();
3397
ui->movedownButton->hide();
3398
ui->moveupButton->hide();
3401
void MainWindow::on_startBtn_8_clicked()
3403
if(ui->lineEdit_6->text().contains("/")){
3404
QMessageBox::warning(this, "Error", "The output filename should not contain the '/' character!");
3407
QString output_iso=ui->output_folder->text()+"/"+ui->lineEdit_6->text()+".iso";
3408
if(QFile(output_iso).exists()){
3409
if(overwrite_existing){
3410
if(!QFile::remove(output_iso)){
3411
QMessageBox::warning(this, "Error", "The file '"+output_iso+"' already exists, but I cannot overwrite it!");
3416
if(desktop_notifications){
3417
file_exists=output_iso;
3418
show_desktop_notification(1);
3423
QMessageBox::warning(this, "Error", "The file '"+output_iso+"' already exists!");
3429
command="genisoimage -o \""+output_iso+"\"";
3430
int table_count=ui->tableWidget_6->rowCount();
3431
for(int i=0;i<table_count;i++){
3432
QString file=ui->tableWidget_6->item(i,0)->toolTip();
3433
if(!QFile(file).exists()){
3434
if(desktop_notifications){
3435
file_not_exists=file;
3436
show_desktop_notification(3);
3441
QMessageBox::warning(this, "Error", "The file '"+file+"' doesn't exist!");
3445
command+=" \""+file+"\"";
3447
ui->loading_label->show();
3448
if(!ui->loading_label->movie()){
3449
QMovie *mov= new QMovie(this);
3450
mov->setFileName(":/pictures/Pictures/c.gif");
3451
ui->loading_label->setMovie(mov);
3455
ui->loading_label->movie()->start();
3457
files_to_iso->start(command);
3458
ui->startBtn_8->hide();
3460
ui->lineEdit_6->setReadOnly(true);
3461
ui->tableWidget_6->setFocus();
3464
void MainWindow::files_to_iso_end(int return_code)
3467
ui->startBtn_8->show();
3468
ui->lineEdit_6->setReadOnly(false);
3469
ui->loading_label->movie()->stop();
3470
ui->loading_label->hide();
3472
//something went wrong
3473
if(desktop_notifications)
3474
show_desktop_notification(5);
3476
QMessageBox::warning(this, "Error", "The creation of the iso file has failed!");
3480
if(desktop_notifications)
3481
show_desktop_notification(2);
3483
QMessageBox::information(this, "Success!", "Your iso file has been created successfully!");
3487
void MainWindow::on_stop_6_clicked()
3489
files_to_iso->close();
3492
void MainWindow::on_select_iso_clicked()
3495
path = QFileDialog::getOpenFileName(this, "Choose Iso File", QDir::homePath(), "*.iso");
3497
if(!path.isEmpty()){
3498
ui->iso_to_cso_file->setText(path);
3499
on_iso_to_cso_output_textEdited();
3504
void MainWindow::on_select_cso_clicked()
3507
path = QFileDialog::getOpenFileName(this, "Choose Iso File", QDir::homePath(), "*.cso");
3509
if(!path.isEmpty()){
3510
ui->cso_to_iso_file->setText(path);
3511
on_cso_to_iso_output_textEdited();
3515
void MainWindow::on_iso_to_cso_start_clicked()
3517
if(overwrite_existing && QFile(ui->output_folder->text()+"/"+ui->iso_to_cso_output->text()+".cso").exists()){
3518
if(!QFile::remove(ui->output_folder->text()+"/"+ui->cso_to_iso_output->text()+".cso"))
3519
cerr << QString("Couldn't delete '"+ui->output_folder->text()+"/"+ui->cso_to_iso_output->text()+".cso"+"'\nPlease, unless the file is problematic, report this bug and attach the file that it caused it!\n").toLocal8Bit().data();
3521
else if(QFile(ui->output_folder->text()+"/"+ui->iso_to_cso_output->text()+".cso").exists()){
3522
file_exists=ui->output_folder->text()+"/"+ui->iso_to_cso_output->text()+".cso";
3523
if(desktop_notifications)
3524
show_desktop_notification(1);
3526
QMessageBox::warning(this, "Error", "The file '"+file_exists+"' already exists!");
3532
if(!QFile(ui->iso_to_cso_file->text()).exists()){
3533
file_not_exists=ui->iso_to_cso_file->text();
3534
if(desktop_notifications)
3535
show_desktop_notification(3);
3537
QMessageBox::warning(this, "Error", "The file '"+file_not_exists+"' doesn't exist!");
3542
command="ciso "+QString::number(ui->iso_to_cso_spinBox->value())+" \""+ui->iso_to_cso_file->text()+"\" \""+ui->output_folder->text()+"/"+ui->iso_to_cso_output->text()+".cso\"";
3543
ui->loading_label_2->show();
3544
if(!ui->loading_label_2->movie()){
3545
QMovie *mov= new QMovie(this);
3546
mov->setFileName(":/pictures/Pictures/c.gif");
3547
ui->loading_label_2->setMovie(mov);
3551
ui->loading_label_2->movie()->start();
3552
iso_to_cso->start(command);
3553
ui->select_iso->setEnabled(false);
3554
ui->iso_to_cso_output->setReadOnly(true);
3555
ui->iso_to_cso_spinBox->setEnabled(false);
3556
ui->iso_to_cso_start->hide();
3557
ui->iso_to_cso_stop->show();
3560
void MainWindow::on_iso_to_cso_output_textEdited()
3562
if(!ui->iso_to_cso_output->text().isEmpty()&&!ui->iso_to_cso_file->text().isEmpty()&&!ui->iso_to_cso_start->isEnabled())
3563
ui->iso_to_cso_start->setEnabled(true);
3564
else if(ui->iso_to_cso_output->text().isEmpty()||ui->iso_to_cso_file->text().isEmpty())
3565
ui->iso_to_cso_start->setEnabled(false);
3568
void MainWindow::on_cso_to_iso_output_textEdited()
3570
if(!ui->cso_to_iso_output->text().isEmpty()&&!ui->cso_to_iso_file->text().isEmpty()&&!ui->cso_to_iso_start->isEnabled())
3571
ui->cso_to_iso_start->setEnabled(true);
3572
else if(ui->cso_to_iso_output->text().isEmpty()||ui->cso_to_iso_file->text().isEmpty())
3573
ui->cso_to_iso_start->setEnabled(false);
3576
void MainWindow::on_cso_to_iso_start_clicked()
3578
if(overwrite_existing && QFile(ui->output_folder->text()+"/"+ui->cso_to_iso_output->text()+".iso").exists()){
3579
if(!QFile::remove(ui->output_folder->text()+"/"+ui->cso_to_iso_output->text()+".iso"))
3580
cerr << QString("Couldn't delete '"+ui->output_folder->text()+"/"+ui->cso_to_iso_output->text()+".iso"+"'\nPlease, unless the file is problematic, report this bug and attach the file that it caused it!\n").toLocal8Bit().data();
3582
else if(QFile(ui->output_folder->text()+"/"+ui->cso_to_iso_output->text()+".iso").exists()){
3583
file_exists=ui->output_folder->text()+"/"+ui->cso_to_iso_output->text()+".iso";
3584
if(desktop_notifications)
3585
show_desktop_notification(1);
3587
QMessageBox::warning(this, "Error", "The file '"+file_exists+"' already exists!");
3592
if(!QFile(ui->cso_to_iso_file->text()).exists()){
3593
file_not_exists=ui->cso_to_iso_file->text();
3594
if(desktop_notifications)
3595
show_desktop_notification(3);
3597
QMessageBox::warning(this, "Error", "The file '"+file_not_exists+"' doesn't exist!");
3602
command="ciso 0 \""+ui->cso_to_iso_file->text()+"\" \""+ui->output_folder->text()+"/"+ui->cso_to_iso_output->text()+".iso\"";
3603
ui->loading_label_3->show();
3604
if(!ui->loading_label_3->movie()){
3605
QMovie *mov= new QMovie(this);
3606
mov->setFileName(":/pictures/Pictures/c.gif");
3607
ui->loading_label_3->setMovie(mov);
3611
ui->loading_label_3->movie()->start();
3612
cso_to_iso->start(command);
3613
ui->select_cso->setEnabled(false);
3614
ui->cso_to_iso_output->setReadOnly(true);
3615
ui->cso_to_iso_start->hide();
3616
ui->cso_to_iso_stop->show();
3619
void MainWindow::iso_to_cso_end(int return_code)
3622
if(desktop_notifications)
3623
show_desktop_notification(6);
3625
QMessageBox::warning(this, "Error", "Your CSO file wasn't created successfully!");
3629
if(!iso_to_cso_stop_pressed){
3630
if(desktop_notifications)
3631
show_desktop_notification(4);
3633
QMessageBox::information(this, "Success!","Your CSO file has been successfully created!");
3636
ui->loading_label_2->movie()->stop();
3637
ui->loading_label_2->hide();
3638
ui->iso_to_cso_stop->hide();
3639
ui->iso_to_cso_start->show();
3640
ui->iso_to_cso_output->setReadOnly(false);
3641
ui->select_iso->setEnabled(true);
3642
ui->iso_to_cso_spinBox->setEnabled(true);
3645
void MainWindow::cso_to_iso_end(int return_code)
3649
if(desktop_notifications)
3650
show_desktop_notification(5);
3652
QMessageBox::warning(this, "Error", "Error creating your ISO file!");
3656
if(!cso_to_iso_stop_pressed){
3657
if(desktop_notifications)
3658
show_desktop_notification(2);
3660
QMessageBox::information(this, "Success!","Your ISO file has been successfully created!");
3663
ui->loading_label_3->movie()->stop();
3664
ui->loading_label_3->hide();
3665
ui->cso_to_iso_stop->hide();
3666
ui->cso_to_iso_start->show();
3667
ui->cso_to_iso_output->setReadOnly(false);
3668
ui->select_cso->setEnabled(true);
3671
void MainWindow::on_iso_to_cso_stop_clicked()
3673
iso_to_cso_stop_pressed=true;
3674
iso_to_cso->close();
3675
ui->iso_to_cso_stop->hide();
3676
ui->iso_to_cso_start->show();
3677
if(!QFile::remove(ui->output_folder->text()+"/"+ui->iso_to_cso_output->text()+".cso"))
3678
cerr << QString("Couldn't delete '"+ui->output_folder->text()+"/"+ui->iso_to_cso_output->text()+".cso"+"'\nPlease, unless the file is problematic, report this bug and attach the file that it caused it!\n").toLocal8Bit().data();
3681
void MainWindow::on_cso_to_iso_stop_clicked()
3683
cso_to_iso_stop_pressed=true;
3684
cso_to_iso->close();
3685
ui->cso_to_iso_stop->hide();
3686
ui->cso_to_iso_start->show();
3687
if(!QFile::remove(ui->output_folder->text()+"/"+ui->iso_to_cso_output->text()+".cso"))
3688
cerr << QString("Couldn't delete '"+ui->output_folder->text()+"/"+ui->iso_to_cso_output->text()+".cso"+"'\nPlease, unless the file is problematic, report this bug and attach the file that it caused it!\n").toLocal8Bit().data();
3691
void MainWindow::open_containing_folder(){
3692
if(QFile("/usr/bin/nautilus").exists() && !system("pidof nautilus > /dev/null")){
3693
//nautilus is installed and it runs! Better open the file with it, so as to be selected!
3695
if(system(QString("nautilus \""+ui->tableWidget->item(ui->tableWidget->currentRow(), 0)->toolTip()+"\"").toLocal8Bit().data()))
3696
cerr << "Could not open containing folder with nautilus.\n";
3698
else if(cur_index==1){
3699
if(system(QString("nautilus \""+ui->tableWidget_2->item(ui->tableWidget_2->currentRow(), 0)->toolTip()+"\"").toLocal8Bit().data()))
3700
cerr << "Could not open containing folder with nautilus.\n";
3702
else if(cur_index==2){
3703
if(system(QString("nautilus \""+ui->tableWidget_3->item(ui->tableWidget_3->currentRow(), 0)->toolTip()+"\"").toLocal8Bit().data()))
3704
cerr << "Could not open containing folder with nautilus.\n";
3711
inf.setFile(ui->tableWidget->item(ui->tableWidget->currentRow(), 0)->toolTip());
3712
else if(cur_index==1)
3713
inf.setFile(ui->tableWidget_2->item(ui->tableWidget_2->currentRow(), 0)->toolTip());
3714
else if(cur_index==1)
3715
inf.setFile(ui->tableWidget_3->item(ui->tableWidget_3->currentRow(), 0)->toolTip());
3716
if(system(QString("xdg-open \""+inf.path()+"\"").toLocal8Bit().data()))
3717
cerr << "Could not open containing folder.\n";
3721
void MainWindow::show_audio_video_item_properties(){
3723
if(!QFile(ui->tableWidget->item(ui->tableWidget->currentRow(), 0)->toolTip()).exists()){
3724
QMessageBox::information(this, "Error", "The file you specified does not exist!");
3727
prop=new audio_video_properties(ui->tableWidget->item(ui->tableWidget->currentRow(), 0)->toolTip(), this);
3729
else if(cur_index==1){
3730
if(!QFile(ui->tableWidget_2->item(ui->tableWidget_2->currentRow(), 0)->toolTip()).exists()){
3731
QMessageBox::information(this, "Error", "The file you specified does not exist!");
3734
prop=new audio_video_properties(ui->tableWidget_2->item(ui->tableWidget_2->currentRow(), 0)->toolTip(), this);
3739
void MainWindow::show_image_properties(){
3740
if(!QFile(ui->tableWidget_3->item(ui->tableWidget_3->currentRow(), 0)->toolTip()).exists()){
3741
QMessageBox::information(this, "Error", "The image you specified does not exist!");
3744
if(QImage(ui->tableWidget_3->item(ui->tableWidget_3->currentRow(), 0)->toolTip()).isNull()){
3745
QMessageBox::information(this, "Error", "The image you specified is invalid!");
3748
improp=new image_properties(ui->tableWidget_3->item(ui->tableWidget_3->currentRow(), 0)->toolTip(), this);
3752
void MainWindow::on_tableWidget_customContextMenuRequested()
3755
menu.addAction("Open Folder",this,SLOT(open_containing_folder()));
3756
menu.addAction("Remove",this,SLOT(on_removeBtn_clicked()));
3757
menu.addAction("Properties",this,SLOT(show_audio_video_item_properties()));
3758
if (ui->tableWidget->rowCount() > 0){
3759
if(! ui->tableWidget->currentIndex().isValid() || !ui->tableWidget->currentItem()->isSelected())
3761
menu.actions().at(0)->setEnabled(false);
3762
menu.actions().at(1)->setEnabled(false);
3763
menu.actions().at(2)->setEnabled(false);
3765
menu.exec(QCursor::pos());
3769
void MainWindow::on_tableWidget_2_customContextMenuRequested()
3772
menu.addAction("Open Folder",this,SLOT(open_containing_folder()));
3773
menu.addAction("Remove",this,SLOT(on_removeBtn_clicked()));
3774
menu.addAction("Properties",this,SLOT(show_audio_video_item_properties()));
3775
if (ui->tableWidget_2->rowCount() > 0){
3776
if(! ui->tableWidget_2->currentIndex().isValid() || !ui->tableWidget_2->currentItem()->isSelected())
3778
menu.actions().at(0)->setEnabled(false);
3779
menu.actions().at(1)->setEnabled(false);
3780
menu.actions().at(2)->setEnabled(false);
3782
menu.exec(QCursor::pos());
3786
void MainWindow::on_tableWidget_3_customContextMenuRequested()
3789
menu.addAction("Open Folder",this,SLOT(open_containing_folder()));
3790
menu.addAction("Remove",this,SLOT(on_removeBtn_clicked()));
3791
menu.addAction("Properties",this,SLOT(show_image_properties()));
3792
if (ui->tableWidget_3->rowCount() > 0){
3793
if(! ui->tableWidget_3->currentIndex().isValid() || !ui->tableWidget_3->currentItem()->isSelected())
3795
menu.actions().at(0)->setEnabled(false);
3796
menu.actions().at(1)->setEnabled(false);
3797
menu.actions().at(2)->setEnabled(false);
3799
menu.exec(QCursor::pos());
3802
void MainWindow::on_selectavi_clicked()
3805
if(QFile(QDir::homePath()+"/Videos").exists())
3806
avi_file=QFileDialog::getOpenFileName(this, "Select avi file", QDir::homePath()+"/Videos", "*.avi");
3808
avi_file=QFileDialog::getOpenFileName(this, "Select avi file", QDir::homePath(), "*.avi");
3809
if(avi_file.isEmpty())
3811
ui->avifile_path->setText(avi_file);
3814
void MainWindow::on_selectsubtitle_clicked()
3817
if(QFile(QDir::homePath()+"/Videos").exists())
3818
sub_file=QFileDialog::getOpenFileName(this, "Select avi file", QDir::homePath()+"/Videos", "*.sub *.srt");
3820
sub_file=QFileDialog::getOpenFileName(this, "Select avi file", QDir::homePath(), "*.sub *.srt");
3821
if(sub_file.isEmpty())
3823
ui->subtitlefile_path->setText(sub_file);
3826
void MainWindow::on_after_convertion2_currentIndexChanged(int index)
3830
ui->after_convertion_icon->setPixmap(QIcon::fromTheme("dialog-error").pixmap(22));
3833
ui->after_convertion_icon->setPixmap(QIcon::fromTheme("system-shutdown").pixmap(22));
3836
ui->after_convertion_icon->setPixmap(QIcon::fromTheme("weather-few-clouds-night").pixmap(22));
3839
ui->after_convertion_icon->setPixmap(QIcon::fromTheme("system-restart").pixmap(22));
3842
ui->after_convertion_icon->setPixmap(QIcon::fromTheme("system-lock-screen").pixmap(22));
3845
ui->after_convertion_icon->setPixmap(QIcon::fromTheme("window-close").pixmap(22));
3850
void MainWindow::on_encode_start_clicked()
3852
QString input_avi=ui->avifile_path->text();
3853
QString input_sub=ui->subtitlefile_path->text();
3854
if(!QFile(input_avi).exists()){
3855
QMessageBox::warning(this, "Error", "The avi file specified does not exist!");
3858
if(!QFile(input_sub).exists()){
3859
QMessageBox::warning(this, "Error", "The subtitle file specified does not exist!");
3863
inf.setFile(input_avi);
3865
QString output_avi=ui->output_folder->text()+"/"+inf.completeBaseName()+".avi";
3866
if(QFile(output_avi).exists()){
3867
if(overwrite_existing){
3868
if(!QFile::remove(output_avi)){
3869
QMessageBox::warning(this, "Error", "The file '"+output_avi+"' already exists, but I cannot overwrite it!");
3874
if(desktop_notifications){
3875
file_exists=output_avi;
3876
show_desktop_notification(7);
3881
QMessageBox::warning(this, "Error", "The file '"+output_avi+"' already exists!");
3887
//mencoder input.avi -oac copy -ovc lavc -sub input.srt -utf8-o output.avi
3889
command="mencoder \""+input_avi+"\" -oac copy -ovc lavc -sub \""+input_sub+"\" -utf8 -o \""+output_avi+"\"";
3890
ui->loading_label_sub_encoding->show();
3891
if(!ui->loading_label->movie()){
3892
QMovie *mov= new QMovie(this);
3893
mov->setFileName(":/pictures/Pictures/c.gif");
3894
ui->loading_label_sub_encoding->setMovie(mov);
3898
ui->loading_label->movie()->start();
3900
sub_encoding->start(command);
3901
ui->encode_start->hide();
3902
ui->encode_stop->show();
3903
ui->selectavi->setEnabled(false);
3904
ui->selectsubtitle->setEnabled(false);
3907
void MainWindow::on_encode_stop_clicked()
3909
sub_stop_pressed=true;
3910
sub_encoding->close();
3911
ui->loading_label_sub_encoding->movie()->stop();
3912
ui->loading_label_sub_encoding->hide();
3913
ui->encode_stop->hide();
3914
ui->encode_start->show();
3915
ui->selectavi->setEnabled(true);
3916
ui->selectsubtitle->setEnabled(true);
3919
void MainWindow::sub_encoding_end(int return_code){
3921
if(!sub_stop_pressed){
3922
if(desktop_notifications)
3923
show_desktop_notification(9);
3925
QMessageBox::warning(this, "Error", "Your subtitles' encoding hasn't finished successfully!");
3930
if(!iso_to_cso_stop_pressed){
3931
if(desktop_notifications)
3932
show_desktop_notification(8);
3934
QMessageBox::information(this, "Success!","Your subtitles' encoding was successful!");
3937
ui->loading_label_sub_encoding->movie()->stop();
3938
ui->loading_label_sub_encoding->hide();
3939
ui->encode_stop->hide();
3940
ui->encode_start->show();
3941
ui->selectavi->setEnabled(true);
3942
ui->selectsubtitle->setEnabled(true);