diff --git a/src/gui/updater/CMakeLists.txt b/src/gui/updater/CMakeLists.txt index a6394ec7d23..0f37f4ea505 100644 --- a/src/gui/updater/CMakeLists.txt +++ b/src/gui/updater/CMakeLists.txt @@ -10,6 +10,9 @@ endif() target_sources(owncloudGui PRIVATE ocupdater.cpp ocupdater.h + nourlwidget.cpp + nourlwidget.h + nourlwidget.ui updateinfo.cpp updateinfo.h updater.cpp diff --git a/src/gui/updater/nourlwidget.cpp b/src/gui/updater/nourlwidget.cpp new file mode 100644 index 00000000000..f1cb149c544 --- /dev/null +++ b/src/gui/updater/nourlwidget.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2023 by Erik Verbruggen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "nourlwidget.h" +#include "theme.h" +#include "ui_nourlwidget.h" + +#include +#include + +namespace OCC { + +NoUrlWidget::NoUrlWidget(QWidget *parent, const QString &statusMessage) + : QWidget(parent) + , _ui(new ::Ui::Ui_NoUrlWidget) +{ + _ui->setupUi(this); + + _ui->icon->setPixmap(Theme::instance()->applicationIcon().pixmap(128, 128)); + _ui->label->setText(statusMessage); + + QPushButton *skipButton = _ui->buttonBox->addButton(tr("Skip this version"), QDialogButtonBox::ResetRole); + QPushButton *getUpdateButton = _ui->buttonBox->addButton(tr("Get update"), QDialogButtonBox::AcceptRole); + QPushButton *rejectButton = _ui->buttonBox->addButton(tr("Skip this time"), QDialogButtonBox::AcceptRole); + + connect(skipButton, &QAbstractButton::clicked, this, &NoUrlWidget::skipVersion); + connect(rejectButton, &QAbstractButton::clicked, this, &NoUrlWidget::notNow); + connect(getUpdateButton, &QAbstractButton::clicked, this, &NoUrlWidget::getUpdate); +} + +void NoUrlWidget::skipVersion() +{ + close(); + Q_EMIT versionSkipped(); +} + +void NoUrlWidget::notNow() +{ + close(); + Q_EMIT noUpdateNow(); +} + +void NoUrlWidget::getUpdate() +{ + close(); + Q_EMIT updateNow(); +} + +} // OCC namespace diff --git a/src/gui/updater/nourlwidget.h b/src/gui/updater/nourlwidget.h new file mode 100644 index 00000000000..83e01d7f824 --- /dev/null +++ b/src/gui/updater/nourlwidget.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2023 by Fabian Müller + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#pragma once + +#include +#include + +namespace Ui { +class Ui_NoUrlWidget; +} + +namespace OCC { + +class NoUrlWidget : public QWidget +{ + Q_OBJECT + +public: + explicit NoUrlWidget(QWidget *parent, const QString &statusMessage); + +private Q_SLOTS: + void skipVersion(); + void notNow(); + void getUpdate(); + +Q_SIGNALS: + void versionSkipped(); + void noUpdateNow(); + void updateNow(); + +private: + QScopedPointer<::Ui::Ui_NoUrlWidget> _ui; +}; + +} diff --git a/src/gui/updater/nourlwidget.ui b/src/gui/updater/nourlwidget.ui new file mode 100644 index 00000000000..8399175706c --- /dev/null +++ b/src/gui/updater/nourlwidget.ui @@ -0,0 +1,96 @@ + + + Ui::NoUrlWidget + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + 0 + 0 + + + + + 128 + 128 + + + + + 128 + 128 + + + + + + + true + + + Qt::AlignCenter + + + + + + + + + Qt::AlignCenter + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + QDialogButtonBox::NoButton + + + + + + + + diff --git a/src/gui/updater/ocupdater.cpp b/src/gui/updater/ocupdater.cpp index 3f5c33e9f8d..54621195fe6 100644 --- a/src/gui/updater/ocupdater.cpp +++ b/src/gui/updater/ocupdater.cpp @@ -22,6 +22,7 @@ #include "settingsdialog.h" #include "updatedownloadeddialog.h" +#include "updater/nourlwidget.h" #include "updater/ocupdater.h" #include "updater/updater_private.h" @@ -376,50 +377,17 @@ void WindowsUpdater::versionInfoArrived(const UpdateInfo &info) void WindowsUpdater::showNoUrlDialog(const UpdateInfo &info) { // if the version tag is set, there is a newer version. - QDialog *msgBox = new QDialog; - msgBox->setAttribute(Qt::WA_DeleteOnClose); - - QIcon infoIcon = msgBox->style()->standardIcon(QStyle::SP_MessageBoxInformation); - int iconSize = msgBox->style()->pixelMetric(QStyle::PM_MessageBoxIconSize); - - msgBox->setWindowIcon(infoIcon); - - QVBoxLayout *layout = new QVBoxLayout(msgBox); - QHBoxLayout *hlayout = new QHBoxLayout; - layout->addLayout(hlayout); - - msgBox->setWindowTitle(tr("New Version Available")); - - QLabel *ico = new QLabel; - ico->setFixedSize(iconSize, iconSize); - ico->setPixmap(infoIcon.pixmap(iconSize)); - QLabel *lbl = new QLabel; QString txt = tr("

A new version of the %1 Client is available.

" "

%2 is available for download. The installed version is %3.

") .arg(Utility::escape(Theme::instance()->appNameGUI()), Utility::escape(info.versionString()), Utility::escape(Version::versionWithBuildNumber().toString())); + auto *widget = new NoUrlWidget(ocApp()->gui()->settingsDialog(), txt); + widget->setAttribute(Qt::WA_DeleteOnClose); - lbl->setText(txt); - lbl->setTextFormat(Qt::RichText); - lbl->setWordWrap(true); - - hlayout->addWidget(ico); - hlayout->addWidget(lbl); + connect(widget, &NoUrlWidget::versionSkipped, this, &WindowsUpdater::slotSetPreviouslySkippedVersion); + connect(widget, &NoUrlWidget::updateNow, this, &WindowsUpdater::slotOpenUpdateUrl); - QDialogButtonBox *bb = new QDialogButtonBox; - QPushButton *skip = bb->addButton(tr("Skip this version"), QDialogButtonBox::ResetRole); - QPushButton *reject = bb->addButton(tr("Skip this time"), QDialogButtonBox::AcceptRole); - QPushButton *getupdate = bb->addButton(tr("Get update"), QDialogButtonBox::AcceptRole); - - connect(skip, &QAbstractButton::clicked, msgBox, &QDialog::reject); - connect(reject, &QAbstractButton::clicked, msgBox, &QDialog::reject); - connect(getupdate, &QAbstractButton::clicked, msgBox, &QDialog::accept); - - connect(skip, &QAbstractButton::clicked, this, &WindowsUpdater::slotSetPreviouslySkippedVersion); - connect(getupdate, &QAbstractButton::clicked, this, &WindowsUpdater::slotOpenUpdateUrl); - - layout->addWidget(bb); - ocApp()->gui()->settingsDialog()->addModalWidget(msgBox); + ocApp()->gui()->settingsDialog()->addModalWidget(widget); } void WindowsUpdater::showUpdateErrorDialog(const QString &targetVersion) diff --git a/src/gui/updater/updatedownloadeddialog.cpp b/src/gui/updater/updatedownloadeddialog.cpp index eab5049ccae..abe074e1dc0 100644 --- a/src/gui/updater/updatedownloadeddialog.cpp +++ b/src/gui/updater/updatedownloadeddialog.cpp @@ -22,18 +22,18 @@ namespace OCC { UpdateDownloadedDialog::UpdateDownloadedDialog(QWidget *parent, const QString &statusMessage) - : QDialog(parent) + : QWidget(parent) , _ui(new ::Ui::UpdateDownloadedDialog) { _ui->setupUi(this); - _ui->iconLabel->setPixmap(Theme::instance()->aboutIcon().pixmap(96, 96)); + _ui->iconLabel->setPixmap(Theme::instance()->applicationIcon().pixmap(128, 128)); _ui->iconLabel->setText(QString()); _ui->descriptionLabel->setText(statusMessage); - connect(_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); - connect(_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(_ui->buttonBox, &QDialogButtonBox::rejected, this, &UpdateDownloadedDialog::reject); + connect(_ui->buttonBox, &QDialogButtonBox::accepted, this, &UpdateDownloadedDialog::accept); const auto noButton = _ui->buttonBox->button(QDialogButtonBox::No); const auto yesButton = _ui->buttonBox->button(QDialogButtonBox::Yes); @@ -44,9 +44,14 @@ UpdateDownloadedDialog::UpdateDownloadedDialog(QWidget *parent, const QString &s yesButton->setDefault(true); } -UpdateDownloadedDialog::~UpdateDownloadedDialog() +void UpdateDownloadedDialog::accept() { - delete _ui; + Q_EMIT accepted(); + close(); } +void UpdateDownloadedDialog::reject() +{ + close(); } +} // OCC namespace diff --git a/src/gui/updater/updatedownloadeddialog.h b/src/gui/updater/updatedownloadeddialog.h index 1e883e1e1cf..07383a8e547 100644 --- a/src/gui/updater/updatedownloadeddialog.h +++ b/src/gui/updater/updatedownloadeddialog.h @@ -14,7 +14,8 @@ #pragma once -#include +#include +#include namespace Ui { class UpdateDownloadedDialog; @@ -22,16 +23,22 @@ class UpdateDownloadedDialog; namespace OCC { -class UpdateDownloadedDialog : public QDialog +class UpdateDownloadedDialog : public QWidget { Q_OBJECT public: explicit UpdateDownloadedDialog(QWidget *parent, const QString &statusMessage); - ~UpdateDownloadedDialog() override; + +public Q_SLOTS: + void accept(); + void reject(); + +Q_SIGNALS: + void accepted(); private: - ::Ui::UpdateDownloadedDialog *_ui; + QScopedPointer<::Ui::UpdateDownloadedDialog> _ui; }; } diff --git a/src/gui/updater/updatedownloadeddialog.ui b/src/gui/updater/updatedownloadeddialog.ui index 411ee3d320a..6fb1206022a 100644 --- a/src/gui/updater/updatedownloadeddialog.ui +++ b/src/gui/updater/updatedownloadeddialog.ui @@ -1,13 +1,13 @@ UpdateDownloadedDialog - + 0 0 414 - 160 + 414 @@ -16,78 +16,113 @@ 0 - - Update downloaded - - - - QLayout::SetMaximumSize - + - - + + + Qt::Vertical + + - 128 - 0 + 20 + 40 - - icon - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - + - - - - - - 0 - 0 - - - - <html><head/><body><p><span style=" font-size:11pt; font-weight:700;">Restart required</span></p></body></html> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - + + + - + 0 0 - 260 + 128 0 - - Update soandso has been downloaded. Restart now to perform the update? + + + 128 + 128 + - - true + + icon (placeholder) - - - - - - QDialogButtonBox::No|QDialogButtonBox::Yes + + Qt::AlignCenter + + + + + 0 + 0 + + + + <html><head/><body><p><span style=" font-size:11pt; font-weight:700;">Restart required</span></p></body></html> + + + Qt::AlignHCenter|Qt::AlignTop + + + + + + + + 0 + 0 + + + + + 260 + 0 + + + + Update soandso has been downloaded. Restart now to perform the update? + + + Qt::AlignCenter + + + true + + + + + + + Qt::Vertical + + + + 20 + 277 + + + + + + + + QDialogButtonBox::No|QDialogButtonBox::Yes + + +