Drag&Drop support. (Any filename ending in ".3ds" is accepted.)
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3469 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
e6f9cb2106
commit
bb6437fe06
|
@ -19,6 +19,8 @@
|
|||
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QUrl>
|
||||
|
||||
// For dump_pie_file
|
||||
#include <lib3ds/file.h>
|
||||
|
@ -32,6 +34,8 @@ Gui3ds2pie::Gui3ds2pie( QWidget *parent )
|
|||
{
|
||||
setupUi(this);
|
||||
|
||||
setAcceptDrops(true);
|
||||
|
||||
connect(inputFile_browse, SIGNAL(clicked()), this, SLOT(browseInputFile()));
|
||||
connect(outputFile_browse, SIGNAL(clicked()), this, SLOT(browseOutputFile()));
|
||||
}
|
||||
|
@ -56,6 +60,31 @@ void Gui3ds2pie::browseOutputFile()
|
|||
}
|
||||
|
||||
|
||||
void Gui3ds2pie::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
if (event->mimeData()->hasUrls())
|
||||
foreach(const QUrl &url, event->mimeData()->urls())
|
||||
if(url.path().endsWith(".3ds", Qt::CaseInsensitive))
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Gui3ds2pie::dropEvent(QDropEvent *event)
|
||||
{
|
||||
foreach(const QUrl &url, event->mimeData()->urls())
|
||||
if(url.path().endsWith(".3ds", Qt::CaseInsensitive))
|
||||
{
|
||||
QString path = url.path();
|
||||
inputFile_edit->setText(path);
|
||||
outputFile_edit->setText( path.replace( path.lastIndexOf(".3ds", -1, Qt::CaseInsensitive), 4, ".pie" ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Gui3ds2pie::accept()
|
||||
{
|
||||
QString inputFile = inputFile_edit->text();
|
||||
|
|
|
@ -37,6 +37,8 @@ class Gui3ds2pie : public QDialog, private Ui::Gui3ds2pie
|
|||
void browseInputFile();
|
||||
void browseOutputFile();
|
||||
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
void dropEvent(QDropEvent *event);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue