summaryrefslogtreecommitdiff
path: root/src/citra_qt/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/citra_qt/main.cpp')
-rw-r--r--src/citra_qt/main.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index 3c2e19344..3c1ae8848 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -54,7 +54,7 @@ Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
54 54
55GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) { 55GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) {
56 Pica::g_debug_context = Pica::DebugContext::Construct(); 56 Pica::g_debug_context = Pica::DebugContext::Construct();
57 57 setAcceptDrops(true);
58 ui.setupUi(this); 58 ui.setupUi(this);
59 statusBar()->hide(); 59 statusBar()->hide();
60 60
@@ -625,6 +625,40 @@ void GMainWindow::closeEvent(QCloseEvent* event) {
625 QWidget::closeEvent(event); 625 QWidget::closeEvent(event);
626} 626}
627 627
628bool IsSingleFileDropEvent(QDropEvent* event) {
629 const QMimeData* mimeData = event->mimeData();
630 return mimeData->hasUrls() && mimeData->urls().length() == 1;
631}
632
633void GMainWindow::dropEvent(QDropEvent* event) {
634 if (IsSingleFileDropEvent(event) && ConfirmChangeGame()) {
635 const QMimeData* mimeData = event->mimeData();
636 QString filename = mimeData->urls().at(0).toLocalFile();
637 BootGame(filename.toStdString());
638 }
639}
640
641void GMainWindow::dragEnterEvent(QDragEnterEvent* event) {
642 if (IsSingleFileDropEvent(event)) {
643 event->acceptProposedAction();
644 }
645}
646
647void GMainWindow::dragMoveEvent(QDragMoveEvent* event) {
648 event->acceptProposedAction();
649}
650
651bool GMainWindow::ConfirmChangeGame() {
652 if (emu_thread == nullptr)
653 return true;
654
655 auto answer = QMessageBox::question(
656 this, tr("Citra"),
657 tr("Are you sure you want to stop the emulation? Any unsaved progress will be lost."),
658 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
659 return answer != QMessageBox::No;
660}
661
628#ifdef main 662#ifdef main
629#undef main 663#undef main
630#endif 664#endif