swift
Loading...
Searching...
No Matches
updateinfodialog.cpp
1// SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
4#include "updateinfodialog.h"
5
6#include <QDesktopServices>
7#include <QPushButton>
8
9#include "ui_updateinfodialog.h"
10
11#include "gui/guiapplication.h"
12
13using namespace swift::misc::db;
14
16{
18 {
19 ui->setupUi(this);
20 ui->bb_UpdateInfolDialog->button(QDialogButtonBox::Ok)->setText(" Download and install ");
21 ui->cb_DontShowAgain->setChecked(!m_setting.get());
22 this->selectionChanged();
23 connect(ui->comp_UpdateInfo, &CUpdateInfoComponent::selectionChanged, this,
24 &CUpdateInfoDialog::selectionChanged);
25 connect(ui->cb_DontShowAgain, &QCheckBox::toggled, this, &CUpdateInfoDialog::onDontShowAgain);
26 }
27
29
31 {
32 const bool newVersion = ui->comp_UpdateInfo->isNewPilotClientVersionAvailable();
33 return newVersion;
34 }
35
37 {
38 const int r = QDialog::exec();
39 if (r != QDialog::Accepted)
40 {
41 return r;
42 }
43 if (!ui->comp_UpdateInfo->isNewPilotClientVersionAvailable())
44 {
45 return QDialog::Rejected;
46 }
47 const CDistribution distribution = ui->comp_UpdateInfo->getCurrentDistribution();
48 if (!distribution.hasDownloadUrl())
49 {
50 return QDialog::Rejected;
51 }
52
53 ui->comp_UpdateInfo->triggerDownload();
54 return r;
55 }
56
57 void CUpdateInfoDialog::onDontShowAgain(bool dontShowAgain) { m_setting.setAndSave(!dontShowAgain); }
58
59 void CUpdateInfoDialog::selectionChanged()
60 {
61 const bool nv = ui->comp_UpdateInfo->isNewPilotClientVersionAvailable();
62 ui->bb_UpdateInfolDialog->button(QDialogButtonBox::Ok)->setVisible(nv);
63 }
64} // namespace swift::gui::components
void selectionChanged()
New platfrom or channel.
CUpdateInfoDialog(QWidget *parent=nullptr)
Constructor.
bool isNewVersionAvailable() const
A new version existing?
CStatusMessage setAndSave(const T &value, qint64 timestamp=0)
Write and save in the same step. Must be called from the thread in which the owner lives.
Definition valuecache.h:420
Distributions for channel.
bool hasDownloadUrl() const
Has a download URL?
High level reusable GUI components.
void toggled(bool checked)
QDialog(QWidget *parent, Qt::WindowFlags f)
virtual int exec()
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * parent() const const
QWidget(QWidget *parent, Qt::WindowFlags f)