-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
1510 lines (1248 loc) · 66.4 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QStyleFactory>
#include <QDesktopServices>
#include <QFileDialog>
#include <QGraphicsVideoItem>
#include <QJsonDocument>
#include <QJsonObject>
#include <QMessageBox>
#include <QNetworkReply>
#include <QShortcut>
#include <QSslConfiguration>
#include <QTimer>
#include <QVersionNumber>
#include <QtDebug>
#include "agfilesystem.h"
#include "aglobal.h"
#include "agview.h"
#include <QtMath>
#include <QToolTip>
#include <QCloseEvent>
#ifdef Q_OS_WIN
#include <QWinTaskbarProgress>
#endif
//https://stackoverflow.com/questions/43347722/qt-show-progress-bar-in-dock-macos
//https://code.qt.io/cgit/qt-creator/qt-creator.git/tree/src/plugins/coreplugin/progressmanager
#include <QScrollBar>
#include <QGraphicsScene>
#include <QTextEdit>
#include <QTextBrowser>
#include <QHostAddress>
#include <QNetworkInterface>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
// qDebug()<<"MainWindow::MainWindow"<<thread();
ui->setupUi(this);
qApp->installEventFilter(this);
agFileSystem = new AGFileSystem(this);
changeUIProperties();
allConnects();
loadSettings();
// onClipsFilterChanged(false); //crash if removed...
allTooltips();
QTimer::singleShot(0, this, [this]()->void
{
QString theme = QSettings().value("theme").toString();
if (theme == "White")
on_actionWhite_theme_triggered();
else
on_actionBlack_theme_triggered();
QString selectedFolderName = QSettings().value("selectedFolderName").toString();
QDir recycleDir(selectedFolderName);
if (!recycleDir.exists())
selectedFolderName = "";
//here as otherwise openfolder not opened
if (selectedFolderName == "")
on_actionOpen_Folder_triggered();
else
{
checkAndOpenFolder(selectedFolderName);
}
// ui->folderTreeView->onIndexClicked(QModelIndex()); //initial load
// qDebug()<<"contextSensitiveHelpOn"<<QSettings().value("contextSensitiveHelpOn");
// if (QSettings().value("contextSensitiveHelpOn").toString() == "" || QSettings().value("contextSensitiveHelpOn").toBool())
// ui->actionContext_Sensitive_Help->setChecked(true);
showUpgradePrompt();
});
//tooltips after 10 seconds (to show hints first)
}
MainWindow::~MainWindow()
{
// qDebug()<<"Destructor"<<geometry();
if (geometry() != QSettings().value("Geometry").toRect())
{
// qDebug()<<"MainWindow::~MainWindow"<<geometry();
QSettings().setValue("Geometry", geometry());
// QSettings().setValue("windowState", saveState());
QSettings().sync();
}
delete ui;
}
void MainWindow::resizeEvent(QResizeEvent* event)
{
QMainWindow::resizeEvent(event);
// qDebug()<<"MainWindow::resizeEvent"<<geometry()<<event<<QSettings().value("Geometry").toRect();
if (geometry() != QSettings().value("Geometry").toRect())
{
if (ui->graphicsView->rootItem != nullptr)
ui->graphicsView->arrangeItems(nullptr, __func__);
QSettings().setValue("Geometry", geometry());
// QSettings().setValue("windowState", saveState());
QSettings().sync();
}
}
void MainWindow::on_actionQuit_triggered()
{
if (checkExit())
qApp->quit();
}
void MainWindow::closeEvent (QCloseEvent *event)
{
if (checkExit())
event->accept();
else
event->ignore();
}
bool MainWindow::checkExit()
{
bool exitYes = false;
// qDebug()<<"MainWindow::checkExit"<<ui->progressBar->value();
// if (ui->progressBar->value() > 0 && ui->progressBar->value() < 100)
// {
// QMessageBox::StandardButton reply;
// reply = QMessageBox::question(this, "Quit", tr("Export in progress, are you sure you want to quit?"), QMessageBox::Yes|QMessageBox::No);
// if (reply == QMessageBox::Yes)
// exitYes = true;
// }
// else
exitYes = true;
if (exitYes)
{
//check unsaved changes
if (ui->graphicsView->undoIndex != ui->graphicsView->undoSavePoint)
{
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, "Check changes", tr("There are %1 changes. Do you want to save these changes").arg(QString::number(qAbs(ui->graphicsView->undoIndex - ui->graphicsView->undoSavePoint))),
QMessageBox::Yes|QMessageBox::No);
if (reply == QMessageBox::Yes)
on_actionSave_triggered();
}
// if (ui->clipsTableView->checkSaveIfClipsChanged())
// ui->graphicsView->clearAll();
foreach (AGProcessAndThread *process, processes)
{
if ((process->process != nullptr && process->process->state() != QProcess::NotRunning) || (process->jobThread != nullptr && process->jobThread->isRunning()))
{
qDebug()<<"MainWindow::checkExit Killing process"<<"Main"<<process->name<<process->process<<process->jobThread;
process->kill();
}
}
// //check gracefull completion
// int nrOfActiveJobs = 1;
// while (nrOfActiveJobs > 0)
// {
// nrOfActiveJobs = 0;
// foreach (AGProcessAndThread *process, processes)
// {
// if ((process->process != nullptr && process->process->state() != QProcess::NotRunning) || (process->jobThread != nullptr && process->jobThread->isRunning()))
// {
//// qDebug()<<"Runnning"<<process->name;
// nrOfActiveJobs ++;
// }
// }
// }
}
// qDebug()<<"checkexit done"<<exitYes;
return exitYes;
}
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
// qDebug()<<"MainWindow::eventFilter"<<event;
if (!ui->actionTooltips->isChecked())
{
if (event->type() == QEvent::ToolTip)
{
return true;
}
else
{
return QMainWindow::eventFilter(obj, event);
}
}
else
{
return QMainWindow::eventFilter(obj, event);
}
}
void MainWindow::changeUIProperties()
{
//added designer settings
//video/media window
//https://joekuan.files.wordpress.com/2015/09/screen3.png
ui->actionSave->setIcon(style()->standardIcon(QStyle::SP_DriveFDIcon));
ui->actionQuit->setIcon(style()->standardIcon(QStyle::SP_DialogCancelButton));
ui->actionOpen_Folder->setIcon(style()->standardIcon(QStyle::SP_DirOpenIcon));
ui->actionBlack_theme->setIcon(style()->standardIcon(QStyle::SP_MediaStop));
ui->actionWhite_theme->setIcon(style()->standardIcon(QStyle::SP_TitleBarMaxButton));
ui->actionPrevious_in_out->setIcon(style()->standardIcon(QStyle::SP_MediaSkipBackward));
ui->actionNext_in_out->setIcon(style()->standardIcon(QStyle::SP_MediaSkipForward));
ui->actionPlay_Pause->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
// ui->actionPlay_Pause->setDisabled(true);
ui->actionNext_frame->setIcon(style()->standardIcon(QStyle::SP_MediaSeekForward));
ui->actionPrevious_frame->setIcon(style()->standardIcon(QStyle::SP_MediaSeekBackward));
ui->actionIn->setIcon(style()->standardIcon(QStyle::SP_ArrowLeft));
ui->actionOut->setIcon(style()->standardIcon(QStyle::SP_ArrowRight));
ui->actionAlike->setIcon(style()->standardIcon(QStyle::SP_DialogApplyButton));
ui->actionExport->setIcon(style()->standardIcon(QStyle::SP_FileDialogStart));
ui->actionWhatIsNew->setIcon(QIcon(QPixmap::fromImage(QImage(":/MediaSidekick.ico"))));
ui->mediaFileScaleSlider->setStyleSheet("QSlider::sub-page:Horizontal { background-color: #9F2425; }"
"QSlider::add-page:Horizontal { background-color: #333333; }"
"QSlider::groove:Horizontal { background: transparent; height:4px; }"
"QSlider::handle:Horizontal { width:10px; border-radius:5px; background:#9F2425; margin: -5px 0px -5px 0px; }");
ui->clipScaleSlider->setStyleSheet("QSlider::sub-page:Horizontal { background-color: #249f55; }"
"QSlider::add-page:Horizontal { background-color: #333333; }"
"QSlider::groove:Horizontal { background: transparent; height:4px; }"
"QSlider::handle:Horizontal { width:10px; border-radius:5px; background:#249f55; margin: -5px 0px -5px 0px; }");
//https://forum.qt.io/topic/87256/how-to-set-qslider-handle-to-round/3
ui->actionRefresh->setIcon(style()->standardIcon(QStyle::SP_BrowserReload));//SP_DialogCancelButton
ui->actionUndo->setIcon(QIcon(QPixmap::fromImage(QImage(":/images/undo.png"))));
ui->actionRedo->setIcon(QIcon(QPixmap::fromImage(QImage(":/images/redo.png"))));
ui->actionZoom_In->setIcon(QIcon(QPixmap::fromImage(QImage(":/images/zoomin.png"))));
ui->actionZoom_Out->setIcon(QIcon(QPixmap::fromImage(QImage(":/images/zoomout.png"))));
}
void MainWindow::allConnects()
{
// ui->graphicsView1->addNode("folder", 0, 0);
// ui->graphicsView1->addNode("prop", 5, 0);
// ui->graphicsView1->addNode("main", 8, 0);
// ui->graphicsView1->addNode("tf1", 13, 0);
// ui->graphicsView1->addNode("time", 2, 3);
// ui->graphicsView1->addNode("video", 5, 3);
// ui->graphicsView1->addNode("star", 11, 3);
// ui->graphicsView1->addNode("tf2", 13, 3);
// ui->graphicsView1->addNode("files", 0, 6);
// ui->graphicsView1->addNode("clip", 8, 6);
// ui->graphicsView1->addNode("tags", 13, 6);
// ui->graphicsView2->addNode("main", 12, 3);
// ui->graphicsView2->addNode("time", 6, 6);
// ui->graphicsView2->addNode("video", 6, 0);
// ui->graphicsView2->addNode("clip", 0, 3);
// //do not show the graph tab (only in debug mode)
// graphWidget1 = ui->clipsTabWidget->widget(1);
// graphWidget2 = ui->clipsTabWidget->widget(2);
// graphicsWidget = ui->clipsTabWidget->widget(3);
connect(&m_network, SIGNAL(finished(QNetworkReply*)), SLOT(onUpgradeCheckFinished(QNetworkReply*)));
connect(agFileSystem, &AGFileSystem::addItem, ui->graphicsView, &AGView::onAddItem, Qt::BlockingQueuedConnection); //to draw item on scene immediately
connect(agFileSystem, &AGFileSystem::deleteItem, ui->graphicsView, &AGView::onDeleteItem);
connect(agFileSystem, &AGFileSystem::fileChanged, ui->graphicsView, &AGView::onFileChanged);
connect(ui->graphicsView, &AGView::fileWatch, agFileSystem, &AGFileSystem::onFileWatch);
connect(ui->graphicsView, &AGView::showInStatusBar, this, &MainWindow::onShowInStatusBar);
} //allConnects
void MainWindow::loadSettings()
{
QRect savedGeometry = QSettings().value("Geometry").toRect();
if (savedGeometry != geometry())
{
if (savedGeometry.width() != 0)
setGeometry(savedGeometry);
}
// restoreState(QSettings().value("windowState").toByteArray());
if (QSettings().value("tooltipsOn").toString() == "")
ui->actionTooltips->setChecked(true);
else
ui->actionTooltips->setChecked(QSettings().value("tooltipsOn").toBool());
QString viewMode = QSettings().value("viewMode").toString(); //default
bool syncNeeded = false;
if (viewMode == "")
{
QSettings().setValue("viewMode", "SpotView");
syncNeeded = true;
}
QString viewDirection = QSettings().value("viewDirection").toString();
if (viewDirection == "")
{
QSettings().setValue("viewDirection", "Return");
syncNeeded = true;
}
if (syncNeeded)
QSettings().sync();
ui->timelineViewButton->setEnabled(QSettings().value("viewMode") != "TimelineView");
ui->spotviewDownButton->setEnabled((QSettings().value("viewMode") != "SpotView" || QSettings().value("viewDirection") != "Down"));
ui->spotviewRightButton->setEnabled((QSettings().value("viewMode") != "SpotView" || QSettings().value("viewDirection") != "Right"));
ui->spotviewReturnButton->setEnabled((QSettings().value("viewMode") != "SpotView" || QSettings().value("viewDirection") != "Return"));
if (QSettings().value("orderBy").toString() == "")
{
QSettings().setValue("orderBy", "Date");
QSettings().sync();
}
ui->graphicsView->setOrderBy(QSettings().value("orderBy").toString());
ui->orderByDateButton->setEnabled(QSettings().value("orderBy").toString() != "Date");
ui->orderByNameButton->setEnabled(QSettings().value("orderBy").toString() != "Name");
QSettings().value("playerInDialogcheckBox");
if (QSettings().value("playerInDialogcheckBox").toString() == "")
#ifdef Q_OS_WIN
ui->playerInDialogcheckBox->setChecked(false);
#else
ui->playerInDialogcheckBox->setChecked(true);
#endif
else
ui->playerInDialogcheckBox->setChecked(QSettings().value("playerInDialogcheckBox").toBool());
ui->graphicsView->setPlayInDialog(ui->playerInDialogcheckBox->isChecked());
ui->searchLineEdit->setText(QSettings().value("searchLineEdit").toString());
on_searchLineEdit_textChanged(QSettings().value("searchLineEdit").toString());
if (QSettings().value("mediaFileScaleSlider").toInt() == 0)
QSettings().setValue("mediaFileScaleSlider", ui->mediaFileScaleSlider->value()); //default
if (QSettings().value("mediaFileScaleSlider").toInt() != ui->mediaFileScaleSlider->value())
ui->mediaFileScaleSlider->setValue(QSettings().value("mediaFileScaleSlider").toInt());
else
on_mediaFileScaleSlider_valueChanged(QSettings().value("mediaFileScaleSlider").toInt()); //force update of label anyway
if (QSettings().value("clipScaleSlider").toInt() == 0)
QSettings().setValue("clipScaleSlider", ui->clipScaleSlider->value()); //default
if (QSettings().value("clipScaleSlider").toInt() != ui->clipScaleSlider->value())
ui->clipScaleSlider->setValue(QSettings().value("clipScaleSlider").toInt());
else
on_clipScaleSlider_valueChanged(QSettings().value("clipScaleSlider").toInt()); //force update of label anyway
} //loadSettings
void MainWindow::allTooltips()
{
QString commandControl = "Ctrl-";
#ifdef Q_OS_MAC
commandControl = "⌘-";
#endif
//folder and file
ui->mainToolBar->setToolTip(tr("<p><b>Folder</b></p>"
"<p><i>Select a folder containing video files</i></p>"
"<ul>"
"<li>Select folder: After selecting a folder, the files tab is shown and clips, tags and properties of all files are loaded</li>"
"<li>Warning: For movie files with more than 100 clips and if more than 100 files with clips are loaded, a warning is given with the option to skip or cancel.</li>"
"</ul>"));
// ui->videoFilesTreeView->setToolTip(tr("<p><b>File</b></p>"
// "<p><i>Files within the selected folder</i></p>"
// "<ul>"
// "<li><b>Click on file</b>: Show the clips of this file on the timeline and in the clips tab</li>"
// "</ul>"
// ));
//video
// ui->videoWidget->setToolTip(tr("<p><b>Media window</b></p>"
// "<p><i>Video and audio is played here</i></p>"
// "<ul>"
// "<li>Player controls...</li>"
// "<li>Add clips...</li>"
// "</ul>"
// ));
// ui->playButton->setToolTip(tr("<p><b>Play or pause</b></p>"
// "<p><i>Play or pause the video</i></p>"
// "<ul>"
// "<li>Shortcut: Space</li>"
// "</ul>"));
// ui->stopButton->setToolTip(tr("<p><b>Stop the video</b></p>"
// "<p><i>Stop the video</i></p>"
// ));
// ui->skipForwardButton->setToolTip(tr("<p><b>Go to next or previous clip</b></p>"
// "<p><i>Go to next or previous clip</i></p>"
// "<ul>"
// "<li>Shortcut: %1up and %1down</li>"
// "</ul>").arg(commandControl));
// ui->skipBackwardButton->setToolTip(ui->skipForwardButton->toolTip());
// ui->seekBackwardButton->setToolTip(tr("<p><b>Go to next or previous frame</b></p>"
// "<p><i>Go to next or previous frame</i></p>"
// "<ul>"
// "<li>Shortcut: %1left and %1right</li>"
// "</ul>").arg(commandControl));
// ui->seekForwardButton->setToolTip(ui->seekBackwardButton->toolTip());
// ui->setInButton->setToolTip(tr("<p><b>Set in- and out- point</b></p>"
// "<p><i>Set the inpoint of a new clip or change the in- or outpoint of the current clip to the current position on the timeline</i></p>"
// "<ul>"
// "<li>Change: inpoint before outpoint of last selected clip or outpoint after inpoint of last selected clip</li>"
//// "<li>Set: No last selected clip or inpoint after outpoint of last selected clip and outpoint before inpoint of last selected clip</li>"
// "<li>Shortcut: %1i and %1o</li>"
// "</ul>").arg(commandControl));
// ui->setOutButton->setToolTip(ui->setInButton->toolTip());
// ui->muteButton->setToolTip(tr("<p><b>Mute or unmute</b></p>"
// "<p><i>Mute or unmute sound (toggle)</i></p>"
// "<ul>"
// "<li>Video files are muted if selected. Audio files are unmuted if selected</li>"
// "<li>Shortcut mute toggle: %1m</li>"
// "</ul>").arg(commandControl));
// ui->speedComboBox->setToolTip(tr("<p><b>Speed</b></p>"
// "<p><i>Change the play speed of the video</i></p>"
// "<ul>"
// "<li>Supported speeds are depending on the media file codec installed on your computer</li>"
// "</ul>"));
//tt clip filters
foreach (QAction *toolBarAction, ui->mainToolBar->actions())
{
if (toolBarAction->text() == "A&like")
toolBarAction->setToolTip(tr("<p><b>Alike</b></p>"
"<p><i>Check if other clips are 'alike' this clip. This is typically the case with Action-cam footage: multiple shots which are similar.</i></p>"
"<p><i>This is used to exclude similar clips from the exported video.</i></p>"
"<ul>"
"<li>Alike filter checkbox: Show only alike clips</li>"
"<li>Alike column: Set if this clip is like another clip <%1 A></li>"
"<li>Timeline: Only clips which meet the filter criteria are shown in the timeline</li>"
"<li>Hint: Give the best of the alikes a higher rating than the others</li>"
"<li>Hint: Give alike clips the same tags to filter on them later</li>"
"</ul>"
).arg(commandControl));
else if (toolBarAction->toolTip().contains("star"))
toolBarAction->setToolTip(tr("<p><b>Ratings</b></p>"
"<p><i>Give a rating to a clip (0 to 5 stars)</i></p>"
"<ul>"
"<li>Rating filter: Select 0 to 5 stars. All clips with same or higher rating are shown</li>"
"<li>Rating column: Double click to change the rating (or %1 0 to %1 5 to rate the current clip)</li>"
"<li>Timeline: Only clips which meet the filter criteria are shown in the timeline</li>"
"</ul>").arg(commandControl));
}
// ui->tagFilter1ListView->setToolTip(tr("<p><b>Tag filters</b></p>"
// "<p><i>Define which clips are shown based on their tags</i></p>"
// "<ul>"
// "<li>Tag fields: The following logical condition applies: (Left1 or left2 or left3 ...) and (right1 or right2 or right3 ...)</li>"
// "<li>Timeline: Only clips which meet the filter criteria are shown in the timeline</li>"
// "<li>Double click: Remove a tag</li>"
// "</ul>"));
// ui->tagFilter2ListView->setToolTip(ui->tagFilter1ListView->toolTip());
// ui->fileOnlyCheckBox->setToolTip(tr("<p><b>File only</b></p>"
// "<p><i>Show only clips of the selected file</i></p>"
// "<ul>"
// "<li><b>Timeline</b>: If file only is checked, the timeline only shows clips of the selected file</li>"
// "</ul>"));
//tt clips table
// ui->resetSortButton->setToolTip(tr("<p><b>Reset sort</b></p>"
// "<p><i>Set the order of clips back to file order</i></p>"
// ));
// ui->clipsTableView->setToolTip(tr("<p><b>Clips list</b></p>"
// "<p><i>Show the clips for the files in the selected folder</i></p>"
// "<ul>"
// "<li>Only clips applying to the <b>filters</b> above this table are shown</li>"
// "<li>Move over the column headers to see <b>column tooltips</b></li>"
// "<li>Clips belonging to the <b>selected file</b> are highlighted gray</li>"
// "<li>The clip <b>currently shown</b> in the video window is highlighted blue</li>"
// "<li>To <b>delete</b> a clip: right mouse click</li>"
// "<li>To change the <b>order</b> of clips: drag the number on the left of this table up or down</li>"
// "<li>Note: Clips are saved on your filesystems as <b>.srt files</b>. They have the same name as the media file for which the edits are made.</li>"
// "</ul>"
// ));
//tt tags
// ui->newTagLineEdit->setToolTip(tr("<p><b>Tag field</b></p>"
// "<p><i>Create and remove tags</i></p>"
// "<ul>"
// "<li>Add new tag to tag list: fill in tag name and press return</li>"
// "</ul>"
// ));
// ui->tagsListView->setToolTip(tr("<p><b>Tag list</b></p>"
// "<p><i>List of tags used in clips or filter</i></p>"
// "<ul>"
// "<li>Add tag to clip: Drag and drop to tag column of clips</li>"
// "<li>Add tag to filter: Drag and drop to filters</li>"
// "<li>Delete tags: double click (or drag tag and drop in the tag field)</li>"
// "</ul>"
// ));
ui->spotviewDownButton->setToolTip(tr("<p><b>Spot view</b></p>"
"<p><i>Arranges clips below their mediafiles. Best for spotting of clips in mediafiles</i></p>"
"<ul>"
"<li><b>Down ↓</b>: Media files arranged vertically</li>"
"<li><b>Right →</b>: Media files arranged horizontally</li>"
"<li><b>Return ↵</b>: Media files arranged in rows</li>"
"<li><b>Media file duration line</b>: In spot view mode the size of the media file item is aligned with the size of the corresponding clips (with a minimum)</li>"
"</ul>"));
ui->spotviewRightButton->setToolTip(ui->spotviewDownButton->toolTip());
ui->spotviewReturnButton->setToolTip(ui->spotviewDownButton->toolTip());
ui->timelineViewButton->setToolTip(tr("<p><b>Timeline view</b></p>"
"<p><i>Arranges clips next to eachother as they will appear in exports. Best for preparing export</i></p>"
"<ul>"
"<li><b>Transitions</b>: Clips will overlap if there is a transition time (currently defined in classical view)</li>"
"<li><b>Media file duration line</b>: In timeline mode the size of the media file item is the same as the duration line (with a minimum)</li>"
"</ul>"));
ui->orderByDateButton->setToolTip(tr("<p><b>Order mediaitems</b></p>"
"<p><i>Orders media items based on their createdate (if present) or filename</i></p>"
"<ul>"
"<li><b>Date ↓</b>: Order by createdate. If no createdate, order by name. Files without createdate are shown first</li>"
"<li><b>Name ↓</b>: Order by file name</li>"
"</ul>"));
ui->orderByNameButton->setToolTip(ui->orderByDateButton->toolTip());
ui->searchLineEdit->setToolTip(tr("<p><b>Search</b></p>"
"<p><i>Shows only items which meet the search criteria</i></p>"
"<ul>"
"<li><b>Matching</b>: match on the tags of clips and on filename</li>"
"</ul>"));
ui->actionReload->setToolTip(tr("<p><b>(Re)load media</b></p>"
"<p><i>Clears the screen and (re)loads all videos, audios and images from the selected folder %1</i></p>"
"<ul>"
"<li><b>Cancel</b>: During loading, the load process can be cancelled</li>"
"<li><b>File changes</b>: file changes are notified by Media Sidekick and updated in the view directly, no reload needed.</li>"
"</ul>").arg(QSettings().value("selectedFolderName").toString()));
ui->actionRefresh->setToolTip(tr("<p><b>Refresh screen</b></p>"
"<p><i>Redraw all the items of selected folder %1 on the screen</i></p>"
"<ul>"
"<li>Refresh the screen if something is not shown correctly</li>"
"</ul>").arg(QSettings().value("selectedFolderName").toString()));
ui->playerInDialogcheckBox->setToolTip(tr("<p><b>Show video in window</b></p>"
"<p><i>Video can be played in a separate window or at the place where it is located on the screen</i></p>"
"<ul>"
"<li><b>Performace on Mac / OSX</b>: Currently performance of video windows in a graphical view on Mac / OSX is very bad (very high CPU load)</li>"
"</ul>"));
ui->mediaFileScaleSlider->setToolTip(tr("<p><b>Media file scale</b></p>"
"<p><i>Sets the size of the video and audio files based on their duration (pixels per minute)</i></p>"
));
ui->clipScaleSlider->setToolTip(tr("<p><b>Clip and export scale</b></p>"
"<p><i>Sets the size of the clips and exported files based on their duration (pixels per minute)</i></p>"
));
} //tooltips
void MainWindow::on_actionBlack_theme_triggered()
{
// qDebug()<<"on_actionBlack_theme_triggered 1"<<qApp->style()<<QStyleFactory::keys();
qApp->setStyle(QStyleFactory::create("Fusion"));
// qApp->setPalette(QApplication::style()->standardPalette());
// qDebug()<<"on_actionBlack_theme_triggered 1.1";
QColor mainColor = QColor(45,45,45);
QColor disabledColor = QColor(127,127,127);
QColor baseColor = QColor(18,18,18);
QColor linkColor = QColor(42, 130, 218);
QColor linkVisitedColor = QColor(255, 0, 255);
QColor highlightColor = QColor(42, 130, 218);
QColor menuColor = QColor(80,80,80);
QPalette palette;
palette.setColor(QPalette::Window, mainColor);
palette.setColor(QPalette::WindowText, Qt::white);
palette.setColor(QPalette::Base, baseColor);
palette.setColor(QPalette::AlternateBase, mainColor);
palette.setColor(QPalette::ToolTipBase, Qt::white);
palette.setColor(QPalette::ToolTipText, Qt::white);
palette.setColor(QPalette::Text, Qt::white);
palette.setColor(QPalette::Disabled, QPalette::Text, disabledColor);
palette.setColor(QPalette::Button, mainColor);
palette.setColor(QPalette::ButtonText, Qt::white);
palette.setColor(QPalette::Disabled, QPalette::ButtonText, disabledColor);
palette.setColor(QPalette::BrightText, Qt::red);
palette.setColor(QPalette::Link, linkColor);
palette.setColor(QPalette::Link, linkVisitedColor);
palette.setColor(QPalette::Highlight, highlightColor);
palette.setColor(QPalette::HighlightedText, Qt::black);
palette.setColor(QPalette::Disabled, QPalette::HighlightedText, disabledColor);
palette.setColor(QPalette::PlaceholderText, Qt::darkGray);
qApp->setPalette(palette);
// qDebug()<<"MainWindow::on_actionBlack_theme_triggered set palette"<<palette;
qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }");
QSettings().setValue("theme", "Black");
QSettings().sync();
ui->graphicsView->setThemeColors(Qt::white);
}
void MainWindow::on_actionWhite_theme_triggered()
{
// qDebug()<<"on_actionWhite_theme_triggered 1";
qApp->setStyle(QStyleFactory::create("Fusion"));
// qDebug()<<"on_actionWhite_theme_triggered 1.1";
QColor mainColor = QColor(240,240,240);
QColor disabledColor = QColor(127,127,127);
QColor baseColor = QColor(255,255,255);
QColor linkColor = QColor(0, 0, 255);
QColor linkVisitedColor = QColor(255, 0, 255);
QColor highlightColor = QColor(0,120,215);
QColor menuColor = mainColor;
QPalette palette;
palette.setColor(QPalette::Window, mainColor);
palette.setColor(QPalette::WindowText, Qt::black);
palette.setColor(QPalette::Base, baseColor);
palette.setColor(QPalette::AlternateBase, mainColor);
palette.setColor(QPalette::ToolTipBase, Qt::black);
palette.setColor(QPalette::ToolTipText, Qt::black);
palette.setColor(QPalette::Text, Qt::black);
palette.setColor(QPalette::Disabled, QPalette::Text, disabledColor);
palette.setColor(QPalette::Button, mainColor);
palette.setColor(QPalette::ButtonText, Qt::black);
palette.setColor(QPalette::Disabled, QPalette::ButtonText, disabledColor);
palette.setColor(QPalette::BrightText, Qt::red);
palette.setColor(QPalette::Link, linkColor);
palette.setColor(QPalette::LinkVisited, linkVisitedColor);
palette.setColor(QPalette::Highlight, highlightColor);
palette.setColor(QPalette::HighlightedText, Qt::white);
palette.setColor(QPalette::Disabled, QPalette::HighlightedText, disabledColor);
palette.setColor(QPalette::PlaceholderText, Qt::lightGray);
qApp->setPalette(palette);
qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }");
QSettings().setValue("theme", "White");
QSettings().sync();
ui->graphicsView->setThemeColors(Qt::black);
}
void MainWindow::on_actionAbout_triggered()
{
QMessageBox::about(this, tr("About Media Sidekick"),
tr("<p><b>Media Sidekick</b> is a free desktop application aimed at minimizing the time between shooting and publishing videos. Media Sidekick prepares raw video for efficient editing in your preferred video editor. Media Sidekick is tuned for action camera footage having a lot of raw video which needs to compressed to a small video showing the best of it.</p>"
"<p>Version %1</p>"
"<p>Licensed under the: <a href=\"https://www.gnu.org/licenses/lgpl-3.0.html\">GNU Lesser General Public License v3.0</a></p>"
"<p>Copyright © 2019-2020</p>"
"<p><a href=\"https://mediasidekick.org\">Media Sidekick Website</a></p>"
"<p>This program proudly uses the following projects:</p>"
"<ul>"
"<li><a href=\"https://www.qt.io/\">Qt</a> application and UI framework</li>"
// "<li><a href=\"https://www.shotcut.org/\">Shotcut</a> Open source video editor (timeline and version check)</li>"
"<li><a href=\"https://www.ffmpeg.org/\">FFmpeg</a> multimedia format and codec libraries (lossless and encoded previews)</li>"
"<li><a href=\"https://exiftool.org/\">Exiftool</a> Read, Write and Edit Meta Information (Properties)</li>"
"<li><a href=\"https://github.com/banelle/derperview\">Derperview by Banelle</a> Perform non-linear stretch of 4:3 video to make it 16:9. See also <a href=\"https://intofpv.com/t-derperview-a-command-line-superview-alternative\">Derperview - A Command Line Superview Alternative</a></li>"
"<li><a href=\"https://github.com/ytdl-org/youtube-dl\">Youtube-dl</a> download videos from youtube.com or other video platforms</li>"
"</ul>"
"<p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</p>"
"<p>As Media Sidekick may contain bugs, BACKUP your video files before editing!</p>"
"<p>Media Sidekick issuetracker on GitHub <a href=\"https://github.com/ewoudwijma/MediaSidekick/issues\">GitHub Media Sidekick issues</a></p>"
"<p>Media Sidekick is created by <a href=\"https://www.linkedin.com/in/ewoudwijma\">Ewoud Wijma</a>.</p>"
).arg(qApp->applicationVersion()));
}
void MainWindow::on_actionAbout_Qt_triggered()
{
qApp->aboutQt();
}
void MainWindow::on_action5_stars_triggered()
{
ui->graphicsView->processAction("Key_*****");
}
void MainWindow::on_action4_stars_triggered()
{
ui->graphicsView->processAction("Key_****");
}
void MainWindow::on_action1_star_triggered()
{
ui->graphicsView->processAction("Key_*");
}
void MainWindow::on_action2_stars_triggered()
{
ui->graphicsView->processAction("Key_**");
}
void MainWindow::on_action3_stars_triggered()
{
ui->graphicsView->processAction("Key_***");
}
void MainWindow::on_action0_stars_triggered()
{
ui->graphicsView->processAction("Key_*0");
}
void MainWindow::on_actionAlike_triggered()
{
ui->graphicsView->processAction("Key_✔");
}
void MainWindow::on_actionSave_triggered()
{
ui->statusBar->showMessage(tr("%1 changes will be saved").arg(QString::number(qAbs(ui->graphicsView->undoIndex - ui->graphicsView->undoSavePoint))), 5000);
ui->graphicsView->saveModels();
// qDebug()<<"MainWindow::on_actionSave_triggered done";
}
void MainWindow::on_actionPlay_Pause_triggered()
{
ui->graphicsView->processAction("actionPlay_Pause");
}
void MainWindow::on_actionIn_triggered()
{
// qDebug()<<"MainWindow::on_actionIn_triggered"<<ui->clipsTableView->highLightedRow<<ui->videoWidget->m_position;
// ui->videoWidget->onSetIn();
ui->graphicsView->processAction("actionIn");
}
void MainWindow::on_actionOut_triggered()
{
// qDebug()<<"MainWindow::on_actionOut_triggered"<<ui->clipsTableView->highLightedRow<<ui->videoWidget->m_position;
// ui->videoWidget->onSetOut();
ui->graphicsView->processAction("actionOut");
}
void MainWindow::on_actionPrevious_frame_triggered()
{
ui->graphicsView->processAction("actionPrevious_frame");
// ui->videoWidget->rewind();
}
void MainWindow::on_actionNext_frame_triggered()
{
ui->graphicsView->processAction("actionNext_frame");
// ui->videoWidget->fastForward();
}
void MainWindow::on_actionPrevious_in_out_triggered()
{
ui->graphicsView->processAction("actionPrevious_in_out");
// ui->videoWidget->skipPrevious();
}
void MainWindow::on_actionNext_in_out_triggered()
{
ui->graphicsView->processAction("actionNext_in_out");
// ui->videoWidget->skipNext();
}
void MainWindow::on_actionExport_triggered()
{
// ui->exportButton->click();
ui->graphicsView->processAction(__func__);
}
void MainWindow::showUpgradePrompt()
{
QString currentPath = QDir::currentPath();
if (!currentPath.contains("Debug", Qt::CaseInsensitive) && !currentPath.contains("Release", Qt::CaseInsensitive))
{
// ui->statusBar->showMessage("Version check...", 15000);
QNetworkRequest request(QUrl("http://www.mediasidekick.org/version.json"));
QSslConfiguration sslConfig = request.sslConfiguration();
sslConfig.setPeerVerifyMode(QSslSocket::VerifyNone);
request.setSslConfiguration(sslConfig);
m_network.get(request);
}
// else
// qDebug()<<__func__<<"not checking latest version because in " + currentPath;
}
void MainWindow::onUpgradeCheckFinished(QNetworkReply* reply)
{
// qDebug()<<"MainWindow::onUpgradeCheckFinished";
QString m_upgradeUrl = "https://mediasidekick.org/download/";
if (!reply->error())
{
QByteArray response = reply->readAll();
// qDebug() << "response: " << response;
if (response.contains("Bitly"))
{
int indexOfAOpen = response.indexOf("<a href=\"");
int indexOfAClose = response.indexOf("\">");
QString httpString = response.mid(indexOfAOpen + 9, indexOfAClose - indexOfAOpen + 1 - 10);
// qDebug() << "response: " << httpString;
QNetworkRequest request(httpString);
// QNetworkRequest request(QUrl("http://www.mediasidekick.org/version.json"));
m_network.get(request);
return;
}
QJsonParseError *error = new QJsonParseError();
QJsonDocument json = QJsonDocument::fromJson(response, error);
QString current = qApp->applicationVersion();
if (!json.isNull() && json.object().value("version_string").type() == QJsonValue::String)
{
QString latest = json.object().value("version_string").toString();
latestVersionURL = json.object().value("url").toString();
if (current != "adhoc" && QVersionNumber::fromString(current) < QVersionNumber::fromString(latest))
{
if (!json.object().value("url").isUndefined())
m_upgradeUrl = json.object().value("url").toString();
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, "Version check", tr("Media Sidekick version %1 is available! Click Yes to get it.").arg(latest), QMessageBox::Yes|QMessageBox::No);
if (reply == QMessageBox::Yes)
QDesktopServices::openUrl(QUrl(m_upgradeUrl));
} else {
ui->statusBar->showMessage(tr("Version check: You are running the latest version of Media Sidekick."), 15000);
}
reply->deleteLater();
return;
}
// else
// {
// ui->statusBar->showMessage("Version check: failed to parse version.json "+ error->errorString());
// }
} else {
// ui->statusBar->showMessage("Network error " + reply->errorString());
qDebug()<<"MainWindow::onUpgradeCheckFinished"<<"Network error " + reply->errorString();
}
// QMessageBox::StandardButton mreply;
// mreply = QMessageBox::question(this, "Version check", tr("Failed to read version.json when checking. Click here to go to the Web site."), QMessageBox::Yes|QMessageBox::No);
// if (mreply == QMessageBox::Yes)
// QDesktopServices::openUrl(QUrl(m_upgradeUrl));
reply->deleteLater();
}
void MainWindow::on_actionDonate_triggered()
{
QDesktopServices::openUrl(QUrl("https://www.mediasidekick.org/support"));
}
void MainWindow::on_actionCheck_for_updates_triggered()
{
showUpgradePrompt();
}
void MainWindow::on_actionWhatIsNew_triggered()
{
QDesktopServices::openUrl(QUrl(latestVersionURL == ""?"https://mediasidekick.org":latestVersionURL));
// QMessageBox::about(this, tr("About Media Sidekick"),
// tr("<p><h1>Media Sidekick process flow</b></p>"
// "<p>Version %1</p>"
// "<ul>"
// "<li>Select a folder: %2</li>"
// "<li>Create clips: %3 clips created</li>"
// "</ul>"
// ).arg(qApp->applicationVersion(), ui->folderLabel->text(), QString::number(ui->clipsTableView->clipsItemModel->rowCount())));
}
void MainWindow::on_actionGithub_MSK_Issues_triggered()
{
QDesktopServices::openUrl(QUrl("https://github.com/ewoudwijma/MediaSidekick/issues"));
}
void MainWindow::on_actionMute_triggered()
{
// ui->videoWidget->onMute();
ui->graphicsView->processAction("actionMute");
}
void MainWindow::on_actionSpeed_Up_triggered()
{
ui->graphicsView->processAction("actionSpeed_Up");
}
void MainWindow::on_actionSpeed_Down_triggered()
{
ui->graphicsView->processAction("actionSpeed_Down");
}
void MainWindow::on_actionVolume_Up_triggered()
{
ui->graphicsView->processAction("actionVolume_Up");
}
void MainWindow::on_actionVolume_Down_triggered()
{
ui->graphicsView->processAction("actionVolume_Down");
}
void MainWindow::on_actionTooltips_changed()
{
// qDebug()<<"MainWindow::on_actionTooltips_changed"<<ui->actionTooltips->isChecked();
if (QSettings().value("tooltipsOn").toBool() != ui->actionTooltips->isChecked())
{
QSettings().setValue("tooltipsOn", ui->actionTooltips->isChecked());
QSettings().sync();
}
}
void MainWindow::onShowInStatusBar(QString message, int timeout)
{
// qDebug()<<__func__<<message<<timeout;
ui->statusBar->showMessage(message, timeout);
}
int MainWindow::countFolders(QString folderName, int depth)
{
int count = 0;
QDir dir(folderName);
dir.setFilter(QDir::AllDirs| QDir::NoDotAndDotDot | QDir::NoSymLinks);
// qDebug()<<"countFolders"<<folderName<<depth<<dir.entryList().count();
for (int i=0; i < dir.entryList().size(); i++)
{
if (dir.entryList().at(i) != "MSKRecycleBin")
{
count++;
// qDebug()<<"countFolders"<<dir.absolutePath() + "/" + dir.entryList().at(i);
count += countFolders(dir.absolutePath() + "/" + dir.entryList().at(i), depth + 1);
}
}
return count;
}
void MainWindow::checkAndOpenFolder(QString selectedFolderName)
{
int count = countFolders(selectedFolderName);
// qDebug()<<"MainWindow::checkAndOpenFolder"<<selectedFolderName<<count;
if (count > 10)
{
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, "Open Folder", tr("Folder %1 contains %2 sub folders, loading can take a while. Do you still want to continue?").arg(selectedFolderName, QString::number(count)), QMessageBox::Yes|QMessageBox::No);
if (reply != QMessageBox::Yes)
{
selectedFolderName = "";
QSettings().setValue("selectedFolderName", selectedFolderName);
QSettings().sync();