summaryrefslogtreecommitdiffstats
path: root/src/citra_qt
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2017-02-17 02:22:26 +0100
committerGitHub <noreply@github.com>2017-02-17 02:22:26 +0100
commit0c28f5dea617e492314a28bd1c754348734a3093 (patch)
tree45622934bd7a7bef6cbadf016bec1752b04be52f /src/citra_qt
parentMerge pull request #2571 from wwylele/missing-file (diff)
parentadded drag n drop feature (diff)
downloadyuzu-0c28f5dea617e492314a28bd1c754348734a3093.tar
yuzu-0c28f5dea617e492314a28bd1c754348734a3093.tar.gz
yuzu-0c28f5dea617e492314a28bd1c754348734a3093.tar.bz2
yuzu-0c28f5dea617e492314a28bd1c754348734a3093.tar.lz
yuzu-0c28f5dea617e492314a28bd1c754348734a3093.tar.xz
yuzu-0c28f5dea617e492314a28bd1c754348734a3093.tar.zst
yuzu-0c28f5dea617e492314a28bd1c754348734a3093.zip
Diffstat (limited to '')
-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);
GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) {
Pica::g_debug_context = Pica::DebugContext::Construct();
-
+ setAcceptDrops(true);
ui.setupUi(this);
statusBar()->hide();
@@ -625,6 +625,40 @@ void GMainWindow::closeEvent(QCloseEvent* event) {
QWidget::closeEvent(event);
}
+bool IsSingleFileDropEvent(QDropEvent* event) {
+ const QMimeData* mimeData = event->mimeData();
+ return mimeData->hasUrls() && mimeData->urls().length() == 1;
+}
+
+void GMainWindow::dropEvent(QDropEvent* event) {
+ if (IsSingleFileDropEvent(event) && ConfirmChangeGame()) {
+ const QMimeData* mimeData = event->mimeData();
+ QString filename = mimeData->urls().at(0).toLocalFile();
+ BootGame(filename.toStdString());
+ }
+}
+
+void GMainWindow::dragEnterEvent(QDragEnterEvent* event) {
+ if (IsSingleFileDropEvent(event)) {
+ event->acceptProposedAction();
+ }
+}
+
+void GMainWindow::dragMoveEvent(QDragMoveEvent* event) {
+ event->acceptProposedAction();
+}
+
+bool GMainWindow::ConfirmChangeGame() {
+ if (emu_thread == nullptr)
+ return true;
+
+ auto answer = QMessageBox::question(
+ this, tr("Citra"),
+ tr("Are you sure you want to stop the emulation? Any unsaved progress will be lost."),
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
+ return answer != QMessageBox::No;
+}
+
#ifdef main
#undef main
#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:
* @return true if the user confirmed
*/
bool ConfirmClose();
+ bool ConfirmChangeGame();
void closeEvent(QCloseEvent* event) override;
private slots:
@@ -155,6 +156,11 @@ private:
WaitTreeWidget* waitTreeWidget;
QAction* actions_recent_files[max_recent_files_item];
+
+protected:
+ void dropEvent(QDropEvent* event) override;
+ void dragEnterEvent(QDragEnterEvent* event) override;
+ void dragMoveEvent(QDragMoveEvent* event) override;
};
#endif // _CITRA_QT_MAIN_HXX_