| 1 |
/****************************************************************************** |
| 2 |
This source file is part of the Avogadro project. |
| 3 |
This source code is released under the 3-Clause BSD License, (see "LICENSE"). |
| 4 |
******************************************************************************/ |
| 5 |
|
| 6 |
#include "packageinstaller.h" |
| 7 |
#include "packagemanagerdialog.h" |
| 8 |
|
| 9 |
#include <QAction> |
| 10 |
|
| 11 |
namespace Avogadro::QtPlugins { |
| 12 |
|
| 13 |
PackageInstaller::PackageInstaller(QObject* parent_) |
| 14 |
: ExtensionPlugin(parent_), m_action(new QAction(this)) |
| 15 |
{ |
| 16 |
m_action->setEnabled(true); |
| 17 |
m_action->setText(tr("Manage Plugins…")); |
| 18 |
m_action->setProperty("menu priority", 520); |
| 19 |
connect(m_action, &QAction::triggered, this, &PackageInstaller::showDialog); |
| 20 |
} |
| 21 |
|
| 22 |
PackageInstaller::~PackageInstaller() |
| 23 |
{ |
| 24 |
if (m_dialog) |
| 25 |
m_dialog->deleteLater(); |
| 26 |
} |
| 27 |
|
| 28 |
QList<QAction*> PackageInstaller::actions() const |
| 29 |
{ |
| 30 |
return { m_action }; |
| 31 |
} |
| 32 |
|
| 33 |
QStringList PackageInstaller::menuPath(QAction*) const |
| 34 |
{ |
| 35 |
return { tr("&Extensions") }; |
| 36 |
} |
| 37 |
|
| 38 |
void PackageInstaller::showDialog() |
| 39 |
{ |
| 40 |
if (m_dialog == nullptr) |
| 41 |
m_dialog = new PackageManagerDialog(qobject_cast<QWidget*>(parent())); |
| 42 |
m_dialog->show(); |
| 43 |
m_dialog->raise(); |
| 44 |
m_dialog->activateWindow(); |
| 45 |
} |
| 46 |
|
| 47 |
} // namespace Avogadro::QtPlugins |