mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 05:26:45 +08:00
- changed xSwiftBus page and added terrain probe copy Ui as well - component for terrain probe
128 lines
4.5 KiB
C++
128 lines
4.5 KiB
C++
/* 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 "configurationwizard.h"
|
|
#include "ui_configurationwizard.h"
|
|
#include "blackgui/guiapplication.h"
|
|
#include "blackmisc/math/mathutils.h"
|
|
#include "blackmisc/directoryutils.h"
|
|
#include <QPointer>
|
|
|
|
using namespace BlackMisc;
|
|
using namespace BlackMisc::Math;
|
|
|
|
namespace BlackGui
|
|
{
|
|
namespace Components
|
|
{
|
|
CConfigurationWizard::CConfigurationWizard(QWidget *parent) :
|
|
QWizard(parent),
|
|
ui(new Ui::CConfigurationWizard)
|
|
{
|
|
ui->setupUi(this);
|
|
ui->wp_CopyModels->setConfigComponent(ui->comp_CopyModels);
|
|
ui->wp_Simulator->setConfigComponent(ui->comp_Simulator);
|
|
ui->wp_SimulatorSpecific->setConfigComponent(ui->comp_XSwiftBus, ui->comp_FsxTerrainProbe);
|
|
ui->wp_DataLoad->setConfigComponent(ui->comp_DataLoad);
|
|
ui->wp_Hotkeys->setConfigComponent(ui->comp_Hotkeys);
|
|
ui->wp_Legal->setConfigComponent(ui->comp_LegalInformation);
|
|
ui->comp_Hotkeys->registerDummyPttEntry();
|
|
this->setButtonText(CustomButton1, "skip");
|
|
|
|
// no other versions, skip copy pages
|
|
if (!CDirectoryUtils::hasOtherSwiftDataDirectories())
|
|
{
|
|
this->setStartId(ConfigSimulator);
|
|
}
|
|
|
|
const QList<int> ids = this->pageIds();
|
|
const auto mm = std::minmax_element(ids.begin(), ids.end());
|
|
m_maxId = *mm.second;
|
|
m_minId = *mm.first;
|
|
|
|
connect(this, &QWizard::currentIdChanged, this, &CConfigurationWizard::wizardCurrentIdChanged);
|
|
connect(this, &QWizard::customButtonClicked, this, &CConfigurationWizard::clickedCustomButton);
|
|
connect(this, &QWizard::rejected, this, &CConfigurationWizard::ended);
|
|
connect(this, &QWizard::accepted, this, &CConfigurationWizard::ended);
|
|
|
|
Q_ASSERT_X(sGui, Q_FUNC_INFO, "missing sGui");
|
|
const QPointer<CConfigurationWizard> myself(this);
|
|
connect(this, &QWizard::helpRequested, sGui, [ = ]
|
|
{
|
|
if (!myself) { return; }
|
|
if (!sGui || sGui->isShuttingDown()) { return; }
|
|
sGui->showHelp(this);
|
|
});
|
|
}
|
|
|
|
CConfigurationWizard::~CConfigurationWizard()
|
|
{ }
|
|
|
|
bool CConfigurationWizard::lastStepSkipped() const
|
|
{
|
|
return m_skipped;
|
|
}
|
|
|
|
bool CConfigurationWizard::lastWizardStepSkipped(const QWizard *standardWizard)
|
|
{
|
|
const CConfigurationWizard *wizard = qobject_cast<const CConfigurationWizard *>(standardWizard);
|
|
return wizard && wizard->lastStepSkipped();
|
|
}
|
|
|
|
bool CConfigurationWizard::event(QEvent *event)
|
|
{
|
|
if (CGuiApplication::triggerShowHelp(this, event)) { return true; }
|
|
return QDialog::event(event);
|
|
}
|
|
|
|
void CConfigurationWizard::wizardCurrentIdChanged(int id)
|
|
{
|
|
const int previousId = m_previousId;
|
|
const bool backward = id < previousId;
|
|
const bool skipped = m_skipped;
|
|
m_previousId = id; // update
|
|
m_skipped = false; // reset
|
|
Q_UNUSED(skipped);
|
|
Q_UNUSED(backward);
|
|
|
|
this->setParentOpacity(0.5);
|
|
const QWizardPage *page = this->currentPage();
|
|
Q_UNUSED(page);
|
|
|
|
this->setOption(HaveCustomButton1, id != m_maxId);
|
|
}
|
|
|
|
void CConfigurationWizard::clickedCustomButton(int which)
|
|
{
|
|
if (which == static_cast<int>(CustomButton1))
|
|
{
|
|
m_skipped = true;
|
|
this->next();
|
|
}
|
|
else
|
|
{
|
|
m_skipped = false;
|
|
}
|
|
}
|
|
|
|
void CConfigurationWizard::ended()
|
|
{
|
|
this->setParentOpacity(1.0);
|
|
}
|
|
|
|
void CConfigurationWizard::setParentOpacity(qreal opacity)
|
|
{
|
|
QWidget *parent = this->parentWidget();
|
|
if (!parent) { return; }
|
|
if (CMathUtils::epsilonEqual(parent->windowOpacity(), opacity)) { return; }
|
|
parent->setWindowOpacity(opacity);
|
|
}
|
|
} // ns
|
|
} // ns
|