3 // Copyright (C) 2012 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 QLineEdit
15 // which accepts drag and drop.
19 #include "ddlineedit.h"
21 Drag_Drop_Line_Edit::Drag_Drop_Line_Edit(QWidget
* parent
)
28 // XXX: There are no standardized MIME types for TTFs and TTCs
29 // which work everywhere. So we rely on the extension.
32 Drag_Drop_Line_Edit::dragEnterEvent(QDragEnterEvent
* event
)
37 if (event
->mimeData()->hasUrls())
39 url_list
= event
->mimeData()->urls();
41 // if just text was dropped, url_list is empty
44 file_name
= url_list
[0].toLocalFile();
46 if (file_name
.endsWith(".ttf")
47 || file_name
.endsWith(".TTF")
48 || file_name
.endsWith(".ttc")
49 || file_name
.endsWith(".TTC"))
50 event
->acceptProposedAction();
57 Drag_Drop_Line_Edit::dropEvent(QDropEvent
* event
)
63 if (event
->mimeData()->hasUrls())
65 url_list
= event
->mimeData()->urls();
67 // if just text was dropped, url_list is empty
70 file_name
= url_list
[0].toLocalFile();
72 // check whether `file_name' is valid
73 info
.setFile(file_name
);
79 event
->acceptProposedAction();
82 // end of ddlineedit.cpp