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 
35 
36 #include <QVBoxLayout>
37 #include <QHBoxLayout>
38 #include <QDialog>
39 #include <QDialogButtonBox>
40 #include <QPushButton>
41 #include <QtDebug>
42 
43 using namespace Core::Internal;
44 
46  : QDialog(parent)
47  , m_view(new ExtensionSystem::PluginView(ExtensionSystem::PluginManager::instance(), this))
48 {
49  QVBoxLayout *vl = new QVBoxLayout(this);
50  vl->addWidget(m_view);
51 
52  m_detailsButton = new QPushButton(tr("Details"), this);
53  m_errorDetailsButton = new QPushButton(tr("Error Details"), this);
54  m_closeButton = new QPushButton(tr("Close"), this);
55  m_detailsButton->setEnabled(false);
56  m_errorDetailsButton->setEnabled(false);
57  m_closeButton->setEnabled(true);
58  m_closeButton->setDefault(true);
59 
60  QHBoxLayout *hl = new QHBoxLayout;
61  hl->addWidget(m_detailsButton);
62  hl->addWidget(m_errorDetailsButton);
63  hl->addStretch(5);
64  hl->addWidget(m_closeButton);
65 
66  vl->addLayout(hl);
67 
68  resize(650, 400);
69  setWindowTitle(tr("Installed Plugins"));
70  setWindowIcon(QIcon(":/core/images/pluginicon.png"));
71 
72  connect(m_view, SIGNAL(currentPluginChanged(ExtensionSystem::PluginSpec *)), this,
73  SLOT(updateButtons()));
74  connect(m_view, SIGNAL(pluginActivated(ExtensionSystem::PluginSpec *)), this,
75  SLOT(openDetails(ExtensionSystem::PluginSpec *)));
76  connect(m_detailsButton, SIGNAL(clicked()), this, SLOT(openDetails()));
77  connect(m_errorDetailsButton, SIGNAL(clicked()), this, SLOT(openErrorDetails()));
78  connect(m_closeButton, SIGNAL(clicked()), this, SLOT(accept()));
79  updateButtons();
80 }
81 
82 void PluginDialog::updateButtons()
83 {
84  ExtensionSystem::PluginSpec *selectedSpec = m_view->currentPlugin();
85  if (selectedSpec) {
86  m_detailsButton->setEnabled(true);
87  m_errorDetailsButton->setEnabled(selectedSpec->hasError());
88  } else {
89  m_detailsButton->setEnabled(false);
90  m_errorDetailsButton->setEnabled(false);
91  }
92 }
93 
94 void PluginDialog::openDetails()
95 {
96  openDetails(m_view->currentPlugin());
97 }
98 
99 void PluginDialog::openDetails(ExtensionSystem::PluginSpec *spec)
100 {
101  if (!spec)
102  return;
103  QDialog dialog(this);
104  dialog.setWindowTitle(tr("Plugin Details of %1").arg(spec->name()));
105  QVBoxLayout *layout = new QVBoxLayout;
106  dialog.setLayout(layout);
108  layout->addWidget(details);
109  details->update(spec);
110  QDialogButtonBox *buttons =
111  new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, &dialog);
112  layout->addWidget(buttons);
113  connect(buttons, SIGNAL(accepted()), &dialog, SLOT(accept()));
114  connect(buttons, SIGNAL(rejected()), &dialog, SLOT(reject()));
115  dialog.resize(400, 500);
116  dialog.exec();
117 }
118 
119 void PluginDialog::openErrorDetails()
120 {
121  ExtensionSystem::PluginSpec *spec = m_view->currentPlugin();
122  if (!spec)
123  return;
124  QDialog dialog(this);
125  dialog.setWindowTitle(tr("Plugin Errors of %1").arg(spec->name()));
126  QVBoxLayout *layout = new QVBoxLayout;
127  dialog.setLayout(layout);
129  layout->addWidget(errors);
130  errors->update(spec);
131  QDialogButtonBox *buttons =
132  new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, &dialog);
133  layout->addWidget(buttons);
134  connect(buttons, SIGNAL(accepted()), &dialog, SLOT(accept()));
135  connect(buttons, SIGNAL(rejected()), &dialog, SLOT(reject()));
136  dialog.resize(500, 300);
137  dialog.exec();
138 }
PluginSpec * currentPlugin() const
Definition: pluginview.cpp:106
Contains the information of the plugins xml description file and information about the plugin's curre...
Definition: pluginspec.h:63
PluginDialog(QWidget *parent)
Widget that displays the state and error message of a PluginSpec.
Widget that displays the contents of a PluginSpec.