Reimplement savestate loading via drag and drop
This commit is contained in:
parent
b2de98cad1
commit
d69740c8b4
|
@ -4,9 +4,14 @@
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
|
#include <QDragEnterEvent>
|
||||||
|
#include <QDropEvent>
|
||||||
|
#include <QFileInfo>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QMimeData>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
@ -14,6 +19,7 @@
|
||||||
|
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
|
#include "Core/State.h"
|
||||||
|
|
||||||
#include "DolphinQt/Host.h"
|
#include "DolphinQt/Host.h"
|
||||||
#include "DolphinQt/RenderWidget.h"
|
#include "DolphinQt/RenderWidget.h"
|
||||||
|
@ -27,6 +33,7 @@ RenderWidget::RenderWidget(QWidget* parent) : QWidget(parent)
|
||||||
{
|
{
|
||||||
setWindowTitle(QStringLiteral("Dolphin"));
|
setWindowTitle(QStringLiteral("Dolphin"));
|
||||||
setWindowIcon(Resources::GetAppIcon());
|
setWindowIcon(Resources::GetAppIcon());
|
||||||
|
setAcceptDrops(true);
|
||||||
|
|
||||||
QPalette p;
|
QPalette p;
|
||||||
p.setColor(QPalette::Background, Qt::black);
|
p.setColor(QPalette::Background, Qt::black);
|
||||||
|
@ -81,6 +88,37 @@ void RenderWidget::SetFillBackground(bool fill)
|
||||||
setAutoFillBackground(fill);
|
setAutoFillBackground(fill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderWidget::dragEnterEvent(QDragEnterEvent* event)
|
||||||
|
{
|
||||||
|
if (event->mimeData()->hasUrls() && event->mimeData()->urls().size() == 1)
|
||||||
|
event->acceptProposedAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderWidget::dropEvent(QDropEvent* event)
|
||||||
|
{
|
||||||
|
const auto& urls = event->mimeData()->urls();
|
||||||
|
if (urls.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const auto& url = urls[0];
|
||||||
|
QFileInfo file_info(url.toLocalFile());
|
||||||
|
|
||||||
|
auto path = file_info.filePath();
|
||||||
|
|
||||||
|
if (!file_info.exists() || !file_info.isReadable())
|
||||||
|
{
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("Failed to open '%1'").arg(path));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file_info.isFile())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
State::LoadAs(path.toStdString());
|
||||||
|
}
|
||||||
|
|
||||||
void RenderWidget::OnHideCursorChanged()
|
void RenderWidget::OnHideCursorChanged()
|
||||||
{
|
{
|
||||||
setCursor(Settings::Instance().GetHideCursor() ? Qt::BlankCursor : Qt::ArrowCursor);
|
setCursor(Settings::Instance().GetHideCursor() ? Qt::BlankCursor : Qt::ArrowCursor);
|
||||||
|
|
|
@ -36,6 +36,8 @@ private:
|
||||||
void OnKeepOnTopChanged(bool top);
|
void OnKeepOnTopChanged(bool top);
|
||||||
void SetFillBackground(bool fill);
|
void SetFillBackground(bool fill);
|
||||||
void OnFreeLookMouseMove(QMouseEvent* event);
|
void OnFreeLookMouseMove(QMouseEvent* event);
|
||||||
|
void dragEnterEvent(QDragEnterEvent* event) override;
|
||||||
|
void dropEvent(QDropEvent* event) override;
|
||||||
|
|
||||||
static constexpr int MOUSE_HIDE_DELAY = 3000;
|
static constexpr int MOUSE_HIDE_DELAY = 3000;
|
||||||
QTimer* m_mouse_timer;
|
QTimer* m_mouse_timer;
|
||||||
|
|
Loading…
Reference in New Issue