make path inputs support drag/dropping files onto them to add the path quickly. fixes #1033
This commit is contained in:
parent
284a9b73b0
commit
d5dbef2c22
|
@ -62,7 +62,7 @@
|
|||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="txtMicWavPath">
|
||||
<widget class="QPathInput" name="txtMicWavPath">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>290</width>
|
||||
|
@ -136,6 +136,13 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QPathInput</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>QPathInput.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
|
|
|
@ -18,6 +18,7 @@ SET(SOURCES_QT_SDL
|
|||
font.h
|
||||
Platform.cpp
|
||||
PlatformConfig.cpp
|
||||
QPathInput.h
|
||||
|
||||
ArchiveUtil.h
|
||||
ArchiveUtil.cpp
|
||||
|
|
|
@ -90,14 +90,14 @@
|
|||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="txtBIOS7Path">
|
||||
<widget class="QPathInput" name="txtBIOS7Path">
|
||||
<property name="whatsThis">
|
||||
<string><html><head/><body><p>DS-mode ARM7 BIOS</p><p>Size should be 16 KB</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="txtFirmwarePath">
|
||||
<widget class="QPathInput" name="txtFirmwarePath">
|
||||
<property name="whatsThis">
|
||||
<string><html><head/><body><p>DS-mode firmware</p><p><br/></p><p>Possible firmwares:</p><p>* 128 KB: DS-mode firmware from a DSi or 3DS. Not bootable.</p><p>* 256 KB: regular DS firmware.</p><p>* 512 KB: iQue DS firmware.</p></body></html></string>
|
||||
</property>
|
||||
|
@ -155,7 +155,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="txtBIOS9Path">
|
||||
<widget class="QPathInput" name="txtBIOS9Path">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -197,7 +197,7 @@
|
|||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="txtDSiBIOS7Path">
|
||||
<widget class="QPathInput" name="txtDSiBIOS7Path">
|
||||
<property name="whatsThis">
|
||||
<string><html><head/><body><p>DSi-mode ARM7 BIOS</p><p><br/></p><p>Size should be 64 KB</p></body></html></string>
|
||||
</property>
|
||||
|
@ -239,7 +239,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="txtDSiNANDPath">
|
||||
<widget class="QPathInput" name="txtDSiNANDPath">
|
||||
<property name="whatsThis">
|
||||
<string><html><head/><body><p>DSi NAND dump</p><p><br/></p><p>Should have 'nocash footer' at the end</p></body></html></string>
|
||||
</property>
|
||||
|
@ -260,7 +260,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="txtDSiBIOS9Path">
|
||||
<widget class="QPathInput" name="txtDSiBIOS9Path">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -287,14 +287,14 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="txtDSiFirmwarePath">
|
||||
<widget class="QPathInput" name="txtDSiFirmwarePath">
|
||||
<property name="whatsThis">
|
||||
<string><html><head/><body><p>DSi-mode firmware (used for DS-mode backwards compatibility)</p><p><br/></p><p>Size should be 128 KB</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLineEdit" name="txtDSiSDPath">
|
||||
<widget class="QPathInput" name="txtDSiSDPath">
|
||||
<property name="whatsThis">
|
||||
<string><html><head/><body><p>SD image file for emulating the DSi's SD card</p></body></html></string>
|
||||
</property>
|
||||
|
@ -410,7 +410,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="txtDLDISDPath"/>
|
||||
<widget class="QPathInput" name="txtDLDISDPath"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
|
@ -448,6 +448,13 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QPathInput</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>QPathInput.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>cbxConsoleType</tabstop>
|
||||
<tabstop>chkDirectBoot</tabstop>
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
Copyright 2016-2021 Arisotura
|
||||
|
||||
This file is part of melonDS.
|
||||
|
||||
melonDS is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation, either version 3 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with melonDS. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#ifndef QPATHINPUT_H
|
||||
#define QPATHINPUT_H
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QDropEvent>
|
||||
#include <QMimeData>
|
||||
|
||||
class QPathInput : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QPathInput(QWidget* parent = nullptr) : QLineEdit(parent)
|
||||
{
|
||||
setAcceptDrops(true);
|
||||
}
|
||||
|
||||
~QPathInput()
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
void dragEnterEvent(QDragEnterEvent* event) override
|
||||
{
|
||||
if (!event->mimeData()->hasUrls()) return QLineEdit::dragEnterEvent(event);
|
||||
|
||||
QList<QUrl> urls = event->mimeData()->urls();
|
||||
if (urls.count() > 1) return QLineEdit::dragEnterEvent(event);
|
||||
|
||||
QString filename = urls.at(0).toLocalFile();
|
||||
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
|
||||
void dropEvent(QDropEvent* event) override
|
||||
{
|
||||
if (!event->mimeData()->hasUrls()) return QLineEdit::dropEvent(event);
|
||||
|
||||
QList<QUrl> urls = event->mimeData()->urls();
|
||||
if (urls.count() > 1) return QLineEdit::dropEvent(event);
|
||||
|
||||
QString filename = urls.at(0).toLocalFile();
|
||||
setText(filename);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // QPATHINPUT_H
|
Loading…
Reference in New Issue