summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/citra_qt/main.cpp36
-rw-r--r--src/citra_qt/main.h6
2 files changed, 41 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
diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h
index a2fd45c47..102fd151d 100644
--- a/src/citra_qt/main.h
+++ b/src/citra_qt/main.h
@@ -110,6 +110,7 @@ private:
110 * @return true if the user confirmed 110 * @return true if the user confirmed
111 */ 111 */
112 bool ConfirmClose(); 112 bool ConfirmClose();
113 bool ConfirmChangeGame();
113 void closeEvent(QCloseEvent* event) override; 114 void closeEvent(QCloseEvent* event) override;
114 115
115private slots: 116private slots:
@@ -155,6 +156,11 @@ private:
155 WaitTreeWidget* waitTreeWidget; 156 WaitTreeWidget* waitTreeWidget;
156 157
157 QAction* actions_recent_files[max_recent_files_item]; 158 QAction* actions_recent_files[max_recent_files_item];
159
160protected:
161 void dropEvent(QDropEvent* event) override;
162 void dragEnterEvent(QDragEnterEvent* event) override;
163 void dragMoveEvent(QDragMoveEvent* event) override;
158}; 164};
159 165
160#endif // _CITRA_QT_MAIN_HXX_ 166#endif // _CITRA_QT_MAIN_HXX_