Skip to content

Commit

Permalink
Adopt Update dialogs to the new modal widget experience
Browse files Browse the repository at this point in the history
Fixes: #11593
  • Loading branch information
erikjv committed Apr 25, 2024
1 parent b0b7bd8 commit 7213797
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 67 deletions.
16 changes: 11 additions & 5 deletions src/gui/updater/updatedownloadeddialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
namespace OCC {

UpdateDownloadedDialog::UpdateDownloadedDialog(QWidget *parent, const QString &statusMessage)
: QDialog(parent)
: QWidget(parent)
, _ui(new ::Ui::UpdateDownloadedDialog)
{
_ui->setupUi(this);
Expand All @@ -32,8 +32,8 @@ UpdateDownloadedDialog::UpdateDownloadedDialog(QWidget *parent, const QString &s

_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);
Expand All @@ -44,9 +44,15 @@ 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();
}

}
15 changes: 11 additions & 4 deletions src/gui/updater/updatedownloadeddialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,31 @@

#pragma once

#include <QDialog>
#include <QScopedPointer>
#include <QWidget>

namespace Ui {
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;
};

}
128 changes: 70 additions & 58 deletions src/gui/updater/updatedownloadeddialog.ui
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>UpdateDownloadedDialog</class>
<widget class="QDialog" name="UpdateDownloadedDialog">
<widget class="QWidget" name="UpdateDownloadedDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>414</width>
<height>160</height>
<height>414</height>
</rect>
</property>
<property name="sizePolicy">
Expand All @@ -16,77 +16,89 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Update downloaded</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="iconLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>128</width>
<height>0</height>
</size>
</property>
<property name="text">
<string notr="true">icon</string>
<string notr="true">icon (placeholder)</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="headingLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:11pt; font-weight:700;&quot;&gt;Restart required&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="descriptionLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>260</width>
<height>0</height>
</size>
</property>
<property name="text">
<string notr="true">Update soandso has been downloaded. Restart now to perform the update?</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,1,0">
<item>
<widget class="QLabel" name="headingLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:11pt; font-weight:700;&quot;&gt;Restart required&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="descriptionLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>260</width>
<height>0</height>
</size>
</property>
<property name="text">
<string notr="true">Update soandso has been downloaded. Restart now to perform the update?</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::No|QDialogButtonBox::Yes</set>
</property>
</widget>
</item>
</layout>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>277</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::No|QDialogButtonBox::Yes</set>
</property>
</widget>
</item>
</layout>
</widget>
Expand Down

0 comments on commit 7213797

Please sign in to comment.