Skip to content

Commit

Permalink
GUI: Allow dropping video files onto the window
Browse files Browse the repository at this point in the history
  • Loading branch information
cantabile committed Jul 30, 2016
1 parent 47d6745 commit a31f414
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/GUIWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ GUIWindow::GUIWindow(QWidget *parent)
qRegisterMetaType<D2V>();


setAcceptDrops(true);


setWindowTitle("D2V Witch v" PACKAGE_VERSION);


Expand Down Expand Up @@ -1086,6 +1089,43 @@ void GUIWindow::createVapourSynthFilterChain() {
}


void GUIWindow::dragEnterEvent(QDragEnterEvent *event) {
if (event->mimeData()->hasUrls())
event->acceptProposedAction();
}


void GUIWindow::dropEvent(QDropEvent *event) {
QList<QUrl> urls = event->mimeData()->urls();

QStringList paths;
paths.reserve(urls.size());

for (int i = 0; i < urls.size(); i++)
if (urls[i].isLocalFile())
paths.push_back(urls[i].toLocalFile());

if (!paths.size())
return;

paths.sort();

fake_file.close();

for (int i = 0; i < paths.size(); i++) {
input_list->addItem(paths[i]);
fake_file.push_back(paths[i].toStdString());
}


clearUserInterface();

inputFilesUpdated();

event->acceptProposedAction();
}


IndexingWorker::IndexingWorker(const QString &_d2v_file_name, FILE *_d2v_file, const D2V::AudioFilesMap &_audio_files, FakeFile *_fake_file, FFMPEG *_f, AVStream *_video_stream, D2V::ColourRange _input_range, GUIWindow *_window)
: d2v(_d2v_file_name.toStdString(), _d2v_file, _audio_files, _fake_file, _f, _video_stream, _input_range, ::updateProgress, _window, ::logMessage, _window)
{
Expand Down
2 changes: 2 additions & 0 deletions src/GUIWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ class GUIWindow : public QMainWindow {
void initialiseVapourSynth();
void freeVapourSynth();
void createVapourSynthFilterChain();
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);

public:
explicit GUIWindow(QWidget *parent = 0);
Expand Down

0 comments on commit a31f414

Please sign in to comment.