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 `Line_Edit' is QLineEdit which accepts drag and drop.
20 Line_Edit::Line_Edit(QWidget
* parent
)
27 // XXX: There are no standardized MIME types for TTFs and TTCs
28 // which work everywhere. So we rely on the extension.
31 Line_Edit::dragEnterEvent(QDragEnterEvent
* event
)
36 if (event
->mimeData()->hasUrls())
38 url_list
= event
->mimeData()->urls();
40 // if just text was dropped, url_list is empty
43 file_name
= url_list
[0].toLocalFile();
45 if (file_name
.endsWith(".ttf")
46 || file_name
.endsWith(".TTF")
47 || file_name
.endsWith(".ttc")
48 || file_name
.endsWith(".TTC"))
49 event
->acceptProposedAction();
56 Line_Edit::dropEvent(QDropEvent
* event
)
62 if (event
->mimeData()->hasUrls())
64 url_list
= event
->mimeData()->urls();
66 // if just text was dropped, url_list is empty
69 file_name
= url_list
[0].toLocalFile();
71 // check whether `file_name' is valid
72 info
.setFile(file_name
);
78 event
->acceptProposedAction();
81 // end of lineedit.cpp