From da70122d9c46c6281c06fe1dedc558c13077f64f Mon Sep 17 00:00:00 2001 From: swirl Date: Sun, 20 Feb 2022 19:23:08 -0500 Subject: remove notifications --- launcher/ui/dialogs/NotificationDialog.cpp | 86 ------------------------------ launcher/ui/dialogs/NotificationDialog.h | 44 --------------- launcher/ui/dialogs/NotificationDialog.ui | 85 ----------------------------- 3 files changed, 215 deletions(-) delete mode 100644 launcher/ui/dialogs/NotificationDialog.cpp delete mode 100644 launcher/ui/dialogs/NotificationDialog.h delete mode 100644 launcher/ui/dialogs/NotificationDialog.ui (limited to 'launcher/ui/dialogs') diff --git a/launcher/ui/dialogs/NotificationDialog.cpp b/launcher/ui/dialogs/NotificationDialog.cpp deleted file mode 100644 index f2a35ae2..00000000 --- a/launcher/ui/dialogs/NotificationDialog.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include "NotificationDialog.h" -#include "ui_NotificationDialog.h" - -#include -#include - -NotificationDialog::NotificationDialog(const NotificationChecker::NotificationEntry &entry, QWidget *parent) : - QDialog(parent, Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint | Qt::CustomizeWindowHint), - ui(new Ui::NotificationDialog) -{ - ui->setupUi(this); - - QStyle::StandardPixmap icon; - switch (entry.type) - { - case NotificationChecker::NotificationEntry::Critical: - icon = QStyle::SP_MessageBoxCritical; - break; - case NotificationChecker::NotificationEntry::Warning: - icon = QStyle::SP_MessageBoxWarning; - break; - default: - case NotificationChecker::NotificationEntry::Information: - icon = QStyle::SP_MessageBoxInformation; - break; - } - ui->iconLabel->setPixmap(style()->standardPixmap(icon, 0, this)); - ui->messageLabel->setText(entry.message); - - m_dontShowAgainText = tr("Don't show again"); - m_closeText = tr("Close"); - - ui->dontShowAgainBtn->setText(m_dontShowAgainText + QString(" (%1)").arg(m_dontShowAgainTime)); - ui->closeBtn->setText(m_closeText + QString(" (%1)").arg(m_closeTime)); - - startTimer(1000); -} - -NotificationDialog::~NotificationDialog() -{ - delete ui; -} - -void NotificationDialog::timerEvent(QTimerEvent *event) -{ - if (m_dontShowAgainTime > 0) - { - m_dontShowAgainTime--; - if (m_dontShowAgainTime == 0) - { - ui->dontShowAgainBtn->setText(m_dontShowAgainText); - ui->dontShowAgainBtn->setEnabled(true); - } - else - { - ui->dontShowAgainBtn->setText(m_dontShowAgainText + QString(" (%1)").arg(m_dontShowAgainTime)); - } - } - if (m_closeTime > 0) - { - m_closeTime--; - if (m_closeTime == 0) - { - ui->closeBtn->setText(m_closeText); - ui->closeBtn->setEnabled(true); - } - else - { - ui->closeBtn->setText(m_closeText + QString(" (%1)").arg(m_closeTime)); - } - } - - if (m_closeTime == 0 && m_dontShowAgainTime == 0) - { - killTimer(event->timerId()); - } -} - -void NotificationDialog::on_dontShowAgainBtn_clicked() -{ - done(DontShowAgain); -} -void NotificationDialog::on_closeBtn_clicked() -{ - done(Normal); -} diff --git a/launcher/ui/dialogs/NotificationDialog.h b/launcher/ui/dialogs/NotificationDialog.h deleted file mode 100644 index e1cbb9fa..00000000 --- a/launcher/ui/dialogs/NotificationDialog.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef NOTIFICATIONDIALOG_H -#define NOTIFICATIONDIALOG_H - -#include - -#include "notifications/NotificationChecker.h" - -namespace Ui { -class NotificationDialog; -} - -class NotificationDialog : public QDialog -{ - Q_OBJECT - -public: - explicit NotificationDialog(const NotificationChecker::NotificationEntry &entry, QWidget *parent = 0); - ~NotificationDialog(); - - enum ExitCode - { - Normal, - DontShowAgain - }; - -protected: - void timerEvent(QTimerEvent *event); - -private: - Ui::NotificationDialog *ui; - - int m_dontShowAgainTime = 10; - int m_closeTime = 5; - - QString m_dontShowAgainText; - QString m_closeText; - -private -slots: - void on_dontShowAgainBtn_clicked(); - void on_closeBtn_clicked(); -}; - -#endif // NOTIFICATIONDIALOG_H diff --git a/launcher/ui/dialogs/NotificationDialog.ui b/launcher/ui/dialogs/NotificationDialog.ui deleted file mode 100644 index 3e6c22bc..00000000 --- a/launcher/ui/dialogs/NotificationDialog.ui +++ /dev/null @@ -1,85 +0,0 @@ - - - NotificationDialog - - - - 0 - 0 - 320 - 240 - - - - Notification - - - - - - - - TextLabel - - - - - - - TextLabel - - - true - - - true - - - Qt::TextBrowserInteraction - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - Don't show again - - - - - - - false - - - Close - - - - - - - - - - -- cgit From b3b613d8b4a5012d22b9e1646f4367fd27c783e3 Mon Sep 17 00:00:00 2001 From: flow Date: Sun, 13 Mar 2022 11:50:18 -0300 Subject: feat(ui): make a better "Mod download confirmation dialog" --- launcher/CMakeLists.txt | 3 + launcher/ui/dialogs/ModDownloadDialog.cpp | 27 +++------ launcher/ui/dialogs/ReviewMessageBox.cpp | 31 ++++++++++ launcher/ui/dialogs/ReviewMessageBox.h | 23 ++++++++ launcher/ui/dialogs/ReviewMessageBox.ui | 98 +++++++++++++++++++++++++++++++ 5 files changed, 163 insertions(+), 19 deletions(-) create mode 100644 launcher/ui/dialogs/ReviewMessageBox.cpp create mode 100644 launcher/ui/dialogs/ReviewMessageBox.h create mode 100644 launcher/ui/dialogs/ReviewMessageBox.ui (limited to 'launcher/ui/dialogs') diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 86c05651..039841ef 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -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 diff --git a/launcher/ui/dialogs/ModDownloadDialog.cpp b/launcher/ui/dialogs/ModDownloadDialog.cpp index 23ca8731..a53f93e8 100644 --- a/launcher/ui/dialogs/ModDownloadDialog.cpp +++ b/launcher/ui/dialogs/ModDownloadDialog.cpp @@ -5,7 +5,7 @@ #include #include "ProgressDialog.h" -#include "CustomMessageBox.h" +#include "ReviewMessageBox.h" #include #include @@ -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(); } diff --git a/launcher/ui/dialogs/ReviewMessageBox.cpp b/launcher/ui/dialogs/ReviewMessageBox.cpp new file mode 100644 index 00000000..139d05f1 --- /dev/null +++ b/launcher/ui/dialogs/ReviewMessageBox.cpp @@ -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, QString("Filename: %1").arg(filename)); + + itemTop->insertChildren(0, { filenameItem }); + + ui->modTreeWidget->addTopLevelItem(itemTop); +} diff --git a/launcher/ui/dialogs/ReviewMessageBox.h b/launcher/ui/dialogs/ReviewMessageBox.h new file mode 100644 index 00000000..48742cd9 --- /dev/null +++ b/launcher/ui/dialogs/ReviewMessageBox.h @@ -0,0 +1,23 @@ +#pragma once + +#include + +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; +}; diff --git a/launcher/ui/dialogs/ReviewMessageBox.ui b/launcher/ui/dialogs/ReviewMessageBox.ui new file mode 100644 index 00000000..d04f3b3f --- /dev/null +++ b/launcher/ui/dialogs/ReviewMessageBox.ui @@ -0,0 +1,98 @@ + + + ReviewMessageBox + + + + 0 + 0 + 400 + 300 + + + + Confirm mod selection + + + true + + + true + + + + + + You're about to download the following mods: + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + true + + + QAbstractItemView::NoSelection + + + QAbstractItemView::SelectItems + + + false + + + + + + + + + + + + + + buttonBox + accepted() + ReviewMessageBox + accept() + + + 200 + 265 + + + 199 + 149 + + + + + buttonBox + rejected() + ReviewMessageBox + reject() + + + 200 + 265 + + + 199 + 149 + + + + + -- cgit From f1e44291cc794fa16e4c975beb95b1f78584f4e5 Mon Sep 17 00:00:00 2001 From: flow Date: Sun, 13 Mar 2022 13:11:35 -0300 Subject: add translation string --- launcher/ui/dialogs/ReviewMessageBox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'launcher/ui/dialogs') diff --git a/launcher/ui/dialogs/ReviewMessageBox.cpp b/launcher/ui/dialogs/ReviewMessageBox.cpp index 139d05f1..2bfd02e0 100644 --- a/launcher/ui/dialogs/ReviewMessageBox.cpp +++ b/launcher/ui/dialogs/ReviewMessageBox.cpp @@ -23,7 +23,7 @@ void ReviewMessageBox::appendMod(const QString& name, const QString& filename) itemTop->setText(0, name); auto filenameItem = new QTreeWidgetItem(itemTop); - filenameItem->setText(0, QString("Filename: %1").arg(filename)); + filenameItem->setText(0, tr("Filename: %1").arg(filename)); itemTop->insertChildren(0, { filenameItem }); -- cgit