Ref T417, SimBrief download dialog

This commit is contained in:
Klaus Basan
2019-06-28 16:39:58 +02:00
committed by Mat Sutcliffe
parent 88373744f8
commit 179cdb1b6d
3 changed files with 192 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
/* Copyright (C) 2019
* 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. 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 "simbriefdownloaddialog.h"
#include "ui_simbriefdownloaddialog.h"
using namespace BlackMisc::Aviation;
namespace BlackGui
{
namespace Components
{
CSimBriefDownloadDialog::CSimBriefDownloadDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::CSimBriefDownloadDialog)
{
ui->setupUi(this);
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
}
CSimBriefDownloadDialog::~CSimBriefDownloadDialog()
{ }
CSimBriefData CSimBriefDownloadDialog::getSimBriefData() const
{
return CSimBriefData(ui->le_SimBriefURL->text().trimmed(), ui->le_SimBriefUsername->text().trimmed());
}
void CSimBriefDownloadDialog::setSimBriefData(const CSimBriefData &data)
{
ui->le_SimBriefURL->setText(data.getUrl());
ui->le_SimBriefUsername->setText(data.getUsername());
}
int CSimBriefDownloadDialog::exec()
{
this->setSimBriefData(m_simBrief.get());
const int r = QDialog::exec();
if (r == Accepted)
{
m_simBrief.set(this->getSimBriefData());
}
return r;
}
} // ns
} // ns

View File

@@ -0,0 +1,51 @@
/* Copyright (C) 2019
* 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. 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_SIMBRIEFDOWNLOADDIALOG_H
#define BLACKGUI_COMPONENTS_SIMBRIEFDOWNLOADDIALOG_H
#include "blackmisc/aviation/simbriefdata.h"
#include <QDialog>
#include <QScopedPointer>
namespace Ui { class CSimBriefDownloadDialog; }
namespace BlackGui
{
namespace Components
{
//! Download from SimBrief
class CSimBriefDownloadDialog : public QDialog
{
Q_OBJECT
public:
//! Ctor
explicit CSimBriefDownloadDialog(QWidget *parent = nullptr);
//! Dtor
virtual ~CSimBriefDownloadDialog() override;
//! SimBrief data
BlackMisc::Aviation::CSimBriefData getSimBriefData() const;
//! Set UI values from data
void setSimBriefData(const BlackMisc::Aviation::CSimBriefData &data);
//! \copydoc QDialog::exec
virtual int exec() override;
private:
QScopedPointer<Ui::CSimBriefDownloadDialog> ui;
BlackMisc::CData<BlackMisc::Aviation::Data::TSimBriefData> m_simBrief { this };
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CSimBriefDownloadDialog</class>
<widget class="QDialog" name="CSimBriefDownloadDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>100</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>100</height>
</size>
</property>
<property name="windowTitle">
<string>SimBrief download</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="lbl_SimBirefUsername">
<property name="text">
<string>SimBrief username:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="le_SimBriefUsername"/>
</item>
<item row="2" column="0" colspan="2">
<widget class="QDialogButtonBox" name="bb_DownloadDialog">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_SimBriefURL">
<property name="text">
<string>SimBrief URL:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="le_SimBriefURL"/>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>bb_DownloadDialog</sender>
<signal>accepted()</signal>
<receiver>CSimBriefDownloadDialog</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_DownloadDialog</sender>
<signal>rejected()</signal>
<receiver>CSimBriefDownloadDialog</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>