mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 19:05:31 +08:00
Ref T41, independent dialog for downloading swift
This commit is contained in:
committed by
Mathew Sutcliffe
parent
8ac609a166
commit
d1bf788f07
62
src/blackgui/components/downloadandinstalldialog.cpp
Normal file
62
src/blackgui/components/downloadandinstalldialog.cpp
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/* Copyright (C) 2017
|
||||||
|
* swift project Community / Contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "downloadandinstalldialog.h"
|
||||||
|
#include "ui_downloadandinstalldialog.h"
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
|
||||||
|
using namespace BlackMisc::Db;
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
class COverlayMessagesFrame;
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
CDownloadAndInstallDialog::CDownloadAndInstallDialog(QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::CDownloadAndInstallDialog)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
ui->bb_DownloadInstallDialog->button(QDialogButtonBox::Ok)->setText("Download and install");
|
||||||
|
this->selectionChanged();
|
||||||
|
connect(ui->comp_DistributionInfo, &CDistributionInfoComponent::selectionChanged, this, &CDownloadAndInstallDialog::selectionChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
CDownloadAndInstallDialog::~CDownloadAndInstallDialog()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
bool CDownloadAndInstallDialog::isNewVersionAvailable() const
|
||||||
|
{
|
||||||
|
const bool newVersion = ui->comp_DistributionInfo->isNewVersionAvailable();
|
||||||
|
return newVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CDownloadAndInstallDialog::exec()
|
||||||
|
{
|
||||||
|
const int r = QDialog::exec();
|
||||||
|
if (r != QDialog::Accepted) return r;
|
||||||
|
if (!ui->comp_DistributionInfo->isNewVersionAvailable()) { return QDialog::Rejected; }
|
||||||
|
const CDistribution distribution = ui->comp_DistributionInfo->getCurrentDistribution();
|
||||||
|
if (!distribution.hasDownloadUrls()) { return QDialog::Rejected; }
|
||||||
|
|
||||||
|
// in future, start download and close application
|
||||||
|
// for now, just open URL
|
||||||
|
QDesktopServices::openUrl(distribution.getDownloadUrls().getRandomUrl());
|
||||||
|
return QDialog::Rejected;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDownloadAndInstallDialog::selectionChanged()
|
||||||
|
{
|
||||||
|
const bool nv = ui->comp_DistributionInfo->isNewVersionAvailable();
|
||||||
|
ui->bb_DownloadInstallDialog->button(QDialogButtonBox::Ok)->setEnabled(nv);
|
||||||
|
}
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
52
src/blackgui/components/downloadandinstalldialog.h
Normal file
52
src/blackgui/components/downloadandinstalldialog.h
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/* Copyright (C) 2017
|
||||||
|
* swift project Community / Contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
|
#ifndef BLACKGUI_COMPONENTS_DOWNLOADANDINSTALLDIALOG_H
|
||||||
|
#define BLACKGUI_COMPONENTS_DOWNLOADANDINSTALLDIALOG_H
|
||||||
|
|
||||||
|
#include "blackgui/blackguiexport.h"
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
namespace Ui { class CDownloadAndInstallDialog; }
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Download and install swift
|
||||||
|
*/
|
||||||
|
class BLACKGUI_EXPORT CDownloadAndInstallDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! Constructor
|
||||||
|
explicit CDownloadAndInstallDialog(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
//! Destructor
|
||||||
|
virtual ~CDownloadAndInstallDialog();
|
||||||
|
|
||||||
|
//! A new version existing?
|
||||||
|
bool isNewVersionAvailable() const;
|
||||||
|
|
||||||
|
//! \copydoc QDialog::exec
|
||||||
|
virtual int exec() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QScopedPointer<Ui::CDownloadAndInstallDialog> ui;
|
||||||
|
|
||||||
|
//! Selection in distribution component changed
|
||||||
|
void selectionChanged();
|
||||||
|
};
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
88
src/blackgui/components/downloadandinstalldialog.ui
Normal file
88
src/blackgui/components/downloadandinstalldialog.ui
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>CDownloadAndInstallDialog</class>
|
||||||
|
<widget class="QDialog" name="CDownloadAndInstallDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>125</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Update checker</string>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
<property name="modal">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="vl_DownloadAndInstall">
|
||||||
|
<item>
|
||||||
|
<widget class="BlackGui::Components::CDistributionInfoComponent" name="comp_DistributionInfo">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="bb_DownloadInstallDialog">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>BlackGui::Components::CDistributionInfoComponent</class>
|
||||||
|
<extends>QFrame</extends>
|
||||||
|
<header>blackgui/components/distributioninfocomponent.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>bb_DownloadInstallDialog</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>CDownloadAndInstallDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>bb_DownloadInstallDialog</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>CDownloadAndInstallDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
||||||
Reference in New Issue
Block a user