... |
... |
@@ -11,6 +11,7 @@ |
11
|
11
|
#include <QMessageBox>
|
12
|
12
|
#include <QSettings>
|
13
|
13
|
#include <QScrollBar>
|
|
14
|
+#include <QMimeData>
|
14
|
15
|
|
15
|
16
|
#include <freetype/ftdriver.h>
|
16
|
17
|
|
... |
... |
@@ -24,6 +25,7 @@ MainGUI::MainGUI(Engine* engine) |
24
|
25
|
createActions();
|
25
|
26
|
createMenus();
|
26
|
27
|
createStatusBar();
|
|
28
|
+ setupDragDrop();
|
27
|
29
|
|
28
|
30
|
readSettings();
|
29
|
31
|
|
... |
... |
@@ -48,6 +50,37 @@ MainGUI::closeEvent(QCloseEvent* event) |
48
|
50
|
}
|
49
|
51
|
|
50
|
52
|
|
|
53
|
+void
|
|
54
|
+MainGUI::dragEnterEvent(QDragEnterEvent* event)
|
|
55
|
+{
|
|
56
|
+ if (event->mimeData()->hasUrls())
|
|
57
|
+ event->acceptProposedAction();
|
|
58
|
+}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+void
|
|
62
|
+MainGUI::dropEvent(QDropEvent* event)
|
|
63
|
+{
|
|
64
|
+ auto mime = event->mimeData();
|
|
65
|
+ if (!mime->hasUrls())
|
|
66
|
+ return;
|
|
67
|
+
|
|
68
|
+ QStringList fileNames;
|
|
69
|
+ for (auto& url : mime->urls())
|
|
70
|
+ {
|
|
71
|
+ if (!url.isLocalFile())
|
|
72
|
+ continue;
|
|
73
|
+ fileNames.append(url.toLocalFile());
|
|
74
|
+ }
|
|
75
|
+
|
|
76
|
+ if (fileNames.empty())
|
|
77
|
+ return;
|
|
78
|
+
|
|
79
|
+ event->acceptProposedAction();
|
|
80
|
+ openFonts(fileNames);
|
|
81
|
+}
|
|
82
|
+
|
|
83
|
+
|
51
|
84
|
void
|
52
|
85
|
MainGUI::about()
|
53
|
86
|
{
|
... |
... |
@@ -82,8 +115,6 @@ MainGUI::aboutQt() |
82
|
115
|
void
|
83
|
116
|
MainGUI::loadFonts()
|
84
|
117
|
{
|
85
|
|
- int oldSize = engine_->numberOfOpenedFonts();
|
86
|
|
-
|
87
|
118
|
QStringList files = QFileDialog::getOpenFileNames(
|
88
|
119
|
this,
|
89
|
120
|
tr("Load one or more fonts"),
|
... |
... |
@@ -91,8 +122,15 @@ MainGUI::loadFonts() |
91
|
122
|
"",
|
92
|
123
|
NULL,
|
93
|
124
|
QFileDialog::ReadOnly);
|
|
125
|
+ openFonts(files);
|
|
126
|
+}
|
|
127
|
+
|
94
|
128
|
|
95
|
|
- engine_->openFonts(files);
|
|
129
|
+void
|
|
130
|
+MainGUI::openFonts(QStringList const& fileNames)
|
|
131
|
+{
|
|
132
|
+ int oldSize = engine_->numberOfOpenedFonts();
|
|
133
|
+ engine_->openFonts(fileNames);
|
96
|
134
|
|
97
|
135
|
// if we have new fonts, set the current index to the first new one
|
98
|
136
|
if (oldSize < engine_->numberOfOpenedFonts())
|
... |
... |
@@ -903,6 +941,14 @@ MainGUI::createStatusBar() |
903
|
941
|
}
|
904
|
942
|
|
905
|
943
|
|
|
944
|
+void
|
|
945
|
+MainGUI::setupDragDrop()
|
|
946
|
+{
|
|
947
|
+ setAcceptDrops(true);
|
|
948
|
+ glyphView_->setAcceptDrops(false);
|
|
949
|
+}
|
|
950
|
+
|
|
951
|
+
|
906
|
952
|
void
|
907
|
953
|
MainGUI::setDefaults()
|
908
|
954
|
{
|