3 // Copyright (C) 2012-2019 by Werner Lemberg.
5 // This file is part of the ttfautohint library, and may only be used,
6 // modified, and distributed under the terms given in `COPYING'. By
7 // continuing to use, modify, or distribute this file you indicate that you
8 // have read `COPYING' and understand and accept it fully.
10 // The file `COPYING' mentioned in the previous paragraph is distributed
11 // with the ttfautohint library.
14 // Derived class `Drag_Drop_Line_Edit' is Tooltip_Line_Edit
15 // that accepts drag and drop.
19 #include "ddlineedit.h"
21 Drag_Drop_Line_Edit::Drag_Drop_Line_Edit(Drag_Drop_File_Type ft
,
23 : Tooltip_Line_Edit(parent
),
30 // XXX: There are no standardized MIME types for TTFs and TTCs
31 // that work everywhere. So we rely on the extension.
34 Drag_Drop_Line_Edit::dragEnterEvent(QDragEnterEvent
* event
)
39 if (event
->mimeData()->hasUrls())
41 url_list
= event
->mimeData()->urls();
43 // if just text was dropped, url_list is empty
46 file_name
= url_list
[0].toLocalFile();
50 case DRAG_DROP_TRUETYPE
:
51 if (file_name
.endsWith(".ttf")
52 || file_name
.endsWith(".TTF")
53 || file_name
.endsWith(".ttc")
54 || file_name
.endsWith(".TTC"))
55 event
->acceptProposedAction();
59 event
->acceptProposedAction();
68 Drag_Drop_Line_Edit::dropEvent(QDropEvent
* event
)
74 if (event
->mimeData()->hasUrls())
76 url_list
= event
->mimeData()->urls();
78 // if just text was dropped, url_list is empty
81 file_name
= url_list
[0].toLocalFile();
83 // check whether `file_name' is valid
84 info
.setFile(file_name
);
90 event
->acceptProposedAction();
93 // end of ddlineedit.cpp