Merge pull request #270 from flowln/dialog
Make a better "Mod download confirmation dialog"
This commit is contained in:
parent
0681568d3e
commit
c560d06b8d
@ -797,6 +797,8 @@ SET(LAUNCHER_SOURCES
|
||||
ui/pagedialog/PageDialog.h
|
||||
ui/dialogs/ProgressDialog.cpp
|
||||
ui/dialogs/ProgressDialog.h
|
||||
ui/dialogs/ReviewMessageBox.cpp
|
||||
ui/dialogs/ReviewMessageBox.h
|
||||
ui/dialogs/UpdateDialog.cpp
|
||||
ui/dialogs/UpdateDialog.h
|
||||
ui/dialogs/VersionSelectDialog.cpp
|
||||
@ -905,6 +907,7 @@ qt5_wrap_ui(LAUNCHER_UI
|
||||
ui/dialogs/AboutDialog.ui
|
||||
ui/dialogs/LoginDialog.ui
|
||||
ui/dialogs/EditAccountDialog.ui
|
||||
ui/dialogs/ReviewMessageBox.ui
|
||||
)
|
||||
|
||||
qt5_add_resources(LAUNCHER_RESOURCES
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <InstanceList.h>
|
||||
|
||||
#include "ProgressDialog.h"
|
||||
#include "CustomMessageBox.h"
|
||||
#include "ReviewMessageBox.h"
|
||||
|
||||
#include <QLayout>
|
||||
#include <QPushButton>
|
||||
@ -75,27 +75,16 @@ void ModDownloadDialog::confirm()
|
||||
auto keys = modTask.keys();
|
||||
keys.sort(Qt::CaseInsensitive);
|
||||
|
||||
auto info = QString(tr("You're about to download the following mods:"));
|
||||
info.append("\n\n");
|
||||
for(auto task : keys){
|
||||
info.append(task);
|
||||
info.append("\n --> ");
|
||||
info.append(tr("File name: "));
|
||||
info.append(modTask.find(task).value()->getFilename());
|
||||
info.append('\n');
|
||||
}
|
||||
|
||||
auto confirm_dialog = CustomMessageBox::selectable(
|
||||
auto confirm_dialog = ReviewMessageBox::create(
|
||||
this,
|
||||
tr("Confirm mods to download"),
|
||||
info,
|
||||
QMessageBox::NoIcon,
|
||||
QMessageBox::Cancel | QMessageBox::Ok,
|
||||
QMessageBox::Ok
|
||||
tr("Confirm mods to download")
|
||||
);
|
||||
|
||||
auto AcceptButton = confirm_dialog->button(QMessageBox::Ok);
|
||||
connect(AcceptButton, &QPushButton::clicked, this, &ModDownloadDialog::accept);
|
||||
for(auto task : keys){
|
||||
confirm_dialog->appendMod(task, modTask.find(task).value()->getFilename());
|
||||
}
|
||||
|
||||
connect(confirm_dialog, &QDialog::accepted, this, &ModDownloadDialog::accept);
|
||||
|
||||
confirm_dialog->open();
|
||||
}
|
||||
|
31
launcher/ui/dialogs/ReviewMessageBox.cpp
Normal file
31
launcher/ui/dialogs/ReviewMessageBox.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
#include "ReviewMessageBox.h"
|
||||
#include "ui_ReviewMessageBox.h"
|
||||
|
||||
ReviewMessageBox::ReviewMessageBox(QWidget* parent, QString const& title, QString const& icon)
|
||||
: QDialog(parent), ui(new Ui::ReviewMessageBox)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
ReviewMessageBox::~ReviewMessageBox()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
auto ReviewMessageBox::create(QWidget* parent, QString&& title, QString&& icon) -> ReviewMessageBox*
|
||||
{
|
||||
return new ReviewMessageBox(parent, title, icon);
|
||||
}
|
||||
|
||||
void ReviewMessageBox::appendMod(const QString& name, const QString& filename)
|
||||
{
|
||||
auto itemTop = new QTreeWidgetItem(ui->modTreeWidget);
|
||||
itemTop->setText(0, name);
|
||||
|
||||
auto filenameItem = new QTreeWidgetItem(itemTop);
|
||||
filenameItem->setText(0, tr("Filename: %1").arg(filename));
|
||||
|
||||
itemTop->insertChildren(0, { filenameItem });
|
||||
|
||||
ui->modTreeWidget->addTopLevelItem(itemTop);
|
||||
}
|
23
launcher/ui/dialogs/ReviewMessageBox.h
Normal file
23
launcher/ui/dialogs/ReviewMessageBox.h
Normal file
@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class ReviewMessageBox;
|
||||
}
|
||||
|
||||
class ReviewMessageBox final : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static auto create(QWidget* parent, QString&& title, QString&& icon = "") -> ReviewMessageBox*;
|
||||
|
||||
void appendMod(const QString& name, const QString& filename);
|
||||
|
||||
~ReviewMessageBox();
|
||||
|
||||
private:
|
||||
ReviewMessageBox(QWidget* parent, const QString& title, const QString& icon);
|
||||
|
||||
Ui::ReviewMessageBox* ui;
|
||||
};
|
98
launcher/ui/dialogs/ReviewMessageBox.ui
Normal file
98
launcher/ui/dialogs/ReviewMessageBox.ui
Normal file
@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ReviewMessageBox</class>
|
||||
<widget class="QDialog" name="ReviewMessageBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Confirm mod selection</string>
|
||||
</property>
|
||||
<property name="sizeGripEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>You're about to download the following mods:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTreeWidget" name="modTreeWidget">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::NoSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectItems</enum>
|
||||
</property>
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ReviewMessageBox</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>200</x>
|
||||
<y>265</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>199</x>
|
||||
<y>149</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ReviewMessageBox</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>200</x>
|
||||
<y>265</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>199</x>
|
||||
<y>149</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
Loading…
Reference in New Issue
Block a user