|
5 | 5 |
|
6 | 6 | #include <FluentQtWidgets/Dialogs/FolderListDialog.h> |
7 | 7 | #include <FluentQtWidgets/Settings/SettingCard.h> |
| 8 | +#include <FluentQtWidgets/Widgets/Button.h> |
8 | 9 | #include <FluentQtWidgets/Widgets/ComboBox.h> |
| 10 | +#include <FluentQtWidgets/Widgets/InfoBar.h> |
9 | 11 |
|
10 | 12 | #include <QtCore/QCoreApplication> |
11 | 13 | #include <QtCore/QDir> |
@@ -377,34 +379,45 @@ void SettingsPage::handleUpdateCheckFinished(bool ok, |
377 | 379 | if(m_updateCard) { |
378 | 380 | m_updateCard->setContent(QStringLiteral("检查失败:%1").arg(message)); |
379 | 381 | } |
380 | | - QMessageBox::warning(this, QStringLiteral("检查更新失败"), message); |
| 382 | + InfoBar::error(QStringLiteral("检查更新失败"), |
| 383 | + message, |
| 384 | + Qt::Horizontal, |
| 385 | + true, |
| 386 | + 3500, |
| 387 | + InfoBarPosition::TopRight, |
| 388 | + window()); |
381 | 389 | return; |
382 | 390 | } |
383 | 391 |
|
384 | 392 | if(!updateAvailable) { |
385 | 393 | if(m_updateCard) { |
386 | 394 | m_updateCard->setContent(QStringLiteral("当前已是最新版本 %1").arg(currentVersion)); |
387 | 395 | } |
388 | | - QMessageBox::information(this, |
389 | | - QStringLiteral("检查更新"), |
390 | | - QStringLiteral("当前已是最新版本:%1").arg(currentVersion)); |
| 396 | + InfoBar::success(QStringLiteral("当前已是最新版本"), |
| 397 | + QStringLiteral("版本 %1").arg(currentVersion), |
| 398 | + Qt::Horizontal, |
| 399 | + true, |
| 400 | + 2200, |
| 401 | + InfoBarPosition::TopRight, |
| 402 | + window()); |
391 | 403 | return; |
392 | 404 | } |
393 | 405 |
|
394 | 406 | if(m_updateCard) { |
395 | 407 | m_updateCard->setContent(QStringLiteral("发现新版本 %1").arg(latestVersion)); |
396 | 408 | } |
397 | 409 |
|
398 | | - QMessageBox messageBox(this); |
399 | | - messageBox.setIcon(QMessageBox::Information); |
400 | | - messageBox.setWindowTitle(QStringLiteral("发现新版本")); |
401 | | - messageBox.setText(QStringLiteral("当前版本:%1\n最新版本:%2").arg(currentVersion, latestVersion)); |
402 | | - messageBox.setInformativeText(QStringLiteral("可以打开 GitHub Releases 下载最新版本。")); |
403 | | - QPushButton *openButton = messageBox.addButton(QStringLiteral("打开发布页"), QMessageBox::AcceptRole); |
404 | | - messageBox.addButton(QStringLiteral("稍后"), QMessageBox::RejectRole); |
405 | | - messageBox.exec(); |
406 | | - |
407 | | - if(messageBox.clickedButton() == openButton && releaseUrl.isValid()) { |
| 410 | + auto *bar = InfoBar::info(QStringLiteral("发现新版本"), |
| 411 | + QStringLiteral("当前 %1,最新 %2").arg(currentVersion, latestVersion), |
| 412 | + Qt::Horizontal, |
| 413 | + true, |
| 414 | + 10000, |
| 415 | + InfoBarPosition::TopRight, |
| 416 | + window()); |
| 417 | + auto *openButton = new PushButton(icon(FluentIcon::Link), QStringLiteral("打开发布页"), bar); |
| 418 | + openButton->setEnabled(releaseUrl.isValid()); |
| 419 | + bar->addWidget(openButton); |
| 420 | + connect(openButton, &PushButton::clicked, this, [releaseUrl]() { |
408 | 421 | QDesktopServices::openUrl(releaseUrl); |
409 | | - } |
| 422 | + }); |
410 | 423 | } |
0 commit comments