Conditionally limit UI login modes in case no simulator is attached

Currently the logic to fall back to observer login, in case no
simulator is attached, is implemented in core. Apart from a log message
there was no clear feedback to the user what has happened.
With this commit, the pilot related login modes are disabled if no
simulator is attached. A tool tip explains the reason.
This is enabled only for shipped versions.

refs #872
This commit is contained in:
Roland Winklmeier
2017-01-28 00:50:46 +01:00
committed by Mathew Sutcliffe
parent a7635a7e13
commit d0cdae7356
2 changed files with 31 additions and 0 deletions

View File

@@ -7,12 +7,17 @@
* contained in the LICENSE file.
*/
#include "blackconfig/buildconfig.h"
#include "blackgui/loginmodebuttons.h"
#include "blackgui/guiapplication.h"
#include "blackcore/context/contextsimulator.h"
#include "ui_loginmodebuttons.h"
#include <QRadioButton>
using namespace BlackConfig;
using namespace BlackCore;
using namespace BlackCore::Context;
namespace BlackGui
{
@@ -21,6 +26,9 @@ namespace BlackGui
ui(new Ui::CLoginModeButtons)
{
ui->setupUi(this);
configureLoginModes();
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged,
this, &CLoginModeButtons::configureLoginModes);
}
CLoginModeButtons::~CLoginModeButtons()
@@ -56,4 +64,25 @@ namespace BlackGui
break;
}
}
void CLoginModeButtons::configureLoginModes()
{
if(CBuildConfig::isShippedVersion() && !sGui->getIContextSimulator()->isSimulatorSimulating())
{
// Disable pilot login modes
ui->rb_LoginNormal->setEnabled(false);
ui->rb_LoginStealth->setEnabled(false);
ui->rb_LoginNormal->setToolTip("No simulator available");
ui->rb_LoginStealth->setToolTip("No simulator available");
ui->rb_LoginObserver->setChecked(true);
}
else
{
ui->rb_LoginNormal->setEnabled(true);
ui->rb_LoginStealth->setEnabled(true);
ui->rb_LoginNormal->setToolTip({});
ui->rb_LoginStealth->setToolTip({});
ui->rb_LoginNormal->setChecked(true);
}
}
}

View File

@@ -44,6 +44,8 @@ namespace BlackGui
void setLoginMode(BlackCore::INetwork::LoginMode mode);
private:
void configureLoginModes();
QScopedPointer<Ui::CLoginModeButtons> ui;
};
}