40
40
#include < QtWidgets/QMenu>
41
41
#include < QtWidgets/QMessageBox>
42
42
#include < QtWidgets/QVBoxLayout>
43
+ #include < QMimeData>
43
44
44
45
#include " quserinterface.h"
45
46
#include " apf/math.h"
@@ -119,6 +120,9 @@ ssr::QUserInterface::QUserInterface(api::Publisher& controller
119
120
// TODO: use screen size for initial window positions
120
121
// QRect screenSize = QApplication::desktop()->screenGeometry();
121
122
setGeometry (200 , 70 , 900 , 700 );
123
+
124
+ setAcceptDrops (true );
125
+
122
126
_controlsParent = new QLabel (this , Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
123
127
_controlsParent->setFixedSize (900 , 75 );
124
128
_controlsParent->move (200 , 780 );
@@ -1191,6 +1195,7 @@ void ssr::QUserInterface::keyPressEvent(QKeyEvent *event)
1191
1195
break ;
1192
1196
case Qt::Key_Return: {_controller.take_control ()->calibrate_tracker (); break ; }
1193
1197
case Qt::Key_Control: {_ctrl_pressed = true ; break ; }
1198
+ case Qt::Key_Shift: {_shift_pressed = true ; break ; }
1194
1199
case Qt::Key_Alt: {_alt_pressed = true ; break ; }
1195
1200
case Qt::Key_F11: {if (!isFullScreen ()) setWindowState (Qt::WindowFullScreen);
1196
1201
else setWindowState ( Qt::WindowNoState );} break ;
@@ -1210,6 +1215,7 @@ void ssr::QUserInterface::keyReleaseEvent(QKeyEvent *event)
1210
1215
switch (event->key ()){
1211
1216
case Qt::Key_Control: {_ctrl_pressed = false ; break ; }
1212
1217
case Qt::Key_Alt: {_alt_pressed = false ; break ; }
1218
+ case Qt::Key_Shift: {_shift_pressed = false ; break ; }
1213
1219
default : ;
1214
1220
}
1215
1221
}
@@ -1226,6 +1232,52 @@ void ssr::QUserInterface::wheelEvent(QWheelEvent *event)
1226
1232
(100 .0f +event->delta ()/100 .f *5 .0f ) + 0 .5f ));
1227
1233
}
1228
1234
1235
+ /* * Handles Qt drag & drop events.
1236
+ * @param event Qt mouse drag enter event.
1237
+ */
1238
+ void ssr::QUserInterface::dragEnterEvent (QDragEnterEvent *event)
1239
+ {
1240
+ // make sure that the drag event contains file paths
1241
+ if (event->mimeData ()->hasUrls ()) event->acceptProposedAction ();
1242
+ // if (event->mimeData()->hasFormat("text/plain"))
1243
+ // event->acceptProposedAction();
1244
+ }
1245
+
1246
+ /* * Handles Qt drag & drop events.
1247
+ * @param event Qt mouse drop event.
1248
+ */
1249
+ void ssr::QUserInterface::dropEvent (QDropEvent *event)
1250
+ {
1251
+ event->acceptProposedAction ();
1252
+
1253
+ const QMimeData* mimeData = event->mimeData ();
1254
+
1255
+ // check for our needed mime type, here a file or a list of files
1256
+ if (mimeData->hasUrls ())
1257
+ {
1258
+ QList<QUrl> urlList = mimeData->urls ();
1259
+
1260
+ QUrl url (urlList.at (0 ));
1261
+
1262
+ VERBOSE (" Dropped file: " <<
1263
+ std::string (url.toString ().toStdString ()));
1264
+
1265
+ // Remove "file://"
1266
+ // this->_load_scene(url.toString().toStdString().substr(7));
1267
+ this ->_load_scene (url.toString ().remove (0 ,7 ));
1268
+
1269
+ // TODO: Add source if more than one file is dragged and dropped.
1270
+ // QStringList pathList;
1271
+ // for (int i = 0; i < urlList.size() && i < 32; +i)
1272
+ // {
1273
+ // pathList.append(urlList.at(i).toLocalFile());
1274
+ // }
1275
+ // call a function to open all files (needs function is yet to be written)
1276
+ // openFiles(pathList);
1277
+
1278
+ }
1279
+ }
1280
+
1229
1281
// / Displays the about window.
1230
1282
void ssr::QUserInterface::_show_about_window ()
1231
1283
{
0 commit comments