dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
plugindialog.cpp
Go to the documentation of this file.
1 
13 /*
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  * for more details.
23  *
24  * You should have received a copy of the GNU General Public License along
25  * with this program; if not, see <http://www.gnu.org/licenses/>
26  */
27 
28 #include "plugindialog.h"
29 
33 
34 #include <QtGui/QVBoxLayout>
35 #include <QtGui/QHBoxLayout>
36 #include <QtGui/QDialog>
37 #include <QtGui/QDialogButtonBox>
38 #include <QtGui/QApplication>
39 #include <QtDebug>
40 
42  : m_view(new ExtensionSystem::PluginView(manager, this))
43 {
44  QVBoxLayout *vl = new QVBoxLayout(this);
45  vl->setMargin(0);
46  vl->setSpacing(0);
47  vl->addWidget(m_view);
48 
49  QHBoxLayout *hl = new QHBoxLayout;
50  vl->addLayout(hl);
51  hl->setMargin(0);
52  hl->setSpacing(6);
53  m_detailsButton = new QPushButton(tr("Details"), this);
54  m_errorDetailsButton = new QPushButton(tr("Error Details"), this);
55  m_detailsButton->setEnabled(false);
56  m_errorDetailsButton->setEnabled(false);
57  hl->addWidget(m_detailsButton);
58  hl->addWidget(m_errorDetailsButton);
59  hl->addStretch(5);
60  resize(650, 300);
61  setWindowTitle(tr("Installed Plugins"));
62 
63  connect(m_view, SIGNAL(currentPluginChanged(ExtensionSystem::PluginSpec*)),
64  this, SLOT(updateButtons()));
65  connect(m_view, SIGNAL(pluginActivated(ExtensionSystem::PluginSpec*)),
66  this, SLOT(openDetails(ExtensionSystem::PluginSpec*)));
67  connect(m_detailsButton, SIGNAL(clicked()), this, SLOT(openDetails()));
68  connect(m_errorDetailsButton, SIGNAL(clicked()), this, SLOT(openErrorDetails()));
69 }
70 
71 void PluginDialog::updateButtons()
72 {
73  ExtensionSystem::PluginSpec *selectedSpec = m_view->currentPlugin();
74  if (selectedSpec) {
75  m_detailsButton->setEnabled(true);
76  m_errorDetailsButton->setEnabled(selectedSpec->hasError());
77  } else {
78  m_detailsButton->setEnabled(false);
79  m_errorDetailsButton->setEnabled(false);
80  }
81 }
82 
83 
84 void PluginDialog::openDetails()
85 {
86  openDetails(m_view->currentPlugin());
87 }
88 
89 void PluginDialog::openDetails(ExtensionSystem::PluginSpec *spec)
90 {
91  if (!spec)
92  return;
93  QDialog dialog(this);
94  dialog.setWindowTitle(tr("Plugin Details of %1").arg(spec->name()));
95  QVBoxLayout *layout = new QVBoxLayout;
96  dialog.setLayout(layout);
98  layout->addWidget(details);
99  details->update(spec);
100  QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, &dialog);
101  layout->addWidget(buttons);
102  connect(buttons, SIGNAL(accepted()), &dialog, SLOT(accept()));
103  connect(buttons, SIGNAL(rejected()), &dialog, SLOT(reject()));
104  dialog.resize(400, 500);
105  dialog.exec();
106 }
107 
108 void PluginDialog::openErrorDetails()
109 {
110  ExtensionSystem::PluginSpec *spec = m_view->currentPlugin();
111  if (!spec)
112  return;
113  QDialog dialog(this);
114  dialog.setWindowTitle(tr("Plugin Errors of %1").arg(spec->name()));
115  QVBoxLayout *layout = new QVBoxLayout;
116  dialog.setLayout(layout);
118  layout->addWidget(errors);
119  errors->update(spec);
120  QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, &dialog);
121  layout->addWidget(buttons);
122  connect(buttons, SIGNAL(accepted()), &dialog, SLOT(accept()));
123  connect(buttons, SIGNAL(rejected()), &dialog, SLOT(reject()));
124  dialog.resize(500, 300);
125  dialog.exec();
126 }
127 
128 int main(int argc, char *argv[])
129 {
131  QApplication app(argc, argv);
132  PluginDialog dialog(&manager);
133  manager.setPluginPaths(QStringList() << "plugins");
134  manager.loadPlugins();
135  dialog.show();
136  app.exec();
137 }
PluginSpec * currentPlugin() const
Definition: pluginview.cpp:106
Core plugin system that manages the plugins, their life cycle and their registered objects...
Definition: pluginmanager.h:53
PluginDialog(ExtensionSystem::PluginManager *manager)
Contains the information of the plugins xml description file and information about the plugin's curre...
Definition: pluginspec.h:63
int main(int argc, char *argv[])
Widget that displays the state and error message of a PluginSpec.
Widget that displays the contents of a PluginSpec.