Marble

MarblePluginSettingsWidget.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2007 Torsten Rahn <rahn@kde.org>
4// SPDX-FileCopyrightText: 2008 Jens-Michael Hoffmann <jensmh@gmx.de>
5//
6
8#include "ui_MarblePluginSettingsWidget.h"
9
10// Qt
11#include <QPointer>
12#include <QDialog>
13
14// Marble
15#include "DialogConfigurationInterface.h"
16#include "PluginAboutDialog.h"
17#include "PluginItemDelegate.h"
18#include "RenderPluginModel.h"
19
20namespace Marble
21{
22
23class MarblePluginSettingsWidgetPrivate : public Ui::MarblePluginSettingsWidget
24{
25 public:
26 explicit MarblePluginSettingsWidgetPrivate( Marble::MarblePluginSettingsWidget *parent ) :
27 q( parent ),
28 m_itemDelegate( nullptr )
29 {}
30
31 /**
32 * Shows the about dialog for the plugin with the corresponding @p nameId.
33 */
34 void showPluginAboutDialog( const QModelIndex &index );
35
36 /**
37 * Shows the configuration dialog for the plugin with the corresponding @p nameId.
38 */
39 void showPluginConfigDialog( const QModelIndex &index );
40
41 Marble::MarblePluginSettingsWidget *const q;
42 PluginItemDelegate *m_itemDelegate;
43 QPointer<RenderPluginModel> m_pluginModel;
44};
45
46void MarblePluginSettingsWidgetPrivate::showPluginAboutDialog( const QModelIndex &index )
47{
48 if ( m_pluginModel.isNull() )
49 return;
50
51 QPointer<PluginAboutDialog> aboutDialog = new PluginAboutDialog( q );
52
53 aboutDialog->setName( m_pluginModel->data( index, RenderPluginModel::Name ).toString() );
54 aboutDialog->setIcon( qvariant_cast<QIcon>( m_pluginModel->data( index, RenderPluginModel::Icon ) ) );
55 aboutDialog->setVersion( m_pluginModel->data( index, RenderPluginModel::Version ).toString() );
56 aboutDialog->setDataText( m_pluginModel->data( index, RenderPluginModel::AboutDataText ).toString() );
57 const QString copyrightText = QObject::tr( "<br/>(c) %1 The Marble Project<br /><br/><a href=\"https://edu.kde.org/marble\">https://edu.kde.org/marble</a>" );
58 aboutDialog->setAboutText( copyrightText.arg( m_pluginModel->data( index, RenderPluginModel::CopyrightYears ).toString() ) );
59 aboutDialog->setAuthors( m_pluginModel->pluginAuthors( index ) );
60
61 aboutDialog->exec();
62 delete aboutDialog;
63}
64
65void MarblePluginSettingsWidgetPrivate::showPluginConfigDialog( const QModelIndex &index )
66{
67 if ( m_pluginModel.isNull() )
68 return;
69
70 DialogConfigurationInterface *configInterface = m_pluginModel->pluginDialogConfigurationInterface( index );
71 QDialog *configDialog = configInterface ? configInterface->configDialog() : nullptr;
72 if ( configDialog ) {
73 configDialog->show();
74 }
75}
76
77MarblePluginSettingsWidget::MarblePluginSettingsWidget( QWidget *parent )
78 : QWidget( parent ),
79 d( new MarblePluginSettingsWidgetPrivate( this ) )
80{
81 d->setupUi( this );
82
83 d->m_itemDelegate = new PluginItemDelegate( d->m_pluginListView, this );
84 d->m_pluginListView->setItemDelegate( d->m_itemDelegate );
85 connect( d->m_itemDelegate, SIGNAL(aboutPluginClicked(QModelIndex)),
86 this, SLOT(showPluginAboutDialog(QModelIndex)) );
87 connect( d->m_itemDelegate, SIGNAL(configPluginClicked(QModelIndex)),
88 this, SLOT(showPluginConfigDialog(QModelIndex)) );
89}
90
91void MarblePluginSettingsWidget::setAboutIcon( const QIcon& icon )
92{
93 d->m_itemDelegate->setAboutIcon( icon );
94}
95
96MarblePluginSettingsWidget::~MarblePluginSettingsWidget()
97{
98 delete d;
99}
100
101void MarblePluginSettingsWidget::setConfigIcon( const QIcon& icon )
102{
103 d->m_itemDelegate->setConfigIcon( icon );
104}
105
106void MarblePluginSettingsWidget::setModel( RenderPluginModel* pluginModel )
107{
108 if ( !d->m_pluginModel.isNull() ) {
109 disconnect( d->m_pluginModel.data(), nullptr, this, nullptr );
110 }
111
112 d->m_pluginModel = pluginModel;
113 d->m_pluginListView->setModel( pluginModel );
114
115 if ( !d->m_pluginModel.isNull() ) {
116 connect( d->m_pluginModel.data(), SIGNAL(itemChanged(QStandardItem*)),
117 this, SIGNAL(pluginListViewClicked()) );
118 }
119}
120
121} // namespace Marble
122
123#include "moc_MarblePluginSettingsWidget.cpp"
This file contains the multiple inheritance ui-wrapper for the MarblePluginSettingsWidget ui file.
Binds a QML item to a specific geodetic location in screen coordinates.
QString tr(const char *sourceText, const char *disambiguation, int n)
QString arg(Args &&... args) const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void setupUi(QWidget *widget)
void show()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:54:17 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.