NOISSUE add pack import using drag&drop
Straight from the browser or the downloads folder.
This commit is contained in:
parent
77a1d39f6b
commit
30863a88ab
@ -449,6 +449,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow
|
|||||||
view->installEventFilter(this);
|
view->installEventFilter(this);
|
||||||
view->setContextMenuPolicy(Qt::CustomContextMenu);
|
view->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(view, &QWidget::customContextMenuRequested, this, &MainWindow::showInstanceContextMenu);
|
connect(view, &QWidget::customContextMenuRequested, this, &MainWindow::showInstanceContextMenu);
|
||||||
|
connect(view, &GroupView::droppedURLs, this, &MainWindow::droppedURLs);
|
||||||
|
|
||||||
proxymodel = new InstanceProxyModel(this);
|
proxymodel = new InstanceProxyModel(this);
|
||||||
proxymodel->setSourceModel(MMC->instances().get());
|
proxymodel->setSourceModel(MMC->instances().get());
|
||||||
@ -1076,7 +1077,7 @@ void MainWindow::finalizeInstance(InstancePtr inst)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionAddInstance_triggered()
|
void MainWindow::addInstance(QString url)
|
||||||
{
|
{
|
||||||
QString groupName;
|
QString groupName;
|
||||||
do
|
do
|
||||||
@ -1098,7 +1099,7 @@ void MainWindow::on_actionAddInstance_triggered()
|
|||||||
groupName = MMC->settings()->get("LastUsedGroupForNewInstance").toString();
|
groupName = MMC->settings()->get("LastUsedGroupForNewInstance").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
NewInstanceDialog newInstDlg(groupName, this);
|
NewInstanceDialog newInstDlg(groupName, url, this);
|
||||||
if (!newInstDlg.exec())
|
if (!newInstDlg.exec())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1116,6 +1117,28 @@ void MainWindow::on_actionAddInstance_triggered()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionAddInstance_triggered()
|
||||||
|
{
|
||||||
|
addInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::droppedURLs(QList<QUrl> urls)
|
||||||
|
{
|
||||||
|
for(auto & url:urls)
|
||||||
|
{
|
||||||
|
if(url.isLocalFile())
|
||||||
|
{
|
||||||
|
addInstance(url.toLocalFile());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
addInstance(url.toString());
|
||||||
|
}
|
||||||
|
// Only process one dropped file...
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionREDDIT_triggered()
|
void MainWindow::on_actionREDDIT_triggered()
|
||||||
{
|
{
|
||||||
DesktopServices::openUrl(QUrl("https://www.reddit.com/r/MultiMC/"));
|
DesktopServices::openUrl(QUrl("https://www.reddit.com/r/MultiMC/"));
|
||||||
|
@ -161,7 +161,10 @@ private slots:
|
|||||||
*/
|
*/
|
||||||
void downloadUpdates(GoUpdate::Status status);
|
void downloadUpdates(GoUpdate::Status status);
|
||||||
|
|
||||||
|
void droppedURLs(QList<QUrl> urls);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void addInstance(QString url = QString());
|
||||||
void activateInstance(InstancePtr instance);
|
void activateInstance(InstancePtr instance);
|
||||||
void setCatBackground(bool enabled);
|
void setCatBackground(bool enabled);
|
||||||
void updateInstanceToolIcon(QString new_icon);
|
void updateInstanceToolIcon(QString new_icon);
|
||||||
|
@ -57,7 +57,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, QWidget *parent)
|
NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, const QString & url, QWidget *parent)
|
||||||
: QDialog(parent), ui(new Ui::NewInstanceDialog)
|
: QDialog(parent), ui(new Ui::NewInstanceDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@ -112,6 +112,11 @@ NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, QWidget *pare
|
|||||||
ui->buttonBox->setFocus();
|
ui->buttonBox->setFocus();
|
||||||
|
|
||||||
originalPlaceholderText = ui->instNameTextBox->placeholderText();
|
originalPlaceholderText = ui->instNameTextBox->placeholderText();
|
||||||
|
if(!url.isEmpty())
|
||||||
|
{
|
||||||
|
ui->modpackBox->setChecked(true);
|
||||||
|
ui->modpackEdit->setText(url);
|
||||||
|
}
|
||||||
updateDialogState();
|
updateDialogState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class NewInstanceDialog : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit NewInstanceDialog(const QString & initialGroup, QWidget *parent = 0);
|
explicit NewInstanceDialog(const QString & initialGroup, const QString & url = QString(), QWidget *parent = 0);
|
||||||
~NewInstanceDialog();
|
~NewInstanceDialog();
|
||||||
|
|
||||||
void updateDialogState();
|
void updateDialogState();
|
||||||
|
@ -534,11 +534,10 @@ void GroupView::dropEvent(QDropEvent *event)
|
|||||||
stopAutoScroll();
|
stopAutoScroll();
|
||||||
setState(NoState);
|
setState(NoState);
|
||||||
|
|
||||||
if (event->source() != this || !(event->possibleActions() & Qt::MoveAction))
|
if (event->source() == this)
|
||||||
|
{
|
||||||
|
if(event->possibleActions() & Qt::MoveAction)
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPair<VisualGroup *, int> dropPos = rowDropPos(event->pos() + offset());
|
QPair<VisualGroup *, int> dropPos = rowDropPos(event->pos() + offset());
|
||||||
const VisualGroup *category = dropPos.first;
|
const VisualGroup *category = dropPos.first;
|
||||||
const int row = dropPos.second;
|
const int row = dropPos.second;
|
||||||
@ -559,6 +558,22 @@ void GroupView::dropEvent(QDropEvent *event)
|
|||||||
}
|
}
|
||||||
updateGeometries();
|
updateGeometries();
|
||||||
viewport()->update();
|
viewport()->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auto mimedata = event->mimeData();
|
||||||
|
|
||||||
|
// check if the action is supported
|
||||||
|
if (!mimedata)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// files dropped from outside?
|
||||||
|
if (mimedata->hasUrls())
|
||||||
|
{
|
||||||
|
auto urls = mimedata->urls();
|
||||||
|
emit droppedURLs(urls);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupView::startDrag(Qt::DropActions supportedActions)
|
void GroupView::startDrag(Qt::DropActions supportedActions)
|
||||||
@ -707,7 +722,7 @@ QList<QPair<QRect, QModelIndex>> GroupView::draggablePaintPairs(const QModelInde
|
|||||||
|
|
||||||
bool GroupView::isDragEventAccepted(QDropEvent *event)
|
bool GroupView::isDragEventAccepted(QDropEvent *event)
|
||||||
{
|
{
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPair<VisualGroup *, int> GroupView::rowDropPos(const QPoint &pos)
|
QPair<VisualGroup *, int> GroupView::rowDropPos(const QPoint &pos)
|
||||||
|
@ -62,6 +62,9 @@ protected slots:
|
|||||||
void modelReset();
|
void modelReset();
|
||||||
void rowsRemoved();
|
void rowsRemoved();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void droppedURLs(QList<QUrl> urls);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool isIndexHidden(const QModelIndex &index) const override;
|
virtual bool isIndexHidden(const QModelIndex &index) const override;
|
||||||
void mousePressEvent(QMouseEvent *event) override;
|
void mousePressEvent(QMouseEvent *event) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user