Merge pull request #7690 from NarryG/dragload-savestate
Reimplement savestate loading via drag and drop (resubmission of #7425)
This commit is contained in:
commit
3892c3ac48
|
@ -4,9 +4,14 @@
|
|||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QDropEvent>
|
||||
#include <QFileInfo>
|
||||
#include <QGuiApplication>
|
||||
#include <QIcon>
|
||||
#include <QKeyEvent>
|
||||
#include <QMessageBox>
|
||||
#include <QMimeData>
|
||||
#include <QMouseEvent>
|
||||
#include <QPalette>
|
||||
#include <QScreen>
|
||||
|
@ -14,6 +19,7 @@
|
|||
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/State.h"
|
||||
|
||||
#include "DolphinQt/Host.h"
|
||||
#include "DolphinQt/RenderWidget.h"
|
||||
|
@ -27,6 +33,7 @@ RenderWidget::RenderWidget(QWidget* parent) : QWidget(parent)
|
|||
{
|
||||
setWindowTitle(QStringLiteral("Dolphin"));
|
||||
setWindowIcon(Resources::GetAppIcon());
|
||||
setAcceptDrops(true);
|
||||
|
||||
QPalette p;
|
||||
p.setColor(QPalette::Background, Qt::black);
|
||||
|
@ -81,6 +88,37 @@ void RenderWidget::SetFillBackground(bool 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()
|
||||
{
|
||||
setCursor(Settings::Instance().GetHideCursor() ? Qt::BlankCursor : Qt::ArrowCursor);
|
||||
|
|
|
@ -36,6 +36,8 @@ private:
|
|||
void OnKeepOnTopChanged(bool top);
|
||||
void SetFillBackground(bool fill);
|
||||
void OnFreeLookMouseMove(QMouseEvent* event);
|
||||
void dragEnterEvent(QDragEnterEvent* event) override;
|
||||
void dropEvent(QDropEvent* event) override;
|
||||
|
||||
static constexpr int MOUSE_HIDE_DELAY = 3000;
|
||||
QTimer* m_mouse_timer;
|
||||
|
|
Loading…
Reference in New Issue