diff --git a/src/blackgui/components/settingssimulatorcomponent.cpp b/src/blackgui/components/settingssimulatorcomponent.cpp index 814a73e8a..e8b95ee19 100644 --- a/src/blackgui/components/settingssimulatorcomponent.cpp +++ b/src/blackgui/components/settingssimulatorcomponent.cpp @@ -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 diff --git a/src/blackgui/components/settingssimulatorcomponent.h b/src/blackgui/components/settingssimulatorcomponent.h index 906c37029..a5f914b39 100644 --- a/src/blackgui/components/settingssimulatorcomponent.h +++ b/src/blackgui/components/settingssimulatorcomponent.h @@ -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 diff --git a/src/blackgui/components/settingssimulatorcomponent.ui b/src/blackgui/components/settingssimulatorcomponent.ui index 276b1905e..e8caf06a5 100644 --- a/src/blackgui/components/settingssimulatorcomponent.ui +++ b/src/blackgui/components/settingssimulatorcomponent.ui @@ -22,7 +22,7 @@ 0 - + 2 @@ -382,7 +382,7 @@ Qt::Vertical - QSizePolicy::Maximum + QSizePolicy::MinimumExpanding diff --git a/src/blackgui/infoarea.cpp b/src/blackgui/infoarea.cpp index fee7cd225..3d52133e3 100644 --- a/src/blackgui/infoarea.cpp +++ b/src/blackgui/infoarea.cpp @@ -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; } diff --git a/src/blackgui/plugindetailswindow.cpp b/src/blackgui/plugindetailswindow.cpp new file mode 100644 index 000000000..dd27e25cf --- /dev/null +++ b/src/blackgui/plugindetailswindow.cpp @@ -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 + +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); + } + +} diff --git a/src/blackgui/plugindetailswindow.h b/src/blackgui/plugindetailswindow.h new file mode 100644 index 000000000..44a5425d6 --- /dev/null +++ b/src/blackgui/plugindetailswindow.h @@ -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 + +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; + }; +} // namespace + +#endif // BLACKGUI_PLUGINDETAILSWINDOW_H diff --git a/src/blackgui/plugindetailswindow.ui b/src/blackgui/plugindetailswindow.ui new file mode 100644 index 000000000..95725085c --- /dev/null +++ b/src/blackgui/plugindetailswindow.ui @@ -0,0 +1,112 @@ + + + CPluginDetailsWindow + + + + 0 + 0 + 291 + 170 + + + + %1 - about the plugin + + + + + + + 75 + true + + + + + + + Qt::AlignCenter + + + + + + + + true + + + + + + + Qt::AlignCenter + + + + + + + + + + Qt::AlignHCenter|Qt::AlignTop + + + 10 + + + + + + + + + + Qt::AlignCenter + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Close + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + diff --git a/src/blackgui/pluginselector.cpp b/src/blackgui/pluginselector.cpp index bb3f87018..cbbc2d6eb 100644 --- a/src/blackgui/pluginselector.cpp +++ b/src/blackgui/pluginselector.cpp @@ -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 @@ -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(&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(&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("..."); diff --git a/src/blackgui/pluginselector.h b/src/blackgui/pluginselector.h index e22a83875..1332f5ad0 100644 --- a/src/blackgui/pluginselector.h +++ b/src/blackgui/pluginselector.h @@ -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 +#include -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 diff --git a/src/blackgui/qss/stdwidget.qss b/src/blackgui/qss/stdwidget.qss index 39e45c316..1134ecf1c 100644 --- a/src/blackgui/qss/stdwidget.qss +++ b/src/blackgui/qss/stdwidget.qss @@ -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); diff --git a/src/plugins/simulator/xplane/simulator_xplane.json b/src/plugins/simulator/xplane/simulator_xplane.json index 2d4ba09a7..ee10d8060 100644 --- a/src/plugins/simulator/xplane/simulator_xplane.json +++ b/src/plugins/simulator/xplane/simulator_xplane.json @@ -1,6 +1,6 @@ { "identifier" : "org.swift-project.plugins.simulator.xplane", - "name" : "X-Plane", + "name" : "X-Plane generic plugin", "simulator" : "xplane", - "description" : "X-Plane support via the xbus plugin" + "description" : "Support for the X-Plane simulator via the xbus plugin." } \ No newline at end of file