From 6ec6b5b3f41dc911c07aa19c25a685ffb64294b4 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 12 Aug 2015 16:34:14 +0200 Subject: [PATCH] GUI: merge: set certain line edits to dropped file names Implements #1344. --- ChangeLog | 5 + src/mkvtoolnix-gui/forms/merge/tab.ui | 153 ++++++++++---------- src/mkvtoolnix-gui/merge/attachments.cpp | 6 +- src/mkvtoolnix-gui/merge/input.cpp | 22 +-- src/mkvtoolnix-gui/merge/output.cpp | 18 +-- src/mkvtoolnix-gui/merge/tab.h | 46 +++--- src/mkvtoolnix-gui/util/basic_line_edit.cpp | 83 +++++++++++ src/mkvtoolnix-gui/util/basic_line_edit.h | 41 ++++++ 8 files changed, 254 insertions(+), 120 deletions(-) create mode 100644 src/mkvtoolnix-gui/util/basic_line_edit.cpp create mode 100644 src/mkvtoolnix-gui/util/basic_line_edit.h diff --git a/ChangeLog b/ChangeLog index a3ae94ccf..05b9c5cce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2015-08-12 Moritz Bunkus + * MKVToolNix GUI: new merge tool feature: dragging & dropping + files onto line edit controls that expect file names (e.g. the + »chapter file« control) will set that line edit's test to the + dropped file name. Implements #1344. + * mkvmerge: bug fix: track statistics tags can be kept with the option »--engage keep_track_statistics_tags«. This allows outputting them in verbose identification mode for easier diff --git a/src/mkvtoolnix-gui/forms/merge/tab.ui b/src/mkvtoolnix-gui/forms/merge/tab.ui index 9b9a0636a..651c6fe7d 100644 --- a/src/mkvtoolnix-gui/forms/merge/tab.ui +++ b/src/mkvtoolnix-gui/forms/merge/tab.ui @@ -396,7 +396,7 @@ - + @@ -526,7 +526,7 @@ - + @@ -834,7 +834,7 @@ - + @@ -859,7 +859,7 @@ - + @@ -884,7 +884,7 @@ - + @@ -1099,7 +1099,7 @@ - + @@ -1479,6 +1479,11 @@
mkvtoolnix-gui/util/files_drag_drop_widget.h
1 + + mtx::gui::Util::BasicLineEdit + QLineEdit +
mkvtoolnix-gui/util/basic_line_edit.h
+
tabs @@ -1587,9 +1592,9 @@ trackName - textEdited(QString) + textChanged(QString) mtx::gui::Merge::Tab - onTrackNameEdited(QString) + onTrackNameChanged(QString) 845 @@ -1683,9 +1688,9 @@ trackTags - textEdited(QString) + textChanged(QString) mtx::gui::Merge::Tab - onTrackTagsEdited(QString) + onTrackTagsChanged(QString) 802 @@ -1701,7 +1706,7 @@ delay textChanged(QString) mtx::gui::Merge::Tab - onDelayEdited(QString) + onDelayChanged(QString) 844 @@ -1717,7 +1722,7 @@ stretchBy textChanged(QString) mtx::gui::Merge::Tab - onStretchByEdited(QString) + onStretchByChanged(QString) 844 @@ -1733,7 +1738,7 @@ defaultDuration editTextChanged(QString) mtx::gui::Merge::Tab - onDefaultDurationEdited(QString) + onDefaultDurationChanged(QString) 844 @@ -1747,9 +1752,9 @@ timecodes - textEdited(QString) + textChanged(QString) mtx::gui::Merge::Tab - onTimecodesEdited(QString) + onTimecodesChanged(QString) 801 @@ -1829,7 +1834,7 @@ aspectRatio editTextChanged(QString) mtx::gui::Merge::Tab - onAspectRatioEdited(QString) + onAspectRatioChanged(QString) 845 @@ -1845,7 +1850,7 @@ aspectRatio currentIndexChanged(QString) mtx::gui::Merge::Tab - onAspectRatioEdited(QString) + onAspectRatioChanged(QString) 845 @@ -1861,7 +1866,7 @@ defaultDuration currentIndexChanged(QString) mtx::gui::Merge::Tab - onDefaultDurationEdited(QString) + onDefaultDurationChanged(QString) 844 @@ -1875,9 +1880,9 @@ displayWidth - textEdited(QString) + textChanged(QString) mtx::gui::Merge::Tab - onDisplayWidthEdited(QString) + onDisplayWidthChanged(QString) 697 @@ -1891,9 +1896,9 @@ displayHeight - textEdited(QString) + textChanged(QString) mtx::gui::Merge::Tab - onDisplayHeightEdited(QString) + onDisplayHeightChanged(QString) 844 @@ -1923,9 +1928,9 @@ cropping - textEdited(QString) + textChanged(QString) mtx::gui::Merge::Tab - onCroppingEdited(QString) + onCroppingChanged(QString) 845 @@ -1971,9 +1976,9 @@ additionalTrackOptions - textEdited(QString) + textChanged(QString) mtx::gui::Merge::Tab - onAdditionalTrackOptionsEdited(QString) + onAdditionalTrackOptionsChanged(QString) 845 @@ -2003,9 +2008,9 @@ title - textEdited(QString) + textChanged(QString) mtx::gui::Merge::Tab - onTitleEdited(QString) + onTitleChanged(QString) 228 @@ -2019,7 +2024,7 @@ output - textEdited(QString) + textChanged(QString) mtx::gui::Merge::Tab setDestination(QString) @@ -2035,9 +2040,9 @@ globalTags - textEdited(QString) + textChanged(QString) mtx::gui::Merge::Tab - onGlobalTagsEdited(QString) + onGlobalTagsChanged(QString) 229 @@ -2051,9 +2056,9 @@ segmentInfo - textEdited(QString) + textChanged(QString) mtx::gui::Merge::Tab - onSegmentInfoEdited(QString) + onSegmentInfoChanged(QString) 333 @@ -2147,9 +2152,9 @@ segmentUIDs - textEdited(QString) + textChanged(QString) mtx::gui::Merge::Tab - onSegmentUIDsEdited(QString) + onSegmentUIDsChanged(QString) 740 @@ -2163,9 +2168,9 @@ previousSegmentUID - textEdited(QString) + textChanged(QString) mtx::gui::Merge::Tab - onPreviousSegmentUIDEdited(QString) + onPreviousSegmentUIDChanged(QString) 740 @@ -2179,9 +2184,9 @@ nextSegmentUID - textEdited(QString) + textChanged(QString) mtx::gui::Merge::Tab - onNextSegmentUIDEdited(QString) + onNextSegmentUIDChanged(QString) 740 @@ -2195,9 +2200,9 @@ chapters - textEdited(QString) + textChanged(QString) mtx::gui::Merge::Tab - onChaptersEdited(QString) + onChaptersChanged(QString) 829 @@ -2259,7 +2264,7 @@ chapterCueNameFormat - textEdited(QString) + textChanged(QString) mtx::gui::Merge::Tab onChapterCueNameFormatChanged(QString) @@ -2291,9 +2296,9 @@ additionalOptions - textEdited(QString) + textChanged(QString) mtx::gui::Merge::Tab - onAdditionalOptionsEdited(QString) + onAdditionalOptionsChanged(QString) 781 @@ -2323,9 +2328,9 @@ attachmentName - textEdited(QString) + textChanged(QString) mtx::gui::Merge::Tab - onAttachmentNameEdited(QString) + onAttachmentNameChanged(QString) 205 @@ -2341,7 +2346,7 @@ attachmentMIMEType editTextChanged(QString) mtx::gui::Merge::Tab - onAttachmentMIMETypeEdited(QString) + onAttachmentMIMETypeChanged(QString) 186 @@ -2357,7 +2362,7 @@ attachmentMIMEType currentIndexChanged(QString) mtx::gui::Merge::Tab - onAttachmentMIMETypeEdited(QString) + onAttachmentMIMETypeChanged(QString) 186 @@ -2371,9 +2376,9 @@ attachmentDescription - textEdited(QString) + textChanged(QString) mtx::gui::Merge::Tab - onAttachmentDescriptionEdited(QString) + onAttachmentDescriptionChanged(QString) 634 @@ -2485,7 +2490,7 @@ splitOptions editTextChanged(QString) mtx::gui::Merge::Tab - onSplitOptionsEdited(QString) + onSplitOptionsChanged(QString) 451 @@ -2551,10 +2556,10 @@ onAddAttachment() onAddFiles() onAddToJobQueue() - onAspectRatioEdited(QString) - onAttachmentDescriptionEdited(QString) - onAttachmentMIMETypeEdited(QString) - onAttachmentNameEdited(QString) + onAspectRatioChanged(QString) + onAttachmentDescriptionChanged(QString) + onAttachmentMIMETypeChanged(QString) + onAttachmentNameChanged(QString) onAttachmentSelectionChanged() onAttachmentStyleChanged(int) onBrowseChapters() @@ -2566,48 +2571,48 @@ onChapterCharacterSetChanged(QString) onChapterCueNameFormatChanged(QString) onChapterLanguageChanged(int) - onChaptersEdited(QString) + onChaptersChanged(QString) onCompressionChanged(int) - onCroppingEdited(QString) + onCroppingChanged(QString) onCuesChanged(int) - onDefaultDurationEdited(QString) + onDefaultDurationChanged(QString) onDefaultTrackFlagChanged(int) - onDelayEdited(QString) - onDisplayHeightEdited(QString) - onDisplayWidthEdited(QString) + onDelayChanged(QString) + onDisplayHeightChanged(QString) + onDisplayWidthChanged(QString) onEditAdditionalOptions() onFilesContextMenu() onForcedTrackFlagChanged(int) - onGlobalTagsEdited(QString) + onGlobalTagsChanged(QString) onLinkFilesClicked(bool) onMuxThisChanged(int) onNew() - onNextSegmentUIDEdited(QString) + onNextSegmentUIDChanged(QString) onOpenConfig() setDestination(QString) - onPreviousSegmentUIDEdited(QString) + onPreviousSegmentUIDChanged(QString) onRemoveAttachments() onSaveConfig() onSaveConfigAs() - onSegmentUIDsEdited(QString) - onSegmentInfoEdited(QString) + onSegmentUIDsChanged(QString) + onSegmentInfoChanged(QString) onSetAspectRatio() onSetDisplayDimensions() onSplitMaxFilesChanged(int) onSplitModeChanged(int) - onSplitOptionsEdited(QString) + onSplitOptionsChanged(QString) onStartMuxing() onStereoscopyChanged(int) - onStretchByEdited(QString) + onStretchByChanged(QString) onSubtitleCharacterSetChanged(int) - onTimecodesEdited(QString) - onTitleEdited(QString) + onTimecodesChanged(QString) + onTitleChanged(QString) onTrackLanguageChanged(int) - onTrackNameEdited(QString) - onTrackTagsEdited(QString) + onTrackNameChanged(QString) + onTrackTagsChanged(QString) onTracksContextMenu() - onAdditionalOptionsEdited(QString) - onAdditionalTrackOptionsEdited(QString) + onAdditionalOptionsChanged(QString) + onAdditionalTrackOptionsChanged(QString) onWebmClicked(bool) resizeAttachmentsColumnsToContents() resizeFilesColumnsToContents() diff --git a/src/mkvtoolnix-gui/merge/attachments.cpp b/src/mkvtoolnix-gui/merge/attachments.cpp index 75cc213fe..7e86c8a89 100644 --- a/src/mkvtoolnix-gui/merge/attachments.cpp +++ b/src/mkvtoolnix-gui/merge/attachments.cpp @@ -83,17 +83,17 @@ Tab::selectAttachments(QList const &attachments) { } void -Tab::onAttachmentNameEdited(QString newValue) { +Tab::onAttachmentNameChanged(QString newValue) { withSelectedAttachments([&](Attachment *attachment) { attachment->m_name = newValue; }); } void -Tab::onAttachmentDescriptionEdited(QString newValue) { +Tab::onAttachmentDescriptionChanged(QString newValue) { withSelectedAttachments([&](Attachment *attachment) { attachment->m_description = newValue; }); } void -Tab::onAttachmentMIMETypeEdited(QString newValue) { +Tab::onAttachmentMIMETypeChanged(QString newValue) { withSelectedAttachments([&](Attachment *attachment) { attachment->m_MIMEType = newValue; }); } diff --git a/src/mkvtoolnix-gui/merge/input.cpp b/src/mkvtoolnix-gui/merge/input.cpp index 65d6b4df3..c2bd68a87 100644 --- a/src/mkvtoolnix-gui/merge/input.cpp +++ b/src/mkvtoolnix-gui/merge/input.cpp @@ -504,7 +504,7 @@ Tab::withSelectedTracks(std::function code, } void -Tab::onTrackNameEdited(QString newValue) { +Tab::onTrackNameChanged(QString newValue) { withSelectedTracks([&](Track *track) { track->m_name = newValue; }, true); } @@ -619,27 +619,27 @@ Tab::onCompressionChanged(int newValue) { } void -Tab::onTrackTagsEdited(QString newValue) { +Tab::onTrackTagsChanged(QString newValue) { withSelectedTracks([&](Track *track) { track->m_tags = newValue; }, true); } void -Tab::onDelayEdited(QString newValue) { +Tab::onDelayChanged(QString newValue) { withSelectedTracks([&](Track *track) { track->m_delay = newValue; }); } void -Tab::onStretchByEdited(QString newValue) { +Tab::onStretchByChanged(QString newValue) { withSelectedTracks([&](Track *track) { track->m_stretchBy = newValue; }); } void -Tab::onDefaultDurationEdited(QString newValue) { +Tab::onDefaultDurationChanged(QString newValue) { withSelectedTracks([&](Track *track) { track->m_defaultDuration = newValue; }, true); } void -Tab::onTimecodesEdited(QString newValue) { +Tab::onTimecodesChanged(QString newValue) { withSelectedTracks([&](Track *track) { track->m_timecodes = newValue; }); } @@ -673,17 +673,17 @@ Tab::onSetDisplayDimensions() { } void -Tab::onAspectRatioEdited(QString newValue) { +Tab::onAspectRatioChanged(QString newValue) { withSelectedTracks([&](Track *track) { track->m_aspectRatio = newValue; }, true); } void -Tab::onDisplayWidthEdited(QString newValue) { +Tab::onDisplayWidthChanged(QString newValue) { withSelectedTracks([&](Track *track) { track->m_displayWidth = newValue; }, true); } void -Tab::onDisplayHeightEdited(QString newValue) { +Tab::onDisplayHeightChanged(QString newValue) { withSelectedTracks([&](Track *track) { track->m_displayHeight = newValue; }, true); } @@ -708,7 +708,7 @@ Tab::onNaluSizeLengthChanged(int newValue) { } void -Tab::onCroppingEdited(QString newValue) { +Tab::onCroppingChanged(QString newValue) { withSelectedTracks([&](Track *track) { track->m_cropping = newValue; }, true); } @@ -747,7 +747,7 @@ Tab::onCuesChanged(int newValue) { } void -Tab::onAdditionalTrackOptionsEdited(QString newValue) { +Tab::onAdditionalTrackOptionsChanged(QString newValue) { withSelectedTracks([&](Track *track) { track->m_additionalOptions = newValue; }, true); } diff --git a/src/mkvtoolnix-gui/merge/output.cpp b/src/mkvtoolnix-gui/merge/output.cpp index 67cc11cd1..f3082c4d0 100644 --- a/src/mkvtoolnix-gui/merge/output.cpp +++ b/src/mkvtoolnix-gui/merge/output.cpp @@ -155,7 +155,7 @@ Tab::setupOutputToolTips() { } void -Tab::onTitleEdited(QString newValue) { +Tab::onTitleChanged(QString newValue) { m_config.m_title = newValue; } @@ -205,7 +205,7 @@ Tab::onBrowseOutput() { } void -Tab::onGlobalTagsEdited(QString newValue) { +Tab::onGlobalTagsChanged(QString newValue) { m_config.m_globalTags = newValue; } @@ -217,7 +217,7 @@ Tab::onBrowseGlobalTags() { } void -Tab::onSegmentInfoEdited(QString newValue) { +Tab::onSegmentInfoChanged(QString newValue) { m_config.m_segmentInfo = newValue; } @@ -348,7 +348,7 @@ Tab::onSplitModeChanged(int newMode) { } void -Tab::onSplitOptionsEdited(QString newValue) { +Tab::onSplitOptionsChanged(QString newValue) { m_config.m_splitOptions = newValue; } @@ -363,22 +363,22 @@ Tab::onSplitMaxFilesChanged(int newValue) { } void -Tab::onSegmentUIDsEdited(QString newValue) { +Tab::onSegmentUIDsChanged(QString newValue) { m_config.m_segmentUIDs = newValue; } void -Tab::onPreviousSegmentUIDEdited(QString newValue) { +Tab::onPreviousSegmentUIDChanged(QString newValue) { m_config.m_previousSegmentUID = newValue; } void -Tab::onNextSegmentUIDEdited(QString newValue) { +Tab::onNextSegmentUIDChanged(QString newValue) { m_config.m_nextSegmentUID = newValue; } void -Tab::onChaptersEdited(QString newValue) { +Tab::onChaptersChanged(QString newValue) { m_config.m_chapters = newValue; } @@ -418,7 +418,7 @@ Tab::onWebmClicked(bool newValue) { } void -Tab::onAdditionalOptionsEdited(QString newValue) { +Tab::onAdditionalOptionsChanged(QString newValue) { m_config.m_additionalOptions = newValue; } diff --git a/src/mkvtoolnix-gui/merge/tab.h b/src/mkvtoolnix-gui/merge/tab.h index af87d987b..3dba8498e 100644 --- a/src/mkvtoolnix-gui/merge/tab.h +++ b/src/mkvtoolnix-gui/merge/tab.h @@ -102,34 +102,34 @@ public slots: virtual void setupMoveUpDownButtons(); virtual void enableMoveFilesButtons(); - virtual void onTrackNameEdited(QString newValue); + virtual void onTrackNameChanged(QString newValue); virtual void onTrackItemChanged(QStandardItem *item); virtual void onMuxThisChanged(int selected); virtual void onTrackLanguageChanged(int newValue); virtual void onDefaultTrackFlagChanged(int newValue); virtual void onForcedTrackFlagChanged(int newValue); virtual void onCompressionChanged(int newValue); - virtual void onTrackTagsEdited(QString newValue); - virtual void onDelayEdited(QString newValue); - virtual void onStretchByEdited(QString newValue); - virtual void onDefaultDurationEdited(QString newValue); - virtual void onTimecodesEdited(QString newValue); + virtual void onTrackTagsChanged(QString newValue); + virtual void onDelayChanged(QString newValue); + virtual void onStretchByChanged(QString newValue); + virtual void onDefaultDurationChanged(QString newValue); + virtual void onTimecodesChanged(QString newValue); virtual void onBrowseTimecodes(); virtual void onFixBitstreamTimingInfoChanged(bool newValue); virtual void onBrowseTrackTags(); virtual void onSetAspectRatio(); virtual void onSetDisplayDimensions(); - virtual void onAspectRatioEdited(QString newValue); - virtual void onDisplayWidthEdited(QString newValue); - virtual void onDisplayHeightEdited(QString newValue); + virtual void onAspectRatioChanged(QString newValue); + virtual void onDisplayWidthChanged(QString newValue); + virtual void onDisplayHeightChanged(QString newValue); virtual void onStereoscopyChanged(int newValue); virtual void onNaluSizeLengthChanged(int newValue); - virtual void onCroppingEdited(QString newValue); + virtual void onCroppingChanged(QString newValue); virtual void onAacIsSBRChanged(int newValue); virtual void onReduceAudioToCoreChanged(bool newValue); virtual void onSubtitleCharacterSetChanged(int newValue); virtual void onCuesChanged(int newValue); - virtual void onAdditionalTrackOptionsEdited(QString newValue); + virtual void onAdditionalTrackOptionsChanged(QString newValue); virtual void resizeFilesColumnsToContents() const; virtual void resizeTracksColumnsToContents() const; @@ -153,33 +153,33 @@ public slots: virtual void clearTitle(); virtual void clearTitleMaybe(); - virtual void onTitleEdited(QString newValue); + virtual void onTitleChanged(QString newValue); virtual void onBrowseOutput(); - virtual void onGlobalTagsEdited(QString newValue); + virtual void onGlobalTagsChanged(QString newValue); virtual void onBrowseGlobalTags(); - virtual void onSegmentInfoEdited(QString newValue); + virtual void onSegmentInfoChanged(QString newValue); virtual void onBrowseSegmentInfo(); virtual void onSplitModeChanged(int newMode); - virtual void onSplitOptionsEdited(QString newValue); + virtual void onSplitOptionsChanged(QString newValue); virtual void onLinkFilesClicked(bool newValue); virtual void onSplitMaxFilesChanged(int newValue); - virtual void onSegmentUIDsEdited(QString newValue); - virtual void onPreviousSegmentUIDEdited(QString newValue); - virtual void onNextSegmentUIDEdited(QString newValue); - virtual void onChaptersEdited(QString newValue); + virtual void onSegmentUIDsChanged(QString newValue); + virtual void onPreviousSegmentUIDChanged(QString newValue); + virtual void onNextSegmentUIDChanged(QString newValue); + virtual void onChaptersChanged(QString newValue); virtual void onBrowseChapters(); virtual void onChapterLanguageChanged(int newValue); virtual void onChapterCharacterSetChanged(QString newValue); virtual void onChapterCueNameFormatChanged(QString newValue); virtual void onWebmClicked(bool newValue); - virtual void onAdditionalOptionsEdited(QString newValue); + virtual void onAdditionalOptionsChanged(QString newValue); virtual void onEditAdditionalOptions(); // Attachments tab: virtual void onAttachmentSelectionChanged(); - virtual void onAttachmentNameEdited(QString newValue); - virtual void onAttachmentDescriptionEdited(QString newValue); - virtual void onAttachmentMIMETypeEdited(QString newValue); + virtual void onAttachmentNameChanged(QString newValue); + virtual void onAttachmentDescriptionChanged(QString newValue); + virtual void onAttachmentMIMETypeChanged(QString newValue); virtual void onAttachmentStyleChanged(int newValue); virtual void onAddAttachments(); virtual void onRemoveAttachments(); diff --git a/src/mkvtoolnix-gui/util/basic_line_edit.cpp b/src/mkvtoolnix-gui/util/basic_line_edit.cpp new file mode 100644 index 000000000..8c492d782 --- /dev/null +++ b/src/mkvtoolnix-gui/util/basic_line_edit.cpp @@ -0,0 +1,83 @@ +#include "common/common_pch.h" + +#include +#include + +#include "common/list_utils.h" +#include "mkvtoolnix-gui/util/basic_line_edit.h" + +namespace mtx { namespace gui { namespace Util { + +using namespace mtx::gui; + +class BasicLineEditPrivate { + friend class BasicLineEdit; + + bool m_acceptDroppedFiles{true}, m_setTextToDroppedFileName{true}; + FilesDragDropHandler m_filesDDHandler{FilesDragDropHandler::Mode::Remember}; +}; + +BasicLineEdit::BasicLineEdit(QWidget *parent) + : QLineEdit{parent} + , d_ptr{new BasicLineEditPrivate} +{ +} + +BasicLineEdit::~BasicLineEdit() { +} + +BasicLineEdit & +BasicLineEdit::acceptDroppedFiles(bool enable) { + Q_D(BasicLineEdit); + + d->m_acceptDroppedFiles = enable; + return *this; +} + +BasicLineEdit & +BasicLineEdit::setTextToDroppedFileName(bool enable) { + Q_D(BasicLineEdit); + + d->m_setTextToDroppedFileName = enable; + return *this; +} + +void +BasicLineEdit::dragEnterEvent(QDragEnterEvent *event) { + Q_D(BasicLineEdit); + + if (d->m_acceptDroppedFiles && d->m_filesDDHandler.handle(event, false)) + return; + + QLineEdit::dragEnterEvent(event); +} + +void +BasicLineEdit::dragMoveEvent(QDragMoveEvent *event) { + Q_D(BasicLineEdit); + + if (d->m_acceptDroppedFiles && d->m_filesDDHandler.handle(event, false)) + return; + + QLineEdit::dragMoveEvent(event); +} + +void +BasicLineEdit::dropEvent(QDropEvent *event) { + Q_D(BasicLineEdit); + + if (d->m_acceptDroppedFiles && d->m_filesDDHandler.handle(event, true)) { + auto fileNames = d->m_filesDDHandler.fileNames(); + + if (d->m_setTextToDroppedFileName && !fileNames.isEmpty()) + setText(fileNames[0]); + + emit filesDropped(fileNames); + + return; + } + + QLineEdit::dropEvent(event); +} + +}}} diff --git a/src/mkvtoolnix-gui/util/basic_line_edit.h b/src/mkvtoolnix-gui/util/basic_line_edit.h new file mode 100644 index 000000000..84a8e444d --- /dev/null +++ b/src/mkvtoolnix-gui/util/basic_line_edit.h @@ -0,0 +1,41 @@ +#ifndef MTX_MKVTOOLNIX_GUI_UTIL_BASIC_LINE_EDIT_H +#define MTX_MKVTOOLNIX_GUI_UTIL_BASIC_LINE_EDIT_H + +#include "common/common_pch.h" + +#include + +#include "mkvtoolnix-gui/util/files_drag_drop_handler.h" + +class QDragEnterEvent; +class QDragMoveEvent; +class QDropEvent; + +namespace mtx { namespace gui { namespace Util { + +class BasicLineEditPrivate; +class BasicLineEdit : public QLineEdit { + Q_OBJECT; + Q_DECLARE_PRIVATE(BasicLineEdit); + + QScopedPointer const d_ptr; + +public: + BasicLineEdit(QWidget *parent); + virtual ~BasicLineEdit(); + + BasicLineEdit &acceptDroppedFiles(bool enable); + BasicLineEdit &setTextToDroppedFileName(bool enable); + +signals: + void filesDropped(QStringList const &fileNames); + +protected: + virtual void dragEnterEvent(QDragEnterEvent *event) override; + virtual void dragMoveEvent(QDragMoveEvent *event) override; + virtual void dropEvent(QDropEvent *event) override; +}; + +}}} + +#endif // MTX_MKVTOOLNIX_GUI_UTIL_BASIC_LINE_EDIT_H