mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-13 07:35:41 +08:00
refs #443 Added PluginDetailsWindow
* New variable in the json metadata file - simulator name * Added PluginDetailsWindow that shows plugin info
This commit is contained in:
committed by
Mathew Sutcliffe
parent
4d772050b0
commit
584616de7a
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "blackcore/context_simulator.h"
|
||||
#include "blackcore/context_network.h"
|
||||
#include "blackgui/plugindetailswindow.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfolist.h"
|
||||
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
@@ -47,6 +48,7 @@ namespace BlackGui
|
||||
// connects
|
||||
connect(this->getIContextSimulator(), &IContextSimulator::simulatorPluginChanged, this, &CSettingsSimulatorComponent::ps_simulatorPluginChanged);
|
||||
connect(this->ui->ps_EnabledSimulators, &CPluginSelector::pluginStateChanged, this, &CSettingsSimulatorComponent::ps_pluginStateChanged);
|
||||
connect(this->ui->ps_EnabledSimulators, &CPluginSelector::pluginDetailsRequested, this, &CSettingsSimulatorComponent::ps_showPluginDetails);
|
||||
connect(this->ui->pb_ApplyMaxAircraft, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyMaxRenderedAircraft);
|
||||
connect(this->ui->pb_ApplyTimeSync, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyTimeSync);
|
||||
connect(this->ui->pb_ApplyMaxDistance, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyMaxRenderedDistance);
|
||||
@@ -122,6 +124,7 @@ namespace BlackGui
|
||||
if (selected->isUnspecified())
|
||||
{
|
||||
CLogMessage(this).error("Simulator plugin does not exist: %1") << identifier;
|
||||
return;
|
||||
}
|
||||
|
||||
if (enabled)
|
||||
@@ -221,6 +224,7 @@ namespace BlackGui
|
||||
{
|
||||
// disable / enable driver specific GUI parts
|
||||
bool hasFsxDriver = this->getIContextSimulator()->getAvailableSimulatorPlugins().supportsSimulator(QStringLiteral("fsx"));
|
||||
this->ui->comp_SettingsSimulatorFsx->setVisible(hasFsxDriver);
|
||||
|
||||
// I intentionally to not set the selected plugin combobox here
|
||||
// as this would cause undesired rountrips
|
||||
@@ -229,7 +233,6 @@ namespace BlackGui
|
||||
if (!info.isUnspecified())
|
||||
{
|
||||
m_pluginLoaded = true;
|
||||
this->ui->comp_SettingsSimulatorFsx->setVisible(hasFsxDriver);
|
||||
this->ui->lbl_PluginInfo->setText(info.getDescription());
|
||||
}
|
||||
else
|
||||
@@ -239,6 +242,26 @@ namespace BlackGui
|
||||
}
|
||||
this->setGuiValues();
|
||||
}
|
||||
|
||||
void CSettingsSimulatorComponent::ps_showPluginDetails(const QString &identifier)
|
||||
{
|
||||
CSimulatorPluginInfoList simDrivers(getAvailablePlugins());
|
||||
auto selected = std::find_if(simDrivers.begin(), simDrivers.end(),
|
||||
[&identifier](const CSimulatorPluginInfo &info)
|
||||
{
|
||||
return info.getIdentifier() == identifier;
|
||||
});
|
||||
|
||||
QWidget* aw = qApp->activeWindow();
|
||||
|
||||
CPluginDetailsWindow *w = new CPluginDetailsWindow(aw);
|
||||
w->setAttribute(Qt::WA_DeleteOnClose);
|
||||
w->setPluginIdentifier(selected->getIdentifier());
|
||||
w->setPluginName(selected->getName());
|
||||
w->setPluginDescription(selected->getDescription());
|
||||
|
||||
w->show();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -61,6 +61,9 @@ namespace BlackGui
|
||||
//! Simulator plugin changed
|
||||
void ps_simulatorPluginChanged(const BlackMisc::Simulation::CSimulatorPluginInfo &info);
|
||||
|
||||
//! Open plugin details window
|
||||
void ps_showPluginDetails(const QString &identifier);
|
||||
|
||||
private:
|
||||
|
||||
//! Set the GUI values
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_SettingsSimulatorComponent">
|
||||
<layout class="QVBoxLayout" name="vl_SettingsSimulatorComponent" stretch="0,0,1">
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
@@ -382,7 +382,7 @@
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Maximum</enum>
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
||||
@@ -655,6 +655,7 @@ namespace BlackGui
|
||||
int CInfoArea::getAreaIndexByWindowTitle(const QString &title) const
|
||||
{
|
||||
Q_ASSERT_X(!title.isEmpty(), Q_FUNC_INFO, "No title");
|
||||
|
||||
for (int i = 0; i < m_dockWidgetInfoAreas.size(); i++)
|
||||
{
|
||||
if (CGuiUtility::lenientTitleComparison(m_dockWidgetInfoAreas.at(i)->windowTitleOrBackup(), title)) { return i; }
|
||||
|
||||
71
src/blackgui/plugindetailswindow.cpp
Normal file
71
src/blackgui/plugindetailswindow.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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 "plugindetailswindow.h"
|
||||
#include "ui_plugindetailswindow.h"
|
||||
|
||||
#include <QDesktopWidget>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
|
||||
CPluginDetailsWindow::CPluginDetailsWindow(QWidget *parent) :
|
||||
QWidget(parent, Qt::Dialog),
|
||||
ui(new Ui::CPluginDetailsWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
QFont font = ui->lbl_PluginName->font();
|
||||
font.setPointSize(font.pointSize() + 2);
|
||||
ui->lbl_PluginName->setFont(font);
|
||||
|
||||
connect(ui->pb_Close, &QPushButton::clicked, this, &CPluginDetailsWindow::close);
|
||||
}
|
||||
|
||||
CPluginDetailsWindow::~CPluginDetailsWindow()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CPluginDetailsWindow::setPluginName(const QString &name)
|
||||
{
|
||||
ui->lbl_PluginName->setText(name);
|
||||
setWindowTitle(name);
|
||||
}
|
||||
|
||||
void CPluginDetailsWindow::setPluginIdentifier(const QString &id)
|
||||
{
|
||||
ui->lbl_PluginIdentifier->setText(id);
|
||||
}
|
||||
|
||||
void CPluginDetailsWindow::setPluginDescription(const QString &description)
|
||||
{
|
||||
ui->lbl_Description->setText(description);
|
||||
}
|
||||
|
||||
void CPluginDetailsWindow::setPluginAuthors(const QString &authors)
|
||||
{
|
||||
ui->lbl_Authors->setText(authors);
|
||||
}
|
||||
|
||||
void CPluginDetailsWindow::showEvent(QShowEvent *event)
|
||||
{
|
||||
this->setGeometry(
|
||||
QStyle::alignedRect(
|
||||
Qt::LeftToRight,
|
||||
Qt::AlignCenter,
|
||||
this->size(),
|
||||
QDesktopWidget().screenGeometry(qApp->activeWindow())
|
||||
)
|
||||
);
|
||||
|
||||
Q_UNUSED(event);
|
||||
}
|
||||
|
||||
}
|
||||
58
src/blackgui/plugindetailswindow.h
Normal file
58
src/blackgui/plugindetailswindow.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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_PLUGINDETAILSWINDOW_H
|
||||
#define BLACKGUI_PLUGINDETAILSWINDOW_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui { class CPluginDetailsWindow; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
|
||||
/*!
|
||||
* A window that shows plugin details.
|
||||
*/
|
||||
class BLACKGUI_EXPORT CPluginDetailsWindow : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
explicit CPluginDetailsWindow(QWidget *parent = 0);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CPluginDetailsWindow();
|
||||
|
||||
//! Sets the plugin name
|
||||
void setPluginName(const QString &name);
|
||||
|
||||
//! Sets the plugin id
|
||||
void setPluginIdentifier(const QString &id);
|
||||
|
||||
//! Sets the plugin description
|
||||
void setPluginDescription(const QString &description);
|
||||
|
||||
//! Sets the plugin authors
|
||||
void setPluginAuthors(const QString &authors);
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent *event) override;
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CPluginDetailsWindow> ui;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
#endif // BLACKGUI_PLUGINDETAILSWINDOW_H
|
||||
112
src/blackgui/plugindetailswindow.ui
Normal file
112
src/blackgui/plugindetailswindow.ui
Normal file
@@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CPluginDetailsWindow</class>
|
||||
<widget class="QWidget" name="CPluginDetailsWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>291</width>
|
||||
<height>170</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>%1 - about the plugin</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,1,0,0">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_PluginName">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_PluginIdentifier">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_Description">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_Authors">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_Close">
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -1,3 +1,12 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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 "pluginselector.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
@@ -9,12 +18,15 @@
|
||||
namespace BlackGui
|
||||
{
|
||||
|
||||
CPluginSelector::CPluginSelector(QWidget *parent) : QWidget(parent)
|
||||
CPluginSelector::CPluginSelector(QWidget *parent) : QWidget(parent),
|
||||
m_mapper(new QSignalMapper(this))
|
||||
{
|
||||
setObjectName("CPluginSelector");
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
setLayout(layout);
|
||||
|
||||
connect(m_mapper, static_cast<void (QSignalMapper::*)(const QString &)>(&QSignalMapper::mapped), this, &CPluginSelector::pluginDetailsRequested);
|
||||
}
|
||||
|
||||
void CPluginSelector::addPlugin(const QString& identifier, const QString &name, bool enabled)
|
||||
@@ -38,6 +50,14 @@ namespace BlackGui
|
||||
|
||||
pw->layout()->addWidget(cb);
|
||||
|
||||
QPushButton *details = new QPushButton("?");
|
||||
m_mapper->setMapping(details, identifier);
|
||||
connect(details, &QPushButton::clicked, m_mapper, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map));
|
||||
pw->layout()->addWidget(details);
|
||||
|
||||
layout->setStretch(0, 1);
|
||||
layout->setStretch(1, 0);
|
||||
|
||||
/* Might be useful for #392 */
|
||||
#if 0
|
||||
QPushButton *pb = new QPushButton("...");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2014
|
||||
/* Copyright (C) 2015
|
||||
* 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
|
||||
@@ -9,18 +9,20 @@
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef PLUGINSELECTOR_H
|
||||
#define PLUGINSELECTOR_H
|
||||
#ifndef BLACKGUI_PLUGINSELECTOR_H
|
||||
#define BLACKGUI_PLUGINSELECTOR_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QSignalMapper>
|
||||
|
||||
namespace BlackGui {
|
||||
namespace BlackGui
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief The CPluginSelector class is used to select which plugins are to be loaded
|
||||
* and (optionally) configure them.
|
||||
* Shows all available plugins in nice list and lets user enable, disable and configure
|
||||
* each of them.
|
||||
*/
|
||||
class BLACKGUI_EXPORT CPluginSelector : public QWidget
|
||||
{
|
||||
@@ -28,7 +30,10 @@ namespace BlackGui {
|
||||
|
||||
signals:
|
||||
//! Emitted when user enables/disables the particular plugin
|
||||
void pluginStateChanged(QString identifier, bool enabled);
|
||||
void pluginStateChanged(const QString &identifier, bool enabled);
|
||||
|
||||
//! Emitted when user clicks the "Details" button
|
||||
void pluginDetailsRequested(const QString &identifier);
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
@@ -43,8 +48,11 @@ namespace BlackGui {
|
||||
private slots:
|
||||
void ps_handlePluginStateChange();
|
||||
|
||||
private:
|
||||
QSignalMapper *m_mapper;
|
||||
|
||||
};
|
||||
|
||||
} // namespace BlackGui
|
||||
|
||||
#endif // PLUGINSELECTOR_H
|
||||
#endif // BLACKGUI_PLUGINSELECTOR_H
|
||||
|
||||
@@ -111,6 +111,11 @@ BlackGui--Editors--CValidationIndicator {
|
||||
background-image: url(:/textures/icons/textures/texture-inner.jpg);
|
||||
}
|
||||
|
||||
BlackGui--CPluginDetailsWindow {
|
||||
background-image: url(:/textures/icons/textures/texture-inner.jpg);
|
||||
background-color: darkslategray;
|
||||
}
|
||||
|
||||
/** default for buttons **/
|
||||
QPushButton {
|
||||
background-color: rgba(0, 0, 255, 128);
|
||||
|
||||
Reference in New Issue
Block a user