mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
My tweaks
Use a tree view instead of table view, remove toggle button (janky) Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
e6d7e5cdae
commit
4bc72ccca4
4 changed files with 27 additions and 50 deletions
|
|
@ -167,10 +167,8 @@ void NetJob::emitFailed(QString reason)
|
|||
auto failed = getFailedActions();
|
||||
auto dialog = NetworkJobFailedDialog(objectName(), m_try, m_done.size(), failed.size(), nullptr);
|
||||
|
||||
int i = 0;
|
||||
for (const auto& request : failed) {
|
||||
dialog.addFailedRequest(i, request->url(), request->errorString());
|
||||
++i;
|
||||
dialog.addFailedRequest(request->url(), request->errorString());
|
||||
}
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
|
|
|
|||
|
|
@ -20,46 +20,37 @@
|
|||
|
||||
#include "ui_NetworkJobFailedDialog.h"
|
||||
|
||||
NetworkJobFailedDialog::NetworkJobFailedDialog(QString jobName, int attempts, int requests, int failed, QWidget* parent) : QDialog(parent), ui(new Ui::NetworkJobFailedDialog)
|
||||
#include <QTableWidgetItem>
|
||||
|
||||
NetworkJobFailedDialog::NetworkJobFailedDialog(QString jobName, int attempts, int requests, int failed, QWidget* parent)
|
||||
: QDialog(parent), m_ui(new Ui::NetworkJobFailedDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->failLabel->setText(ui->failLabel->text().arg(jobName));
|
||||
m_ui->setupUi(this);
|
||||
m_ui->failLabel->setText(m_ui->failLabel->text().arg(jobName));
|
||||
if (failed == requests) {
|
||||
ui->requestCountLabel->setText(tr("All %1 requests have failed after %2 attempts").arg(failed).arg(attempts));
|
||||
m_ui->requestCountLabel->setText(tr("All %1 requests have failed after %2 attempts").arg(failed).arg(attempts));
|
||||
} else if (failed < requests / 2) {
|
||||
ui->requestCountLabel->setText(tr("Out of %1 requests, %2 have failed after %3 attempts").arg(requests).arg(failed).arg(attempts));
|
||||
m_ui->requestCountLabel->setText(
|
||||
tr("Out of %1 requests, %2 have failed after %3 attempts").arg(requests).arg(failed).arg(attempts));
|
||||
} else {
|
||||
ui->requestCountLabel->setText(tr("Out of %1 requests, only %2 succeeded after %3 attempts").arg(requests).arg(requests - failed).arg(attempts));
|
||||
m_ui->requestCountLabel->setText(
|
||||
tr("Out of %1 requests, only %2 succeeded after %3 attempts").arg(requests).arg(requests - failed).arg(attempts));
|
||||
}
|
||||
ui->detailsTable->setRowCount(failed);
|
||||
|
||||
setShowDetails(failed < 5);
|
||||
m_ui->detailsTable->header()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
m_ui->detailsTable->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
|
||||
|
||||
connect(ui->dialogButtonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(ui->dialogButtonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
connect(m_ui->dialogButtonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(m_ui->dialogButtonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
}
|
||||
|
||||
NetworkJobFailedDialog::~NetworkJobFailedDialog()
|
||||
{
|
||||
delete ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void NetworkJobFailedDialog::addFailedRequest(int row, QUrl url, QString error) const
|
||||
void NetworkJobFailedDialog::addFailedRequest(QUrl url, QString error) const
|
||||
{
|
||||
const auto urlItem = new QTableWidgetItem(url.toString());
|
||||
const auto errorItem = new QTableWidgetItem(error);
|
||||
ui->detailsTable->setItem(row, 0, urlItem);
|
||||
ui->detailsTable->setItem(row, 1, errorItem);
|
||||
}
|
||||
|
||||
void NetworkJobFailedDialog::setShowDetails(bool showDetails)
|
||||
{
|
||||
m_showDetails = showDetails;
|
||||
ui->detailsTable->setVisible(m_showDetails);
|
||||
ui->detailsButton->setText(!m_showDetails ? tr("Show details") : tr("Hide details"));
|
||||
}
|
||||
|
||||
void NetworkJobFailedDialog::on_detailsButton_clicked()
|
||||
{
|
||||
setShowDetails(!m_showDetails);
|
||||
auto item = new QTreeWidgetItem(m_ui->detailsTable, { url.toString(), error });
|
||||
m_ui->detailsTable->addTopLevelItem(item);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,16 +33,8 @@ class NetworkJobFailedDialog : public QDialog {
|
|||
explicit NetworkJobFailedDialog(QString jobName, int attempts, int requests, int failed, QWidget* parent = nullptr);
|
||||
~NetworkJobFailedDialog() override;
|
||||
|
||||
void addFailedRequest(int row, QUrl url, QString error) const;
|
||||
void addFailedRequest(QUrl url, QString error) const;
|
||||
|
||||
private:
|
||||
void setShowDetails(bool showDetails);
|
||||
|
||||
private slots:
|
||||
void on_detailsButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::NetworkJobFailedDialog* ui;
|
||||
|
||||
bool m_showDetails = false;
|
||||
Ui::NetworkJobFailedDialog* m_ui;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -39,22 +39,18 @@
|
|||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">TextLabel</string>
|
||||
<string notr="true">(request count)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="detailsButton">
|
||||
<property name="text">
|
||||
<string notr="true">PushButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="detailsTable">
|
||||
<widget class="QTreeWidget" name="detailsTable">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::EditTrigger::NoEditTriggers</set>
|
||||
</property>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>URL</string>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue